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_integral;
32 template <class T> struct is_floating_point;
33 template <class T> struct is_array;
34 template <class T> struct is_pointer;
35 template <class T> struct is_lvalue_reference;
36 template <class T> struct is_rvalue_reference;
37 template <class T> struct is_member_object_pointer;
38 template <class T> struct is_member_function_pointer;
39 template <class T> struct is_enum;
40 template <class T> struct is_union;
41 template <class T> struct is_class;
42 template <class T> struct is_function;
44 // Secondary classification traits:
45 template <class T> struct is_reference;
46 template <class T> struct is_arithmetic;
47 template <class T> struct is_fundamental;
48 template <class T> struct is_member_pointer;
49 template <class T> struct is_scalar;
50 template <class T> struct is_object;
51 template <class T> struct is_compound;
53 // Const-volatile properties and transformations:
54 template <class T> struct is_const;
55 template <class T> struct is_volatile;
56 template <class T> struct remove_const;
57 template <class T> struct remove_volatile;
58 template <class T> struct remove_cv;
59 template <class T> struct add_const;
60 template <class T> struct add_volatile;
61 template <class T> struct add_cv;
63 // Reference transformations:
64 template <class T> struct remove_reference;
65 template <class T> struct add_lvalue_reference;
66 template <class T> struct add_rvalue_reference;
68 // Pointer transformations:
69 template <class T> struct remove_pointer;
70 template <class T> struct add_pointer;
72 // Integral properties:
73 template <class T> struct is_signed;
74 template <class T> struct is_unsigned;
75 template <class T> struct make_signed;
76 template <class T> struct make_unsigned;
78 // Array properties and transformations:
79 template <class T> struct rank;
80 template <class T, unsigned I = 0> struct extent;
81 template <class T> struct remove_extent;
82 template <class T> struct remove_all_extents;
84 // Member introspection:
85 template <class T> struct is_pod;
86 template <class T> struct is_trivial;
87 template <class T> struct is_trivially_copyable;
88 template <class T> struct is_standard_layout;
89 template <class T> struct is_literal_type;
90 template <class T> struct is_empty;
91 template <class T> struct is_polymorphic;
92 template <class T> struct is_abstract;
94 template <class T, class... Args> struct is_constructible;
95 template <class T> struct is_default_constructible;
96 template <class T> struct is_copy_constructible;
97 template <class T> struct is_move_constructible;
98 template <class T, class U> struct is_assignable;
99 template <class T> struct is_copy_assignable;
100 template <class T> struct is_move_assignable;
101 template <class T> struct is_destructible;
103 template <class T, class... Args> struct is_trivially_constructible;
104 template <class T> struct is_trivially_default_constructible;
105 template <class T> struct is_trivially_copy_constructible;
106 template <class T> struct is_trivially_move_constructible;
107 template <class T, class U> struct is_trivially_assignable;
108 template <class T> struct is_trivially_copy_assignable;
109 template <class T> struct is_trivially_move_assignable;
110 template <class T> struct is_trivially_destructible;
112 template <class T, class... Args> struct is_nothrow_constructible;
113 template <class T> struct is_nothrow_default_constructible;
114 template <class T> struct is_nothrow_copy_constructible;
115 template <class T> struct is_nothrow_move_constructible;
116 template <class T, class U> struct is_nothrow_assignable;
117 template <class T> struct is_nothrow_copy_assignable;
118 template <class T> struct is_nothrow_move_assignable;
119 template <class T> struct is_nothrow_destructible;
121 template <class T> struct has_virtual_destructor;
123 // Relationships between types:
124 template <class T, class U> struct is_same;
125 template <class Base, class Derived> struct is_base_of;
126 template <class From, class To> struct is_convertible;
128 // Alignment properties and transformations:
129 template <class T> struct alignment_of;
130 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
131 struct aligned_storage;
132 template <size_t Len, class... Types> struct aligned_union;
134 template <class T> struct decay;
135 template <class... T> struct common_type;
136 template <class T> struct underlying_type;
137 template <class> class result_of; // undefined
138 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
140 // const-volatile modifications:
142 using remove_const_t = typename remove_const<T>::type; // C++14
144 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
146 using remove_cv_t = typename remove_cv<T>::type; // C++14
148 using add_const_t = typename add_const<T>::type; // C++14
150 using add_volatile_t = typename add_volatile<T>::type; // C++14
152 using add_cv_t = typename add_cv<T>::type; // C++14
154 // reference modifications:
156 using remove_reference_t = typename remove_reference<T>::type; // C++14
158 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
160 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
162 // sign modifications:
164 using make_signed_t = typename make_signed<T>::type; // C++14
166 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
168 // array modifications:
170 using remove_extent_t = typename remove_extent<T>::type; // C++14
172 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
174 // pointer modifications:
176 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
178 using add_pointer_t = typename add_pointer<T>::type; // C++14
180 // other transformations:
181 template <size_t Len, std::size_t Align=default-alignment>
182 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
183 template <std::size_t Len, class... Types>
184 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
186 using decay_t = typename decay<T>::type; // C++14
187 template <bool b, class T=void>
188 using enable_if_t = typename enable_if<b,T>::type; // C++14
189 template <bool b, class T, class F>
190 using conditional_t = typename conditional<b,T,F>::type; // C++14
191 template <class... T>
192 using common_type_t = typename common_type<T...>::type; // C++14
194 using underlying_type_t = typename underlying_type<T>::type; // C++14
195 template <class F, class... ArgTypes>
196 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
204 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
205 #pragma GCC system_header
208 _LIBCPP_BEGIN_NAMESPACE_STD
210 template <bool _Bp, class _If, class _Then>
211 struct _LIBCPP_TYPE_VIS conditional {typedef _If type;};
212 template <class _If, class _Then>
213 struct _LIBCPP_TYPE_VIS conditional<false, _If, _Then> {typedef _Then type;};
215 #if _LIBCPP_STD_VER > 11
216 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
219 template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS enable_if {};
220 template <class _Tp> struct _LIBCPP_TYPE_VIS enable_if<true, _Tp> {typedef _Tp type;};
222 #if _LIBCPP_STD_VER > 11
223 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
227 struct __two {char __lx[2];};
231 template <class _Tp, _Tp __v>
232 struct _LIBCPP_TYPE_VIS integral_constant
234 static _LIBCPP_CONSTEXPR const _Tp value = __v;
235 typedef _Tp value_type;
236 typedef integral_constant type;
237 _LIBCPP_INLINE_VISIBILITY
238 _LIBCPP_CONSTEXPR operator value_type() const {return value;}
241 template <class _Tp, _Tp __v>
242 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
244 typedef integral_constant<bool, true> true_type;
245 typedef integral_constant<bool, false> false_type;
249 template <class _Tp> struct _LIBCPP_TYPE_VIS is_const : public false_type {};
250 template <class _Tp> struct _LIBCPP_TYPE_VIS is_const<_Tp const> : public true_type {};
254 template <class _Tp> struct _LIBCPP_TYPE_VIS is_volatile : public false_type {};
255 template <class _Tp> struct _LIBCPP_TYPE_VIS is_volatile<_Tp volatile> : public true_type {};
259 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_const {typedef _Tp type;};
260 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_const<const _Tp> {typedef _Tp type;};
261 #if _LIBCPP_STD_VER > 11
262 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
267 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile {typedef _Tp type;};
268 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
269 #if _LIBCPP_STD_VER > 11
270 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
275 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_cv
276 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
277 #if _LIBCPP_STD_VER > 11
278 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
283 template <class _Tp> struct __is_void : public false_type {};
284 template <> struct __is_void<void> : public true_type {};
286 template <class _Tp> struct _LIBCPP_TYPE_VIS is_void
287 : public __is_void<typename remove_cv<_Tp>::type> {};
291 template <class _Tp> struct ____is_nullptr_t : public false_type {};
292 template <> struct ____is_nullptr_t<nullptr_t> : public true_type {};
294 template <class _Tp> struct _LIBCPP_TYPE_VIS __is_nullptr_t
295 : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {};
299 template <class _Tp> struct __is_integral : public false_type {};
300 template <> struct __is_integral<bool> : public true_type {};
301 template <> struct __is_integral<char> : public true_type {};
302 template <> struct __is_integral<signed char> : public true_type {};
303 template <> struct __is_integral<unsigned char> : public true_type {};
304 template <> struct __is_integral<wchar_t> : public true_type {};
305 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
306 template <> struct __is_integral<char16_t> : public true_type {};
307 template <> struct __is_integral<char32_t> : public true_type {};
308 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
309 template <> struct __is_integral<short> : public true_type {};
310 template <> struct __is_integral<unsigned short> : public true_type {};
311 template <> struct __is_integral<int> : public true_type {};
312 template <> struct __is_integral<unsigned int> : public true_type {};
313 template <> struct __is_integral<long> : public true_type {};
314 template <> struct __is_integral<unsigned long> : public true_type {};
315 template <> struct __is_integral<long long> : public true_type {};
316 template <> struct __is_integral<unsigned long long> : public true_type {};
318 template <class _Tp> struct _LIBCPP_TYPE_VIS is_integral
319 : public __is_integral<typename remove_cv<_Tp>::type> {};
323 template <class _Tp> struct __is_floating_point : public false_type {};
324 template <> struct __is_floating_point<float> : public true_type {};
325 template <> struct __is_floating_point<double> : public true_type {};
326 template <> struct __is_floating_point<long double> : public true_type {};
328 template <class _Tp> struct _LIBCPP_TYPE_VIS is_floating_point
329 : public __is_floating_point<typename remove_cv<_Tp>::type> {};
333 template <class _Tp> struct _LIBCPP_TYPE_VIS is_array
334 : public false_type {};
335 template <class _Tp> struct _LIBCPP_TYPE_VIS is_array<_Tp[]>
336 : public true_type {};
337 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS is_array<_Tp[_Np]>
338 : public true_type {};
342 template <class _Tp> struct __is_pointer : public false_type {};
343 template <class _Tp> struct __is_pointer<_Tp*> : public true_type {};
345 template <class _Tp> struct _LIBCPP_TYPE_VIS is_pointer
346 : public __is_pointer<typename remove_cv<_Tp>::type> {};
350 template <class _Tp> struct _LIBCPP_TYPE_VIS is_lvalue_reference : public false_type {};
351 template <class _Tp> struct _LIBCPP_TYPE_VIS is_lvalue_reference<_Tp&> : public true_type {};
353 template <class _Tp> struct _LIBCPP_TYPE_VIS is_rvalue_reference : public false_type {};
354 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
355 template <class _Tp> struct _LIBCPP_TYPE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
358 template <class _Tp> struct _LIBCPP_TYPE_VIS is_reference : public false_type {};
359 template <class _Tp> struct _LIBCPP_TYPE_VIS is_reference<_Tp&> : public true_type {};
360 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
361 template <class _Tp> struct _LIBCPP_TYPE_VIS is_reference<_Tp&&> : public true_type {};
364 #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
365 #define _LIBCPP_HAS_TYPE_TRAITS
370 #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
372 template <class _Tp> struct _LIBCPP_TYPE_VIS is_union
373 : public integral_constant<bool, __is_union(_Tp)> {};
377 template <class _Tp> struct __libcpp_union : public false_type {};
378 template <class _Tp> struct _LIBCPP_TYPE_VIS is_union
379 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
385 #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
387 template <class _Tp> struct _LIBCPP_TYPE_VIS is_class
388 : public integral_constant<bool, __is_class(_Tp)> {};
392 namespace __is_class_imp
394 template <class _Tp> char __test(int _Tp::*);
395 template <class _Tp> __two __test(...);
398 template <class _Tp> struct _LIBCPP_TYPE_VIS is_class
399 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
405 template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS is_same : public false_type {};
406 template <class _Tp> struct _LIBCPP_TYPE_VIS is_same<_Tp, _Tp> : public true_type {};
410 namespace __is_function_imp
412 template <class _Tp> char __test(_Tp*);
413 template <class _Tp> __two __test(...);
414 template <class _Tp> _Tp& __source();
417 template <class _Tp, bool = is_class<_Tp>::value ||
418 is_union<_Tp>::value ||
419 is_void<_Tp>::value ||
420 is_reference<_Tp>::value ||
421 is_same<_Tp, nullptr_t>::value >
423 : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1>
425 template <class _Tp> struct __is_function<_Tp, true> : public false_type {};
427 template <class _Tp> struct _LIBCPP_TYPE_VIS is_function
428 : public __is_function<_Tp> {};
430 // is_member_function_pointer
432 template <class _Tp> struct __is_member_function_pointer : public false_type {};
433 template <class _Tp, class _Up> struct __is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
435 template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_function_pointer
436 : public __is_member_function_pointer<typename remove_cv<_Tp>::type> {};
440 template <class _Tp> struct __is_member_pointer : public false_type {};
441 template <class _Tp, class _Up> struct __is_member_pointer<_Tp _Up::*> : public true_type {};
443 template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_pointer
444 : public __is_member_pointer<typename remove_cv<_Tp>::type> {};
446 // is_member_object_pointer
448 template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_object_pointer
449 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
450 !is_member_function_pointer<_Tp>::value> {};
454 #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
456 template <class _Tp> struct _LIBCPP_TYPE_VIS is_enum
457 : public integral_constant<bool, __is_enum(_Tp)> {};
461 template <class _Tp> struct _LIBCPP_TYPE_VIS is_enum
462 : public integral_constant<bool, !is_void<_Tp>::value &&
463 !is_integral<_Tp>::value &&
464 !is_floating_point<_Tp>::value &&
465 !is_array<_Tp>::value &&
466 !is_pointer<_Tp>::value &&
467 !is_reference<_Tp>::value &&
468 !is_member_pointer<_Tp>::value &&
469 !is_union<_Tp>::value &&
470 !is_class<_Tp>::value &&
471 !is_function<_Tp>::value > {};
477 template <class _Tp> struct _LIBCPP_TYPE_VIS is_arithmetic
478 : public integral_constant<bool, is_integral<_Tp>::value ||
479 is_floating_point<_Tp>::value> {};
483 template <class _Tp> struct _LIBCPP_TYPE_VIS is_fundamental
484 : public integral_constant<bool, is_void<_Tp>::value ||
485 __is_nullptr_t<_Tp>::value ||
486 is_arithmetic<_Tp>::value> {};
490 template <class _Tp> struct _LIBCPP_TYPE_VIS is_scalar
491 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
492 is_member_pointer<_Tp>::value ||
493 is_pointer<_Tp>::value ||
494 __is_nullptr_t<_Tp>::value ||
495 is_enum<_Tp>::value > {};
497 template <> struct _LIBCPP_TYPE_VIS is_scalar<nullptr_t> : public true_type {};
501 template <class _Tp> struct _LIBCPP_TYPE_VIS is_object
502 : public integral_constant<bool, is_scalar<_Tp>::value ||
503 is_array<_Tp>::value ||
504 is_union<_Tp>::value ||
505 is_class<_Tp>::value > {};
509 template <class _Tp> struct _LIBCPP_TYPE_VIS is_compound
510 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
514 template <class _Tp, bool = is_reference<_Tp>::value ||
515 is_function<_Tp>::value ||
516 is_const<_Tp>::value >
517 struct __add_const {typedef _Tp type;};
520 struct __add_const<_Tp, false> {typedef const _Tp type;};
522 template <class _Tp> struct _LIBCPP_TYPE_VIS add_const
523 {typedef typename __add_const<_Tp>::type type;};
525 #if _LIBCPP_STD_VER > 11
526 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
531 template <class _Tp, bool = is_reference<_Tp>::value ||
532 is_function<_Tp>::value ||
533 is_volatile<_Tp>::value >
534 struct __add_volatile {typedef _Tp type;};
537 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
539 template <class _Tp> struct _LIBCPP_TYPE_VIS add_volatile
540 {typedef typename __add_volatile<_Tp>::type type;};
542 #if _LIBCPP_STD_VER > 11
543 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
548 template <class _Tp> struct _LIBCPP_TYPE_VIS add_cv
549 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
551 #if _LIBCPP_STD_VER > 11
552 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
557 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference {typedef _Tp type;};
558 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&> {typedef _Tp type;};
559 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
560 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
563 #if _LIBCPP_STD_VER > 11
564 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
567 // add_lvalue_reference
569 template <class _Tp> struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef _Tp& type;};
570 template <class _Tp> struct _LIBCPP_TYPE_VIS add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
571 template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<void> {typedef void type;};
572 template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<const void> {typedef const void type;};
573 template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<volatile void> {typedef volatile void type;};
574 template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<const volatile void> {typedef const volatile void type;};
576 #if _LIBCPP_STD_VER > 11
577 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
580 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
582 template <class _Tp> struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef _Tp&& type;};
583 template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<void> {typedef void type;};
584 template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<const void> {typedef const void type;};
585 template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<volatile void> {typedef volatile void type;};
586 template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<const volatile void> {typedef const volatile void type;};
588 #if _LIBCPP_STD_VER > 11
589 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
592 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
594 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
597 typename add_rvalue_reference<_Tp>::type
600 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
603 typename add_lvalue_reference<_Tp>::type
606 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
615 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer {typedef _Tp type;};
616 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
617 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
618 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
619 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
621 #if _LIBCPP_STD_VER > 11
622 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
627 template <class _Tp> struct _LIBCPP_TYPE_VIS add_pointer
628 {typedef typename remove_reference<_Tp>::type* type;};
630 #if _LIBCPP_STD_VER > 11
631 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
636 template <class _Tp, bool = is_integral<_Tp>::value>
637 struct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
640 struct ___is_signed<_Tp, false> : public true_type {}; // floating point
642 template <class _Tp, bool = is_arithmetic<_Tp>::value>
643 struct __is_signed : public ___is_signed<_Tp> {};
645 template <class _Tp> struct __is_signed<_Tp, false> : public false_type {};
647 template <class _Tp> struct _LIBCPP_TYPE_VIS is_signed : public __is_signed<_Tp> {};
651 template <class _Tp, bool = is_integral<_Tp>::value>
652 struct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
655 struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point
657 template <class _Tp, bool = is_arithmetic<_Tp>::value>
658 struct __is_unsigned : public ___is_unsigned<_Tp> {};
660 template <class _Tp> struct __is_unsigned<_Tp, false> : public false_type {};
662 template <class _Tp> struct _LIBCPP_TYPE_VIS is_unsigned : public __is_unsigned<_Tp> {};
666 template <class _Tp> struct _LIBCPP_TYPE_VIS rank
667 : public integral_constant<size_t, 0> {};
668 template <class _Tp> struct _LIBCPP_TYPE_VIS rank<_Tp[]>
669 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
670 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS rank<_Tp[_Np]>
671 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
675 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS extent
676 : public integral_constant<size_t, 0> {};
677 template <class _Tp> struct _LIBCPP_TYPE_VIS extent<_Tp[], 0>
678 : public integral_constant<size_t, 0> {};
679 template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS extent<_Tp[], _Ip>
680 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
681 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], 0>
682 : public integral_constant<size_t, _Np> {};
683 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], _Ip>
684 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
688 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_extent
690 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[]>
692 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[_Np]>
695 #if _LIBCPP_STD_VER > 11
696 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
699 // remove_all_extents
701 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents
703 template <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[]>
704 {typedef typename remove_all_extents<_Tp>::type type;};
705 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[_Np]>
706 {typedef typename remove_all_extents<_Tp>::type type;};
708 #if _LIBCPP_STD_VER > 11
709 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
714 namespace __is_abstract_imp
716 template <class _Tp> char __test(_Tp (*)[1]);
717 template <class _Tp> __two __test(...);
720 template <class _Tp, bool = is_class<_Tp>::value>
721 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
723 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
725 template <class _Tp> struct _LIBCPP_TYPE_VIS is_abstract : public __libcpp_abstract<_Tp> {};
729 #ifdef _LIBCP_HAS_IS_BASE_OF
731 template <class _Bp, class _Dp>
732 struct _LIBCPP_TYPE_VIS is_base_of
733 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
735 #else // __has_feature(is_base_of)
737 namespace __is_base_of_imp
742 _Dst(const volatile _Tp &);
747 operator const volatile _Tp &();
748 template <class _Up> operator const _Dst<_Up> &();
750 template <size_t> struct __one { typedef char type; };
751 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
752 template <class _Bp, class _Dp> __two __test(...);
755 template <class _Bp, class _Dp>
756 struct _LIBCPP_TYPE_VIS is_base_of
757 : public integral_constant<bool, is_class<_Bp>::value &&
758 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
760 #endif // __has_feature(is_base_of)
764 #if __has_feature(is_convertible_to)
766 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS is_convertible
767 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
768 !is_abstract<_T2>::value> {};
770 #else // __has_feature(is_convertible_to)
772 namespace __is_convertible_imp
774 template <class _Tp> char __test(_Tp);
775 template <class _Tp> __two __test(...);
776 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
777 template <class _Tp> _Tp&& __source();
779 template <class _Tp> typename remove_reference<_Tp>::type& __source();
782 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
783 bool _IsFunction = is_function<_Tp>::value,
784 bool _IsVoid = is_void<_Tp>::value>
785 struct __is_array_function_or_void {enum {value = 0};};
786 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
787 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
788 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
792 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
793 struct __is_convertible_check
795 static const size_t __v = 0;
799 struct __is_convertible_check<_Tp, 0>
801 static const size_t __v = sizeof(_Tp);
804 template <class _T1, class _T2,
805 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
806 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
807 struct __is_convertible
808 : public integral_constant<bool,
809 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
810 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
812 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
813 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
814 && (!is_const<typename remove_reference<_T2>::type>::value
815 || is_volatile<typename remove_reference<_T2>::type>::value)
816 && (is_same<typename remove_cv<_T1>::type,
817 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
818 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
823 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
825 template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
826 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
827 template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
828 template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
829 template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
830 template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
831 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
833 template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
834 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
836 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
837 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
839 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
840 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
842 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
843 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
845 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
846 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
847 template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
849 template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
850 template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
851 template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
852 template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
853 template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
855 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
857 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
858 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
859 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
860 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
862 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
863 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
864 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
865 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
867 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
868 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
869 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
870 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
872 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS is_convertible
873 : public __is_convertible<_T1, _T2>
875 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
876 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
879 #endif // __has_feature(is_convertible_to)
883 #if __has_feature(is_empty)
886 struct _LIBCPP_TYPE_VIS is_empty
887 : public integral_constant<bool, __is_empty(_Tp)> {};
889 #else // __has_feature(is_empty)
903 template <class _Tp, bool = is_class<_Tp>::value>
904 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
906 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
908 template <class _Tp> struct _LIBCPP_TYPE_VIS is_empty : public __libcpp_empty<_Tp> {};
910 #endif // __has_feature(is_empty)
914 #if __has_feature(is_polymorphic)
917 struct _LIBCPP_TYPE_VIS is_polymorphic
918 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
922 template<typename _Tp> char &__is_polymorphic_impl(
923 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
925 template<typename _Tp> __two &__is_polymorphic_impl(...);
927 template <class _Tp> struct _LIBCPP_TYPE_VIS is_polymorphic
928 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
930 #endif // __has_feature(is_polymorphic)
932 // has_virtual_destructor
934 #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
936 template <class _Tp> struct _LIBCPP_TYPE_VIS has_virtual_destructor
937 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
939 #else // _LIBCPP_HAS_TYPE_TRAITS
941 template <class _Tp> struct _LIBCPP_TYPE_VIS has_virtual_destructor
942 : public false_type {};
944 #endif // _LIBCPP_HAS_TYPE_TRAITS
948 template <class _Tp> struct _LIBCPP_TYPE_VIS alignment_of
949 : public integral_constant<size_t, __alignof__(_Tp)> {};
953 template <class _Hp, class _Tp>
962 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
964 __nat(const __nat&) = delete;
965 __nat& operator=(const __nat&) = delete;
973 static const size_t value = alignment_of<_Tp>::value;
977 struct __struct_double {long double __lx;};
978 struct __struct_double4 {double __lx[4];};
981 __type_list<__align_type<unsigned char>,
982 __type_list<__align_type<unsigned short>,
983 __type_list<__align_type<unsigned int>,
984 __type_list<__align_type<unsigned long>,
985 __type_list<__align_type<unsigned long long>,
986 __type_list<__align_type<double>,
987 __type_list<__align_type<long double>,
988 __type_list<__align_type<__struct_double>,
989 __type_list<__align_type<__struct_double4>,
990 __type_list<__align_type<int*>,
992 > > > > > > > > > > __all_types;
994 template <class _TL, size_t _Align> struct __find_pod;
996 template <class _Hp, size_t _Align>
997 struct __find_pod<__type_list<_Hp, __nat>, _Align>
999 typedef typename conditional<
1000 _Align == _Hp::value,
1006 template <class _Hp, class _Tp, size_t _Align>
1007 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1009 typedef typename conditional<
1010 _Align == _Hp::value,
1012 typename __find_pod<_Tp, _Align>::type
1016 template <class _TL, size_t _Len> struct __find_max_align;
1018 template <class _Hp, size_t _Len>
1019 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1021 template <size_t _Len, size_t _A1, size_t _A2>
1022 struct __select_align
1025 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1026 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1028 static const size_t value = _Len < __max ? __min : __max;
1031 template <class _Hp, class _Tp, size_t _Len>
1032 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1033 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1035 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1036 struct _LIBCPP_TYPE_VIS aligned_storage
1038 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1039 static_assert(!is_void<_Aligner>::value, "");
1043 unsigned char __data[_Len];
1047 #if _LIBCPP_STD_VER > 11
1048 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1049 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1052 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1053 template <size_t _Len>\
1054 struct _LIBCPP_TYPE_VIS aligned_storage<_Len, n>\
1056 struct _ALIGNAS(n) type\
1058 unsigned char __lx[_Len];\
1062 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1063 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1064 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1065 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1066 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1067 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1068 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1069 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1070 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1071 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1072 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1073 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1074 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1075 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1076 // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1077 #if !defined(_MSC_VER)
1078 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1081 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1083 #ifndef _LIBCPP_HAS_NO_VARIADICS
1087 template <size_t _I0, size_t ..._In>
1088 struct __static_max;
1090 template <size_t _I0>
1091 struct __static_max<_I0>
1093 static const size_t value = _I0;
1096 template <size_t _I0, size_t _I1, size_t ..._In>
1097 struct __static_max<_I0, _I1, _In...>
1099 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1100 __static_max<_I1, _In...>::value;
1103 template <size_t _Len, class _Type0, class ..._Types>
1104 struct aligned_union
1106 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1107 __alignof__(_Types)...>::value;
1108 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1109 sizeof(_Types)...>::value;
1110 typedef typename aligned_storage<__len, alignment_value>::type type;
1113 #if _LIBCPP_STD_VER > 11
1114 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1117 #endif // _LIBCPP_HAS_NO_VARIADICS
1121 template <class _A1, class _A2 = void, class _A3 = void,
1122 bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
1123 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
1124 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
1127 template <class _A1, class _A2, class _A3>
1128 class __promote<_A1, _A2, _A3, true>
1131 typedef typename __promote<_A1>::type __type1;
1132 typedef typename __promote<_A2>::type __type2;
1133 typedef typename __promote<_A3>::type __type3;
1135 typedef decltype(__type1() + __type2() + __type3()) type;
1138 template <class _A1, class _A2>
1139 class __promote<_A1, _A2, void, true>
1142 typedef typename __promote<_A1>::type __type1;
1143 typedef typename __promote<_A2>::type __type2;
1145 typedef decltype(__type1() + __type2()) type;
1148 template <class _A1>
1149 class __promote<_A1, void, void, true>
1152 typedef typename conditional<is_arithmetic<_A1>::value,
1153 typename conditional<is_integral<_A1>::value, double, _A1>::type,
1158 #ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1162 template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1163 template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;};
1164 template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;};
1165 template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;};
1166 template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1168 #endif // _LIBCPP_STORE_AS_OPTIMIZATION
1170 // make_signed / make_unsigned
1173 __type_list<signed char,
1174 __type_list<signed short,
1175 __type_list<signed int,
1176 __type_list<signed long,
1177 __type_list<signed long long,
1179 > > > > > __signed_types;
1182 __type_list<unsigned char,
1183 __type_list<unsigned short,
1184 __type_list<unsigned int,
1185 __type_list<unsigned long,
1186 __type_list<unsigned long long,
1188 > > > > > __unsigned_types;
1190 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1192 template <class _Hp, class _Tp, size_t _Size>
1193 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1198 template <class _Hp, class _Tp, size_t _Size>
1199 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1201 typedef typename __find_first<_Tp, _Size>::type type;
1204 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1205 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1211 template <class _Tp, class _Up>
1212 struct __apply_cv<_Tp, _Up, true, false>
1214 typedef const _Up type;
1217 template <class _Tp, class _Up>
1218 struct __apply_cv<_Tp, _Up, false, true>
1220 typedef volatile _Up type;
1223 template <class _Tp, class _Up>
1224 struct __apply_cv<_Tp, _Up, true, true>
1226 typedef const volatile _Up type;
1229 template <class _Tp, class _Up>
1230 struct __apply_cv<_Tp&, _Up, false, false>
1235 template <class _Tp, class _Up>
1236 struct __apply_cv<_Tp&, _Up, true, false>
1238 typedef const _Up& type;
1241 template <class _Tp, class _Up>
1242 struct __apply_cv<_Tp&, _Up, false, true>
1244 typedef volatile _Up& type;
1247 template <class _Tp, class _Up>
1248 struct __apply_cv<_Tp&, _Up, true, true>
1250 typedef const volatile _Up& type;
1253 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1254 struct __make_signed {};
1256 template <class _Tp>
1257 struct __make_signed<_Tp, true>
1259 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1262 template <> struct __make_signed<bool, true> {};
1263 template <> struct __make_signed< signed short, true> {typedef short type;};
1264 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1265 template <> struct __make_signed< signed int, true> {typedef int type;};
1266 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1267 template <> struct __make_signed< signed long, true> {typedef long type;};
1268 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1269 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1270 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1272 template <class _Tp>
1273 struct _LIBCPP_TYPE_VIS make_signed
1275 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1278 #if _LIBCPP_STD_VER > 11
1279 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1282 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1283 struct __make_unsigned {};
1285 template <class _Tp>
1286 struct __make_unsigned<_Tp, true>
1288 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1291 template <> struct __make_unsigned<bool, true> {};
1292 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1293 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1294 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1295 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1296 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1297 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1298 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1299 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1301 template <class _Tp>
1302 struct _LIBCPP_TYPE_VIS make_unsigned
1304 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1307 #if _LIBCPP_STD_VER > 11
1308 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1311 #ifdef _LIBCPP_HAS_NO_VARIADICS
1313 template <class _Tp, class _Up = void, class V = void>
1314 struct _LIBCPP_TYPE_VIS common_type
1317 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1320 template <class _Tp>
1321 struct _LIBCPP_TYPE_VIS common_type<_Tp, void, void>
1327 template <class _Tp, class _Up>
1328 struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, void>
1331 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1334 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1337 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1339 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1342 #else // _LIBCPP_HAS_NO_VARIADICS
1344 template <class ..._Tp> struct common_type;
1346 template <class _Tp>
1347 struct _LIBCPP_TYPE_VIS common_type<_Tp>
1352 template <class _Tp, class _Up>
1353 struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up>
1360 typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type;
1363 template <class _Tp, class _Up, class ..._Vp>
1364 struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, _Vp...>
1366 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1369 #if _LIBCPP_STD_VER > 11
1370 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1373 #endif // _LIBCPP_HAS_NO_VARIADICS
1377 template <class _Tp, class _Arg>
1378 decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type()))
1379 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1380 __is_assignable_test(_Tp&&, _Arg&&);
1382 __is_assignable_test(_Tp, _Arg&);
1385 template <class _Arg>
1387 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1388 __is_assignable_test(__any, _Arg&&);
1390 __is_assignable_test(__any, _Arg&);
1393 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1394 struct __is_assignable_imp
1395 : public common_type
1397 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1400 template <class _Tp, class _Arg>
1401 struct __is_assignable_imp<_Tp, _Arg, true>
1406 template <class _Tp, class _Arg>
1407 struct is_assignable
1408 : public __is_assignable_imp<_Tp, _Arg> {};
1410 // is_copy_assignable
1412 template <class _Tp> struct _LIBCPP_TYPE_VIS is_copy_assignable
1413 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1414 const typename add_lvalue_reference<_Tp>::type> {};
1416 // is_move_assignable
1418 template <class _Tp> struct _LIBCPP_TYPE_VIS is_move_assignable
1419 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1420 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1421 const typename add_rvalue_reference<_Tp>::type> {};
1423 : public is_copy_assignable<_Tp> {};
1428 template <class _Tp>
1429 struct __destructible_test
1434 template <class _Tp>
1435 decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1436 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1437 __is_destructible_test(_Tp&&);
1439 __is_destructible_test(_Tp&);
1443 __is_destructible_test(__any);
1445 template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value>
1446 struct __destructible_imp
1447 : public common_type
1449 decltype(__is_destructible_test(declval<_Tp>()))
1452 template <class _Tp>
1453 struct __destructible_imp<_Tp, true>
1454 : public false_type {};
1456 template <class _Tp>
1457 struct is_destructible
1458 : public __destructible_imp<_Tp> {};
1462 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1464 template <class _Tp>
1465 inline _LIBCPP_INLINE_VISIBILITY
1466 typename remove_reference<_Tp>::type&&
1467 move(_Tp&& __t) _NOEXCEPT
1469 typedef typename remove_reference<_Tp>::type _Up;
1470 return static_cast<_Up&&>(__t);
1473 template <class _Tp>
1474 inline _LIBCPP_INLINE_VISIBILITY
1476 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1478 return static_cast<_Tp&&>(__t);
1481 template <class _Tp>
1482 inline _LIBCPP_INLINE_VISIBILITY
1484 forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1486 static_assert(!std::is_lvalue_reference<_Tp>::value,
1487 "Can not forward an rvalue as an lvalue.");
1488 return static_cast<_Tp&&>(__t);
1491 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1493 template <class _Tp>
1494 inline _LIBCPP_INLINE_VISIBILITY
1501 template <class _Tp>
1502 inline _LIBCPP_INLINE_VISIBILITY
1504 move(const _Tp& __t)
1509 template <class _Tp>
1510 inline _LIBCPP_INLINE_VISIBILITY
1512 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1518 template <class _Tp>
1521 typedef typename remove_reference<_Tp>::type _Trr;
1524 _LIBCPP_INLINE_VISIBILITY
1525 _Trr* operator->() {return &t_;}
1526 _LIBCPP_INLINE_VISIBILITY
1527 explicit __rv(_Trr& __t) : t_(__t) {}
1530 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1532 template <class _Tp>
1533 struct _LIBCPP_TYPE_VIS decay
1536 typedef typename remove_reference<_Tp>::type _Up;
1538 typedef typename conditional
1540 is_array<_Up>::value,
1541 typename remove_extent<_Up>::type*,
1542 typename conditional
1544 is_function<_Up>::value,
1545 typename add_pointer<_Up>::type,
1546 typename remove_cv<_Up>::type
1551 #if _LIBCPP_STD_VER > 11
1552 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1555 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1557 template <class _Tp>
1558 inline _LIBCPP_INLINE_VISIBILITY
1559 typename decay<_Tp>::type
1560 __decay_copy(_Tp&& __t)
1562 return _VSTD::forward<_Tp>(__t);
1567 template <class _Tp>
1568 inline _LIBCPP_INLINE_VISIBILITY
1569 typename decay<_Tp>::type
1570 __decay_copy(const _Tp& __t)
1572 return _VSTD::forward<_Tp>(__t);
1577 template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1578 struct __member_pointer_traits_imp
1582 #ifndef _LIBCPP_HAS_NO_VARIADICS
1584 template <class _Rp, class _Class, class ..._Param>
1585 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1587 typedef _Class _ClassType;
1588 typedef _Rp _ReturnType;
1591 template <class _Rp, class _Class, class ..._Param>
1592 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1594 typedef _Class const _ClassType;
1595 typedef _Rp _ReturnType;
1598 template <class _Rp, class _Class, class ..._Param>
1599 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1601 typedef _Class volatile _ClassType;
1602 typedef _Rp _ReturnType;
1605 template <class _Rp, class _Class, class ..._Param>
1606 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1608 typedef _Class const volatile _ClassType;
1609 typedef _Rp _ReturnType;
1612 #if __has_feature(cxx_reference_qualified_functions)
1614 template <class _Rp, class _Class, class ..._Param>
1615 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1617 typedef _Class& _ClassType;
1618 typedef _Rp _ReturnType;
1621 template <class _Rp, class _Class, class ..._Param>
1622 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1624 typedef _Class const& _ClassType;
1625 typedef _Rp _ReturnType;
1628 template <class _Rp, class _Class, class ..._Param>
1629 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1631 typedef _Class volatile& _ClassType;
1632 typedef _Rp _ReturnType;
1635 template <class _Rp, class _Class, class ..._Param>
1636 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1638 typedef _Class const volatile& _ClassType;
1639 typedef _Rp _ReturnType;
1642 template <class _Rp, class _Class, class ..._Param>
1643 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1645 typedef _Class&& _ClassType;
1646 typedef _Rp _ReturnType;
1649 template <class _Rp, class _Class, class ..._Param>
1650 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1652 typedef _Class const&& _ClassType;
1653 typedef _Rp _ReturnType;
1656 template <class _Rp, class _Class, class ..._Param>
1657 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1659 typedef _Class volatile&& _ClassType;
1660 typedef _Rp _ReturnType;
1663 template <class _Rp, class _Class, class ..._Param>
1664 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1666 typedef _Class const volatile&& _ClassType;
1667 typedef _Rp _ReturnType;
1670 #endif // __has_feature(cxx_reference_qualified_functions)
1672 #else // _LIBCPP_HAS_NO_VARIADICS
1674 template <class _Rp, class _Class>
1675 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1677 typedef _Class _ClassType;
1678 typedef _Rp _ReturnType;
1681 template <class _Rp, class _Class, class _P0>
1682 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1684 typedef _Class _ClassType;
1685 typedef _Rp _ReturnType;
1688 template <class _Rp, class _Class, class _P0, class _P1>
1689 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1691 typedef _Class _ClassType;
1692 typedef _Rp _ReturnType;
1695 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1696 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1698 typedef _Class _ClassType;
1699 typedef _Rp _ReturnType;
1702 template <class _Rp, class _Class>
1703 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1705 typedef _Class const _ClassType;
1706 typedef _Rp _ReturnType;
1709 template <class _Rp, class _Class, class _P0>
1710 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1712 typedef _Class const _ClassType;
1713 typedef _Rp _ReturnType;
1716 template <class _Rp, class _Class, class _P0, class _P1>
1717 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1719 typedef _Class const _ClassType;
1720 typedef _Rp _ReturnType;
1723 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1724 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1726 typedef _Class const _ClassType;
1727 typedef _Rp _ReturnType;
1730 template <class _Rp, class _Class>
1731 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1733 typedef _Class volatile _ClassType;
1734 typedef _Rp _ReturnType;
1737 template <class _Rp, class _Class, class _P0>
1738 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1740 typedef _Class volatile _ClassType;
1741 typedef _Rp _ReturnType;
1744 template <class _Rp, class _Class, class _P0, class _P1>
1745 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1747 typedef _Class volatile _ClassType;
1748 typedef _Rp _ReturnType;
1751 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1752 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1754 typedef _Class volatile _ClassType;
1755 typedef _Rp _ReturnType;
1758 template <class _Rp, class _Class>
1759 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1761 typedef _Class const volatile _ClassType;
1762 typedef _Rp _ReturnType;
1765 template <class _Rp, class _Class, class _P0>
1766 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1768 typedef _Class const volatile _ClassType;
1769 typedef _Rp _ReturnType;
1772 template <class _Rp, class _Class, class _P0, class _P1>
1773 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1775 typedef _Class const volatile _ClassType;
1776 typedef _Rp _ReturnType;
1779 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1780 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1782 typedef _Class const volatile _ClassType;
1783 typedef _Rp _ReturnType;
1786 #endif // _LIBCPP_HAS_NO_VARIADICS
1788 template <class _Rp, class _Class>
1789 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1791 typedef _Class _ClassType;
1792 typedef _Rp _ReturnType;
1795 template <class _MP>
1796 struct __member_pointer_traits
1797 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
1798 is_member_function_pointer<_MP>::value,
1799 is_member_object_pointer<_MP>::value>
1801 // typedef ... _ClassType;
1802 // typedef ... _ReturnType;
1807 template <class _Callable> class result_of;
1809 #ifdef _LIBCPP_HAS_NO_VARIADICS
1811 template <class _Fn, bool, bool>
1816 template <class _Fn>
1817 class __result_of<_Fn(), true, false>
1820 typedef decltype(declval<_Fn>()()) type;
1823 template <class _Fn, class _A0>
1824 class __result_of<_Fn(_A0), true, false>
1827 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1830 template <class _Fn, class _A0, class _A1>
1831 class __result_of<_Fn(_A0, _A1), true, false>
1834 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1837 template <class _Fn, class _A0, class _A1, class _A2>
1838 class __result_of<_Fn(_A0, _A1, _A2), true, false>
1841 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1844 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1845 struct __result_of_mp;
1847 // member function pointer
1849 template <class _MP, class _Tp>
1850 struct __result_of_mp<_MP, _Tp, true>
1851 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1855 // member data pointer
1857 template <class _MP, class _Tp, bool>
1858 struct __result_of_mdp;
1860 template <class _Rp, class _Class, class _Tp>
1861 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
1863 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1866 template <class _Rp, class _Class, class _Tp>
1867 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
1869 typedef typename __apply_cv<_Tp, _Rp>::type& type;
1872 template <class _Rp, class _Class, class _Tp>
1873 struct __result_of_mp<_Rp _Class::*, _Tp, false>
1874 : public __result_of_mdp<_Rp _Class::*, _Tp,
1875 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1881 template <class _Fn, class _Tp>
1882 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
1883 : public __result_of_mp<typename remove_reference<_Fn>::type,
1885 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1889 template <class _Fn, class _Tp, class _A0>
1890 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
1891 : public __result_of_mp<typename remove_reference<_Fn>::type,
1893 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1897 template <class _Fn, class _Tp, class _A0, class _A1>
1898 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
1899 : public __result_of_mp<typename remove_reference<_Fn>::type,
1901 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1905 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1906 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
1907 : public __result_of_mp<typename remove_reference<_Fn>::type,
1909 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1915 template <class _Fn>
1916 class _LIBCPP_TYPE_VIS result_of<_Fn()>
1917 : public __result_of<_Fn(),
1918 is_class<typename remove_reference<_Fn>::type>::value ||
1919 is_function<typename remove_reference<_Fn>::type>::value,
1920 is_member_pointer<typename remove_reference<_Fn>::type>::value
1925 template <class _Fn, class _A0>
1926 class _LIBCPP_TYPE_VIS result_of<_Fn(_A0)>
1927 : public __result_of<_Fn(_A0),
1928 is_class<typename remove_reference<_Fn>::type>::value ||
1929 is_function<typename remove_reference<_Fn>::type>::value,
1930 is_member_pointer<typename remove_reference<_Fn>::type>::value
1935 template <class _Fn, class _A0, class _A1>
1936 class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1)>
1937 : public __result_of<_Fn(_A0, _A1),
1938 is_class<typename remove_reference<_Fn>::type>::value ||
1939 is_function<typename remove_reference<_Fn>::type>::value,
1940 is_member_pointer<typename remove_reference<_Fn>::type>::value
1945 template <class _Fn, class _A0, class _A1, class _A2>
1946 class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1, _A2)>
1947 : public __result_of<_Fn(_A0, _A1, _A2),
1948 is_class<typename remove_reference<_Fn>::type>::value ||
1949 is_function<typename remove_reference<_Fn>::type>::value,
1950 is_member_pointer<typename remove_reference<_Fn>::type>::value
1955 #endif // _LIBCPP_HAS_NO_VARIADICS
1957 #ifndef _LIBCPP_HAS_NO_VARIADICS
1959 // template <class T, class... Args> struct is_constructible;
1961 // main is_constructible test
1963 template<typename, typename T> struct __select_2nd { typedef T type; };
1965 template <class _Tp, class ..._Args>
1966 typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
1967 __is_constructible_test(_Tp&&, _Args&& ...);
1969 template <class ..._Args>
1971 __is_constructible_test(__any, _Args&& ...);
1973 template <bool, class _Tp, class... _Args>
1974 struct __is_constructible // false, _Tp is not a scalar
1975 : public common_type
1977 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1981 // function types are not constructible
1983 template <class _Rp, class... _A1, class... _A2>
1984 struct __is_constructible<false, _Rp(_A1...), _A2...>
1988 // handle scalars and reference types
1990 // Scalars are default constructible, references are not
1992 template <class _Tp>
1993 struct __is_constructible<true, _Tp>
1994 : public is_scalar<_Tp>
1997 // Scalars and references are constructible from one arg if that arg is
1998 // implicitly convertible to the scalar or reference.
2000 template <class _Tp>
2001 struct __is_constructible_ref
2003 true_type static __lxx(_Tp);
2004 false_type static __lxx(...);
2007 template <class _Tp, class _A0>
2008 struct __is_constructible<true, _Tp, _A0>
2009 : public common_type
2011 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2015 // Scalars and references are not constructible from multiple args.
2017 template <class _Tp, class _A0, class ..._Args>
2018 struct __is_constructible<true, _Tp, _A0, _Args...>
2022 // Treat scalars and reference types separately
2024 template <bool, class _Tp, class... _Args>
2025 struct __is_constructible_void_check
2026 : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2030 // If any of T or Args is void, is_constructible should be false
2032 template <class _Tp, class... _Args>
2033 struct __is_constructible_void_check<true, _Tp, _Args...>
2037 template <class ..._Args> struct __contains_void;
2039 template <> struct __contains_void<> : false_type {};
2041 template <class _A0, class ..._Args>
2042 struct __contains_void<_A0, _Args...>
2044 static const bool value = is_void<_A0>::value ||
2045 __contains_void<_Args...>::value;
2048 // is_constructible entry point
2050 template <class _Tp, class... _Args>
2051 struct _LIBCPP_TYPE_VIS is_constructible
2052 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2053 || is_abstract<_Tp>::value,
2057 // Array types are default constructible if their element type
2058 // is default constructible
2060 template <class _Ap, size_t _Np>
2061 struct __is_constructible<false, _Ap[_Np]>
2062 : public is_constructible<typename remove_all_extents<_Ap>::type>
2065 // Otherwise array types are not constructible by this syntax
2067 template <class _Ap, size_t _Np, class ..._Args>
2068 struct __is_constructible<false, _Ap[_Np], _Args...>
2072 // Incomplete array types are not constructible
2074 template <class _Ap, class ..._Args>
2075 struct __is_constructible<false, _Ap[], _Args...>
2079 #else // _LIBCPP_HAS_NO_VARIADICS
2081 // template <class T> struct is_constructible0;
2083 // main is_constructible0 test
2085 template <class _Tp>
2086 decltype((_Tp(), true_type()))
2087 __is_constructible0_test(_Tp&);
2090 __is_constructible0_test(__any);
2092 template <class _Tp, class _A0>
2093 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2094 __is_constructible1_test(_Tp&, _A0&);
2096 template <class _A0>
2098 __is_constructible1_test(__any, _A0&);
2100 template <class _Tp, class _A0, class _A1>
2101 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2102 __is_constructible2_test(_Tp&, _A0&, _A1&);
2104 template <class _A0, class _A1>
2106 __is_constructible2_test(__any, _A0&, _A1&);
2108 template <bool, class _Tp>
2109 struct __is_constructible0_imp // false, _Tp is not a scalar
2110 : public common_type
2112 decltype(__is_constructible0_test(declval<_Tp&>()))
2116 template <bool, class _Tp, class _A0>
2117 struct __is_constructible1_imp // false, _Tp is not a scalar
2118 : public common_type
2120 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2124 template <bool, class _Tp, class _A0, class _A1>
2125 struct __is_constructible2_imp // false, _Tp is not a scalar
2126 : public common_type
2128 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2132 // handle scalars and reference types
2134 // Scalars are default constructible, references are not
2136 template <class _Tp>
2137 struct __is_constructible0_imp<true, _Tp>
2138 : public is_scalar<_Tp>
2141 template <class _Tp, class _A0>
2142 struct __is_constructible1_imp<true, _Tp, _A0>
2143 : public is_convertible<_A0, _Tp>
2146 template <class _Tp, class _A0, class _A1>
2147 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
2151 // Treat scalars and reference types separately
2153 template <bool, class _Tp>
2154 struct __is_constructible0_void_check
2155 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2159 template <bool, class _Tp, class _A0>
2160 struct __is_constructible1_void_check
2161 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2165 template <bool, class _Tp, class _A0, class _A1>
2166 struct __is_constructible2_void_check
2167 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2171 // If any of T or Args is void, is_constructible should be false
2173 template <class _Tp>
2174 struct __is_constructible0_void_check<true, _Tp>
2178 template <class _Tp, class _A0>
2179 struct __is_constructible1_void_check<true, _Tp, _A0>
2183 template <class _Tp, class _A0, class _A1>
2184 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2188 // is_constructible entry point
2190 namespace __is_construct
2197 template <class _Tp, class _A0 = __is_construct::__nat,
2198 class _A1 = __is_construct::__nat>
2199 struct _LIBCPP_TYPE_VIS is_constructible
2200 : public __is_constructible2_void_check<is_void<_Tp>::value
2201 || is_abstract<_Tp>::value
2202 || is_function<_Tp>::value
2203 || is_void<_A0>::value
2204 || is_void<_A1>::value,
2208 template <class _Tp>
2209 struct _LIBCPP_TYPE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2210 : public __is_constructible0_void_check<is_void<_Tp>::value
2211 || is_abstract<_Tp>::value
2212 || is_function<_Tp>::value,
2216 template <class _Tp, class _A0>
2217 struct _LIBCPP_TYPE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
2218 : public __is_constructible1_void_check<is_void<_Tp>::value
2219 || is_abstract<_Tp>::value
2220 || is_function<_Tp>::value
2221 || is_void<_A0>::value,
2225 // Array types are default constructible if their element type
2226 // is default constructible
2228 template <class _Ap, size_t _Np>
2229 struct __is_constructible0_imp<false, _Ap[_Np]>
2230 : public is_constructible<typename remove_all_extents<_Ap>::type>
2233 template <class _Ap, size_t _Np, class _A0>
2234 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
2238 template <class _Ap, size_t _Np, class _A0, class _A1>
2239 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2243 // Incomplete array types are not constructible
2245 template <class _Ap>
2246 struct __is_constructible0_imp<false, _Ap[]>
2250 template <class _Ap, class _A0>
2251 struct __is_constructible1_imp<false, _Ap[], _A0>
2255 template <class _Ap, class _A0, class _A1>
2256 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2260 #endif // _LIBCPP_HAS_NO_VARIADICS
2262 // is_default_constructible
2264 template <class _Tp>
2265 struct _LIBCPP_TYPE_VIS is_default_constructible
2266 : public is_constructible<_Tp>
2269 // is_copy_constructible
2271 template <class _Tp>
2272 struct _LIBCPP_TYPE_VIS is_copy_constructible
2273 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2276 // is_move_constructible
2278 template <class _Tp>
2279 struct _LIBCPP_TYPE_VIS is_move_constructible
2280 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2281 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2283 : public is_copy_constructible<_Tp>
2287 // is_trivially_constructible
2289 #ifndef _LIBCPP_HAS_NO_VARIADICS
2291 #if __has_feature(is_trivially_constructible)
2293 template <class _Tp, class... _Args>
2294 struct _LIBCPP_TYPE_VIS is_trivially_constructible
2295 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2299 #else // !__has_feature(is_trivially_constructible)
2301 template <class _Tp, class... _Args>
2302 struct _LIBCPP_TYPE_VIS is_trivially_constructible
2307 template <class _Tp>
2308 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp>
2309 #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2310 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2312 : integral_constant<bool, is_scalar<_Tp>::value>
2317 template <class _Tp>
2318 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2319 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&&>
2321 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp>
2323 : integral_constant<bool, is_scalar<_Tp>::value>
2327 template <class _Tp>
2328 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&>
2329 : integral_constant<bool, is_scalar<_Tp>::value>
2333 template <class _Tp>
2334 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&>
2335 : integral_constant<bool, is_scalar<_Tp>::value>
2339 #endif // !__has_feature(is_trivially_constructible)
2341 #else // _LIBCPP_HAS_NO_VARIADICS
2343 template <class _Tp, class _A0 = __is_construct::__nat,
2344 class _A1 = __is_construct::__nat>
2345 struct _LIBCPP_TYPE_VIS is_trivially_constructible
2350 #if __has_feature(is_trivially_constructible)
2352 template <class _Tp>
2353 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
2354 __is_construct::__nat>
2355 : integral_constant<bool, __is_trivially_constructible(_Tp)>
2359 template <class _Tp>
2360 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp,
2361 __is_construct::__nat>
2362 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2366 template <class _Tp>
2367 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&,
2368 __is_construct::__nat>
2369 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2373 template <class _Tp>
2374 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&,
2375 __is_construct::__nat>
2376 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2380 #else // !__has_feature(is_trivially_constructible)
2382 template <class _Tp>
2383 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
2384 __is_construct::__nat>
2385 : integral_constant<bool, is_scalar<_Tp>::value>
2389 template <class _Tp>
2390 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp,
2391 __is_construct::__nat>
2392 : integral_constant<bool, is_scalar<_Tp>::value>
2396 template <class _Tp>
2397 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&,
2398 __is_construct::__nat>
2399 : integral_constant<bool, is_scalar<_Tp>::value>
2403 template <class _Tp>
2404 struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&,
2405 __is_construct::__nat>
2406 : integral_constant<bool, is_scalar<_Tp>::value>
2410 #endif // !__has_feature(is_trivially_constructible)
2412 #endif // _LIBCPP_HAS_NO_VARIADICS
2414 // is_trivially_default_constructible
2416 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_default_constructible
2417 : public is_trivially_constructible<_Tp>
2420 // is_trivially_copy_constructible
2422 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copy_constructible
2423 : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2426 // is_trivially_move_constructible
2428 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_move_constructible
2429 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2430 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2432 : public is_trivially_copy_constructible<_Tp>
2436 // is_trivially_assignable
2438 #if __has_feature(is_trivially_constructible)
2440 template <class _Tp, class _Arg>
2441 struct is_trivially_assignable
2442 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2446 #else // !__has_feature(is_trivially_constructible)
2448 template <class _Tp, class _Arg>
2449 struct is_trivially_assignable
2450 : public false_type {};
2452 template <class _Tp>
2453 struct is_trivially_assignable<_Tp&, _Tp>
2454 : integral_constant<bool, is_scalar<_Tp>::value> {};
2456 template <class _Tp>
2457 struct is_trivially_assignable<_Tp&, _Tp&>
2458 : integral_constant<bool, is_scalar<_Tp>::value> {};
2460 template <class _Tp>
2461 struct is_trivially_assignable<_Tp&, const _Tp&>
2462 : integral_constant<bool, is_scalar<_Tp>::value> {};
2464 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2466 template <class _Tp>
2467 struct is_trivially_assignable<_Tp&, _Tp&&>
2468 : integral_constant<bool, is_scalar<_Tp>::value> {};
2470 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2472 #endif // !__has_feature(is_trivially_constructible)
2474 // is_trivially_copy_assignable
2476 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copy_assignable
2477 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2478 const typename add_lvalue_reference<_Tp>::type>
2481 // is_trivially_move_assignable
2483 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_move_assignable
2484 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2485 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2486 typename add_rvalue_reference<_Tp>::type>
2488 typename add_lvalue_reference<_Tp>::type>
2492 // is_trivially_destructible
2494 #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2496 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_destructible
2497 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2499 #else // _LIBCPP_HAS_TYPE_TRAITS
2501 template <class _Tp> struct __libcpp_trivial_destructor
2502 : public integral_constant<bool, is_scalar<_Tp>::value ||
2503 is_reference<_Tp>::value> {};
2505 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_destructible
2506 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2508 #endif // _LIBCPP_HAS_TYPE_TRAITS
2510 // is_nothrow_constructible
2512 #ifndef _LIBCPP_HAS_NO_VARIADICS
2514 #if __has_feature(cxx_noexcept)
2516 template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2518 template <class _Tp, class... _Args>
2519 struct __is_nothrow_constructible<true, _Tp, _Args...>
2520 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2524 template <class _Tp, class... _Args>
2525 struct __is_nothrow_constructible<false, _Tp, _Args...>
2530 template <class _Tp, class... _Args>
2531 struct _LIBCPP_TYPE_VIS is_nothrow_constructible
2532 : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2536 template <class _Tp, size_t _Ns>
2537 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp[_Ns]>
2538 : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2542 #else // __has_feature(cxx_noexcept)
2544 template <class _Tp, class... _Args>
2545 struct _LIBCPP_TYPE_VIS is_nothrow_constructible
2550 template <class _Tp>
2551 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp>
2552 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2553 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2555 : integral_constant<bool, is_scalar<_Tp>::value>
2560 template <class _Tp>
2561 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2562 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&&>
2564 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp>
2566 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2567 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2569 : integral_constant<bool, is_scalar<_Tp>::value>
2574 template <class _Tp>
2575 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&>
2576 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2577 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2579 : integral_constant<bool, is_scalar<_Tp>::value>
2584 template <class _Tp>
2585 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&>
2586 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2587 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2589 : integral_constant<bool, is_scalar<_Tp>::value>
2594 #endif // __has_feature(cxx_noexcept)
2596 #else // _LIBCPP_HAS_NO_VARIADICS
2598 template <class _Tp, class _A0 = __is_construct::__nat,
2599 class _A1 = __is_construct::__nat>
2600 struct _LIBCPP_TYPE_VIS is_nothrow_constructible
2605 template <class _Tp>
2606 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
2607 __is_construct::__nat>
2608 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2609 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2611 : integral_constant<bool, is_scalar<_Tp>::value>
2616 template <class _Tp>
2617 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp,
2618 __is_construct::__nat>
2619 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2620 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2622 : integral_constant<bool, is_scalar<_Tp>::value>
2627 template <class _Tp>
2628 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&,
2629 __is_construct::__nat>
2630 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2631 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2633 : integral_constant<bool, is_scalar<_Tp>::value>
2638 template <class _Tp>
2639 struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&,
2640 __is_construct::__nat>
2641 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2642 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2644 : integral_constant<bool, is_scalar<_Tp>::value>
2649 #endif // _LIBCPP_HAS_NO_VARIADICS
2651 // is_nothrow_default_constructible
2653 template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_default_constructible
2654 : public is_nothrow_constructible<_Tp>
2657 // is_nothrow_copy_constructible
2659 template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_copy_constructible
2660 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2663 // is_nothrow_move_constructible
2665 template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_move_constructible
2666 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2667 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2669 : public is_nothrow_copy_constructible<_Tp>
2673 // is_nothrow_assignable
2675 #if __has_feature(cxx_noexcept)
2677 template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2679 template <class _Tp, class _Arg>
2680 struct __is_nothrow_assignable<false, _Tp, _Arg>
2685 template <class _Tp, class _Arg>
2686 struct __is_nothrow_assignable<true, _Tp, _Arg>
2687 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2691 template <class _Tp, class _Arg>
2692 struct _LIBCPP_TYPE_VIS is_nothrow_assignable
2693 : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2697 #else // __has_feature(cxx_noexcept)
2699 template <class _Tp, class _Arg>
2700 struct _LIBCPP_TYPE_VIS is_nothrow_assignable
2701 : public false_type {};
2703 template <class _Tp>
2704 struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp>
2705 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2706 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2708 : integral_constant<bool, is_scalar<_Tp>::value> {};
2711 template <class _Tp>
2712 struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp&>
2713 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2714 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2716 : integral_constant<bool, is_scalar<_Tp>::value> {};
2719 template <class _Tp>
2720 struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
2721 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2722 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2724 : integral_constant<bool, is_scalar<_Tp>::value> {};
2727 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2729 template <class _Tp>
2730 struct is_nothrow_assignable<_Tp&, _Tp&&>
2731 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2732 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2734 : integral_constant<bool, is_scalar<_Tp>::value> {};
2737 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2739 #endif // __has_feature(cxx_noexcept)
2741 // is_nothrow_copy_assignable
2743 template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_copy_assignable
2744 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2745 const typename add_lvalue_reference<_Tp>::type>
2748 // is_nothrow_move_assignable
2750 template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_move_assignable
2751 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2752 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2753 typename add_rvalue_reference<_Tp>::type>
2755 typename add_lvalue_reference<_Tp>::type>
2759 // is_nothrow_destructible
2761 #if __has_feature(cxx_noexcept)
2763 template <bool, class _Tp> struct __is_nothrow_destructible;
2765 template <class _Tp>
2766 struct __is_nothrow_destructible<false, _Tp>
2771 template <class _Tp>
2772 struct __is_nothrow_destructible<true, _Tp>
2773 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2777 template <class _Tp>
2778 struct _LIBCPP_TYPE_VIS is_nothrow_destructible
2779 : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2783 template <class _Tp, size_t _Ns>
2784 struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp[_Ns]>
2785 : public is_nothrow_destructible<_Tp>
2789 template <class _Tp>
2790 struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&>
2795 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2797 template <class _Tp>
2798 struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&&>
2807 template <class _Tp> struct __libcpp_nothrow_destructor
2808 : public integral_constant<bool, is_scalar<_Tp>::value ||
2809 is_reference<_Tp>::value> {};
2811 template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_destructible
2812 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2818 #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2820 template <class _Tp> struct _LIBCPP_TYPE_VIS is_pod
2821 : public integral_constant<bool, __is_pod(_Tp)> {};
2823 #else // _LIBCPP_HAS_TYPE_TRAITS
2825 template <class _Tp> struct _LIBCPP_TYPE_VIS is_pod
2826 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
2827 is_trivially_copy_constructible<_Tp>::value &&
2828 is_trivially_copy_assignable<_Tp>::value &&
2829 is_trivially_destructible<_Tp>::value> {};
2831 #endif // _LIBCPP_HAS_TYPE_TRAITS
2835 template <class _Tp> struct _LIBCPP_TYPE_VIS is_literal_type
2836 #if __has_feature(is_literal)
2837 : public integral_constant<bool, __is_literal(_Tp)>
2839 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2840 is_reference<typename remove_all_extents<_Tp>::type>::value>
2844 // is_standard_layout;
2846 template <class _Tp> struct _LIBCPP_TYPE_VIS is_standard_layout
2847 #if __has_feature(is_standard_layout)
2848 : public integral_constant<bool, __is_standard_layout(_Tp)>
2850 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2854 // is_trivially_copyable;
2856 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copyable
2857 #if __has_feature(is_trivially_copyable)
2858 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2860 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2866 template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivial
2867 #if __has_feature(is_trivial)
2868 : public integral_constant<bool, __is_trivial(_Tp)>
2870 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2871 is_trivially_default_constructible<_Tp>::value>
2875 #ifndef _LIBCPP_HAS_NO_VARIADICS
2877 // Check for complete types
2879 template <class ..._Tp> struct __check_complete;
2882 struct __check_complete<>
2886 template <class _Hp, class _T0, class ..._Tp>
2887 struct __check_complete<_Hp, _T0, _Tp...>
2888 : private __check_complete<_Hp>,
2889 private __check_complete<_T0, _Tp...>
2893 template <class _Hp>
2894 struct __check_complete<_Hp, _Hp>
2895 : private __check_complete<_Hp>
2899 template <class _Tp>
2900 struct __check_complete<_Tp>
2902 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2905 template <class _Tp>
2906 struct __check_complete<_Tp&>
2907 : private __check_complete<_Tp>
2911 template <class _Tp>
2912 struct __check_complete<_Tp&&>
2913 : private __check_complete<_Tp>
2917 template <class _Rp, class ..._Param>
2918 struct __check_complete<_Rp (*)(_Param...)>
2919 : private __check_complete<_Rp>
2923 template <class _Rp, class ..._Param>
2924 struct __check_complete<_Rp (_Param...)>
2925 : private __check_complete<_Rp>
2929 template <class _Rp, class _Class, class ..._Param>
2930 struct __check_complete<_Rp (_Class::*)(_Param...)>
2931 : private __check_complete<_Class>
2935 template <class _Rp, class _Class, class ..._Param>
2936 struct __check_complete<_Rp (_Class::*)(_Param...) const>
2937 : private __check_complete<_Class>
2941 template <class _Rp, class _Class, class ..._Param>
2942 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
2943 : private __check_complete<_Class>
2947 template <class _Rp, class _Class, class ..._Param>
2948 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
2949 : private __check_complete<_Class>
2953 #if __has_feature(cxx_reference_qualified_functions)
2955 template <class _Rp, class _Class, class ..._Param>
2956 struct __check_complete<_Rp (_Class::*)(_Param...) &>
2957 : private __check_complete<_Class>
2961 template <class _Rp, class _Class, class ..._Param>
2962 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
2963 : private __check_complete<_Class>
2967 template <class _Rp, class _Class, class ..._Param>
2968 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
2969 : private __check_complete<_Class>
2973 template <class _Rp, class _Class, class ..._Param>
2974 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
2975 : private __check_complete<_Class>
2979 template <class _Rp, class _Class, class ..._Param>
2980 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
2981 : private __check_complete<_Class>
2985 template <class _Rp, class _Class, class ..._Param>
2986 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
2987 : private __check_complete<_Class>
2991 template <class _Rp, class _Class, class ..._Param>
2992 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
2993 : private __check_complete<_Class>
2997 template <class _Rp, class _Class, class ..._Param>
2998 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
2999 : private __check_complete<_Class>
3005 template <class _Rp, class _Class>
3006 struct __check_complete<_Rp _Class::*>
3007 : private __check_complete<_Class>
3011 // __invoke forward declarations
3013 // fall back - none of the bullets
3015 template <class ..._Args>
3017 __invoke(__any, _Args&& ...__args)
3022 template <class _Fp, class _A0, class ..._Args,
3023 class = typename enable_if
3025 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3026 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3027 typename remove_reference<_A0>::type>::value
3030 _LIBCPP_INLINE_VISIBILITY
3032 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3033 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
3035 template <class _Fp, class _A0, class ..._Args,
3036 class = typename enable_if
3038 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3039 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3040 typename remove_reference<_A0>::type>::value
3043 _LIBCPP_INLINE_VISIBILITY
3045 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3046 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
3050 template <class _Fp, class _A0,
3051 class = typename enable_if
3053 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3054 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3055 typename remove_reference<_A0>::type>::value
3058 _LIBCPP_INLINE_VISIBILITY
3060 __invoke(_Fp&& __f, _A0&& __a0)
3061 -> decltype(_VSTD::forward<_A0>(__a0).*__f);
3063 template <class _Fp, class _A0,
3064 class = typename enable_if
3066 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3067 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3068 typename remove_reference<_A0>::type>::value
3071 _LIBCPP_INLINE_VISIBILITY
3073 __invoke(_Fp&& __f, _A0&& __a0)
3074 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
3078 template <class _Fp, class ..._Args>
3079 _LIBCPP_INLINE_VISIBILITY
3081 __invoke(_Fp&& __f, _Args&& ...__args)
3082 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
3086 template <class _Fp, class ..._Args>
3087 struct __invokable_imp
3088 : private __check_complete<_Fp>
3091 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
3093 static const bool value = !is_same<type, __nat>::value;
3096 template <class _Fp, class ..._Args>
3098 : public integral_constant<bool,
3099 __invokable_imp<_Fp, _Args...>::value>
3105 template <bool _Invokable, class _Fp, class ..._Args>
3106 struct __invoke_of_imp // false
3110 template <class _Fp, class ..._Args>
3111 struct __invoke_of_imp<true, _Fp, _Args...>
3113 typedef typename __invokable_imp<_Fp, _Args...>::type type;
3116 template <class _Fp, class ..._Args>
3118 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
3122 template <class _Fp, class ..._Args>
3123 class _LIBCPP_TYPE_VIS result_of<_Fp(_Args...)>
3124 : public __invoke_of<_Fp, _Args...>
3128 #if _LIBCPP_STD_VER > 11
3129 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3132 #endif // _LIBCPP_HAS_NO_VARIADICS
3134 template <class _Tp>
3135 inline _LIBCPP_INLINE_VISIBILITY
3136 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3139 is_move_constructible<_Tp>::value &&
3140 is_move_assignable<_Tp>::value
3145 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3146 is_nothrow_move_assignable<_Tp>::value)
3148 _Tp __t(_VSTD::move(__x));
3149 __x = _VSTD::move(__y);
3150 __y = _VSTD::move(__t);
3153 template <class _ForwardIterator1, class _ForwardIterator2>
3154 inline _LIBCPP_INLINE_VISIBILITY
3156 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3157 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3158 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3159 *_VSTD::declval<_ForwardIterator2>())))
3170 __nat swap(__any, __any);
3172 template <class _Tp>
3175 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3176 static const bool value = !is_same<type, __nat>::value;
3181 template <class _Tp>
3182 struct __is_swappable
3183 : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3187 #if __has_feature(cxx_noexcept)
3189 template <bool, class _Tp>
3190 struct __is_nothrow_swappable_imp
3191 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3192 _VSTD::declval<_Tp&>()))>
3196 template <class _Tp>
3197 struct __is_nothrow_swappable_imp<false, _Tp>
3202 template <class _Tp>
3203 struct __is_nothrow_swappable
3204 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3208 #else // __has_feature(cxx_noexcept)
3210 template <class _Tp>
3211 struct __is_nothrow_swappable
3216 #endif // __has_feature(cxx_noexcept)
3218 #ifdef _LIBCXX_UNDERLYING_TYPE
3220 template <class _Tp>
3221 struct underlying_type
3223 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3226 #if _LIBCPP_STD_VER > 11
3227 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3230 #else // _LIBCXX_UNDERLYING_TYPE
3232 template <class _Tp, bool _Support = false>
3233 struct underlying_type
3235 static_assert(_Support, "The underyling_type trait requires compiler "
3236 "support. Either no such support exists or "
3237 "libc++ does not know how to use it.");
3240 #endif // _LIBCXX_UNDERLYING_TYPE
3242 _LIBCPP_END_NAMESPACE_STD
3244 #endif // _LIBCPP_TYPE_TRAITS