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