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;   // C++11
     23     typedef integral_constant<bool, false> false_type;  // C++11
     24     
     25     template <bool B>                                   // C++14
     26     using bool_constant = integral_constant<bool, B>;   // C++14
     27     typedef bool_constant<true> true_type;              // C++14
     28     typedef bool_constant<false> false_type;            // C++14
     29 
     30     // helper traits
     31     template <bool, class T = void> struct enable_if;
     32     template <bool, class T, class F> struct conditional;
     33 
     34     // Primary classification traits:
     35     template <class T> struct is_void;
     36     template <class T> struct is_null_pointer;  // C++14
     37     template <class T> struct is_integral;
     38     template <class T> struct is_floating_point;
     39     template <class T> struct is_array;
     40     template <class T> struct is_pointer;
     41     template <class T> struct is_lvalue_reference;
     42     template <class T> struct is_rvalue_reference;
     43     template <class T> struct is_member_object_pointer;
     44     template <class T> struct is_member_function_pointer;
     45     template <class T> struct is_enum;
     46     template <class T> struct is_union;
     47     template <class T> struct is_class;
     48     template <class T> struct is_function;
     49 
     50     // Secondary classification traits:
     51     template <class T> struct is_reference;
     52     template <class T> struct is_arithmetic;
     53     template <class T> struct is_fundamental;
     54     template <class T> struct is_member_pointer;
     55     template <class T> struct is_scalar;
     56     template <class T> struct is_object;
     57     template <class T> struct is_compound;
     58 
     59     // Const-volatile properties and transformations:
     60     template <class T> struct is_const;
     61     template <class T> struct is_volatile;
     62     template <class T> struct remove_const;
     63     template <class T> struct remove_volatile;
     64     template <class T> struct remove_cv;
     65     template <class T> struct add_const;
     66     template <class T> struct add_volatile;
     67     template <class T> struct add_cv;
     68 
     69     // Reference transformations:
     70     template <class T> struct remove_reference;
     71     template <class T> struct add_lvalue_reference;
     72     template <class T> struct add_rvalue_reference;
     73 
     74     // Pointer transformations:
     75     template <class T> struct remove_pointer;
     76     template <class T> struct add_pointer;
     77 
     78     // Integral properties:
     79     template <class T> struct is_signed;
     80     template <class T> struct is_unsigned;
     81     template <class T> struct make_signed;
     82     template <class T> struct make_unsigned;
     83 
     84     // Array properties and transformations:
     85     template <class T> struct rank;
     86     template <class T, unsigned I = 0> struct extent;
     87     template <class T> struct remove_extent;
     88     template <class T> struct remove_all_extents;
     89 
     90     // Member introspection:
     91     template <class T> struct is_pod;
     92     template <class T> struct is_trivial;
     93     template <class T> struct is_trivially_copyable;
     94     template <class T> struct is_standard_layout;
     95     template <class T> struct is_literal_type;
     96     template <class T> struct is_empty;
     97     template <class T> struct is_polymorphic;
     98     template <class T> struct is_abstract;
     99     template <class T> struct is_final; // C++14
    100     template <class T> struct is_aggregate; // C++17
    101 
    102     template <class T, class... Args> struct is_constructible;
    103     template <class T>                struct is_default_constructible;
    104     template <class T>                struct is_copy_constructible;
    105     template <class T>                struct is_move_constructible;
    106     template <class T, class U>       struct is_assignable;
    107     template <class T>                struct is_copy_assignable;
    108     template <class T>                struct is_move_assignable;
    109     template <class T, class U>       struct is_swappable_with;       // C++17
    110     template <class T>                struct is_swappable;            // C++17
    111     template <class T>                struct is_destructible;
    112 
    113     template <class T, class... Args> struct is_trivially_constructible;
    114     template <class T>                struct is_trivially_default_constructible;
    115     template <class T>                struct is_trivially_copy_constructible;
    116     template <class T>                struct is_trivially_move_constructible;
    117     template <class T, class U>       struct is_trivially_assignable;
    118     template <class T>                struct is_trivially_copy_assignable;
    119     template <class T>                struct is_trivially_move_assignable;
    120     template <class T>                struct is_trivially_destructible;
    121 
    122     template <class T, class... Args> struct is_nothrow_constructible;
    123     template <class T>                struct is_nothrow_default_constructible;
    124     template <class T>                struct is_nothrow_copy_constructible;
    125     template <class T>                struct is_nothrow_move_constructible;
    126     template <class T, class U>       struct is_nothrow_assignable;
    127     template <class T>                struct is_nothrow_copy_assignable;
    128     template <class T>                struct is_nothrow_move_assignable;
    129     template <class T, class U>       struct is_nothrow_swappable_with; // C++17
    130     template <class T>                struct is_nothrow_swappable;      // C++17
    131     template <class T>                struct is_nothrow_destructible;
    132 
    133     template <class T> struct has_virtual_destructor;
    134 
    135     template<class T> struct has_unique_object_representations;         // C++17
    136 
    137     // Relationships between types:
    138     template <class T, class U> struct is_same;
    139     template <class Base, class Derived> struct is_base_of;
    140     template <class From, class To> struct is_convertible;
    141 
    142     template <class Fn, class... ArgTypes> struct is_invocable;
    143     template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
    144 
    145     template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
    146     template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
    147 
    148     // Alignment properties and transformations:
    149     template <class T> struct alignment_of;
    150     template <size_t Len, size_t Align = most_stringent_alignment_requirement>
    151         struct aligned_storage;
    152     template <size_t Len, class... Types> struct aligned_union;
    153     template <class T> struct remove_cvref; // C++20
    154 
    155     template <class T> struct decay;
    156     template <class... T> struct common_type;
    157     template <class T> struct underlying_type;
    158     template <class> class result_of; // undefined
    159     template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
    160     template <class Fn, class... ArgTypes> struct invoke_result;  // C++17
    161 
    162     // const-volatile modifications:
    163     template <class T>
    164       using remove_const_t    = typename remove_const<T>::type;  // C++14
    165     template <class T>
    166       using remove_volatile_t = typename remove_volatile<T>::type;  // C++14
    167     template <class T>
    168       using remove_cv_t       = typename remove_cv<T>::type;  // C++14
    169     template <class T>
    170       using add_const_t       = typename add_const<T>::type;  // C++14
    171     template <class T>
    172       using add_volatile_t    = typename add_volatile<T>::type;  // C++14
    173     template <class T>
    174       using add_cv_t          = typename add_cv<T>::type;  // C++14
    175   
    176     // reference modifications:
    177     template <class T>
    178       using remove_reference_t     = typename remove_reference<T>::type;  // C++14
    179     template <class T>
    180       using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;  // C++14
    181     template <class T>
    182       using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;  // C++14
    183   
    184     // sign modifications:
    185     template <class T>
    186       using make_signed_t   = typename make_signed<T>::type;  // C++14
    187     template <class T>
    188       using make_unsigned_t = typename make_unsigned<T>::type;  // C++14
    189   
    190     // array modifications:
    191     template <class T>
    192       using remove_extent_t      = typename remove_extent<T>::type;  // C++14
    193     template <class T>
    194       using remove_all_extents_t = typename remove_all_extents<T>::type;  // C++14
    195 
    196     // pointer modifications:
    197     template <class T>
    198       using remove_pointer_t = typename remove_pointer<T>::type;  // C++14
    199     template <class T>
    200       using add_pointer_t    = typename add_pointer<T>::type;  // C++14
    201 
    202     // other transformations:
    203     template <size_t Len, std::size_t Align=default-alignment>
    204       using aligned_storage_t = typename aligned_storage<Len,Align>::type;  // C++14
    205     template <std::size_t Len, class... Types>
    206       using aligned_union_t   = typename aligned_union<Len,Types...>::type;  // C++14
    207     template <class T>
    208       using remove_cvref_t    = typename remove_cvref<T>::type;  // C++20
    209     template <class T>
    210       using decay_t           = typename decay<T>::type;  // C++14
    211     template <bool b, class T=void>
    212       using enable_if_t       = typename enable_if<b,T>::type;  // C++14
    213     template <bool b, class T, class F>
    214       using conditional_t     = typename conditional<b,T,F>::type;  // C++14
    215     template <class... T>
    216       using common_type_t     = typename common_type<T...>::type;  // C++14
    217     template <class T>
    218       using underlying_type_t = typename underlying_type<T>::type;  // C++14
    219     template <class T>
    220       using result_of_t       = typename result_of<T>::type;  // C++14
    221     template <class Fn, class... ArgTypes>
    222       using invoke_result_t   = typename invoke_result<Fn, ArgTypes...>::type;  // C++17
    223 
    224     template <class...>
    225       using void_t = void;   // C++17
    226       
    227       // See C++14 20.10.4.1, primary type categories
    228       template <class T> inline constexpr bool is_void_v
    229         = is_void<T>::value;                                             // C++17
    230       template <class T> inline constexpr bool is_null_pointer_v
    231         = is_null_pointer<T>::value;                                     // C++17
    232       template <class T> inline constexpr bool is_integral_v
    233         = is_integral<T>::value;                                         // C++17
    234       template <class T> inline constexpr bool is_floating_point_v
    235         = is_floating_point<T>::value;                                   // C++17
    236       template <class T> inline constexpr bool is_array_v
    237         = is_array<T>::value;                                            // C++17
    238       template <class T> inline constexpr bool is_pointer_v
    239         = is_pointer<T>::value;                                          // C++17
    240       template <class T> inline constexpr bool is_lvalue_reference_v
    241         = is_lvalue_reference<T>::value;                                 // C++17
    242       template <class T> inline constexpr bool is_rvalue_reference_v
    243         = is_rvalue_reference<T>::value;                                 // C++17
    244       template <class T> inline constexpr bool is_member_object_pointer_v
    245         = is_member_object_pointer<T>::value;                            // C++17
    246       template <class T> inline constexpr bool is_member_function_pointer_v
    247         = is_member_function_pointer<T>::value;                          // C++17
    248       template <class T> inline constexpr bool is_enum_v
    249         = is_enum<T>::value;                                             // C++17
    250       template <class T> inline constexpr bool is_union_v
    251         = is_union<T>::value;                                            // C++17
    252       template <class T> inline constexpr bool is_class_v
    253         = is_class<T>::value;                                            // C++17
    254       template <class T> inline constexpr bool is_function_v
    255         = is_function<T>::value;                                         // C++17
    256 
    257       // See C++14 20.10.4.2, composite type categories
    258       template <class T> inline constexpr bool is_reference_v
    259         = is_reference<T>::value;                                        // C++17
    260       template <class T> inline constexpr bool is_arithmetic_v
    261         = is_arithmetic<T>::value;                                       // C++17
    262       template <class T> inline constexpr bool is_fundamental_v
    263         = is_fundamental<T>::value;                                      // C++17
    264       template <class T> inline constexpr bool is_object_v
    265         = is_object<T>::value;                                           // C++17
    266       template <class T> inline constexpr bool is_scalar_v
    267         = is_scalar<T>::value;                                           // C++17
    268       template <class T> inline constexpr bool is_compound_v
    269         = is_compound<T>::value;                                         // C++17
    270       template <class T> inline constexpr bool is_member_pointer_v
    271         = is_member_pointer<T>::value;                                   // C++17
    272 
    273       // See C++14 20.10.4.3, type properties
    274       template <class T> inline constexpr bool is_const_v
    275         = is_const<T>::value;                                            // C++17
    276       template <class T> inline constexpr bool is_volatile_v
    277         = is_volatile<T>::value;                                         // C++17
    278       template <class T> inline constexpr bool is_trivial_v
    279         = is_trivial<T>::value;                                          // C++17
    280       template <class T> inline constexpr bool is_trivially_copyable_v
    281         = is_trivially_copyable<T>::value;                               // C++17
    282       template <class T> inline constexpr bool is_standard_layout_v
    283         = is_standard_layout<T>::value;                                  // C++17
    284       template <class T> inline constexpr bool is_pod_v
    285         = is_pod<T>::value;                                              // C++17
    286       template <class T> inline constexpr bool is_literal_type_v
    287         = is_literal_type<T>::value;                                     // C++17
    288       template <class T> inline constexpr bool is_empty_v
    289         = is_empty<T>::value;                                            // C++17
    290       template <class T> inline constexpr bool is_polymorphic_v
    291         = is_polymorphic<T>::value;                                      // C++17
    292       template <class T> inline constexpr bool is_abstract_v
    293         = is_abstract<T>::value;                                         // C++17
    294       template <class T> inline constexpr bool is_final_v
    295         = is_final<T>::value;                                            // C++17
    296       template <class T> inline constexpr bool is_aggregate_v
    297         = is_aggregate<T>::value;                                        // C++17
    298       template <class T> inline constexpr bool is_signed_v
    299         = is_signed<T>::value;                                           // C++17
    300       template <class T> inline constexpr bool is_unsigned_v
    301         = is_unsigned<T>::value;                                         // C++17
    302       template <class T, class... Args> inline constexpr bool is_constructible_v
    303         = is_constructible<T, Args...>::value;                           // C++17
    304       template <class T> inline constexpr bool is_default_constructible_v
    305         = is_default_constructible<T>::value;                            // C++17
    306       template <class T> inline constexpr bool is_copy_constructible_v
    307         = is_copy_constructible<T>::value;                               // C++17
    308       template <class T> inline constexpr bool is_move_constructible_v
    309         = is_move_constructible<T>::value;                               // C++17
    310       template <class T, class U> inline constexpr bool is_assignable_v
    311         = is_assignable<T, U>::value;                                    // C++17
    312       template <class T> inline constexpr bool is_copy_assignable_v
    313         = is_copy_assignable<T>::value;                                  // C++17
    314       template <class T> inline constexpr bool is_move_assignable_v
    315         = is_move_assignable<T>::value;                                  // C++17
    316       template <class T, class U> inline constexpr bool is_swappable_with_v
    317         = is_swappable_with<T, U>::value;                                // C++17
    318       template <class T> inline constexpr bool is_swappable_v
    319         = is_swappable<T>::value;                                        // C++17
    320       template <class T> inline constexpr bool is_destructible_v
    321         = is_destructible<T>::value;                                     // C++17
    322       template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
    323         = is_trivially_constructible<T, Args...>::value;                 // C++17
    324       template <class T> inline constexpr bool is_trivially_default_constructible_v
    325         = is_trivially_default_constructible<T>::value;                  // C++17
    326       template <class T> inline constexpr bool is_trivially_copy_constructible_v
    327         = is_trivially_copy_constructible<T>::value;                     // C++17
    328       template <class T> inline constexpr bool is_trivially_move_constructible_v
    329         = is_trivially_move_constructible<T>::value;                     // C++17
    330       template <class T, class U> inline constexpr bool is_trivially_assignable_v
    331         = is_trivially_assignable<T, U>::value;                          // C++17
    332       template <class T> inline constexpr bool is_trivially_copy_assignable_v
    333         = is_trivially_copy_assignable<T>::value;                        // C++17
    334       template <class T> inline constexpr bool is_trivially_move_assignable_v
    335         = is_trivially_move_assignable<T>::value;                        // C++17
    336       template <class T> inline constexpr bool is_trivially_destructible_v
    337         = is_trivially_destructible<T>::value;                           // C++17
    338       template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
    339         = is_nothrow_constructible<T, Args...>::value;                   // C++17
    340       template <class T> inline constexpr bool is_nothrow_default_constructible_v
    341         = is_nothrow_default_constructible<T>::value;                    // C++17
    342       template <class T> inline constexpr bool is_nothrow_copy_constructible_v
    343         = is_nothrow_copy_constructible<T>::value;                       // C++17
    344       template <class T> inline constexpr bool is_nothrow_move_constructible_v
    345         = is_nothrow_move_constructible<T>::value;                       // C++17
    346       template <class T, class U> inline constexpr bool is_nothrow_assignable_v
    347         = is_nothrow_assignable<T, U>::value;                            // C++17
    348       template <class T> inline constexpr bool is_nothrow_copy_assignable_v
    349         = is_nothrow_copy_assignable<T>::value;                          // C++17
    350       template <class T> inline constexpr bool is_nothrow_move_assignable_v
    351         = is_nothrow_move_assignable<T>::value;                          // C++17
    352       template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
    353         = is_nothrow_swappable_with<T, U>::value;                       // C++17
    354       template <class T> inline constexpr bool is_nothrow_swappable_v
    355         = is_nothrow_swappable<T>::value;                               // C++17
    356       template <class T> inline constexpr bool is_nothrow_destructible_v
    357         = is_nothrow_destructible<T>::value;                             // C++17
    358       template <class T> inline constexpr bool has_virtual_destructor_v
    359         = has_virtual_destructor<T>::value;                              // C++17
    360       template<class T> inline constexpr bool has_unique_object_representations_v // C++17
    361         = has_unique_object_representations<T>::value;
    362 
    363       // See C++14 20.10.5, type property queries
    364       template <class T> inline constexpr size_t alignment_of_v
    365         = alignment_of<T>::value;                                        // C++17
    366       template <class T> inline constexpr size_t rank_v
    367         = rank<T>::value;                                                // C++17
    368       template <class T, unsigned I = 0> inline constexpr size_t extent_v
    369         = extent<T, I>::value;                                           // C++17
    370 
    371       // See C++14 20.10.6, type relations
    372       template <class T, class U> inline constexpr bool is_same_v
    373         = is_same<T, U>::value;                                          // C++17
    374       template <class Base, class Derived> inline constexpr bool is_base_of_v
    375         = is_base_of<Base, Derived>::value;                              // C++17
    376       template <class From, class To> inline constexpr bool is_convertible_v
    377         = is_convertible<From, To>::value;                               // C++17
    378       template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
    379         = is_invocable<Fn, ArgTypes...>::value;                          // C++17
    380       template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
    381         = is_invocable_r<R, Fn, ArgTypes...>::value;                     // C++17
    382       template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
    383         = is_nothrow_invocable<Fn, ArgTypes...>::value;                  // C++17
    384       template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
    385         = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value;             // C++17
    386 
    387       // [meta.logical], logical operator traits:
    388       template<class... B> struct conjunction;                           // C++17
    389       template<class... B> 
    390         inline constexpr bool conjunction_v = conjunction<B...>::value;  // C++17
    391       template<class... B> struct disjunction;                           // C++17
    392       template<class... B>
    393         inline constexpr bool disjunction_v = disjunction<B...>::value;  // C++17
    394       template<class B> struct negation;                                 // C++17
    395       template<class B> 
    396         inline constexpr bool negation_v = negation<B>::value;           // C++17
    397 
    398 }
    399 
    400 */
    401 #include <__config>
    402 #include <cstddef>
    403 
    404 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
    405 #pragma GCC system_header
    406 #endif
    407 
    408 _LIBCPP_BEGIN_NAMESPACE_STD
    409 
    410 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
    411 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
    412 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
    413 
    414 template <class>
    415 struct __void_t { typedef void type; };
    416 
    417 template <class _Tp>
    418 struct __identity { typedef _Tp type; };
    419 
    420 template <class _Tp, bool>
    421 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
    422 
    423 template <bool _Bp, class _If, class _Then>
    424     struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
    425 template <class _If, class _Then>
    426     struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
    427 
    428 #if _LIBCPP_STD_VER > 11
    429 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
    430 #endif
    431 
    432 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {};
    433 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
    434 
    435 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
    436 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
    437 
    438 #if _LIBCPP_STD_VER > 11
    439 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
    440 #endif
    441 
    442 // addressof
    443 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
    444 
    445 template <class _Tp>
    446 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
    447 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
    448 _Tp*
    449 addressof(_Tp& __x) _NOEXCEPT
    450 {
    451     return __builtin_addressof(__x);
    452 }
    453 
    454 #else
    455 
    456 template <class _Tp>
    457 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
    458 _Tp*
    459 addressof(_Tp& __x) _NOEXCEPT
    460 {
    461   return reinterpret_cast<_Tp *>(
    462       const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
    463 }
    464 
    465 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
    466 
    467 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
    468 // Objective-C++ Automatic Reference Counting uses qualified pointers
    469 // that require special addressof() signatures. When
    470 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
    471 // itself is providing these definitions. Otherwise, we provide them.
    472 template <class _Tp>
    473 inline _LIBCPP_INLINE_VISIBILITY
    474 __strong _Tp*
    475 addressof(__strong _Tp& __x) _NOEXCEPT
    476 {
    477   return &__x;
    478 }
    479 
    480 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
    481 template <class _Tp>
    482 inline _LIBCPP_INLINE_VISIBILITY
    483 __weak _Tp*
    484 addressof(__weak _Tp& __x) _NOEXCEPT
    485 {
    486   return &__x;
    487 }
    488 #endif
    489 
    490 template <class _Tp>
    491 inline _LIBCPP_INLINE_VISIBILITY
    492 __autoreleasing _Tp*
    493 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
    494 {
    495   return &__x;
    496 }
    497 
    498 template <class _Tp>
    499 inline _LIBCPP_INLINE_VISIBILITY
    500 __unsafe_unretained _Tp*
    501 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
    502 {
    503   return &__x;
    504 }
    505 #endif
    506 
    507 #if !defined(_LIBCPP_CXX03_LANG)
    508 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
    509 #endif
    510 
    511 struct __two {char __lx[2];};
    512 
    513 // helper class:
    514 
    515 template <class _Tp, _Tp __v>
    516 struct _LIBCPP_TEMPLATE_VIS integral_constant
    517 {
    518     static _LIBCPP_CONSTEXPR const _Tp      value = __v;
    519     typedef _Tp               value_type;
    520     typedef integral_constant type;
    521     _LIBCPP_INLINE_VISIBILITY
    522         _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
    523 #if _LIBCPP_STD_VER > 11
    524     _LIBCPP_INLINE_VISIBILITY
    525          constexpr value_type operator ()() const _NOEXCEPT {return value;}
    526 #endif
    527 };
    528 
    529 template <class _Tp, _Tp __v>
    530 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
    531 
    532 #if _LIBCPP_STD_VER > 14
    533 template <bool __b>
    534 using bool_constant = integral_constant<bool, __b>;
    535 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
    536 #else
    537 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
    538 #endif
    539 
    540 typedef _LIBCPP_BOOL_CONSTANT(true)  true_type;
    541 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
    542 
    543 #if !defined(_LIBCPP_CXX03_LANG)
    544 
    545 // __lazy_and
    546 
    547 template <bool _Last, class ..._Preds>
    548 struct __lazy_and_impl;
    549 
    550 template <class ..._Preds>
    551 struct __lazy_and_impl<false, _Preds...> : false_type {};
    552 
    553 template <>
    554 struct __lazy_and_impl<true> : true_type {};
    555 
    556 template <class _Pred>
    557 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
    558 
    559 template <class _Hp, class ..._Tp>
    560 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
    561 
    562 template <class _P1, class ..._Pr>
    563 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
    564 
    565 // __lazy_or
    566 
    567 template <bool _List, class ..._Preds>
    568 struct __lazy_or_impl;
    569 
    570 template <class ..._Preds>
    571 struct __lazy_or_impl<true, _Preds...> : true_type {};
    572 
    573 template <>
    574 struct __lazy_or_impl<false> : false_type {};
    575 
    576 template <class _Hp, class ..._Tp>
    577 struct __lazy_or_impl<false, _Hp, _Tp...>
    578         : __lazy_or_impl<_Hp::type::value, _Tp...> {};
    579 
    580 template <class _P1, class ..._Pr>
    581 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
    582 
    583 // __lazy_not
    584 
    585 template <class _Pred>
    586 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
    587 
    588 // __and_
    589 template<class...> struct __and_;
    590 template<> struct __and_<> : true_type {};
    591 
    592 template<class _B0> struct __and_<_B0> : _B0 {};
    593 
    594 template<class _B0, class _B1>
    595 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
    596 
    597 template<class _B0, class _B1, class _B2, class... _Bn>
    598 struct __and_<_B0, _B1, _B2, _Bn...> 
    599         : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
    600 
    601 // __or_
    602 template<class...> struct __or_;
    603 template<> struct __or_<> : false_type {};
    604 
    605 template<class _B0> struct __or_<_B0> : _B0 {};
    606 
    607 template<class _B0, class _B1>
    608 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
    609 
    610 template<class _B0, class _B1, class _B2, class... _Bn>
    611 struct __or_<_B0, _B1, _B2, _Bn...> 
    612         : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
    613 
    614 // __not_
    615 template<class _Tp> 
    616 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
    617 
    618 #endif // !defined(_LIBCPP_CXX03_LANG)
    619 
    620 // is_const
    621 
    622 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const            : public false_type {};
    623 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
    624 
    625 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    626 template <class _Tp>
    627 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
    628     = is_const<_Tp>::value;
    629 #endif
    630 
    631 // is_volatile
    632 
    633 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile               : public false_type {};
    634 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
    635 
    636 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    637 template <class _Tp>
    638 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
    639     = is_volatile<_Tp>::value;
    640 #endif
    641 
    642 // remove_const
    643 
    644 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const            {typedef _Tp type;};
    645 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
    646 #if _LIBCPP_STD_VER > 11
    647 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
    648 #endif
    649 
    650 // remove_volatile
    651 
    652 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile               {typedef _Tp type;};
    653 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
    654 #if _LIBCPP_STD_VER > 11
    655 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
    656 #endif
    657 
    658 // remove_cv
    659 
    660 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
    661 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
    662 #if _LIBCPP_STD_VER > 11
    663 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
    664 #endif
    665 
    666 // is_void
    667 
    668 template <class _Tp> struct __libcpp_is_void       : public false_type {};
    669 template <>          struct __libcpp_is_void<void> : public true_type {};
    670 
    671 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
    672     : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
    673 
    674 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    675 template <class _Tp>
    676 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
    677     = is_void<_Tp>::value;
    678 #endif
    679 
    680 // __is_nullptr_t
    681 
    682 template <class _Tp> struct __is_nullptr_t_impl       : public false_type {};
    683 template <>          struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
    684 
    685 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
    686     : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
    687 
    688 #if _LIBCPP_STD_VER > 11
    689 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
    690     : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
    691 
    692 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    693 template <class _Tp>
    694 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
    695     = is_null_pointer<_Tp>::value;
    696 #endif
    697 #endif
    698 
    699 // is_integral
    700 
    701 template <class _Tp> struct __libcpp_is_integral                     : public false_type {};
    702 template <>          struct __libcpp_is_integral<bool>               : public true_type {};
    703 template <>          struct __libcpp_is_integral<char>               : public true_type {};
    704 template <>          struct __libcpp_is_integral<signed char>        : public true_type {};
    705 template <>          struct __libcpp_is_integral<unsigned char>      : public true_type {};
    706 template <>          struct __libcpp_is_integral<wchar_t>            : public true_type {};
    707 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
    708 template <>          struct __libcpp_is_integral<char16_t>           : public true_type {};
    709 template <>          struct __libcpp_is_integral<char32_t>           : public true_type {};
    710 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
    711 template <>          struct __libcpp_is_integral<short>              : public true_type {};
    712 template <>          struct __libcpp_is_integral<unsigned short>     : public true_type {};
    713 template <>          struct __libcpp_is_integral<int>                : public true_type {};
    714 template <>          struct __libcpp_is_integral<unsigned int>       : public true_type {};
    715 template <>          struct __libcpp_is_integral<long>               : public true_type {};
    716 template <>          struct __libcpp_is_integral<unsigned long>      : public true_type {};
    717 template <>          struct __libcpp_is_integral<long long>          : public true_type {};
    718 template <>          struct __libcpp_is_integral<unsigned long long> : public true_type {};
    719 #ifndef _LIBCPP_HAS_NO_INT128
    720 template <>          struct __libcpp_is_integral<__int128_t>         : public true_type {};
    721 template <>          struct __libcpp_is_integral<__uint128_t>        : public true_type {};
    722 #endif
    723 
    724 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
    725     : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
    726 
    727 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    728 template <class _Tp>
    729 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
    730     = is_integral<_Tp>::value;
    731 #endif
    732 
    733 // is_floating_point
    734 
    735 template <class _Tp> struct __libcpp_is_floating_point              : public false_type {};
    736 template <>          struct __libcpp_is_floating_point<float>       : public true_type {};
    737 template <>          struct __libcpp_is_floating_point<double>      : public true_type {};
    738 template <>          struct __libcpp_is_floating_point<long double> : public true_type {};
    739 
    740 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
    741     : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
    742 
    743 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    744 template <class _Tp>
    745 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
    746     = is_floating_point<_Tp>::value;
    747 #endif
    748 
    749 // is_array
    750 
    751 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
    752     : public false_type {};
    753 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
    754     : public true_type {};
    755 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
    756     : public true_type {};
    757 
    758 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    759 template <class _Tp>
    760 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
    761     = is_array<_Tp>::value;
    762 #endif
    763 
    764 // is_pointer
    765 
    766 template <class _Tp> struct __libcpp_is_pointer       : public false_type {};
    767 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
    768 
    769 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
    770     : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
    771 
    772 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    773 template <class _Tp>
    774 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
    775     = is_pointer<_Tp>::value;
    776 #endif
    777 
    778 // is_reference
    779 
    780 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference       : public false_type {};
    781 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
    782 
    783 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference        : public false_type {};
    784 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    785 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
    786 #endif
    787 
    788 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference        : public false_type {};
    789 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&>  : public true_type {};
    790 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
    792 #endif
    793 
    794 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    795 template <class _Tp>
    796 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
    797     = is_reference<_Tp>::value;
    798 
    799 template <class _Tp>
    800 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
    801     = is_lvalue_reference<_Tp>::value;
    802 
    803 template <class _Tp>
    804 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
    805     = is_rvalue_reference<_Tp>::value;
    806 #endif
    807 // is_union
    808 
    809 #if __has_feature(is_union) || (_GNUC_VER >= 403)
    810 
    811 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
    812     : public integral_constant<bool, __is_union(_Tp)> {};
    813 
    814 #else
    815 
    816 template <class _Tp> struct __libcpp_union : public false_type {};
    817 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
    818     : public __libcpp_union<typename remove_cv<_Tp>::type> {};
    819 
    820 #endif
    821 
    822 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    823 template <class _Tp>
    824 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
    825     = is_union<_Tp>::value;
    826 #endif
    827 
    828 // is_class
    829 
    830 #if __has_feature(is_class) || (_GNUC_VER >= 403)
    831 
    832 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
    833     : public integral_constant<bool, __is_class(_Tp)> {};
    834 
    835 #else
    836 
    837 namespace __is_class_imp
    838 {
    839 template <class _Tp> char  __test(int _Tp::*);
    840 template <class _Tp> __two __test(...);
    841 }
    842 
    843 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
    844     : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
    845 
    846 #endif
    847 
    848 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    849 template <class _Tp>
    850 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
    851     = is_class<_Tp>::value;
    852 #endif
    853 
    854 // is_same
    855 
    856 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same           : public false_type {};
    857 template <class _Tp>            struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
    858 
    859 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    860 template <class _Tp, class _Up>
    861 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
    862     = is_same<_Tp, _Up>::value;
    863 #endif
    864 
    865 // is_function
    866 
    867 namespace __libcpp_is_function_imp
    868 {
    869 struct __dummy_type {};
    870 template <class _Tp> char  __test(_Tp*);
    871 template <class _Tp> char __test(__dummy_type);
    872 template <class _Tp> __two __test(...);
    873 template <class _Tp> _Tp&  __source(int);
    874 template <class _Tp> __dummy_type __source(...);
    875 }
    876 
    877 template <class _Tp, bool = is_class<_Tp>::value ||
    878                             is_union<_Tp>::value ||
    879                             is_void<_Tp>::value  ||
    880                             is_reference<_Tp>::value ||
    881                             __is_nullptr_t<_Tp>::value >
    882 struct __libcpp_is_function
    883     : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
    884     {};
    885 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
    886 
    887 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
    888     : public __libcpp_is_function<_Tp> {};
    889 
    890 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    891 template <class _Tp>
    892 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
    893     = is_function<_Tp>::value;
    894 #endif
    895 
    896 // is_member_function_pointer
    897 
    898 // template <class _Tp> struct            __libcpp_is_member_function_pointer             : public false_type {};
    899 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
    900 // 
    901 
    902 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
    903 struct __member_pointer_traits_imp
    904 {  // forward declaration; specializations later
    905 };
    906 
    907 
    908 template <class _Tp> struct __libcpp_is_member_function_pointer
    909     : public false_type {};
    910 
    911 template <class _Ret, class _Class>
    912 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
    913     : public is_function<_Ret> {};
    914 
    915 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
    916     : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
    917 
    918 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    919 template <class _Tp>
    920 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
    921     = is_member_function_pointer<_Tp>::value;
    922 #endif
    923 
    924 // is_member_pointer
    925 
    926 template <class _Tp>            struct __libcpp_is_member_pointer             : public false_type {};
    927 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
    928 
    929 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
    930     : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
    931 
    932 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    933 template <class _Tp>
    934 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
    935     = is_member_pointer<_Tp>::value;
    936 #endif
    937 
    938 // is_member_object_pointer
    939 
    940 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
    941     : public integral_constant<bool, is_member_pointer<_Tp>::value &&
    942                                     !is_member_function_pointer<_Tp>::value> {};
    943 
    944 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    945 template <class _Tp>
    946 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
    947     = is_member_object_pointer<_Tp>::value;
    948 #endif
    949 
    950 // is_enum
    951 
    952 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
    953 
    954 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
    955     : public integral_constant<bool, __is_enum(_Tp)> {};
    956 
    957 #else
    958 
    959 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
    960     : public integral_constant<bool, !is_void<_Tp>::value             &&
    961                                      !is_integral<_Tp>::value         &&
    962                                      !is_floating_point<_Tp>::value   &&
    963                                      !is_array<_Tp>::value            &&
    964                                      !is_pointer<_Tp>::value          &&
    965                                      !is_reference<_Tp>::value        &&
    966                                      !is_member_pointer<_Tp>::value   &&
    967                                      !is_union<_Tp>::value            &&
    968                                      !is_class<_Tp>::value            &&
    969                                      !is_function<_Tp>::value         > {};
    970 
    971 #endif
    972 
    973 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    974 template <class _Tp>
    975 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
    976     = is_enum<_Tp>::value;
    977 #endif
    978 
    979 // is_arithmetic
    980 
    981 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
    982     : public integral_constant<bool, is_integral<_Tp>::value      ||
    983                                      is_floating_point<_Tp>::value> {};
    984 
    985 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    986 template <class _Tp>
    987 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
    988     = is_arithmetic<_Tp>::value;
    989 #endif
    990 
    991 // is_fundamental
    992 
    993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
    994     : public integral_constant<bool, is_void<_Tp>::value        ||
    995                                      __is_nullptr_t<_Tp>::value ||
    996                                      is_arithmetic<_Tp>::value> {};
    997 
    998 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
    999 template <class _Tp>
   1000 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
   1001     = is_fundamental<_Tp>::value;
   1002 #endif
   1003 
   1004 // is_scalar
   1005 
   1006 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
   1007     : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
   1008                                      is_member_pointer<_Tp>::value ||
   1009                                      is_pointer<_Tp>::value        ||
   1010                                      __is_nullptr_t<_Tp>::value    ||
   1011                                      is_enum<_Tp>::value           > {};
   1012 
   1013 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
   1014 
   1015 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1016 template <class _Tp>
   1017 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
   1018     = is_scalar<_Tp>::value;
   1019 #endif
   1020 
   1021 // is_object
   1022 
   1023 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
   1024     : public integral_constant<bool, is_scalar<_Tp>::value ||
   1025                                      is_array<_Tp>::value  ||
   1026                                      is_union<_Tp>::value  ||
   1027                                      is_class<_Tp>::value  > {};
   1028 
   1029 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1030 template <class _Tp>
   1031 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
   1032     = is_object<_Tp>::value;
   1033 #endif
   1034 
   1035 // is_compound
   1036 
   1037 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
   1038     : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
   1039 
   1040 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1041 template <class _Tp>
   1042 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
   1043     = is_compound<_Tp>::value;
   1044 #endif
   1045 
   1046 
   1047 // __is_referenceable  [defns.referenceable]
   1048 
   1049 struct __is_referenceable_impl {
   1050     template <class _Tp> static _Tp& __test(int);
   1051     template <class _Tp> static __two __test(...);
   1052 };
   1053 
   1054 template <class _Tp>
   1055 struct __is_referenceable : integral_constant<bool,
   1056     !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
   1057 
   1058 
   1059 // add_const
   1060 
   1061 template <class _Tp, bool = is_reference<_Tp>::value ||
   1062                             is_function<_Tp>::value  ||
   1063                             is_const<_Tp>::value     >
   1064 struct __add_const             {typedef _Tp type;};
   1065 
   1066 template <class _Tp>
   1067 struct __add_const<_Tp, false> {typedef const _Tp type;};
   1068 
   1069 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
   1070     {typedef typename __add_const<_Tp>::type type;};
   1071 
   1072 #if _LIBCPP_STD_VER > 11
   1073 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
   1074 #endif
   1075 
   1076 // add_volatile
   1077 
   1078 template <class _Tp, bool = is_reference<_Tp>::value ||
   1079                             is_function<_Tp>::value  ||
   1080                             is_volatile<_Tp>::value  >
   1081 struct __add_volatile             {typedef _Tp type;};
   1082 
   1083 template <class _Tp>
   1084 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
   1085 
   1086 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
   1087     {typedef typename __add_volatile<_Tp>::type type;};
   1088 
   1089 #if _LIBCPP_STD_VER > 11
   1090 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
   1091 #endif
   1092 
   1093 // add_cv
   1094 
   1095 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
   1096     {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
   1097 
   1098 #if _LIBCPP_STD_VER > 11
   1099 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
   1100 #endif
   1101 
   1102 // remove_reference
   1103 
   1104 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference        {typedef _Tp type;};
   1105 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&>  {typedef _Tp type;};
   1106 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1107 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
   1108 #endif
   1109 
   1110 #if _LIBCPP_STD_VER > 11
   1111 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
   1112 #endif
   1113 
   1114 // add_lvalue_reference
   1115 
   1116 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl            { typedef _Tp  type; };
   1117 template <class _Tp                                       > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
   1118 
   1119 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
   1120 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
   1121 
   1122 #if _LIBCPP_STD_VER > 11
   1123 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
   1124 #endif
   1125 
   1126 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1127 
   1128 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl            { typedef _Tp   type; };
   1129 template <class _Tp                                       > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
   1130 
   1131 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
   1132 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
   1133 
   1134 #if _LIBCPP_STD_VER > 11
   1135 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
   1136 #endif
   1137 
   1138 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1139 
   1140 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1141 
   1142 template <class _Tp> _Tp&& __declval(int);
   1143 template <class _Tp> _Tp   __declval(long);
   1144 
   1145 template <class _Tp>
   1146 decltype(_VSTD::__declval<_Tp>(0))
   1147 declval() _NOEXCEPT;
   1148 
   1149 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1150 
   1151 template <class _Tp>
   1152 typename add_lvalue_reference<_Tp>::type
   1153 declval();
   1154 
   1155 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1156 
   1157 // __uncvref
   1158 
   1159 template <class _Tp>
   1160 struct __uncvref  {
   1161     typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
   1162 };
   1163 
   1164 template <class _Tp>
   1165 struct __unconstref {
   1166     typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
   1167 };
   1168 
   1169 #ifndef _LIBCPP_CXX03_LANG
   1170 template <class _Tp>
   1171 using __uncvref_t = typename __uncvref<_Tp>::type;
   1172 #endif
   1173 
   1174 // __is_same_uncvref
   1175 
   1176 template <class _Tp, class _Up>
   1177 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
   1178                                    typename __uncvref<_Up>::type> {};
   1179 
   1180 #if _LIBCPP_STD_VER > 17
   1181 // aligned_union - same as __uncvref
   1182 template <class _Tp>
   1183 struct remove_cvref : public __uncvref<_Tp> {};
   1184 
   1185 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
   1186 #endif
   1187 
   1188 
   1189 struct __any
   1190 {
   1191     __any(...);
   1192 };
   1193 
   1194 // remove_pointer
   1195 
   1196 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer                      {typedef _Tp type;};
   1197 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*>                {typedef _Tp type;};
   1198 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const>          {typedef _Tp type;};
   1199 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile>       {typedef _Tp type;};
   1200 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
   1201 
   1202 #if _LIBCPP_STD_VER > 11
   1203 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
   1204 #endif
   1205 
   1206 // add_pointer
   1207 
   1208 template <class _Tp, 
   1209         bool = __is_referenceable<_Tp>::value || 
   1210                 is_same<typename remove_cv<_Tp>::type, void>::value>
   1211 struct __add_pointer_impl
   1212     {typedef typename remove_reference<_Tp>::type* type;};
   1213 template <class _Tp> struct __add_pointer_impl<_Tp, false> 
   1214     {typedef _Tp type;};
   1215 
   1216 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
   1217     {typedef typename __add_pointer_impl<_Tp>::type type;};
   1218 
   1219 #if _LIBCPP_STD_VER > 11
   1220 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
   1221 #endif
   1222 
   1223 // is_signed
   1224 
   1225 template <class _Tp, bool = is_integral<_Tp>::value>
   1226 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
   1227 
   1228 template <class _Tp>
   1229 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {};  // floating point
   1230 
   1231 template <class _Tp, bool = is_arithmetic<_Tp>::value>
   1232 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
   1233 
   1234 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
   1235 
   1236 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
   1237 
   1238 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1239 template <class _Tp>
   1240 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
   1241     = is_signed<_Tp>::value;
   1242 #endif
   1243 
   1244 // is_unsigned
   1245 
   1246 template <class _Tp, bool = is_integral<_Tp>::value>
   1247 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
   1248 
   1249 template <class _Tp>
   1250 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {};  // floating point
   1251 
   1252 template <class _Tp, bool = is_arithmetic<_Tp>::value>
   1253 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
   1254 
   1255 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
   1256 
   1257 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
   1258 
   1259 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1260 template <class _Tp>
   1261 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
   1262     = is_unsigned<_Tp>::value;
   1263 #endif
   1264 
   1265 // rank
   1266 
   1267 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
   1268     : public integral_constant<size_t, 0> {};
   1269 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
   1270     : public integral_constant<size_t, rank<_Tp>::value + 1> {};
   1271 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
   1272     : public integral_constant<size_t, rank<_Tp>::value + 1> {};
   1273 
   1274 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1275 template <class _Tp>
   1276 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
   1277     = rank<_Tp>::value;
   1278 #endif
   1279 
   1280 // extent
   1281 
   1282 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
   1283     : public integral_constant<size_t, 0> {};
   1284 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
   1285     : public integral_constant<size_t, 0> {};
   1286 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
   1287     : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
   1288 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
   1289     : public integral_constant<size_t, _Np> {};
   1290 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
   1291     : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
   1292 
   1293 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1294 template <class _Tp, unsigned _Ip = 0>
   1295 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
   1296     = extent<_Tp, _Ip>::value;
   1297 #endif
   1298 
   1299 // remove_extent
   1300 
   1301 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
   1302     {typedef _Tp type;};
   1303 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
   1304     {typedef _Tp type;};
   1305 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
   1306     {typedef _Tp type;};
   1307 
   1308 #if _LIBCPP_STD_VER > 11
   1309 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
   1310 #endif
   1311 
   1312 // remove_all_extents
   1313 
   1314 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
   1315     {typedef _Tp type;};
   1316 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
   1317     {typedef typename remove_all_extents<_Tp>::type type;};
   1318 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
   1319     {typedef typename remove_all_extents<_Tp>::type type;};
   1320 
   1321 #if _LIBCPP_STD_VER > 11
   1322 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
   1323 #endif
   1324 
   1325 // decay
   1326 
   1327 template <class _Up, bool>
   1328 struct __decay {
   1329     typedef typename remove_cv<_Up>::type type;
   1330 };
   1331 
   1332 template <class _Up>
   1333 struct __decay<_Up, true> {
   1334 public:
   1335     typedef typename conditional
   1336                      <
   1337                          is_array<_Up>::value,
   1338                          typename remove_extent<_Up>::type*,
   1339                          typename conditional
   1340                          <
   1341                               is_function<_Up>::value,
   1342                               typename add_pointer<_Up>::type,
   1343                               typename remove_cv<_Up>::type
   1344                          >::type
   1345                      >::type type;
   1346 };
   1347 
   1348 template <class _Tp>
   1349 struct _LIBCPP_TEMPLATE_VIS decay
   1350 {
   1351 private:
   1352     typedef typename remove_reference<_Tp>::type _Up;
   1353 public:
   1354     typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
   1355 };
   1356 
   1357 #if _LIBCPP_STD_VER > 11
   1358 template <class _Tp> using decay_t = typename decay<_Tp>::type;
   1359 #endif
   1360 
   1361 // is_abstract
   1362 
   1363 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
   1364     : public integral_constant<bool, __is_abstract(_Tp)> {};
   1365 
   1366 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1367 template <class _Tp>
   1368 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
   1369     = is_abstract<_Tp>::value;
   1370 #endif
   1371 
   1372 // is_final
   1373 
   1374 #if defined(_LIBCPP_HAS_IS_FINAL)
   1375 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
   1376 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
   1377 #else
   1378 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
   1379 __libcpp_is_final : public false_type {};
   1380 #endif
   1381 
   1382 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
   1383 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
   1384 is_final : public integral_constant<bool, __is_final(_Tp)> {};
   1385 #endif
   1386 
   1387 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1388 template <class _Tp>
   1389 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
   1390     = is_final<_Tp>::value;
   1391 #endif
   1392 
   1393 // is_aggregate
   1394 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
   1395 
   1396 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
   1397 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
   1398 
   1399 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1400 template <class _Tp>
   1401 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
   1402     = is_aggregate<_Tp>::value;
   1403 #endif
   1404 
   1405 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
   1406 
   1407 // is_base_of
   1408 
   1409 #ifdef _LIBCPP_HAS_IS_BASE_OF
   1410 
   1411 template <class _Bp, class _Dp>
   1412 struct _LIBCPP_TEMPLATE_VIS is_base_of
   1413     : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
   1414 
   1415 #else  // _LIBCPP_HAS_IS_BASE_OF
   1416 
   1417 namespace __is_base_of_imp
   1418 {
   1419 template <class _Tp>
   1420 struct _Dst
   1421 {
   1422     _Dst(const volatile _Tp &);
   1423 };
   1424 template <class _Tp>
   1425 struct _Src
   1426 {
   1427     operator const volatile _Tp &();
   1428     template <class _Up> operator const _Dst<_Up> &();
   1429 };
   1430 template <size_t> struct __one { typedef char type; };
   1431 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
   1432 template <class _Bp, class _Dp> __two __test(...);
   1433 }
   1434 
   1435 template <class _Bp, class _Dp>
   1436 struct _LIBCPP_TEMPLATE_VIS is_base_of
   1437     : public integral_constant<bool, is_class<_Bp>::value &&
   1438                                      sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
   1439 
   1440 #endif  // _LIBCPP_HAS_IS_BASE_OF
   1441 
   1442 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1443 template <class _Bp, class _Dp>
   1444 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
   1445     = is_base_of<_Bp, _Dp>::value;
   1446 #endif
   1447 
   1448 // is_convertible
   1449 
   1450 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
   1451 
   1452 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
   1453     : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
   1454                                      !is_abstract<_T2>::value> {};
   1455 
   1456 #else  // __has_feature(is_convertible_to)
   1457 
   1458 namespace __is_convertible_imp
   1459 {
   1460 template <class _Tp> void  __test_convert(_Tp);
   1461 
   1462 template <class _From, class _To, class = void>
   1463 struct __is_convertible_test : public false_type {};
   1464 
   1465 template <class _From, class _To>
   1466 struct __is_convertible_test<_From, _To,
   1467     decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
   1468 {};
   1469 
   1470 template <class _Tp, bool _IsArray =    is_array<_Tp>::value,
   1471                      bool _IsFunction = is_function<_Tp>::value,
   1472                      bool _IsVoid =     is_void<_Tp>::value>
   1473                      struct __is_array_function_or_void                          {enum {value = 0};};
   1474 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
   1475 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
   1476 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
   1477 }
   1478 
   1479 template <class _Tp,
   1480     unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
   1481 struct __is_convertible_check
   1482 {
   1483     static const size_t __v = 0;
   1484 };
   1485 
   1486 template <class _Tp>
   1487 struct __is_convertible_check<_Tp, 0>
   1488 {
   1489     static const size_t __v = sizeof(_Tp);
   1490 };
   1491 
   1492 template <class _T1, class _T2,
   1493     unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
   1494     unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
   1495 struct __is_convertible
   1496     : public integral_constant<bool,
   1497         __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
   1498 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
   1499          && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
   1500               && (!is_const<typename remove_reference<_T2>::type>::value
   1501                   || is_volatile<typename remove_reference<_T2>::type>::value)
   1502                   && (is_same<typename remove_cv<_T1>::type,
   1503                               typename remove_cv<typename remove_reference<_T2>::type>::type>::value
   1504                       || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
   1505 #endif
   1506     >
   1507 {};
   1508 
   1509 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
   1510 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
   1511 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
   1512 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
   1513 
   1514 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
   1515 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
   1516 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
   1517 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
   1518 
   1519 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
   1520 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
   1521 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
   1522 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
   1523 
   1524 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
   1525     : public __is_convertible<_T1, _T2>
   1526 {
   1527     static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
   1528     static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
   1529 };
   1530 
   1531 #endif  // __has_feature(is_convertible_to)
   1532 
   1533 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1534 template <class _From, class _To>
   1535 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
   1536     = is_convertible<_From, _To>::value;
   1537 #endif
   1538 
   1539 // is_empty
   1540 
   1541 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
   1542 
   1543 template <class _Tp>
   1544 struct _LIBCPP_TEMPLATE_VIS is_empty
   1545     : public integral_constant<bool, __is_empty(_Tp)> {};
   1546 
   1547 #else  // __has_feature(is_empty)
   1548 
   1549 template <class _Tp>
   1550 struct __is_empty1
   1551     : public _Tp
   1552 {
   1553     double __lx;
   1554 };
   1555 
   1556 struct __is_empty2
   1557 {
   1558     double __lx;
   1559 };
   1560 
   1561 template <class _Tp, bool = is_class<_Tp>::value>
   1562 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
   1563 
   1564 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
   1565 
   1566 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
   1567 
   1568 #endif  // __has_feature(is_empty)
   1569 
   1570 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1571 template <class _Tp>
   1572 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
   1573     = is_empty<_Tp>::value;
   1574 #endif
   1575 
   1576 // is_polymorphic
   1577 
   1578 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
   1579 
   1580 template <class _Tp>
   1581 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
   1582     : public integral_constant<bool, __is_polymorphic(_Tp)> {};
   1583 
   1584 #else
   1585 
   1586 template<typename _Tp> char &__is_polymorphic_impl(
   1587     typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
   1588                        int>::type);
   1589 template<typename _Tp> __two &__is_polymorphic_impl(...);
   1590 
   1591 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
   1592     : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
   1593 
   1594 #endif // __has_feature(is_polymorphic)
   1595 
   1596 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1597 template <class _Tp>
   1598 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
   1599     = is_polymorphic<_Tp>::value;
   1600 #endif
   1601 
   1602 // has_virtual_destructor
   1603 
   1604 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
   1605 
   1606 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
   1607     : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
   1608 
   1609 #else
   1610 
   1611 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
   1612     : public false_type {};
   1613 
   1614 #endif
   1615 
   1616 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1617 template <class _Tp>
   1618 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
   1619     = has_virtual_destructor<_Tp>::value;
   1620 #endif
   1621 
   1622 // has_unique_object_representations
   1623 
   1624 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
   1625 
   1626 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
   1627     : public integral_constant<bool, 
   1628        __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
   1629 
   1630 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1631 template <class _Tp>
   1632 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
   1633     = has_unique_object_representations<_Tp>::value;
   1634 #endif
   1635 
   1636 #endif
   1637 
   1638 // alignment_of
   1639 
   1640 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
   1641     : public integral_constant<size_t, __alignof__(_Tp)> {};
   1642 
   1643 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   1644 template <class _Tp>
   1645 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
   1646     = alignment_of<_Tp>::value;
   1647 #endif
   1648 
   1649 // aligned_storage
   1650 
   1651 template <class _Hp, class _Tp>
   1652 struct __type_list
   1653 {
   1654     typedef _Hp _Head;
   1655     typedef _Tp _Tail;
   1656 };
   1657 
   1658 struct __nat
   1659 {
   1660 #ifndef _LIBCPP_CXX03_LANG
   1661     __nat() = delete;
   1662     __nat(const __nat&) = delete;
   1663     __nat& operator=(const __nat&) = delete;
   1664     ~__nat() = delete;
   1665 #endif
   1666 };
   1667 
   1668 template <class _Tp>
   1669 struct __align_type
   1670 {
   1671     static const size_t value = alignment_of<_Tp>::value;
   1672     typedef _Tp type;
   1673 };
   1674 
   1675 struct __struct_double {long double __lx;};
   1676 struct __struct_double4 {double __lx[4];};
   1677 
   1678 typedef
   1679     __type_list<__align_type<unsigned char>,
   1680     __type_list<__align_type<unsigned short>,
   1681     __type_list<__align_type<unsigned int>,
   1682     __type_list<__align_type<unsigned long>,
   1683     __type_list<__align_type<unsigned long long>,
   1684     __type_list<__align_type<double>,
   1685     __type_list<__align_type<long double>,
   1686     __type_list<__align_type<__struct_double>,
   1687     __type_list<__align_type<__struct_double4>,
   1688     __type_list<__align_type<int*>,
   1689     __nat
   1690     > > > > > > > > > > __all_types;
   1691 
   1692 template <class _TL, size_t _Align> struct __find_pod;
   1693 
   1694 template <class _Hp, size_t _Align>
   1695 struct __find_pod<__type_list<_Hp, __nat>, _Align>
   1696 {
   1697     typedef typename conditional<
   1698                              _Align == _Hp::value,
   1699                              typename _Hp::type,
   1700                              void
   1701                          >::type type;
   1702 };
   1703 
   1704 template <class _Hp, class _Tp, size_t _Align>
   1705 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
   1706 {
   1707     typedef typename conditional<
   1708                              _Align == _Hp::value,
   1709                              typename _Hp::type,
   1710                              typename __find_pod<_Tp, _Align>::type
   1711                          >::type type;
   1712 };
   1713 
   1714 template <class _TL, size_t _Len> struct __find_max_align;
   1715 
   1716 template <class _Hp, size_t _Len>
   1717 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
   1718 
   1719 template <size_t _Len, size_t _A1, size_t _A2>
   1720 struct __select_align
   1721 {
   1722 private:
   1723     static const size_t __min = _A2 < _A1 ? _A2 : _A1;
   1724     static const size_t __max = _A1 < _A2 ? _A2 : _A1;
   1725 public:
   1726     static const size_t value = _Len < __max ? __min : __max;
   1727 };
   1728 
   1729 template <class _Hp, class _Tp, size_t _Len>
   1730 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
   1731     : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
   1732 
   1733 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
   1734 struct _LIBCPP_TEMPLATE_VIS aligned_storage
   1735 {
   1736     typedef typename __find_pod<__all_types, _Align>::type _Aligner;
   1737     static_assert(!is_void<_Aligner>::value, "");
   1738     union type
   1739     {
   1740         _Aligner __align;
   1741         unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
   1742     };
   1743 };
   1744 
   1745 #if _LIBCPP_STD_VER > 11
   1746 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
   1747     using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
   1748 #endif
   1749 
   1750 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
   1751 template <size_t _Len>\
   1752 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
   1753 {\
   1754     struct _ALIGNAS(n) type\
   1755     {\
   1756         unsigned char __lx[(_Len + n - 1)/n * n];\
   1757     };\
   1758 }
   1759 
   1760 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
   1761 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
   1762 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
   1763 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
   1764 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
   1765 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
   1766 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
   1767 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
   1768 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
   1769 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
   1770 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
   1771 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
   1772 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
   1773 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
   1774 // PE/COFF does not support alignment beyond 8192 (=0x2000)
   1775 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
   1776 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
   1777 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
   1778 
   1779 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
   1780 
   1781 #ifndef _LIBCPP_HAS_NO_VARIADICS
   1782 
   1783 // aligned_union
   1784 
   1785 template <size_t _I0, size_t ..._In>
   1786 struct __static_max;
   1787 
   1788 template <size_t _I0>
   1789 struct __static_max<_I0>
   1790 {
   1791     static const size_t value = _I0;
   1792 };
   1793 
   1794 template <size_t _I0, size_t _I1, size_t ..._In>
   1795 struct __static_max<_I0, _I1, _In...>
   1796 {
   1797     static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
   1798                                              __static_max<_I1, _In...>::value;
   1799 };
   1800 
   1801 template <size_t _Len, class _Type0, class ..._Types>
   1802 struct aligned_union
   1803 {
   1804     static const size_t alignment_value = __static_max<__alignof__(_Type0),
   1805                                                        __alignof__(_Types)...>::value;
   1806     static const size_t __len = __static_max<_Len, sizeof(_Type0),
   1807                                              sizeof(_Types)...>::value;
   1808     typedef typename aligned_storage<__len, alignment_value>::type type;
   1809 };
   1810 
   1811 #if _LIBCPP_STD_VER > 11
   1812 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
   1813 #endif
   1814 
   1815 #endif  // _LIBCPP_HAS_NO_VARIADICS
   1816 
   1817 template <class _Tp>
   1818 struct __numeric_type
   1819 {
   1820    static void __test(...);
   1821    static float __test(float);
   1822    static double __test(char);
   1823    static double __test(int);
   1824    static double __test(unsigned);
   1825    static double __test(long);
   1826    static double __test(unsigned long);
   1827    static double __test(long long);
   1828    static double __test(unsigned long long);
   1829    static double __test(double);
   1830    static long double __test(long double);
   1831 
   1832    typedef decltype(__test(declval<_Tp>())) type;
   1833    static const bool value = !is_same<type, void>::value;
   1834 };
   1835 
   1836 template <>
   1837 struct __numeric_type<void>
   1838 {
   1839    static const bool value = true;
   1840 };
   1841 
   1842 // __promote
   1843 
   1844 template <class _A1, class _A2 = void, class _A3 = void,
   1845           bool = __numeric_type<_A1>::value &&
   1846                  __numeric_type<_A2>::value &&
   1847                  __numeric_type<_A3>::value>
   1848 class __promote_imp
   1849 {
   1850 public:
   1851     static const bool value = false;
   1852 };
   1853 
   1854 template <class _A1, class _A2, class _A3>
   1855 class __promote_imp<_A1, _A2, _A3, true>
   1856 {
   1857 private:
   1858     typedef typename __promote_imp<_A1>::type __type1;
   1859     typedef typename __promote_imp<_A2>::type __type2;
   1860     typedef typename __promote_imp<_A3>::type __type3;
   1861 public:
   1862     typedef decltype(__type1() + __type2() + __type3()) type;
   1863     static const bool value = true;
   1864 };
   1865 
   1866 template <class _A1, class _A2>
   1867 class __promote_imp<_A1, _A2, void, true>
   1868 {
   1869 private:
   1870     typedef typename __promote_imp<_A1>::type __type1;
   1871     typedef typename __promote_imp<_A2>::type __type2;
   1872 public:
   1873     typedef decltype(__type1() + __type2()) type;
   1874     static const bool value = true;
   1875 };
   1876 
   1877 template <class _A1>
   1878 class __promote_imp<_A1, void, void, true>
   1879 {
   1880 public:
   1881     typedef typename __numeric_type<_A1>::type type;
   1882     static const bool value = true;
   1883 };
   1884 
   1885 template <class _A1, class _A2 = void, class _A3 = void>
   1886 class __promote : public __promote_imp<_A1, _A2, _A3> {};
   1887 
   1888 // make_signed / make_unsigned
   1889 
   1890 typedef
   1891     __type_list<signed char,
   1892     __type_list<signed short,
   1893     __type_list<signed int,
   1894     __type_list<signed long,
   1895     __type_list<signed long long,
   1896 #ifndef _LIBCPP_HAS_NO_INT128
   1897     __type_list<__int128_t,
   1898 #endif
   1899     __nat
   1900 #ifndef _LIBCPP_HAS_NO_INT128
   1901     >
   1902 #endif
   1903     > > > > > __signed_types;
   1904 
   1905 typedef
   1906     __type_list<unsigned char,
   1907     __type_list<unsigned short,
   1908     __type_list<unsigned int,
   1909     __type_list<unsigned long,
   1910     __type_list<unsigned long long,
   1911 #ifndef _LIBCPP_HAS_NO_INT128
   1912     __type_list<__uint128_t,
   1913 #endif
   1914     __nat
   1915 #ifndef _LIBCPP_HAS_NO_INT128
   1916     >
   1917 #endif
   1918     > > > > > __unsigned_types;
   1919 
   1920 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
   1921 
   1922 template <class _Hp, class _Tp, size_t _Size>
   1923 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
   1924 {
   1925     typedef _Hp type;
   1926 };
   1927 
   1928 template <class _Hp, class _Tp, size_t _Size>
   1929 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
   1930 {
   1931     typedef typename __find_first<_Tp, _Size>::type type;
   1932 };
   1933 
   1934 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
   1935                              bool = is_volatile<typename remove_reference<_Tp>::type>::value>
   1936 struct __apply_cv
   1937 {
   1938     typedef _Up type;
   1939 };
   1940 
   1941 template <class _Tp, class _Up>
   1942 struct __apply_cv<_Tp, _Up, true, false>
   1943 {
   1944     typedef const _Up type;
   1945 };
   1946 
   1947 template <class _Tp, class _Up>
   1948 struct __apply_cv<_Tp, _Up, false, true>
   1949 {
   1950     typedef volatile _Up type;
   1951 };
   1952 
   1953 template <class _Tp, class _Up>
   1954 struct __apply_cv<_Tp, _Up, true, true>
   1955 {
   1956     typedef const volatile _Up type;
   1957 };
   1958 
   1959 template <class _Tp, class _Up>
   1960 struct __apply_cv<_Tp&, _Up, false, false>
   1961 {
   1962     typedef _Up& type;
   1963 };
   1964 
   1965 template <class _Tp, class _Up>
   1966 struct __apply_cv<_Tp&, _Up, true, false>
   1967 {
   1968     typedef const _Up& type;
   1969 };
   1970 
   1971 template <class _Tp, class _Up>
   1972 struct __apply_cv<_Tp&, _Up, false, true>
   1973 {
   1974     typedef volatile _Up& type;
   1975 };
   1976 
   1977 template <class _Tp, class _Up>
   1978 struct __apply_cv<_Tp&, _Up, true, true>
   1979 {
   1980     typedef const volatile _Up& type;
   1981 };
   1982 
   1983 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
   1984 struct __make_signed {};
   1985 
   1986 template <class _Tp>
   1987 struct __make_signed<_Tp, true>
   1988 {
   1989     typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
   1990 };
   1991 
   1992 template <> struct __make_signed<bool,               true> {};
   1993 template <> struct __make_signed<  signed short,     true> {typedef short     type;};
   1994 template <> struct __make_signed<unsigned short,     true> {typedef short     type;};
   1995 template <> struct __make_signed<  signed int,       true> {typedef int       type;};
   1996 template <> struct __make_signed<unsigned int,       true> {typedef int       type;};
   1997 template <> struct __make_signed<  signed long,      true> {typedef long      type;};
   1998 template <> struct __make_signed<unsigned long,      true> {typedef long      type;};
   1999 template <> struct __make_signed<  signed long long, true> {typedef long long type;};
   2000 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
   2001 #ifndef _LIBCPP_HAS_NO_INT128
   2002 template <> struct __make_signed<__int128_t,         true> {typedef __int128_t type;};
   2003 template <> struct __make_signed<__uint128_t,        true> {typedef __int128_t type;};
   2004 #endif
   2005 
   2006 template <class _Tp>
   2007 struct _LIBCPP_TEMPLATE_VIS make_signed
   2008 {
   2009     typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
   2010 };
   2011 
   2012 #if _LIBCPP_STD_VER > 11
   2013 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
   2014 #endif
   2015 
   2016 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
   2017 struct __make_unsigned {};
   2018 
   2019 template <class _Tp>
   2020 struct __make_unsigned<_Tp, true>
   2021 {
   2022     typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
   2023 };
   2024 
   2025 template <> struct __make_unsigned<bool,               true> {};
   2026 template <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
   2027 template <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
   2028 template <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
   2029 template <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
   2030 template <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
   2031 template <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
   2032 template <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
   2033 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
   2034 #ifndef _LIBCPP_HAS_NO_INT128
   2035 template <> struct __make_unsigned<__int128_t,         true> {typedef __uint128_t        type;};
   2036 template <> struct __make_unsigned<__uint128_t,        true> {typedef __uint128_t        type;};
   2037 #endif
   2038 
   2039 template <class _Tp>
   2040 struct _LIBCPP_TEMPLATE_VIS make_unsigned
   2041 {
   2042     typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
   2043 };
   2044 
   2045 #if _LIBCPP_STD_VER > 11
   2046 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
   2047 #endif
   2048 
   2049 #ifdef _LIBCPP_HAS_NO_VARIADICS
   2050 
   2051 template <class _Tp, class _Up = void, class _Vp = void>
   2052 struct _LIBCPP_TEMPLATE_VIS common_type
   2053 {
   2054 public:
   2055     typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
   2056 };
   2057 
   2058 template <>
   2059 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void>
   2060 {
   2061 public:
   2062     typedef void type;
   2063 };
   2064 
   2065 template <class _Tp>
   2066 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
   2067 {
   2068 public:
   2069     typedef typename common_type<_Tp, _Tp>::type type;
   2070 };
   2071 
   2072 template <class _Tp, class _Up>
   2073 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
   2074 {
   2075     typedef typename decay<decltype(
   2076         true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
   2077       )>::type type;
   2078 };
   2079 
   2080 #else  // _LIBCPP_HAS_NO_VARIADICS
   2081 
   2082 // bullet 1 - sizeof...(Tp) == 0
   2083 
   2084 template <class ..._Tp>
   2085 struct _LIBCPP_TEMPLATE_VIS common_type {};
   2086 
   2087 // bullet 2 - sizeof...(Tp) == 1
   2088 
   2089 template <class _Tp>
   2090 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
   2091     : public common_type<_Tp, _Tp> {};
   2092 
   2093 // bullet 3 - sizeof...(Tp) == 2
   2094 
   2095 template <class _Tp, class _Up, class = void>
   2096 struct __common_type2_imp {};
   2097 
   2098 template <class _Tp, class _Up>
   2099 struct __common_type2_imp<_Tp, _Up,
   2100     typename __void_t<decltype(
   2101         true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
   2102     )>::type>
   2103 {
   2104     typedef typename decay<decltype(
   2105         true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
   2106     )>::type type;
   2107 };
   2108 
   2109 template <class _Tp, class _Up,
   2110           class _DTp = typename decay<_Tp>::type,
   2111           class _DUp = typename decay<_Up>::type>
   2112 using __common_type2 =
   2113   typename conditional<
   2114     is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
   2115     __common_type2_imp<_Tp, _Up>,
   2116     common_type<_DTp, _DUp>
   2117   >::type;
   2118 
   2119 template <class _Tp, class _Up>
   2120 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
   2121     : __common_type2<_Tp, _Up> {};
   2122 
   2123 // bullet 4 - sizeof...(Tp) > 2
   2124 
   2125 template <class ...Tp> struct __common_types;
   2126 
   2127 template <class, class = void>
   2128 struct __common_type_impl {};
   2129 
   2130 template <class _Tp, class _Up>
   2131 struct __common_type_impl<
   2132     __common_types<_Tp, _Up>,
   2133     typename __void_t<typename common_type<_Tp, _Up>::type>::type>
   2134 {
   2135   typedef typename common_type<_Tp, _Up>::type type;
   2136 };
   2137 
   2138 template <class _Tp, class _Up, class ..._Vp>
   2139 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
   2140     typename __void_t<typename common_type<_Tp, _Up>::type>::type>
   2141   : __common_type_impl<
   2142       __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
   2143 {
   2144 
   2145 };
   2146 
   2147 template <class _Tp, class _Up, class ..._Vp>
   2148 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
   2149     : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
   2150 
   2151 #if _LIBCPP_STD_VER > 11
   2152 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
   2153 #endif
   2154 
   2155 #endif  // _LIBCPP_HAS_NO_VARIADICS
   2156 
   2157 // is_assignable
   2158 
   2159 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
   2160 
   2161 template <class _Tp, class _Arg>
   2162 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
   2163 __is_assignable_test(int);
   2164 
   2165 template <class, class>
   2166 false_type __is_assignable_test(...);
   2167 
   2168 
   2169 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
   2170 struct __is_assignable_imp
   2171     : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
   2172 
   2173 template <class _Tp, class _Arg>
   2174 struct __is_assignable_imp<_Tp, _Arg, true>
   2175     : public false_type
   2176 {
   2177 };
   2178 
   2179 template <class _Tp, class _Arg>
   2180 struct is_assignable
   2181     : public __is_assignable_imp<_Tp, _Arg> {};
   2182 
   2183 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   2184 template <class _Tp, class _Arg>
   2185 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
   2186     = is_assignable<_Tp, _Arg>::value;
   2187 #endif
   2188 
   2189 // is_copy_assignable
   2190 
   2191 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
   2192     : public is_assignable<typename add_lvalue_reference<_Tp>::type,
   2193                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
   2194 
   2195 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   2196 template <class _Tp>
   2197 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
   2198     = is_copy_assignable<_Tp>::value;
   2199 #endif
   2200 
   2201 // is_move_assignable
   2202 
   2203 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
   2204 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2205     : public is_assignable<typename add_lvalue_reference<_Tp>::type,
   2206                            typename add_rvalue_reference<_Tp>::type> {};
   2207 #else
   2208     : public is_copy_assignable<_Tp> {};
   2209 #endif
   2210 
   2211 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   2212 template <class _Tp>
   2213 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
   2214     = is_move_assignable<_Tp>::value;
   2215 #endif
   2216 
   2217 // is_destructible
   2218 
   2219 //  if it's a reference, return true
   2220 //  if it's a function, return false
   2221 //  if it's   void,     return false
   2222 //  if it's an array of unknown bound, return false
   2223 //  Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
   2224 //    where _Up is remove_all_extents<_Tp>::type
   2225 
   2226 template <class>
   2227 struct __is_destructible_apply { typedef int type; };
   2228 
   2229 template <typename _Tp>
   2230 struct __is_destructor_wellformed {
   2231     template <typename _Tp1>
   2232     static char  __test (
   2233         typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
   2234     );
   2235 
   2236     template <typename _Tp1>
   2237     static __two __test (...);
   2238     
   2239     static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
   2240 };
   2241 
   2242 template <class _Tp, bool>
   2243 struct __destructible_imp;
   2244 
   2245 template <class _Tp>
   2246 struct __destructible_imp<_Tp, false> 
   2247    : public _VSTD::integral_constant<bool, 
   2248         __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
   2249 
   2250 template <class _Tp>
   2251 struct __destructible_imp<_Tp, true>
   2252     : public _VSTD::true_type {};
   2253 
   2254 template <class _Tp, bool>
   2255 struct __destructible_false;
   2256 
   2257 template <class _Tp>
   2258 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
   2259 
   2260 template <class _Tp>
   2261 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
   2262 
   2263 template <class _Tp>
   2264 struct is_destructible
   2265     : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
   2266 
   2267 template <class _Tp>
   2268 struct is_destructible<_Tp[]>
   2269     : public _VSTD::false_type {};
   2270 
   2271 template <>
   2272 struct is_destructible<void>
   2273     : public _VSTD::false_type {};
   2274 
   2275 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   2276 template <class _Tp>
   2277 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
   2278     = is_destructible<_Tp>::value;
   2279 #endif
   2280 
   2281 // move
   2282 
   2283 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2284 
   2285 template <class _Tp>
   2286 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   2287 typename remove_reference<_Tp>::type&&
   2288 move(_Tp&& __t) _NOEXCEPT
   2289 {
   2290     typedef typename remove_reference<_Tp>::type _Up;
   2291     return static_cast<_Up&&>(__t);
   2292 }
   2293 
   2294 template <class _Tp>
   2295 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   2296 _Tp&&
   2297 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
   2298 {
   2299     return static_cast<_Tp&&>(__t);
   2300 }
   2301 
   2302 template <class _Tp>
   2303 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   2304 _Tp&&
   2305 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
   2306 {
   2307     static_assert(!is_lvalue_reference<_Tp>::value,
   2308                   "can not forward an rvalue as an lvalue");
   2309     return static_cast<_Tp&&>(__t);
   2310 }
   2311 
   2312 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2313 
   2314 template <class _Tp>
   2315 inline _LIBCPP_INLINE_VISIBILITY
   2316 _Tp&
   2317 move(_Tp& __t)
   2318 {
   2319     return __t;
   2320 }
   2321 
   2322 template <class _Tp>
   2323 inline _LIBCPP_INLINE_VISIBILITY
   2324 const _Tp&
   2325 move(const _Tp& __t)
   2326 {
   2327     return __t;
   2328 }
   2329 
   2330 template <class _Tp>
   2331 inline _LIBCPP_INLINE_VISIBILITY
   2332 _Tp&
   2333 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
   2334 {
   2335     return __t;
   2336 }
   2337 
   2338 
   2339 template <class _Tp>
   2340 class __rv
   2341 {
   2342     typedef typename remove_reference<_Tp>::type _Trr;
   2343     _Trr& t_;
   2344 public:
   2345     _LIBCPP_INLINE_VISIBILITY
   2346     _Trr* operator->() {return &t_;}
   2347     _LIBCPP_INLINE_VISIBILITY
   2348     explicit __rv(_Trr& __t) : t_(__t) {}
   2349 };
   2350 
   2351 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2352 
   2353 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2354 
   2355 template <class _Tp>
   2356 inline _LIBCPP_INLINE_VISIBILITY
   2357 typename decay<_Tp>::type
   2358 __decay_copy(_Tp&& __t)
   2359 {
   2360     return _VSTD::forward<_Tp>(__t);
   2361 }
   2362 
   2363 #else
   2364 
   2365 template <class _Tp>
   2366 inline _LIBCPP_INLINE_VISIBILITY
   2367 typename decay<_Tp>::type
   2368 __decay_copy(const _Tp& __t)
   2369 {
   2370     return _VSTD::forward<_Tp>(__t);
   2371 }
   2372 
   2373 #endif
   2374 
   2375 #ifndef _LIBCPP_HAS_NO_VARIADICS
   2376 
   2377 template <class _Rp, class _Class, class ..._Param>
   2378 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
   2379 {
   2380     typedef _Class _ClassType;
   2381     typedef _Rp _ReturnType;
   2382     typedef _Rp (_FnType) (_Param...);
   2383 };
   2384 
   2385 template <class _Rp, class _Class, class ..._Param>
   2386 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
   2387 {
   2388     typedef _Class _ClassType;
   2389     typedef _Rp _ReturnType;
   2390     typedef _Rp (_FnType) (_Param..., ...);
   2391 };
   2392 
   2393 template <class _Rp, class _Class, class ..._Param>
   2394 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
   2395 {
   2396     typedef _Class const _ClassType;
   2397     typedef _Rp _ReturnType;
   2398     typedef _Rp (_FnType) (_Param...);
   2399 };
   2400 
   2401 template <class _Rp, class _Class, class ..._Param>
   2402 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
   2403 {
   2404     typedef _Class const _ClassType;
   2405     typedef _Rp _ReturnType;
   2406     typedef _Rp (_FnType) (_Param..., ...);
   2407 };
   2408 
   2409 template <class _Rp, class _Class, class ..._Param>
   2410 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
   2411 {
   2412     typedef _Class volatile _ClassType;
   2413     typedef _Rp _ReturnType;
   2414     typedef _Rp (_FnType) (_Param...);
   2415 };
   2416 
   2417 template <class _Rp, class _Class, class ..._Param>
   2418 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
   2419 {
   2420     typedef _Class volatile _ClassType;
   2421     typedef _Rp _ReturnType;
   2422     typedef _Rp (_FnType) (_Param..., ...);
   2423 };
   2424 
   2425 template <class _Rp, class _Class, class ..._Param>
   2426 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
   2427 {
   2428     typedef _Class const volatile _ClassType;
   2429     typedef _Rp _ReturnType;
   2430     typedef _Rp (_FnType) (_Param...);
   2431 };
   2432 
   2433 template <class _Rp, class _Class, class ..._Param>
   2434 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
   2435 {
   2436     typedef _Class const volatile _ClassType;
   2437     typedef _Rp _ReturnType;
   2438     typedef _Rp (_FnType) (_Param..., ...);
   2439 };
   2440 
   2441 #if __has_feature(cxx_reference_qualified_functions) || \
   2442     (defined(_GNUC_VER) && _GNUC_VER >= 409)
   2443 
   2444 template <class _Rp, class _Class, class ..._Param>
   2445 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
   2446 {
   2447     typedef _Class& _ClassType;
   2448     typedef _Rp _ReturnType;
   2449     typedef _Rp (_FnType) (_Param...);
   2450 };
   2451 
   2452 template <class _Rp, class _Class, class ..._Param>
   2453 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
   2454 {
   2455     typedef _Class& _ClassType;
   2456     typedef _Rp _ReturnType;
   2457     typedef _Rp (_FnType) (_Param..., ...);
   2458 };
   2459 
   2460 template <class _Rp, class _Class, class ..._Param>
   2461 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
   2462 {
   2463     typedef _Class const& _ClassType;
   2464     typedef _Rp _ReturnType;
   2465     typedef _Rp (_FnType) (_Param...);
   2466 };
   2467 
   2468 template <class _Rp, class _Class, class ..._Param>
   2469 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
   2470 {
   2471     typedef _Class const& _ClassType;
   2472     typedef _Rp _ReturnType;
   2473     typedef _Rp (_FnType) (_Param..., ...);
   2474 };
   2475 
   2476 template <class _Rp, class _Class, class ..._Param>
   2477 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
   2478 {
   2479     typedef _Class volatile& _ClassType;
   2480     typedef _Rp _ReturnType;
   2481     typedef _Rp (_FnType) (_Param...);
   2482 };
   2483 
   2484 template <class _Rp, class _Class, class ..._Param>
   2485 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
   2486 {
   2487     typedef _Class volatile& _ClassType;
   2488     typedef _Rp _ReturnType;
   2489     typedef _Rp (_FnType) (_Param..., ...);
   2490 };
   2491 
   2492 template <class _Rp, class _Class, class ..._Param>
   2493 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
   2494 {
   2495     typedef _Class const volatile& _ClassType;
   2496     typedef _Rp _ReturnType;
   2497     typedef _Rp (_FnType) (_Param...);
   2498 };
   2499 
   2500 template <class _Rp, class _Class, class ..._Param>
   2501 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
   2502 {
   2503     typedef _Class const volatile& _ClassType;
   2504     typedef _Rp _ReturnType;
   2505     typedef _Rp (_FnType) (_Param..., ...);
   2506 };
   2507 
   2508 template <class _Rp, class _Class, class ..._Param>
   2509 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
   2510 {
   2511     typedef _Class&& _ClassType;
   2512     typedef _Rp _ReturnType;
   2513     typedef _Rp (_FnType) (_Param...);
   2514 };
   2515 
   2516 template <class _Rp, class _Class, class ..._Param>
   2517 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
   2518 {
   2519     typedef _Class&& _ClassType;
   2520     typedef _Rp _ReturnType;
   2521     typedef _Rp (_FnType) (_Param..., ...);
   2522 };
   2523 
   2524 template <class _Rp, class _Class, class ..._Param>
   2525 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
   2526 {
   2527     typedef _Class const&& _ClassType;
   2528     typedef _Rp _ReturnType;
   2529     typedef _Rp (_FnType) (_Param...);
   2530 };
   2531 
   2532 template <class _Rp, class _Class, class ..._Param>
   2533 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
   2534 {
   2535     typedef _Class const&& _ClassType;
   2536     typedef _Rp _ReturnType;
   2537     typedef _Rp (_FnType) (_Param..., ...);
   2538 };
   2539 
   2540 template <class _Rp, class _Class, class ..._Param>
   2541 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
   2542 {
   2543     typedef _Class volatile&& _ClassType;
   2544     typedef _Rp _ReturnType;
   2545     typedef _Rp (_FnType) (_Param...);
   2546 };
   2547 
   2548 template <class _Rp, class _Class, class ..._Param>
   2549 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
   2550 {
   2551     typedef _Class volatile&& _ClassType;
   2552     typedef _Rp _ReturnType;
   2553     typedef _Rp (_FnType) (_Param..., ...);
   2554 };
   2555 
   2556 template <class _Rp, class _Class, class ..._Param>
   2557 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
   2558 {
   2559     typedef _Class const volatile&& _ClassType;
   2560     typedef _Rp _ReturnType;
   2561     typedef _Rp (_FnType) (_Param...);
   2562 };
   2563 
   2564 template <class _Rp, class _Class, class ..._Param>
   2565 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
   2566 {
   2567     typedef _Class const volatile&& _ClassType;
   2568     typedef _Rp _ReturnType;
   2569     typedef _Rp (_FnType) (_Param..., ...);
   2570 };
   2571 
   2572 #endif  // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
   2573 
   2574 #else  // _LIBCPP_HAS_NO_VARIADICS
   2575 
   2576 template <class _Rp, class _Class>
   2577 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
   2578 {
   2579     typedef _Class _ClassType;
   2580     typedef _Rp _ReturnType;
   2581     typedef _Rp (_FnType) ();
   2582 };
   2583 
   2584 template <class _Rp, class _Class>
   2585 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
   2586 {
   2587     typedef _Class _ClassType;
   2588     typedef _Rp _ReturnType;
   2589     typedef _Rp (_FnType) (...);
   2590 };
   2591 
   2592 template <class _Rp, class _Class, class _P0>
   2593 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
   2594 {
   2595     typedef _Class _ClassType;
   2596     typedef _Rp _ReturnType;
   2597     typedef _Rp (_FnType) (_P0);
   2598 };
   2599 
   2600 template <class _Rp, class _Class, class _P0>
   2601 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
   2602 {
   2603     typedef _Class _ClassType;
   2604     typedef _Rp _ReturnType;
   2605     typedef _Rp (_FnType) (_P0, ...);
   2606 };
   2607 
   2608 template <class _Rp, class _Class, class _P0, class _P1>
   2609 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
   2610 {
   2611     typedef _Class _ClassType;
   2612     typedef _Rp _ReturnType;
   2613     typedef _Rp (_FnType) (_P0, _P1);
   2614 };
   2615 
   2616 template <class _Rp, class _Class, class _P0, class _P1>
   2617 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
   2618 {
   2619     typedef _Class _ClassType;
   2620     typedef _Rp _ReturnType;
   2621     typedef _Rp (_FnType) (_P0, _P1, ...);
   2622 };
   2623 
   2624 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2625 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
   2626 {
   2627     typedef _Class _ClassType;
   2628     typedef _Rp _ReturnType;
   2629     typedef _Rp (_FnType) (_P0, _P1, _P2);
   2630 };
   2631 
   2632 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2633 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
   2634 {
   2635     typedef _Class _ClassType;
   2636     typedef _Rp _ReturnType;
   2637     typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
   2638 };
   2639 
   2640 template <class _Rp, class _Class>
   2641 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
   2642 {
   2643     typedef _Class const _ClassType;
   2644     typedef _Rp _ReturnType;
   2645     typedef _Rp (_FnType) ();
   2646 };
   2647 
   2648 template <class _Rp, class _Class>
   2649 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
   2650 {
   2651     typedef _Class const _ClassType;
   2652     typedef _Rp _ReturnType;
   2653     typedef _Rp (_FnType) (...);
   2654 };
   2655 
   2656 template <class _Rp, class _Class, class _P0>
   2657 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
   2658 {
   2659     typedef _Class const _ClassType;
   2660     typedef _Rp _ReturnType;
   2661     typedef _Rp (_FnType) (_P0);
   2662 };
   2663 
   2664 template <class _Rp, class _Class, class _P0>
   2665 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
   2666 {
   2667     typedef _Class const _ClassType;
   2668     typedef _Rp _ReturnType;
   2669     typedef _Rp (_FnType) (_P0, ...);
   2670 };
   2671 
   2672 template <class _Rp, class _Class, class _P0, class _P1>
   2673 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
   2674 {
   2675     typedef _Class const _ClassType;
   2676     typedef _Rp _ReturnType;
   2677     typedef _Rp (_FnType) (_P0, _P1);
   2678 };
   2679 
   2680 template <class _Rp, class _Class, class _P0, class _P1>
   2681 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
   2682 {
   2683     typedef _Class const _ClassType;
   2684     typedef _Rp _ReturnType;
   2685     typedef _Rp (_FnType) (_P0, _P1, ...);
   2686 };
   2687 
   2688 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2689 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
   2690 {
   2691     typedef _Class const _ClassType;
   2692     typedef _Rp _ReturnType;
   2693     typedef _Rp (_FnType) (_P0, _P1, _P2);
   2694 };
   2695 
   2696 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2697 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
   2698 {
   2699     typedef _Class const _ClassType;
   2700     typedef _Rp _ReturnType;
   2701     typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
   2702 };
   2703 
   2704 template <class _Rp, class _Class>
   2705 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
   2706 {
   2707     typedef _Class volatile _ClassType;
   2708     typedef _Rp _ReturnType;
   2709     typedef _Rp (_FnType) ();
   2710 };
   2711 
   2712 template <class _Rp, class _Class>
   2713 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
   2714 {
   2715     typedef _Class volatile _ClassType;
   2716     typedef _Rp _ReturnType;
   2717     typedef _Rp (_FnType) (...);
   2718 };
   2719 
   2720 template <class _Rp, class _Class, class _P0>
   2721 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
   2722 {
   2723     typedef _Class volatile _ClassType;
   2724     typedef _Rp _ReturnType;
   2725     typedef _Rp (_FnType) (_P0);
   2726 };
   2727 
   2728 template <class _Rp, class _Class, class _P0>
   2729 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
   2730 {
   2731     typedef _Class volatile _ClassType;
   2732     typedef _Rp _ReturnType;
   2733     typedef _Rp (_FnType) (_P0, ...);
   2734 };
   2735 
   2736 template <class _Rp, class _Class, class _P0, class _P1>
   2737 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
   2738 {
   2739     typedef _Class volatile _ClassType;
   2740     typedef _Rp _ReturnType;
   2741     typedef _Rp (_FnType) (_P0, _P1);
   2742 };
   2743 
   2744 template <class _Rp, class _Class, class _P0, class _P1>
   2745 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
   2746 {
   2747     typedef _Class volatile _ClassType;
   2748     typedef _Rp _ReturnType;
   2749     typedef _Rp (_FnType) (_P0, _P1, ...);
   2750 };
   2751 
   2752 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2753 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
   2754 {
   2755     typedef _Class volatile _ClassType;
   2756     typedef _Rp _ReturnType;
   2757     typedef _Rp (_FnType) (_P0, _P1, _P2);
   2758 };
   2759 
   2760 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2761 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
   2762 {
   2763     typedef _Class volatile _ClassType;
   2764     typedef _Rp _ReturnType;
   2765     typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
   2766 };
   2767 
   2768 template <class _Rp, class _Class>
   2769 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
   2770 {
   2771     typedef _Class const volatile _ClassType;
   2772     typedef _Rp _ReturnType;
   2773     typedef _Rp (_FnType) ();
   2774 };
   2775 
   2776 template <class _Rp, class _Class>
   2777 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
   2778 {
   2779     typedef _Class const volatile _ClassType;
   2780     typedef _Rp _ReturnType;
   2781     typedef _Rp (_FnType) (...);
   2782 };
   2783 
   2784 template <class _Rp, class _Class, class _P0>
   2785 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
   2786 {
   2787     typedef _Class const volatile _ClassType;
   2788     typedef _Rp _ReturnType;
   2789     typedef _Rp (_FnType) (_P0);
   2790 };
   2791 
   2792 template <class _Rp, class _Class, class _P0>
   2793 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
   2794 {
   2795     typedef _Class const volatile _ClassType;
   2796     typedef _Rp _ReturnType;
   2797     typedef _Rp (_FnType) (_P0, ...);
   2798 };
   2799 
   2800 template <class _Rp, class _Class, class _P0, class _P1>
   2801 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
   2802 {
   2803     typedef _Class const volatile _ClassType;
   2804     typedef _Rp _ReturnType;
   2805     typedef _Rp (_FnType) (_P0, _P1);
   2806 };
   2807 
   2808 template <class _Rp, class _Class, class _P0, class _P1>
   2809 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
   2810 {
   2811     typedef _Class const volatile _ClassType;
   2812     typedef _Rp _ReturnType;
   2813     typedef _Rp (_FnType) (_P0, _P1, ...);
   2814 };
   2815 
   2816 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2817 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
   2818 {
   2819     typedef _Class const volatile _ClassType;
   2820     typedef _Rp _ReturnType;
   2821     typedef _Rp (_FnType) (_P0, _P1, _P2);
   2822 };
   2823 
   2824 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
   2825 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
   2826 {
   2827     typedef _Class const volatile _ClassType;
   2828     typedef _Rp _ReturnType;
   2829     typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
   2830 };
   2831 
   2832 #endif  // _LIBCPP_HAS_NO_VARIADICS
   2833 
   2834 template <class _Rp, class _Class>
   2835 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
   2836 {
   2837     typedef _Class _ClassType;
   2838     typedef _Rp _ReturnType;
   2839 };
   2840 
   2841 template <class _MP>
   2842 struct __member_pointer_traits
   2843     : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
   2844                     is_member_function_pointer<_MP>::value,
   2845                     is_member_object_pointer<_MP>::value>
   2846 {
   2847 //     typedef ... _ClassType;
   2848 //     typedef ... _ReturnType;
   2849 //     typedef ... _FnType;
   2850 };
   2851 
   2852 
   2853 template <class _DecayedFp>
   2854 struct __member_pointer_class_type {};
   2855 
   2856 template <class _Ret, class _ClassType>
   2857 struct __member_pointer_class_type<_Ret _ClassType::*> {
   2858   typedef _ClassType type;
   2859 };
   2860 
   2861 // result_of
   2862 
   2863 template <class _Callable> class result_of;
   2864 
   2865 #ifdef _LIBCPP_HAS_NO_VARIADICS
   2866 
   2867 template <class _Fn, bool, bool>
   2868 class __result_of
   2869 {
   2870 };
   2871 
   2872 template <class _Fn>
   2873 class __result_of<_Fn(), true, false>
   2874 {
   2875 public:
   2876     typedef decltype(declval<_Fn>()()) type;
   2877 };
   2878 
   2879 template <class _Fn, class _A0>
   2880 class __result_of<_Fn(_A0), true, false>
   2881 {
   2882 public:
   2883     typedef decltype(declval<_Fn>()(declval<_A0>())) type;
   2884 };
   2885 
   2886 template <class _Fn, class _A0, class _A1>
   2887 class __result_of<_Fn(_A0, _A1), true, false>
   2888 {
   2889 public:
   2890     typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
   2891 };
   2892 
   2893 template <class _Fn, class _A0, class _A1, class _A2>
   2894 class __result_of<_Fn(_A0, _A1, _A2), true, false>
   2895 {
   2896 public:
   2897     typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
   2898 };
   2899 
   2900 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
   2901 struct __result_of_mp;
   2902 
   2903 // member function pointer
   2904 
   2905 template <class _MP, class _Tp>
   2906 struct __result_of_mp<_MP, _Tp, true>
   2907     : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
   2908 {
   2909 };
   2910 
   2911 // member data pointer
   2912 
   2913 template <class _MP, class _Tp, bool>
   2914 struct __result_of_mdp;
   2915 
   2916 template <class _Rp, class _Class, class _Tp>
   2917 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
   2918 {
   2919     typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
   2920 };
   2921 
   2922 template <class _Rp, class _Class, class _Tp>
   2923 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
   2924 {
   2925     typedef typename __apply_cv<_Tp, _Rp>::type& type;
   2926 };
   2927 
   2928 template <class _Rp, class _Class, class _Tp>
   2929 struct __result_of_mp<_Rp _Class::*, _Tp, false>
   2930     : public __result_of_mdp<_Rp _Class::*, _Tp,
   2931             is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
   2932 {
   2933 };
   2934 
   2935 
   2936 
   2937 template <class _Fn, class _Tp>
   2938 class __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
   2939     : public __result_of_mp<typename remove_reference<_Fn>::type,
   2940                             _Tp,
   2941                             is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
   2942 {
   2943 };
   2944 
   2945 template <class _Fn, class _Tp, class _A0>
   2946 class __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
   2947     : public __result_of_mp<typename remove_reference<_Fn>::type,
   2948                             _Tp,
   2949                             is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
   2950 {
   2951 };
   2952 
   2953 template <class _Fn, class _Tp, class _A0, class _A1>
   2954 class __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
   2955     : public __result_of_mp<typename remove_reference<_Fn>::type,
   2956                             _Tp,
   2957                             is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
   2958 {
   2959 };
   2960 
   2961 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
   2962 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
   2963     : public __result_of_mp<typename remove_reference<_Fn>::type,
   2964                             _Tp,
   2965                             is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
   2966 {
   2967 };
   2968 
   2969 // result_of
   2970 
   2971 template <class _Fn>
   2972 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
   2973     : public __result_of<_Fn(),
   2974                          is_class<typename remove_reference<_Fn>::type>::value ||
   2975                          is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
   2976                          is_member_pointer<typename remove_reference<_Fn>::type>::value
   2977                         >
   2978 {
   2979 };
   2980 
   2981 template <class _Fn, class _A0>
   2982 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
   2983     : public __result_of<_Fn(_A0),
   2984                          is_class<typename remove_reference<_Fn>::type>::value ||
   2985                          is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
   2986                          is_member_pointer<typename remove_reference<_Fn>::type>::value
   2987                         >
   2988 {
   2989 };
   2990 
   2991 template <class _Fn, class _A0, class _A1>
   2992 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
   2993     : public __result_of<_Fn(_A0, _A1),
   2994                          is_class<typename remove_reference<_Fn>::type>::value ||
   2995                          is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
   2996                          is_member_pointer<typename remove_reference<_Fn>::type>::value
   2997                         >
   2998 {
   2999 };
   3000 
   3001 template <class _Fn, class _A0, class _A1, class _A2>
   3002 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
   3003     : public __result_of<_Fn(_A0, _A1, _A2),
   3004                          is_class<typename remove_reference<_Fn>::type>::value ||
   3005                          is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
   3006                          is_member_pointer<typename remove_reference<_Fn>::type>::value
   3007                         >
   3008 {
   3009 };
   3010 
   3011 #endif  // _LIBCPP_HAS_NO_VARIADICS
   3012 
   3013 // template <class T, class... Args> struct is_constructible;
   3014 
   3015 namespace __is_construct
   3016 {
   3017 struct __nat {};
   3018 }
   3019 
   3020 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
   3021     defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
   3022 
   3023 template <class _Tp, class... _Args>
   3024 struct __libcpp_is_constructible;
   3025 
   3026 template <class _To, class _From>
   3027 struct __is_invalid_base_to_derived_cast {
   3028   static_assert(is_reference<_To>::value, "Wrong specialization");
   3029   using _RawFrom = __uncvref_t<_From>;
   3030   using _RawTo = __uncvref_t<_To>;
   3031   static const bool value = __lazy_and<
   3032         __lazy_not<is_same<_RawFrom, _RawTo>>,
   3033         is_base_of<_RawFrom, _RawTo>,
   3034         __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
   3035   >::value;
   3036 };
   3037 
   3038 template <class _To, class _From>
   3039 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
   3040   static_assert(is_reference<_To>::value, "Wrong specialization");
   3041 };
   3042 
   3043 template <class _ToRef, class _FromRef>
   3044 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
   3045   using _RawFrom = __uncvref_t<_FromRef>;
   3046   using _RawTo = __uncvref_t<_ToRef>;
   3047   static const bool value = __lazy_and<
   3048       __lazy_not<is_function<_RawTo>>,
   3049       __lazy_or<
   3050         is_same<_RawFrom, _RawTo>,
   3051         is_base_of<_RawTo, _RawFrom>>
   3052     >::value;
   3053 };
   3054 
   3055 struct __is_constructible_helper
   3056 {
   3057     template <class _To>
   3058     static void __eat(_To);
   3059 
   3060     // This overload is needed to work around a Clang bug that disallows
   3061     // static_cast<T&&>(e) for non-reference-compatible types.
   3062     // Example: static_cast<int&&>(declval<double>());
   3063     // NOTE: The static_cast implementation below is required to support
   3064     //  classes with explicit conversion operators.
   3065     template <class _To, class _From,
   3066               class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
   3067     static true_type __test_cast(int);
   3068 
   3069     template <class _To, class _From,
   3070               class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
   3071     static integral_constant<bool,
   3072         !__is_invalid_base_to_derived_cast<_To, _From>::value &&
   3073         !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
   3074     > __test_cast(long);
   3075 
   3076     template <class, class>
   3077     static false_type __test_cast(...);
   3078 
   3079     template <class _Tp, class ..._Args,
   3080         class = decltype(_Tp(_VSTD::declval<_Args>()...))>
   3081     static true_type __test_nary(int);
   3082     template <class _Tp, class...>
   3083     static false_type __test_nary(...);
   3084 
   3085     template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
   3086     static is_destructible<_Tp> __test_unary(int);
   3087     template <class, class>
   3088     static false_type __test_unary(...);
   3089 };
   3090 
   3091 template <class _Tp, bool = is_void<_Tp>::value>
   3092 struct __is_default_constructible
   3093     : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
   3094 {};
   3095 
   3096 template <class _Tp>
   3097 struct __is_default_constructible<_Tp, true> : false_type {};
   3098 
   3099 template <class _Tp>
   3100 struct __is_default_constructible<_Tp[], false> : false_type {};
   3101 
   3102 template <class _Tp, size_t _Nx>
   3103 struct __is_default_constructible<_Tp[_Nx], false>
   3104     : __is_default_constructible<typename remove_all_extents<_Tp>::type>  {};
   3105 
   3106 template <class _Tp, class... _Args>
   3107 struct __libcpp_is_constructible
   3108 {
   3109   static_assert(sizeof...(_Args) > 1, "Wrong specialization");
   3110   typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
   3111       type;
   3112 };
   3113 
   3114 template <class _Tp>
   3115 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
   3116 
   3117 template <class _Tp, class _A0>
   3118 struct __libcpp_is_constructible<_Tp, _A0>
   3119     : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
   3120 {};
   3121 
   3122 template <class _Tp, class _A0>
   3123 struct __libcpp_is_constructible<_Tp&, _A0>
   3124     : public decltype(__is_constructible_helper::
   3125     __test_cast<_Tp&, _A0>(0))
   3126 {};
   3127 
   3128 template <class _Tp, class _A0>
   3129 struct __libcpp_is_constructible<_Tp&&, _A0>
   3130     : public decltype(__is_constructible_helper::
   3131     __test_cast<_Tp&&, _A0>(0))
   3132 {};
   3133 
   3134 #endif
   3135 
   3136 #if __has_feature(is_constructible)
   3137 template <class _Tp, class ..._Args>
   3138 struct _LIBCPP_TEMPLATE_VIS is_constructible
   3139     : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
   3140     {};
   3141 #elif !defined(_LIBCPP_CXX03_LANG)
   3142 template <class _Tp, class... _Args>
   3143 struct _LIBCPP_TEMPLATE_VIS is_constructible
   3144     : public __libcpp_is_constructible<_Tp, _Args...>::type {};
   3145 #else
   3146 // template <class T> struct is_constructible0;
   3147 
   3148 //      main is_constructible0 test
   3149 
   3150 template <class _Tp>
   3151 decltype((_Tp(), true_type()))
   3152 __is_constructible0_test(_Tp&);
   3153 
   3154 false_type
   3155 __is_constructible0_test(__any);
   3156 
   3157 template <class _Tp, class _A0>
   3158 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
   3159 __is_constructible1_test(_Tp&, _A0&);
   3160 
   3161 template <class _A0>
   3162 false_type
   3163 __is_constructible1_test(__any, _A0&);
   3164 
   3165 template <class _Tp, class _A0, class _A1>
   3166 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
   3167 __is_constructible2_test(_Tp&, _A0&, _A1&);
   3168 
   3169 template <class _A0, class _A1>
   3170 false_type
   3171 __is_constructible2_test(__any, _A0&, _A1&);
   3172 
   3173 template <class _Tp, class _A0, class _A1, class _A2>
   3174 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type()))
   3175 __is_constructible3_test(_Tp&, _A0&, _A1&, _A2&);
   3176 
   3177 template <class _A0, class _A1, class _A2>
   3178 false_type
   3179 __is_constructible3_test(__any, _A0&, _A1&, _A2&);
   3180 
   3181 template <bool, class _Tp>
   3182 struct __is_constructible0_imp // false, _Tp is not a scalar
   3183     : public common_type
   3184              <
   3185                  decltype(__is_constructible0_test(declval<_Tp&>()))
   3186              >::type
   3187     {};
   3188 
   3189 template <bool, class _Tp, class _A0>
   3190 struct __is_constructible1_imp // false, _Tp is not a scalar
   3191     : public common_type
   3192              <
   3193                  decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
   3194              >::type
   3195     {};
   3196 
   3197 template <bool, class _Tp, class _A0, class _A1>
   3198 struct __is_constructible2_imp // false, _Tp is not a scalar
   3199     : public common_type
   3200              <
   3201                  decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
   3202              >::type
   3203     {};
   3204 
   3205 template <bool, class _Tp, class _A0, class _A1, class _A2>
   3206 struct __is_constructible3_imp // false, _Tp is not a scalar
   3207     : public common_type
   3208              <
   3209                  decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>()))
   3210              >::type
   3211     {};
   3212 
   3213 //      handle scalars and reference types
   3214 
   3215 //      Scalars are default constructible, references are not
   3216 
   3217 template <class _Tp>
   3218 struct __is_constructible0_imp<true, _Tp>
   3219     : public is_scalar<_Tp>
   3220     {};
   3221 
   3222 template <class _Tp, class _A0>
   3223 struct __is_constructible1_imp<true, _Tp, _A0>
   3224     : public is_convertible<_A0, _Tp>
   3225     {};
   3226 
   3227 template <class _Tp, class _A0, class _A1>
   3228 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
   3229     : public false_type
   3230     {};
   3231 
   3232 template <class _Tp, class _A0, class _A1, class _A2>
   3233 struct __is_constructible3_imp<true, _Tp, _A0, _A1, _A2>
   3234     : public false_type
   3235     {};
   3236 
   3237 //      Treat scalars and reference types separately
   3238 
   3239 template <bool, class _Tp>
   3240 struct __is_constructible0_void_check
   3241     : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
   3242                                 _Tp>
   3243     {};
   3244 
   3245 template <bool, class _Tp, class _A0>
   3246 struct __is_constructible1_void_check
   3247     : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
   3248                                 _Tp, _A0>
   3249     {};
   3250 
   3251 template <bool, class _Tp, class _A0, class _A1>
   3252 struct __is_constructible2_void_check
   3253     : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
   3254                                 _Tp, _A0, _A1>
   3255     {};
   3256 
   3257 template <bool, class _Tp, class _A0, class _A1, class _A2>
   3258 struct __is_constructible3_void_check
   3259     : public __is_constructible3_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
   3260                                 _Tp, _A0, _A1, _A2>
   3261     {};
   3262 
   3263 //      If any of T or Args is void, is_constructible should be false
   3264 
   3265 template <class _Tp>
   3266 struct __is_constructible0_void_check<true, _Tp>
   3267     : public false_type
   3268     {};
   3269 
   3270 template <class _Tp, class _A0>
   3271 struct __is_constructible1_void_check<true, _Tp, _A0>
   3272     : public false_type
   3273     {};
   3274 
   3275 template <class _Tp, class _A0, class _A1>
   3276 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
   3277     : public false_type
   3278     {};
   3279 
   3280 template <class _Tp, class _A0, class _A1, class _A2>
   3281 struct __is_constructible3_void_check<true, _Tp, _A0, _A1, _A2>
   3282     : public false_type
   3283     {};
   3284 
   3285 //      is_constructible entry point
   3286 
   3287 template <class _Tp, class _A0 = __is_construct::__nat,
   3288                      class _A1 = __is_construct::__nat,
   3289                      class _A2 = __is_construct::__nat>
   3290 struct _LIBCPP_TEMPLATE_VIS is_constructible
   3291     : public __is_constructible3_void_check<is_void<_Tp>::value
   3292                                         || is_abstract<_Tp>::value
   3293                                         || is_function<_Tp>::value
   3294                                         || is_void<_A0>::value
   3295                                         || is_void<_A1>::value
   3296                                         || is_void<_A2>::value,
   3297                                            _Tp, _A0, _A1, _A2>
   3298     {};
   3299 
   3300 template <class _Tp>
   3301 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
   3302     : public __is_constructible0_void_check<is_void<_Tp>::value
   3303                                         || is_abstract<_Tp>::value
   3304                                         || is_function<_Tp>::value,
   3305                                            _Tp>
   3306     {};
   3307 
   3308 template <class _Tp, class _A0>
   3309 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
   3310     : public __is_constructible1_void_check<is_void<_Tp>::value
   3311                                         || is_abstract<_Tp>::value
   3312                                         || is_function<_Tp>::value
   3313                                         || is_void<_A0>::value,
   3314                                            _Tp, _A0>
   3315     {};
   3316 
   3317 template <class _Tp, class _A0, class _A1>
   3318 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, _A1, __is_construct::__nat>
   3319     : public __is_constructible2_void_check<is_void<_Tp>::value
   3320                                         || is_abstract<_Tp>::value
   3321                                         || is_function<_Tp>::value
   3322                                         || is_void<_A0>::value
   3323                                         || is_void<_A1>::value,
   3324                                            _Tp, _A0, _A1>
   3325     {};
   3326 
   3327 //      Array types are default constructible if their element type
   3328 //      is default constructible
   3329 
   3330 template <class _Ap, size_t _Np>
   3331 struct __is_constructible0_imp<false, _Ap[_Np]>
   3332     : public is_constructible<typename remove_all_extents<_Ap>::type>
   3333     {};
   3334 
   3335 template <class _Ap, size_t _Np, class _A0>
   3336 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
   3337     : public false_type
   3338     {};
   3339 
   3340 template <class _Ap, size_t _Np, class _A0, class _A1>
   3341 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
   3342     : public false_type
   3343     {};
   3344 
   3345 template <class _Ap, size_t _Np, class _A0, class _A1, class _A2>
   3346 struct __is_constructible3_imp<false, _Ap[_Np], _A0, _A1, _A2>
   3347     : public false_type
   3348     {};
   3349 
   3350 //      Incomplete array types are not constructible
   3351 
   3352 template <class _Ap>
   3353 struct __is_constructible0_imp<false, _Ap[]>
   3354     : public false_type
   3355     {};
   3356 
   3357 template <class _Ap, class _A0>
   3358 struct __is_constructible1_imp<false, _Ap[], _A0>
   3359     : public false_type
   3360     {};
   3361 
   3362 template <class _Ap, class _A0, class _A1>
   3363 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
   3364     : public false_type
   3365     {};
   3366 
   3367 template <class _Ap, class _A0, class _A1, class _A2>
   3368 struct __is_constructible3_imp<false, _Ap[], _A0, _A1, _A2>
   3369     : public false_type
   3370     {};
   3371 
   3372 #endif // __has_feature(is_constructible)
   3373 
   3374 
   3375 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
   3376 template <class _Tp, class ..._Args>
   3377 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
   3378     = is_constructible<_Tp, _Args...>::value;
   3379 #endif
   3380 
   3381 // is_default_constructible
   3382 
   3383 template <class _Tp>
   3384 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
   3385     : public is_constructible<_Tp>
   3386     {};
   3387 
   3388 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3389 template <class _Tp>
   3390 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
   3391     = is_default_constructible<_Tp>::value;
   3392 #endif
   3393 
   3394 // is_copy_constructible
   3395 
   3396 template <class _Tp>
   3397 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
   3398     : public is_constructible<_Tp, 
   3399                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
   3400 
   3401 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3402 template <class _Tp>
   3403 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
   3404     = is_copy_constructible<_Tp>::value;
   3405 #endif
   3406 
   3407 // is_move_constructible
   3408 
   3409 template <class _Tp>
   3410 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
   3411 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3412     : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
   3413 #else
   3414     : public is_copy_constructible<_Tp>
   3415 #endif
   3416     {};
   3417 
   3418 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3419 template <class _Tp>
   3420 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
   3421     = is_move_constructible<_Tp>::value;
   3422 #endif
   3423 
   3424 // is_trivially_constructible
   3425 
   3426 #ifndef _LIBCPP_HAS_NO_VARIADICS
   3427 
   3428 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
   3429 
   3430 template <class _Tp, class... _Args>
   3431 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
   3432     : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
   3433 {
   3434 };
   3435 
   3436 #else  // !__has_feature(is_trivially_constructible)
   3437 
   3438 template <class _Tp, class... _Args>
   3439 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
   3440     : false_type
   3441 {
   3442 };
   3443 
   3444 template <class _Tp>
   3445 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
   3446 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
   3447     : integral_constant<bool, __has_trivial_constructor(_Tp)>
   3448 #else
   3449     : integral_constant<bool, is_scalar<_Tp>::value>
   3450 #endif
   3451 {
   3452 };
   3453 
   3454 template <class _Tp>
   3455 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3456 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
   3457 #else
   3458 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
   3459 #endif
   3460     : integral_constant<bool, is_scalar<_Tp>::value>
   3461 {
   3462 };
   3463 
   3464 template <class _Tp>
   3465 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
   3466     : integral_constant<bool, is_scalar<_Tp>::value>
   3467 {
   3468 };
   3469 
   3470 template <class _Tp>
   3471 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
   3472     : integral_constant<bool, is_scalar<_Tp>::value>
   3473 {
   3474 };
   3475 
   3476 #endif  // !__has_feature(is_trivially_constructible)
   3477 
   3478 #else  // _LIBCPP_HAS_NO_VARIADICS
   3479 
   3480 template <class _Tp, class _A0 = __is_construct::__nat,
   3481                      class _A1 = __is_construct::__nat>
   3482 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
   3483     : false_type
   3484 {
   3485 };
   3486 
   3487 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
   3488 
   3489 template <class _Tp>
   3490 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
   3491                                                        __is_construct::__nat>
   3492     : integral_constant<bool, __is_trivially_constructible(_Tp)>
   3493 {
   3494 };
   3495 
   3496 template <class _Tp>
   3497 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
   3498                                                        __is_construct::__nat>
   3499     : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
   3500 {
   3501 };
   3502 
   3503 template <class _Tp>
   3504 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
   3505                                                        __is_construct::__nat>
   3506     : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
   3507 {
   3508 };
   3509 
   3510 template <class _Tp>
   3511 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
   3512                                                        __is_construct::__nat>
   3513     : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
   3514 {
   3515 };
   3516 
   3517 #else  // !__has_feature(is_trivially_constructible)
   3518 
   3519 template <class _Tp>
   3520 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
   3521                                                        __is_construct::__nat>
   3522     : integral_constant<bool, is_scalar<_Tp>::value>
   3523 {
   3524 };
   3525 
   3526 template <class _Tp>
   3527 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
   3528                                                        __is_construct::__nat>
   3529     : integral_constant<bool, is_scalar<_Tp>::value>
   3530 {
   3531 };
   3532 
   3533 template <class _Tp>
   3534 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
   3535                                                        __is_construct::__nat>
   3536     : integral_constant<bool, is_scalar<_Tp>::value>
   3537 {
   3538 };
   3539 
   3540 template <class _Tp>
   3541 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
   3542                                                        __is_construct::__nat>
   3543     : integral_constant<bool, is_scalar<_Tp>::value>
   3544 {
   3545 };
   3546 
   3547 #endif  // !__has_feature(is_trivially_constructible)
   3548 
   3549 #endif  // _LIBCPP_HAS_NO_VARIADICS
   3550 
   3551 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
   3552 template <class _Tp, class... _Args>
   3553 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
   3554     = is_trivially_constructible<_Tp, _Args...>::value;
   3555 #endif
   3556 
   3557 // is_trivially_default_constructible
   3558 
   3559 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
   3560     : public is_trivially_constructible<_Tp>
   3561     {};
   3562 
   3563 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3564 template <class _Tp>
   3565 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
   3566     = is_trivially_default_constructible<_Tp>::value;
   3567 #endif
   3568 
   3569 // is_trivially_copy_constructible
   3570 
   3571 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
   3572     : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
   3573     {};
   3574 
   3575 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3576 template <class _Tp>
   3577 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
   3578     = is_trivially_copy_constructible<_Tp>::value;
   3579 #endif
   3580 
   3581 // is_trivially_move_constructible
   3582 
   3583 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
   3584 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3585     : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
   3586 #else
   3587     : public is_trivially_copy_constructible<_Tp>
   3588 #endif
   3589     {};
   3590 
   3591 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3592 template <class _Tp>
   3593 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
   3594     = is_trivially_move_constructible<_Tp>::value;
   3595 #endif
   3596 
   3597 // is_trivially_assignable
   3598 
   3599 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
   3600 
   3601 template <class _Tp, class _Arg>
   3602 struct is_trivially_assignable
   3603     : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
   3604 {
   3605 };
   3606 
   3607 #else  // !__has_feature(is_trivially_assignable)
   3608 
   3609 template <class _Tp, class _Arg>
   3610 struct is_trivially_assignable
   3611     : public false_type {};
   3612 
   3613 template <class _Tp>
   3614 struct is_trivially_assignable<_Tp&, _Tp>
   3615     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3616 
   3617 template <class _Tp>
   3618 struct is_trivially_assignable<_Tp&, _Tp&>
   3619     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3620 
   3621 template <class _Tp>
   3622 struct is_trivially_assignable<_Tp&, const _Tp&>
   3623     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3624 
   3625 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3626 
   3627 template <class _Tp>
   3628 struct is_trivially_assignable<_Tp&, _Tp&&>
   3629     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3630 
   3631 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3632 
   3633 #endif  // !__has_feature(is_trivially_assignable)
   3634 
   3635 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3636 template <class _Tp, class _Arg>
   3637 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
   3638     = is_trivially_assignable<_Tp, _Arg>::value;
   3639 #endif
   3640 
   3641 // is_trivially_copy_assignable
   3642 
   3643 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
   3644     : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
   3645                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
   3646 
   3647 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3648 template <class _Tp>
   3649 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
   3650     = is_trivially_copy_assignable<_Tp>::value;
   3651 #endif
   3652 
   3653 // is_trivially_move_assignable
   3654 
   3655 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
   3656     : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
   3657 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3658                                      typename add_rvalue_reference<_Tp>::type>
   3659 #else
   3660                                      typename add_lvalue_reference<_Tp>::type>
   3661 #endif
   3662     {};
   3663 
   3664 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3665 template <class _Tp>
   3666 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
   3667     = is_trivially_move_assignable<_Tp>::value;
   3668 #endif
   3669 
   3670 // is_trivially_destructible
   3671 
   3672 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
   3673 
   3674 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
   3675     : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
   3676 
   3677 #else
   3678 
   3679 template <class _Tp> struct __libcpp_trivial_destructor
   3680     : public integral_constant<bool, is_scalar<_Tp>::value ||
   3681                                      is_reference<_Tp>::value> {};
   3682 
   3683 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
   3684     : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
   3685 
   3686 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
   3687     : public false_type {};
   3688 
   3689 #endif
   3690 
   3691 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3692 template <class _Tp>
   3693 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
   3694     = is_trivially_destructible<_Tp>::value;
   3695 #endif
   3696 
   3697 // is_nothrow_constructible
   3698 
   3699 #if 0
   3700 template <class _Tp, class... _Args>
   3701 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
   3702     : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
   3703 {
   3704 };
   3705 
   3706 #else
   3707 
   3708 #ifndef _LIBCPP_HAS_NO_VARIADICS
   3709 
   3710 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
   3711 
   3712 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
   3713 
   3714 template <class _Tp, class... _Args>
   3715 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
   3716     : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
   3717 {
   3718 };
   3719 
   3720 template <class _Tp>
   3721 void __implicit_conversion_to(_Tp) noexcept { }
   3722 
   3723 template <class _Tp, class _Arg>
   3724 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
   3725     : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
   3726 {
   3727 };
   3728 
   3729 template <class _Tp, bool _IsReference, class... _Args>
   3730 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
   3731     : public false_type
   3732 {
   3733 };
   3734 
   3735 template <class _Tp, class... _Args>
   3736 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
   3737     : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
   3738 {
   3739 };
   3740 
   3741 template <class _Tp, size_t _Ns>
   3742 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
   3743     : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
   3744 {
   3745 };
   3746 
   3747 #else  // __has_feature(cxx_noexcept)
   3748 
   3749 template <class _Tp, class... _Args>
   3750 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
   3751     : false_type
   3752 {
   3753 };
   3754 
   3755 template <class _Tp>
   3756 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
   3757 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
   3758     : integral_constant<bool, __has_nothrow_constructor(_Tp)>
   3759 #else
   3760     : integral_constant<bool, is_scalar<_Tp>::value>
   3761 #endif
   3762 {
   3763 };
   3764 
   3765 template <class _Tp>
   3766 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3767 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
   3768 #else
   3769 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
   3770 #endif
   3771 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
   3772     : integral_constant<bool, __has_nothrow_copy(_Tp)>
   3773 #else
   3774     : integral_constant<bool, is_scalar<_Tp>::value>
   3775 #endif
   3776 {
   3777 };
   3778 
   3779 template <class _Tp>
   3780 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
   3781 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
   3782     : integral_constant<bool, __has_nothrow_copy(_Tp)>
   3783 #else
   3784     : integral_constant<bool, is_scalar<_Tp>::value>
   3785 #endif
   3786 {
   3787 };
   3788 
   3789 template <class _Tp>
   3790 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
   3791 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
   3792     : integral_constant<bool, __has_nothrow_copy(_Tp)>
   3793 #else
   3794     : integral_constant<bool, is_scalar<_Tp>::value>
   3795 #endif
   3796 {
   3797 };
   3798 
   3799 #endif  // __has_feature(cxx_noexcept)
   3800 
   3801 #else  // _LIBCPP_HAS_NO_VARIADICS
   3802 
   3803 template <class _Tp, class _A0 = __is_construct::__nat,
   3804                      class _A1 = __is_construct::__nat>
   3805 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
   3806     : false_type
   3807 {
   3808 };
   3809 
   3810 template <class _Tp>
   3811 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
   3812                                                        __is_construct::__nat>
   3813 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
   3814     : integral_constant<bool, __has_nothrow_constructor(_Tp)>
   3815 #else
   3816     : integral_constant<bool, is_scalar<_Tp>::value>
   3817 #endif
   3818 {
   3819 };
   3820 
   3821 template <class _Tp>
   3822 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
   3823                                                        __is_construct::__nat>
   3824 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
   3825     : integral_constant<bool, __has_nothrow_copy(_Tp)>
   3826 #else
   3827     : integral_constant<bool, is_scalar<_Tp>::value>
   3828 #endif
   3829 {
   3830 };
   3831 
   3832 template <class _Tp>
   3833 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
   3834                                                        __is_construct::__nat>
   3835 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
   3836     : integral_constant<bool, __has_nothrow_copy(_Tp)>
   3837 #else
   3838     : integral_constant<bool, is_scalar<_Tp>::value>
   3839 #endif
   3840 {
   3841 };
   3842 
   3843 template <class _Tp>
   3844 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
   3845                                                        __is_construct::__nat>
   3846 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
   3847     : integral_constant<bool, __has_nothrow_copy(_Tp)>
   3848 #else
   3849     : integral_constant<bool, is_scalar<_Tp>::value>
   3850 #endif
   3851 {
   3852 };
   3853 
   3854 #endif  // _LIBCPP_HAS_NO_VARIADICS
   3855 #endif  // __has_feature(is_nothrow_constructible)
   3856 
   3857 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
   3858 template <class _Tp, class ..._Args>
   3859 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
   3860     = is_nothrow_constructible<_Tp, _Args...>::value;
   3861 #endif
   3862 
   3863 // is_nothrow_default_constructible
   3864 
   3865 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
   3866     : public is_nothrow_constructible<_Tp>
   3867     {};
   3868 
   3869 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3870 template <class _Tp>
   3871 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
   3872     = is_nothrow_default_constructible<_Tp>::value;
   3873 #endif
   3874 
   3875 // is_nothrow_copy_constructible
   3876 
   3877 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
   3878     : public is_nothrow_constructible<_Tp,
   3879                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
   3880 
   3881 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3882 template <class _Tp>
   3883 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
   3884     = is_nothrow_copy_constructible<_Tp>::value;
   3885 #endif
   3886 
   3887 // is_nothrow_move_constructible
   3888 
   3889 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
   3890 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3891     : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
   3892 #else
   3893     : public is_nothrow_copy_constructible<_Tp>
   3894 #endif
   3895     {};
   3896 
   3897 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3898 template <class _Tp>
   3899 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
   3900     = is_nothrow_move_constructible<_Tp>::value;
   3901 #endif
   3902 
   3903 // is_nothrow_assignable
   3904 
   3905 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
   3906 
   3907 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
   3908 
   3909 template <class _Tp, class _Arg>
   3910 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
   3911     : public false_type
   3912 {
   3913 };
   3914 
   3915 template <class _Tp, class _Arg>
   3916 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
   3917     : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
   3918 {
   3919 };
   3920 
   3921 template <class _Tp, class _Arg>
   3922 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
   3923     : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
   3924 {
   3925 };
   3926 
   3927 #else  // __has_feature(cxx_noexcept)
   3928 
   3929 template <class _Tp, class _Arg>
   3930 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
   3931     : public false_type {};
   3932 
   3933 template <class _Tp>
   3934 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
   3935 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
   3936     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
   3937 #else
   3938     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3939 #endif
   3940 
   3941 template <class _Tp>
   3942 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
   3943 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
   3944     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
   3945 #else
   3946     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3947 #endif
   3948 
   3949 template <class _Tp>
   3950 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
   3951 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
   3952     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
   3953 #else
   3954     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3955 #endif
   3956 
   3957 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3958 
   3959 template <class _Tp>
   3960 struct is_nothrow_assignable<_Tp&, _Tp&&>
   3961 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
   3962     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
   3963 #else
   3964     : integral_constant<bool, is_scalar<_Tp>::value> {};
   3965 #endif
   3966 
   3967 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3968 
   3969 #endif  // __has_feature(cxx_noexcept)
   3970 
   3971 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3972 template <class _Tp, class _Arg>
   3973 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
   3974     = is_nothrow_assignable<_Tp, _Arg>::value;
   3975 #endif
   3976 
   3977 // is_nothrow_copy_assignable
   3978 
   3979 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
   3980     : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
   3981                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
   3982 
   3983 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   3984 template <class _Tp>
   3985 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
   3986     = is_nothrow_copy_assignable<_Tp>::value;
   3987 #endif
   3988 
   3989 // is_nothrow_move_assignable
   3990 
   3991 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
   3992     : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
   3993 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3994                                      typename add_rvalue_reference<_Tp>::type>
   3995 #else
   3996                                      typename add_lvalue_reference<_Tp>::type>
   3997 #endif
   3998     {};
   3999 
   4000 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   4001 template <class _Tp>
   4002 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
   4003     = is_nothrow_move_assignable<_Tp>::value;
   4004 #endif
   4005 
   4006 // is_nothrow_destructible
   4007 
   4008 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
   4009 
   4010 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
   4011 
   4012 template <class _Tp>
   4013 struct __libcpp_is_nothrow_destructible<false, _Tp>
   4014     : public false_type
   4015 {
   4016 };
   4017 
   4018 template <class _Tp>
   4019 struct __libcpp_is_nothrow_destructible<true, _Tp>
   4020     : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
   4021 {
   4022 };
   4023 
   4024 template <class _Tp>
   4025 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
   4026     : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
   4027 {
   4028 };
   4029 
   4030 template <class _Tp, size_t _Ns>
   4031 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
   4032     : public is_nothrow_destructible<_Tp>
   4033 {
   4034 };
   4035 
   4036 template <class _Tp>
   4037 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
   4038     : public true_type
   4039 {
   4040 };
   4041 
   4042 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   4043 
   4044 template <class _Tp>
   4045 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
   4046     : public true_type
   4047 {
   4048 };
   4049 
   4050 #endif
   4051 
   4052 #else
   4053 
   4054 template <class _Tp> struct __libcpp_nothrow_destructor
   4055     : public integral_constant<bool, is_scalar<_Tp>::value ||
   4056                                      is_reference<_Tp>::value> {};
   4057 
   4058 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
   4059     : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
   4060 
   4061 template <class _Tp>
   4062 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
   4063     : public false_type {};
   4064 
   4065 #endif
   4066 
   4067 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   4068 template <class _Tp>
   4069 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
   4070     = is_nothrow_destructible<_Tp>::value;
   4071 #endif
   4072 
   4073 // is_pod
   4074 
   4075 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
   4076 
   4077 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
   4078     : public integral_constant<bool, __is_pod(_Tp)> {};
   4079 
   4080 #else
   4081 
   4082 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
   4083     : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
   4084                                      is_trivially_copy_constructible<_Tp>::value      &&
   4085                                      is_trivially_copy_assignable<_Tp>::value    &&
   4086                                      is_trivially_destructible<_Tp>::value> {};
   4087 
   4088 #endif
   4089 
   4090 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   4091 template <class _Tp>
   4092 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
   4093     = is_pod<_Tp>::value;
   4094 #endif
   4095 
   4096 // is_literal_type;
   4097 
   4098 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
   4099 #ifdef _LIBCPP_IS_LITERAL
   4100     : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
   4101 #else
   4102     : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
   4103                               is_reference<typename remove_all_extents<_Tp>::type>::value>
   4104 #endif
   4105     {};
   4106     
   4107 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   4108 template <class _Tp>
   4109 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
   4110     = is_literal_type<_Tp>::value;
   4111 #endif
   4112 
   4113 // is_standard_layout;
   4114 
   4115 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
   4116 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
   4117     : public integral_constant<bool, __is_standard_layout(_Tp)>
   4118 #else
   4119     : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
   4120 #endif
   4121     {};
   4122     
   4123 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   4124 template <class _Tp>
   4125 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
   4126     = is_standard_layout<_Tp>::value;
   4127 #endif
   4128 
   4129 // is_trivially_copyable;
   4130 
   4131 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
   4132 #if __has_feature(is_trivially_copyable)
   4133     : public integral_constant<bool, __is_trivially_copyable(_Tp)>
   4134 #elif _GNUC_VER >= 501
   4135     : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
   4136 #else
   4137     : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
   4138 #endif
   4139     {};
   4140     
   4141 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   4142 template <class _Tp>
   4143 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
   4144     = is_trivially_copyable<_Tp>::value;
   4145 #endif
   4146 
   4147 // is_trivial;
   4148 
   4149 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
   4150 #if __has_feature(is_trivial) || _GNUC_VER >= 407
   4151     : public integral_constant<bool, __is_trivial(_Tp)>
   4152 #else
   4153     : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
   4154                                  is_trivially_default_constructible<_Tp>::value>
   4155 #endif
   4156     {};
   4157 
   4158 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
   4159 template <class _Tp>
   4160 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
   4161     = is_trivial<_Tp>::value;
   4162 #endif
   4163 
   4164 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
   4165 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
   4166 template <class _Tp> struct __is_reference_wrapper
   4167     : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
   4168 
   4169 #ifndef _LIBCPP_CXX03_LANG
   4170 
   4171 // Check for complete types
   4172 
   4173 template <class ..._Tp> struct __check_complete;
   4174 
   4175 template <>
   4176 struct __check_complete<>
   4177 {
   4178 };
   4179 
   4180 template <class _Hp, class _T0, class ..._Tp>
   4181 struct __check_complete<_Hp, _T0, _Tp...>
   4182     : private __check_complete<_Hp>,
   4183       private __check_complete<_T0, _Tp...>
   4184 {
   4185 };
   4186 
   4187 template <class _Hp>
   4188 struct __check_complete<_Hp, _Hp>
   4189     : private __check_complete<_Hp>
   4190 {
   4191 };
   4192 
   4193 template <class _Tp>
   4194 struct __check_complete<_Tp>
   4195 {
   4196     static_assert(sizeof(_Tp) > 0, "Type must be complete.");
   4197 };
   4198 
   4199 template <class _Tp>
   4200 struct __check_complete<_Tp&>
   4201     : private __check_complete<_Tp>
   4202 {
   4203 };
   4204 
   4205 template <class _Tp>
   4206 struct __check_complete<_Tp&&>
   4207     : private __check_complete<_Tp>
   4208 {
   4209 };
   4210 
   4211 template <class _Rp, class ..._Param>
   4212 struct __check_complete<_Rp (*)(_Param...)>
   4213     : private __check_complete<_Rp>
   4214 {
   4215 };
   4216 
   4217 template <class ..._Param>
   4218 struct __check_complete<void (*)(_Param...)>
   4219 {
   4220 };
   4221 
   4222 template <class _Rp, class ..._Param>
   4223 struct __check_complete<_Rp (_Param...)>
   4224     : private __check_complete<_Rp>
   4225 {
   4226 };
   4227 
   4228 template <class ..._Param>
   4229 struct __check_complete<void (_Param...)>
   4230 {
   4231 };
   4232 
   4233 template <class _Rp, class _Class, class ..._Param>
   4234 struct __check_complete<_Rp (_Class::*)(_Param...)>
   4235     : private __check_complete<_Class>
   4236 {
   4237 };
   4238 
   4239 template <class _Rp, class _Class, class ..._Param>
   4240 struct __check_complete<_Rp (_Class::*)(_Param...) const>
   4241     : private __check_complete<_Class>
   4242 {
   4243 };
   4244 
   4245 template <class _Rp, class _Class, class ..._Param>
   4246 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
   4247     : private __check_complete<_Class>
   4248 {
   4249 };
   4250 
   4251 template <class _Rp, class _Class, class ..._Param>
   4252 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
   4253     : private __check_complete<_Class>
   4254 {
   4255 };
   4256 
   4257 template <class _Rp, class _Class, class ..._Param>
   4258 struct __check_complete<_Rp (_Class::*)(_Param...) &>
   4259     : private __check_complete<_Class>
   4260 {
   4261 };
   4262 
   4263 template <class _Rp, class _Class, class ..._Param>
   4264 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
   4265     : private __check_complete<_Class>
   4266 {
   4267 };
   4268 
   4269 template <class _Rp, class _Class, class ..._Param>
   4270 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
   4271     : private __check_complete<_Class>
   4272 {
   4273 };
   4274 
   4275 template <class _Rp, class _Class, class ..._Param>
   4276 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
   4277     : private __check_complete<_Class>
   4278 {
   4279 };
   4280 
   4281 template <class _Rp, class _Class, class ..._Param>
   4282 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
   4283     : private __check_complete<_Class>
   4284 {
   4285 };
   4286 
   4287 template <class _Rp, class _Class, class ..._Param>
   4288 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
   4289     : private __check_complete<_Class>
   4290 {
   4291 };
   4292 
   4293 template <class _Rp, class _Class, class ..._Param>
   4294 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
   4295     : private __check_complete<_Class>
   4296 {
   4297 };
   4298 
   4299 template <class _Rp, class _Class, class ..._Param>
   4300 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
   4301     : private __check_complete<_Class>
   4302 {
   4303 };
   4304 
   4305 template <class _Rp, class _Class>
   4306 struct __check_complete<_Rp _Class::*>
   4307     : private __check_complete<_Class>
   4308 {
   4309 };
   4310 
   4311 
   4312 template <class _Fp, class _A0,
   4313          class _DecayFp = typename decay<_Fp>::type,
   4314          class _DecayA0 = typename decay<_A0>::type,
   4315          class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
   4316 using __enable_if_bullet1 = typename enable_if
   4317     <
   4318         is_member_function_pointer<_DecayFp>::value
   4319         && is_base_of<_ClassT, _DecayA0>::value
   4320     >::type;
   4321 
   4322 template <class _Fp, class _A0,
   4323          class _DecayFp = typename decay<_Fp>::type,
   4324          class _DecayA0 = typename decay<_A0>::type>
   4325 using __enable_if_bullet2 = typename enable_if
   4326     <
   4327         is_member_function_pointer<_DecayFp>::value
   4328         && __is_reference_wrapper<_DecayA0>::value
   4329     >::type;
   4330 
   4331 template <class _Fp, class _A0,
   4332          class _DecayFp = typename decay<_Fp>::type,
   4333          class _DecayA0 = typename decay<_A0>::type,
   4334          class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
   4335 using __enable_if_bullet3 = typename enable_if
   4336     <
   4337         is_member_function_pointer<_DecayFp>::value
   4338         && !is_base_of<_ClassT, _DecayA0>::value
   4339         && !__is_reference_wrapper<_DecayA0>::value
   4340     >::type;
   4341 
   4342 template <class _Fp, class _A0,
   4343          class _DecayFp = typename decay<_Fp>::type,
   4344          class _DecayA0 = typename decay<_A0>::type,
   4345          class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
   4346 using __enable_if_bullet4 = typename enable_if
   4347     <
   4348         is_member_object_pointer<_DecayFp>::value
   4349         && is_base_of<_ClassT, _DecayA0>::value
   4350     >::type;
   4351 
   4352 template <class _Fp, class _A0,
   4353          class _DecayFp = typename decay<_Fp>::type,
   4354          class _DecayA0 = typename decay<_A0>::type>
   4355 using __enable_if_bullet5 = typename enable_if
   4356     <
   4357         is_member_object_pointer<_DecayFp>::value
   4358         && __is_reference_wrapper<_DecayA0>::value
   4359     >::type;
   4360 
   4361 template <class _Fp, class _A0,
   4362          class _DecayFp = typename decay<_Fp>::type,
   4363          class _DecayA0 = typename decay<_A0>::type,
   4364          class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
   4365 using __enable_if_bullet6 = typename enable_if
   4366     <
   4367         is_member_object_pointer<_DecayFp>::value
   4368         && !is_base_of<_ClassT, _DecayA0>::value
   4369         && !__is_reference_wrapper<_DecayA0>::value
   4370     >::type;
   4371 
   4372 // __invoke forward declarations
   4373 
   4374 // fall back - none of the bullets
   4375 
   4376 #define _LIBCPP_INVOKE_RETURN(...) \
   4377     noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
   4378     { return __VA_ARGS__; }
   4379 
   4380 template <class ..._Args>
   4381 auto __invoke(__any, _Args&& ...__args) -> __nat;
   4382 
   4383 template <class ..._Args>
   4384 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
   4385 
   4386 // bullets 1, 2 and 3
   4387 
   4388 template <class _Fp, class _A0, class ..._Args,
   4389           class = __enable_if_bullet1<_Fp, _A0>>
   4390 inline _LIBCPP_INLINE_VISIBILITY
   4391 auto
   4392 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
   4393 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
   4394 
   4395 template <class _Fp, class _A0, class ..._Args,
   4396           class = __enable_if_bullet1<_Fp, _A0>>
   4397 inline _LIBCPP_INLINE_VISIBILITY
   4398 _LIBCPP_CONSTEXPR auto
   4399 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
   4400 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
   4401 
   4402 template <class _Fp, class _A0, class ..._Args,
   4403           class = __enable_if_bullet2<_Fp, _A0>>
   4404 inline _LIBCPP_INLINE_VISIBILITY
   4405 auto
   4406 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
   4407 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
   4408 
   4409 template <class _Fp, class _A0, class ..._Args,
   4410           class = __enable_if_bullet2<_Fp, _A0>>
   4411 inline _LIBCPP_INLINE_VISIBILITY
   4412 _LIBCPP_CONSTEXPR auto
   4413 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
   4414 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
   4415 
   4416 template <class _Fp, class _A0, class ..._Args,
   4417           class = __enable_if_bullet3<_Fp, _A0>>
   4418 inline _LIBCPP_INLINE_VISIBILITY
   4419 auto
   4420 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
   4421 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
   4422 
   4423 template <class _Fp, class _A0, class ..._Args,
   4424           class = __enable_if_bullet3<_Fp, _A0>>
   4425 inline _LIBCPP_INLINE_VISIBILITY
   4426 _LIBCPP_CONSTEXPR auto
   4427 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
   4428 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
   4429 
   4430 // bullets 4, 5 and 6
   4431 
   4432 template <class _Fp, class _A0,
   4433           class = __enable_if_bullet4<_Fp, _A0>>
   4434 inline _LIBCPP_INLINE_VISIBILITY
   4435 auto
   4436 __invoke(_Fp&& __f, _A0&& __a0)
   4437 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
   4438 
   4439 template <class _Fp, class _A0,
   4440           class = __enable_if_bullet4<_Fp, _A0>>
   4441 inline _LIBCPP_INLINE_VISIBILITY
   4442 _LIBCPP_CONSTEXPR auto
   4443 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
   4444 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
   4445 
   4446 template <class _Fp, class _A0,
   4447           class = __enable_if_bullet5<_Fp, _A0>>
   4448 inline _LIBCPP_INLINE_VISIBILITY
   4449 auto
   4450 __invoke(_Fp&& __f, _A0&& __a0)
   4451 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
   4452 
   4453 template <class _Fp, class _A0,
   4454           class = __enable_if_bullet5<_Fp, _A0>>
   4455 inline _LIBCPP_INLINE_VISIBILITY
   4456 _LIBCPP_CONSTEXPR auto
   4457 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
   4458 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
   4459 
   4460 template <class _Fp, class _A0,
   4461           class = __enable_if_bullet6<_Fp, _A0>>
   4462 inline _LIBCPP_INLINE_VISIBILITY
   4463 auto
   4464 __invoke(_Fp&& __f, _A0&& __a0)
   4465 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
   4466 
   4467 template <class _Fp, class _A0,
   4468           class = __enable_if_bullet6<_Fp, _A0>>
   4469 inline _LIBCPP_INLINE_VISIBILITY
   4470 _LIBCPP_CONSTEXPR auto
   4471 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
   4472 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
   4473 
   4474 // bullet 7
   4475 
   4476 template <class _Fp, class ..._Args>
   4477 inline _LIBCPP_INLINE_VISIBILITY
   4478 auto
   4479 __invoke(_Fp&& __f, _Args&& ...__args)
   4480 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
   4481 
   4482 template <class _Fp, class ..._Args>
   4483 inline _LIBCPP_INLINE_VISIBILITY
   4484 _LIBCPP_CONSTEXPR auto
   4485 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
   4486 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
   4487 
   4488 #undef _LIBCPP_INVOKE_RETURN
   4489 
   4490 // __invokable
   4491 
   4492 template <class _Ret, class _Fp, class ..._Args>
   4493 struct __invokable_r
   4494     : private __check_complete<_Fp>
   4495 {
   4496     using _Result = decltype(
   4497         _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
   4498 
   4499     using type =
   4500         typename conditional<
   4501             !is_same<_Result, __nat>::value,
   4502             typename conditional<
   4503                 is_void<_Ret>::value,
   4504                 true_type,
   4505                 is_convertible<_Result, _Ret>
   4506             >::type,
   4507             false_type
   4508         >::type;
   4509     static const bool value = type::value;
   4510 };
   4511 
   4512 template <class _Fp, class ..._Args>
   4513 using __invokable = __invokable_r<void, _Fp, _Args...>;
   4514 
   4515 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
   4516 struct __nothrow_invokable_r_imp {
   4517   static const bool value = false;
   4518 };
   4519 
   4520 template <class _Ret, class _Fp, class ..._Args>
   4521 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
   4522 {
   4523     typedef __nothrow_invokable_r_imp _ThisT;
   4524 
   4525     template <class _Tp>
   4526     static void __test_noexcept(_Tp) noexcept;
   4527 
   4528     static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
   4529         _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
   4530 };
   4531 
   4532 template <class _Ret, class _Fp, class ..._Args>
   4533 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
   4534 {
   4535     static const bool value = noexcept(
   4536         _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
   4537 };
   4538 
   4539 template <class _Ret, class _Fp, class ..._Args>
   4540 using __nothrow_invokable_r =
   4541     __nothrow_invokable_r_imp<
   4542             __invokable_r<_Ret, _Fp, _Args...>::value,
   4543             is_void<_Ret>::value,
   4544             _Ret, _Fp, _Args...
   4545     >;
   4546 
   4547 template <class _Fp, class ..._Args>
   4548 using __nothrow_invokable =
   4549     __nothrow_invokable_r_imp<
   4550             __invokable<_Fp, _Args...>::value,
   4551             true, void, _Fp, _Args...
   4552     >;
   4553 
   4554 template <class _Fp, class ..._Args>
   4555 struct __invoke_of
   4556     : public enable_if<
   4557         __invokable<_Fp, _Args...>::value,
   4558         typename __invokable_r<void, _Fp, _Args...>::_Result>
   4559 {
   4560 };
   4561 
   4562 // result_of
   4563 
   4564 template <class _Fp, class ..._Args>
   4565 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
   4566     : public __invoke_of<_Fp, _Args...>
   4567 {
   4568 };
   4569 
   4570 #if _LIBCPP_STD_VER > 11
   4571 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
   4572 #endif
   4573 
   4574 #if _LIBCPP_STD_VER > 14
   4575 
   4576 // invoke_result
   4577 
   4578 template <class _Fn, class... _Args>
   4579 struct _LIBCPP_TEMPLATE_VIS invoke_result
   4580     : __invoke_of<_Fn, _Args...>
   4581 {
   4582 };
   4583 
   4584 template <class _Fn, class... _Args>
   4585 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
   4586 
   4587 // is_invocable
   4588 
   4589 template <class _Fn, class ..._Args>
   4590 struct _LIBCPP_TEMPLATE_VIS is_invocable
   4591     : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
   4592 
   4593 template <class _Ret, class _Fn, class ..._Args>
   4594 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
   4595     : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
   4596 
   4597 template <class _Fn, class ..._Args>
   4598 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
   4599     = is_invocable<_Fn, _Args...>::value;
   4600 
   4601 template <class _Ret, class _Fn, class ..._Args>
   4602 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
   4603     = is_invocable_r<_Ret, _Fn, _Args...>::value;
   4604 
   4605 // is_nothrow_invocable
   4606 
   4607 template <class _Fn, class ..._Args>
   4608 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
   4609     : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
   4610 
   4611 template <class _Ret, class _Fn, class ..._Args>
   4612 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
   4613     : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
   4614 
   4615 template <class _Fn, class ..._Args>
   4616 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
   4617     = is_nothrow_invocable<_Fn, _Args...>::value;
   4618 
   4619 template <class _Ret, class _Fn, class ..._Args>
   4620 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
   4621     = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
   4622 
   4623 #endif // _LIBCPP_STD_VER > 14
   4624 
   4625 #endif  // !defined(_LIBCPP_CXX03_LANG)
   4626 
   4627 template <class _Tp> struct __is_swappable;
   4628 template <class _Tp> struct __is_nothrow_swappable;
   4629 
   4630 template <class _Tp>
   4631 inline _LIBCPP_INLINE_VISIBILITY
   4632 #ifndef _LIBCPP_CXX03_LANG
   4633 typename enable_if
   4634 <
   4635     is_move_constructible<_Tp>::value &&
   4636     is_move_assignable<_Tp>::value
   4637 >::type
   4638 #else
   4639 void
   4640 #endif
   4641 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
   4642                                     is_nothrow_move_assignable<_Tp>::value)
   4643 {
   4644     _Tp __t(_VSTD::move(__x));
   4645     __x = _VSTD::move(__y);
   4646     __y = _VSTD::move(__t);
   4647 }
   4648 
   4649 template<class _Tp, size_t _Np>
   4650 inline _LIBCPP_INLINE_VISIBILITY
   4651 typename enable_if<
   4652     __is_swappable<_Tp>::value
   4653 >::type
   4654 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
   4655 
   4656 template <class _ForwardIterator1, class _ForwardIterator2>
   4657 inline _LIBCPP_INLINE_VISIBILITY
   4658 void
   4659 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
   4660     //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
   4661                _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
   4662                                           *_VSTD::declval<_ForwardIterator2>())))
   4663 {
   4664     swap(*__a, *__b);
   4665 }
   4666 
   4667 // __swappable
   4668 
   4669 namespace __detail
   4670 {
   4671 // ALL generic swap overloads MUST already have a declaration available at this point.
   4672 
   4673 template <class _Tp, class _Up = _Tp,
   4674           bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
   4675 struct __swappable_with
   4676 {
   4677     template <class _LHS, class _RHS>
   4678     static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
   4679     __test_swap(int);
   4680     template <class, class>
   4681     static __nat __test_swap(long);
   4682 
   4683     // Extra parens are needed for the C++03 definition of decltype.
   4684     typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
   4685     typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
   4686 
   4687     static const bool value = !is_same<__swap1, __nat>::value
   4688                            && !is_same<__swap2, __nat>::value;
   4689 };
   4690 
   4691 template <class _Tp, class _Up>
   4692 struct __swappable_with<_Tp, _Up,  false> : false_type {};
   4693 
   4694 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
   4695 struct __nothrow_swappable_with {
   4696   static const bool value =
   4697 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
   4698       noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
   4699   &&  noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
   4700 #else
   4701       false;
   4702 #endif
   4703 };
   4704 
   4705 template <class _Tp, class _Up>
   4706 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
   4707 
   4708 }  // __detail
   4709 
   4710 template <class _Tp>
   4711 struct __is_swappable
   4712     : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
   4713 {
   4714 };
   4715 
   4716 template <class _Tp>
   4717 struct __is_nothrow_swappable
   4718     : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
   4719 {
   4720 };
   4721 
   4722 #if _LIBCPP_STD_VER > 14
   4723 
   4724 template <class _Tp, class _Up>
   4725 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
   4726     : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
   4727 {
   4728 };
   4729 
   4730 template <class _Tp>
   4731 struct _LIBCPP_TEMPLATE_VIS is_swappable
   4732     : public conditional<
   4733         __is_referenceable<_Tp>::value,
   4734         is_swappable_with<
   4735             typename add_lvalue_reference<_Tp>::type,
   4736             typename add_lvalue_reference<_Tp>::type>,
   4737         false_type
   4738     >::type
   4739 {
   4740 };
   4741 
   4742 template <class _Tp, class _Up>
   4743 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
   4744     : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
   4745 {
   4746 };
   4747 
   4748 template <class _Tp>
   4749 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
   4750     : public conditional<
   4751         __is_referenceable<_Tp>::value,
   4752         is_nothrow_swappable_with<
   4753             typename add_lvalue_reference<_Tp>::type,
   4754             typename add_lvalue_reference<_Tp>::type>,
   4755         false_type
   4756     >::type
   4757 {
   4758 };
   4759 
   4760 template <class _Tp, class _Up>
   4761 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
   4762     = is_swappable_with<_Tp, _Up>::value;
   4763 
   4764 template <class _Tp>
   4765 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
   4766     = is_swappable<_Tp>::value;
   4767 
   4768 template <class _Tp, class _Up>
   4769 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
   4770     = is_nothrow_swappable_with<_Tp, _Up>::value;
   4771 
   4772 template <class _Tp>
   4773 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
   4774     = is_nothrow_swappable<_Tp>::value;
   4775 
   4776 #endif // _LIBCPP_STD_VER > 14
   4777 
   4778 #ifdef _LIBCPP_UNDERLYING_TYPE
   4779 
   4780 template <class _Tp>
   4781 struct underlying_type
   4782 {
   4783     typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
   4784 };
   4785 
   4786 #if _LIBCPP_STD_VER > 11
   4787 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
   4788 #endif
   4789 
   4790 #else  // _LIBCPP_UNDERLYING_TYPE
   4791 
   4792 template <class _Tp, bool _Support = false>
   4793 struct underlying_type
   4794 {
   4795     static_assert(_Support, "The underyling_type trait requires compiler "
   4796                             "support. Either no such support exists or "
   4797                             "libc++ does not know how to use it.");
   4798 };
   4799 
   4800 #endif // _LIBCPP_UNDERLYING_TYPE
   4801 
   4802 
   4803 template <class _Tp, bool = is_enum<_Tp>::value>
   4804 struct __sfinae_underlying_type
   4805 {
   4806     typedef typename underlying_type<_Tp>::type type;
   4807     typedef decltype(((type)1) + 0) __promoted_type;
   4808 };
   4809 
   4810 template <class _Tp>
   4811 struct __sfinae_underlying_type<_Tp, false> {};
   4812 
   4813 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4814 int __convert_to_integral(int __val) { return __val; }
   4815 
   4816 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4817 unsigned __convert_to_integral(unsigned __val) { return __val; }
   4818 
   4819 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4820 long __convert_to_integral(long __val) { return __val; }
   4821 
   4822 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4823 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
   4824 
   4825 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4826 long long __convert_to_integral(long long __val) { return __val; }
   4827 
   4828 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4829 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
   4830 
   4831 template<typename _Fp>
   4832 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4833 typename enable_if<is_floating_point<_Fp>::value, long long>::type
   4834  __convert_to_integral(_Fp __val) { return __val; }
   4835 
   4836 #ifndef _LIBCPP_HAS_NO_INT128
   4837 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4838 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
   4839 
   4840 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4841 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
   4842 #endif
   4843 
   4844 template <class _Tp>
   4845 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   4846 typename __sfinae_underlying_type<_Tp>::__promoted_type
   4847 __convert_to_integral(_Tp __val) { return __val; }
   4848 
   4849 #ifndef _LIBCPP_CXX03_LANG
   4850 
   4851 template <class _Tp>
   4852 struct __has_operator_addressof_member_imp
   4853 {
   4854     template <class _Up>
   4855         static auto __test(int)
   4856             -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
   4857     template <class>
   4858         static auto __test(long) -> false_type;
   4859 
   4860     static const bool value = decltype(__test<_Tp>(0))::value;
   4861 };
   4862 
   4863 template <class _Tp>
   4864 struct __has_operator_addressof_free_imp
   4865 {
   4866     template <class _Up>
   4867         static auto __test(int)
   4868             -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
   4869     template <class>
   4870         static auto __test(long) -> false_type;
   4871 
   4872     static const bool value = decltype(__test<_Tp>(0))::value;
   4873 };
   4874 
   4875 template <class _Tp>
   4876 struct __has_operator_addressof
   4877     : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
   4878                                   || __has_operator_addressof_free_imp<_Tp>::value>
   4879 {};
   4880 
   4881 #endif  // _LIBCPP_CXX03_LANG
   4882 
   4883 #if _LIBCPP_STD_VER > 14
   4884 
   4885 #define __cpp_lib_void_t 201411
   4886 template <class...> using void_t = void;
   4887 
   4888 # ifndef _LIBCPP_HAS_NO_VARIADICS
   4889 template <class... _Args>
   4890 struct conjunction : __and_<_Args...> {};
   4891 template<class... _Args>
   4892 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
   4893     = conjunction<_Args...>::value;
   4894 
   4895 template <class... _Args>
   4896 struct disjunction : __or_<_Args...> {};
   4897 template<class... _Args>
   4898 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
   4899     = disjunction<_Args...>::value;
   4900 
   4901 template <class _Tp>
   4902 struct negation : __not_<_Tp> {};
   4903 template<class _Tp>
   4904 _LIBCPP_INLINE_VAR constexpr bool negation_v
   4905     = negation<_Tp>::value;
   4906 # endif // _LIBCPP_HAS_NO_VARIADICS
   4907 #endif  // _LIBCPP_STD_VER > 14
   4908 
   4909 // These traits are used in __tree and __hash_table
   4910 #ifndef _LIBCPP_CXX03_LANG
   4911 struct __extract_key_fail_tag {};
   4912 struct __extract_key_self_tag {};
   4913 struct __extract_key_first_tag {};
   4914 
   4915 template <class _ValTy, class _Key,
   4916           class _RawValTy = typename __unconstref<_ValTy>::type>
   4917 struct __can_extract_key
   4918     : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
   4919                   __extract_key_fail_tag>::type {};
   4920 
   4921 template <class _Pair, class _Key, class _First, class _Second>
   4922 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
   4923     : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
   4924                   __extract_key_first_tag, __extract_key_fail_tag>::type {};
   4925 
   4926 // __can_extract_map_key uses true_type/false_type instead of the tags.
   4927 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
   4928 // and _ValTy == _Key.
   4929 template <class _ValTy, class _Key, class _ContainerValueTy,
   4930           class _RawValTy = typename __unconstref<_ValTy>::type>
   4931 struct __can_extract_map_key
   4932     : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
   4933 
   4934 // This specialization returns __extract_key_fail_tag for non-map containers
   4935 // because _Key == _ContainerValueTy
   4936 template <class _ValTy, class _Key, class _RawValTy>
   4937 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
   4938     : false_type {};
   4939 
   4940 #endif
   4941 
   4942 #if _LIBCPP_STD_VER > 17
   4943 enum class endian
   4944 {
   4945     little = 0xDEAD,
   4946     big    = 0xFACE,
   4947 #if defined(_LIBCPP_LITTLE_ENDIAN)
   4948     native = little
   4949 #elif defined(_LIBCPP_BIG_ENDIAN)
   4950     native = big
   4951 #else
   4952     native = 0xCAFE
   4953 #endif
   4954 };
   4955 #endif
   4956 
   4957 _LIBCPP_END_NAMESPACE_STD
   4958 
   4959 #if _LIBCPP_STD_VER > 14
   4960 // std::byte
   4961 namespace std  // purposefully not versioned
   4962 {
   4963 template <class _Integer>
   4964   constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
   4965   operator<<=(byte& __lhs, _Integer __shift) noexcept
   4966   { return __lhs = __lhs << __shift; }
   4967   
   4968 template <class _Integer>
   4969   constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
   4970   operator<< (byte  __lhs, _Integer __shift) noexcept
   4971   { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
   4972 
   4973 template <class _Integer>
   4974   constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
   4975   operator>>=(byte& __lhs, _Integer __shift) noexcept
   4976   { return __lhs = __lhs >> __shift; }
   4977 
   4978 template <class _Integer>
   4979   constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
   4980   operator>> (byte  __lhs, _Integer __shift) noexcept
   4981   { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
   4982   
   4983 template <class _Integer>
   4984   constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
   4985   to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
   4986 
   4987 }
   4988 #endif
   4989 
   4990 #endif  // _LIBCPP_TYPE_TRAITS
   4991