1// -*- C++ -*-
2//===------------------------ type_traits ---------------------------------===//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_TYPE_TRAITS
12#define _LIBCPP_TYPE_TRAITS
13
14/*
15    type_traits synopsis
16
17namespace std
18{
19
20    // helper class:
21    template <class T, T v> struct integral_constant;
22    typedef integral_constant<bool, true>  true_type;
23    typedef integral_constant<bool, false> false_type;
24
25    // helper traits
26    template <bool, class T = void> struct enable_if;
27    template <bool, class T, class F> struct conditional;
28
29    // Primary classification traits:
30    template <class T> struct is_void;
31    template <class T> struct is_null_pointer;  // C++14
32    template <class T> struct is_integral;
33    template <class T> struct is_floating_point;
34    template <class T> struct is_array;
35    template <class T> struct is_pointer;
36    template <class T> struct is_lvalue_reference;
37    template <class T> struct is_rvalue_reference;
38    template <class T> struct is_member_object_pointer;
39    template <class T> struct is_member_function_pointer;
40    template <class T> struct is_enum;
41    template <class T> struct is_union;
42    template <class T> struct is_class;
43    template <class T> struct is_function;
44
45    // Secondary classification traits:
46    template <class T> struct is_reference;
47    template <class T> struct is_arithmetic;
48    template <class T> struct is_fundamental;
49    template <class T> struct is_member_pointer;
50    template <class T> struct is_scalar;
51    template <class T> struct is_object;
52    template <class T> struct is_compound;
53
54    // Const-volatile properties and transformations:
55    template <class T> struct is_const;
56    template <class T> struct is_volatile;
57    template <class T> struct remove_const;
58    template <class T> struct remove_volatile;
59    template <class T> struct remove_cv;
60    template <class T> struct add_const;
61    template <class T> struct add_volatile;
62    template <class T> struct add_cv;
63
64    // Reference transformations:
65    template <class T> struct remove_reference;
66    template <class T> struct add_lvalue_reference;
67    template <class T> struct add_rvalue_reference;
68
69    // Pointer transformations:
70    template <class T> struct remove_pointer;
71    template <class T> struct add_pointer;
72
73    // Integral properties:
74    template <class T> struct is_signed;
75    template <class T> struct is_unsigned;
76    template <class T> struct make_signed;
77    template <class T> struct make_unsigned;
78
79    // Array properties and transformations:
80    template <class T> struct rank;
81    template <class T, unsigned I = 0> struct extent;
82    template <class T> struct remove_extent;
83    template <class T> struct remove_all_extents;
84
85    // Member introspection:
86    template <class T> struct is_pod;
87    template <class T> struct is_trivial;
88    template <class T> struct is_trivially_copyable;
89    template <class T> struct is_standard_layout;
90    template <class T> struct is_literal_type;
91    template <class T> struct is_empty;
92    template <class T> struct is_polymorphic;
93    template <class T> struct is_abstract;
94    template <class T> struct is_final; // C++14
95
96    template <class T, class... Args> struct is_constructible;
97    template <class T>                struct is_default_constructible;
98    template <class T>                struct is_copy_constructible;
99    template <class T>                struct is_move_constructible;
100    template <class T, class U>       struct is_assignable;
101    template <class T>                struct is_copy_assignable;
102    template <class T>                struct is_move_assignable;
103    template <class T>                struct is_destructible;
104
105    template <class T, class... Args> struct is_trivially_constructible;
106    template <class T>                struct is_trivially_default_constructible;
107    template <class T>                struct is_trivially_copy_constructible;
108    template <class T>                struct is_trivially_move_constructible;
109    template <class T, class U>       struct is_trivially_assignable;
110    template <class T>                struct is_trivially_copy_assignable;
111    template <class T>                struct is_trivially_move_assignable;
112    template <class T>                struct is_trivially_destructible;
113
114    template <class T, class... Args> struct is_nothrow_constructible;
115    template <class T>                struct is_nothrow_default_constructible;
116    template <class T>                struct is_nothrow_copy_constructible;
117    template <class T>                struct is_nothrow_move_constructible;
118    template <class T, class U>       struct is_nothrow_assignable;
119    template <class T>                struct is_nothrow_copy_assignable;
120    template <class T>                struct is_nothrow_move_assignable;
121    template <class T>                struct is_nothrow_destructible;
122
123    template <class T> struct has_virtual_destructor;
124
125    // Relationships between types:
126    template <class T, class U> struct is_same;
127    template <class Base, class Derived> struct is_base_of;
128    template <class From, class To> struct is_convertible;
129
130    // Alignment properties and transformations:
131    template <class T> struct alignment_of;
132    template <size_t Len, size_t Align = most_stringent_alignment_requirement>
133        struct aligned_storage;
134    template <size_t Len, class... Types> struct aligned_union;
135
136    template <class T> struct decay;
137    template <class... T> struct common_type;
138    template <class T> struct underlying_type;
139    template <class> class result_of; // undefined
140    template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
141
142    // const-volatile modifications:
143    template <class T>
144      using remove_const_t    = typename remove_const<T>::type;  // C++14
145    template <class T>
146      using remove_volatile_t = typename remove_volatile<T>::type;  // C++14
147    template <class T>
148      using remove_cv_t       = typename remove_cv<T>::type;  // C++14
149    template <class T>
150      using add_const_t       = typename add_const<T>::type;  // C++14
151    template <class T>
152      using add_volatile_t    = typename add_volatile<T>::type;  // C++14
153    template <class T>
154      using add_cv_t          = typename add_cv<T>::type;  // C++14
155  
156    // reference modifications:
157    template <class T>
158      using remove_reference_t     = typename remove_reference<T>::type;  // C++14
159    template <class T>
160      using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;  // C++14
161    template <class T>
162      using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;  // C++14
163  
164    // sign modifications:
165    template <class T>
166      using make_signed_t   = typename make_signed<T>::type;  // C++14
167    template <class T>
168      using make_unsigned_t = typename make_unsigned<T>::type;  // C++14
169  
170    // array modifications:
171    template <class T>
172      using remove_extent_t      = typename remove_extent<T>::type;  // C++14
173    template <class T>
174      using remove_all_extents_t = typename remove_all_extents<T>::type;  // C++14
175
176    // pointer modifications:
177    template <class T>
178      using remove_pointer_t = typename remove_pointer<T>::type;  // C++14
179    template <class T>
180      using add_pointer_t    = typename add_pointer<T>::type;  // C++14
181
182    // other transformations:
183    template <size_t Len, std::size_t Align=default-alignment>
184      using aligned_storage_t = typename aligned_storage<Len,Align>::type;  // C++14
185    template <std::size_t Len, class... Types>
186      using aligned_union_t   = typename aligned_union<Len,Types...>::type;  // C++14
187    template <class T>
188      using decay_t           = typename decay<T>::type;  // C++14
189    template <bool b, class T=void>
190      using enable_if_t       = typename enable_if<b,T>::type;  // C++14
191    template <bool b, class T, class F>
192      using conditional_t     = typename conditional<b,T,F>::type;  // C++14
193    template <class... T>
194      using common_type_t     = typename common_type<T...>::type;  // C++14
195    template <class T>
196      using underlying_type_t = typename underlying_type<T>::type;  // C++14
197    template <class F, class... ArgTypes>
198      using result_of_t       = typename result_of<F(ArgTypes...)>::type;  // C++14
199
200    template <class...>
201      using void_t = void;
202}  // C++17
203
204*/
205#include <__config>
206#include <cstddef>
207
208#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
209#pragma GCC system_header
210#endif
211
212_LIBCPP_BEGIN_NAMESPACE_STD
213
214#ifndef _LIBCPP_HAS_NO_VARIADICS
215template <class...> 
216struct __void_t { typedef void type; };
217#endif
218
219template <bool _Bp, class _If, class _Then>
220    struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
221template <class _If, class _Then>
222    struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
223
224#if _LIBCPP_STD_VER > 11
225template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
226#endif
227
228template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
229template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
230
231template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
232template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
233
234#if _LIBCPP_STD_VER > 11
235template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
236#endif
237
238
239struct __two {char __lx[2];};
240
241// helper class:
242
243template <class _Tp, _Tp __v>
244struct _LIBCPP_TYPE_VIS_ONLY integral_constant
245{
246    static _LIBCPP_CONSTEXPR const _Tp      value = __v;
247    typedef _Tp               value_type;
248    typedef integral_constant type;
249    _LIBCPP_INLINE_VISIBILITY
250        _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
251#if _LIBCPP_STD_VER > 11
252    _LIBCPP_INLINE_VISIBILITY
253         constexpr value_type operator ()() const _NOEXCEPT {return value;}
254#endif
255};
256
257template <class _Tp, _Tp __v>
258_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
259
260typedef integral_constant<bool, true>  true_type;
261typedef integral_constant<bool, false> false_type;
262
263// is_const
264
265template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const            : public false_type {};
266template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
267
268// is_volatile
269
270template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile               : public false_type {};
271template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
272
273// remove_const
274
275template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const            {typedef _Tp type;};
276template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
277#if _LIBCPP_STD_VER > 11
278template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
279#endif
280
281// remove_volatile
282
283template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile               {typedef _Tp type;};
284template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
285#if _LIBCPP_STD_VER > 11
286template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
287#endif
288
289// remove_cv
290
291template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
292{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
293#if _LIBCPP_STD_VER > 11
294template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
295#endif
296
297// is_void
298
299template <class _Tp> struct __libcpp_is_void       : public false_type {};
300template <>          struct __libcpp_is_void<void> : public true_type {};
301
302template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
303    : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
304
305// __is_nullptr_t
306
307template <class _Tp> struct __is_nullptr_t_impl       : public false_type {};
308template <>          struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
309
310template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
311    : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
312
313#if _LIBCPP_STD_VER > 11
314template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
315    : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
316#endif
317
318// is_integral
319
320template <class _Tp> struct __libcpp_is_integral                     : public false_type {};
321template <>          struct __libcpp_is_integral<bool>               : public true_type {};
322template <>          struct __libcpp_is_integral<char>               : public true_type {};
323template <>          struct __libcpp_is_integral<signed char>        : public true_type {};
324template <>          struct __libcpp_is_integral<unsigned char>      : public true_type {};
325template <>          struct __libcpp_is_integral<wchar_t>            : public true_type {};
326#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
327template <>          struct __libcpp_is_integral<char16_t>           : public true_type {};
328template <>          struct __libcpp_is_integral<char32_t>           : public true_type {};
329#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
330template <>          struct __libcpp_is_integral<short>              : public true_type {};
331template <>          struct __libcpp_is_integral<unsigned short>     : public true_type {};
332template <>          struct __libcpp_is_integral<int>                : public true_type {};
333template <>          struct __libcpp_is_integral<unsigned int>       : public true_type {};
334template <>          struct __libcpp_is_integral<long>               : public true_type {};
335template <>          struct __libcpp_is_integral<unsigned long>      : public true_type {};
336template <>          struct __libcpp_is_integral<long long>          : public true_type {};
337template <>          struct __libcpp_is_integral<unsigned long long> : public true_type {};
338#ifndef _LIBCPP_HAS_NO_INT128
339template <>          struct __libcpp_is_integral<__int128_t>         : public true_type {};
340template <>          struct __libcpp_is_integral<__uint128_t>        : public true_type {};
341#endif
342
343template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
344    : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
345
346// is_floating_point
347
348template <class _Tp> struct __libcpp_is_floating_point              : public false_type {};
349template <>          struct __libcpp_is_floating_point<float>       : public true_type {};
350template <>          struct __libcpp_is_floating_point<double>      : public true_type {};
351template <>          struct __libcpp_is_floating_point<long double> : public true_type {};
352
353template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
354    : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
355
356// is_array
357
358template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
359    : public false_type {};
360template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
361    : public true_type {};
362template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
363    : public true_type {};
364
365// is_pointer
366
367template <class _Tp> struct __libcpp_is_pointer       : public false_type {};
368template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
369
370template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
371    : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
372
373// is_reference
374
375template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference       : public false_type {};
376template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
377
378template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference        : public false_type {};
379#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
380template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
381#endif
382
383template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference        : public false_type {};
384template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&>  : public true_type {};
385#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
386template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
387#endif
388
389// is_union
390
391#if __has_feature(is_union) || (_GNUC_VER >= 403)
392
393template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
394    : public integral_constant<bool, __is_union(_Tp)> {};
395
396#else
397
398template <class _Tp> struct __libcpp_union : public false_type {};
399template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
400    : public __libcpp_union<typename remove_cv<_Tp>::type> {};
401
402#endif
403
404// is_class
405
406#if __has_feature(is_class) || (_GNUC_VER >= 403)
407
408template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
409    : public integral_constant<bool, __is_class(_Tp)> {};
410
411#else
412
413namespace __is_class_imp
414{
415template <class _Tp> char  __test(int _Tp::*);
416template <class _Tp> __two __test(...);
417}
418
419template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
420    : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
421
422#endif
423
424// is_same
425
426template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same           : public false_type {};
427template <class _Tp>            struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
428
429// is_function
430
431namespace __libcpp_is_function_imp
432{
433template <class _Tp> char  __test(_Tp*);
434template <class _Tp> __two __test(...);
435template <class _Tp> _Tp&  __source();
436}
437
438template <class _Tp, bool = is_class<_Tp>::value ||
439                            is_union<_Tp>::value ||
440                            is_void<_Tp>::value  ||
441                            is_reference<_Tp>::value ||
442                            __is_nullptr_t<_Tp>::value >
443struct __libcpp_is_function
444    : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>())) == 1>
445    {};
446template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
447
448template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
449    : public __libcpp_is_function<_Tp> {};
450
451// is_member_function_pointer
452
453// template <class _Tp> struct            __libcpp_is_member_function_pointer             : public false_type {};
454// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
455// 
456
457template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
458struct __member_pointer_traits_imp
459{  // forward declaration; specializations later
460};
461
462
463namespace __libcpp_is_member_function_pointer_imp {
464    template <typename _Tp>
465    char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *);
466
467    template <typename>
468    std::__two __test(...);
469};
470    
471template <class _Tp> struct __libcpp_is_member_function_pointer
472    : public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {};
473
474template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
475    : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
476
477// is_member_pointer
478
479template <class _Tp>            struct __libcpp_is_member_pointer             : public false_type {};
480template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
481
482template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
483    : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
484
485// is_member_object_pointer
486
487template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
488    : public integral_constant<bool, is_member_pointer<_Tp>::value &&
489                                    !is_member_function_pointer<_Tp>::value> {};
490
491// is_enum
492
493#if __has_feature(is_enum) || (_GNUC_VER >= 403)
494
495template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
496    : public integral_constant<bool, __is_enum(_Tp)> {};
497
498#else
499
500template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
501    : public integral_constant<bool, !is_void<_Tp>::value             &&
502                                     !is_integral<_Tp>::value         &&
503                                     !is_floating_point<_Tp>::value   &&
504                                     !is_array<_Tp>::value            &&
505                                     !is_pointer<_Tp>::value          &&
506                                     !is_reference<_Tp>::value        &&
507                                     !is_member_pointer<_Tp>::value   &&
508                                     !is_union<_Tp>::value            &&
509                                     !is_class<_Tp>::value            &&
510                                     !is_function<_Tp>::value         > {};
511
512#endif
513
514// is_arithmetic
515
516template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
517    : public integral_constant<bool, is_integral<_Tp>::value      ||
518                                     is_floating_point<_Tp>::value> {};
519
520// is_fundamental
521
522template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
523    : public integral_constant<bool, is_void<_Tp>::value        ||
524                                     __is_nullptr_t<_Tp>::value ||
525                                     is_arithmetic<_Tp>::value> {};
526
527// is_scalar
528
529template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
530    : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
531                                     is_member_pointer<_Tp>::value ||
532                                     is_pointer<_Tp>::value        ||
533                                     __is_nullptr_t<_Tp>::value    ||
534                                     is_enum<_Tp>::value           > {};
535
536template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
537
538// is_object
539
540template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
541    : public integral_constant<bool, is_scalar<_Tp>::value ||
542                                     is_array<_Tp>::value  ||
543                                     is_union<_Tp>::value  ||
544                                     is_class<_Tp>::value  > {};
545
546// is_compound
547
548template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
549    : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
550
551// add_const
552
553template <class _Tp, bool = is_reference<_Tp>::value ||
554                            is_function<_Tp>::value  ||
555                            is_const<_Tp>::value     >
556struct __add_const             {typedef _Tp type;};
557
558template <class _Tp>
559struct __add_const<_Tp, false> {typedef const _Tp type;};
560
561template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
562    {typedef typename __add_const<_Tp>::type type;};
563
564#if _LIBCPP_STD_VER > 11
565template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
566#endif
567
568// add_volatile
569
570template <class _Tp, bool = is_reference<_Tp>::value ||
571                            is_function<_Tp>::value  ||
572                            is_volatile<_Tp>::value  >
573struct __add_volatile             {typedef _Tp type;};
574
575template <class _Tp>
576struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
577
578template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
579    {typedef typename __add_volatile<_Tp>::type type;};
580
581#if _LIBCPP_STD_VER > 11
582template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
583#endif
584
585// add_cv
586
587template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
588    {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
589
590#if _LIBCPP_STD_VER > 11
591template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
592#endif
593
594// remove_reference
595
596template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference        {typedef _Tp type;};
597template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&>  {typedef _Tp type;};
598#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
599template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
600#endif
601
602#if _LIBCPP_STD_VER > 11
603template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
604#endif
605
606// add_lvalue_reference
607
608template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference                      {typedef _Tp& type;};
609template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&>                {typedef _Tp& type;};  // for older compiler
610template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void>                {typedef void type;};
611template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void>          {typedef const void type;};
612template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void>       {typedef volatile void type;};
613template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
614
615#if _LIBCPP_STD_VER > 11
616template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
617#endif
618
619#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
620
621template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY  add_rvalue_reference                     {typedef _Tp&& type;};
622template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void>                {typedef void type;};
623template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void>          {typedef const void type;};
624template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void>       {typedef volatile void type;};
625template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
626
627#if _LIBCPP_STD_VER > 11
628template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
629#endif
630
631#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
632
633#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
634
635template <class _Tp>
636typename add_rvalue_reference<_Tp>::type
637declval() _NOEXCEPT;
638
639#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
640
641template <class _Tp>
642typename add_lvalue_reference<_Tp>::type
643declval();
644
645#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
646
647struct __any
648{
649    __any(...);
650};
651
652// remove_pointer
653
654template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer                      {typedef _Tp type;};
655template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*>                {typedef _Tp type;};
656template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const>          {typedef _Tp type;};
657template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile>       {typedef _Tp type;};
658template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
659
660#if _LIBCPP_STD_VER > 11
661template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
662#endif
663
664// add_pointer
665
666template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
667    {typedef typename remove_reference<_Tp>::type* type;};
668
669#if _LIBCPP_STD_VER > 11
670template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
671#endif
672
673// is_signed
674
675template <class _Tp, bool = is_integral<_Tp>::value>
676struct __libcpp_is_signed_impl : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
677
678template <class _Tp>
679struct __libcpp_is_signed_impl<_Tp, false> : public true_type {};  // floating point
680
681template <class _Tp, bool = is_arithmetic<_Tp>::value>
682struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
683
684template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
685
686template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
687
688// is_unsigned
689
690template <class _Tp, bool = is_integral<_Tp>::value>
691struct __libcpp_is_unsigned_impl : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
692
693template <class _Tp>
694struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {};  // floating point
695
696template <class _Tp, bool = is_arithmetic<_Tp>::value>
697struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
698
699template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
700
701template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
702
703// rank
704
705template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
706    : public integral_constant<size_t, 0> {};
707template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
708    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
709template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
710    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
711
712// extent
713
714template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
715    : public integral_constant<size_t, 0> {};
716template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
717    : public integral_constant<size_t, 0> {};
718template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
719    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
720template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
721    : public integral_constant<size_t, _Np> {};
722template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
723    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
724
725// remove_extent
726
727template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
728    {typedef _Tp type;};
729template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
730    {typedef _Tp type;};
731template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
732    {typedef _Tp type;};
733
734#if _LIBCPP_STD_VER > 11
735template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
736#endif
737
738// remove_all_extents
739
740template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
741    {typedef _Tp type;};
742template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
743    {typedef typename remove_all_extents<_Tp>::type type;};
744template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
745    {typedef typename remove_all_extents<_Tp>::type type;};
746
747#if _LIBCPP_STD_VER > 11
748template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
749#endif
750
751// decay
752
753template <class _Tp>
754struct _LIBCPP_TYPE_VIS_ONLY decay
755{
756private:
757    typedef typename remove_reference<_Tp>::type _Up;
758public:
759    typedef typename conditional
760                     <
761                         is_array<_Up>::value,
762                         typename remove_extent<_Up>::type*,
763                         typename conditional
764                         <
765                              is_function<_Up>::value,
766                              typename add_pointer<_Up>::type,
767                              typename remove_cv<_Up>::type
768                         >::type
769                     >::type type;
770};
771
772#if _LIBCPP_STD_VER > 11
773template <class _Tp> using decay_t = typename decay<_Tp>::type;
774#endif
775
776// is_abstract
777
778namespace __is_abstract_imp
779{
780template <class _Tp> char  __test(_Tp (*)[1]);
781template <class _Tp> __two __test(...);
782}
783
784template <class _Tp, bool = is_class<_Tp>::value>
785struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
786
787template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
788
789template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
790
791// is_final
792
793#if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
794template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY 
795is_final : public integral_constant<bool, __is_final(_Tp)> {};
796#endif
797
798// is_base_of
799
800#ifdef _LIBCPP_HAS_IS_BASE_OF
801
802template <class _Bp, class _Dp>
803struct _LIBCPP_TYPE_VIS_ONLY is_base_of
804    : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
805
806#else  // _LIBCPP_HAS_IS_BASE_OF
807
808namespace __is_base_of_imp
809{
810template <class _Tp>
811struct _Dst
812{
813    _Dst(const volatile _Tp &);
814};
815template <class _Tp>
816struct _Src
817{
818    operator const volatile _Tp &();
819    template <class _Up> operator const _Dst<_Up> &();
820};
821template <size_t> struct __one { typedef char type; };
822template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
823template <class _Bp, class _Dp> __two __test(...);
824}
825
826template <class _Bp, class _Dp>
827struct _LIBCPP_TYPE_VIS_ONLY is_base_of
828    : public integral_constant<bool, is_class<_Bp>::value &&
829                                     sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
830
831#endif  // _LIBCPP_HAS_IS_BASE_OF
832
833// is_convertible
834
835#if __has_feature(is_convertible_to)
836
837template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
838    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
839                                     !is_abstract<_T2>::value> {};
840
841#else  // __has_feature(is_convertible_to)
842
843namespace __is_convertible_imp
844{
845template <class _Tp> void  __test_convert(_Tp);
846
847template <class _From, class _To, class = void>
848struct __is_convertible_test : public false_type {};
849
850template <class _From, class _To>
851struct __is_convertible_test<_From, _To,
852    decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
853{};
854
855template <class _Tp> __two __test(...);
856#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
857template <class _Tp> _Tp&& __source();
858#else
859template <class _Tp> typename remove_reference<_Tp>::type& __source();
860#endif
861
862template <class _Tp, bool _IsArray =    is_array<_Tp>::value,
863                     bool _IsFunction = is_function<_Tp>::value,
864                     bool _IsVoid =     is_void<_Tp>::value>
865                     struct __is_array_function_or_void                          {enum {value = 0};};
866template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
867template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
868template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
869}
870
871template <class _Tp,
872    unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
873struct __is_convertible_check
874{
875    static const size_t __v = 0;
876};
877
878template <class _Tp>
879struct __is_convertible_check<_Tp, 0>
880{
881    static const size_t __v = sizeof(_Tp);
882};
883
884template <class _T1, class _T2,
885    unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
886    unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
887struct __is_convertible
888    : public integral_constant<bool,
889        __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
890#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
891         && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
892              && (!is_const<typename remove_reference<_T2>::type>::value
893                  || is_volatile<typename remove_reference<_T2>::type>::value)
894                  && (is_same<typename remove_cv<_T1>::type,
895                              typename remove_cv<typename remove_reference<_T2>::type>::type>::value
896                      || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
897#endif
898    >
899{};
900
901template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
902
903template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
904#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
905template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
906template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
907template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
908template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
909#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
910
911template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
912    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
913
914template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
915    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
916
917template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
918    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
919
920template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
921    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
922
923template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0>                : public false_type {};
924#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
925template <class _T1>            struct __is_convertible<_T1, _T1&&, 2, 0>               : public true_type {};
926#endif
927template <class _T1>            struct __is_convertible<_T1, _T1&, 2, 0>               : public true_type {};
928template <class _T1>            struct __is_convertible<_T1, _T1*, 2, 0>               : public true_type {};
929template <class _T1>            struct __is_convertible<_T1, _T1*const, 2, 0>          : public true_type {};
930template <class _T1>            struct __is_convertible<_T1, _T1*volatile, 2, 0>       : public true_type {};
931template <class _T1>            struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
932
933template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
934
935template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
936template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
937template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
938template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
939
940template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
941template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
942template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
943template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
944
945template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
946template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
947template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
948template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
949
950template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
951    : public __is_convertible<_T1, _T2>
952{
953    static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
954    static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
955};
956
957#endif  // __has_feature(is_convertible_to)
958
959// is_empty
960
961#if __has_feature(is_empty) || (_GNUC_VER >= 407)
962
963template <class _Tp>
964struct _LIBCPP_TYPE_VIS_ONLY is_empty
965    : public integral_constant<bool, __is_empty(_Tp)> {};
966
967#else  // __has_feature(is_empty)
968
969template <class _Tp>
970struct __is_empty1
971    : public _Tp
972{
973    double __lx;
974};
975
976struct __is_empty2
977{
978    double __lx;
979};
980
981template <class _Tp, bool = is_class<_Tp>::value>
982struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
983
984template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
985
986template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
987
988#endif  // __has_feature(is_empty)
989
990// is_polymorphic
991
992#if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
993
994template <class _Tp>
995struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
996    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
997
998#else
999
1000template<typename _Tp> char &__is_polymorphic_impl(
1001    typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1002                       int>::type);
1003template<typename _Tp> __two &__is_polymorphic_impl(...);
1004
1005template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1006    : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1007
1008#endif // __has_feature(is_polymorphic)
1009
1010// has_virtual_destructor
1011
1012#if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1013
1014template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1015    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1016
1017#else
1018
1019template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1020    : public false_type {};
1021
1022#endif
1023
1024// alignment_of
1025
1026template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
1027    : public integral_constant<size_t, __alignof__(_Tp)> {};
1028
1029// aligned_storage
1030
1031template <class _Hp, class _Tp>
1032struct __type_list
1033{
1034    typedef _Hp _Head;
1035    typedef _Tp _Tail;
1036};
1037
1038struct __nat
1039{
1040#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1041    __nat() = delete;
1042    __nat(const __nat&) = delete;
1043    __nat& operator=(const __nat&) = delete;
1044    ~__nat() = delete;
1045#endif
1046};
1047
1048template <class _Tp>
1049struct __align_type
1050{
1051    static const size_t value = alignment_of<_Tp>::value;
1052    typedef _Tp type;
1053};
1054
1055struct __struct_double {long double __lx;};
1056struct __struct_double4 {double __lx[4];};
1057
1058typedef
1059    __type_list<__align_type<unsigned char>,
1060    __type_list<__align_type<unsigned short>,
1061    __type_list<__align_type<unsigned int>,
1062    __type_list<__align_type<unsigned long>,
1063    __type_list<__align_type<unsigned long long>,
1064    __type_list<__align_type<double>,
1065    __type_list<__align_type<long double>,
1066    __type_list<__align_type<__struct_double>,
1067    __type_list<__align_type<__struct_double4>,
1068    __type_list<__align_type<int*>,
1069    __nat
1070    > > > > > > > > > > __all_types;
1071
1072template <class _TL, size_t _Align> struct __find_pod;
1073
1074template <class _Hp, size_t _Align>
1075struct __find_pod<__type_list<_Hp, __nat>, _Align>
1076{
1077    typedef typename conditional<
1078                             _Align == _Hp::value,
1079                             typename _Hp::type,
1080                             void
1081                         >::type type;
1082};
1083
1084template <class _Hp, class _Tp, size_t _Align>
1085struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1086{
1087    typedef typename conditional<
1088                             _Align == _Hp::value,
1089                             typename _Hp::type,
1090                             typename __find_pod<_Tp, _Align>::type
1091                         >::type type;
1092};
1093
1094template <class _TL, size_t _Len> struct __find_max_align;
1095
1096template <class _Hp, size_t _Len>
1097struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1098
1099template <size_t _Len, size_t _A1, size_t _A2>
1100struct __select_align
1101{
1102private:
1103    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1104    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1105public:
1106    static const size_t value = _Len < __max ? __min : __max;
1107};
1108
1109template <class _Hp, class _Tp, size_t _Len>
1110struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1111    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1112
1113template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1114struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
1115{
1116    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1117    static_assert(!is_void<_Aligner>::value, "");
1118    union type
1119    {
1120        _Aligner __align;
1121        unsigned char __data[_Len];
1122    };
1123};
1124
1125#if _LIBCPP_STD_VER > 11
1126template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1127    using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1128#endif
1129
1130#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1131template <size_t _Len>\
1132struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
1133{\
1134    struct _ALIGNAS(n) type\
1135    {\
1136        unsigned char __lx[_Len];\
1137    };\
1138}
1139
1140_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1141_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1142_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1143_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1144_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1145_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1146_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1147_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1148_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1149_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1150_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1151_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1152_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1153_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1154// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1155#if !defined(_LIBCPP_MSVC)
1156_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1157#endif // !_LIBCPP_MSVC
1158
1159#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1160
1161#ifndef _LIBCPP_HAS_NO_VARIADICS
1162
1163// aligned_union
1164
1165template <size_t _I0, size_t ..._In>
1166struct __static_max;
1167
1168template <size_t _I0>
1169struct __static_max<_I0>
1170{
1171    static const size_t value = _I0;
1172};
1173
1174template <size_t _I0, size_t _I1, size_t ..._In>
1175struct __static_max<_I0, _I1, _In...>
1176{
1177    static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1178                                             __static_max<_I1, _In...>::value;
1179};
1180
1181template <size_t _Len, class _Type0, class ..._Types>
1182struct aligned_union
1183{
1184    static const size_t alignment_value = __static_max<__alignof__(_Type0),
1185                                                       __alignof__(_Types)...>::value;
1186    static const size_t __len = __static_max<_Len, sizeof(_Type0),
1187                                             sizeof(_Types)...>::value;
1188    typedef typename aligned_storage<__len, alignment_value>::type type;
1189};
1190
1191#if _LIBCPP_STD_VER > 11
1192template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1193#endif
1194
1195#endif  // _LIBCPP_HAS_NO_VARIADICS
1196
1197template <class _Tp>
1198struct __numeric_type
1199{
1200   static void __test(...);
1201   static float __test(float);
1202   static double __test(char);
1203   static double __test(int);
1204   static double __test(unsigned);
1205   static double __test(long);
1206   static double __test(unsigned long);
1207   static double __test(long long);
1208   static double __test(unsigned long long);
1209   static double __test(double);
1210   static long double __test(long double);
1211
1212   typedef decltype(__test(declval<_Tp>())) type;
1213   static const bool value = !is_same<type, void>::value;
1214};
1215
1216template <>
1217struct __numeric_type<void>
1218{
1219   static const bool value = true;
1220};
1221
1222// __promote
1223
1224template <class _A1, class _A2 = void, class _A3 = void,
1225          bool = __numeric_type<_A1>::value &&
1226                 __numeric_type<_A2>::value &&
1227                 __numeric_type<_A3>::value>
1228class __promote_imp
1229{
1230public:
1231    static const bool value = false;
1232};
1233
1234template <class _A1, class _A2, class _A3>
1235class __promote_imp<_A1, _A2, _A3, true>
1236{
1237private:
1238    typedef typename __promote_imp<_A1>::type __type1;
1239    typedef typename __promote_imp<_A2>::type __type2;
1240    typedef typename __promote_imp<_A3>::type __type3;
1241public:
1242    typedef decltype(__type1() + __type2() + __type3()) type;
1243    static const bool value = true;
1244};
1245
1246template <class _A1, class _A2>
1247class __promote_imp<_A1, _A2, void, true>
1248{
1249private:
1250    typedef typename __promote_imp<_A1>::type __type1;
1251    typedef typename __promote_imp<_A2>::type __type2;
1252public:
1253    typedef decltype(__type1() + __type2()) type;
1254    static const bool value = true;
1255};
1256
1257template <class _A1>
1258class __promote_imp<_A1, void, void, true>
1259{
1260public:
1261    typedef typename __numeric_type<_A1>::type type;
1262    static const bool value = true;
1263};
1264
1265template <class _A1, class _A2 = void, class _A3 = void>
1266class __promote : public __promote_imp<_A1, _A2, _A3> {};
1267
1268#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1269
1270// __transform
1271
1272template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1273template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char      type;};
1274template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short     type;};
1275template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int       type;};
1276template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1277
1278#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
1279
1280// make_signed / make_unsigned
1281
1282typedef
1283    __type_list<signed char,
1284    __type_list<signed short,
1285    __type_list<signed int,
1286    __type_list<signed long,
1287    __type_list<signed long long,
1288#ifndef _LIBCPP_HAS_NO_INT128
1289    __type_list<__int128_t,
1290#endif
1291    __nat
1292#ifndef _LIBCPP_HAS_NO_INT128
1293    >
1294#endif
1295    > > > > > __signed_types;
1296
1297typedef
1298    __type_list<unsigned char,
1299    __type_list<unsigned short,
1300    __type_list<unsigned int,
1301    __type_list<unsigned long,
1302    __type_list<unsigned long long,
1303#ifndef _LIBCPP_HAS_NO_INT128
1304    __type_list<__uint128_t,
1305#endif
1306    __nat
1307#ifndef _LIBCPP_HAS_NO_INT128
1308    >
1309#endif
1310    > > > > > __unsigned_types;
1311
1312template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1313
1314template <class _Hp, class _Tp, size_t _Size>
1315struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1316{
1317    typedef _Hp type;
1318};
1319
1320template <class _Hp, class _Tp, size_t _Size>
1321struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1322{
1323    typedef typename __find_first<_Tp, _Size>::type type;
1324};
1325
1326template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1327                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1328struct __apply_cv
1329{
1330    typedef _Up type;
1331};
1332
1333template <class _Tp, class _Up>
1334struct __apply_cv<_Tp, _Up, true, false>
1335{
1336    typedef const _Up type;
1337};
1338
1339template <class _Tp, class _Up>
1340struct __apply_cv<_Tp, _Up, false, true>
1341{
1342    typedef volatile _Up type;
1343};
1344
1345template <class _Tp, class _Up>
1346struct __apply_cv<_Tp, _Up, true, true>
1347{
1348    typedef const volatile _Up type;
1349};
1350
1351template <class _Tp, class _Up>
1352struct __apply_cv<_Tp&, _Up, false, false>
1353{
1354    typedef _Up& type;
1355};
1356
1357template <class _Tp, class _Up>
1358struct __apply_cv<_Tp&, _Up, true, false>
1359{
1360    typedef const _Up& type;
1361};
1362
1363template <class _Tp, class _Up>
1364struct __apply_cv<_Tp&, _Up, false, true>
1365{
1366    typedef volatile _Up& type;
1367};
1368
1369template <class _Tp, class _Up>
1370struct __apply_cv<_Tp&, _Up, true, true>
1371{
1372    typedef const volatile _Up& type;
1373};
1374
1375template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1376struct __make_signed {};
1377
1378template <class _Tp>
1379struct __make_signed<_Tp, true>
1380{
1381    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1382};
1383
1384template <> struct __make_signed<bool,               true> {};
1385template <> struct __make_signed<  signed short,     true> {typedef short     type;};
1386template <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1387template <> struct __make_signed<  signed int,       true> {typedef int       type;};
1388template <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1389template <> struct __make_signed<  signed long,      true> {typedef long      type;};
1390template <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1391template <> struct __make_signed<  signed long long, true> {typedef long long type;};
1392template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1393#ifndef _LIBCPP_HAS_NO_INT128
1394template <> struct __make_signed<__int128_t,         true> {typedef __int128_t type;};
1395template <> struct __make_signed<__uint128_t,        true> {typedef __int128_t type;};
1396#endif
1397
1398template <class _Tp>
1399struct _LIBCPP_TYPE_VIS_ONLY make_signed
1400{
1401    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1402};
1403
1404#if _LIBCPP_STD_VER > 11
1405template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1406#endif
1407
1408template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1409struct __make_unsigned {};
1410
1411template <class _Tp>
1412struct __make_unsigned<_Tp, true>
1413{
1414    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1415};
1416
1417template <> struct __make_unsigned<bool,               true> {};
1418template <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1419template <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1420template <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1421template <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1422template <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1423template <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1424template <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1425template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1426#ifndef _LIBCPP_HAS_NO_INT128
1427template <> struct __make_unsigned<__int128_t,         true> {typedef __uint128_t        type;};
1428template <> struct __make_unsigned<__uint128_t,        true> {typedef __uint128_t        type;};
1429#endif
1430
1431template <class _Tp>
1432struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
1433{
1434    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1435};
1436
1437#if _LIBCPP_STD_VER > 11
1438template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1439#endif
1440
1441#ifdef _LIBCPP_HAS_NO_VARIADICS
1442
1443template <class _Tp, class _Up = void, class V = void>
1444struct _LIBCPP_TYPE_VIS_ONLY common_type
1445{
1446public:
1447    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1448};
1449
1450template <class _Tp>
1451struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
1452{
1453public:
1454    typedef typename decay<_Tp>::type type;
1455};
1456
1457template <class _Tp, class _Up>
1458struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
1459{
1460private:
1461#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1462    static _Tp&& __t();
1463    static _Up&& __u();
1464#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1465    static _Tp __t();
1466    static _Up __u();
1467#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1468public:
1469    typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1470};
1471
1472#else  // _LIBCPP_HAS_NO_VARIADICS
1473
1474template <class ..._Tp> struct common_type;
1475
1476template <class _Tp>
1477struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
1478{
1479    typedef typename decay<_Tp>::type type;
1480};
1481
1482template <class _Tp, class _Up>
1483struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
1484{
1485private:
1486    static _Tp&& __t();
1487    static _Up&& __u();
1488    static bool __f();
1489public:
1490    typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
1491};
1492
1493template <class _Tp, class _Up, class ..._Vp>
1494struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
1495{
1496    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1497};
1498
1499#if _LIBCPP_STD_VER > 11
1500template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1501#endif
1502
1503#endif  // _LIBCPP_HAS_NO_VARIADICS
1504
1505// is_assignable
1506
1507template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
1508
1509template <class _Tp, class _Arg>
1510typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
1511#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1512__is_assignable_test(_Tp&&, _Arg&&);
1513#else
1514__is_assignable_test(_Tp, _Arg&);
1515#endif
1516
1517template <class _Arg>
1518false_type
1519#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1520__is_assignable_test(__any, _Arg&&);
1521#else
1522__is_assignable_test(__any, _Arg&);
1523#endif
1524
1525template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1526struct __is_assignable_imp
1527    : public common_type
1528        <
1529            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1530        >::type {};
1531
1532template <class _Tp, class _Arg>
1533struct __is_assignable_imp<_Tp, _Arg, true>
1534    : public false_type
1535{
1536};
1537
1538template <class _Tp, class _Arg>
1539struct is_assignable
1540    : public __is_assignable_imp<_Tp, _Arg> {};
1541
1542// is_copy_assignable
1543
1544template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
1545    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1546                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
1547
1548// is_move_assignable
1549
1550template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
1551#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1552    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1553                     const typename add_rvalue_reference<_Tp>::type> {};
1554#else
1555    : public is_copy_assignable<_Tp> {};
1556#endif
1557
1558// is_destructible
1559
1560//  if it's a reference, return true
1561//  if it's a function, return false
1562//  if it's   void,     return false
1563//  if it's an array of unknown bound, return false
1564//  Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
1565//    where _Up is remove_all_extents<_Tp>::type
1566
1567template <class>
1568struct __is_destructible_apply { typedef int type; };
1569
1570template <typename _Tp>
1571struct __is_destructor_wellformed {
1572    template <typename _Tp1>
1573    static char  __test (
1574        typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
1575    );
1576
1577    template <typename _Tp1>
1578    static __two __test (...);
1579    
1580    static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
1581};
1582
1583template <class _Tp, bool>
1584struct __destructible_imp;
1585
1586template <class _Tp>
1587struct __destructible_imp<_Tp, false> 
1588   : public _VSTD::integral_constant<bool, 
1589        __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
1590
1591template <class _Tp>
1592struct __destructible_imp<_Tp, true>
1593    : public _VSTD::true_type {};
1594
1595template <class _Tp, bool>
1596struct __destructible_false;
1597
1598template <class _Tp>
1599struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
1600
1601template <class _Tp>
1602struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
1603
1604template <class _Tp>
1605struct is_destructible
1606    : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
1607
1608template <class _Tp>
1609struct is_destructible<_Tp[]>
1610    : public _VSTD::false_type {};
1611
1612template <>
1613struct is_destructible<void>
1614    : public _VSTD::false_type {};
1615
1616// move
1617
1618#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1619
1620template <class _Tp>
1621inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1622typename remove_reference<_Tp>::type&&
1623move(_Tp&& __t) _NOEXCEPT
1624{
1625    typedef typename remove_reference<_Tp>::type _Up;
1626    return static_cast<_Up&&>(__t);
1627}
1628
1629template <class _Tp>
1630inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1631_Tp&&
1632forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1633{
1634    return static_cast<_Tp&&>(__t);
1635}
1636
1637template <class _Tp>
1638inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1639_Tp&&
1640forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1641{
1642    static_assert(!std::is_lvalue_reference<_Tp>::value,
1643                  "Can not forward an rvalue as an lvalue.");
1644    return static_cast<_Tp&&>(__t);
1645}
1646
1647#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1648
1649template <class _Tp>
1650inline _LIBCPP_INLINE_VISIBILITY
1651_Tp&
1652move(_Tp& __t)
1653{
1654    return __t;
1655}
1656
1657template <class _Tp>
1658inline _LIBCPP_INLINE_VISIBILITY
1659const _Tp&
1660move(const _Tp& __t)
1661{
1662    return __t;
1663}
1664
1665template <class _Tp>
1666inline _LIBCPP_INLINE_VISIBILITY
1667_Tp&
1668forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1669{
1670    return __t;
1671}
1672
1673
1674template <class _Tp>
1675class __rv
1676{
1677    typedef typename remove_reference<_Tp>::type _Trr;
1678    _Trr& t_;
1679public:
1680    _LIBCPP_INLINE_VISIBILITY
1681    _Trr* operator->() {return &t_;}
1682    _LIBCPP_INLINE_VISIBILITY
1683    explicit __rv(_Trr& __t) : t_(__t) {}
1684};
1685
1686#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1687
1688#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1689
1690template <class _Tp>
1691inline _LIBCPP_INLINE_VISIBILITY
1692typename decay<_Tp>::type
1693__decay_copy(_Tp&& __t)
1694{
1695    return _VSTD::forward<_Tp>(__t);
1696}
1697
1698#else
1699
1700template <class _Tp>
1701inline _LIBCPP_INLINE_VISIBILITY
1702typename decay<_Tp>::type
1703__decay_copy(const _Tp& __t)
1704{
1705    return _VSTD::forward<_Tp>(__t);
1706}
1707
1708#endif
1709
1710#ifndef _LIBCPP_HAS_NO_VARIADICS
1711
1712template <class _Rp, class _Class, class ..._Param>
1713struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1714{
1715    typedef _Class _ClassType;
1716    typedef _Rp _ReturnType;
1717    typedef _Rp (_FnType) (_Param...);
1718};
1719
1720template <class _Rp, class _Class, class ..._Param>
1721struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
1722{
1723    typedef _Class _ClassType;
1724    typedef _Rp _ReturnType;
1725    typedef _Rp (_FnType) (_Param..., ...);
1726};
1727
1728template <class _Rp, class _Class, class ..._Param>
1729struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1730{
1731    typedef _Class const _ClassType;
1732    typedef _Rp _ReturnType;
1733    typedef _Rp (_FnType) (_Param...);
1734};
1735
1736template <class _Rp, class _Class, class ..._Param>
1737struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
1738{
1739    typedef _Class const _ClassType;
1740    typedef _Rp _ReturnType;
1741    typedef _Rp (_FnType) (_Param..., ...);
1742};
1743
1744template <class _Rp, class _Class, class ..._Param>
1745struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1746{
1747    typedef _Class volatile _ClassType;
1748    typedef _Rp _ReturnType;
1749    typedef _Rp (_FnType) (_Param...);
1750};
1751
1752template <class _Rp, class _Class, class ..._Param>
1753struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
1754{
1755    typedef _Class volatile _ClassType;
1756    typedef _Rp _ReturnType;
1757    typedef _Rp (_FnType) (_Param..., ...);
1758};
1759
1760template <class _Rp, class _Class, class ..._Param>
1761struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1762{
1763    typedef _Class const volatile _ClassType;
1764    typedef _Rp _ReturnType;
1765    typedef _Rp (_FnType) (_Param...);
1766};
1767
1768template <class _Rp, class _Class, class ..._Param>
1769struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
1770{
1771    typedef _Class const volatile _ClassType;
1772    typedef _Rp _ReturnType;
1773    typedef _Rp (_FnType) (_Param..., ...);
1774};
1775
1776#if __has_feature(cxx_reference_qualified_functions)
1777
1778template <class _Rp, class _Class, class ..._Param>
1779struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1780{
1781    typedef _Class& _ClassType;
1782    typedef _Rp _ReturnType;
1783    typedef _Rp (_FnType) (_Param...);
1784};
1785
1786template <class _Rp, class _Class, class ..._Param>
1787struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
1788{
1789    typedef _Class& _ClassType;
1790    typedef _Rp _ReturnType;
1791    typedef _Rp (_FnType) (_Param..., ...);
1792};
1793
1794template <class _Rp, class _Class, class ..._Param>
1795struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1796{
1797    typedef _Class const& _ClassType;
1798    typedef _Rp _ReturnType;
1799    typedef _Rp (_FnType) (_Param...);
1800};
1801
1802template <class _Rp, class _Class, class ..._Param>
1803struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
1804{
1805    typedef _Class const& _ClassType;
1806    typedef _Rp _ReturnType;
1807    typedef _Rp (_FnType) (_Param..., ...);
1808};
1809
1810template <class _Rp, class _Class, class ..._Param>
1811struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1812{
1813    typedef _Class volatile& _ClassType;
1814    typedef _Rp _ReturnType;
1815    typedef _Rp (_FnType) (_Param...);
1816};
1817
1818template <class _Rp, class _Class, class ..._Param>
1819struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
1820{
1821    typedef _Class volatile& _ClassType;
1822    typedef _Rp _ReturnType;
1823    typedef _Rp (_FnType) (_Param..., ...);
1824};
1825
1826template <class _Rp, class _Class, class ..._Param>
1827struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1828{
1829    typedef _Class const volatile& _ClassType;
1830    typedef _Rp _ReturnType;
1831    typedef _Rp (_FnType) (_Param...);
1832};
1833
1834template <class _Rp, class _Class, class ..._Param>
1835struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
1836{
1837    typedef _Class const volatile& _ClassType;
1838    typedef _Rp _ReturnType;
1839    typedef _Rp (_FnType) (_Param..., ...);
1840};
1841
1842template <class _Rp, class _Class, class ..._Param>
1843struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1844{
1845    typedef _Class&& _ClassType;
1846    typedef _Rp _ReturnType;
1847    typedef _Rp (_FnType) (_Param...);
1848};
1849
1850template <class _Rp, class _Class, class ..._Param>
1851struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
1852{
1853    typedef _Class&& _ClassType;
1854    typedef _Rp _ReturnType;
1855    typedef _Rp (_FnType) (_Param..., ...);
1856};
1857
1858template <class _Rp, class _Class, class ..._Param>
1859struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1860{
1861    typedef _Class const&& _ClassType;
1862    typedef _Rp _ReturnType;
1863    typedef _Rp (_FnType) (_Param...);
1864};
1865
1866template <class _Rp, class _Class, class ..._Param>
1867struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
1868{
1869    typedef _Class const&& _ClassType;
1870    typedef _Rp _ReturnType;
1871    typedef _Rp (_FnType) (_Param..., ...);
1872};
1873
1874template <class _Rp, class _Class, class ..._Param>
1875struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1876{
1877    typedef _Class volatile&& _ClassType;
1878    typedef _Rp _ReturnType;
1879    typedef _Rp (_FnType) (_Param...);
1880};
1881
1882template <class _Rp, class _Class, class ..._Param>
1883struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
1884{
1885    typedef _Class volatile&& _ClassType;
1886    typedef _Rp _ReturnType;
1887    typedef _Rp (_FnType) (_Param..., ...);
1888};
1889
1890template <class _Rp, class _Class, class ..._Param>
1891struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1892{
1893    typedef _Class const volatile&& _ClassType;
1894    typedef _Rp _ReturnType;
1895    typedef _Rp (_FnType) (_Param...);
1896};
1897
1898template <class _Rp, class _Class, class ..._Param>
1899struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
1900{
1901    typedef _Class const volatile&& _ClassType;
1902    typedef _Rp _ReturnType;
1903    typedef _Rp (_FnType) (_Param..., ...);
1904};
1905
1906#endif  // __has_feature(cxx_reference_qualified_functions)
1907
1908#else  // _LIBCPP_HAS_NO_VARIADICS
1909
1910template <class _Rp, class _Class>
1911struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1912{
1913    typedef _Class _ClassType;
1914    typedef _Rp _ReturnType;
1915    typedef _Rp (_FnType) ();
1916};
1917
1918template <class _Rp, class _Class>
1919struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
1920{
1921    typedef _Class _ClassType;
1922    typedef _Rp _ReturnType;
1923    typedef _Rp (_FnType) (...);
1924};
1925
1926template <class _Rp, class _Class, class _P0>
1927struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1928{
1929    typedef _Class _ClassType;
1930    typedef _Rp _ReturnType;
1931    typedef _Rp (_FnType) (_P0);
1932};
1933
1934template <class _Rp, class _Class, class _P0>
1935struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
1936{
1937    typedef _Class _ClassType;
1938    typedef _Rp _ReturnType;
1939    typedef _Rp (_FnType) (_P0, ...);
1940};
1941
1942template <class _Rp, class _Class, class _P0, class _P1>
1943struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1944{
1945    typedef _Class _ClassType;
1946    typedef _Rp _ReturnType;
1947    typedef _Rp (_FnType) (_P0, _P1);
1948};
1949
1950template <class _Rp, class _Class, class _P0, class _P1>
1951struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
1952{
1953    typedef _Class _ClassType;
1954    typedef _Rp _ReturnType;
1955    typedef _Rp (_FnType) (_P0, _P1, ...);
1956};
1957
1958template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1959struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1960{
1961    typedef _Class _ClassType;
1962    typedef _Rp _ReturnType;
1963    typedef _Rp (_FnType) (_P0, _P1, _P2);
1964};
1965
1966template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1967struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
1968{
1969    typedef _Class _ClassType;
1970    typedef _Rp _ReturnType;
1971    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
1972};
1973
1974template <class _Rp, class _Class>
1975struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1976{
1977    typedef _Class const _ClassType;
1978    typedef _Rp _ReturnType;
1979    typedef _Rp (_FnType) ();
1980};
1981
1982template <class _Rp, class _Class>
1983struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
1984{
1985    typedef _Class const _ClassType;
1986    typedef _Rp _ReturnType;
1987    typedef _Rp (_FnType) (...);
1988};
1989
1990template <class _Rp, class _Class, class _P0>
1991struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1992{
1993    typedef _Class const _ClassType;
1994    typedef _Rp _ReturnType;
1995    typedef _Rp (_FnType) (_P0);
1996};
1997
1998template <class _Rp, class _Class, class _P0>
1999struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2000{
2001    typedef _Class const _ClassType;
2002    typedef _Rp _ReturnType;
2003    typedef _Rp (_FnType) (_P0, ...);
2004};
2005
2006template <class _Rp, class _Class, class _P0, class _P1>
2007struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2008{
2009    typedef _Class const _ClassType;
2010    typedef _Rp _ReturnType;
2011    typedef _Rp (_FnType) (_P0, _P1);
2012};
2013
2014template <class _Rp, class _Class, class _P0, class _P1>
2015struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2016{
2017    typedef _Class const _ClassType;
2018    typedef _Rp _ReturnType;
2019    typedef _Rp (_FnType) (_P0, _P1, ...);
2020};
2021
2022template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2023struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2024{
2025    typedef _Class const _ClassType;
2026    typedef _Rp _ReturnType;
2027    typedef _Rp (_FnType) (_P0, _P1, _P2);
2028};
2029
2030template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2031struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2032{
2033    typedef _Class const _ClassType;
2034    typedef _Rp _ReturnType;
2035    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2036};
2037
2038template <class _Rp, class _Class>
2039struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2040{
2041    typedef _Class volatile _ClassType;
2042    typedef _Rp _ReturnType;
2043    typedef _Rp (_FnType) ();
2044};
2045
2046template <class _Rp, class _Class>
2047struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2048{
2049    typedef _Class volatile _ClassType;
2050    typedef _Rp _ReturnType;
2051    typedef _Rp (_FnType) (...);
2052};
2053
2054template <class _Rp, class _Class, class _P0>
2055struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2056{
2057    typedef _Class volatile _ClassType;
2058    typedef _Rp _ReturnType;
2059    typedef _Rp (_FnType) (_P0);
2060};
2061
2062template <class _Rp, class _Class, class _P0>
2063struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2064{
2065    typedef _Class volatile _ClassType;
2066    typedef _Rp _ReturnType;
2067    typedef _Rp (_FnType) (_P0, ...);
2068};
2069
2070template <class _Rp, class _Class, class _P0, class _P1>
2071struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2072{
2073    typedef _Class volatile _ClassType;
2074    typedef _Rp _ReturnType;
2075    typedef _Rp (_FnType) (_P0, _P1);
2076};
2077
2078template <class _Rp, class _Class, class _P0, class _P1>
2079struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2080{
2081    typedef _Class volatile _ClassType;
2082    typedef _Rp _ReturnType;
2083    typedef _Rp (_FnType) (_P0, _P1, ...);
2084};
2085
2086template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2087struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2088{
2089    typedef _Class volatile _ClassType;
2090    typedef _Rp _ReturnType;
2091    typedef _Rp (_FnType) (_P0, _P1, _P2);
2092};
2093
2094template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2095struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2096{
2097    typedef _Class volatile _ClassType;
2098    typedef _Rp _ReturnType;
2099    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2100};
2101
2102template <class _Rp, class _Class>
2103struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2104{
2105    typedef _Class const volatile _ClassType;
2106    typedef _Rp _ReturnType;
2107    typedef _Rp (_FnType) ();
2108};
2109
2110template <class _Rp, class _Class>
2111struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2112{
2113    typedef _Class const volatile _ClassType;
2114    typedef _Rp _ReturnType;
2115    typedef _Rp (_FnType) (...);
2116};
2117
2118template <class _Rp, class _Class, class _P0>
2119struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2120{
2121    typedef _Class const volatile _ClassType;
2122    typedef _Rp _ReturnType;
2123    typedef _Rp (_FnType) (_P0);
2124};
2125
2126template <class _Rp, class _Class, class _P0>
2127struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2128{
2129    typedef _Class const volatile _ClassType;
2130    typedef _Rp _ReturnType;
2131    typedef _Rp (_FnType) (_P0, ...);
2132};
2133
2134template <class _Rp, class _Class, class _P0, class _P1>
2135struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2136{
2137    typedef _Class const volatile _ClassType;
2138    typedef _Rp _ReturnType;
2139    typedef _Rp (_FnType) (_P0, _P1);
2140};
2141
2142template <class _Rp, class _Class, class _P0, class _P1>
2143struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2144{
2145    typedef _Class const volatile _ClassType;
2146    typedef _Rp _ReturnType;
2147    typedef _Rp (_FnType) (_P0, _P1, ...);
2148};
2149
2150template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2151struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2152{
2153    typedef _Class const volatile _ClassType;
2154    typedef _Rp _ReturnType;
2155    typedef _Rp (_FnType) (_P0, _P1, _P2);
2156};
2157
2158template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2159struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2160{
2161    typedef _Class const volatile _ClassType;
2162    typedef _Rp _ReturnType;
2163    typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2164};
2165
2166#endif  // _LIBCPP_HAS_NO_VARIADICS
2167
2168template <class _Rp, class _Class>
2169struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2170{
2171    typedef _Class _ClassType;
2172    typedef _Rp _ReturnType;
2173};
2174
2175template <class _MP>
2176struct __member_pointer_traits
2177    : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2178                    is_member_function_pointer<_MP>::value,
2179                    is_member_object_pointer<_MP>::value>
2180{
2181//     typedef ... _ClassType;
2182//     typedef ... _ReturnType;
2183//     typedef ... _FnType;
2184};
2185
2186// result_of
2187
2188template <class _Callable> class result_of;
2189
2190#ifdef _LIBCPP_HAS_NO_VARIADICS
2191
2192template <class _Fn, bool, bool>
2193class __result_of
2194{
2195};
2196
2197template <class _Fn>
2198class __result_of<_Fn(), true, false>
2199{
2200public:
2201    typedef decltype(declval<_Fn>()()) type;
2202};
2203
2204template <class _Fn, class _A0>
2205class __result_of<_Fn(_A0), true, false>
2206{
2207public:
2208    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2209};
2210
2211template <class _Fn, class _A0, class _A1>
2212class __result_of<_Fn(_A0, _A1), true, false>
2213{
2214public:
2215    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2216};
2217
2218template <class _Fn, class _A0, class _A1, class _A2>
2219class __result_of<_Fn(_A0, _A1, _A2), true, false>
2220{
2221public:
2222    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2223};
2224
2225template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2226struct __result_of_mp;
2227
2228// member function pointer
2229
2230template <class _MP, class _Tp>
2231struct __result_of_mp<_MP, _Tp, true>
2232    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
2233{
2234};
2235
2236// member data pointer
2237
2238template <class _MP, class _Tp, bool>
2239struct __result_of_mdp;
2240
2241template <class _Rp, class _Class, class _Tp>
2242struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2243{
2244    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2245};
2246
2247template <class _Rp, class _Class, class _Tp>
2248struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2249{
2250    typedef typename __apply_cv<_Tp, _Rp>::type& type;
2251};
2252
2253template <class _Rp, class _Class, class _Tp>
2254struct __result_of_mp<_Rp _Class::*, _Tp, false>
2255    : public __result_of_mdp<_Rp _Class::*, _Tp,
2256            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2257{
2258};
2259
2260
2261
2262template <class _Fn, class _Tp>
2263class __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
2264    : public __result_of_mp<typename remove_reference<_Fn>::type,
2265                            _Tp,
2266                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2267{
2268};
2269
2270template <class _Fn, class _Tp, class _A0>
2271class __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
2272    : public __result_of_mp<typename remove_reference<_Fn>::type,
2273                            _Tp,
2274                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2275{
2276};
2277
2278template <class _Fn, class _Tp, class _A0, class _A1>
2279class __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
2280    : public __result_of_mp<typename remove_reference<_Fn>::type,
2281                            _Tp,
2282                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2283{
2284};
2285
2286template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2287class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
2288    : public __result_of_mp<typename remove_reference<_Fn>::type,
2289                            _Tp,
2290                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2291{
2292};
2293
2294// result_of
2295
2296template <class _Fn>
2297class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
2298    : public __result_of<_Fn(),
2299                         is_class<typename remove_reference<_Fn>::type>::value ||
2300                         is_function<typename remove_reference<_Fn>::type>::value,
2301                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2302                        >
2303{
2304};
2305
2306template <class _Fn, class _A0>
2307class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
2308    : public __result_of<_Fn(_A0),
2309                         is_class<typename remove_reference<_Fn>::type>::value ||
2310                         is_function<typename remove_reference<_Fn>::type>::value,
2311                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2312                        >
2313{
2314};
2315
2316template <class _Fn, class _A0, class _A1>
2317class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
2318    : public __result_of<_Fn(_A0, _A1),
2319                         is_class<typename remove_reference<_Fn>::type>::value ||
2320                         is_function<typename remove_reference<_Fn>::type>::value,
2321                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2322                        >
2323{
2324};
2325
2326template <class _Fn, class _A0, class _A1, class _A2>
2327class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
2328    : public __result_of<_Fn(_A0, _A1, _A2),
2329                         is_class<typename remove_reference<_Fn>::type>::value ||
2330                         is_function<typename remove_reference<_Fn>::type>::value,
2331                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2332                        >
2333{
2334};
2335
2336#endif  // _LIBCPP_HAS_NO_VARIADICS
2337
2338// template <class T, class... Args> struct is_constructible;
2339
2340namespace __is_construct
2341{
2342struct __nat {};
2343}
2344
2345#if __has_feature(is_constructible)
2346
2347template <class _Tp, class ..._Args>
2348struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2349    : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2350    {};
2351
2352#else
2353
2354#ifndef _LIBCPP_HAS_NO_VARIADICS
2355
2356//      main is_constructible test
2357
2358template <class _Tp, class ..._Args>
2359typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
2360__is_constructible_test(_Tp&&, _Args&& ...);
2361
2362template <class ..._Args>
2363false_type
2364__is_constructible_test(__any, _Args&& ...);
2365
2366template <bool, class _Tp, class... _Args>
2367struct __libcpp_is_constructible // false, _Tp is not a scalar
2368    : public common_type
2369             <
2370                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
2371             >::type
2372    {};
2373
2374//      function types are not constructible
2375
2376template <class _Rp, class... _A1, class... _A2>
2377struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
2378    : public false_type
2379    {};
2380
2381//      handle scalars and reference types
2382
2383//      Scalars are default constructible, references are not
2384
2385template <class _Tp>
2386struct __libcpp_is_constructible<true, _Tp>
2387    : public is_scalar<_Tp>
2388    {};
2389
2390//      Scalars and references are constructible from one arg if that arg is
2391//          implicitly convertible to the scalar or reference.
2392
2393template <class _Tp>
2394struct __is_constructible_ref
2395{
2396    true_type static __lxx(_Tp);
2397    false_type static __lxx(...);
2398};
2399
2400template <class _Tp, class _A0>
2401struct __libcpp_is_constructible<true, _Tp, _A0>
2402    : public common_type
2403             <
2404                 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2405             >::type
2406    {};
2407
2408//      Scalars and references are not constructible from multiple args.
2409
2410template <class _Tp, class _A0, class ..._Args>
2411struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
2412    : public false_type
2413    {};
2414
2415//      Treat scalars and reference types separately
2416
2417template <bool, class _Tp, class... _Args>
2418struct __is_constructible_void_check
2419    : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2420                                _Tp, _Args...>
2421    {};
2422
2423//      If any of T or Args is void, is_constructible should be false
2424
2425template <class _Tp, class... _Args>
2426struct __is_constructible_void_check<true, _Tp, _Args...>
2427    : public false_type
2428    {};
2429
2430template <class ..._Args> struct __contains_void;
2431
2432template <> struct __contains_void<> : false_type {};
2433
2434template <class _A0, class ..._Args>
2435struct __contains_void<_A0, _Args...>
2436{
2437    static const bool value = is_void<_A0>::value ||
2438                              __contains_void<_Args...>::value;
2439};
2440
2441//      is_constructible entry point
2442
2443template <class _Tp, class... _Args>
2444struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2445    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2446                                        || is_abstract<_Tp>::value,
2447                                           _Tp, _Args...>
2448    {};
2449
2450//      Array types are default constructible if their element type
2451//      is default constructible
2452
2453template <class _Ap, size_t _Np>
2454struct __libcpp_is_constructible<false, _Ap[_Np]>
2455    : public is_constructible<typename remove_all_extents<_Ap>::type>
2456    {};
2457
2458//      Otherwise array types are not constructible by this syntax
2459
2460template <class _Ap, size_t _Np, class ..._Args>
2461struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
2462    : public false_type
2463    {};
2464
2465//      Incomplete array types are not constructible
2466
2467template <class _Ap, class ..._Args>
2468struct __libcpp_is_constructible<false, _Ap[], _Args...>
2469    : public false_type
2470    {};
2471
2472#else  // _LIBCPP_HAS_NO_VARIADICS
2473
2474// template <class T> struct is_constructible0;
2475
2476//      main is_constructible0 test
2477
2478template <class _Tp>
2479decltype((_Tp(), true_type()))
2480__is_constructible0_test(_Tp&);
2481
2482false_type
2483__is_constructible0_test(__any);
2484
2485template <class _Tp, class _A0>
2486decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2487__is_constructible1_test(_Tp&, _A0&);
2488
2489template <class _A0>
2490false_type
2491__is_constructible1_test(__any, _A0&);
2492
2493template <class _Tp, class _A0, class _A1>
2494decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2495__is_constructible2_test(_Tp&, _A0&, _A1&);
2496
2497template <class _A0, class _A1>
2498false_type
2499__is_constructible2_test(__any, _A0&, _A1&);
2500
2501template <bool, class _Tp>
2502struct __is_constructible0_imp // false, _Tp is not a scalar
2503    : public common_type
2504             <
2505                 decltype(__is_constructible0_test(declval<_Tp&>()))
2506             >::type
2507    {};
2508
2509template <bool, class _Tp, class _A0>
2510struct __is_constructible1_imp // false, _Tp is not a scalar
2511    : public common_type
2512             <
2513                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2514             >::type
2515    {};
2516
2517template <bool, class _Tp, class _A0, class _A1>
2518struct __is_constructible2_imp // false, _Tp is not a scalar
2519    : public common_type
2520             <
2521                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2522             >::type
2523    {};
2524
2525//      handle scalars and reference types
2526
2527//      Scalars are default constructible, references are not
2528
2529template <class _Tp>
2530struct __is_constructible0_imp<true, _Tp>
2531    : public is_scalar<_Tp>
2532    {};
2533
2534template <class _Tp, class _A0>
2535struct __is_constructible1_imp<true, _Tp, _A0>
2536    : public is_convertible<_A0, _Tp>
2537    {};
2538
2539template <class _Tp, class _A0, class _A1>
2540struct __is_constructible2_imp<true, _Tp, _A0, _A1>
2541    : public false_type
2542    {};
2543
2544//      Treat scalars and reference types separately
2545
2546template <bool, class _Tp>
2547struct __is_constructible0_void_check
2548    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2549                                _Tp>
2550    {};
2551
2552template <bool, class _Tp, class _A0>
2553struct __is_constructible1_void_check
2554    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2555                                _Tp, _A0>
2556    {};
2557
2558template <bool, class _Tp, class _A0, class _A1>
2559struct __is_constructible2_void_check
2560    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2561                                _Tp, _A0, _A1>
2562    {};
2563
2564//      If any of T or Args is void, is_constructible should be false
2565
2566template <class _Tp>
2567struct __is_constructible0_void_check<true, _Tp>
2568    : public false_type
2569    {};
2570
2571template <class _Tp, class _A0>
2572struct __is_constructible1_void_check<true, _Tp, _A0>
2573    : public false_type
2574    {};
2575
2576template <class _Tp, class _A0, class _A1>
2577struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2578    : public false_type
2579    {};
2580
2581//      is_constructible entry point
2582
2583template <class _Tp, class _A0 = __is_construct::__nat,
2584                     class _A1 = __is_construct::__nat>
2585struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2586    : public __is_constructible2_void_check<is_void<_Tp>::value
2587                                        || is_abstract<_Tp>::value
2588                                        || is_function<_Tp>::value
2589                                        || is_void<_A0>::value
2590                                        || is_void<_A1>::value,
2591                                           _Tp, _A0, _A1>
2592    {};
2593
2594template <class _Tp>
2595struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2596    : public __is_constructible0_void_check<is_void<_Tp>::value
2597                                        || is_abstract<_Tp>::value
2598                                        || is_function<_Tp>::value,
2599                                           _Tp>
2600    {};
2601
2602template <class _Tp, class _A0>
2603struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
2604    : public __is_constructible1_void_check<is_void<_Tp>::value
2605                                        || is_abstract<_Tp>::value
2606                                        || is_function<_Tp>::value
2607                                        || is_void<_A0>::value,
2608                                           _Tp, _A0>
2609    {};
2610
2611//      Array types are default constructible if their element type
2612//      is default constructible
2613
2614template <class _Ap, size_t _Np>
2615struct __is_constructible0_imp<false, _Ap[_Np]>
2616    : public is_constructible<typename remove_all_extents<_Ap>::type>
2617    {};
2618
2619template <class _Ap, size_t _Np, class _A0>
2620struct __is_constructible1_imp<false, _Ap[_Np], _A0>
2621    : public false_type
2622    {};
2623
2624template <class _Ap, size_t _Np, class _A0, class _A1>
2625struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2626    : public false_type
2627    {};
2628
2629//      Incomplete array types are not constructible
2630
2631template <class _Ap>
2632struct __is_constructible0_imp<false, _Ap[]>
2633    : public false_type
2634    {};
2635
2636template <class _Ap, class _A0>
2637struct __is_constructible1_imp<false, _Ap[], _A0>
2638    : public false_type
2639    {};
2640
2641template <class _Ap, class _A0, class _A1>
2642struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2643    : public false_type
2644    {};
2645
2646#endif  // _LIBCPP_HAS_NO_VARIADICS
2647#endif  // __has_feature(is_constructible)
2648
2649// is_default_constructible
2650
2651template <class _Tp>
2652struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
2653    : public is_constructible<_Tp>
2654    {};
2655
2656// is_copy_constructible
2657
2658template <class _Tp>
2659struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
2660    : public is_constructible<_Tp, 
2661                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2662
2663// is_move_constructible
2664
2665template <class _Tp>
2666struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
2667#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2668    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2669#else
2670    : public is_copy_constructible<_Tp>
2671#endif
2672    {};
2673
2674// is_trivially_constructible
2675
2676#ifndef _LIBCPP_HAS_NO_VARIADICS
2677
2678#if __has_feature(is_trivially_constructible)
2679
2680template <class _Tp, class... _Args>
2681struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2682    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2683{
2684};
2685
2686#else  // !__has_feature(is_trivially_constructible)
2687
2688template <class _Tp, class... _Args>
2689struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2690    : false_type
2691{
2692};
2693
2694template <class _Tp>
2695struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
2696#if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
2697    : integral_constant<bool, __has_trivial_constructor(_Tp)>
2698#else
2699    : integral_constant<bool, is_scalar<_Tp>::value>
2700#endif
2701{
2702};
2703
2704template <class _Tp>
2705#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2706struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
2707#else
2708struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
2709#endif
2710    : integral_constant<bool, is_scalar<_Tp>::value>
2711{
2712};
2713
2714template <class _Tp>
2715struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
2716    : integral_constant<bool, is_scalar<_Tp>::value>
2717{
2718};
2719
2720template <class _Tp>
2721struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
2722    : integral_constant<bool, is_scalar<_Tp>::value>
2723{
2724};
2725
2726#endif  // !__has_feature(is_trivially_constructible)
2727
2728#else  // _LIBCPP_HAS_NO_VARIADICS
2729
2730template <class _Tp, class _A0 = __is_construct::__nat,
2731                     class _A1 = __is_construct::__nat>
2732struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2733    : false_type
2734{
2735};
2736
2737#if __has_feature(is_trivially_constructible)
2738
2739template <class _Tp>
2740struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2741                                                       __is_construct::__nat>
2742    : integral_constant<bool, __is_trivially_constructible(_Tp)>
2743{
2744};
2745
2746template <class _Tp>
2747struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2748                                                       __is_construct::__nat>
2749    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2750{
2751};
2752
2753template <class _Tp>
2754struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2755                                                       __is_construct::__nat>
2756    : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2757{
2758};
2759
2760template <class _Tp>
2761struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2762                                                       __is_construct::__nat>
2763    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2764{
2765};
2766
2767#else  // !__has_feature(is_trivially_constructible)
2768
2769template <class _Tp>
2770struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2771                                                       __is_construct::__nat>
2772    : integral_constant<bool, is_scalar<_Tp>::value>
2773{
2774};
2775
2776template <class _Tp>
2777struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2778                                                       __is_construct::__nat>
2779    : integral_constant<bool, is_scalar<_Tp>::value>
2780{
2781};
2782
2783template <class _Tp>
2784struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2785                                                       __is_construct::__nat>
2786    : integral_constant<bool, is_scalar<_Tp>::value>
2787{
2788};
2789
2790template <class _Tp>
2791struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2792                                                       __is_construct::__nat>
2793    : integral_constant<bool, is_scalar<_Tp>::value>
2794{
2795};
2796
2797#endif  // !__has_feature(is_trivially_constructible)
2798
2799#endif  // _LIBCPP_HAS_NO_VARIADICS
2800
2801// is_trivially_default_constructible
2802
2803template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
2804    : public is_trivially_constructible<_Tp>
2805    {};
2806
2807// is_trivially_copy_constructible
2808
2809template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
2810    : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2811    {};
2812
2813// is_trivially_move_constructible
2814
2815template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
2816#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2817    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2818#else
2819    : public is_trivially_copy_constructible<_Tp>
2820#endif
2821    {};
2822
2823// is_trivially_assignable
2824
2825#if __has_feature(is_trivially_assignable)
2826
2827template <class _Tp, class _Arg>
2828struct is_trivially_assignable
2829    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2830{
2831};
2832
2833#else  // !__has_feature(is_trivially_assignable)
2834
2835template <class _Tp, class _Arg>
2836struct is_trivially_assignable
2837    : public false_type {};
2838
2839template <class _Tp>
2840struct is_trivially_assignable<_Tp&, _Tp>
2841    : integral_constant<bool, is_scalar<_Tp>::value> {};
2842
2843template <class _Tp>
2844struct is_trivially_assignable<_Tp&, _Tp&>
2845    : integral_constant<bool, is_scalar<_Tp>::value> {};
2846
2847template <class _Tp>
2848struct is_trivially_assignable<_Tp&, const _Tp&>
2849    : integral_constant<bool, is_scalar<_Tp>::value> {};
2850
2851#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2852
2853template <class _Tp>
2854struct is_trivially_assignable<_Tp&, _Tp&&>
2855    : integral_constant<bool, is_scalar<_Tp>::value> {};
2856
2857#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2858
2859#endif  // !__has_feature(is_trivially_assignable)
2860
2861// is_trivially_copy_assignable
2862
2863template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
2864    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2865                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2866
2867// is_trivially_move_assignable
2868
2869template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
2870    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2871#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2872                                     typename add_rvalue_reference<_Tp>::type>
2873#else
2874                                     typename add_lvalue_reference<_Tp>::type>
2875#endif
2876    {};
2877
2878// is_trivially_destructible
2879
2880#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
2881
2882template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2883    : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
2884
2885#else
2886
2887template <class _Tp> struct __libcpp_trivial_destructor
2888    : public integral_constant<bool, is_scalar<_Tp>::value ||
2889                                     is_reference<_Tp>::value> {};
2890
2891template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2892    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2893
2894#endif
2895
2896// is_nothrow_constructible
2897
2898#if 0
2899template <class _Tp, class... _Args>
2900struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2901    : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
2902{
2903};
2904
2905#else
2906
2907#ifndef _LIBCPP_HAS_NO_VARIADICS
2908
2909#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
2910
2911template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
2912
2913template <class _Tp, class... _Args>
2914struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
2915    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2916{
2917};
2918
2919template <class _Tp>
2920void __implicit_conversion_to(_Tp) noexcept { }
2921
2922template <class _Tp, class _Arg>
2923struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
2924    : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
2925{
2926};
2927
2928template <class _Tp, bool _IsReference, class... _Args>
2929struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
2930    : public false_type
2931{
2932};
2933
2934template <class _Tp, class... _Args>
2935struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2936    : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
2937{
2938};
2939
2940template <class _Tp, size_t _Ns>
2941struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
2942    : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
2943{
2944};
2945
2946#else  // __has_feature(cxx_noexcept)
2947
2948template <class _Tp, class... _Args>
2949struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2950    : false_type
2951{
2952};
2953
2954template <class _Tp>
2955struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
2956#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
2957    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2958#else
2959    : integral_constant<bool, is_scalar<_Tp>::value>
2960#endif
2961{
2962};
2963
2964template <class _Tp>
2965#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2966struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
2967#else
2968struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
2969#endif
2970#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
2971    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2972#else
2973    : integral_constant<bool, is_scalar<_Tp>::value>
2974#endif
2975{
2976};
2977
2978template <class _Tp>
2979struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
2980#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
2981    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2982#else
2983    : integral_constant<bool, is_scalar<_Tp>::value>
2984#endif
2985{
2986};
2987
2988template <class _Tp>
2989struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
2990#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
2991    : integral_constant<bool, __has_nothrow_copy(_Tp)>
2992#else
2993    : integral_constant<bool, is_scalar<_Tp>::value>
2994#endif
2995{
2996};
2997
2998#endif  // __has_feature(cxx_noexcept)
2999
3000#else  // _LIBCPP_HAS_NO_VARIADICS
3001
3002template <class _Tp, class _A0 = __is_construct::__nat,
3003                     class _A1 = __is_construct::__nat>
3004struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3005    : false_type
3006{
3007};
3008
3009template <class _Tp>
3010struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
3011                                                       __is_construct::__nat>
3012#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3013    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3014#else
3015    : integral_constant<bool, is_scalar<_Tp>::value>
3016#endif
3017{
3018};
3019
3020template <class _Tp>
3021struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
3022                                                       __is_construct::__nat>
3023#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3024    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3025#else
3026    : integral_constant<bool, is_scalar<_Tp>::value>
3027#endif
3028{
3029};
3030
3031template <class _Tp>
3032struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
3033                                                       __is_construct::__nat>
3034#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3035    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3036#else
3037    : integral_constant<bool, is_scalar<_Tp>::value>
3038#endif
3039{
3040};
3041
3042template <class _Tp>
3043struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
3044                                                       __is_construct::__nat>
3045#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3046    : integral_constant<bool, __has_nothrow_copy(_Tp)>
3047#else
3048    : integral_constant<bool, is_scalar<_Tp>::value>
3049#endif
3050{
3051};
3052
3053#endif  // _LIBCPP_HAS_NO_VARIADICS
3054#endif  // __has_feature(is_nothrow_constructible)
3055
3056// is_nothrow_default_constructible
3057
3058template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
3059    : public is_nothrow_constructible<_Tp>
3060    {};
3061
3062// is_nothrow_copy_constructible
3063
3064template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
3065    : public is_nothrow_constructible<_Tp,
3066                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3067
3068// is_nothrow_move_constructible
3069
3070template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
3071#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3072    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3073#else
3074    : public is_nothrow_copy_constructible<_Tp>
3075#endif
3076    {};
3077
3078// is_nothrow_assignable
3079
3080#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3081
3082template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3083
3084template <class _Tp, class _Arg>
3085struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3086    : public false_type
3087{
3088};
3089
3090template <class _Tp, class _Arg>
3091struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3092    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3093{
3094};
3095
3096template <class _Tp, class _Arg>
3097struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3098    : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3099{
3100};
3101
3102#else  // __has_feature(cxx_noexcept)
3103
3104template <class _Tp, class _Arg>
3105struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3106    : public false_type {};
3107
3108template <class _Tp>
3109struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
3110#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3111    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3112#else
3113    : integral_constant<bool, is_scalar<_Tp>::value> {};
3114#endif
3115
3116template <class _Tp>
3117struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
3118#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3119    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3120#else
3121    : integral_constant<bool, is_scalar<_Tp>::value> {};
3122#endif
3123
3124template <class _Tp>
3125struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
3126#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3127    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3128#else
3129    : integral_constant<bool, is_scalar<_Tp>::value> {};
3130#endif
3131
3132#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3133
3134template <class _Tp>
3135struct is_nothrow_assignable<_Tp&, _Tp&&>
3136#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3137    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3138#else
3139    : integral_constant<bool, is_scalar<_Tp>::value> {};
3140#endif
3141
3142#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3143
3144#endif  // __has_feature(cxx_noexcept)
3145
3146// is_nothrow_copy_assignable
3147
3148template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
3149    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3150                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3151
3152// is_nothrow_move_assignable
3153
3154template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
3155    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3156#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3157                                     typename add_rvalue_reference<_Tp>::type>
3158#else
3159                                     typename add_lvalue_reference<_Tp>::type>
3160#endif
3161    {};
3162
3163// is_nothrow_destructible
3164
3165#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3166
3167template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3168
3169template <class _Tp>
3170struct __libcpp_is_nothrow_destructible<false, _Tp>
3171    : public false_type
3172{
3173};
3174
3175template <class _Tp>
3176struct __libcpp_is_nothrow_destructible<true, _Tp>
3177    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3178{
3179};
3180
3181template <class _Tp>
3182struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3183    : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3184{
3185};
3186
3187template <class _Tp, size_t _Ns>
3188struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
3189    : public is_nothrow_destructible<_Tp>
3190{
3191};
3192
3193template <class _Tp>
3194struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
3195    : public true_type
3196{
3197};
3198
3199#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3200
3201template <class _Tp>
3202struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
3203    : public true_type
3204{
3205};
3206
3207#endif
3208
3209#else
3210
3211template <class _Tp> struct __libcpp_nothrow_destructor
3212    : public integral_constant<bool, is_scalar<_Tp>::value ||
3213                                     is_reference<_Tp>::value> {};
3214
3215template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3216    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3217
3218#endif
3219
3220// is_pod
3221
3222#if __has_feature(is_pod) || (_GNUC_VER >= 403)
3223
3224template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3225    : public integral_constant<bool, __is_pod(_Tp)> {};
3226
3227#else
3228
3229template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3230    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
3231                                     is_trivially_copy_constructible<_Tp>::value      &&
3232                                     is_trivially_copy_assignable<_Tp>::value    &&
3233                                     is_trivially_destructible<_Tp>::value> {};
3234
3235#endif
3236
3237// is_literal_type;
3238
3239template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
3240#ifdef _LIBCPP_IS_LITERAL
3241    : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3242#else
3243    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3244                              is_reference<typename remove_all_extents<_Tp>::type>::value>
3245#endif
3246    {};
3247    
3248// is_standard_layout;
3249
3250template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
3251#if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3252    : public integral_constant<bool, __is_standard_layout(_Tp)>
3253#else
3254    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3255#endif
3256    {};
3257    
3258// is_trivially_copyable;
3259
3260template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
3261#if __has_feature(is_trivially_copyable)
3262    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3263#else
3264    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3265#endif
3266    {};
3267    
3268// is_trivial;
3269
3270template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
3271#if __has_feature(is_trivial) || (_GNUC_VER >= 407)
3272    : public integral_constant<bool, __is_trivial(_Tp)>
3273#else
3274    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3275                                 is_trivially_default_constructible<_Tp>::value>
3276#endif
3277    {};
3278
3279#ifndef _LIBCPP_HAS_NO_VARIADICS
3280
3281// Check for complete types
3282
3283template <class ..._Tp> struct __check_complete;
3284
3285template <>
3286struct __check_complete<>
3287{
3288};
3289
3290template <class _Hp, class _T0, class ..._Tp>
3291struct __check_complete<_Hp, _T0, _Tp...>
3292    : private __check_complete<_Hp>,
3293      private __check_complete<_T0, _Tp...>
3294{
3295};
3296
3297template <class _Hp>
3298struct __check_complete<_Hp, _Hp>
3299    : private __check_complete<_Hp>
3300{
3301};
3302
3303template <class _Tp>
3304struct __check_complete<_Tp>
3305{
3306    static_assert(sizeof(_Tp) > 0, "Type must be complete.");
3307};
3308
3309template <class _Tp>
3310struct __check_complete<_Tp&>
3311    : private __check_complete<_Tp>
3312{
3313};
3314
3315template <class _Tp>
3316struct __check_complete<_Tp&&>
3317    : private __check_complete<_Tp>
3318{
3319};
3320
3321template <class _Rp, class ..._Param>
3322struct __check_complete<_Rp (*)(_Param...)>
3323    : private __check_complete<_Rp>
3324{
3325};
3326
3327template <class ..._Param>
3328struct __check_complete<void (*)(_Param...)>
3329{
3330};
3331
3332template <class _Rp, class ..._Param>
3333struct __check_complete<_Rp (_Param...)>
3334    : private __check_complete<_Rp>
3335{
3336};
3337
3338template <class ..._Param>
3339struct __check_complete<void (_Param...)>
3340{
3341};
3342
3343template <class _Rp, class _Class, class ..._Param>
3344struct __check_complete<_Rp (_Class::*)(_Param...)>
3345    : private __check_complete<_Class>
3346{
3347};
3348
3349template <class _Rp, class _Class, class ..._Param>
3350struct __check_complete<_Rp (_Class::*)(_Param...) const>
3351    : private __check_complete<_Class>
3352{
3353};
3354
3355template <class _Rp, class _Class, class ..._Param>
3356struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
3357    : private __check_complete<_Class>
3358{
3359};
3360
3361template <class _Rp, class _Class, class ..._Param>
3362struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
3363    : private __check_complete<_Class>
3364{
3365};
3366
3367#if __has_feature(cxx_reference_qualified_functions)
3368
3369template <class _Rp, class _Class, class ..._Param>
3370struct __check_complete<_Rp (_Class::*)(_Param...) &>
3371    : private __check_complete<_Class>
3372{
3373};
3374
3375template <class _Rp, class _Class, class ..._Param>
3376struct __check_complete<_Rp (_Class::*)(_Param...) const&>
3377    : private __check_complete<_Class>
3378{
3379};
3380
3381template <class _Rp, class _Class, class ..._Param>
3382struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
3383    : private __check_complete<_Class>
3384{
3385};
3386
3387template <class _Rp, class _Class, class ..._Param>
3388struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
3389    : private __check_complete<_Class>
3390{
3391};
3392
3393template <class _Rp, class _Class, class ..._Param>
3394struct __check_complete<_Rp (_Class::*)(_Param...) &&>
3395    : private __check_complete<_Class>
3396{
3397};
3398
3399template <class _Rp, class _Class, class ..._Param>
3400struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
3401    : private __check_complete<_Class>
3402{
3403};
3404
3405template <class _Rp, class _Class, class ..._Param>
3406struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
3407    : private __check_complete<_Class>
3408{
3409};
3410
3411template <class _Rp, class _Class, class ..._Param>
3412struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
3413    : private __check_complete<_Class>
3414{
3415};
3416
3417#endif
3418
3419template <class _Rp, class _Class>
3420struct __check_complete<_Rp _Class::*>
3421    : private __check_complete<_Class>
3422{
3423};
3424
3425// __invoke forward declarations
3426
3427// fall back - none of the bullets
3428
3429template <class ..._Args>
3430auto
3431__invoke(__any, _Args&& ...__args)
3432    -> __nat;
3433
3434// bullets 1 and 2
3435
3436template <class _Fp, class _A0, class ..._Args,
3437            class = typename enable_if
3438            <
3439                is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3440                is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3441                           typename remove_reference<_A0>::type>::value
3442            >::type
3443         >
3444_LIBCPP_INLINE_VISIBILITY
3445auto
3446__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3447    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
3448
3449template <class _Fp, class _A0, class ..._Args,
3450            class = typename enable_if
3451            <
3452                is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3453                !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3454                           typename remove_reference<_A0>::type>::value
3455            >::type
3456         >
3457_LIBCPP_INLINE_VISIBILITY
3458auto
3459__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3460    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
3461
3462// bullets 3 and 4
3463
3464template <class _Fp, class _A0,
3465            class = typename enable_if
3466            <
3467                is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3468                is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3469                           typename remove_reference<_A0>::type>::value
3470            >::type
3471         >
3472_LIBCPP_INLINE_VISIBILITY
3473auto
3474__invoke(_Fp&& __f, _A0&& __a0)
3475    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
3476
3477template <class _Fp, class _A0,
3478            class = typename enable_if
3479            <
3480                is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3481                !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3482                           typename remove_reference<_A0>::type>::value
3483            >::type
3484         >
3485_LIBCPP_INLINE_VISIBILITY
3486auto
3487__invoke(_Fp&& __f, _A0&& __a0)
3488    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
3489
3490// bullet 5
3491
3492template <class _Fp, class ..._Args>
3493_LIBCPP_INLINE_VISIBILITY
3494auto
3495__invoke(_Fp&& __f, _Args&& ...__args)
3496    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
3497
3498// __invokable
3499
3500template <class _Fp, class ..._Args>
3501struct __invokable_imp
3502    : private __check_complete<_Fp>
3503{
3504    typedef decltype(
3505            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
3506                    ) type;
3507    static const bool value = !is_same<type, __nat>::value;
3508};
3509
3510template <class _Fp, class ..._Args>
3511struct __invokable
3512    : public integral_constant<bool,
3513          __invokable_imp<_Fp, _Args...>::value>
3514{
3515};
3516
3517// __invoke_of
3518
3519template <bool _Invokable, class _Fp, class ..._Args>
3520struct __invoke_of_imp  // false
3521{
3522};
3523
3524template <class _Fp, class ..._Args>
3525struct __invoke_of_imp<true, _Fp, _Args...>
3526{
3527    typedef typename __invokable_imp<_Fp, _Args...>::type type;
3528};
3529
3530template <class _Fp, class ..._Args>
3531struct __invoke_of
3532    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
3533{
3534};
3535
3536template <class _Fp, class ..._Args>
3537class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
3538    : public __invoke_of<_Fp, _Args...>
3539{
3540};
3541
3542#if _LIBCPP_STD_VER > 11
3543template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3544#endif
3545
3546#endif  // _LIBCPP_HAS_NO_VARIADICS
3547
3548template <class _Tp>
3549inline _LIBCPP_INLINE_VISIBILITY
3550#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3551typename enable_if
3552<
3553    is_move_constructible<_Tp>::value &&
3554    is_move_assignable<_Tp>::value
3555>::type
3556#else
3557void
3558#endif
3559swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3560                                    is_nothrow_move_assignable<_Tp>::value)
3561{
3562    _Tp __t(_VSTD::move(__x));
3563    __x = _VSTD::move(__y);
3564    __y = _VSTD::move(__t);
3565}
3566
3567template <class _ForwardIterator1, class _ForwardIterator2>
3568inline _LIBCPP_INLINE_VISIBILITY
3569void
3570iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3571    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3572               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3573                                          *_VSTD::declval<_ForwardIterator2>())))
3574{
3575    swap(*__a, *__b);
3576}
3577
3578// __swappable
3579
3580namespace __detail
3581{
3582
3583using _VSTD::swap;
3584__nat swap(__any, __any);
3585
3586template <class _Tp>
3587struct __swappable
3588{
3589    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3590    static const bool value = !is_same<type, __nat>::value;
3591};
3592
3593}  // __detail
3594
3595template <class _Tp>
3596struct __is_swappable
3597    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3598{
3599};
3600
3601#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3602
3603template <bool, class _Tp>
3604struct __is_nothrow_swappable_imp
3605    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3606                                                   _VSTD::declval<_Tp&>()))>
3607{
3608};
3609
3610template <class _Tp>
3611struct __is_nothrow_swappable_imp<false, _Tp>
3612    : public false_type
3613{
3614};
3615
3616template <class _Tp>
3617struct __is_nothrow_swappable
3618    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3619{
3620};
3621
3622#else  // __has_feature(cxx_noexcept)
3623
3624template <class _Tp>
3625struct __is_nothrow_swappable
3626    : public false_type
3627{
3628};
3629
3630#endif  // __has_feature(cxx_noexcept)
3631
3632#ifdef _LIBCPP_UNDERLYING_TYPE
3633
3634template <class _Tp>
3635struct underlying_type
3636{
3637    typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
3638};
3639
3640#if _LIBCPP_STD_VER > 11
3641template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3642#endif
3643
3644#else  // _LIBCPP_UNDERLYING_TYPE
3645
3646template <class _Tp, bool _Support = false>
3647struct underlying_type
3648{
3649    static_assert(_Support, "The underyling_type trait requires compiler "
3650                            "support. Either no such support exists or "
3651                            "libc++ does not know how to use it.");
3652};
3653
3654#endif // _LIBCPP_UNDERLYING_TYPE
3655
3656#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3657
3658template <class _Tp>
3659struct __has_operator_addressof_member_imp
3660{
3661    template <class _Up>
3662        static auto __test(int)
3663            -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
3664    template <class>
3665        static auto __test(long) -> false_type;
3666
3667    static const bool value = decltype(__test<_Tp>(0))::value;
3668};
3669
3670template <class _Tp>
3671struct __has_operator_addressof_free_imp
3672{
3673    template <class _Up>
3674        static auto __test(int)
3675            -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
3676    template <class>
3677        static auto __test(long) -> false_type;
3678
3679    static const bool value = decltype(__test<_Tp>(0))::value;
3680};
3681
3682template <class _Tp>
3683struct __has_operator_addressof
3684    : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
3685                                  || __has_operator_addressof_free_imp<_Tp>::value>
3686{};
3687
3688#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
3689
3690#if _LIBCPP_STD_VER > 14
3691template <class...> using void_t = void;
3692#endif
3693
3694_LIBCPP_END_NAMESPACE_STD
3695
3696#endif  // _LIBCPP_TYPE_TRAITS
3697