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