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