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;
23 typedef integral_constant<bool, false> false_type;
26 template <bool, class T = void> struct enable_if;
27 template <bool, class T, class F> struct conditional;
29 // Primary classification traits:
30 template <class T> struct is_void;
31 template <class T> struct is_null_pointer; // C++14
32 template <class T> struct is_integral;
33 template <class T> struct is_floating_point;
34 template <class T> struct is_array;
35 template <class T> struct is_pointer;
36 template <class T> struct is_lvalue_reference;
37 template <class T> struct is_rvalue_reference;
38 template <class T> struct is_member_object_pointer;
39 template <class T> struct is_member_function_pointer;
40 template <class T> struct is_enum;
41 template <class T> struct is_union;
42 template <class T> struct is_class;
43 template <class T> struct is_function;
45 // Secondary classification traits:
46 template <class T> struct is_reference;
47 template <class T> struct is_arithmetic;
48 template <class T> struct is_fundamental;
49 template <class T> struct is_member_pointer;
50 template <class T> struct is_scalar;
51 template <class T> struct is_object;
52 template <class T> struct is_compound;
54 // Const-volatile properties and transformations:
55 template <class T> struct is_const;
56 template <class T> struct is_volatile;
57 template <class T> struct remove_const;
58 template <class T> struct remove_volatile;
59 template <class T> struct remove_cv;
60 template <class T> struct add_const;
61 template <class T> struct add_volatile;
62 template <class T> struct add_cv;
64 // Reference transformations:
65 template <class T> struct remove_reference;
66 template <class T> struct add_lvalue_reference;
67 template <class T> struct add_rvalue_reference;
69 // Pointer transformations:
70 template <class T> struct remove_pointer;
71 template <class T> struct add_pointer;
73 // Integral properties:
74 template <class T> struct is_signed;
75 template <class T> struct is_unsigned;
76 template <class T> struct make_signed;
77 template <class T> struct make_unsigned;
79 // Array properties and transformations:
80 template <class T> struct rank;
81 template <class T, unsigned I = 0> struct extent;
82 template <class T> struct remove_extent;
83 template <class T> struct remove_all_extents;
85 // Member introspection:
86 template <class T> struct is_pod;
87 template <class T> struct is_trivial;
88 template <class T> struct is_trivially_copyable;
89 template <class T> struct is_standard_layout;
90 template <class T> struct is_literal_type;
91 template <class T> struct is_empty;
92 template <class T> struct is_polymorphic;
93 template <class T> struct is_abstract;
95 template <class T, class... Args> struct is_constructible;
96 template <class T> struct is_default_constructible;
97 template <class T> struct is_copy_constructible;
98 template <class T> struct is_move_constructible;
99 template <class T, class U> struct is_assignable;
100 template <class T> struct is_copy_assignable;
101 template <class T> struct is_move_assignable;
102 template <class T> struct is_destructible;
104 template <class T, class... Args> struct is_trivially_constructible;
105 template <class T> struct is_trivially_default_constructible;
106 template <class T> struct is_trivially_copy_constructible;
107 template <class T> struct is_trivially_move_constructible;
108 template <class T, class U> struct is_trivially_assignable;
109 template <class T> struct is_trivially_copy_assignable;
110 template <class T> struct is_trivially_move_assignable;
111 template <class T> struct is_trivially_destructible;
113 template <class T, class... Args> struct is_nothrow_constructible;
114 template <class T> struct is_nothrow_default_constructible;
115 template <class T> struct is_nothrow_copy_constructible;
116 template <class T> struct is_nothrow_move_constructible;
117 template <class T, class U> struct is_nothrow_assignable;
118 template <class T> struct is_nothrow_copy_assignable;
119 template <class T> struct is_nothrow_move_assignable;
120 template <class T> struct is_nothrow_destructible;
122 template <class T> struct has_virtual_destructor;
124 // Relationships between types:
125 template <class T, class U> struct is_same;
126 template <class Base, class Derived> struct is_base_of;
127 template <class From, class To> struct is_convertible;
129 // Alignment properties and transformations:
130 template <class T> struct alignment_of;
131 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
132 struct aligned_storage;
133 template <size_t Len, class... Types> struct aligned_union;
135 template <class T> struct decay;
136 template <class... T> struct common_type;
137 template <class T> struct underlying_type;
138 template <class> class result_of; // undefined
139 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
141 // const-volatile modifications:
143 using remove_const_t = typename remove_const<T>::type; // C++14
145 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
147 using remove_cv_t = typename remove_cv<T>::type; // C++14
149 using add_const_t = typename add_const<T>::type; // C++14
151 using add_volatile_t = typename add_volatile<T>::type; // C++14
153 using add_cv_t = typename add_cv<T>::type; // C++14
155 // reference modifications:
157 using remove_reference_t = typename remove_reference<T>::type; // C++14
159 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
161 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
163 // sign modifications:
165 using make_signed_t = typename make_signed<T>::type; // C++14
167 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
169 // array modifications:
171 using remove_extent_t = typename remove_extent<T>::type; // C++14
173 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
175 // pointer modifications:
177 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
179 using add_pointer_t = typename add_pointer<T>::type; // C++14
181 // other transformations:
182 template <size_t Len, std::size_t Align=default-alignment>
183 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
184 template <std::size_t Len, class... Types>
185 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
187 using decay_t = typename decay<T>::type; // C++14
188 template <bool b, class T=void>
189 using enable_if_t = typename enable_if<b,T>::type; // C++14
190 template <bool b, class T, class F>
191 using conditional_t = typename conditional<b,T,F>::type; // C++14
192 template <class... T>
193 using common_type_t = typename common_type<T...>::type; // C++14
195 using underlying_type_t = typename underlying_type<T>::type; // C++14
196 template <class F, class... ArgTypes>
197 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
205 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
206 #pragma GCC system_header
209 _LIBCPP_BEGIN_NAMESPACE_STD
211 template <bool _Bp, class _If, class _Then>
212 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
213 template <class _If, class _Then>
214 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
216 #if _LIBCPP_STD_VER > 11
217 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
220 template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
221 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
223 #if _LIBCPP_STD_VER > 11
224 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
228 struct __two {char __lx[2];};
232 template <class _Tp, _Tp __v>
233 struct _LIBCPP_TYPE_VIS_ONLY integral_constant
235 static _LIBCPP_CONSTEXPR const _Tp value = __v;
236 typedef _Tp value_type;
237 typedef integral_constant type;
238 _LIBCPP_INLINE_VISIBILITY
239 _LIBCPP_CONSTEXPR operator value_type() const {return value;}
240 #if _LIBCPP_STD_VER > 11
241 _LIBCPP_INLINE_VISIBILITY
242 constexpr value_type operator ()() const {return value;}
246 template <class _Tp, _Tp __v>
247 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
249 typedef integral_constant<bool, true> true_type;
250 typedef integral_constant<bool, false> false_type;
254 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
255 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
259 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
260 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
264 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
265 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
266 #if _LIBCPP_STD_VER > 11
267 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
272 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
273 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
274 #if _LIBCPP_STD_VER > 11
275 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
280 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
281 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
282 #if _LIBCPP_STD_VER > 11
283 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
288 template <class _Tp> struct __libcpp_is_void : public false_type {};
289 template <> struct __libcpp_is_void<void> : public true_type {};
291 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
292 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
296 template <class _Tp> struct __libcpp___is_nullptr : public false_type {};
297 template <> struct __libcpp___is_nullptr<nullptr_t> : public true_type {};
299 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
300 : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {};
302 #if _LIBCPP_STD_VER > 11
303 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
304 : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {};
309 template <class _Tp> struct __libcpp_is_integral : public false_type {};
310 template <> struct __libcpp_is_integral<bool> : public true_type {};
311 template <> struct __libcpp_is_integral<char> : public true_type {};
312 template <> struct __libcpp_is_integral<signed char> : public true_type {};
313 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
314 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
315 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
316 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
317 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
318 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
319 template <> struct __libcpp_is_integral<short> : public true_type {};
320 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
321 template <> struct __libcpp_is_integral<int> : public true_type {};
322 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
323 template <> struct __libcpp_is_integral<long> : public true_type {};
324 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
325 template <> struct __libcpp_is_integral<long long> : public true_type {};
326 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
328 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
329 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
333 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
334 template <> struct __libcpp_is_floating_point<float> : public true_type {};
335 template <> struct __libcpp_is_floating_point<double> : public true_type {};
336 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
338 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
339 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
343 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
344 : public false_type {};
345 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
346 : public true_type {};
347 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
348 : public true_type {};
352 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
353 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
355 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
356 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
360 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
361 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
363 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
364 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
365 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
368 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
369 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
370 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
371 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
374 #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
375 #define _LIBCPP_HAS_TYPE_TRAITS
380 #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
382 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
383 : public integral_constant<bool, __is_union(_Tp)> {};
387 template <class _Tp> struct __libcpp_union : public false_type {};
388 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
389 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
395 #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
397 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
398 : public integral_constant<bool, __is_class(_Tp)> {};
402 namespace __is_class_imp
404 template <class _Tp> char __test(int _Tp::*);
405 template <class _Tp> __two __test(...);
408 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
409 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
415 template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
416 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
420 namespace __is_function_imp
422 template <class _Tp> char __test(_Tp*);
423 template <class _Tp> __two __test(...);
424 template <class _Tp> _Tp& __source();
427 template <class _Tp, bool = is_class<_Tp>::value ||
428 is_union<_Tp>::value ||
429 is_void<_Tp>::value ||
430 is_reference<_Tp>::value ||
431 __is_nullptr_t<_Tp>::value >
432 struct __libcpp_is_function
433 : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1>
435 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
437 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
438 : public __libcpp_is_function<_Tp> {};
440 // is_member_function_pointer
442 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
443 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
446 template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
447 struct __member_pointer_traits_imp
448 { // forward declaration; specializations later
452 namespace __libcpp_is_member_function_pointer_imp {
453 template <typename _Tp>
454 char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *);
457 std::__two __test(...);
460 template <class _Tp> struct __libcpp_is_member_function_pointer
461 : public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {};
463 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
464 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
468 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
469 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
471 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
472 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
474 // is_member_object_pointer
476 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
477 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
478 !is_member_function_pointer<_Tp>::value> {};
482 #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
484 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
485 : public integral_constant<bool, __is_enum(_Tp)> {};
489 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
490 : public integral_constant<bool, !is_void<_Tp>::value &&
491 !is_integral<_Tp>::value &&
492 !is_floating_point<_Tp>::value &&
493 !is_array<_Tp>::value &&
494 !is_pointer<_Tp>::value &&
495 !is_reference<_Tp>::value &&
496 !is_member_pointer<_Tp>::value &&
497 !is_union<_Tp>::value &&
498 !is_class<_Tp>::value &&
499 !is_function<_Tp>::value > {};
505 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
506 : public integral_constant<bool, is_integral<_Tp>::value ||
507 is_floating_point<_Tp>::value> {};
511 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
512 : public integral_constant<bool, is_void<_Tp>::value ||
513 __is_nullptr_t<_Tp>::value ||
514 is_arithmetic<_Tp>::value> {};
518 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
519 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
520 is_member_pointer<_Tp>::value ||
521 is_pointer<_Tp>::value ||
522 __is_nullptr_t<_Tp>::value ||
523 is_enum<_Tp>::value > {};
525 template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
529 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
530 : public integral_constant<bool, is_scalar<_Tp>::value ||
531 is_array<_Tp>::value ||
532 is_union<_Tp>::value ||
533 is_class<_Tp>::value > {};
537 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
538 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
542 template <class _Tp, bool = is_reference<_Tp>::value ||
543 is_function<_Tp>::value ||
544 is_const<_Tp>::value >
545 struct __add_const {typedef _Tp type;};
548 struct __add_const<_Tp, false> {typedef const _Tp type;};
550 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
551 {typedef typename __add_const<_Tp>::type type;};
553 #if _LIBCPP_STD_VER > 11
554 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
559 template <class _Tp, bool = is_reference<_Tp>::value ||
560 is_function<_Tp>::value ||
561 is_volatile<_Tp>::value >
562 struct __add_volatile {typedef _Tp type;};
565 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
567 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
568 {typedef typename __add_volatile<_Tp>::type type;};
570 #if _LIBCPP_STD_VER > 11
571 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
576 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
577 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
579 #if _LIBCPP_STD_VER > 11
580 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
585 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
586 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
587 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
588 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
591 #if _LIBCPP_STD_VER > 11
592 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
595 // add_lvalue_reference
597 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;};
598 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
599 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;};
600 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;};
601 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;};
602 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
604 #if _LIBCPP_STD_VER > 11
605 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
608 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
610 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;};
611 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;};
612 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;};
613 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;};
614 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
616 #if _LIBCPP_STD_VER > 11
617 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
620 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
622 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
625 typename add_rvalue_reference<_Tp>::type
628 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
631 typename add_lvalue_reference<_Tp>::type
634 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
643 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
644 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
645 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
646 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
647 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
649 #if _LIBCPP_STD_VER > 11
650 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
655 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
656 {typedef typename remove_reference<_Tp>::type* type;};
658 #if _LIBCPP_STD_VER > 11
659 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
664 template <class _Tp, bool = is_integral<_Tp>::value>
665 struct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
668 struct ___is_signed<_Tp, false> : public true_type {}; // floating point
670 template <class _Tp, bool = is_arithmetic<_Tp>::value>
671 struct __libcpp_is_signed : public ___is_signed<_Tp> {};
673 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
675 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
679 template <class _Tp, bool = is_integral<_Tp>::value>
680 struct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
683 struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point
685 template <class _Tp, bool = is_arithmetic<_Tp>::value>
686 struct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {};
688 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
690 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
694 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
695 : public integral_constant<size_t, 0> {};
696 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
697 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
698 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
699 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
703 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
704 : public integral_constant<size_t, 0> {};
705 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
706 : public integral_constant<size_t, 0> {};
707 template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
708 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
709 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
710 : public integral_constant<size_t, _Np> {};
711 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
712 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
716 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
718 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
720 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
723 #if _LIBCPP_STD_VER > 11
724 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
727 // remove_all_extents
729 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
731 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
732 {typedef typename remove_all_extents<_Tp>::type type;};
733 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
734 {typedef typename remove_all_extents<_Tp>::type type;};
736 #if _LIBCPP_STD_VER > 11
737 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
743 struct _LIBCPP_TYPE_VIS_ONLY decay
746 typedef typename remove_reference<_Tp>::type _Up;
748 typedef typename conditional
750 is_array<_Up>::value,
751 typename remove_extent<_Up>::type*,
754 is_function<_Up>::value,
755 typename add_pointer<_Up>::type,
756 typename remove_cv<_Up>::type
761 #if _LIBCPP_STD_VER > 11
762 template <class _Tp> using decay_t = typename decay<_Tp>::type;
767 namespace __is_abstract_imp
769 template <class _Tp> char __test(_Tp (*)[1]);
770 template <class _Tp> __two __test(...);
773 template <class _Tp, bool = is_class<_Tp>::value>
774 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
776 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
778 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
782 #ifdef _LIBCPP_HAS_IS_BASE_OF
784 template <class _Bp, class _Dp>
785 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
786 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
788 #else // __has_feature(is_base_of)
790 namespace __is_base_of_imp
795 _Dst(const volatile _Tp &);
800 operator const volatile _Tp &();
801 template <class _Up> operator const _Dst<_Up> &();
803 template <size_t> struct __one { typedef char type; };
804 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
805 template <class _Bp, class _Dp> __two __test(...);
808 template <class _Bp, class _Dp>
809 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
810 : public integral_constant<bool, is_class<_Bp>::value &&
811 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
813 #endif // __has_feature(is_base_of)
817 #if __has_feature(is_convertible_to)
819 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
820 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
821 !is_abstract<_T2>::value> {};
823 #else // __has_feature(is_convertible_to)
825 namespace __is_convertible_imp
827 template <class _Tp> char __test(_Tp);
828 template <class _Tp> __two __test(...);
829 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
830 template <class _Tp> _Tp&& __source();
832 template <class _Tp> typename remove_reference<_Tp>::type& __source();
835 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
836 bool _IsFunction = is_function<_Tp>::value,
837 bool _IsVoid = is_void<_Tp>::value>
838 struct __is_array_function_or_void {enum {value = 0};};
839 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
840 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
841 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
845 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
846 struct __is_convertible_check
848 static const size_t __v = 0;
852 struct __is_convertible_check<_Tp, 0>
854 static const size_t __v = sizeof(_Tp);
857 template <class _T1, class _T2,
858 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
859 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
860 struct __is_convertible
861 : public integral_constant<bool,
862 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
863 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
865 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
866 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
867 && (!is_const<typename remove_reference<_T2>::type>::value
868 || is_volatile<typename remove_reference<_T2>::type>::value)
869 && (is_same<typename remove_cv<_T1>::type,
870 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
871 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
876 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
878 template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
879 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
880 template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
881 template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
882 template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
883 template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
884 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
886 template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
887 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
889 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
890 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
892 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
893 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
895 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
896 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
898 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
899 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
900 template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
902 template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
903 template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
904 template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
905 template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
906 template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
908 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
910 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
911 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
912 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
913 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
915 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
916 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
917 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
918 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
920 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
921 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
922 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
923 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
925 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
926 : public __is_convertible<_T1, _T2>
928 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
929 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
932 #endif // __has_feature(is_convertible_to)
936 #if __has_feature(is_empty)
939 struct _LIBCPP_TYPE_VIS_ONLY is_empty
940 : public integral_constant<bool, __is_empty(_Tp)> {};
942 #else // __has_feature(is_empty)
956 template <class _Tp, bool = is_class<_Tp>::value>
957 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
959 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
961 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
963 #endif // __has_feature(is_empty)
967 #if __has_feature(is_polymorphic)
970 struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
971 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
975 template<typename _Tp> char &__is_polymorphic_impl(
976 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
978 template<typename _Tp> __two &__is_polymorphic_impl(...);
980 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
981 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
983 #endif // __has_feature(is_polymorphic)
985 // has_virtual_destructor
987 #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
989 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
990 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
992 #else // _LIBCPP_HAS_TYPE_TRAITS
994 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
995 : public false_type {};
997 #endif // _LIBCPP_HAS_TYPE_TRAITS
1001 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
1002 : public integral_constant<size_t, __alignof__(_Tp)> {};
1006 template <class _Hp, class _Tp>
1015 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1017 __nat(const __nat&) = delete;
1018 __nat& operator=(const __nat&) = delete;
1023 template <class _Tp>
1026 static const size_t value = alignment_of<_Tp>::value;
1030 struct __struct_double {long double __lx;};
1031 struct __struct_double4 {double __lx[4];};
1034 __type_list<__align_type<unsigned char>,
1035 __type_list<__align_type<unsigned short>,
1036 __type_list<__align_type<unsigned int>,
1037 __type_list<__align_type<unsigned long>,
1038 __type_list<__align_type<unsigned long long>,
1039 __type_list<__align_type<double>,
1040 __type_list<__align_type<long double>,
1041 __type_list<__align_type<__struct_double>,
1042 __type_list<__align_type<__struct_double4>,
1043 __type_list<__align_type<int*>,
1045 > > > > > > > > > > __all_types;
1047 template <class _TL, size_t _Align> struct __find_pod;
1049 template <class _Hp, size_t _Align>
1050 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1052 typedef typename conditional<
1053 _Align == _Hp::value,
1059 template <class _Hp, class _Tp, size_t _Align>
1060 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1062 typedef typename conditional<
1063 _Align == _Hp::value,
1065 typename __find_pod<_Tp, _Align>::type
1069 template <class _TL, size_t _Len> struct __find_max_align;
1071 template <class _Hp, size_t _Len>
1072 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1074 template <size_t _Len, size_t _A1, size_t _A2>
1075 struct __select_align
1078 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1079 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1081 static const size_t value = _Len < __max ? __min : __max;
1084 template <class _Hp, class _Tp, size_t _Len>
1085 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1086 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1088 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1089 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
1091 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1092 static_assert(!is_void<_Aligner>::value, "");
1096 unsigned char __data[_Len];
1100 #if _LIBCPP_STD_VER > 11
1101 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1102 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1105 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1106 template <size_t _Len>\
1107 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
1109 struct _ALIGNAS(n) type\
1111 unsigned char __lx[_Len];\
1115 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1116 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1117 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1118 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1119 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1120 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1121 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1122 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1123 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1124 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1125 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1126 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1127 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1128 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1129 // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1130 #if !defined(_LIBCPP_MSVC)
1131 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1132 #endif // !_LIBCPP_MSVC
1134 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1136 #ifndef _LIBCPP_HAS_NO_VARIADICS
1140 template <size_t _I0, size_t ..._In>
1141 struct __static_max;
1143 template <size_t _I0>
1144 struct __static_max<_I0>
1146 static const size_t value = _I0;
1149 template <size_t _I0, size_t _I1, size_t ..._In>
1150 struct __static_max<_I0, _I1, _In...>
1152 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1153 __static_max<_I1, _In...>::value;
1156 template <size_t _Len, class _Type0, class ..._Types>
1157 struct aligned_union
1159 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1160 __alignof__(_Types)...>::value;
1161 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1162 sizeof(_Types)...>::value;
1163 typedef typename aligned_storage<__len, alignment_value>::type type;
1166 #if _LIBCPP_STD_VER > 11
1167 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1170 #endif // _LIBCPP_HAS_NO_VARIADICS
1174 template <class _A1, class _A2 = void, class _A3 = void,
1175 bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
1176 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
1177 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
1180 template <class _A1, class _A2, class _A3>
1181 class __promote<_A1, _A2, _A3, true>
1184 typedef typename __promote<_A1>::type __type1;
1185 typedef typename __promote<_A2>::type __type2;
1186 typedef typename __promote<_A3>::type __type3;
1188 typedef decltype(__type1() + __type2() + __type3()) type;
1191 template <class _A1, class _A2>
1192 class __promote<_A1, _A2, void, true>
1195 typedef typename __promote<_A1>::type __type1;
1196 typedef typename __promote<_A2>::type __type2;
1198 typedef decltype(__type1() + __type2()) type;
1201 template <class _A1>
1202 class __promote<_A1, void, void, true>
1205 typedef typename conditional<is_arithmetic<_A1>::value,
1206 typename conditional<is_integral<_A1>::value, double, _A1>::type,
1211 #ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1215 template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1216 template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;};
1217 template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;};
1218 template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;};
1219 template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1221 #endif // _LIBCPP_STORE_AS_OPTIMIZATION
1223 // make_signed / make_unsigned
1226 __type_list<signed char,
1227 __type_list<signed short,
1228 __type_list<signed int,
1229 __type_list<signed long,
1230 __type_list<signed long long,
1232 > > > > > __signed_types;
1235 __type_list<unsigned char,
1236 __type_list<unsigned short,
1237 __type_list<unsigned int,
1238 __type_list<unsigned long,
1239 __type_list<unsigned long long,
1241 > > > > > __unsigned_types;
1243 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1245 template <class _Hp, class _Tp, size_t _Size>
1246 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1251 template <class _Hp, class _Tp, size_t _Size>
1252 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1254 typedef typename __find_first<_Tp, _Size>::type type;
1257 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1258 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1264 template <class _Tp, class _Up>
1265 struct __apply_cv<_Tp, _Up, true, false>
1267 typedef const _Up type;
1270 template <class _Tp, class _Up>
1271 struct __apply_cv<_Tp, _Up, false, true>
1273 typedef volatile _Up type;
1276 template <class _Tp, class _Up>
1277 struct __apply_cv<_Tp, _Up, true, true>
1279 typedef const volatile _Up type;
1282 template <class _Tp, class _Up>
1283 struct __apply_cv<_Tp&, _Up, false, false>
1288 template <class _Tp, class _Up>
1289 struct __apply_cv<_Tp&, _Up, true, false>
1291 typedef const _Up& type;
1294 template <class _Tp, class _Up>
1295 struct __apply_cv<_Tp&, _Up, false, true>
1297 typedef volatile _Up& type;
1300 template <class _Tp, class _Up>
1301 struct __apply_cv<_Tp&, _Up, true, true>
1303 typedef const volatile _Up& type;
1306 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1307 struct __make_signed {};
1309 template <class _Tp>
1310 struct __make_signed<_Tp, true>
1312 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1315 template <> struct __make_signed<bool, true> {};
1316 template <> struct __make_signed< signed short, true> {typedef short type;};
1317 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1318 template <> struct __make_signed< signed int, true> {typedef int type;};
1319 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1320 template <> struct __make_signed< signed long, true> {typedef long type;};
1321 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1322 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1323 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1325 template <class _Tp>
1326 struct _LIBCPP_TYPE_VIS_ONLY make_signed
1328 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1331 #if _LIBCPP_STD_VER > 11
1332 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1335 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1336 struct __make_unsigned {};
1338 template <class _Tp>
1339 struct __make_unsigned<_Tp, true>
1341 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1344 template <> struct __make_unsigned<bool, true> {};
1345 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1346 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1347 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1348 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1349 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1350 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1351 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1352 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1354 template <class _Tp>
1355 struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
1357 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1360 #if _LIBCPP_STD_VER > 11
1361 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1364 #ifdef _LIBCPP_HAS_NO_VARIADICS
1366 template <class _Tp, class _Up = void, class V = void>
1367 struct _LIBCPP_TYPE_VIS_ONLY common_type
1370 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1373 template <class _Tp>
1374 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
1380 template <class _Tp, class _Up>
1381 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
1384 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1387 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1390 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1392 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1395 #else // _LIBCPP_HAS_NO_VARIADICS
1397 template <class ..._Tp> struct common_type;
1399 template <class _Tp>
1400 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
1402 typedef typename decay<_Tp>::type type;
1405 template <class _Tp, class _Up>
1406 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
1413 typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
1416 template <class _Tp, class _Up, class ..._Vp>
1417 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
1419 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1422 #if _LIBCPP_STD_VER > 11
1423 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1426 #endif // _LIBCPP_HAS_NO_VARIADICS
1430 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
1432 template <class _Tp, class _Arg>
1433 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
1434 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1435 __is_assignable_test(_Tp&&, _Arg&&);
1437 __is_assignable_test(_Tp, _Arg&);
1440 template <class _Arg>
1442 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1443 __is_assignable_test(__any, _Arg&&);
1445 __is_assignable_test(__any, _Arg&);
1448 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1449 struct __is_assignable_imp
1450 : public common_type
1452 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1455 template <class _Tp, class _Arg>
1456 struct __is_assignable_imp<_Tp, _Arg, true>
1461 template <class _Tp, class _Arg>
1462 struct is_assignable
1463 : public __is_assignable_imp<_Tp, _Arg> {};
1465 // is_copy_assignable
1467 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
1468 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1469 const typename add_lvalue_reference<_Tp>::type> {};
1471 // is_move_assignable
1473 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
1474 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1475 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1476 const typename add_rvalue_reference<_Tp>::type> {};
1478 : public is_copy_assignable<_Tp> {};
1483 template <class _Tp>
1484 struct __destructible_test
1489 template <class _Tp>
1490 decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1491 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1492 __is_destructible_test(_Tp&&);
1494 __is_destructible_test(_Tp&);
1498 __is_destructible_test(__any);
1500 template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value
1501 || is_function<_Tp>::value>
1502 struct __destructible_imp
1503 : public common_type
1505 decltype(__is_destructible_test(declval<_Tp>()))
1508 template <class _Tp>
1509 struct __destructible_imp<_Tp, true>
1510 : public false_type {};
1512 template <class _Tp>
1513 struct is_destructible
1514 : public __destructible_imp<_Tp> {};
1516 template <class _Tp>
1517 struct is_destructible<_Tp[]>
1518 : public false_type {};
1522 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1524 template <class _Tp>
1525 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1526 typename remove_reference<_Tp>::type&&
1527 move(_Tp&& __t) _NOEXCEPT
1529 typedef typename remove_reference<_Tp>::type _Up;
1530 return static_cast<_Up&&>(__t);
1533 template <class _Tp>
1534 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1536 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1538 return static_cast<_Tp&&>(__t);
1541 template <class _Tp>
1542 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1544 forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1546 static_assert(!std::is_lvalue_reference<_Tp>::value,
1547 "Can not forward an rvalue as an lvalue.");
1548 return static_cast<_Tp&&>(__t);
1551 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1553 template <class _Tp>
1554 inline _LIBCPP_INLINE_VISIBILITY
1561 template <class _Tp>
1562 inline _LIBCPP_INLINE_VISIBILITY
1564 move(const _Tp& __t)
1569 template <class _Tp>
1570 inline _LIBCPP_INLINE_VISIBILITY
1572 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1578 template <class _Tp>
1581 typedef typename remove_reference<_Tp>::type _Trr;
1584 _LIBCPP_INLINE_VISIBILITY
1585 _Trr* operator->() {return &t_;}
1586 _LIBCPP_INLINE_VISIBILITY
1587 explicit __rv(_Trr& __t) : t_(__t) {}
1590 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1592 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1594 template <class _Tp>
1595 inline _LIBCPP_INLINE_VISIBILITY
1596 typename decay<_Tp>::type
1597 __decay_copy(_Tp&& __t)
1599 return _VSTD::forward<_Tp>(__t);
1604 template <class _Tp>
1605 inline _LIBCPP_INLINE_VISIBILITY
1606 typename decay<_Tp>::type
1607 __decay_copy(const _Tp& __t)
1609 return _VSTD::forward<_Tp>(__t);
1614 #ifndef _LIBCPP_HAS_NO_VARIADICS
1616 template <class _Rp, class _Class, class ..._Param>
1617 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1619 typedef _Class _ClassType;
1620 typedef _Rp _ReturnType;
1621 typedef _Rp (_FnType) (_Param...);
1624 template <class _Rp, class _Class, class ..._Param>
1625 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1627 typedef _Class const _ClassType;
1628 typedef _Rp _ReturnType;
1629 typedef _Rp (_FnType) (_Param...);
1632 template <class _Rp, class _Class, class ..._Param>
1633 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1635 typedef _Class volatile _ClassType;
1636 typedef _Rp _ReturnType;
1637 typedef _Rp (_FnType) (_Param...);
1640 template <class _Rp, class _Class, class ..._Param>
1641 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1643 typedef _Class const volatile _ClassType;
1644 typedef _Rp _ReturnType;
1645 typedef _Rp (_FnType) (_Param...);
1648 #if __has_feature(cxx_reference_qualified_functions)
1650 template <class _Rp, class _Class, class ..._Param>
1651 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1653 typedef _Class& _ClassType;
1654 typedef _Rp _ReturnType;
1655 typedef _Rp (_FnType) (_Param...);
1658 template <class _Rp, class _Class, class ..._Param>
1659 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1661 typedef _Class const& _ClassType;
1662 typedef _Rp _ReturnType;
1663 typedef _Rp (_FnType) (_Param...);
1666 template <class _Rp, class _Class, class ..._Param>
1667 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1669 typedef _Class volatile& _ClassType;
1670 typedef _Rp _ReturnType;
1671 typedef _Rp (_FnType) (_Param...);
1674 template <class _Rp, class _Class, class ..._Param>
1675 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1677 typedef _Class const volatile& _ClassType;
1678 typedef _Rp _ReturnType;
1679 typedef _Rp (_FnType) (_Param...);
1682 template <class _Rp, class _Class, class ..._Param>
1683 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1685 typedef _Class&& _ClassType;
1686 typedef _Rp _ReturnType;
1687 typedef _Rp (_FnType) (_Param...);
1690 template <class _Rp, class _Class, class ..._Param>
1691 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1693 typedef _Class const&& _ClassType;
1694 typedef _Rp _ReturnType;
1695 typedef _Rp (_FnType) (_Param...);
1698 template <class _Rp, class _Class, class ..._Param>
1699 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1701 typedef _Class volatile&& _ClassType;
1702 typedef _Rp _ReturnType;
1703 typedef _Rp (_FnType) (_Param...);
1706 template <class _Rp, class _Class, class ..._Param>
1707 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1709 typedef _Class const volatile&& _ClassType;
1710 typedef _Rp _ReturnType;
1711 typedef _Rp (_FnType) (_Param...);
1714 #endif // __has_feature(cxx_reference_qualified_functions)
1716 #else // _LIBCPP_HAS_NO_VARIADICS
1718 template <class _Rp, class _Class>
1719 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1721 typedef _Class _ClassType;
1722 typedef _Rp _ReturnType;
1723 typedef _Rp (_FnType) ();
1726 template <class _Rp, class _Class, class _P0>
1727 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1729 typedef _Class _ClassType;
1730 typedef _Rp _ReturnType;
1731 typedef _Rp (_FnType) (_P0);
1734 template <class _Rp, class _Class, class _P0, class _P1>
1735 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1737 typedef _Class _ClassType;
1738 typedef _Rp _ReturnType;
1739 typedef _Rp (_FnType) (_P0, _P1);
1742 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1743 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1745 typedef _Class _ClassType;
1746 typedef _Rp _ReturnType;
1747 typedef _Rp (_FnType) (_P0, _P1, _P2);
1750 template <class _Rp, class _Class>
1751 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1753 typedef _Class const _ClassType;
1754 typedef _Rp _ReturnType;
1755 typedef _Rp (_FnType) ();
1758 template <class _Rp, class _Class, class _P0>
1759 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1761 typedef _Class const _ClassType;
1762 typedef _Rp _ReturnType;
1763 typedef _Rp (_FnType) (_P0);
1766 template <class _Rp, class _Class, class _P0, class _P1>
1767 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1769 typedef _Class const _ClassType;
1770 typedef _Rp _ReturnType;
1771 typedef _Rp (_FnType) (_P0, _P1);
1774 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1775 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1777 typedef _Class const _ClassType;
1778 typedef _Rp _ReturnType;
1779 typedef _Rp (_FnType) (_P0, _P1, _P2);
1782 template <class _Rp, class _Class>
1783 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1785 typedef _Class volatile _ClassType;
1786 typedef _Rp _ReturnType;
1787 typedef _Rp (_FnType) ();
1790 template <class _Rp, class _Class, class _P0>
1791 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1793 typedef _Class volatile _ClassType;
1794 typedef _Rp _ReturnType;
1795 typedef _Rp (_FnType) (_P0);
1798 template <class _Rp, class _Class, class _P0, class _P1>
1799 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1801 typedef _Class volatile _ClassType;
1802 typedef _Rp _ReturnType;
1803 typedef _Rp (_FnType) (_P0, _P1);
1806 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1807 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1809 typedef _Class volatile _ClassType;
1810 typedef _Rp _ReturnType;
1811 typedef _Rp (_FnType) (_P0, _P1, _P2);
1814 template <class _Rp, class _Class>
1815 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1817 typedef _Class const volatile _ClassType;
1818 typedef _Rp _ReturnType;
1819 typedef _Rp (_FnType) ();
1822 template <class _Rp, class _Class, class _P0>
1823 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1825 typedef _Class const volatile _ClassType;
1826 typedef _Rp _ReturnType;
1827 typedef _Rp (_FnType) (_P0);
1830 template <class _Rp, class _Class, class _P0, class _P1>
1831 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1833 typedef _Class const volatile _ClassType;
1834 typedef _Rp _ReturnType;
1835 typedef _Rp (_FnType) (_P0, _P1);
1838 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1839 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1841 typedef _Class const volatile _ClassType;
1842 typedef _Rp _ReturnType;
1843 typedef _Rp (_FnType) (_P0, _P1, _P2);
1846 #endif // _LIBCPP_HAS_NO_VARIADICS
1848 template <class _Rp, class _Class>
1849 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1851 typedef _Class _ClassType;
1852 typedef _Rp _ReturnType;
1855 template <class _MP>
1856 struct __member_pointer_traits
1857 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
1858 is_member_function_pointer<_MP>::value,
1859 is_member_object_pointer<_MP>::value>
1861 // typedef ... _ClassType;
1862 // typedef ... _ReturnType;
1863 // typedef ... _FnType;
1868 template <class _Callable> class result_of;
1870 #ifdef _LIBCPP_HAS_NO_VARIADICS
1872 template <class _Fn, bool, bool>
1877 template <class _Fn>
1878 class __result_of<_Fn(), true, false>
1881 typedef decltype(declval<_Fn>()()) type;
1884 template <class _Fn, class _A0>
1885 class __result_of<_Fn(_A0), true, false>
1888 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1891 template <class _Fn, class _A0, class _A1>
1892 class __result_of<_Fn(_A0, _A1), true, false>
1895 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1898 template <class _Fn, class _A0, class _A1, class _A2>
1899 class __result_of<_Fn(_A0, _A1, _A2), true, false>
1902 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1905 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1906 struct __result_of_mp;
1908 // member function pointer
1910 template <class _MP, class _Tp>
1911 struct __result_of_mp<_MP, _Tp, true>
1912 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1916 // member data pointer
1918 template <class _MP, class _Tp, bool>
1919 struct __result_of_mdp;
1921 template <class _Rp, class _Class, class _Tp>
1922 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
1924 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1927 template <class _Rp, class _Class, class _Tp>
1928 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
1930 typedef typename __apply_cv<_Tp, _Rp>::type& type;
1933 template <class _Rp, class _Class, class _Tp>
1934 struct __result_of_mp<_Rp _Class::*, _Tp, false>
1935 : public __result_of_mdp<_Rp _Class::*, _Tp,
1936 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1942 template <class _Fn, class _Tp>
1943 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
1944 : public __result_of_mp<typename remove_reference<_Fn>::type,
1946 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1950 template <class _Fn, class _Tp, class _A0>
1951 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
1952 : public __result_of_mp<typename remove_reference<_Fn>::type,
1954 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1958 template <class _Fn, class _Tp, class _A0, class _A1>
1959 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
1960 : public __result_of_mp<typename remove_reference<_Fn>::type,
1962 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1966 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1967 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
1968 : public __result_of_mp<typename remove_reference<_Fn>::type,
1970 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1976 template <class _Fn>
1977 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
1978 : public __result_of<_Fn(),
1979 is_class<typename remove_reference<_Fn>::type>::value ||
1980 is_function<typename remove_reference<_Fn>::type>::value,
1981 is_member_pointer<typename remove_reference<_Fn>::type>::value
1986 template <class _Fn, class _A0>
1987 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
1988 : public __result_of<_Fn(_A0),
1989 is_class<typename remove_reference<_Fn>::type>::value ||
1990 is_function<typename remove_reference<_Fn>::type>::value,
1991 is_member_pointer<typename remove_reference<_Fn>::type>::value
1996 template <class _Fn, class _A0, class _A1>
1997 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
1998 : public __result_of<_Fn(_A0, _A1),
1999 is_class<typename remove_reference<_Fn>::type>::value ||
2000 is_function<typename remove_reference<_Fn>::type>::value,
2001 is_member_pointer<typename remove_reference<_Fn>::type>::value
2006 template <class _Fn, class _A0, class _A1, class _A2>
2007 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
2008 : public __result_of<_Fn(_A0, _A1, _A2),
2009 is_class<typename remove_reference<_Fn>::type>::value ||
2010 is_function<typename remove_reference<_Fn>::type>::value,
2011 is_member_pointer<typename remove_reference<_Fn>::type>::value
2016 #endif // _LIBCPP_HAS_NO_VARIADICS
2018 // template <class T, class... Args> struct is_constructible;
2020 namespace __is_construct
2025 #if __has_feature(is_constructible)
2027 template <class _Tp, class ..._Args>
2028 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2029 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2034 #ifndef _LIBCPP_HAS_NO_VARIADICS
2036 // main is_constructible test
2038 template <class _Tp, class ..._Args>
2039 typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
2040 __is_constructible_test(_Tp&&, _Args&& ...);
2042 template <class ..._Args>
2044 __is_constructible_test(__any, _Args&& ...);
2046 template <bool, class _Tp, class... _Args>
2047 struct __libcpp_is_constructible // false, _Tp is not a scalar
2048 : public common_type
2050 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
2054 // function types are not constructible
2056 template <class _Rp, class... _A1, class... _A2>
2057 struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
2061 // handle scalars and reference types
2063 // Scalars are default constructible, references are not
2065 template <class _Tp>
2066 struct __libcpp_is_constructible<true, _Tp>
2067 : public is_scalar<_Tp>
2070 // Scalars and references are constructible from one arg if that arg is
2071 // implicitly convertible to the scalar or reference.
2073 template <class _Tp>
2074 struct __is_constructible_ref
2076 true_type static __lxx(_Tp);
2077 false_type static __lxx(...);
2080 template <class _Tp, class _A0>
2081 struct __libcpp_is_constructible<true, _Tp, _A0>
2082 : public common_type
2084 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2088 // Scalars and references are not constructible from multiple args.
2090 template <class _Tp, class _A0, class ..._Args>
2091 struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
2095 // Treat scalars and reference types separately
2097 template <bool, class _Tp, class... _Args>
2098 struct __is_constructible_void_check
2099 : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2103 // If any of T or Args is void, is_constructible should be false
2105 template <class _Tp, class... _Args>
2106 struct __is_constructible_void_check<true, _Tp, _Args...>
2110 template <class ..._Args> struct __contains_void;
2112 template <> struct __contains_void<> : false_type {};
2114 template <class _A0, class ..._Args>
2115 struct __contains_void<_A0, _Args...>
2117 static const bool value = is_void<_A0>::value ||
2118 __contains_void<_Args...>::value;
2121 // is_constructible entry point
2123 template <class _Tp, class... _Args>
2124 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2125 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2126 || is_abstract<_Tp>::value,
2130 // Array types are default constructible if their element type
2131 // is default constructible
2133 template <class _Ap, size_t _Np>
2134 struct __libcpp_is_constructible<false, _Ap[_Np]>
2135 : public is_constructible<typename remove_all_extents<_Ap>::type>
2138 // Otherwise array types are not constructible by this syntax
2140 template <class _Ap, size_t _Np, class ..._Args>
2141 struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
2145 // Incomplete array types are not constructible
2147 template <class _Ap, class ..._Args>
2148 struct __libcpp_is_constructible<false, _Ap[], _Args...>
2152 #else // _LIBCPP_HAS_NO_VARIADICS
2154 // template <class T> struct is_constructible0;
2156 // main is_constructible0 test
2158 template <class _Tp>
2159 decltype((_Tp(), true_type()))
2160 __is_constructible0_test(_Tp&);
2163 __is_constructible0_test(__any);
2165 template <class _Tp, class _A0>
2166 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2167 __is_constructible1_test(_Tp&, _A0&);
2169 template <class _A0>
2171 __is_constructible1_test(__any, _A0&);
2173 template <class _Tp, class _A0, class _A1>
2174 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2175 __is_constructible2_test(_Tp&, _A0&, _A1&);
2177 template <class _A0, class _A1>
2179 __is_constructible2_test(__any, _A0&, _A1&);
2181 template <bool, class _Tp>
2182 struct __is_constructible0_imp // false, _Tp is not a scalar
2183 : public common_type
2185 decltype(__is_constructible0_test(declval<_Tp&>()))
2189 template <bool, class _Tp, class _A0>
2190 struct __is_constructible1_imp // false, _Tp is not a scalar
2191 : public common_type
2193 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2197 template <bool, class _Tp, class _A0, class _A1>
2198 struct __is_constructible2_imp // false, _Tp is not a scalar
2199 : public common_type
2201 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2205 // handle scalars and reference types
2207 // Scalars are default constructible, references are not
2209 template <class _Tp>
2210 struct __is_constructible0_imp<true, _Tp>
2211 : public is_scalar<_Tp>
2214 template <class _Tp, class _A0>
2215 struct __is_constructible1_imp<true, _Tp, _A0>
2216 : public is_convertible<_A0, _Tp>
2219 template <class _Tp, class _A0, class _A1>
2220 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
2224 // Treat scalars and reference types separately
2226 template <bool, class _Tp>
2227 struct __is_constructible0_void_check
2228 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2232 template <bool, class _Tp, class _A0>
2233 struct __is_constructible1_void_check
2234 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2238 template <bool, class _Tp, class _A0, class _A1>
2239 struct __is_constructible2_void_check
2240 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2244 // If any of T or Args is void, is_constructible should be false
2246 template <class _Tp>
2247 struct __is_constructible0_void_check<true, _Tp>
2251 template <class _Tp, class _A0>
2252 struct __is_constructible1_void_check<true, _Tp, _A0>
2256 template <class _Tp, class _A0, class _A1>
2257 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2261 // is_constructible entry point
2263 template <class _Tp, class _A0 = __is_construct::__nat,
2264 class _A1 = __is_construct::__nat>
2265 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2266 : public __is_constructible2_void_check<is_void<_Tp>::value
2267 || is_abstract<_Tp>::value
2268 || is_function<_Tp>::value
2269 || is_void<_A0>::value
2270 || is_void<_A1>::value,
2274 template <class _Tp>
2275 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2276 : public __is_constructible0_void_check<is_void<_Tp>::value
2277 || is_abstract<_Tp>::value
2278 || is_function<_Tp>::value,
2282 template <class _Tp, class _A0>
2283 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
2284 : public __is_constructible1_void_check<is_void<_Tp>::value
2285 || is_abstract<_Tp>::value
2286 || is_function<_Tp>::value
2287 || is_void<_A0>::value,
2291 // Array types are default constructible if their element type
2292 // is default constructible
2294 template <class _Ap, size_t _Np>
2295 struct __is_constructible0_imp<false, _Ap[_Np]>
2296 : public is_constructible<typename remove_all_extents<_Ap>::type>
2299 template <class _Ap, size_t _Np, class _A0>
2300 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
2304 template <class _Ap, size_t _Np, class _A0, class _A1>
2305 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2309 // Incomplete array types are not constructible
2311 template <class _Ap>
2312 struct __is_constructible0_imp<false, _Ap[]>
2316 template <class _Ap, class _A0>
2317 struct __is_constructible1_imp<false, _Ap[], _A0>
2321 template <class _Ap, class _A0, class _A1>
2322 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2326 #endif // _LIBCPP_HAS_NO_VARIADICS
2327 #endif // __has_feature(is_constructible)
2329 // is_default_constructible
2331 template <class _Tp>
2332 struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
2333 : public is_constructible<_Tp>
2336 // is_copy_constructible
2338 template <class _Tp>
2339 struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
2340 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2343 // is_move_constructible
2345 template <class _Tp>
2346 struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
2347 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2348 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2350 : public is_copy_constructible<_Tp>
2354 // is_trivially_constructible
2356 #ifndef _LIBCPP_HAS_NO_VARIADICS
2358 #if __has_feature(is_trivially_constructible)
2360 template <class _Tp, class... _Args>
2361 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2362 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2366 #else // !__has_feature(is_trivially_constructible)
2368 template <class _Tp, class... _Args>
2369 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2374 template <class _Tp>
2375 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
2376 #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2377 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2379 : integral_constant<bool, is_scalar<_Tp>::value>
2384 template <class _Tp>
2385 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2386 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
2388 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
2390 : integral_constant<bool, is_scalar<_Tp>::value>
2394 template <class _Tp>
2395 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
2396 : integral_constant<bool, is_scalar<_Tp>::value>
2400 template <class _Tp>
2401 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
2402 : integral_constant<bool, is_scalar<_Tp>::value>
2406 #endif // !__has_feature(is_trivially_constructible)
2408 #else // _LIBCPP_HAS_NO_VARIADICS
2410 template <class _Tp, class _A0 = __is_construct::__nat,
2411 class _A1 = __is_construct::__nat>
2412 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2417 #if __has_feature(is_trivially_constructible)
2419 template <class _Tp>
2420 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2421 __is_construct::__nat>
2422 : integral_constant<bool, __is_trivially_constructible(_Tp)>
2426 template <class _Tp>
2427 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2428 __is_construct::__nat>
2429 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2433 template <class _Tp>
2434 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2435 __is_construct::__nat>
2436 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2440 template <class _Tp>
2441 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2442 __is_construct::__nat>
2443 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2447 #else // !__has_feature(is_trivially_constructible)
2449 template <class _Tp>
2450 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2451 __is_construct::__nat>
2452 : integral_constant<bool, is_scalar<_Tp>::value>
2456 template <class _Tp>
2457 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2458 __is_construct::__nat>
2459 : integral_constant<bool, is_scalar<_Tp>::value>
2463 template <class _Tp>
2464 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2465 __is_construct::__nat>
2466 : integral_constant<bool, is_scalar<_Tp>::value>
2470 template <class _Tp>
2471 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2472 __is_construct::__nat>
2473 : integral_constant<bool, is_scalar<_Tp>::value>
2477 #endif // !__has_feature(is_trivially_constructible)
2479 #endif // _LIBCPP_HAS_NO_VARIADICS
2481 // is_trivially_default_constructible
2483 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
2484 : public is_trivially_constructible<_Tp>
2487 // is_trivially_copy_constructible
2489 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
2490 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2493 // is_trivially_move_constructible
2495 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
2496 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2497 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2499 : public is_trivially_copy_constructible<_Tp>
2503 // is_trivially_assignable
2505 #if __has_feature(is_trivially_constructible)
2507 template <class _Tp, class _Arg>
2508 struct is_trivially_assignable
2509 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2513 #else // !__has_feature(is_trivially_constructible)
2515 template <class _Tp, class _Arg>
2516 struct is_trivially_assignable
2517 : public false_type {};
2519 template <class _Tp>
2520 struct is_trivially_assignable<_Tp&, _Tp>
2521 : integral_constant<bool, is_scalar<_Tp>::value> {};
2523 template <class _Tp>
2524 struct is_trivially_assignable<_Tp&, _Tp&>
2525 : integral_constant<bool, is_scalar<_Tp>::value> {};
2527 template <class _Tp>
2528 struct is_trivially_assignable<_Tp&, const _Tp&>
2529 : integral_constant<bool, is_scalar<_Tp>::value> {};
2531 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2533 template <class _Tp>
2534 struct is_trivially_assignable<_Tp&, _Tp&&>
2535 : integral_constant<bool, is_scalar<_Tp>::value> {};
2537 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2539 #endif // !__has_feature(is_trivially_constructible)
2541 // is_trivially_copy_assignable
2543 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
2544 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2545 const typename add_lvalue_reference<_Tp>::type>
2548 // is_trivially_move_assignable
2550 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
2551 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2552 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2553 typename add_rvalue_reference<_Tp>::type>
2555 typename add_lvalue_reference<_Tp>::type>
2559 // is_trivially_destructible
2561 #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2563 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2564 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2566 #else // _LIBCPP_HAS_TYPE_TRAITS
2568 template <class _Tp> struct __libcpp_trivial_destructor
2569 : public integral_constant<bool, is_scalar<_Tp>::value ||
2570 is_reference<_Tp>::value> {};
2572 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2573 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2575 #endif // _LIBCPP_HAS_TYPE_TRAITS
2577 // is_nothrow_constructible
2580 template <class _Tp, class... _Args>
2581 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2582 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
2588 #ifndef _LIBCPP_HAS_NO_VARIADICS
2590 #if __has_feature(cxx_noexcept)
2592 template <bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
2594 template <class _Tp, class... _Args>
2595 struct __libcpp_is_nothrow_constructible<true, _Tp, _Args...>
2596 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2600 template <class _Tp, class... _Args>
2601 struct __libcpp_is_nothrow_constructible<false, _Tp, _Args...>
2606 template <class _Tp, class... _Args>
2607 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2608 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2612 template <class _Tp, size_t _Ns>
2613 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
2614 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2618 #else // __has_feature(cxx_noexcept)
2620 template <class _Tp, class... _Args>
2621 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2626 template <class _Tp>
2627 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
2628 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2629 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2631 : integral_constant<bool, is_scalar<_Tp>::value>
2636 template <class _Tp>
2637 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2638 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
2640 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
2642 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2643 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2645 : integral_constant<bool, is_scalar<_Tp>::value>
2650 template <class _Tp>
2651 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
2652 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2653 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2655 : integral_constant<bool, is_scalar<_Tp>::value>
2660 template <class _Tp>
2661 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
2662 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2663 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2665 : integral_constant<bool, is_scalar<_Tp>::value>
2670 #endif // __has_feature(cxx_noexcept)
2672 #else // _LIBCPP_HAS_NO_VARIADICS
2674 template <class _Tp, class _A0 = __is_construct::__nat,
2675 class _A1 = __is_construct::__nat>
2676 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2681 template <class _Tp>
2682 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
2683 __is_construct::__nat>
2684 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2685 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2687 : integral_constant<bool, is_scalar<_Tp>::value>
2692 template <class _Tp>
2693 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
2694 __is_construct::__nat>
2695 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2696 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2698 : integral_constant<bool, is_scalar<_Tp>::value>
2703 template <class _Tp>
2704 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
2705 __is_construct::__nat>
2706 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2707 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2709 : integral_constant<bool, is_scalar<_Tp>::value>
2714 template <class _Tp>
2715 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
2716 __is_construct::__nat>
2717 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2718 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2720 : integral_constant<bool, is_scalar<_Tp>::value>
2725 #endif // _LIBCPP_HAS_NO_VARIADICS
2726 #endif // __has_feature(is_nothrow_constructible)
2728 // is_nothrow_default_constructible
2730 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
2731 : public is_nothrow_constructible<_Tp>
2734 // is_nothrow_copy_constructible
2736 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
2737 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2740 // is_nothrow_move_constructible
2742 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
2743 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2744 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2746 : public is_nothrow_copy_constructible<_Tp>
2750 // is_nothrow_assignable
2752 #if __has_feature(cxx_noexcept)
2754 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
2756 template <class _Tp, class _Arg>
2757 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
2762 template <class _Tp, class _Arg>
2763 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
2764 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2768 template <class _Tp, class _Arg>
2769 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
2770 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2774 #else // __has_feature(cxx_noexcept)
2776 template <class _Tp, class _Arg>
2777 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
2778 : public false_type {};
2780 template <class _Tp>
2781 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
2782 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2783 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2785 : integral_constant<bool, is_scalar<_Tp>::value> {};
2788 template <class _Tp>
2789 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
2790 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2791 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2793 : integral_constant<bool, is_scalar<_Tp>::value> {};
2796 template <class _Tp>
2797 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
2798 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2799 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2801 : integral_constant<bool, is_scalar<_Tp>::value> {};
2804 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2806 template <class _Tp>
2807 struct is_nothrow_assignable<_Tp&, _Tp&&>
2808 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2809 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2811 : integral_constant<bool, is_scalar<_Tp>::value> {};
2814 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2816 #endif // __has_feature(cxx_noexcept)
2818 // is_nothrow_copy_assignable
2820 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
2821 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2822 const typename add_lvalue_reference<_Tp>::type>
2825 // is_nothrow_move_assignable
2827 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
2828 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2829 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2830 typename add_rvalue_reference<_Tp>::type>
2832 typename add_lvalue_reference<_Tp>::type>
2836 // is_nothrow_destructible
2838 #if __has_feature(cxx_noexcept)
2840 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
2842 template <class _Tp>
2843 struct __libcpp_is_nothrow_destructible<false, _Tp>
2848 template <class _Tp>
2849 struct __libcpp_is_nothrow_destructible<true, _Tp>
2850 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2854 template <class _Tp>
2855 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
2856 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2860 template <class _Tp, size_t _Ns>
2861 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
2862 : public is_nothrow_destructible<_Tp>
2866 template <class _Tp>
2867 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
2872 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2874 template <class _Tp>
2875 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
2884 template <class _Tp> struct __libcpp_nothrow_destructor
2885 : public integral_constant<bool, is_scalar<_Tp>::value ||
2886 is_reference<_Tp>::value> {};
2888 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
2889 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2895 #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2897 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
2898 : public integral_constant<bool, __is_pod(_Tp)> {};
2900 #else // _LIBCPP_HAS_TYPE_TRAITS
2902 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
2903 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
2904 is_trivially_copy_constructible<_Tp>::value &&
2905 is_trivially_copy_assignable<_Tp>::value &&
2906 is_trivially_destructible<_Tp>::value> {};
2908 #endif // _LIBCPP_HAS_TYPE_TRAITS
2912 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
2913 #if __has_feature(is_literal)
2914 : public integral_constant<bool, __is_literal(_Tp)>
2916 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2917 is_reference<typename remove_all_extents<_Tp>::type>::value>
2921 // is_standard_layout;
2923 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
2924 #if __has_feature(is_standard_layout)
2925 : public integral_constant<bool, __is_standard_layout(_Tp)>
2927 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2931 // is_trivially_copyable;
2933 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
2934 #if __has_feature(is_trivially_copyable)
2935 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2937 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2943 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
2944 #if __has_feature(is_trivial)
2945 : public integral_constant<bool, __is_trivial(_Tp)>
2947 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2948 is_trivially_default_constructible<_Tp>::value>
2952 #ifndef _LIBCPP_HAS_NO_VARIADICS
2954 // Check for complete types
2956 template <class ..._Tp> struct __check_complete;
2959 struct __check_complete<>
2963 template <class _Hp, class _T0, class ..._Tp>
2964 struct __check_complete<_Hp, _T0, _Tp...>
2965 : private __check_complete<_Hp>,
2966 private __check_complete<_T0, _Tp...>
2970 template <class _Hp>
2971 struct __check_complete<_Hp, _Hp>
2972 : private __check_complete<_Hp>
2976 template <class _Tp>
2977 struct __check_complete<_Tp>
2979 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2982 template <class _Tp>
2983 struct __check_complete<_Tp&>
2984 : private __check_complete<_Tp>
2988 template <class _Tp>
2989 struct __check_complete<_Tp&&>
2990 : private __check_complete<_Tp>
2994 template <class _Rp, class ..._Param>
2995 struct __check_complete<_Rp (*)(_Param...)>
2996 : private __check_complete<_Rp>
3000 template <class ..._Param>
3001 struct __check_complete<void (*)(_Param...)>
3005 template <class _Rp, class ..._Param>
3006 struct __check_complete<_Rp (_Param...)>
3007 : private __check_complete<_Rp>
3011 template <class ..._Param>
3012 struct __check_complete<void (_Param...)>
3016 template <class _Rp, class _Class, class ..._Param>
3017 struct __check_complete<_Rp (_Class::*)(_Param...)>
3018 : private __check_complete<_Class>
3022 template <class _Rp, class _Class, class ..._Param>
3023 struct __check_complete<_Rp (_Class::*)(_Param...) const>
3024 : private __check_complete<_Class>
3028 template <class _Rp, class _Class, class ..._Param>
3029 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
3030 : private __check_complete<_Class>
3034 template <class _Rp, class _Class, class ..._Param>
3035 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
3036 : private __check_complete<_Class>
3040 #if __has_feature(cxx_reference_qualified_functions)
3042 template <class _Rp, class _Class, class ..._Param>
3043 struct __check_complete<_Rp (_Class::*)(_Param...) &>
3044 : private __check_complete<_Class>
3048 template <class _Rp, class _Class, class ..._Param>
3049 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
3050 : private __check_complete<_Class>
3054 template <class _Rp, class _Class, class ..._Param>
3055 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
3056 : private __check_complete<_Class>
3060 template <class _Rp, class _Class, class ..._Param>
3061 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
3062 : private __check_complete<_Class>
3066 template <class _Rp, class _Class, class ..._Param>
3067 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
3068 : private __check_complete<_Class>
3072 template <class _Rp, class _Class, class ..._Param>
3073 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
3074 : private __check_complete<_Class>
3078 template <class _Rp, class _Class, class ..._Param>
3079 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
3080 : private __check_complete<_Class>
3084 template <class _Rp, class _Class, class ..._Param>
3085 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
3086 : private __check_complete<_Class>
3092 template <class _Rp, class _Class>
3093 struct __check_complete<_Rp _Class::*>
3094 : private __check_complete<_Class>
3098 // __invoke forward declarations
3100 // fall back - none of the bullets
3102 template <class ..._Args>
3104 __invoke(__any, _Args&& ...__args)
3109 template <class _Fp, class _A0, class ..._Args,
3110 class = typename enable_if
3112 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3113 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3114 typename remove_reference<_A0>::type>::value
3117 _LIBCPP_INLINE_VISIBILITY
3119 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3120 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
3122 template <class _Fp, class _A0, class ..._Args,
3123 class = typename enable_if
3125 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3126 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3127 typename remove_reference<_A0>::type>::value
3130 _LIBCPP_INLINE_VISIBILITY
3132 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3133 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
3137 template <class _Fp, class _A0,
3138 class = typename enable_if
3140 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3141 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3142 typename remove_reference<_A0>::type>::value
3145 _LIBCPP_INLINE_VISIBILITY
3147 __invoke(_Fp&& __f, _A0&& __a0)
3148 -> decltype(_VSTD::forward<_A0>(__a0).*__f);
3150 template <class _Fp, class _A0,
3151 class = typename enable_if
3153 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3154 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3155 typename remove_reference<_A0>::type>::value
3158 _LIBCPP_INLINE_VISIBILITY
3160 __invoke(_Fp&& __f, _A0&& __a0)
3161 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
3165 template <class _Fp, class ..._Args>
3166 _LIBCPP_INLINE_VISIBILITY
3168 __invoke(_Fp&& __f, _Args&& ...__args)
3169 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
3173 template <class _Fp, class ..._Args>
3174 struct __invokable_imp
3175 : private __check_complete<_Fp>
3178 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
3180 static const bool value = !is_same<type, __nat>::value;
3183 template <class _Fp, class ..._Args>
3185 : public integral_constant<bool,
3186 __invokable_imp<_Fp, _Args...>::value>
3192 template <bool _Invokable, class _Fp, class ..._Args>
3193 struct __invoke_of_imp // false
3197 template <class _Fp, class ..._Args>
3198 struct __invoke_of_imp<true, _Fp, _Args...>
3200 typedef typename __invokable_imp<_Fp, _Args...>::type type;
3203 template <class _Fp, class ..._Args>
3205 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
3209 template <class _Fp, class ..._Args>
3210 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
3211 : public __invoke_of<_Fp, _Args...>
3215 #if _LIBCPP_STD_VER > 11
3216 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3219 #endif // _LIBCPP_HAS_NO_VARIADICS
3221 template <class _Tp>
3222 inline _LIBCPP_INLINE_VISIBILITY
3223 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3226 is_move_constructible<_Tp>::value &&
3227 is_move_assignable<_Tp>::value
3232 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3233 is_nothrow_move_assignable<_Tp>::value)
3235 _Tp __t(_VSTD::move(__x));
3236 __x = _VSTD::move(__y);
3237 __y = _VSTD::move(__t);
3240 template <class _ForwardIterator1, class _ForwardIterator2>
3241 inline _LIBCPP_INLINE_VISIBILITY
3243 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3244 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3245 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3246 *_VSTD::declval<_ForwardIterator2>())))
3257 __nat swap(__any, __any);
3259 template <class _Tp>
3262 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3263 static const bool value = !is_same<type, __nat>::value;
3268 template <class _Tp>
3269 struct __is_swappable
3270 : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3274 #if __has_feature(cxx_noexcept)
3276 template <bool, class _Tp>
3277 struct __is_nothrow_swappable_imp
3278 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3279 _VSTD::declval<_Tp&>()))>
3283 template <class _Tp>
3284 struct __is_nothrow_swappable_imp<false, _Tp>
3289 template <class _Tp>
3290 struct __is_nothrow_swappable
3291 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3295 #else // __has_feature(cxx_noexcept)
3297 template <class _Tp>
3298 struct __is_nothrow_swappable
3303 #endif // __has_feature(cxx_noexcept)
3305 #ifdef _LIBCXX_UNDERLYING_TYPE
3307 template <class _Tp>
3308 struct underlying_type
3310 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3313 #if _LIBCPP_STD_VER > 11
3314 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3317 #else // _LIBCXX_UNDERLYING_TYPE
3319 template <class _Tp, bool _Support = false>
3320 struct underlying_type
3322 static_assert(_Support, "The underyling_type trait requires compiler "
3323 "support. Either no such support exists or "
3324 "libc++ does not know how to use it.");
3327 #endif // _LIBCXX_UNDERLYING_TYPE
3329 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3331 template <class _Tp>
3332 struct __has_operator_addressof_imp
3335 static auto __test(__any) -> false_type;
3336 template <class _Up>
3337 static auto __test(_Up* __u)
3338 -> typename __select_2nd<decltype(__u->operator&()), true_type>::type;
3340 static const bool value = decltype(__test<_Tp>(nullptr))::value;
3343 template <class _Tp>
3344 struct __has_operator_addressof
3345 : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value>
3348 #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
3350 _LIBCPP_END_NAMESPACE_STD
3352 #endif // _LIBCPP_TYPE_TRAITS