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