2 //===------------------------ type_traits ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_TYPE_TRAITS
12 #define _LIBCPP_TYPE_TRAITS
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
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
31 template <bool, class T = void> struct enable_if;
32 template <bool, class T, class F> struct conditional;
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;
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;
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;
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;
74 // Pointer transformations:
75 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;
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;
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;
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
101 template <class T, class... Args> struct is_constructible;
102 template <class T> struct is_default_constructible;
103 template <class T> struct is_copy_constructible;
104 template <class T> struct is_move_constructible;
105 template <class T, class U> struct is_assignable;
106 template <class T> struct is_copy_assignable;
107 template <class T> struct is_move_assignable;
108 template <class T> struct is_destructible;
110 template <class T, class... Args> struct is_trivially_constructible;
111 template <class T> struct is_trivially_default_constructible;
112 template <class T> struct is_trivially_copy_constructible;
113 template <class T> struct is_trivially_move_constructible;
114 template <class T, class U> struct is_trivially_assignable;
115 template <class T> struct is_trivially_copy_assignable;
116 template <class T> struct is_trivially_move_assignable;
117 template <class T> struct is_trivially_destructible;
119 template <class T, class... Args> struct is_nothrow_constructible;
120 template <class T> struct is_nothrow_default_constructible;
121 template <class T> struct is_nothrow_copy_constructible;
122 template <class T> struct is_nothrow_move_constructible;
123 template <class T, class U> struct is_nothrow_assignable;
124 template <class T> struct is_nothrow_copy_assignable;
125 template <class T> struct is_nothrow_move_assignable;
126 template <class T> struct is_nothrow_destructible;
128 template <class T> struct has_virtual_destructor;
130 // Relationships between types:
131 template <class T, class U> struct is_same;
132 template <class Base, class Derived> struct is_base_of;
133 template <class From, class To> struct is_convertible;
135 // Alignment properties and transformations:
136 template <class T> struct alignment_of;
137 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
138 struct aligned_storage;
139 template <size_t Len, class... Types> struct aligned_union;
141 template <class T> struct decay;
142 template <class... T> struct common_type;
143 template <class T> struct underlying_type;
144 template <class> class result_of; // undefined
145 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
147 // const-volatile modifications:
149 using remove_const_t = typename remove_const<T>::type; // C++14
151 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
153 using remove_cv_t = typename remove_cv<T>::type; // C++14
155 using add_const_t = typename add_const<T>::type; // C++14
157 using add_volatile_t = typename add_volatile<T>::type; // C++14
159 using add_cv_t = typename add_cv<T>::type; // C++14
161 // reference modifications:
163 using remove_reference_t = typename remove_reference<T>::type; // C++14
165 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
167 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
169 // sign modifications:
171 using make_signed_t = typename make_signed<T>::type; // C++14
173 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
175 // array modifications:
177 using remove_extent_t = typename remove_extent<T>::type; // C++14
179 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
181 // pointer modifications:
183 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
185 using add_pointer_t = typename add_pointer<T>::type; // C++14
187 // other transformations:
188 template <size_t Len, std::size_t Align=default-alignment>
189 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
190 template <std::size_t Len, class... Types>
191 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
193 using decay_t = typename decay<T>::type; // C++14
194 template <bool b, class T=void>
195 using enable_if_t = typename enable_if<b,T>::type; // C++14
196 template <bool b, class T, class F>
197 using conditional_t = typename conditional<b,T,F>::type; // C++14
198 template <class... T>
199 using common_type_t = typename common_type<T...>::type; // C++14
201 using underlying_type_t = typename underlying_type<T>::type; // C++14
202 template <class F, class... ArgTypes>
203 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
213 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
214 #pragma GCC system_header
217 _LIBCPP_BEGIN_NAMESPACE_STD
220 struct __void_t { typedef void type; };
223 struct __identity { typedef _Tp type; };
225 template <class _Tp, bool>
226 struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
228 template <bool _Bp, class _If, class _Then>
229 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
230 template <class _If, class _Then>
231 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
233 #if _LIBCPP_STD_VER > 11
234 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
237 template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
238 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
240 template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
241 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
243 #if _LIBCPP_STD_VER > 11
244 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
248 struct __two {char __lx[2];};
252 template <class _Tp, _Tp __v>
253 struct _LIBCPP_TYPE_VIS_ONLY integral_constant
255 static _LIBCPP_CONSTEXPR const _Tp value = __v;
256 typedef _Tp value_type;
257 typedef integral_constant type;
258 _LIBCPP_INLINE_VISIBILITY
259 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
260 #if _LIBCPP_STD_VER > 11
261 _LIBCPP_INLINE_VISIBILITY
262 constexpr value_type operator ()() const _NOEXCEPT {return value;}
266 template <class _Tp, _Tp __v>
267 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
269 #if _LIBCPP_STD_VER > 14
271 using bool_constant = integral_constant<bool, __b>;
272 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
274 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
277 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
278 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
282 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
283 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
287 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
288 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
292 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
293 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
294 #if _LIBCPP_STD_VER > 11
295 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
300 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
301 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
302 #if _LIBCPP_STD_VER > 11
303 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
308 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
309 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
310 #if _LIBCPP_STD_VER > 11
311 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
316 template <class _Tp> struct __libcpp_is_void : public false_type {};
317 template <> struct __libcpp_is_void<void> : public true_type {};
319 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
320 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
324 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
325 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
327 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
328 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
330 #if _LIBCPP_STD_VER > 11
331 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
332 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
337 template <class _Tp> struct __libcpp_is_integral : public false_type {};
338 template <> struct __libcpp_is_integral<bool> : public true_type {};
339 template <> struct __libcpp_is_integral<char> : public true_type {};
340 template <> struct __libcpp_is_integral<signed char> : public true_type {};
341 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
342 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
343 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
344 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
345 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
346 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
347 template <> struct __libcpp_is_integral<short> : public true_type {};
348 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
349 template <> struct __libcpp_is_integral<int> : public true_type {};
350 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
351 template <> struct __libcpp_is_integral<long> : public true_type {};
352 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
353 template <> struct __libcpp_is_integral<long long> : public true_type {};
354 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
355 #ifndef _LIBCPP_HAS_NO_INT128
356 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
357 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
360 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
361 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
365 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
366 template <> struct __libcpp_is_floating_point<float> : public true_type {};
367 template <> struct __libcpp_is_floating_point<double> : public true_type {};
368 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
370 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
371 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
375 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
376 : public false_type {};
377 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
378 : public true_type {};
379 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
380 : public true_type {};
384 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
385 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
387 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
388 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
392 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
393 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
395 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
396 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
397 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
400 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
401 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
402 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
403 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
408 #if __has_feature(is_union) || (_GNUC_VER >= 403)
410 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
411 : public integral_constant<bool, __is_union(_Tp)> {};
415 template <class _Tp> struct __libcpp_union : public false_type {};
416 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
417 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
423 #if __has_feature(is_class) || (_GNUC_VER >= 403)
425 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
426 : public integral_constant<bool, __is_class(_Tp)> {};
430 namespace __is_class_imp
432 template <class _Tp> char __test(int _Tp::*);
433 template <class _Tp> __two __test(...);
436 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
437 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
443 template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
444 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
448 namespace __libcpp_is_function_imp
450 struct __dummy_type {};
451 template <class _Tp> char __test(_Tp*);
452 template <class _Tp> char __test(__dummy_type);
453 template <class _Tp> __two __test(...);
454 template <class _Tp> _Tp& __source(int);
455 template <class _Tp> __dummy_type __source(...);
458 template <class _Tp, bool = is_class<_Tp>::value ||
459 is_union<_Tp>::value ||
460 is_void<_Tp>::value ||
461 is_reference<_Tp>::value ||
462 __is_nullptr_t<_Tp>::value >
463 struct __libcpp_is_function
464 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
466 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
468 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
469 : public __libcpp_is_function<_Tp> {};
471 // is_member_function_pointer
473 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
474 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
477 template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
478 struct __member_pointer_traits_imp
479 { // forward declaration; specializations later
483 template <class _Tp> struct __libcpp_is_member_function_pointer
484 : public false_type {};
486 template <class _Ret, class _Class>
487 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
488 : public is_function<_Ret> {};
490 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
491 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
495 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
496 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
498 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
499 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
501 // is_member_object_pointer
503 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
504 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
505 !is_member_function_pointer<_Tp>::value> {};
509 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
511 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
512 : public integral_constant<bool, __is_enum(_Tp)> {};
516 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
517 : public integral_constant<bool, !is_void<_Tp>::value &&
518 !is_integral<_Tp>::value &&
519 !is_floating_point<_Tp>::value &&
520 !is_array<_Tp>::value &&
521 !is_pointer<_Tp>::value &&
522 !is_reference<_Tp>::value &&
523 !is_member_pointer<_Tp>::value &&
524 !is_union<_Tp>::value &&
525 !is_class<_Tp>::value &&
526 !is_function<_Tp>::value > {};
532 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
533 : public integral_constant<bool, is_integral<_Tp>::value ||
534 is_floating_point<_Tp>::value> {};
538 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
539 : public integral_constant<bool, is_void<_Tp>::value ||
540 __is_nullptr_t<_Tp>::value ||
541 is_arithmetic<_Tp>::value> {};
545 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
546 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
547 is_member_pointer<_Tp>::value ||
548 is_pointer<_Tp>::value ||
549 __is_nullptr_t<_Tp>::value ||
550 is_enum<_Tp>::value > {};
552 template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
556 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
557 : public integral_constant<bool, is_scalar<_Tp>::value ||
558 is_array<_Tp>::value ||
559 is_union<_Tp>::value ||
560 is_class<_Tp>::value > {};
564 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
565 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
569 template <class _Tp, bool = is_reference<_Tp>::value ||
570 is_function<_Tp>::value ||
571 is_const<_Tp>::value >
572 struct __add_const {typedef _Tp type;};
575 struct __add_const<_Tp, false> {typedef const _Tp type;};
577 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
578 {typedef typename __add_const<_Tp>::type type;};
580 #if _LIBCPP_STD_VER > 11
581 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
586 template <class _Tp, bool = is_reference<_Tp>::value ||
587 is_function<_Tp>::value ||
588 is_volatile<_Tp>::value >
589 struct __add_volatile {typedef _Tp type;};
592 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
594 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
595 {typedef typename __add_volatile<_Tp>::type type;};
597 #if _LIBCPP_STD_VER > 11
598 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
603 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
604 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
606 #if _LIBCPP_STD_VER > 11
607 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
612 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
613 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
614 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
615 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
618 #if _LIBCPP_STD_VER > 11
619 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
622 // add_lvalue_reference
624 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;};
625 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
626 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;};
627 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;};
628 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;};
629 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
631 #if _LIBCPP_STD_VER > 11
632 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
635 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
637 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;};
638 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;};
639 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;};
640 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;};
641 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
643 #if _LIBCPP_STD_VER > 11
644 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
647 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
649 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
652 typename add_rvalue_reference<_Tp>::type
655 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
658 typename add_lvalue_reference<_Tp>::type
661 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
670 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
671 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
672 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
673 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
674 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
676 #if _LIBCPP_STD_VER > 11
677 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
682 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
683 {typedef typename remove_reference<_Tp>::type* type;};
685 #if _LIBCPP_STD_VER > 11
686 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
691 template <class _Tp, bool = is_integral<_Tp>::value>
692 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
695 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
697 template <class _Tp, bool = is_arithmetic<_Tp>::value>
698 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
700 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
702 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
706 template <class _Tp, bool = is_integral<_Tp>::value>
707 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
710 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
712 template <class _Tp, bool = is_arithmetic<_Tp>::value>
713 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
715 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
717 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
721 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
722 : public integral_constant<size_t, 0> {};
723 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
724 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
725 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
726 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
730 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
731 : public integral_constant<size_t, 0> {};
732 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
733 : public integral_constant<size_t, 0> {};
734 template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
735 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
736 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
737 : public integral_constant<size_t, _Np> {};
738 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
739 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
743 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
745 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
747 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
750 #if _LIBCPP_STD_VER > 11
751 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
754 // remove_all_extents
756 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
758 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
759 {typedef typename remove_all_extents<_Tp>::type type;};
760 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
761 {typedef typename remove_all_extents<_Tp>::type type;};
763 #if _LIBCPP_STD_VER > 11
764 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
770 struct _LIBCPP_TYPE_VIS_ONLY decay
773 typedef typename remove_reference<_Tp>::type _Up;
775 typedef typename conditional
777 is_array<_Up>::value,
778 typename remove_extent<_Up>::type*,
781 is_function<_Up>::value,
782 typename add_pointer<_Up>::type,
783 typename remove_cv<_Up>::type
788 #if _LIBCPP_STD_VER > 11
789 template <class _Tp> using decay_t = typename decay<_Tp>::type;
794 namespace __is_abstract_imp
796 template <class _Tp> char __test(_Tp (*)[1]);
797 template <class _Tp> __two __test(...);
800 template <class _Tp, bool = is_class<_Tp>::value>
801 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
803 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
805 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
809 #if defined(_LIBCPP_HAS_IS_FINAL)
810 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
811 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
813 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
814 __libcpp_is_final : public false_type {};
817 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
818 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
819 is_final : public integral_constant<bool, __is_final(_Tp)> {};
824 #ifdef _LIBCPP_HAS_IS_BASE_OF
826 template <class _Bp, class _Dp>
827 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
828 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
830 #else // _LIBCPP_HAS_IS_BASE_OF
832 namespace __is_base_of_imp
837 _Dst(const volatile _Tp &);
842 operator const volatile _Tp &();
843 template <class _Up> operator const _Dst<_Up> &();
845 template <size_t> struct __one { typedef char type; };
846 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
847 template <class _Bp, class _Dp> __two __test(...);
850 template <class _Bp, class _Dp>
851 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
852 : public integral_constant<bool, is_class<_Bp>::value &&
853 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
855 #endif // _LIBCPP_HAS_IS_BASE_OF
859 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
861 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
862 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
863 !is_abstract<_T2>::value> {};
865 #else // __has_feature(is_convertible_to)
867 namespace __is_convertible_imp
869 template <class _Tp> void __test_convert(_Tp);
871 template <class _From, class _To, class = void>
872 struct __is_convertible_test : public false_type {};
874 template <class _From, class _To>
875 struct __is_convertible_test<_From, _To,
876 decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
879 template <class _Tp> __two __test(...);
880 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
881 template <class _Tp> _Tp&& __source();
883 template <class _Tp> typename remove_reference<_Tp>::type& __source();
886 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
887 bool _IsFunction = is_function<_Tp>::value,
888 bool _IsVoid = is_void<_Tp>::value>
889 struct __is_array_function_or_void {enum {value = 0};};
890 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
891 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
892 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
896 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
897 struct __is_convertible_check
899 static const size_t __v = 0;
903 struct __is_convertible_check<_Tp, 0>
905 static const size_t __v = sizeof(_Tp);
908 template <class _T1, class _T2,
909 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
910 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
911 struct __is_convertible
912 : public integral_constant<bool,
913 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
914 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
915 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
916 && (!is_const<typename remove_reference<_T2>::type>::value
917 || is_volatile<typename remove_reference<_T2>::type>::value)
918 && (is_same<typename remove_cv<_T1>::type,
919 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
920 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
925 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
927 template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
928 template <class _T1> struct __is_convertible<const _T1, const _T1&, 1, 0> : true_type {};
929 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
930 template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
931 template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
932 template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
933 template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
934 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
936 template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
937 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
939 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
940 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
942 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
943 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
945 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
946 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
948 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
949 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
950 template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
952 template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
953 template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
954 template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
955 template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
956 template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
958 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
960 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
961 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
962 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
963 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
965 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
966 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
967 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
968 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
970 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
971 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
972 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
973 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
975 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
976 : public __is_convertible<_T1, _T2>
978 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
979 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
982 #endif // __has_feature(is_convertible_to)
986 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
989 struct _LIBCPP_TYPE_VIS_ONLY is_empty
990 : public integral_constant<bool, __is_empty(_Tp)> {};
992 #else // __has_feature(is_empty)
1006 template <class _Tp, bool = is_class<_Tp>::value>
1007 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1009 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1011 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
1013 #endif // __has_feature(is_empty)
1017 #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
1019 template <class _Tp>
1020 struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1021 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1025 template<typename _Tp> char &__is_polymorphic_impl(
1026 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1028 template<typename _Tp> __two &__is_polymorphic_impl(...);
1030 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1031 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1033 #endif // __has_feature(is_polymorphic)
1035 // has_virtual_destructor
1037 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1039 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1040 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1044 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1045 : public false_type {};
1051 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
1052 : public integral_constant<size_t, __alignof__(_Tp)> {};
1056 template <class _Hp, class _Tp>
1065 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1067 __nat(const __nat&) = delete;
1068 __nat& operator=(const __nat&) = delete;
1073 template <class _Tp>
1076 static const size_t value = alignment_of<_Tp>::value;
1080 struct __struct_double {long double __lx;};
1081 struct __struct_double4 {double __lx[4];};
1084 __type_list<__align_type<unsigned char>,
1085 __type_list<__align_type<unsigned short>,
1086 __type_list<__align_type<unsigned int>,
1087 __type_list<__align_type<unsigned long>,
1088 __type_list<__align_type<unsigned long long>,
1089 __type_list<__align_type<double>,
1090 __type_list<__align_type<long double>,
1091 __type_list<__align_type<__struct_double>,
1092 __type_list<__align_type<__struct_double4>,
1093 __type_list<__align_type<int*>,
1095 > > > > > > > > > > __all_types;
1097 template <class _TL, size_t _Align> struct __find_pod;
1099 template <class _Hp, size_t _Align>
1100 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1102 typedef typename conditional<
1103 _Align == _Hp::value,
1109 template <class _Hp, class _Tp, size_t _Align>
1110 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1112 typedef typename conditional<
1113 _Align == _Hp::value,
1115 typename __find_pod<_Tp, _Align>::type
1119 template <class _TL, size_t _Len> struct __find_max_align;
1121 template <class _Hp, size_t _Len>
1122 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1124 template <size_t _Len, size_t _A1, size_t _A2>
1125 struct __select_align
1128 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1129 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1131 static const size_t value = _Len < __max ? __min : __max;
1134 template <class _Hp, class _Tp, size_t _Len>
1135 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1136 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1138 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1139 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
1141 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1142 static_assert(!is_void<_Aligner>::value, "");
1146 unsigned char __data[_Len];
1150 #if _LIBCPP_STD_VER > 11
1151 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1152 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1155 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1156 template <size_t _Len>\
1157 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
1159 struct _ALIGNAS(n) type\
1161 unsigned char __lx[_Len];\
1165 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1166 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1167 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1168 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1169 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1170 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1171 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1172 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1173 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1174 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1175 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1176 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1177 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1178 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1179 // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1180 #if !defined(_LIBCPP_MSVC)
1181 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1182 #endif // !_LIBCPP_MSVC
1184 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1186 #ifndef _LIBCPP_HAS_NO_VARIADICS
1190 template <size_t _I0, size_t ..._In>
1191 struct __static_max;
1193 template <size_t _I0>
1194 struct __static_max<_I0>
1196 static const size_t value = _I0;
1199 template <size_t _I0, size_t _I1, size_t ..._In>
1200 struct __static_max<_I0, _I1, _In...>
1202 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1203 __static_max<_I1, _In...>::value;
1206 template <size_t _Len, class _Type0, class ..._Types>
1207 struct aligned_union
1209 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1210 __alignof__(_Types)...>::value;
1211 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1212 sizeof(_Types)...>::value;
1213 typedef typename aligned_storage<__len, alignment_value>::type type;
1216 #if _LIBCPP_STD_VER > 11
1217 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1220 #endif // _LIBCPP_HAS_NO_VARIADICS
1222 template <class _Tp>
1223 struct __numeric_type
1225 static void __test(...);
1226 static float __test(float);
1227 static double __test(char);
1228 static double __test(int);
1229 static double __test(unsigned);
1230 static double __test(long);
1231 static double __test(unsigned long);
1232 static double __test(long long);
1233 static double __test(unsigned long long);
1234 static double __test(double);
1235 static long double __test(long double);
1237 typedef decltype(__test(declval<_Tp>())) type;
1238 static const bool value = !is_same<type, void>::value;
1242 struct __numeric_type<void>
1244 static const bool value = true;
1249 template <class _A1, class _A2 = void, class _A3 = void,
1250 bool = __numeric_type<_A1>::value &&
1251 __numeric_type<_A2>::value &&
1252 __numeric_type<_A3>::value>
1256 static const bool value = false;
1259 template <class _A1, class _A2, class _A3>
1260 class __promote_imp<_A1, _A2, _A3, true>
1263 typedef typename __promote_imp<_A1>::type __type1;
1264 typedef typename __promote_imp<_A2>::type __type2;
1265 typedef typename __promote_imp<_A3>::type __type3;
1267 typedef decltype(__type1() + __type2() + __type3()) type;
1268 static const bool value = true;
1271 template <class _A1, class _A2>
1272 class __promote_imp<_A1, _A2, void, true>
1275 typedef typename __promote_imp<_A1>::type __type1;
1276 typedef typename __promote_imp<_A2>::type __type2;
1278 typedef decltype(__type1() + __type2()) type;
1279 static const bool value = true;
1282 template <class _A1>
1283 class __promote_imp<_A1, void, void, true>
1286 typedef typename __numeric_type<_A1>::type type;
1287 static const bool value = true;
1290 template <class _A1, class _A2 = void, class _A3 = void>
1291 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1293 #ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1297 template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1298 template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;};
1299 template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;};
1300 template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;};
1301 template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1303 #endif // _LIBCPP_STORE_AS_OPTIMIZATION
1305 // make_signed / make_unsigned
1308 __type_list<signed char,
1309 __type_list<signed short,
1310 __type_list<signed int,
1311 __type_list<signed long,
1312 __type_list<signed long long,
1313 #ifndef _LIBCPP_HAS_NO_INT128
1314 __type_list<__int128_t,
1317 #ifndef _LIBCPP_HAS_NO_INT128
1320 > > > > > __signed_types;
1323 __type_list<unsigned char,
1324 __type_list<unsigned short,
1325 __type_list<unsigned int,
1326 __type_list<unsigned long,
1327 __type_list<unsigned long long,
1328 #ifndef _LIBCPP_HAS_NO_INT128
1329 __type_list<__uint128_t,
1332 #ifndef _LIBCPP_HAS_NO_INT128
1335 > > > > > __unsigned_types;
1337 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1339 template <class _Hp, class _Tp, size_t _Size>
1340 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1345 template <class _Hp, class _Tp, size_t _Size>
1346 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1348 typedef typename __find_first<_Tp, _Size>::type type;
1351 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1352 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1358 template <class _Tp, class _Up>
1359 struct __apply_cv<_Tp, _Up, true, false>
1361 typedef const _Up type;
1364 template <class _Tp, class _Up>
1365 struct __apply_cv<_Tp, _Up, false, true>
1367 typedef volatile _Up type;
1370 template <class _Tp, class _Up>
1371 struct __apply_cv<_Tp, _Up, true, true>
1373 typedef const volatile _Up type;
1376 template <class _Tp, class _Up>
1377 struct __apply_cv<_Tp&, _Up, false, false>
1382 template <class _Tp, class _Up>
1383 struct __apply_cv<_Tp&, _Up, true, false>
1385 typedef const _Up& type;
1388 template <class _Tp, class _Up>
1389 struct __apply_cv<_Tp&, _Up, false, true>
1391 typedef volatile _Up& type;
1394 template <class _Tp, class _Up>
1395 struct __apply_cv<_Tp&, _Up, true, true>
1397 typedef const volatile _Up& type;
1400 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1401 struct __make_signed {};
1403 template <class _Tp>
1404 struct __make_signed<_Tp, true>
1406 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1409 template <> struct __make_signed<bool, true> {};
1410 template <> struct __make_signed< signed short, true> {typedef short type;};
1411 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1412 template <> struct __make_signed< signed int, true> {typedef int type;};
1413 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1414 template <> struct __make_signed< signed long, true> {typedef long type;};
1415 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1416 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1417 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1418 #ifndef _LIBCPP_HAS_NO_INT128
1419 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1420 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1423 template <class _Tp>
1424 struct _LIBCPP_TYPE_VIS_ONLY make_signed
1426 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1429 #if _LIBCPP_STD_VER > 11
1430 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1433 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1434 struct __make_unsigned {};
1436 template <class _Tp>
1437 struct __make_unsigned<_Tp, true>
1439 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1442 template <> struct __make_unsigned<bool, true> {};
1443 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1444 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1445 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1446 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1447 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1448 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1449 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1450 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1451 #ifndef _LIBCPP_HAS_NO_INT128
1452 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1453 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1456 template <class _Tp>
1457 struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
1459 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1462 #if _LIBCPP_STD_VER > 11
1463 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1466 #ifdef _LIBCPP_HAS_NO_VARIADICS
1468 template <class _Tp, class _Up = void, class _Vp = void>
1469 struct _LIBCPP_TYPE_VIS_ONLY common_type
1472 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
1475 template <class _Tp>
1476 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
1479 typedef typename decay<_Tp>::type type;
1482 template <class _Tp, class _Up>
1483 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
1486 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1489 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1492 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1494 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1497 #else // _LIBCPP_HAS_NO_VARIADICS
1499 template <class ..._Tp> struct common_type;
1501 template <class _Tp>
1502 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
1504 typedef typename decay<_Tp>::type type;
1507 template <class _Tp, class _Up>
1508 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
1515 typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
1518 template <class _Tp, class _Up, class ..._Vp>
1519 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
1521 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1524 #if _LIBCPP_STD_VER > 11
1525 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1528 #endif // _LIBCPP_HAS_NO_VARIADICS
1532 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
1534 template <class _Tp, class _Arg>
1535 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
1536 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1537 __is_assignable_test(_Tp&&, _Arg&&);
1539 __is_assignable_test(_Tp, _Arg&);
1542 template <class _Arg>
1544 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1545 __is_assignable_test(__any, _Arg&&);
1547 __is_assignable_test(__any, _Arg&);
1550 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1551 struct __is_assignable_imp
1552 : public common_type
1554 decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1557 template <class _Tp, class _Arg>
1558 struct __is_assignable_imp<_Tp, _Arg, true>
1563 template <class _Tp, class _Arg>
1564 struct is_assignable
1565 : public __is_assignable_imp<_Tp, _Arg> {};
1567 // is_copy_assignable
1569 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
1570 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1571 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
1573 // is_move_assignable
1575 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
1576 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1577 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1578 const typename add_rvalue_reference<_Tp>::type> {};
1580 : public is_copy_assignable<_Tp> {};
1585 // if it's a reference, return true
1586 // if it's a function, return false
1587 // if it's void, return false
1588 // if it's an array of unknown bound, return false
1589 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
1590 // where _Up is remove_all_extents<_Tp>::type
1593 struct __is_destructible_apply { typedef int type; };
1595 template <typename _Tp>
1596 struct __is_destructor_wellformed {
1597 template <typename _Tp1>
1598 static char __test (
1599 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
1602 template <typename _Tp1>
1603 static __two __test (...);
1605 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
1608 template <class _Tp, bool>
1609 struct __destructible_imp;
1611 template <class _Tp>
1612 struct __destructible_imp<_Tp, false>
1613 : public _VSTD::integral_constant<bool,
1614 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
1616 template <class _Tp>
1617 struct __destructible_imp<_Tp, true>
1618 : public _VSTD::true_type {};
1620 template <class _Tp, bool>
1621 struct __destructible_false;
1623 template <class _Tp>
1624 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
1626 template <class _Tp>
1627 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
1629 template <class _Tp>
1630 struct is_destructible
1631 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
1633 template <class _Tp>
1634 struct is_destructible<_Tp[]>
1635 : public _VSTD::false_type {};
1638 struct is_destructible<void>
1639 : public _VSTD::false_type {};
1643 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1645 template <class _Tp>
1646 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1647 typename remove_reference<_Tp>::type&&
1648 move(_Tp&& __t) _NOEXCEPT
1650 typedef typename remove_reference<_Tp>::type _Up;
1651 return static_cast<_Up&&>(__t);
1654 template <class _Tp>
1655 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1657 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1659 return static_cast<_Tp&&>(__t);
1662 template <class _Tp>
1663 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1665 forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1667 static_assert(!std::is_lvalue_reference<_Tp>::value,
1668 "Can not forward an rvalue as an lvalue.");
1669 return static_cast<_Tp&&>(__t);
1672 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1674 template <class _Tp>
1675 inline _LIBCPP_INLINE_VISIBILITY
1682 template <class _Tp>
1683 inline _LIBCPP_INLINE_VISIBILITY
1685 move(const _Tp& __t)
1690 template <class _Tp>
1691 inline _LIBCPP_INLINE_VISIBILITY
1693 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1699 template <class _Tp>
1702 typedef typename remove_reference<_Tp>::type _Trr;
1705 _LIBCPP_INLINE_VISIBILITY
1706 _Trr* operator->() {return &t_;}
1707 _LIBCPP_INLINE_VISIBILITY
1708 explicit __rv(_Trr& __t) : t_(__t) {}
1711 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1713 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1715 template <class _Tp>
1716 inline _LIBCPP_INLINE_VISIBILITY
1717 typename decay<_Tp>::type
1718 __decay_copy(_Tp&& __t)
1720 return _VSTD::forward<_Tp>(__t);
1725 template <class _Tp>
1726 inline _LIBCPP_INLINE_VISIBILITY
1727 typename decay<_Tp>::type
1728 __decay_copy(const _Tp& __t)
1730 return _VSTD::forward<_Tp>(__t);
1735 #ifndef _LIBCPP_HAS_NO_VARIADICS
1737 template <class _Rp, class _Class, class ..._Param>
1738 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1740 typedef _Class _ClassType;
1741 typedef _Rp _ReturnType;
1742 typedef _Rp (_FnType) (_Param...);
1745 template <class _Rp, class _Class, class ..._Param>
1746 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
1748 typedef _Class _ClassType;
1749 typedef _Rp _ReturnType;
1750 typedef _Rp (_FnType) (_Param..., ...);
1753 template <class _Rp, class _Class, class ..._Param>
1754 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1756 typedef _Class const _ClassType;
1757 typedef _Rp _ReturnType;
1758 typedef _Rp (_FnType) (_Param...);
1761 template <class _Rp, class _Class, class ..._Param>
1762 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
1764 typedef _Class const _ClassType;
1765 typedef _Rp _ReturnType;
1766 typedef _Rp (_FnType) (_Param..., ...);
1769 template <class _Rp, class _Class, class ..._Param>
1770 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1772 typedef _Class volatile _ClassType;
1773 typedef _Rp _ReturnType;
1774 typedef _Rp (_FnType) (_Param...);
1777 template <class _Rp, class _Class, class ..._Param>
1778 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
1780 typedef _Class volatile _ClassType;
1781 typedef _Rp _ReturnType;
1782 typedef _Rp (_FnType) (_Param..., ...);
1785 template <class _Rp, class _Class, class ..._Param>
1786 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1788 typedef _Class const volatile _ClassType;
1789 typedef _Rp _ReturnType;
1790 typedef _Rp (_FnType) (_Param...);
1793 template <class _Rp, class _Class, class ..._Param>
1794 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
1796 typedef _Class const volatile _ClassType;
1797 typedef _Rp _ReturnType;
1798 typedef _Rp (_FnType) (_Param..., ...);
1801 #if __has_feature(cxx_reference_qualified_functions) || \
1802 (defined(_GNUC_VER) && _GNUC_VER >= 409)
1804 template <class _Rp, class _Class, class ..._Param>
1805 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1807 typedef _Class& _ClassType;
1808 typedef _Rp _ReturnType;
1809 typedef _Rp (_FnType) (_Param...);
1812 template <class _Rp, class _Class, class ..._Param>
1813 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
1815 typedef _Class& _ClassType;
1816 typedef _Rp _ReturnType;
1817 typedef _Rp (_FnType) (_Param..., ...);
1820 template <class _Rp, class _Class, class ..._Param>
1821 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1823 typedef _Class const& _ClassType;
1824 typedef _Rp _ReturnType;
1825 typedef _Rp (_FnType) (_Param...);
1828 template <class _Rp, class _Class, class ..._Param>
1829 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
1831 typedef _Class const& _ClassType;
1832 typedef _Rp _ReturnType;
1833 typedef _Rp (_FnType) (_Param..., ...);
1836 template <class _Rp, class _Class, class ..._Param>
1837 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1839 typedef _Class volatile& _ClassType;
1840 typedef _Rp _ReturnType;
1841 typedef _Rp (_FnType) (_Param...);
1844 template <class _Rp, class _Class, class ..._Param>
1845 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
1847 typedef _Class volatile& _ClassType;
1848 typedef _Rp _ReturnType;
1849 typedef _Rp (_FnType) (_Param..., ...);
1852 template <class _Rp, class _Class, class ..._Param>
1853 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1855 typedef _Class const volatile& _ClassType;
1856 typedef _Rp _ReturnType;
1857 typedef _Rp (_FnType) (_Param...);
1860 template <class _Rp, class _Class, class ..._Param>
1861 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
1863 typedef _Class const volatile& _ClassType;
1864 typedef _Rp _ReturnType;
1865 typedef _Rp (_FnType) (_Param..., ...);
1868 template <class _Rp, class _Class, class ..._Param>
1869 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1871 typedef _Class&& _ClassType;
1872 typedef _Rp _ReturnType;
1873 typedef _Rp (_FnType) (_Param...);
1876 template <class _Rp, class _Class, class ..._Param>
1877 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
1879 typedef _Class&& _ClassType;
1880 typedef _Rp _ReturnType;
1881 typedef _Rp (_FnType) (_Param..., ...);
1884 template <class _Rp, class _Class, class ..._Param>
1885 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1887 typedef _Class const&& _ClassType;
1888 typedef _Rp _ReturnType;
1889 typedef _Rp (_FnType) (_Param...);
1892 template <class _Rp, class _Class, class ..._Param>
1893 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
1895 typedef _Class const&& _ClassType;
1896 typedef _Rp _ReturnType;
1897 typedef _Rp (_FnType) (_Param..., ...);
1900 template <class _Rp, class _Class, class ..._Param>
1901 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1903 typedef _Class volatile&& _ClassType;
1904 typedef _Rp _ReturnType;
1905 typedef _Rp (_FnType) (_Param...);
1908 template <class _Rp, class _Class, class ..._Param>
1909 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
1911 typedef _Class volatile&& _ClassType;
1912 typedef _Rp _ReturnType;
1913 typedef _Rp (_FnType) (_Param..., ...);
1916 template <class _Rp, class _Class, class ..._Param>
1917 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1919 typedef _Class const volatile&& _ClassType;
1920 typedef _Rp _ReturnType;
1921 typedef _Rp (_FnType) (_Param...);
1924 template <class _Rp, class _Class, class ..._Param>
1925 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
1927 typedef _Class const volatile&& _ClassType;
1928 typedef _Rp _ReturnType;
1929 typedef _Rp (_FnType) (_Param..., ...);
1932 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
1934 #else // _LIBCPP_HAS_NO_VARIADICS
1936 template <class _Rp, class _Class>
1937 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1939 typedef _Class _ClassType;
1940 typedef _Rp _ReturnType;
1941 typedef _Rp (_FnType) ();
1944 template <class _Rp, class _Class>
1945 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
1947 typedef _Class _ClassType;
1948 typedef _Rp _ReturnType;
1949 typedef _Rp (_FnType) (...);
1952 template <class _Rp, class _Class, class _P0>
1953 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1955 typedef _Class _ClassType;
1956 typedef _Rp _ReturnType;
1957 typedef _Rp (_FnType) (_P0);
1960 template <class _Rp, class _Class, class _P0>
1961 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
1963 typedef _Class _ClassType;
1964 typedef _Rp _ReturnType;
1965 typedef _Rp (_FnType) (_P0, ...);
1968 template <class _Rp, class _Class, class _P0, class _P1>
1969 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1971 typedef _Class _ClassType;
1972 typedef _Rp _ReturnType;
1973 typedef _Rp (_FnType) (_P0, _P1);
1976 template <class _Rp, class _Class, class _P0, class _P1>
1977 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
1979 typedef _Class _ClassType;
1980 typedef _Rp _ReturnType;
1981 typedef _Rp (_FnType) (_P0, _P1, ...);
1984 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1985 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1987 typedef _Class _ClassType;
1988 typedef _Rp _ReturnType;
1989 typedef _Rp (_FnType) (_P0, _P1, _P2);
1992 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1993 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
1995 typedef _Class _ClassType;
1996 typedef _Rp _ReturnType;
1997 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2000 template <class _Rp, class _Class>
2001 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2003 typedef _Class const _ClassType;
2004 typedef _Rp _ReturnType;
2005 typedef _Rp (_FnType) ();
2008 template <class _Rp, class _Class>
2009 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2011 typedef _Class const _ClassType;
2012 typedef _Rp _ReturnType;
2013 typedef _Rp (_FnType) (...);
2016 template <class _Rp, class _Class, class _P0>
2017 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2019 typedef _Class const _ClassType;
2020 typedef _Rp _ReturnType;
2021 typedef _Rp (_FnType) (_P0);
2024 template <class _Rp, class _Class, class _P0>
2025 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2027 typedef _Class const _ClassType;
2028 typedef _Rp _ReturnType;
2029 typedef _Rp (_FnType) (_P0, ...);
2032 template <class _Rp, class _Class, class _P0, class _P1>
2033 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2035 typedef _Class const _ClassType;
2036 typedef _Rp _ReturnType;
2037 typedef _Rp (_FnType) (_P0, _P1);
2040 template <class _Rp, class _Class, class _P0, class _P1>
2041 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2043 typedef _Class const _ClassType;
2044 typedef _Rp _ReturnType;
2045 typedef _Rp (_FnType) (_P0, _P1, ...);
2048 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2049 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2051 typedef _Class const _ClassType;
2052 typedef _Rp _ReturnType;
2053 typedef _Rp (_FnType) (_P0, _P1, _P2);
2056 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2057 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2059 typedef _Class const _ClassType;
2060 typedef _Rp _ReturnType;
2061 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2064 template <class _Rp, class _Class>
2065 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2067 typedef _Class volatile _ClassType;
2068 typedef _Rp _ReturnType;
2069 typedef _Rp (_FnType) ();
2072 template <class _Rp, class _Class>
2073 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2075 typedef _Class volatile _ClassType;
2076 typedef _Rp _ReturnType;
2077 typedef _Rp (_FnType) (...);
2080 template <class _Rp, class _Class, class _P0>
2081 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2083 typedef _Class volatile _ClassType;
2084 typedef _Rp _ReturnType;
2085 typedef _Rp (_FnType) (_P0);
2088 template <class _Rp, class _Class, class _P0>
2089 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2091 typedef _Class volatile _ClassType;
2092 typedef _Rp _ReturnType;
2093 typedef _Rp (_FnType) (_P0, ...);
2096 template <class _Rp, class _Class, class _P0, class _P1>
2097 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2099 typedef _Class volatile _ClassType;
2100 typedef _Rp _ReturnType;
2101 typedef _Rp (_FnType) (_P0, _P1);
2104 template <class _Rp, class _Class, class _P0, class _P1>
2105 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2107 typedef _Class volatile _ClassType;
2108 typedef _Rp _ReturnType;
2109 typedef _Rp (_FnType) (_P0, _P1, ...);
2112 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2113 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2115 typedef _Class volatile _ClassType;
2116 typedef _Rp _ReturnType;
2117 typedef _Rp (_FnType) (_P0, _P1, _P2);
2120 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2121 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2123 typedef _Class volatile _ClassType;
2124 typedef _Rp _ReturnType;
2125 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2128 template <class _Rp, class _Class>
2129 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2131 typedef _Class const volatile _ClassType;
2132 typedef _Rp _ReturnType;
2133 typedef _Rp (_FnType) ();
2136 template <class _Rp, class _Class>
2137 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2139 typedef _Class const volatile _ClassType;
2140 typedef _Rp _ReturnType;
2141 typedef _Rp (_FnType) (...);
2144 template <class _Rp, class _Class, class _P0>
2145 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2147 typedef _Class const volatile _ClassType;
2148 typedef _Rp _ReturnType;
2149 typedef _Rp (_FnType) (_P0);
2152 template <class _Rp, class _Class, class _P0>
2153 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2155 typedef _Class const volatile _ClassType;
2156 typedef _Rp _ReturnType;
2157 typedef _Rp (_FnType) (_P0, ...);
2160 template <class _Rp, class _Class, class _P0, class _P1>
2161 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2163 typedef _Class const volatile _ClassType;
2164 typedef _Rp _ReturnType;
2165 typedef _Rp (_FnType) (_P0, _P1);
2168 template <class _Rp, class _Class, class _P0, class _P1>
2169 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2171 typedef _Class const volatile _ClassType;
2172 typedef _Rp _ReturnType;
2173 typedef _Rp (_FnType) (_P0, _P1, ...);
2176 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2177 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2179 typedef _Class const volatile _ClassType;
2180 typedef _Rp _ReturnType;
2181 typedef _Rp (_FnType) (_P0, _P1, _P2);
2184 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2185 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2187 typedef _Class const volatile _ClassType;
2188 typedef _Rp _ReturnType;
2189 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2192 #endif // _LIBCPP_HAS_NO_VARIADICS
2194 template <class _Rp, class _Class>
2195 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2197 typedef _Class _ClassType;
2198 typedef _Rp _ReturnType;
2201 template <class _MP>
2202 struct __member_pointer_traits
2203 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2204 is_member_function_pointer<_MP>::value,
2205 is_member_object_pointer<_MP>::value>
2207 // typedef ... _ClassType;
2208 // typedef ... _ReturnType;
2209 // typedef ... _FnType;
2214 template <class _Callable> class result_of;
2216 #ifdef _LIBCPP_HAS_NO_VARIADICS
2218 template <class _Fn, bool, bool>
2223 template <class _Fn>
2224 class __result_of<_Fn(), true, false>
2227 typedef decltype(declval<_Fn>()()) type;
2230 template <class _Fn, class _A0>
2231 class __result_of<_Fn(_A0), true, false>
2234 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2237 template <class _Fn, class _A0, class _A1>
2238 class __result_of<_Fn(_A0, _A1), true, false>
2241 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2244 template <class _Fn, class _A0, class _A1, class _A2>
2245 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2248 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2251 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2252 struct __result_of_mp;
2254 // member function pointer
2256 template <class _MP, class _Tp>
2257 struct __result_of_mp<_MP, _Tp, true>
2258 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2262 // member data pointer
2264 template <class _MP, class _Tp, bool>
2265 struct __result_of_mdp;
2267 template <class _Rp, class _Class, class _Tp>
2268 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2270 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2273 template <class _Rp, class _Class, class _Tp>
2274 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2276 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2279 template <class _Rp, class _Class, class _Tp>
2280 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2281 : public __result_of_mdp<_Rp _Class::*, _Tp,
2282 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2288 template <class _Fn, class _Tp>
2289 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2290 : public __result_of_mp<typename remove_reference<_Fn>::type,
2292 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2296 template <class _Fn, class _Tp, class _A0>
2297 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2298 : public __result_of_mp<typename remove_reference<_Fn>::type,
2300 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2304 template <class _Fn, class _Tp, class _A0, class _A1>
2305 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2306 : public __result_of_mp<typename remove_reference<_Fn>::type,
2308 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2312 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2313 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2314 : public __result_of_mp<typename remove_reference<_Fn>::type,
2316 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2322 template <class _Fn>
2323 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
2324 : public __result_of<_Fn(),
2325 is_class<typename remove_reference<_Fn>::type>::value ||
2326 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2327 is_member_pointer<typename remove_reference<_Fn>::type>::value
2332 template <class _Fn, class _A0>
2333 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
2334 : public __result_of<_Fn(_A0),
2335 is_class<typename remove_reference<_Fn>::type>::value ||
2336 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2337 is_member_pointer<typename remove_reference<_Fn>::type>::value
2342 template <class _Fn, class _A0, class _A1>
2343 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
2344 : public __result_of<_Fn(_A0, _A1),
2345 is_class<typename remove_reference<_Fn>::type>::value ||
2346 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2347 is_member_pointer<typename remove_reference<_Fn>::type>::value
2352 template <class _Fn, class _A0, class _A1, class _A2>
2353 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
2354 : public __result_of<_Fn(_A0, _A1, _A2),
2355 is_class<typename remove_reference<_Fn>::type>::value ||
2356 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2357 is_member_pointer<typename remove_reference<_Fn>::type>::value
2362 #endif // _LIBCPP_HAS_NO_VARIADICS
2364 // template <class T, class... Args> struct is_constructible;
2366 namespace __is_construct
2371 #if __has_feature(is_constructible)
2373 template <class _Tp, class ..._Args>
2374 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2375 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2380 #ifndef _LIBCPP_HAS_NO_VARIADICS
2382 // main is_constructible test
2384 template <class _Tp, class ..._Args>
2385 typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
2386 __is_constructible_test(_Tp&&, _Args&& ...);
2388 template <class ..._Args>
2390 __is_constructible_test(__any, _Args&& ...);
2392 template <bool, class _Tp, class... _Args>
2393 struct __libcpp_is_constructible // false, _Tp is not a scalar
2394 : public common_type
2396 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
2400 // function types are not constructible
2402 template <class _Rp, class... _A1, class... _A2>
2403 struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
2407 // handle scalars and reference types
2409 // Scalars are default constructible, references are not
2411 template <class _Tp>
2412 struct __libcpp_is_constructible<true, _Tp>
2413 : public is_scalar<_Tp>
2416 // Scalars and references are constructible from one arg if that arg is
2417 // implicitly convertible to the scalar or reference.
2419 template <class _Tp>
2420 struct __is_constructible_ref
2422 true_type static __lxx(_Tp);
2423 false_type static __lxx(...);
2426 template <class _Tp, class _A0>
2427 struct __libcpp_is_constructible<true, _Tp, _A0>
2428 : public common_type
2430 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2434 // Scalars and references are not constructible from multiple args.
2436 template <class _Tp, class _A0, class ..._Args>
2437 struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
2441 // Treat scalars and reference types separately
2443 template <bool, class _Tp, class... _Args>
2444 struct __is_constructible_void_check
2445 : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2449 // If any of T or Args is void, is_constructible should be false
2451 template <class _Tp, class... _Args>
2452 struct __is_constructible_void_check<true, _Tp, _Args...>
2456 template <class ..._Args> struct __contains_void;
2458 template <> struct __contains_void<> : false_type {};
2460 template <class _A0, class ..._Args>
2461 struct __contains_void<_A0, _Args...>
2463 static const bool value = is_void<_A0>::value ||
2464 __contains_void<_Args...>::value;
2467 // is_constructible entry point
2469 template <class _Tp, class... _Args>
2470 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2471 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2472 || is_abstract<_Tp>::value,
2476 // Array types are default constructible if their element type
2477 // is default constructible
2479 template <class _Ap, size_t _Np>
2480 struct __libcpp_is_constructible<false, _Ap[_Np]>
2481 : public is_constructible<typename remove_all_extents<_Ap>::type>
2484 // Otherwise array types are not constructible by this syntax
2486 template <class _Ap, size_t _Np, class ..._Args>
2487 struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
2491 // Incomplete array types are not constructible
2493 template <class _Ap, class ..._Args>
2494 struct __libcpp_is_constructible<false, _Ap[], _Args...>
2498 #else // _LIBCPP_HAS_NO_VARIADICS
2500 // template <class T> struct is_constructible0;
2502 // main is_constructible0 test
2504 template <class _Tp>
2505 decltype((_Tp(), true_type()))
2506 __is_constructible0_test(_Tp&);
2509 __is_constructible0_test(__any);
2511 template <class _Tp, class _A0>
2512 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2513 __is_constructible1_test(_Tp&, _A0&);
2515 template <class _A0>
2517 __is_constructible1_test(__any, _A0&);
2519 template <class _Tp, class _A0, class _A1>
2520 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2521 __is_constructible2_test(_Tp&, _A0&, _A1&);
2523 template <class _A0, class _A1>
2525 __is_constructible2_test(__any, _A0&, _A1&);
2527 template <bool, class _Tp>
2528 struct __is_constructible0_imp // false, _Tp is not a scalar
2529 : public common_type
2531 decltype(__is_constructible0_test(declval<_Tp&>()))
2535 template <bool, class _Tp, class _A0>
2536 struct __is_constructible1_imp // false, _Tp is not a scalar
2537 : public common_type
2539 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2543 template <bool, class _Tp, class _A0, class _A1>
2544 struct __is_constructible2_imp // false, _Tp is not a scalar
2545 : public common_type
2547 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2551 // handle scalars and reference types
2553 // Scalars are default constructible, references are not
2555 template <class _Tp>
2556 struct __is_constructible0_imp<true, _Tp>
2557 : public is_scalar<_Tp>
2560 template <class _Tp, class _A0>
2561 struct __is_constructible1_imp<true, _Tp, _A0>
2562 : public is_convertible<_A0, _Tp>
2565 template <class _Tp, class _A0, class _A1>
2566 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
2570 // Treat scalars and reference types separately
2572 template <bool, class _Tp>
2573 struct __is_constructible0_void_check
2574 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2578 template <bool, class _Tp, class _A0>
2579 struct __is_constructible1_void_check
2580 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2584 template <bool, class _Tp, class _A0, class _A1>
2585 struct __is_constructible2_void_check
2586 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2590 // If any of T or Args is void, is_constructible should be false
2592 template <class _Tp>
2593 struct __is_constructible0_void_check<true, _Tp>
2597 template <class _Tp, class _A0>
2598 struct __is_constructible1_void_check<true, _Tp, _A0>
2602 template <class _Tp, class _A0, class _A1>
2603 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2607 // is_constructible entry point
2609 template <class _Tp, class _A0 = __is_construct::__nat,
2610 class _A1 = __is_construct::__nat>
2611 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2612 : public __is_constructible2_void_check<is_void<_Tp>::value
2613 || is_abstract<_Tp>::value
2614 || is_function<_Tp>::value
2615 || is_void<_A0>::value
2616 || is_void<_A1>::value,
2620 template <class _Tp>
2621 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2622 : public __is_constructible0_void_check<is_void<_Tp>::value
2623 || is_abstract<_Tp>::value
2624 || is_function<_Tp>::value,
2628 template <class _Tp, class _A0>
2629 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
2630 : public __is_constructible1_void_check<is_void<_Tp>::value
2631 || is_abstract<_Tp>::value
2632 || is_function<_Tp>::value
2633 || is_void<_A0>::value,
2637 // Array types are default constructible if their element type
2638 // is default constructible
2640 template <class _Ap, size_t _Np>
2641 struct __is_constructible0_imp<false, _Ap[_Np]>
2642 : public is_constructible<typename remove_all_extents<_Ap>::type>
2645 template <class _Ap, size_t _Np, class _A0>
2646 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
2650 template <class _Ap, size_t _Np, class _A0, class _A1>
2651 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2655 // Incomplete array types are not constructible
2657 template <class _Ap>
2658 struct __is_constructible0_imp<false, _Ap[]>
2662 template <class _Ap, class _A0>
2663 struct __is_constructible1_imp<false, _Ap[], _A0>
2667 template <class _Ap, class _A0, class _A1>
2668 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2672 #endif // _LIBCPP_HAS_NO_VARIADICS
2673 #endif // __has_feature(is_constructible)
2675 // is_default_constructible
2677 template <class _Tp>
2678 struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
2679 : public is_constructible<_Tp>
2682 // is_copy_constructible
2684 template <class _Tp>
2685 struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
2686 : public is_constructible<_Tp,
2687 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2689 // is_move_constructible
2691 template <class _Tp>
2692 struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
2693 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2694 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2696 : public is_copy_constructible<_Tp>
2700 // is_trivially_constructible
2702 #ifndef _LIBCPP_HAS_NO_VARIADICS
2704 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
2706 template <class _Tp, class... _Args>
2707 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2708 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2712 #else // !__has_feature(is_trivially_constructible)
2714 template <class _Tp, class... _Args>
2715 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2720 template <class _Tp>
2721 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
2722 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
2723 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2725 : integral_constant<bool, is_scalar<_Tp>::value>
2730 template <class _Tp>
2731 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2732 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
2734 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
2736 : integral_constant<bool, is_scalar<_Tp>::value>
2740 template <class _Tp>
2741 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
2742 : integral_constant<bool, is_scalar<_Tp>::value>
2746 template <class _Tp>
2747 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
2748 : integral_constant<bool, is_scalar<_Tp>::value>
2752 #endif // !__has_feature(is_trivially_constructible)
2754 #else // _LIBCPP_HAS_NO_VARIADICS
2756 template <class _Tp, class _A0 = __is_construct::__nat,
2757 class _A1 = __is_construct::__nat>
2758 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2763 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
2765 template <class _Tp>
2766 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2767 __is_construct::__nat>
2768 : integral_constant<bool, __is_trivially_constructible(_Tp)>
2772 template <class _Tp>
2773 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2774 __is_construct::__nat>
2775 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2779 template <class _Tp>
2780 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2781 __is_construct::__nat>
2782 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2786 template <class _Tp>
2787 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2788 __is_construct::__nat>
2789 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2793 #else // !__has_feature(is_trivially_constructible)
2795 template <class _Tp>
2796 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2797 __is_construct::__nat>
2798 : integral_constant<bool, is_scalar<_Tp>::value>
2802 template <class _Tp>
2803 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2804 __is_construct::__nat>
2805 : integral_constant<bool, is_scalar<_Tp>::value>
2809 template <class _Tp>
2810 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2811 __is_construct::__nat>
2812 : integral_constant<bool, is_scalar<_Tp>::value>
2816 template <class _Tp>
2817 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2818 __is_construct::__nat>
2819 : integral_constant<bool, is_scalar<_Tp>::value>
2823 #endif // !__has_feature(is_trivially_constructible)
2825 #endif // _LIBCPP_HAS_NO_VARIADICS
2827 // is_trivially_default_constructible
2829 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
2830 : public is_trivially_constructible<_Tp>
2833 // is_trivially_copy_constructible
2835 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
2836 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2839 // is_trivially_move_constructible
2841 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
2842 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2843 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2845 : public is_trivially_copy_constructible<_Tp>
2849 // is_trivially_assignable
2851 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
2853 template <class _Tp, class _Arg>
2854 struct is_trivially_assignable
2855 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2859 #else // !__has_feature(is_trivially_assignable)
2861 template <class _Tp, class _Arg>
2862 struct is_trivially_assignable
2863 : public false_type {};
2865 template <class _Tp>
2866 struct is_trivially_assignable<_Tp&, _Tp>
2867 : integral_constant<bool, is_scalar<_Tp>::value> {};
2869 template <class _Tp>
2870 struct is_trivially_assignable<_Tp&, _Tp&>
2871 : integral_constant<bool, is_scalar<_Tp>::value> {};
2873 template <class _Tp>
2874 struct is_trivially_assignable<_Tp&, const _Tp&>
2875 : integral_constant<bool, is_scalar<_Tp>::value> {};
2877 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2879 template <class _Tp>
2880 struct is_trivially_assignable<_Tp&, _Tp&&>
2881 : integral_constant<bool, is_scalar<_Tp>::value> {};
2883 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2885 #endif // !__has_feature(is_trivially_assignable)
2887 // is_trivially_copy_assignable
2889 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
2890 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2891 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2893 // is_trivially_move_assignable
2895 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
2896 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2897 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2898 typename add_rvalue_reference<_Tp>::type>
2900 typename add_lvalue_reference<_Tp>::type>
2904 // is_trivially_destructible
2906 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
2908 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2909 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
2913 template <class _Tp> struct __libcpp_trivial_destructor
2914 : public integral_constant<bool, is_scalar<_Tp>::value ||
2915 is_reference<_Tp>::value> {};
2917 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2918 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2922 // is_nothrow_constructible
2925 template <class _Tp, class... _Args>
2926 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2927 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
2933 #ifndef _LIBCPP_HAS_NO_VARIADICS
2935 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
2937 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
2939 template <class _Tp, class... _Args>
2940 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
2941 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2945 template <class _Tp>
2946 void __implicit_conversion_to(_Tp) noexcept { }
2948 template <class _Tp, class _Arg>
2949 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
2950 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
2954 template <class _Tp, bool _IsReference, class... _Args>
2955 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
2960 template <class _Tp, class... _Args>
2961 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2962 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
2966 template <class _Tp, size_t _Ns>
2967 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
2968 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
2972 #else // __has_feature(cxx_noexcept)
2974 template <class _Tp, class... _Args>
2975 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2980 template <class _Tp>
2981 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
2982 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
2983 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2985 : integral_constant<bool, is_scalar<_Tp>::value>
2990 template <class _Tp>
2991 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2992 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
2994 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
2996 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
2997 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2999 : integral_constant<bool, is_scalar<_Tp>::value>
3004 template <class _Tp>
3005 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
3006 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3007 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3009 : integral_constant<bool, is_scalar<_Tp>::value>
3014 template <class _Tp>
3015 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
3016 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3017 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3019 : integral_constant<bool, is_scalar<_Tp>::value>
3024 #endif // __has_feature(cxx_noexcept)
3026 #else // _LIBCPP_HAS_NO_VARIADICS
3028 template <class _Tp, class _A0 = __is_construct::__nat,
3029 class _A1 = __is_construct::__nat>
3030 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3035 template <class _Tp>
3036 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
3037 __is_construct::__nat>
3038 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3039 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3041 : integral_constant<bool, is_scalar<_Tp>::value>
3046 template <class _Tp>
3047 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
3048 __is_construct::__nat>
3049 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3050 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3052 : integral_constant<bool, is_scalar<_Tp>::value>
3057 template <class _Tp>
3058 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
3059 __is_construct::__nat>
3060 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3061 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3063 : integral_constant<bool, is_scalar<_Tp>::value>
3068 template <class _Tp>
3069 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
3070 __is_construct::__nat>
3071 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3072 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3074 : integral_constant<bool, is_scalar<_Tp>::value>
3079 #endif // _LIBCPP_HAS_NO_VARIADICS
3080 #endif // __has_feature(is_nothrow_constructible)
3082 // is_nothrow_default_constructible
3084 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
3085 : public is_nothrow_constructible<_Tp>
3088 // is_nothrow_copy_constructible
3090 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
3091 : public is_nothrow_constructible<_Tp,
3092 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3094 // is_nothrow_move_constructible
3096 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
3097 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3098 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3100 : public is_nothrow_copy_constructible<_Tp>
3104 // is_nothrow_assignable
3106 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3108 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3110 template <class _Tp, class _Arg>
3111 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3116 template <class _Tp, class _Arg>
3117 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3118 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3122 template <class _Tp, class _Arg>
3123 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3124 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3128 #else // __has_feature(cxx_noexcept)
3130 template <class _Tp, class _Arg>
3131 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3132 : public false_type {};
3134 template <class _Tp>
3135 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
3136 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3137 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3139 : integral_constant<bool, is_scalar<_Tp>::value> {};
3142 template <class _Tp>
3143 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
3144 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3145 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3147 : integral_constant<bool, is_scalar<_Tp>::value> {};
3150 template <class _Tp>
3151 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
3152 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3153 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3155 : integral_constant<bool, is_scalar<_Tp>::value> {};
3158 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3160 template <class _Tp>
3161 struct is_nothrow_assignable<_Tp&, _Tp&&>
3162 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3163 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3165 : integral_constant<bool, is_scalar<_Tp>::value> {};
3168 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3170 #endif // __has_feature(cxx_noexcept)
3172 // is_nothrow_copy_assignable
3174 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
3175 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3176 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3178 // is_nothrow_move_assignable
3180 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
3181 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3182 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3183 typename add_rvalue_reference<_Tp>::type>
3185 typename add_lvalue_reference<_Tp>::type>
3189 // is_nothrow_destructible
3191 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3193 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3195 template <class _Tp>
3196 struct __libcpp_is_nothrow_destructible<false, _Tp>
3201 template <class _Tp>
3202 struct __libcpp_is_nothrow_destructible<true, _Tp>
3203 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3207 template <class _Tp>
3208 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3209 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3213 template <class _Tp, size_t _Ns>
3214 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
3215 : public is_nothrow_destructible<_Tp>
3219 template <class _Tp>
3220 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
3225 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3227 template <class _Tp>
3228 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
3237 template <class _Tp> struct __libcpp_nothrow_destructor
3238 : public integral_constant<bool, is_scalar<_Tp>::value ||
3239 is_reference<_Tp>::value> {};
3241 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3242 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3248 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
3250 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3251 : public integral_constant<bool, __is_pod(_Tp)> {};
3255 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3256 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3257 is_trivially_copy_constructible<_Tp>::value &&
3258 is_trivially_copy_assignable<_Tp>::value &&
3259 is_trivially_destructible<_Tp>::value> {};
3265 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
3266 #ifdef _LIBCPP_IS_LITERAL
3267 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3269 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3270 is_reference<typename remove_all_extents<_Tp>::type>::value>
3274 // is_standard_layout;
3276 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
3277 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3278 : public integral_constant<bool, __is_standard_layout(_Tp)>
3280 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3284 // is_trivially_copyable;
3286 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
3287 #if __has_feature(is_trivially_copyable)
3288 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3289 #elif _GNUC_VER >= 501
3290 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3292 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3298 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
3299 #if __has_feature(is_trivial) || _GNUC_VER >= 407
3300 : public integral_constant<bool, __is_trivial(_Tp)>
3302 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3303 is_trivially_default_constructible<_Tp>::value>
3307 #ifndef _LIBCPP_HAS_NO_VARIADICS
3309 // Check for complete types
3311 template <class ..._Tp> struct __check_complete;
3314 struct __check_complete<>
3318 template <class _Hp, class _T0, class ..._Tp>
3319 struct __check_complete<_Hp, _T0, _Tp...>
3320 : private __check_complete<_Hp>,
3321 private __check_complete<_T0, _Tp...>
3325 template <class _Hp>
3326 struct __check_complete<_Hp, _Hp>
3327 : private __check_complete<_Hp>
3331 template <class _Tp>
3332 struct __check_complete<_Tp>
3334 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
3337 template <class _Tp>
3338 struct __check_complete<_Tp&>
3339 : private __check_complete<_Tp>
3343 template <class _Tp>
3344 struct __check_complete<_Tp&&>
3345 : private __check_complete<_Tp>
3349 template <class _Rp, class ..._Param>
3350 struct __check_complete<_Rp (*)(_Param...)>
3351 : private __check_complete<_Rp>
3355 template <class ..._Param>
3356 struct __check_complete<void (*)(_Param...)>
3360 template <class _Rp, class ..._Param>
3361 struct __check_complete<_Rp (_Param...)>
3362 : private __check_complete<_Rp>
3366 template <class ..._Param>
3367 struct __check_complete<void (_Param...)>
3371 template <class _Rp, class _Class, class ..._Param>
3372 struct __check_complete<_Rp (_Class::*)(_Param...)>
3373 : private __check_complete<_Class>
3377 template <class _Rp, class _Class, class ..._Param>
3378 struct __check_complete<_Rp (_Class::*)(_Param...) const>
3379 : private __check_complete<_Class>
3383 template <class _Rp, class _Class, class ..._Param>
3384 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
3385 : private __check_complete<_Class>
3389 template <class _Rp, class _Class, class ..._Param>
3390 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
3391 : private __check_complete<_Class>
3395 #if __has_feature(cxx_reference_qualified_functions)
3397 template <class _Rp, class _Class, class ..._Param>
3398 struct __check_complete<_Rp (_Class::*)(_Param...) &>
3399 : private __check_complete<_Class>
3403 template <class _Rp, class _Class, class ..._Param>
3404 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
3405 : private __check_complete<_Class>
3409 template <class _Rp, class _Class, class ..._Param>
3410 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
3411 : private __check_complete<_Class>
3415 template <class _Rp, class _Class, class ..._Param>
3416 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
3417 : private __check_complete<_Class>
3421 template <class _Rp, class _Class, class ..._Param>
3422 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
3423 : private __check_complete<_Class>
3427 template <class _Rp, class _Class, class ..._Param>
3428 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
3429 : private __check_complete<_Class>
3433 template <class _Rp, class _Class, class ..._Param>
3434 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
3435 : private __check_complete<_Class>
3439 template <class _Rp, class _Class, class ..._Param>
3440 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
3441 : private __check_complete<_Class>
3447 template <class _Rp, class _Class>
3448 struct __check_complete<_Rp _Class::*>
3449 : private __check_complete<_Class>
3453 // __invoke forward declarations
3455 // fall back - none of the bullets
3457 template <class ..._Args>
3459 __invoke(__any, _Args&& ...__args)
3464 template <class _Fp, class _A0, class ..._Args,
3465 class = typename enable_if
3467 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3468 is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3469 typename remove_reference<_A0>::type>::value
3472 _LIBCPP_INLINE_VISIBILITY
3474 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3475 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
3477 template <class _Fp, class _A0, class ..._Args,
3478 class = typename enable_if
3480 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3481 !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3482 typename remove_reference<_A0>::type>::value
3485 _LIBCPP_INLINE_VISIBILITY
3487 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3488 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
3492 template <class _Fp, class _A0,
3493 class = typename enable_if
3495 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3496 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3497 typename remove_reference<_A0>::type>::value
3500 _LIBCPP_INLINE_VISIBILITY
3502 __invoke(_Fp&& __f, _A0&& __a0)
3503 -> decltype(_VSTD::forward<_A0>(__a0).*__f);
3505 template <class _Fp, class _A0,
3506 class = typename enable_if
3508 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3509 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3510 typename remove_reference<_A0>::type>::value
3513 _LIBCPP_INLINE_VISIBILITY
3515 __invoke(_Fp&& __f, _A0&& __a0)
3516 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
3520 template <class _Fp, class ..._Args>
3521 _LIBCPP_INLINE_VISIBILITY
3523 __invoke(_Fp&& __f, _Args&& ...__args)
3524 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
3528 template <class _Fp, class ..._Args>
3529 struct __invokable_imp
3530 : private __check_complete<_Fp>
3533 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
3535 static const bool value = !is_same<type, __nat>::value;
3538 template <class _Fp, class ..._Args>
3540 : public integral_constant<bool,
3541 __invokable_imp<_Fp, _Args...>::value>
3547 template <bool _Invokable, class _Fp, class ..._Args>
3548 struct __invoke_of_imp // false
3552 template <class _Fp, class ..._Args>
3553 struct __invoke_of_imp<true, _Fp, _Args...>
3555 typedef typename __invokable_imp<_Fp, _Args...>::type type;
3558 template <class _Fp, class ..._Args>
3560 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
3564 template <class _Fp, class ..._Args>
3565 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
3566 : public __invoke_of<_Fp, _Args...>
3570 #if _LIBCPP_STD_VER > 11
3571 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3574 #endif // _LIBCPP_HAS_NO_VARIADICS
3576 template <class _Tp>
3577 inline _LIBCPP_INLINE_VISIBILITY
3578 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3581 is_move_constructible<_Tp>::value &&
3582 is_move_assignable<_Tp>::value
3587 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3588 is_nothrow_move_assignable<_Tp>::value)
3590 _Tp __t(_VSTD::move(__x));
3591 __x = _VSTD::move(__y);
3592 __y = _VSTD::move(__t);
3595 template <class _ForwardIterator1, class _ForwardIterator2>
3596 inline _LIBCPP_INLINE_VISIBILITY
3598 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3599 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3600 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3601 *_VSTD::declval<_ForwardIterator2>())))
3612 __nat swap(__any, __any);
3614 template <class _Tp>
3617 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3618 static const bool value = !is_same<type, __nat>::value;
3623 template <class _Tp>
3624 struct __is_swappable
3625 : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3629 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3631 template <bool, class _Tp>
3632 struct __is_nothrow_swappable_imp
3633 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3634 _VSTD::declval<_Tp&>()))>
3638 template <class _Tp>
3639 struct __is_nothrow_swappable_imp<false, _Tp>
3644 template <class _Tp>
3645 struct __is_nothrow_swappable
3646 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3650 #else // __has_feature(cxx_noexcept)
3652 template <class _Tp>
3653 struct __is_nothrow_swappable
3658 #endif // __has_feature(cxx_noexcept)
3660 #ifdef _LIBCPP_UNDERLYING_TYPE
3662 template <class _Tp>
3663 struct underlying_type
3665 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
3668 #if _LIBCPP_STD_VER > 11
3669 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3672 #else // _LIBCPP_UNDERLYING_TYPE
3674 template <class _Tp, bool _Support = false>
3675 struct underlying_type
3677 static_assert(_Support, "The underyling_type trait requires compiler "
3678 "support. Either no such support exists or "
3679 "libc++ does not know how to use it.");
3682 #endif // _LIBCPP_UNDERLYING_TYPE
3685 template <class _Tp, bool = std::is_enum<_Tp>::value>
3686 struct __sfinae_underlying_type
3688 typedef typename underlying_type<_Tp>::type type;
3689 typedef decltype(((type)1) + 0) __promoted_type;
3692 template <class _Tp>
3693 struct __sfinae_underlying_type<_Tp, false> {};
3695 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3696 int __convert_to_integral(int __val) { return __val; }
3698 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3699 unsigned __convert_to_integral(unsigned __val) { return __val; }
3701 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3702 long __convert_to_integral(long __val) { return __val; }
3704 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3705 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
3707 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3708 long long __convert_to_integral(long long __val) { return __val; }
3710 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3711 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
3713 #ifndef _LIBCPP_HAS_NO_INT128
3714 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3715 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
3717 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3718 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
3721 template <class _Tp>
3722 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
3723 typename __sfinae_underlying_type<_Tp>::__promoted_type
3724 __convert_to_integral(_Tp __val) { return __val; }
3726 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3728 template <class _Tp>
3729 struct __has_operator_addressof_member_imp
3731 template <class _Up>
3732 static auto __test(int)
3733 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
3735 static auto __test(long) -> false_type;
3737 static const bool value = decltype(__test<_Tp>(0))::value;
3740 template <class _Tp>
3741 struct __has_operator_addressof_free_imp
3743 template <class _Up>
3744 static auto __test(int)
3745 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
3747 static auto __test(long) -> false_type;
3749 static const bool value = decltype(__test<_Tp>(0))::value;
3752 template <class _Tp>
3753 struct __has_operator_addressof
3754 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
3755 || __has_operator_addressof_free_imp<_Tp>::value>
3758 #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
3760 #if _LIBCPP_STD_VER > 14
3761 template <class...> using void_t = void;
3764 _LIBCPP_END_NAMESPACE_STD
3766 #endif // _LIBCPP_TYPE_TRAITS