2 //===------------------------ type_traits ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_TYPE_TRAITS
12 #define _LIBCPP_TYPE_TRAITS
21 template <class T, T v> struct integral_constant;
22 typedef integral_constant<bool, true> true_type;
23 typedef integral_constant<bool, false> false_type;
26 template <bool, class T = void> struct enable_if;
27 template <bool, class T, class F> struct conditional;
29 // Primary classification traits:
30 template <class T> struct is_void;
31 template <class T> struct is_null_pointer; // C++14
32 template <class T> struct is_integral;
33 template <class T> struct is_floating_point;
34 template <class T> struct is_array;
35 template <class T> struct is_pointer;
36 template <class T> struct is_lvalue_reference;
37 template <class T> struct is_rvalue_reference;
38 template <class T> struct is_member_object_pointer;
39 template <class T> struct is_member_function_pointer;
40 template <class T> struct is_enum;
41 template <class T> struct is_union;
42 template <class T> struct is_class;
43 template <class T> struct is_function;
45 // Secondary classification traits:
46 template <class T> struct is_reference;
47 template <class T> struct is_arithmetic;
48 template <class T> struct is_fundamental;
49 template <class T> struct is_member_pointer;
50 template <class T> struct is_scalar;
51 template <class T> struct is_object;
52 template <class T> struct is_compound;
54 // Const-volatile properties and transformations:
55 template <class T> struct is_const;
56 template <class T> struct is_volatile;
57 template <class T> struct remove_const;
58 template <class T> struct remove_volatile;
59 template <class T> struct remove_cv;
60 template <class T> struct add_const;
61 template <class T> struct add_volatile;
62 template <class T> struct add_cv;
64 // Reference transformations:
65 template <class T> struct remove_reference;
66 template <class T> struct add_lvalue_reference;
67 template <class T> struct add_rvalue_reference;
69 // Pointer transformations:
70 template <class T> struct remove_pointer;
71 template <class T> struct add_pointer;
73 // Integral properties:
74 template <class T> struct is_signed;
75 template <class T> struct is_unsigned;
76 template <class T> struct make_signed;
77 template <class T> struct make_unsigned;
79 // Array properties and transformations:
80 template <class T> struct rank;
81 template <class T, unsigned I = 0> struct extent;
82 template <class T> struct remove_extent;
83 template <class T> struct remove_all_extents;
85 // Member introspection:
86 template <class T> struct is_pod;
87 template <class T> struct is_trivial;
88 template <class T> struct is_trivially_copyable;
89 template <class T> struct is_standard_layout;
90 template <class T> struct is_literal_type;
91 template <class T> struct is_empty;
92 template <class T> struct is_polymorphic;
93 template <class T> struct is_abstract;
95 template <class T, class... Args> struct is_constructible;
96 template <class T> struct is_default_constructible;
97 template <class T> struct is_copy_constructible;
98 template <class T> struct is_move_constructible;
99 template <class T, class U> struct is_assignable;
100 template <class T> struct is_copy_assignable;
101 template <class T> struct is_move_assignable;
102 template <class T> struct is_destructible;
104 template <class T, class... Args> struct is_trivially_constructible;
105 template <class T> struct is_trivially_default_constructible;
106 template <class T> struct is_trivially_copy_constructible;
107 template <class T> struct is_trivially_move_constructible;
108 template <class T, class U> struct is_trivially_assignable;
109 template <class T> struct is_trivially_copy_assignable;
110 template <class T> struct is_trivially_move_assignable;
111 template <class T> struct is_trivially_destructible;
113 template <class T, class... Args> struct is_nothrow_constructible;
114 template <class T> struct is_nothrow_default_constructible;
115 template <class T> struct is_nothrow_copy_constructible;
116 template <class T> struct is_nothrow_move_constructible;
117 template <class T, class U> struct is_nothrow_assignable;
118 template <class T> struct is_nothrow_copy_assignable;
119 template <class T> struct is_nothrow_move_assignable;
120 template <class T> struct is_nothrow_destructible;
122 template <class T> struct has_virtual_destructor;
124 // Relationships between types:
125 template <class T, class U> struct is_same;
126 template <class Base, class Derived> struct is_base_of;
127 template <class From, class To> struct is_convertible;
129 // Alignment properties and transformations:
130 template <class T> struct alignment_of;
131 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
132 struct aligned_storage;
133 template <size_t Len, class... Types> struct aligned_union;
135 template <class T> struct decay;
136 template <class... T> struct common_type;
137 template <class T> struct underlying_type;
138 template <class> class result_of; // undefined
139 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
141 // const-volatile modifications:
143 using remove_const_t = typename remove_const<T>::type; // C++14
145 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
147 using remove_cv_t = typename remove_cv<T>::type; // C++14
149 using add_const_t = typename add_const<T>::type; // C++14
151 using add_volatile_t = typename add_volatile<T>::type; // C++14
153 using add_cv_t = typename add_cv<T>::type; // C++14
155 // reference modifications:
157 using remove_reference_t = typename remove_reference<T>::type; // C++14
159 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
161 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
163 // sign modifications:
165 using make_signed_t = typename make_signed<T>::type; // C++14
167 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
169 // array modifications:
171 using remove_extent_t = typename remove_extent<T>::type; // C++14
173 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
175 // pointer modifications:
177 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
179 using add_pointer_t = typename add_pointer<T>::type; // C++14
181 // other transformations:
182 template <size_t Len, std::size_t Align=default-alignment>
183 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
184 template <std::size_t Len, class... Types>
185 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
187 using decay_t = typename decay<T>::type; // C++14
188 template <bool b, class T=void>
189 using enable_if_t = typename enable_if<b,T>::type; // C++14
190 template <bool b, class T, class F>
191 using conditional_t = typename conditional<b,T,F>::type; // C++14
192 template <class... T>
193 using common_type_t = typename common_type<T...>::type; // C++14
195 using underlying_type_t = typename underlying_type<T>::type; // C++14
196 template <class F, class... ArgTypes>
197 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
205 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
206 #pragma GCC system_header
209 _LIBCPP_BEGIN_NAMESPACE_STD
211 template <bool _Bp, class _If, class _Then>
212 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
213 template <class _If, class _Then>
214 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
216 #if _LIBCPP_STD_VER > 11
217 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
220 template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
221 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
223 #if _LIBCPP_STD_VER > 11
224 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
228 struct __two {char __lx[2];};
232 template <class _Tp, _Tp __v>
233 struct _LIBCPP_TYPE_VIS_ONLY integral_constant
235 static _LIBCPP_CONSTEXPR const _Tp value = __v;
236 typedef _Tp value_type;
237 typedef integral_constant type;
238 _LIBCPP_INLINE_VISIBILITY
239 _LIBCPP_CONSTEXPR operator value_type() const {return value;}
240 #if _LIBCPP_STD_VER > 11
241 _LIBCPP_INLINE_VISIBILITY
242 constexpr value_type operator ()() const {return value;}
246 template <class _Tp, _Tp __v>
247 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
249 typedef integral_constant<bool, true> true_type;
250 typedef integral_constant<bool, false> false_type;
254 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
255 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
259 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
260 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
264 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
265 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
266 #if _LIBCPP_STD_VER > 11
267 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
272 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
273 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
274 #if _LIBCPP_STD_VER > 11
275 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
280 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
281 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
282 #if _LIBCPP_STD_VER > 11
283 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
288 template <class _Tp> struct __libcpp_is_void : public false_type {};
289 template <> struct __libcpp_is_void<void> : public true_type {};
291 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
292 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
296 template <class _Tp> struct __libcpp___is_nullptr : public false_type {};
297 template <> struct __libcpp___is_nullptr<nullptr_t> : public true_type {};
299 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
300 : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {};
302 #if _LIBCPP_STD_VER > 11
303 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
304 : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {};
309 template <class _Tp> struct __libcpp_is_integral : public false_type {};
310 template <> struct __libcpp_is_integral<bool> : public true_type {};
311 template <> struct __libcpp_is_integral<char> : public true_type {};
312 template <> struct __libcpp_is_integral<signed char> : public true_type {};
313 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
314 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
315 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
316 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
317 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
318 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
319 template <> struct __libcpp_is_integral<short> : public true_type {};
320 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
321 template <> struct __libcpp_is_integral<int> : public true_type {};
322 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
323 template <> struct __libcpp_is_integral<long> : public true_type {};
324 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
325 template <> struct __libcpp_is_integral<long long> : public true_type {};
326 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
328 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
329 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
333 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
334 template <> struct __libcpp_is_floating_point<float> : public true_type {};
335 template <> struct __libcpp_is_floating_point<double> : public true_type {};
336 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
338 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
339 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
343 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
344 : public false_type {};
345 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
346 : public true_type {};
347 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
348 : public true_type {};
352 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
353 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
355 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
356 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
360 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
361 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
363 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
364 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
365 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
368 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
369 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
370 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
371 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
374 #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
375 #define _LIBCPP_HAS_TYPE_TRAITS
380 #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
382 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
383 : public integral_constant<bool, __is_union(_Tp)> {};
387 template <class _Tp> struct __libcpp_union : public false_type {};
388 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
389 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
395 #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
397 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
398 : public integral_constant<bool, __is_class(_Tp)> {};
402 namespace __is_class_imp
404 template <class _Tp> char __test(int _Tp::*);
405 template <class _Tp> __two __test(...);
408 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
409 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
415 template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
416 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
420 namespace __is_function_imp
422 template <class _Tp> char __test(_Tp*);
423 template <class _Tp> __two __test(...);
424 template <class _Tp> _Tp& __source();
427 template <class _Tp, bool = is_class<_Tp>::value ||
428 is_union<_Tp>::value ||
429 is_void<_Tp>::value ||
430 is_reference<_Tp>::value ||
431 __is_nullptr_t<_Tp>::value >
432 struct __libcpp_is_function
433 : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1>
435 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
437 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
438 : public __libcpp_is_function<_Tp> {};
440 // is_member_function_pointer
442 template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
443 template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
445 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
446 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
450 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
451 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
453 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
454 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
456 // is_member_object_pointer
458 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
459 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
460 !is_member_function_pointer<_Tp>::value> {};
464 #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
466 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
467 : public integral_constant<bool, __is_enum(_Tp)> {};
471 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
472 : public integral_constant<bool, !is_void<_Tp>::value &&
473 !is_integral<_Tp>::value &&
474 !is_floating_point<_Tp>::value &&
475 !is_array<_Tp>::value &&
476 !is_pointer<_Tp>::value &&
477 !is_reference<_Tp>::value &&
478 !is_member_pointer<_Tp>::value &&
479 !is_union<_Tp>::value &&
480 !is_class<_Tp>::value &&
481 !is_function<_Tp>::value > {};
487 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
488 : public integral_constant<bool, is_integral<_Tp>::value ||
489 is_floating_point<_Tp>::value> {};
493 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
494 : public integral_constant<bool, is_void<_Tp>::value ||
495 __is_nullptr_t<_Tp>::value ||
496 is_arithmetic<_Tp>::value> {};
500 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
501 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
502 is_member_pointer<_Tp>::value ||
503 is_pointer<_Tp>::value ||
504 __is_nullptr_t<_Tp>::value ||
505 is_enum<_Tp>::value > {};
507 template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
511 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
512 : public integral_constant<bool, is_scalar<_Tp>::value ||
513 is_array<_Tp>::value ||
514 is_union<_Tp>::value ||
515 is_class<_Tp>::value > {};
519 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
520 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
524 template <class _Tp, bool = is_reference<_Tp>::value ||
525 is_function<_Tp>::value ||
526 is_const<_Tp>::value >
527 struct __add_const {typedef _Tp type;};
530 struct __add_const<_Tp, false> {typedef const _Tp type;};
532 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
533 {typedef typename __add_const<_Tp>::type type;};
535 #if _LIBCPP_STD_VER > 11
536 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
541 template <class _Tp, bool = is_reference<_Tp>::value ||
542 is_function<_Tp>::value ||
543 is_volatile<_Tp>::value >
544 struct __add_volatile {typedef _Tp type;};
547 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
549 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
550 {typedef typename __add_volatile<_Tp>::type type;};
552 #if _LIBCPP_STD_VER > 11
553 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
558 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
559 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
561 #if _LIBCPP_STD_VER > 11
562 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
567 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
568 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
569 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
570 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
573 #if _LIBCPP_STD_VER > 11
574 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
577 // add_lvalue_reference
579 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;};
580 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
581 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;};
582 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;};
583 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;};
584 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
586 #if _LIBCPP_STD_VER > 11
587 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
590 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
592 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;};
593 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;};
594 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;};
595 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;};
596 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
598 #if _LIBCPP_STD_VER > 11
599 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
602 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
604 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
607 typename add_rvalue_reference<_Tp>::type
610 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
613 typename add_lvalue_reference<_Tp>::type
616 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
625 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
626 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
627 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
628 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
629 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
631 #if _LIBCPP_STD_VER > 11
632 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
637 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
638 {typedef typename remove_reference<_Tp>::type* type;};
640 #if _LIBCPP_STD_VER > 11
641 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
646 template <class _Tp, bool = is_integral<_Tp>::value>
647 struct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
650 struct ___is_signed<_Tp, false> : public true_type {}; // floating point
652 template <class _Tp, bool = is_arithmetic<_Tp>::value>
653 struct __libcpp_is_signed : public ___is_signed<_Tp> {};
655 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
657 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
661 template <class _Tp, bool = is_integral<_Tp>::value>
662 struct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
665 struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point
667 template <class _Tp, bool = is_arithmetic<_Tp>::value>
668 struct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {};
670 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
672 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
676 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
677 : public integral_constant<size_t, 0> {};
678 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
679 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
680 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
681 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
685 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
686 : public integral_constant<size_t, 0> {};
687 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
688 : public integral_constant<size_t, 0> {};
689 template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
690 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
691 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
692 : public integral_constant<size_t, _Np> {};
693 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
694 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
698 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
700 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
702 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
705 #if _LIBCPP_STD_VER > 11
706 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
709 // remove_all_extents
711 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
713 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
714 {typedef typename remove_all_extents<_Tp>::type type;};
715 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
716 {typedef typename remove_all_extents<_Tp>::type type;};
718 #if _LIBCPP_STD_VER > 11
719 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
725 struct _LIBCPP_TYPE_VIS_ONLY decay
728 typedef typename remove_reference<_Tp>::type _Up;
730 typedef typename conditional
732 is_array<_Up>::value,
733 typename remove_extent<_Up>::type*,
736 is_function<_Up>::value,
737 typename add_pointer<_Up>::type,
738 typename remove_cv<_Up>::type
743 #if _LIBCPP_STD_VER > 11
744 template <class _Tp> using decay_t = typename decay<_Tp>::type;
749 namespace __is_abstract_imp
751 template <class _Tp> char __test(_Tp (*)[1]);
752 template <class _Tp> __two __test(...);
755 template <class _Tp, bool = is_class<_Tp>::value>
756 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
758 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
760 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
764 #ifdef _LIBCPP_HAS_IS_BASE_OF
766 template <class _Bp, class _Dp>
767 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
768 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
770 #else // __has_feature(is_base_of)
772 namespace __is_base_of_imp
777 _Dst(const volatile _Tp &);
782 operator const volatile _Tp &();
783 template <class _Up> operator const _Dst<_Up> &();
785 template <size_t> struct __one { typedef char type; };
786 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
787 template <class _Bp, class _Dp> __two __test(...);
790 template <class _Bp, class _Dp>
791 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
792 : public integral_constant<bool, is_class<_Bp>::value &&
793 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
795 #endif // __has_feature(is_base_of)
799 #if __has_feature(is_convertible_to)
801 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
802 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
803 !is_abstract<_T2>::value> {};
805 #else // __has_feature(is_convertible_to)
807 namespace __is_convertible_imp
809 template <class _Tp> char __test(_Tp);
810 template <class _Tp> __two __test(...);
811 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
812 template <class _Tp> _Tp&& __source();
814 template <class _Tp> typename remove_reference<_Tp>::type& __source();
817 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
818 bool _IsFunction = is_function<_Tp>::value,
819 bool _IsVoid = is_void<_Tp>::value>
820 struct __is_array_function_or_void {enum {value = 0};};
821 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
822 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
823 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
827 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
828 struct __is_convertible_check
830 static const size_t __v = 0;
834 struct __is_convertible_check<_Tp, 0>
836 static const size_t __v = sizeof(_Tp);
839 template <class _T1, class _T2,
840 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
841 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
842 struct __is_convertible
843 : public integral_constant<bool,
844 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
845 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
847 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
848 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
849 && (!is_const<typename remove_reference<_T2>::type>::value
850 || is_volatile<typename remove_reference<_T2>::type>::value)
851 && (is_same<typename remove_cv<_T1>::type,
852 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
853 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
858 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
860 template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
861 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
862 template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
863 template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
864 template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
865 template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
866 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
868 template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
869 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
871 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
872 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
874 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
875 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
877 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
878 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
880 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
881 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
882 template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
884 template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
885 template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
886 template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
887 template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
888 template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
890 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
892 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
893 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
894 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
895 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
897 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
898 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
899 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
900 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
902 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
903 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
904 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
905 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
907 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
908 : public __is_convertible<_T1, _T2>
910 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
911 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
914 #endif // __has_feature(is_convertible_to)
918 #if __has_feature(is_empty)
921 struct _LIBCPP_TYPE_VIS_ONLY is_empty
922 : public integral_constant<bool, __is_empty(_Tp)> {};
924 #else // __has_feature(is_empty)
938 template <class _Tp, bool = is_class<_Tp>::value>
939 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
941 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
943 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
945 #endif // __has_feature(is_empty)
949 #if __has_feature(is_polymorphic)
952 struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
953 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
957 template<typename _Tp> char &__is_polymorphic_impl(
958 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
960 template<typename _Tp> __two &__is_polymorphic_impl(...);
962 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
963 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
965 #endif // __has_feature(is_polymorphic)
967 // has_virtual_destructor
969 #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
971 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
972 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
974 #else // _LIBCPP_HAS_TYPE_TRAITS
976 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
977 : public false_type {};
979 #endif // _LIBCPP_HAS_TYPE_TRAITS
983 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
984 : public integral_constant<size_t, __alignof__(_Tp)> {};
988 template <class _Hp, class _Tp>
997 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
999 __nat(const __nat&) = delete;
1000 __nat& operator=(const __nat&) = delete;
1005 template <class _Tp>
1008 static const size_t value = alignment_of<_Tp>::value;
1012 struct __struct_double {long double __lx;};
1013 struct __struct_double4 {double __lx[4];};
1016 __type_list<__align_type<unsigned char>,
1017 __type_list<__align_type<unsigned short>,
1018 __type_list<__align_type<unsigned int>,
1019 __type_list<__align_type<unsigned long>,
1020 __type_list<__align_type<unsigned long long>,
1021 __type_list<__align_type<double>,
1022 __type_list<__align_type<long double>,
1023 __type_list<__align_type<__struct_double>,
1024 __type_list<__align_type<__struct_double4>,
1025 __type_list<__align_type<int*>,
1027 > > > > > > > > > > __all_types;
1029 template <class _TL, size_t _Align> struct __find_pod;
1031 template <class _Hp, size_t _Align>
1032 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1034 typedef typename conditional<
1035 _Align == _Hp::value,
1041 template <class _Hp, class _Tp, size_t _Align>
1042 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1044 typedef typename conditional<
1045 _Align == _Hp::value,
1047 typename __find_pod<_Tp, _Align>::type
1051 template <class _TL, size_t _Len> struct __find_max_align;
1053 template <class _Hp, size_t _Len>
1054 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1056 template <size_t _Len, size_t _A1, size_t _A2>
1057 struct __select_align
1060 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1061 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1063 static const size_t value = _Len < __max ? __min : __max;
1066 template <class _Hp, class _Tp, size_t _Len>
1067 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1068 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1070 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1071 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
1073 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1074 static_assert(!is_void<_Aligner>::value, "");
1078 unsigned char __data[_Len];
1082 #if _LIBCPP_STD_VER > 11
1083 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1084 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1087 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1088 template <size_t _Len>\
1089 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
1091 struct _ALIGNAS(n) type\
1093 unsigned char __lx[_Len];\
1097 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1098 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1099 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1100 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1101 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1102 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1103 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1104 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1105 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1106 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1107 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1108 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1109 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1110 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1111 // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1112 #if !defined(_LIBCPP_MSVC)
1113 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1114 #endif // !_LIBCPP_MSVC
1116 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1118 #ifndef _LIBCPP_HAS_NO_VARIADICS
1122 template <size_t _I0, size_t ..._In>
1123 struct __static_max;
1125 template <size_t _I0>
1126 struct __static_max<_I0>
1128 static const size_t value = _I0;
1131 template <size_t _I0, size_t _I1, size_t ..._In>
1132 struct __static_max<_I0, _I1, _In...>
1134 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1135 __static_max<_I1, _In...>::value;
1138 template <size_t _Len, class _Type0, class ..._Types>
1139 struct aligned_union
1141 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1142 __alignof__(_Types)...>::value;
1143 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1144 sizeof(_Types)...>::value;
1145 typedef typename aligned_storage<__len, alignment_value>::type type;
1148 #if _LIBCPP_STD_VER > 11
1149 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1152 #endif // _LIBCPP_HAS_NO_VARIADICS
1156 template <class _A1, class _A2 = void, class _A3 = void,
1157 bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
1158 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
1159 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
1162 template <class _A1, class _A2, class _A3>
1163 class __promote<_A1, _A2, _A3, true>
1166 typedef typename __promote<_A1>::type __type1;
1167 typedef typename __promote<_A2>::type __type2;
1168 typedef typename __promote<_A3>::type __type3;
1170 typedef decltype(__type1() + __type2() + __type3()) type;
1173 template <class _A1, class _A2>
1174 class __promote<_A1, _A2, void, true>
1177 typedef typename __promote<_A1>::type __type1;
1178 typedef typename __promote<_A2>::type __type2;
1180 typedef decltype(__type1() + __type2()) type;
1183 template <class _A1>
1184 class __promote<_A1, void, void, true>
1187 typedef typename conditional<is_arithmetic<_A1>::value,
1188 typename conditional<is_integral<_A1>::value, double, _A1>::type,
1193 #ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1197 template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1198 template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;};
1199 template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;};
1200 template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;};
1201 template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1203 #endif // _LIBCPP_STORE_AS_OPTIMIZATION
1205 // make_signed / make_unsigned
1208 __type_list<signed char,
1209 __type_list<signed short,
1210 __type_list<signed int,
1211 __type_list<signed long,
1212 __type_list<signed long long,
1214 > > > > > __signed_types;
1217 __type_list<unsigned char,
1218 __type_list<unsigned short,
1219 __type_list<unsigned int,
1220 __type_list<unsigned long,
1221 __type_list<unsigned long long,
1223 > > > > > __unsigned_types;
1225 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1227 template <class _Hp, class _Tp, size_t _Size>
1228 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1233 template <class _Hp, class _Tp, size_t _Size>
1234 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1236 typedef typename __find_first<_Tp, _Size>::type type;
1239 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1240 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1246 template <class _Tp, class _Up>
1247 struct __apply_cv<_Tp, _Up, true, false>
1249 typedef const _Up type;
1252 template <class _Tp, class _Up>
1253 struct __apply_cv<_Tp, _Up, false, true>
1255 typedef volatile _Up type;
1258 template <class _Tp, class _Up>
1259 struct __apply_cv<_Tp, _Up, true, true>
1261 typedef const volatile _Up type;
1264 template <class _Tp, class _Up>
1265 struct __apply_cv<_Tp&, _Up, false, false>
1270 template <class _Tp, class _Up>
1271 struct __apply_cv<_Tp&, _Up, true, false>
1273 typedef const _Up& type;
1276 template <class _Tp, class _Up>
1277 struct __apply_cv<_Tp&, _Up, false, true>
1279 typedef volatile _Up& type;
1282 template <class _Tp, class _Up>
1283 struct __apply_cv<_Tp&, _Up, true, true>
1285 typedef const volatile _Up& type;
1288 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1289 struct __make_signed {};
1291 template <class _Tp>
1292 struct __make_signed<_Tp, true>
1294 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1297 template <> struct __make_signed<bool, true> {};
1298 template <> struct __make_signed< signed short, true> {typedef short type;};
1299 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1300 template <> struct __make_signed< signed int, true> {typedef int type;};
1301 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1302 template <> struct __make_signed< signed long, true> {typedef long type;};
1303 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1304 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1305 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1307 template <class _Tp>
1308 struct _LIBCPP_TYPE_VIS_ONLY make_signed
1310 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1313 #if _LIBCPP_STD_VER > 11
1314 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1317 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1318 struct __make_unsigned {};
1320 template <class _Tp>
1321 struct __make_unsigned<_Tp, true>
1323 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1326 template <> struct __make_unsigned<bool, true> {};
1327 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1328 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1329 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1330 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1331 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1332 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1333 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1334 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1336 template <class _Tp>
1337 struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
1339 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1342 #if _LIBCPP_STD_VER > 11
1343 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1346 #ifdef _LIBCPP_HAS_NO_VARIADICS
1348 template <class _Tp, class _Up = void, class V = void>
1349 struct _LIBCPP_TYPE_VIS_ONLY common_type
1352 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1355 template <class _Tp>
1356 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
1362 template <class _Tp, class _Up>
1363 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
1366 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1369 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1372 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1374 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1377 #else // _LIBCPP_HAS_NO_VARIADICS
1379 template <class ..._Tp> struct common_type;
1381 template <class _Tp>
1382 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
1384 typedef typename decay<_Tp>::type type;
1387 template <class _Tp, class _Up>
1388 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
1395 typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
1398 template <class _Tp, class _Up, class ..._Vp>
1399 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
1401 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1404 #if _LIBCPP_STD_VER > 11
1405 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1408 #endif // _LIBCPP_HAS_NO_VARIADICS
1412 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
1414 template <class _Tp, class _Arg>
1415 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
1416 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1417 __is_assignable_test(_Tp&&, _Arg&&);
1419 __is_assignable_test(_Tp, _Arg&);
1422 template <class _Arg>
1424 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1425 __is_assignable_test(__any, _Arg&&);
1427 __is_assignable_test(__any, _Arg&);
1430 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1431 struct __is_assignable_imp
1432 : public common_type
1434 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1437 template <class _Tp, class _Arg>
1438 struct __is_assignable_imp<_Tp, _Arg, true>
1443 template <class _Tp, class _Arg>
1444 struct is_assignable
1445 : public __is_assignable_imp<_Tp, _Arg> {};
1447 // is_copy_assignable
1449 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
1450 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1451 const typename add_lvalue_reference<_Tp>::type> {};
1453 // is_move_assignable
1455 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
1456 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1457 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1458 const typename add_rvalue_reference<_Tp>::type> {};
1460 : public is_copy_assignable<_Tp> {};
1465 template <class _Tp>
1466 struct __destructible_test
1471 template <class _Tp>
1472 decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1473 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1474 __is_destructible_test(_Tp&&);
1476 __is_destructible_test(_Tp&);
1480 __is_destructible_test(__any);
1482 template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value
1483 || is_function<_Tp>::value>
1484 struct __destructible_imp
1485 : public common_type
1487 decltype(__is_destructible_test(declval<_Tp>()))
1490 template <class _Tp>
1491 struct __destructible_imp<_Tp, true>
1492 : public false_type {};
1494 template <class _Tp>
1495 struct is_destructible
1496 : public __destructible_imp<_Tp> {};
1498 template <class _Tp>
1499 struct is_destructible<_Tp[]>
1500 : public false_type {};
1504 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1506 template <class _Tp>
1507 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1508 typename remove_reference<_Tp>::type&&
1509 move(_Tp&& __t) _NOEXCEPT
1511 typedef typename remove_reference<_Tp>::type _Up;
1512 return static_cast<_Up&&>(__t);
1515 template <class _Tp>
1516 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1518 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1520 return static_cast<_Tp&&>(__t);
1523 template <class _Tp>
1524 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1526 forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1528 static_assert(!std::is_lvalue_reference<_Tp>::value,
1529 "Can not forward an rvalue as an lvalue.");
1530 return static_cast<_Tp&&>(__t);
1533 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1535 template <class _Tp>
1536 inline _LIBCPP_INLINE_VISIBILITY
1543 template <class _Tp>
1544 inline _LIBCPP_INLINE_VISIBILITY
1546 move(const _Tp& __t)
1551 template <class _Tp>
1552 inline _LIBCPP_INLINE_VISIBILITY
1554 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1560 template <class _Tp>
1563 typedef typename remove_reference<_Tp>::type _Trr;
1566 _LIBCPP_INLINE_VISIBILITY
1567 _Trr* operator->() {return &t_;}
1568 _LIBCPP_INLINE_VISIBILITY
1569 explicit __rv(_Trr& __t) : t_(__t) {}
1572 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1574 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1576 template <class _Tp>
1577 inline _LIBCPP_INLINE_VISIBILITY
1578 typename decay<_Tp>::type
1579 __decay_copy(_Tp&& __t)
1581 return _VSTD::forward<_Tp>(__t);
1586 template <class _Tp>
1587 inline _LIBCPP_INLINE_VISIBILITY
1588 typename decay<_Tp>::type
1589 __decay_copy(const _Tp& __t)
1591 return _VSTD::forward<_Tp>(__t);
1596 template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1597 struct __member_pointer_traits_imp
1601 #ifndef _LIBCPP_HAS_NO_VARIADICS
1603 template <class _Rp, class _Class, class ..._Param>
1604 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1606 typedef _Class _ClassType;
1607 typedef _Rp _ReturnType;
1610 template <class _Rp, class _Class, class ..._Param>
1611 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1613 typedef _Class const _ClassType;
1614 typedef _Rp _ReturnType;
1617 template <class _Rp, class _Class, class ..._Param>
1618 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1620 typedef _Class volatile _ClassType;
1621 typedef _Rp _ReturnType;
1624 template <class _Rp, class _Class, class ..._Param>
1625 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1627 typedef _Class const volatile _ClassType;
1628 typedef _Rp _ReturnType;
1631 #if __has_feature(cxx_reference_qualified_functions)
1633 template <class _Rp, class _Class, class ..._Param>
1634 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1636 typedef _Class& _ClassType;
1637 typedef _Rp _ReturnType;
1640 template <class _Rp, class _Class, class ..._Param>
1641 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1643 typedef _Class const& _ClassType;
1644 typedef _Rp _ReturnType;
1647 template <class _Rp, class _Class, class ..._Param>
1648 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1650 typedef _Class volatile& _ClassType;
1651 typedef _Rp _ReturnType;
1654 template <class _Rp, class _Class, class ..._Param>
1655 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1657 typedef _Class const volatile& _ClassType;
1658 typedef _Rp _ReturnType;
1661 template <class _Rp, class _Class, class ..._Param>
1662 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1664 typedef _Class&& _ClassType;
1665 typedef _Rp _ReturnType;
1668 template <class _Rp, class _Class, class ..._Param>
1669 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1671 typedef _Class const&& _ClassType;
1672 typedef _Rp _ReturnType;
1675 template <class _Rp, class _Class, class ..._Param>
1676 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1678 typedef _Class volatile&& _ClassType;
1679 typedef _Rp _ReturnType;
1682 template <class _Rp, class _Class, class ..._Param>
1683 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1685 typedef _Class const volatile&& _ClassType;
1686 typedef _Rp _ReturnType;
1689 #endif // __has_feature(cxx_reference_qualified_functions)
1691 #else // _LIBCPP_HAS_NO_VARIADICS
1693 template <class _Rp, class _Class>
1694 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1696 typedef _Class _ClassType;
1697 typedef _Rp _ReturnType;
1700 template <class _Rp, class _Class, class _P0>
1701 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1703 typedef _Class _ClassType;
1704 typedef _Rp _ReturnType;
1707 template <class _Rp, class _Class, class _P0, class _P1>
1708 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1710 typedef _Class _ClassType;
1711 typedef _Rp _ReturnType;
1714 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1715 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1717 typedef _Class _ClassType;
1718 typedef _Rp _ReturnType;
1721 template <class _Rp, class _Class>
1722 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1724 typedef _Class const _ClassType;
1725 typedef _Rp _ReturnType;
1728 template <class _Rp, class _Class, class _P0>
1729 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1731 typedef _Class const _ClassType;
1732 typedef _Rp _ReturnType;
1735 template <class _Rp, class _Class, class _P0, class _P1>
1736 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1738 typedef _Class const _ClassType;
1739 typedef _Rp _ReturnType;
1742 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1743 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1745 typedef _Class const _ClassType;
1746 typedef _Rp _ReturnType;
1749 template <class _Rp, class _Class>
1750 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1752 typedef _Class volatile _ClassType;
1753 typedef _Rp _ReturnType;
1756 template <class _Rp, class _Class, class _P0>
1757 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1759 typedef _Class volatile _ClassType;
1760 typedef _Rp _ReturnType;
1763 template <class _Rp, class _Class, class _P0, class _P1>
1764 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1766 typedef _Class volatile _ClassType;
1767 typedef _Rp _ReturnType;
1770 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1771 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1773 typedef _Class volatile _ClassType;
1774 typedef _Rp _ReturnType;
1777 template <class _Rp, class _Class>
1778 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1780 typedef _Class const volatile _ClassType;
1781 typedef _Rp _ReturnType;
1784 template <class _Rp, class _Class, class _P0>
1785 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1787 typedef _Class const volatile _ClassType;
1788 typedef _Rp _ReturnType;
1791 template <class _Rp, class _Class, class _P0, class _P1>
1792 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1794 typedef _Class const volatile _ClassType;
1795 typedef _Rp _ReturnType;
1798 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1799 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1801 typedef _Class const volatile _ClassType;
1802 typedef _Rp _ReturnType;
1805 #endif // _LIBCPP_HAS_NO_VARIADICS
1807 template <class _Rp, class _Class>
1808 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1810 typedef _Class _ClassType;
1811 typedef _Rp _ReturnType;
1814 template <class _MP>
1815 struct __member_pointer_traits
1816 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
1817 is_member_function_pointer<_MP>::value,
1818 is_member_object_pointer<_MP>::value>
1820 // typedef ... _ClassType;
1821 // typedef ... _ReturnType;
1826 template <class _Callable> class result_of;
1828 #ifdef _LIBCPP_HAS_NO_VARIADICS
1830 template <class _Fn, bool, bool>
1835 template <class _Fn>
1836 class __result_of<_Fn(), true, false>
1839 typedef decltype(declval<_Fn>()()) type;
1842 template <class _Fn, class _A0>
1843 class __result_of<_Fn(_A0), true, false>
1846 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1849 template <class _Fn, class _A0, class _A1>
1850 class __result_of<_Fn(_A0, _A1), true, false>
1853 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1856 template <class _Fn, class _A0, class _A1, class _A2>
1857 class __result_of<_Fn(_A0, _A1, _A2), true, false>
1860 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1863 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1864 struct __result_of_mp;
1866 // member function pointer
1868 template <class _MP, class _Tp>
1869 struct __result_of_mp<_MP, _Tp, true>
1870 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1874 // member data pointer
1876 template <class _MP, class _Tp, bool>
1877 struct __result_of_mdp;
1879 template <class _Rp, class _Class, class _Tp>
1880 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
1882 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1885 template <class _Rp, class _Class, class _Tp>
1886 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
1888 typedef typename __apply_cv<_Tp, _Rp>::type& type;
1891 template <class _Rp, class _Class, class _Tp>
1892 struct __result_of_mp<_Rp _Class::*, _Tp, false>
1893 : public __result_of_mdp<_Rp _Class::*, _Tp,
1894 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1900 template <class _Fn, class _Tp>
1901 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
1902 : public __result_of_mp<typename remove_reference<_Fn>::type,
1904 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1908 template <class _Fn, class _Tp, class _A0>
1909 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
1910 : public __result_of_mp<typename remove_reference<_Fn>::type,
1912 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1916 template <class _Fn, class _Tp, class _A0, class _A1>
1917 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
1918 : public __result_of_mp<typename remove_reference<_Fn>::type,
1920 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1924 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1925 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
1926 : public __result_of_mp<typename remove_reference<_Fn>::type,
1928 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1934 template <class _Fn>
1935 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
1936 : public __result_of<_Fn(),
1937 is_class<typename remove_reference<_Fn>::type>::value ||
1938 is_function<typename remove_reference<_Fn>::type>::value,
1939 is_member_pointer<typename remove_reference<_Fn>::type>::value
1944 template <class _Fn, class _A0>
1945 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
1946 : public __result_of<_Fn(_A0),
1947 is_class<typename remove_reference<_Fn>::type>::value ||
1948 is_function<typename remove_reference<_Fn>::type>::value,
1949 is_member_pointer<typename remove_reference<_Fn>::type>::value
1954 template <class _Fn, class _A0, class _A1>
1955 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
1956 : public __result_of<_Fn(_A0, _A1),
1957 is_class<typename remove_reference<_Fn>::type>::value ||
1958 is_function<typename remove_reference<_Fn>::type>::value,
1959 is_member_pointer<typename remove_reference<_Fn>::type>::value
1964 template <class _Fn, class _A0, class _A1, class _A2>
1965 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
1966 : public __result_of<_Fn(_A0, _A1, _A2),
1967 is_class<typename remove_reference<_Fn>::type>::value ||
1968 is_function<typename remove_reference<_Fn>::type>::value,
1969 is_member_pointer<typename remove_reference<_Fn>::type>::value
1974 #endif // _LIBCPP_HAS_NO_VARIADICS
1976 #ifndef _LIBCPP_HAS_NO_VARIADICS
1978 // template <class T, class... Args> struct is_constructible;
1980 // main is_constructible test
1982 template <class _Tp, class ..._Args>
1983 typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
1984 __is_constructible_test(_Tp&&, _Args&& ...);
1986 template <class ..._Args>
1988 __is_constructible_test(__any, _Args&& ...);
1990 template <bool, class _Tp, class... _Args>
1991 struct __is_constructible // false, _Tp is not a scalar
1992 : public common_type
1994 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1998 // function types are not constructible
2000 template <class _Rp, class... _A1, class... _A2>
2001 struct __is_constructible<false, _Rp(_A1...), _A2...>
2005 // handle scalars and reference types
2007 // Scalars are default constructible, references are not
2009 template <class _Tp>
2010 struct __is_constructible<true, _Tp>
2011 : public is_scalar<_Tp>
2014 // Scalars and references are constructible from one arg if that arg is
2015 // implicitly convertible to the scalar or reference.
2017 template <class _Tp>
2018 struct __is_constructible_ref
2020 true_type static __lxx(_Tp);
2021 false_type static __lxx(...);
2024 template <class _Tp, class _A0>
2025 struct __is_constructible<true, _Tp, _A0>
2026 : public common_type
2028 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2032 // Scalars and references are not constructible from multiple args.
2034 template <class _Tp, class _A0, class ..._Args>
2035 struct __is_constructible<true, _Tp, _A0, _Args...>
2039 // Treat scalars and reference types separately
2041 template <bool, class _Tp, class... _Args>
2042 struct __is_constructible_void_check
2043 : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2047 // If any of T or Args is void, is_constructible should be false
2049 template <class _Tp, class... _Args>
2050 struct __is_constructible_void_check<true, _Tp, _Args...>
2054 template <class ..._Args> struct __contains_void;
2056 template <> struct __contains_void<> : false_type {};
2058 template <class _A0, class ..._Args>
2059 struct __contains_void<_A0, _Args...>
2061 static const bool value = is_void<_A0>::value ||
2062 __contains_void<_Args...>::value;
2065 // is_constructible entry point
2067 template <class _Tp, class... _Args>
2068 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2069 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2070 || is_abstract<_Tp>::value,
2074 // Array types are default constructible if their element type
2075 // is default constructible
2077 template <class _Ap, size_t _Np>
2078 struct __is_constructible<false, _Ap[_Np]>
2079 : public is_constructible<typename remove_all_extents<_Ap>::type>
2082 // Otherwise array types are not constructible by this syntax
2084 template <class _Ap, size_t _Np, class ..._Args>
2085 struct __is_constructible<false, _Ap[_Np], _Args...>
2089 // Incomplete array types are not constructible
2091 template <class _Ap, class ..._Args>
2092 struct __is_constructible<false, _Ap[], _Args...>
2096 #else // _LIBCPP_HAS_NO_VARIADICS
2098 // template <class T> struct is_constructible0;
2100 // main is_constructible0 test
2102 template <class _Tp>
2103 decltype((_Tp(), true_type()))
2104 __is_constructible0_test(_Tp&);
2107 __is_constructible0_test(__any);
2109 template <class _Tp, class _A0>
2110 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2111 __is_constructible1_test(_Tp&, _A0&);
2113 template <class _A0>
2115 __is_constructible1_test(__any, _A0&);
2117 template <class _Tp, class _A0, class _A1>
2118 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2119 __is_constructible2_test(_Tp&, _A0&, _A1&);
2121 template <class _A0, class _A1>
2123 __is_constructible2_test(__any, _A0&, _A1&);
2125 template <bool, class _Tp>
2126 struct __is_constructible0_imp // false, _Tp is not a scalar
2127 : public common_type
2129 decltype(__is_constructible0_test(declval<_Tp&>()))
2133 template <bool, class _Tp, class _A0>
2134 struct __is_constructible1_imp // false, _Tp is not a scalar
2135 : public common_type
2137 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2141 template <bool, class _Tp, class _A0, class _A1>
2142 struct __is_constructible2_imp // false, _Tp is not a scalar
2143 : public common_type
2145 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2149 // handle scalars and reference types
2151 // Scalars are default constructible, references are not
2153 template <class _Tp>
2154 struct __is_constructible0_imp<true, _Tp>
2155 : public is_scalar<_Tp>
2158 template <class _Tp, class _A0>
2159 struct __is_constructible1_imp<true, _Tp, _A0>
2160 : public is_convertible<_A0, _Tp>
2163 template <class _Tp, class _A0, class _A1>
2164 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
2168 // Treat scalars and reference types separately
2170 template <bool, class _Tp>
2171 struct __is_constructible0_void_check
2172 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2176 template <bool, class _Tp, class _A0>
2177 struct __is_constructible1_void_check
2178 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2182 template <bool, class _Tp, class _A0, class _A1>
2183 struct __is_constructible2_void_check
2184 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2188 // If any of T or Args is void, is_constructible should be false
2190 template <class _Tp>
2191 struct __is_constructible0_void_check<true, _Tp>
2195 template <class _Tp, class _A0>
2196 struct __is_constructible1_void_check<true, _Tp, _A0>
2200 template <class _Tp, class _A0, class _A1>
2201 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2205 // is_constructible entry point
2207 namespace __is_construct
2214 template <class _Tp, class _A0 = __is_construct::__nat,
2215 class _A1 = __is_construct::__nat>
2216 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2217 : public __is_constructible2_void_check<is_void<_Tp>::value
2218 || is_abstract<_Tp>::value
2219 || is_function<_Tp>::value
2220 || is_void<_A0>::value
2221 || is_void<_A1>::value,
2225 template <class _Tp>
2226 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2227 : public __is_constructible0_void_check<is_void<_Tp>::value
2228 || is_abstract<_Tp>::value
2229 || is_function<_Tp>::value,
2233 template <class _Tp, class _A0>
2234 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
2235 : public __is_constructible1_void_check<is_void<_Tp>::value
2236 || is_abstract<_Tp>::value
2237 || is_function<_Tp>::value
2238 || is_void<_A0>::value,
2242 // Array types are default constructible if their element type
2243 // is default constructible
2245 template <class _Ap, size_t _Np>
2246 struct __is_constructible0_imp<false, _Ap[_Np]>
2247 : public is_constructible<typename remove_all_extents<_Ap>::type>
2250 template <class _Ap, size_t _Np, class _A0>
2251 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
2255 template <class _Ap, size_t _Np, class _A0, class _A1>
2256 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2260 // Incomplete array types are not constructible
2262 template <class _Ap>
2263 struct __is_constructible0_imp<false, _Ap[]>
2267 template <class _Ap, class _A0>
2268 struct __is_constructible1_imp<false, _Ap[], _A0>
2272 template <class _Ap, class _A0, class _A1>
2273 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2277 #endif // _LIBCPP_HAS_NO_VARIADICS
2279 // is_default_constructible
2281 template <class _Tp>
2282 struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
2283 : public is_constructible<_Tp>
2286 // is_copy_constructible
2288 template <class _Tp>
2289 struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
2290 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2293 // is_move_constructible
2295 template <class _Tp>
2296 struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
2297 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2298 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2300 : public is_copy_constructible<_Tp>
2304 // is_trivially_constructible
2306 #ifndef _LIBCPP_HAS_NO_VARIADICS
2308 #if __has_feature(is_trivially_constructible)
2310 template <class _Tp, class... _Args>
2311 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2312 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2316 #else // !__has_feature(is_trivially_constructible)
2318 template <class _Tp, class... _Args>
2319 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2324 template <class _Tp>
2325 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
2326 #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2327 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2329 : integral_constant<bool, is_scalar<_Tp>::value>
2334 template <class _Tp>
2335 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2336 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
2338 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
2340 : integral_constant<bool, is_scalar<_Tp>::value>
2344 template <class _Tp>
2345 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
2346 : integral_constant<bool, is_scalar<_Tp>::value>
2350 template <class _Tp>
2351 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
2352 : integral_constant<bool, is_scalar<_Tp>::value>
2356 #endif // !__has_feature(is_trivially_constructible)
2358 #else // _LIBCPP_HAS_NO_VARIADICS
2360 template <class _Tp, class _A0 = __is_construct::__nat,
2361 class _A1 = __is_construct::__nat>
2362 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2367 #if __has_feature(is_trivially_constructible)
2369 template <class _Tp>
2370 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2371 __is_construct::__nat>
2372 : integral_constant<bool, __is_trivially_constructible(_Tp)>
2376 template <class _Tp>
2377 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2378 __is_construct::__nat>
2379 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2383 template <class _Tp>
2384 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2385 __is_construct::__nat>
2386 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2390 template <class _Tp>
2391 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2392 __is_construct::__nat>
2393 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2397 #else // !__has_feature(is_trivially_constructible)
2399 template <class _Tp>
2400 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2401 __is_construct::__nat>
2402 : integral_constant<bool, is_scalar<_Tp>::value>
2406 template <class _Tp>
2407 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2408 __is_construct::__nat>
2409 : integral_constant<bool, is_scalar<_Tp>::value>
2413 template <class _Tp>
2414 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2415 __is_construct::__nat>
2416 : integral_constant<bool, is_scalar<_Tp>::value>
2420 template <class _Tp>
2421 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2422 __is_construct::__nat>
2423 : integral_constant<bool, is_scalar<_Tp>::value>
2427 #endif // !__has_feature(is_trivially_constructible)
2429 #endif // _LIBCPP_HAS_NO_VARIADICS
2431 // is_trivially_default_constructible
2433 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
2434 : public is_trivially_constructible<_Tp>
2437 // is_trivially_copy_constructible
2439 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
2440 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2443 // is_trivially_move_constructible
2445 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
2446 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2447 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2449 : public is_trivially_copy_constructible<_Tp>
2453 // is_trivially_assignable
2455 #if __has_feature(is_trivially_constructible)
2457 template <class _Tp, class _Arg>
2458 struct is_trivially_assignable
2459 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2463 #else // !__has_feature(is_trivially_constructible)
2465 template <class _Tp, class _Arg>
2466 struct is_trivially_assignable
2467 : public false_type {};
2469 template <class _Tp>
2470 struct is_trivially_assignable<_Tp&, _Tp>
2471 : integral_constant<bool, is_scalar<_Tp>::value> {};
2473 template <class _Tp>
2474 struct is_trivially_assignable<_Tp&, _Tp&>
2475 : integral_constant<bool, is_scalar<_Tp>::value> {};
2477 template <class _Tp>
2478 struct is_trivially_assignable<_Tp&, const _Tp&>
2479 : integral_constant<bool, is_scalar<_Tp>::value> {};
2481 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2483 template <class _Tp>
2484 struct is_trivially_assignable<_Tp&, _Tp&&>
2485 : integral_constant<bool, is_scalar<_Tp>::value> {};
2487 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2489 #endif // !__has_feature(is_trivially_constructible)
2491 // is_trivially_copy_assignable
2493 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
2494 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2495 const typename add_lvalue_reference<_Tp>::type>
2498 // is_trivially_move_assignable
2500 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
2501 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2502 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2503 typename add_rvalue_reference<_Tp>::type>
2505 typename add_lvalue_reference<_Tp>::type>
2509 // is_trivially_destructible
2511 #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2513 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2514 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2516 #else // _LIBCPP_HAS_TYPE_TRAITS
2518 template <class _Tp> struct __libcpp_trivial_destructor
2519 : public integral_constant<bool, is_scalar<_Tp>::value ||
2520 is_reference<_Tp>::value> {};
2522 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2523 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2525 #endif // _LIBCPP_HAS_TYPE_TRAITS
2527 // is_nothrow_constructible
2529 #ifndef _LIBCPP_HAS_NO_VARIADICS
2531 #if __has_feature(cxx_noexcept)
2533 template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2535 template <class _Tp, class... _Args>
2536 struct __is_nothrow_constructible<true, _Tp, _Args...>
2537 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2541 template <class _Tp, class... _Args>
2542 struct __is_nothrow_constructible<false, _Tp, _Args...>
2547 template <class _Tp, class... _Args>
2548 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2549 : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2553 template <class _Tp, size_t _Ns>
2554 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
2555 : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2559 #else // __has_feature(cxx_noexcept)
2561 template <class _Tp, class... _Args>
2562 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2567 template <class _Tp>
2568 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
2569 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2570 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2572 : integral_constant<bool, is_scalar<_Tp>::value>
2577 template <class _Tp>
2578 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2579 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
2581 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
2583 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2584 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2586 : integral_constant<bool, is_scalar<_Tp>::value>
2591 template <class _Tp>
2592 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
2593 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2594 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2596 : integral_constant<bool, is_scalar<_Tp>::value>
2601 template <class _Tp>
2602 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
2603 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2604 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2606 : integral_constant<bool, is_scalar<_Tp>::value>
2611 #endif // __has_feature(cxx_noexcept)
2613 #else // _LIBCPP_HAS_NO_VARIADICS
2615 template <class _Tp, class _A0 = __is_construct::__nat,
2616 class _A1 = __is_construct::__nat>
2617 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2622 template <class _Tp>
2623 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
2624 __is_construct::__nat>
2625 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2626 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2628 : integral_constant<bool, is_scalar<_Tp>::value>
2633 template <class _Tp>
2634 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
2635 __is_construct::__nat>
2636 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2637 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2639 : integral_constant<bool, is_scalar<_Tp>::value>
2644 template <class _Tp>
2645 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
2646 __is_construct::__nat>
2647 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2648 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2650 : integral_constant<bool, is_scalar<_Tp>::value>
2655 template <class _Tp>
2656 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
2657 __is_construct::__nat>
2658 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2659 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2661 : integral_constant<bool, is_scalar<_Tp>::value>
2666 #endif // _LIBCPP_HAS_NO_VARIADICS
2668 // is_nothrow_default_constructible
2670 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
2671 : public is_nothrow_constructible<_Tp>
2674 // is_nothrow_copy_constructible
2676 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
2677 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2680 // is_nothrow_move_constructible
2682 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
2683 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2684 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2686 : public is_nothrow_copy_constructible<_Tp>
2690 // is_nothrow_assignable
2692 #if __has_feature(cxx_noexcept)
2694 template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2696 template <class _Tp, class _Arg>
2697 struct __is_nothrow_assignable<false, _Tp, _Arg>
2702 template <class _Tp, class _Arg>
2703 struct __is_nothrow_assignable<true, _Tp, _Arg>
2704 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2708 template <class _Tp, class _Arg>
2709 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
2710 : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2714 #else // __has_feature(cxx_noexcept)
2716 template <class _Tp, class _Arg>
2717 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
2718 : public false_type {};
2720 template <class _Tp>
2721 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
2722 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2723 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2725 : integral_constant<bool, is_scalar<_Tp>::value> {};
2728 template <class _Tp>
2729 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
2730 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2731 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2733 : integral_constant<bool, is_scalar<_Tp>::value> {};
2736 template <class _Tp>
2737 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
2738 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2739 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2741 : integral_constant<bool, is_scalar<_Tp>::value> {};
2744 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2746 template <class _Tp>
2747 struct is_nothrow_assignable<_Tp&, _Tp&&>
2748 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2749 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2751 : integral_constant<bool, is_scalar<_Tp>::value> {};
2754 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2756 #endif // __has_feature(cxx_noexcept)
2758 // is_nothrow_copy_assignable
2760 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
2761 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2762 const typename add_lvalue_reference<_Tp>::type>
2765 // is_nothrow_move_assignable
2767 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
2768 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2769 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2770 typename add_rvalue_reference<_Tp>::type>
2772 typename add_lvalue_reference<_Tp>::type>
2776 // is_nothrow_destructible
2778 #if __has_feature(cxx_noexcept)
2780 template <bool, class _Tp> struct __is_nothrow_destructible;
2782 template <class _Tp>
2783 struct __is_nothrow_destructible<false, _Tp>
2788 template <class _Tp>
2789 struct __is_nothrow_destructible<true, _Tp>
2790 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2794 template <class _Tp>
2795 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
2796 : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2800 template <class _Tp, size_t _Ns>
2801 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
2802 : public is_nothrow_destructible<_Tp>
2806 template <class _Tp>
2807 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
2812 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2814 template <class _Tp>
2815 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
2824 template <class _Tp> struct __libcpp_nothrow_destructor
2825 : public integral_constant<bool, is_scalar<_Tp>::value ||
2826 is_reference<_Tp>::value> {};
2828 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
2829 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2835 #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2837 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
2838 : public integral_constant<bool, __is_pod(_Tp)> {};
2840 #else // _LIBCPP_HAS_TYPE_TRAITS
2842 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
2843 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
2844 is_trivially_copy_constructible<_Tp>::value &&
2845 is_trivially_copy_assignable<_Tp>::value &&
2846 is_trivially_destructible<_Tp>::value> {};
2848 #endif // _LIBCPP_HAS_TYPE_TRAITS
2852 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
2853 #if __has_feature(is_literal)
2854 : public integral_constant<bool, __is_literal(_Tp)>
2856 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2857 is_reference<typename remove_all_extents<_Tp>::type>::value>
2861 // is_standard_layout;
2863 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
2864 #if __has_feature(is_standard_layout)
2865 : public integral_constant<bool, __is_standard_layout(_Tp)>
2867 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2871 // is_trivially_copyable;
2873 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
2874 #if __has_feature(is_trivially_copyable)
2875 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2877 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2883 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
2884 #if __has_feature(is_trivial)
2885 : public integral_constant<bool, __is_trivial(_Tp)>
2887 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2888 is_trivially_default_constructible<_Tp>::value>
2892 #ifndef _LIBCPP_HAS_NO_VARIADICS
2894 // Check for complete types
2896 template <class ..._Tp> struct __check_complete;
2899 struct __check_complete<>
2903 template <class _Hp, class _T0, class ..._Tp>
2904 struct __check_complete<_Hp, _T0, _Tp...>
2905 : private __check_complete<_Hp>,
2906 private __check_complete<_T0, _Tp...>
2910 template <class _Hp>
2911 struct __check_complete<_Hp, _Hp>
2912 : private __check_complete<_Hp>
2916 template <class _Tp>
2917 struct __check_complete<_Tp>
2919 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2922 template <class _Tp>
2923 struct __check_complete<_Tp&>
2924 : private __check_complete<_Tp>
2928 template <class _Tp>
2929 struct __check_complete<_Tp&&>
2930 : private __check_complete<_Tp>
2934 template <class _Rp, class ..._Param>
2935 struct __check_complete<_Rp (*)(_Param...)>
2936 : private __check_complete<_Rp>
2940 template <class ..._Param>
2941 struct __check_complete<void (*)(_Param...)>
2945 template <class _Rp, class ..._Param>
2946 struct __check_complete<_Rp (_Param...)>
2947 : private __check_complete<_Rp>
2951 template <class ..._Param>
2952 struct __check_complete<void (_Param...)>
2956 template <class _Rp, class _Class, class ..._Param>
2957 struct __check_complete<_Rp (_Class::*)(_Param...)>
2958 : private __check_complete<_Class>
2962 template <class _Rp, class _Class, class ..._Param>
2963 struct __check_complete<_Rp (_Class::*)(_Param...) const>
2964 : private __check_complete<_Class>
2968 template <class _Rp, class _Class, class ..._Param>
2969 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
2970 : private __check_complete<_Class>
2974 template <class _Rp, class _Class, class ..._Param>
2975 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
2976 : private __check_complete<_Class>
2980 #if __has_feature(cxx_reference_qualified_functions)
2982 template <class _Rp, class _Class, class ..._Param>
2983 struct __check_complete<_Rp (_Class::*)(_Param...) &>
2984 : private __check_complete<_Class>
2988 template <class _Rp, class _Class, class ..._Param>
2989 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
2990 : private __check_complete<_Class>
2994 template <class _Rp, class _Class, class ..._Param>
2995 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
2996 : private __check_complete<_Class>
3000 template <class _Rp, class _Class, class ..._Param>
3001 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
3002 : private __check_complete<_Class>
3006 template <class _Rp, class _Class, class ..._Param>
3007 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
3008 : private __check_complete<_Class>
3012 template <class _Rp, class _Class, class ..._Param>
3013 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
3014 : private __check_complete<_Class>
3018 template <class _Rp, class _Class, class ..._Param>
3019 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
3020 : private __check_complete<_Class>
3024 template <class _Rp, class _Class, class ..._Param>
3025 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
3026 : private __check_complete<_Class>
3032 template <class _Rp, class _Class>
3033 struct __check_complete<_Rp _Class::*>
3034 : private __check_complete<_Class>
3038 // __invoke forward declarations
3040 // fall back - none of the bullets
3042 template <class ..._Args>
3044 __invoke(__any, _Args&& ...__args)
3049 template <class _Fp, class _A0, class ..._Args,
3050 class = typename enable_if
3052 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3053 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3054 typename remove_reference<_A0>::type>::value
3057 _LIBCPP_INLINE_VISIBILITY
3059 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3060 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
3062 template <class _Fp, class _A0, class ..._Args,
3063 class = typename enable_if
3065 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3066 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3067 typename remove_reference<_A0>::type>::value
3070 _LIBCPP_INLINE_VISIBILITY
3072 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3073 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
3077 template <class _Fp, class _A0,
3078 class = typename enable_if
3080 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3081 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3082 typename remove_reference<_A0>::type>::value
3085 _LIBCPP_INLINE_VISIBILITY
3087 __invoke(_Fp&& __f, _A0&& __a0)
3088 -> decltype(_VSTD::forward<_A0>(__a0).*__f);
3090 template <class _Fp, class _A0,
3091 class = typename enable_if
3093 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3094 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3095 typename remove_reference<_A0>::type>::value
3098 _LIBCPP_INLINE_VISIBILITY
3100 __invoke(_Fp&& __f, _A0&& __a0)
3101 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
3105 template <class _Fp, class ..._Args>
3106 _LIBCPP_INLINE_VISIBILITY
3108 __invoke(_Fp&& __f, _Args&& ...__args)
3109 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
3113 template <class _Fp, class ..._Args>
3114 struct __invokable_imp
3115 : private __check_complete<_Fp>
3118 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
3120 static const bool value = !is_same<type, __nat>::value;
3123 template <class _Fp, class ..._Args>
3125 : public integral_constant<bool,
3126 __invokable_imp<_Fp, _Args...>::value>
3132 template <bool _Invokable, class _Fp, class ..._Args>
3133 struct __invoke_of_imp // false
3137 template <class _Fp, class ..._Args>
3138 struct __invoke_of_imp<true, _Fp, _Args...>
3140 typedef typename __invokable_imp<_Fp, _Args...>::type type;
3143 template <class _Fp, class ..._Args>
3145 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
3149 template <class _Fp, class ..._Args>
3150 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
3151 : public __invoke_of<_Fp, _Args...>
3155 #if _LIBCPP_STD_VER > 11
3156 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3159 #endif // _LIBCPP_HAS_NO_VARIADICS
3161 template <class _Tp>
3162 inline _LIBCPP_INLINE_VISIBILITY
3163 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3166 is_move_constructible<_Tp>::value &&
3167 is_move_assignable<_Tp>::value
3172 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3173 is_nothrow_move_assignable<_Tp>::value)
3175 _Tp __t(_VSTD::move(__x));
3176 __x = _VSTD::move(__y);
3177 __y = _VSTD::move(__t);
3180 template <class _ForwardIterator1, class _ForwardIterator2>
3181 inline _LIBCPP_INLINE_VISIBILITY
3183 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3184 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3185 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3186 *_VSTD::declval<_ForwardIterator2>())))
3197 __nat swap(__any, __any);
3199 template <class _Tp>
3202 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3203 static const bool value = !is_same<type, __nat>::value;
3208 template <class _Tp>
3209 struct __is_swappable
3210 : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3214 #if __has_feature(cxx_noexcept)
3216 template <bool, class _Tp>
3217 struct __is_nothrow_swappable_imp
3218 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3219 _VSTD::declval<_Tp&>()))>
3223 template <class _Tp>
3224 struct __is_nothrow_swappable_imp<false, _Tp>
3229 template <class _Tp>
3230 struct __is_nothrow_swappable
3231 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3235 #else // __has_feature(cxx_noexcept)
3237 template <class _Tp>
3238 struct __is_nothrow_swappable
3243 #endif // __has_feature(cxx_noexcept)
3245 #ifdef _LIBCXX_UNDERLYING_TYPE
3247 template <class _Tp>
3248 struct underlying_type
3250 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3253 #if _LIBCPP_STD_VER > 11
3254 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3257 #else // _LIBCXX_UNDERLYING_TYPE
3259 template <class _Tp, bool _Support = false>
3260 struct underlying_type
3262 static_assert(_Support, "The underyling_type trait requires compiler "
3263 "support. Either no such support exists or "
3264 "libc++ does not know how to use it.");
3267 #endif // _LIBCXX_UNDERLYING_TYPE
3269 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3271 template <class _Tp>
3272 struct __has_operator_addressof_imp
3275 static auto __test(__any) -> false_type;
3276 template <class _Up>
3277 static auto __test(_Up* __u)
3278 -> typename __select_2nd<decltype(__u->operator&()), true_type>::type;
3280 static const bool value = decltype(__test<_Tp>(nullptr))::value;
3283 template <class _Tp>
3284 struct __has_operator_addressof
3285 : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value>
3288 #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
3290 _LIBCPP_END_NAMESPACE_STD
3292 #endif // _LIBCPP_TYPE_TRAITS