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;
94 template <class T> struct is_final; // C++14
96 template <class T, class... Args> struct is_constructible;
97 template <class T> struct is_default_constructible;
98 template <class T> struct is_copy_constructible;
99 template <class T> struct is_move_constructible;
100 template <class T, class U> struct is_assignable;
101 template <class T> struct is_copy_assignable;
102 template <class T> struct is_move_assignable;
103 template <class T> struct is_destructible;
105 template <class T, class... Args> struct is_trivially_constructible;
106 template <class T> struct is_trivially_default_constructible;
107 template <class T> struct is_trivially_copy_constructible;
108 template <class T> struct is_trivially_move_constructible;
109 template <class T, class U> struct is_trivially_assignable;
110 template <class T> struct is_trivially_copy_assignable;
111 template <class T> struct is_trivially_move_assignable;
112 template <class T> struct is_trivially_destructible;
114 template <class T, class... Args> struct is_nothrow_constructible;
115 template <class T> struct is_nothrow_default_constructible;
116 template <class T> struct is_nothrow_copy_constructible;
117 template <class T> struct is_nothrow_move_constructible;
118 template <class T, class U> struct is_nothrow_assignable;
119 template <class T> struct is_nothrow_copy_assignable;
120 template <class T> struct is_nothrow_move_assignable;
121 template <class T> struct is_nothrow_destructible;
123 template <class T> struct has_virtual_destructor;
125 // Relationships between types:
126 template <class T, class U> struct is_same;
127 template <class Base, class Derived> struct is_base_of;
128 template <class From, class To> struct is_convertible;
130 // Alignment properties and transformations:
131 template <class T> struct alignment_of;
132 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
133 struct aligned_storage;
134 template <size_t Len, class... Types> struct aligned_union;
136 template <class T> struct decay;
137 template <class... T> struct common_type;
138 template <class T> struct underlying_type;
139 template <class> class result_of; // undefined
140 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
142 // const-volatile modifications:
144 using remove_const_t = typename remove_const<T>::type; // C++14
146 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
148 using remove_cv_t = typename remove_cv<T>::type; // C++14
150 using add_const_t = typename add_const<T>::type; // C++14
152 using add_volatile_t = typename add_volatile<T>::type; // C++14
154 using add_cv_t = typename add_cv<T>::type; // C++14
156 // reference modifications:
158 using remove_reference_t = typename remove_reference<T>::type; // C++14
160 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
162 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
164 // sign modifications:
166 using make_signed_t = typename make_signed<T>::type; // C++14
168 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
170 // array modifications:
172 using remove_extent_t = typename remove_extent<T>::type; // C++14
174 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
176 // pointer modifications:
178 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
180 using add_pointer_t = typename add_pointer<T>::type; // C++14
182 // other transformations:
183 template <size_t Len, std::size_t Align=default-alignment>
184 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
185 template <std::size_t Len, class... Types>
186 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
188 using decay_t = typename decay<T>::type; // C++14
189 template <bool b, class T=void>
190 using enable_if_t = typename enable_if<b,T>::type; // C++14
191 template <bool b, class T, class F>
192 using conditional_t = typename conditional<b,T,F>::type; // C++14
193 template <class... T>
194 using common_type_t = typename common_type<T...>::type; // C++14
196 using underlying_type_t = typename underlying_type<T>::type; // C++14
197 template <class F, class... ArgTypes>
198 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
208 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
209 #pragma GCC system_header
212 _LIBCPP_BEGIN_NAMESPACE_STD
214 #ifndef _LIBCPP_HAS_NO_VARIADICS
216 struct __void_t { typedef void type; };
219 template <bool _Bp, class _If, class _Then>
220 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
221 template <class _If, class _Then>
222 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
224 #if _LIBCPP_STD_VER > 11
225 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
228 template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
229 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
231 template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
232 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
234 #if _LIBCPP_STD_VER > 11
235 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
239 struct __two {char __lx[2];};
243 template <class _Tp, _Tp __v>
244 struct _LIBCPP_TYPE_VIS_ONLY integral_constant
246 static _LIBCPP_CONSTEXPR const _Tp value = __v;
247 typedef _Tp value_type;
248 typedef integral_constant type;
249 _LIBCPP_INLINE_VISIBILITY
250 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
251 #if _LIBCPP_STD_VER > 11
252 _LIBCPP_INLINE_VISIBILITY
253 constexpr value_type operator ()() const _NOEXCEPT {return value;}
257 template <class _Tp, _Tp __v>
258 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
260 typedef integral_constant<bool, true> true_type;
261 typedef integral_constant<bool, false> false_type;
265 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
266 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
270 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
271 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
275 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
276 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
277 #if _LIBCPP_STD_VER > 11
278 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
283 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
284 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
285 #if _LIBCPP_STD_VER > 11
286 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
291 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
292 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
293 #if _LIBCPP_STD_VER > 11
294 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
299 template <class _Tp> struct __libcpp_is_void : public false_type {};
300 template <> struct __libcpp_is_void<void> : public true_type {};
302 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
303 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
307 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
308 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
310 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
311 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
313 #if _LIBCPP_STD_VER > 11
314 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
315 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
320 template <class _Tp> struct __libcpp_is_integral : public false_type {};
321 template <> struct __libcpp_is_integral<bool> : public true_type {};
322 template <> struct __libcpp_is_integral<char> : public true_type {};
323 template <> struct __libcpp_is_integral<signed char> : public true_type {};
324 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
325 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
326 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
327 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
328 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
329 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
330 template <> struct __libcpp_is_integral<short> : public true_type {};
331 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
332 template <> struct __libcpp_is_integral<int> : public true_type {};
333 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
334 template <> struct __libcpp_is_integral<long> : public true_type {};
335 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
336 template <> struct __libcpp_is_integral<long long> : public true_type {};
337 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
338 #ifndef _LIBCPP_HAS_NO_INT128
339 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
340 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
343 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
344 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
348 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
349 template <> struct __libcpp_is_floating_point<float> : public true_type {};
350 template <> struct __libcpp_is_floating_point<double> : public true_type {};
351 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
353 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
354 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
358 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
359 : public false_type {};
360 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
361 : public true_type {};
362 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
363 : public true_type {};
367 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
368 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
370 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
371 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
375 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
376 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
378 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
379 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
380 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
383 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
384 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
385 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
386 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
391 #if __has_feature(is_union) || (_GNUC_VER >= 403)
393 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
394 : public integral_constant<bool, __is_union(_Tp)> {};
398 template <class _Tp> struct __libcpp_union : public false_type {};
399 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
400 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
406 #if __has_feature(is_class) || (_GNUC_VER >= 403)
408 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
409 : public integral_constant<bool, __is_class(_Tp)> {};
413 namespace __is_class_imp
415 template <class _Tp> char __test(int _Tp::*);
416 template <class _Tp> __two __test(...);
419 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
420 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
426 template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
427 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
431 namespace __libcpp_is_function_imp
433 template <class _Tp> char __test(_Tp*);
434 template <class _Tp> __two __test(...);
435 template <class _Tp> _Tp& __source();
438 template <class _Tp, bool = is_class<_Tp>::value ||
439 is_union<_Tp>::value ||
440 is_void<_Tp>::value ||
441 is_reference<_Tp>::value ||
442 __is_nullptr_t<_Tp>::value >
443 struct __libcpp_is_function
444 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>())) == 1>
446 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
448 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
449 : public __libcpp_is_function<_Tp> {};
451 // is_member_function_pointer
453 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
454 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
457 template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
458 struct __member_pointer_traits_imp
459 { // forward declaration; specializations later
463 namespace __libcpp_is_member_function_pointer_imp {
464 template <typename _Tp>
465 char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *);
468 std::__two __test(...);
471 template <class _Tp> struct __libcpp_is_member_function_pointer
472 : public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {};
474 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
475 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
479 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
480 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
482 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
483 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
485 // is_member_object_pointer
487 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
488 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
489 !is_member_function_pointer<_Tp>::value> {};
493 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
495 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
496 : public integral_constant<bool, __is_enum(_Tp)> {};
500 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
501 : public integral_constant<bool, !is_void<_Tp>::value &&
502 !is_integral<_Tp>::value &&
503 !is_floating_point<_Tp>::value &&
504 !is_array<_Tp>::value &&
505 !is_pointer<_Tp>::value &&
506 !is_reference<_Tp>::value &&
507 !is_member_pointer<_Tp>::value &&
508 !is_union<_Tp>::value &&
509 !is_class<_Tp>::value &&
510 !is_function<_Tp>::value > {};
516 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
517 : public integral_constant<bool, is_integral<_Tp>::value ||
518 is_floating_point<_Tp>::value> {};
522 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
523 : public integral_constant<bool, is_void<_Tp>::value ||
524 __is_nullptr_t<_Tp>::value ||
525 is_arithmetic<_Tp>::value> {};
529 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
530 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
531 is_member_pointer<_Tp>::value ||
532 is_pointer<_Tp>::value ||
533 __is_nullptr_t<_Tp>::value ||
534 is_enum<_Tp>::value > {};
536 template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
540 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
541 : public integral_constant<bool, is_scalar<_Tp>::value ||
542 is_array<_Tp>::value ||
543 is_union<_Tp>::value ||
544 is_class<_Tp>::value > {};
548 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
549 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
553 template <class _Tp, bool = is_reference<_Tp>::value ||
554 is_function<_Tp>::value ||
555 is_const<_Tp>::value >
556 struct __add_const {typedef _Tp type;};
559 struct __add_const<_Tp, false> {typedef const _Tp type;};
561 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
562 {typedef typename __add_const<_Tp>::type type;};
564 #if _LIBCPP_STD_VER > 11
565 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
570 template <class _Tp, bool = is_reference<_Tp>::value ||
571 is_function<_Tp>::value ||
572 is_volatile<_Tp>::value >
573 struct __add_volatile {typedef _Tp type;};
576 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
578 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
579 {typedef typename __add_volatile<_Tp>::type type;};
581 #if _LIBCPP_STD_VER > 11
582 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
587 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
588 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
590 #if _LIBCPP_STD_VER > 11
591 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
596 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
597 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
598 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
599 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
602 #if _LIBCPP_STD_VER > 11
603 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
606 // add_lvalue_reference
608 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;};
609 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
610 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;};
611 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;};
612 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;};
613 template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
615 #if _LIBCPP_STD_VER > 11
616 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
619 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
621 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;};
622 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;};
623 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;};
624 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;};
625 template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
627 #if _LIBCPP_STD_VER > 11
628 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
631 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
633 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
636 typename add_rvalue_reference<_Tp>::type
639 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
642 typename add_lvalue_reference<_Tp>::type
645 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
654 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
655 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
656 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
657 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
658 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
660 #if _LIBCPP_STD_VER > 11
661 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
666 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
667 {typedef typename remove_reference<_Tp>::type* type;};
669 #if _LIBCPP_STD_VER > 11
670 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
675 template <class _Tp, bool = is_integral<_Tp>::value>
676 struct __libcpp_is_signed_impl : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
679 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
681 template <class _Tp, bool = is_arithmetic<_Tp>::value>
682 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
684 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
686 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
690 template <class _Tp, bool = is_integral<_Tp>::value>
691 struct __libcpp_is_unsigned_impl : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
694 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
696 template <class _Tp, bool = is_arithmetic<_Tp>::value>
697 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
699 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
701 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
705 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
706 : public integral_constant<size_t, 0> {};
707 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
708 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
709 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
710 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
714 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
715 : public integral_constant<size_t, 0> {};
716 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
717 : public integral_constant<size_t, 0> {};
718 template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
719 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
720 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
721 : public integral_constant<size_t, _Np> {};
722 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
723 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
727 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
729 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
731 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
734 #if _LIBCPP_STD_VER > 11
735 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
738 // remove_all_extents
740 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
742 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
743 {typedef typename remove_all_extents<_Tp>::type type;};
744 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
745 {typedef typename remove_all_extents<_Tp>::type type;};
747 #if _LIBCPP_STD_VER > 11
748 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
754 struct _LIBCPP_TYPE_VIS_ONLY decay
757 typedef typename remove_reference<_Tp>::type _Up;
759 typedef typename conditional
761 is_array<_Up>::value,
762 typename remove_extent<_Up>::type*,
765 is_function<_Up>::value,
766 typename add_pointer<_Up>::type,
767 typename remove_cv<_Up>::type
772 #if _LIBCPP_STD_VER > 11
773 template <class _Tp> using decay_t = typename decay<_Tp>::type;
778 namespace __is_abstract_imp
780 template <class _Tp> char __test(_Tp (*)[1]);
781 template <class _Tp> __two __test(...);
784 template <class _Tp, bool = is_class<_Tp>::value>
785 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
787 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
789 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
793 #if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
794 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
795 is_final : public integral_constant<bool, __is_final(_Tp)> {};
800 #ifdef _LIBCPP_HAS_IS_BASE_OF
802 template <class _Bp, class _Dp>
803 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
804 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
806 #else // _LIBCPP_HAS_IS_BASE_OF
808 namespace __is_base_of_imp
813 _Dst(const volatile _Tp &);
818 operator const volatile _Tp &();
819 template <class _Up> operator const _Dst<_Up> &();
821 template <size_t> struct __one { typedef char type; };
822 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
823 template <class _Bp, class _Dp> __two __test(...);
826 template <class _Bp, class _Dp>
827 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
828 : public integral_constant<bool, is_class<_Bp>::value &&
829 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
831 #endif // _LIBCPP_HAS_IS_BASE_OF
835 #if __has_feature(is_convertible_to)
837 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
838 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
839 !is_abstract<_T2>::value> {};
841 #else // __has_feature(is_convertible_to)
843 namespace __is_convertible_imp
845 template <class _Tp> void __test_convert(_Tp);
847 template <class _From, class _To, class = void>
848 struct __is_convertible_test : public false_type {};
850 template <class _From, class _To>
851 struct __is_convertible_test<_From, _To,
852 decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
855 template <class _Tp> __two __test(...);
856 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
857 template <class _Tp> _Tp&& __source();
859 template <class _Tp> typename remove_reference<_Tp>::type& __source();
862 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
863 bool _IsFunction = is_function<_Tp>::value,
864 bool _IsVoid = is_void<_Tp>::value>
865 struct __is_array_function_or_void {enum {value = 0};};
866 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
867 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
868 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
872 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
873 struct __is_convertible_check
875 static const size_t __v = 0;
879 struct __is_convertible_check<_Tp, 0>
881 static const size_t __v = sizeof(_Tp);
884 template <class _T1, class _T2,
885 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
886 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
887 struct __is_convertible
888 : public integral_constant<bool,
889 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
890 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
891 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
892 && (!is_const<typename remove_reference<_T2>::type>::value
893 || is_volatile<typename remove_reference<_T2>::type>::value)
894 && (is_same<typename remove_cv<_T1>::type,
895 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
896 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
901 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
903 template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
904 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
905 template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
906 template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
907 template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
908 template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
909 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
911 template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
912 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
914 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
915 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
917 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
918 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
920 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
921 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
923 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
924 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
925 template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
927 template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
928 template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
929 template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
930 template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
931 template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
933 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
935 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
936 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
937 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
938 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
940 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
941 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
942 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
943 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
945 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
946 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
947 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
948 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
950 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
951 : public __is_convertible<_T1, _T2>
953 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
954 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
957 #endif // __has_feature(is_convertible_to)
961 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
964 struct _LIBCPP_TYPE_VIS_ONLY is_empty
965 : public integral_constant<bool, __is_empty(_Tp)> {};
967 #else // __has_feature(is_empty)
981 template <class _Tp, bool = is_class<_Tp>::value>
982 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
984 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
986 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
988 #endif // __has_feature(is_empty)
992 #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
995 struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
996 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1000 template<typename _Tp> char &__is_polymorphic_impl(
1001 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1003 template<typename _Tp> __two &__is_polymorphic_impl(...);
1005 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1006 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1008 #endif // __has_feature(is_polymorphic)
1010 // has_virtual_destructor
1012 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1014 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1015 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1019 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1020 : public false_type {};
1026 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
1027 : public integral_constant<size_t, __alignof__(_Tp)> {};
1031 template <class _Hp, class _Tp>
1040 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1042 __nat(const __nat&) = delete;
1043 __nat& operator=(const __nat&) = delete;
1048 template <class _Tp>
1051 static const size_t value = alignment_of<_Tp>::value;
1055 struct __struct_double {long double __lx;};
1056 struct __struct_double4 {double __lx[4];};
1059 __type_list<__align_type<unsigned char>,
1060 __type_list<__align_type<unsigned short>,
1061 __type_list<__align_type<unsigned int>,
1062 __type_list<__align_type<unsigned long>,
1063 __type_list<__align_type<unsigned long long>,
1064 __type_list<__align_type<double>,
1065 __type_list<__align_type<long double>,
1066 __type_list<__align_type<__struct_double>,
1067 __type_list<__align_type<__struct_double4>,
1068 __type_list<__align_type<int*>,
1070 > > > > > > > > > > __all_types;
1072 template <class _TL, size_t _Align> struct __find_pod;
1074 template <class _Hp, size_t _Align>
1075 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1077 typedef typename conditional<
1078 _Align == _Hp::value,
1084 template <class _Hp, class _Tp, size_t _Align>
1085 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1087 typedef typename conditional<
1088 _Align == _Hp::value,
1090 typename __find_pod<_Tp, _Align>::type
1094 template <class _TL, size_t _Len> struct __find_max_align;
1096 template <class _Hp, size_t _Len>
1097 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1099 template <size_t _Len, size_t _A1, size_t _A2>
1100 struct __select_align
1103 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1104 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1106 static const size_t value = _Len < __max ? __min : __max;
1109 template <class _Hp, class _Tp, size_t _Len>
1110 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1111 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1113 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1114 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
1116 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1117 static_assert(!is_void<_Aligner>::value, "");
1121 unsigned char __data[_Len];
1125 #if _LIBCPP_STD_VER > 11
1126 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1127 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1130 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1131 template <size_t _Len>\
1132 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
1134 struct _ALIGNAS(n) type\
1136 unsigned char __lx[_Len];\
1140 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1141 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1142 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1143 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1144 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1145 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1146 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1147 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1148 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1149 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1150 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1151 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1152 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1153 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1154 // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1155 #if !defined(_LIBCPP_MSVC)
1156 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1157 #endif // !_LIBCPP_MSVC
1159 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1161 #ifndef _LIBCPP_HAS_NO_VARIADICS
1165 template <size_t _I0, size_t ..._In>
1166 struct __static_max;
1168 template <size_t _I0>
1169 struct __static_max<_I0>
1171 static const size_t value = _I0;
1174 template <size_t _I0, size_t _I1, size_t ..._In>
1175 struct __static_max<_I0, _I1, _In...>
1177 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1178 __static_max<_I1, _In...>::value;
1181 template <size_t _Len, class _Type0, class ..._Types>
1182 struct aligned_union
1184 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1185 __alignof__(_Types)...>::value;
1186 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1187 sizeof(_Types)...>::value;
1188 typedef typename aligned_storage<__len, alignment_value>::type type;
1191 #if _LIBCPP_STD_VER > 11
1192 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1195 #endif // _LIBCPP_HAS_NO_VARIADICS
1197 template <class _Tp>
1198 struct __numeric_type
1200 static void __test(...);
1201 static float __test(float);
1202 static double __test(char);
1203 static double __test(int);
1204 static double __test(unsigned);
1205 static double __test(long);
1206 static double __test(unsigned long);
1207 static double __test(long long);
1208 static double __test(unsigned long long);
1209 static double __test(double);
1210 static long double __test(long double);
1212 typedef decltype(__test(declval<_Tp>())) type;
1213 static const bool value = !is_same<type, void>::value;
1217 struct __numeric_type<void>
1219 static const bool value = true;
1224 template <class _A1, class _A2 = void, class _A3 = void,
1225 bool = __numeric_type<_A1>::value &&
1226 __numeric_type<_A2>::value &&
1227 __numeric_type<_A3>::value>
1231 static const bool value = false;
1234 template <class _A1, class _A2, class _A3>
1235 class __promote_imp<_A1, _A2, _A3, true>
1238 typedef typename __promote_imp<_A1>::type __type1;
1239 typedef typename __promote_imp<_A2>::type __type2;
1240 typedef typename __promote_imp<_A3>::type __type3;
1242 typedef decltype(__type1() + __type2() + __type3()) type;
1243 static const bool value = true;
1246 template <class _A1, class _A2>
1247 class __promote_imp<_A1, _A2, void, true>
1250 typedef typename __promote_imp<_A1>::type __type1;
1251 typedef typename __promote_imp<_A2>::type __type2;
1253 typedef decltype(__type1() + __type2()) type;
1254 static const bool value = true;
1257 template <class _A1>
1258 class __promote_imp<_A1, void, void, true>
1261 typedef typename __numeric_type<_A1>::type type;
1262 static const bool value = true;
1265 template <class _A1, class _A2 = void, class _A3 = void>
1266 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1268 #ifdef _LIBCPP_STORE_AS_OPTIMIZATION
1272 template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
1273 template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;};
1274 template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;};
1275 template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;};
1276 template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
1278 #endif // _LIBCPP_STORE_AS_OPTIMIZATION
1280 // make_signed / make_unsigned
1283 __type_list<signed char,
1284 __type_list<signed short,
1285 __type_list<signed int,
1286 __type_list<signed long,
1287 __type_list<signed long long,
1288 #ifndef _LIBCPP_HAS_NO_INT128
1289 __type_list<__int128_t,
1292 #ifndef _LIBCPP_HAS_NO_INT128
1295 > > > > > __signed_types;
1298 __type_list<unsigned char,
1299 __type_list<unsigned short,
1300 __type_list<unsigned int,
1301 __type_list<unsigned long,
1302 __type_list<unsigned long long,
1303 #ifndef _LIBCPP_HAS_NO_INT128
1304 __type_list<__uint128_t,
1307 #ifndef _LIBCPP_HAS_NO_INT128
1310 > > > > > __unsigned_types;
1312 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1314 template <class _Hp, class _Tp, size_t _Size>
1315 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1320 template <class _Hp, class _Tp, size_t _Size>
1321 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1323 typedef typename __find_first<_Tp, _Size>::type type;
1326 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1327 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1333 template <class _Tp, class _Up>
1334 struct __apply_cv<_Tp, _Up, true, false>
1336 typedef const _Up type;
1339 template <class _Tp, class _Up>
1340 struct __apply_cv<_Tp, _Up, false, true>
1342 typedef volatile _Up type;
1345 template <class _Tp, class _Up>
1346 struct __apply_cv<_Tp, _Up, true, true>
1348 typedef const volatile _Up type;
1351 template <class _Tp, class _Up>
1352 struct __apply_cv<_Tp&, _Up, false, false>
1357 template <class _Tp, class _Up>
1358 struct __apply_cv<_Tp&, _Up, true, false>
1360 typedef const _Up& type;
1363 template <class _Tp, class _Up>
1364 struct __apply_cv<_Tp&, _Up, false, true>
1366 typedef volatile _Up& type;
1369 template <class _Tp, class _Up>
1370 struct __apply_cv<_Tp&, _Up, true, true>
1372 typedef const volatile _Up& type;
1375 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1376 struct __make_signed {};
1378 template <class _Tp>
1379 struct __make_signed<_Tp, true>
1381 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1384 template <> struct __make_signed<bool, true> {};
1385 template <> struct __make_signed< signed short, true> {typedef short type;};
1386 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1387 template <> struct __make_signed< signed int, true> {typedef int type;};
1388 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1389 template <> struct __make_signed< signed long, true> {typedef long type;};
1390 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1391 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1392 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1393 #ifndef _LIBCPP_HAS_NO_INT128
1394 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1395 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1398 template <class _Tp>
1399 struct _LIBCPP_TYPE_VIS_ONLY make_signed
1401 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1404 #if _LIBCPP_STD_VER > 11
1405 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1408 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1409 struct __make_unsigned {};
1411 template <class _Tp>
1412 struct __make_unsigned<_Tp, true>
1414 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1417 template <> struct __make_unsigned<bool, true> {};
1418 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1419 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1420 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1421 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1422 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1423 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1424 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1425 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1426 #ifndef _LIBCPP_HAS_NO_INT128
1427 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1428 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1431 template <class _Tp>
1432 struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
1434 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1437 #if _LIBCPP_STD_VER > 11
1438 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1441 #ifdef _LIBCPP_HAS_NO_VARIADICS
1443 template <class _Tp, class _Up = void, class V = void>
1444 struct _LIBCPP_TYPE_VIS_ONLY common_type
1447 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1450 template <class _Tp>
1451 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
1454 typedef typename decay<_Tp>::type type;
1457 template <class _Tp, class _Up>
1458 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
1461 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1464 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1467 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1469 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1472 #else // _LIBCPP_HAS_NO_VARIADICS
1474 template <class ..._Tp> struct common_type;
1476 template <class _Tp>
1477 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
1479 typedef typename decay<_Tp>::type type;
1482 template <class _Tp, class _Up>
1483 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
1490 typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
1493 template <class _Tp, class _Up, class ..._Vp>
1494 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
1496 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1499 #if _LIBCPP_STD_VER > 11
1500 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1503 #endif // _LIBCPP_HAS_NO_VARIADICS
1507 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
1509 template <class _Tp, class _Arg>
1510 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
1511 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1512 __is_assignable_test(_Tp&&, _Arg&&);
1514 __is_assignable_test(_Tp, _Arg&);
1517 template <class _Arg>
1519 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1520 __is_assignable_test(__any, _Arg&&);
1522 __is_assignable_test(__any, _Arg&);
1525 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1526 struct __is_assignable_imp
1527 : public common_type
1529 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1532 template <class _Tp, class _Arg>
1533 struct __is_assignable_imp<_Tp, _Arg, true>
1538 template <class _Tp, class _Arg>
1539 struct is_assignable
1540 : public __is_assignable_imp<_Tp, _Arg> {};
1542 // is_copy_assignable
1544 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
1545 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1546 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
1548 // is_move_assignable
1550 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
1551 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1552 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1553 const typename add_rvalue_reference<_Tp>::type> {};
1555 : public is_copy_assignable<_Tp> {};
1560 // if it's a reference, return true
1561 // if it's a function, return false
1562 // if it's void, return false
1563 // if it's an array of unknown bound, return false
1564 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
1565 // where _Up is remove_all_extents<_Tp>::type
1568 struct __is_destructible_apply { typedef int type; };
1570 template <typename _Tp>
1571 struct __is_destructor_wellformed {
1572 template <typename _Tp1>
1573 static char __test (
1574 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
1577 template <typename _Tp1>
1578 static __two __test (...);
1580 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
1583 template <class _Tp, bool>
1584 struct __destructible_imp;
1586 template <class _Tp>
1587 struct __destructible_imp<_Tp, false>
1588 : public _VSTD::integral_constant<bool,
1589 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
1591 template <class _Tp>
1592 struct __destructible_imp<_Tp, true>
1593 : public _VSTD::true_type {};
1595 template <class _Tp, bool>
1596 struct __destructible_false;
1598 template <class _Tp>
1599 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
1601 template <class _Tp>
1602 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
1604 template <class _Tp>
1605 struct is_destructible
1606 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
1608 template <class _Tp>
1609 struct is_destructible<_Tp[]>
1610 : public _VSTD::false_type {};
1613 struct is_destructible<void>
1614 : public _VSTD::false_type {};
1618 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1620 template <class _Tp>
1621 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1622 typename remove_reference<_Tp>::type&&
1623 move(_Tp&& __t) _NOEXCEPT
1625 typedef typename remove_reference<_Tp>::type _Up;
1626 return static_cast<_Up&&>(__t);
1629 template <class _Tp>
1630 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1632 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1634 return static_cast<_Tp&&>(__t);
1637 template <class _Tp>
1638 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1640 forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1642 static_assert(!std::is_lvalue_reference<_Tp>::value,
1643 "Can not forward an rvalue as an lvalue.");
1644 return static_cast<_Tp&&>(__t);
1647 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1649 template <class _Tp>
1650 inline _LIBCPP_INLINE_VISIBILITY
1657 template <class _Tp>
1658 inline _LIBCPP_INLINE_VISIBILITY
1660 move(const _Tp& __t)
1665 template <class _Tp>
1666 inline _LIBCPP_INLINE_VISIBILITY
1668 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1674 template <class _Tp>
1677 typedef typename remove_reference<_Tp>::type _Trr;
1680 _LIBCPP_INLINE_VISIBILITY
1681 _Trr* operator->() {return &t_;}
1682 _LIBCPP_INLINE_VISIBILITY
1683 explicit __rv(_Trr& __t) : t_(__t) {}
1686 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1688 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1690 template <class _Tp>
1691 inline _LIBCPP_INLINE_VISIBILITY
1692 typename decay<_Tp>::type
1693 __decay_copy(_Tp&& __t)
1695 return _VSTD::forward<_Tp>(__t);
1700 template <class _Tp>
1701 inline _LIBCPP_INLINE_VISIBILITY
1702 typename decay<_Tp>::type
1703 __decay_copy(const _Tp& __t)
1705 return _VSTD::forward<_Tp>(__t);
1710 #ifndef _LIBCPP_HAS_NO_VARIADICS
1712 template <class _Rp, class _Class, class ..._Param>
1713 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1715 typedef _Class _ClassType;
1716 typedef _Rp _ReturnType;
1717 typedef _Rp (_FnType) (_Param...);
1720 template <class _Rp, class _Class, class ..._Param>
1721 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
1723 typedef _Class _ClassType;
1724 typedef _Rp _ReturnType;
1725 typedef _Rp (_FnType) (_Param..., ...);
1728 template <class _Rp, class _Class, class ..._Param>
1729 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1731 typedef _Class const _ClassType;
1732 typedef _Rp _ReturnType;
1733 typedef _Rp (_FnType) (_Param...);
1736 template <class _Rp, class _Class, class ..._Param>
1737 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
1739 typedef _Class const _ClassType;
1740 typedef _Rp _ReturnType;
1741 typedef _Rp (_FnType) (_Param..., ...);
1744 template <class _Rp, class _Class, class ..._Param>
1745 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1747 typedef _Class volatile _ClassType;
1748 typedef _Rp _ReturnType;
1749 typedef _Rp (_FnType) (_Param...);
1752 template <class _Rp, class _Class, class ..._Param>
1753 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
1755 typedef _Class volatile _ClassType;
1756 typedef _Rp _ReturnType;
1757 typedef _Rp (_FnType) (_Param..., ...);
1760 template <class _Rp, class _Class, class ..._Param>
1761 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1763 typedef _Class const volatile _ClassType;
1764 typedef _Rp _ReturnType;
1765 typedef _Rp (_FnType) (_Param...);
1768 template <class _Rp, class _Class, class ..._Param>
1769 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
1771 typedef _Class const volatile _ClassType;
1772 typedef _Rp _ReturnType;
1773 typedef _Rp (_FnType) (_Param..., ...);
1776 #if __has_feature(cxx_reference_qualified_functions)
1778 template <class _Rp, class _Class, class ..._Param>
1779 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1781 typedef _Class& _ClassType;
1782 typedef _Rp _ReturnType;
1783 typedef _Rp (_FnType) (_Param...);
1786 template <class _Rp, class _Class, class ..._Param>
1787 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
1789 typedef _Class& _ClassType;
1790 typedef _Rp _ReturnType;
1791 typedef _Rp (_FnType) (_Param..., ...);
1794 template <class _Rp, class _Class, class ..._Param>
1795 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1797 typedef _Class const& _ClassType;
1798 typedef _Rp _ReturnType;
1799 typedef _Rp (_FnType) (_Param...);
1802 template <class _Rp, class _Class, class ..._Param>
1803 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
1805 typedef _Class const& _ClassType;
1806 typedef _Rp _ReturnType;
1807 typedef _Rp (_FnType) (_Param..., ...);
1810 template <class _Rp, class _Class, class ..._Param>
1811 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1813 typedef _Class volatile& _ClassType;
1814 typedef _Rp _ReturnType;
1815 typedef _Rp (_FnType) (_Param...);
1818 template <class _Rp, class _Class, class ..._Param>
1819 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
1821 typedef _Class volatile& _ClassType;
1822 typedef _Rp _ReturnType;
1823 typedef _Rp (_FnType) (_Param..., ...);
1826 template <class _Rp, class _Class, class ..._Param>
1827 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1829 typedef _Class const volatile& _ClassType;
1830 typedef _Rp _ReturnType;
1831 typedef _Rp (_FnType) (_Param...);
1834 template <class _Rp, class _Class, class ..._Param>
1835 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
1837 typedef _Class const volatile& _ClassType;
1838 typedef _Rp _ReturnType;
1839 typedef _Rp (_FnType) (_Param..., ...);
1842 template <class _Rp, class _Class, class ..._Param>
1843 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1845 typedef _Class&& _ClassType;
1846 typedef _Rp _ReturnType;
1847 typedef _Rp (_FnType) (_Param...);
1850 template <class _Rp, class _Class, class ..._Param>
1851 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
1853 typedef _Class&& _ClassType;
1854 typedef _Rp _ReturnType;
1855 typedef _Rp (_FnType) (_Param..., ...);
1858 template <class _Rp, class _Class, class ..._Param>
1859 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1861 typedef _Class const&& _ClassType;
1862 typedef _Rp _ReturnType;
1863 typedef _Rp (_FnType) (_Param...);
1866 template <class _Rp, class _Class, class ..._Param>
1867 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
1869 typedef _Class const&& _ClassType;
1870 typedef _Rp _ReturnType;
1871 typedef _Rp (_FnType) (_Param..., ...);
1874 template <class _Rp, class _Class, class ..._Param>
1875 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1877 typedef _Class volatile&& _ClassType;
1878 typedef _Rp _ReturnType;
1879 typedef _Rp (_FnType) (_Param...);
1882 template <class _Rp, class _Class, class ..._Param>
1883 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
1885 typedef _Class volatile&& _ClassType;
1886 typedef _Rp _ReturnType;
1887 typedef _Rp (_FnType) (_Param..., ...);
1890 template <class _Rp, class _Class, class ..._Param>
1891 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1893 typedef _Class const volatile&& _ClassType;
1894 typedef _Rp _ReturnType;
1895 typedef _Rp (_FnType) (_Param...);
1898 template <class _Rp, class _Class, class ..._Param>
1899 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
1901 typedef _Class const volatile&& _ClassType;
1902 typedef _Rp _ReturnType;
1903 typedef _Rp (_FnType) (_Param..., ...);
1906 #endif // __has_feature(cxx_reference_qualified_functions)
1908 #else // _LIBCPP_HAS_NO_VARIADICS
1910 template <class _Rp, class _Class>
1911 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1913 typedef _Class _ClassType;
1914 typedef _Rp _ReturnType;
1915 typedef _Rp (_FnType) ();
1918 template <class _Rp, class _Class>
1919 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
1921 typedef _Class _ClassType;
1922 typedef _Rp _ReturnType;
1923 typedef _Rp (_FnType) (...);
1926 template <class _Rp, class _Class, class _P0>
1927 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1929 typedef _Class _ClassType;
1930 typedef _Rp _ReturnType;
1931 typedef _Rp (_FnType) (_P0);
1934 template <class _Rp, class _Class, class _P0>
1935 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
1937 typedef _Class _ClassType;
1938 typedef _Rp _ReturnType;
1939 typedef _Rp (_FnType) (_P0, ...);
1942 template <class _Rp, class _Class, class _P0, class _P1>
1943 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1945 typedef _Class _ClassType;
1946 typedef _Rp _ReturnType;
1947 typedef _Rp (_FnType) (_P0, _P1);
1950 template <class _Rp, class _Class, class _P0, class _P1>
1951 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
1953 typedef _Class _ClassType;
1954 typedef _Rp _ReturnType;
1955 typedef _Rp (_FnType) (_P0, _P1, ...);
1958 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1959 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1961 typedef _Class _ClassType;
1962 typedef _Rp _ReturnType;
1963 typedef _Rp (_FnType) (_P0, _P1, _P2);
1966 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1967 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
1969 typedef _Class _ClassType;
1970 typedef _Rp _ReturnType;
1971 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
1974 template <class _Rp, class _Class>
1975 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1977 typedef _Class const _ClassType;
1978 typedef _Rp _ReturnType;
1979 typedef _Rp (_FnType) ();
1982 template <class _Rp, class _Class>
1983 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
1985 typedef _Class const _ClassType;
1986 typedef _Rp _ReturnType;
1987 typedef _Rp (_FnType) (...);
1990 template <class _Rp, class _Class, class _P0>
1991 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1993 typedef _Class const _ClassType;
1994 typedef _Rp _ReturnType;
1995 typedef _Rp (_FnType) (_P0);
1998 template <class _Rp, class _Class, class _P0>
1999 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2001 typedef _Class const _ClassType;
2002 typedef _Rp _ReturnType;
2003 typedef _Rp (_FnType) (_P0, ...);
2006 template <class _Rp, class _Class, class _P0, class _P1>
2007 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2009 typedef _Class const _ClassType;
2010 typedef _Rp _ReturnType;
2011 typedef _Rp (_FnType) (_P0, _P1);
2014 template <class _Rp, class _Class, class _P0, class _P1>
2015 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2017 typedef _Class const _ClassType;
2018 typedef _Rp _ReturnType;
2019 typedef _Rp (_FnType) (_P0, _P1, ...);
2022 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2023 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2025 typedef _Class const _ClassType;
2026 typedef _Rp _ReturnType;
2027 typedef _Rp (_FnType) (_P0, _P1, _P2);
2030 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2031 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2033 typedef _Class const _ClassType;
2034 typedef _Rp _ReturnType;
2035 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2038 template <class _Rp, class _Class>
2039 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2041 typedef _Class volatile _ClassType;
2042 typedef _Rp _ReturnType;
2043 typedef _Rp (_FnType) ();
2046 template <class _Rp, class _Class>
2047 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2049 typedef _Class volatile _ClassType;
2050 typedef _Rp _ReturnType;
2051 typedef _Rp (_FnType) (...);
2054 template <class _Rp, class _Class, class _P0>
2055 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2057 typedef _Class volatile _ClassType;
2058 typedef _Rp _ReturnType;
2059 typedef _Rp (_FnType) (_P0);
2062 template <class _Rp, class _Class, class _P0>
2063 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2065 typedef _Class volatile _ClassType;
2066 typedef _Rp _ReturnType;
2067 typedef _Rp (_FnType) (_P0, ...);
2070 template <class _Rp, class _Class, class _P0, class _P1>
2071 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2073 typedef _Class volatile _ClassType;
2074 typedef _Rp _ReturnType;
2075 typedef _Rp (_FnType) (_P0, _P1);
2078 template <class _Rp, class _Class, class _P0, class _P1>
2079 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2081 typedef _Class volatile _ClassType;
2082 typedef _Rp _ReturnType;
2083 typedef _Rp (_FnType) (_P0, _P1, ...);
2086 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2087 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2089 typedef _Class volatile _ClassType;
2090 typedef _Rp _ReturnType;
2091 typedef _Rp (_FnType) (_P0, _P1, _P2);
2094 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2095 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2097 typedef _Class volatile _ClassType;
2098 typedef _Rp _ReturnType;
2099 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2102 template <class _Rp, class _Class>
2103 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2105 typedef _Class const volatile _ClassType;
2106 typedef _Rp _ReturnType;
2107 typedef _Rp (_FnType) ();
2110 template <class _Rp, class _Class>
2111 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2113 typedef _Class const volatile _ClassType;
2114 typedef _Rp _ReturnType;
2115 typedef _Rp (_FnType) (...);
2118 template <class _Rp, class _Class, class _P0>
2119 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2121 typedef _Class const volatile _ClassType;
2122 typedef _Rp _ReturnType;
2123 typedef _Rp (_FnType) (_P0);
2126 template <class _Rp, class _Class, class _P0>
2127 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2129 typedef _Class const volatile _ClassType;
2130 typedef _Rp _ReturnType;
2131 typedef _Rp (_FnType) (_P0, ...);
2134 template <class _Rp, class _Class, class _P0, class _P1>
2135 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2137 typedef _Class const volatile _ClassType;
2138 typedef _Rp _ReturnType;
2139 typedef _Rp (_FnType) (_P0, _P1);
2142 template <class _Rp, class _Class, class _P0, class _P1>
2143 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2145 typedef _Class const volatile _ClassType;
2146 typedef _Rp _ReturnType;
2147 typedef _Rp (_FnType) (_P0, _P1, ...);
2150 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2151 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2153 typedef _Class const volatile _ClassType;
2154 typedef _Rp _ReturnType;
2155 typedef _Rp (_FnType) (_P0, _P1, _P2);
2158 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2159 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2161 typedef _Class const volatile _ClassType;
2162 typedef _Rp _ReturnType;
2163 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2166 #endif // _LIBCPP_HAS_NO_VARIADICS
2168 template <class _Rp, class _Class>
2169 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2171 typedef _Class _ClassType;
2172 typedef _Rp _ReturnType;
2175 template <class _MP>
2176 struct __member_pointer_traits
2177 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2178 is_member_function_pointer<_MP>::value,
2179 is_member_object_pointer<_MP>::value>
2181 // typedef ... _ClassType;
2182 // typedef ... _ReturnType;
2183 // typedef ... _FnType;
2188 template <class _Callable> class result_of;
2190 #ifdef _LIBCPP_HAS_NO_VARIADICS
2192 template <class _Fn, bool, bool>
2197 template <class _Fn>
2198 class __result_of<_Fn(), true, false>
2201 typedef decltype(declval<_Fn>()()) type;
2204 template <class _Fn, class _A0>
2205 class __result_of<_Fn(_A0), true, false>
2208 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2211 template <class _Fn, class _A0, class _A1>
2212 class __result_of<_Fn(_A0, _A1), true, false>
2215 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2218 template <class _Fn, class _A0, class _A1, class _A2>
2219 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2222 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2225 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2226 struct __result_of_mp;
2228 // member function pointer
2230 template <class _MP, class _Tp>
2231 struct __result_of_mp<_MP, _Tp, true>
2232 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
2236 // member data pointer
2238 template <class _MP, class _Tp, bool>
2239 struct __result_of_mdp;
2241 template <class _Rp, class _Class, class _Tp>
2242 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2244 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2247 template <class _Rp, class _Class, class _Tp>
2248 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2250 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2253 template <class _Rp, class _Class, class _Tp>
2254 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2255 : public __result_of_mdp<_Rp _Class::*, _Tp,
2256 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2262 template <class _Fn, class _Tp>
2263 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2264 : public __result_of_mp<typename remove_reference<_Fn>::type,
2266 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2270 template <class _Fn, class _Tp, class _A0>
2271 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2272 : public __result_of_mp<typename remove_reference<_Fn>::type,
2274 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2278 template <class _Fn, class _Tp, class _A0, class _A1>
2279 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2280 : public __result_of_mp<typename remove_reference<_Fn>::type,
2282 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2286 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2287 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2288 : public __result_of_mp<typename remove_reference<_Fn>::type,
2290 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2296 template <class _Fn>
2297 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
2298 : public __result_of<_Fn(),
2299 is_class<typename remove_reference<_Fn>::type>::value ||
2300 is_function<typename remove_reference<_Fn>::type>::value,
2301 is_member_pointer<typename remove_reference<_Fn>::type>::value
2306 template <class _Fn, class _A0>
2307 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
2308 : public __result_of<_Fn(_A0),
2309 is_class<typename remove_reference<_Fn>::type>::value ||
2310 is_function<typename remove_reference<_Fn>::type>::value,
2311 is_member_pointer<typename remove_reference<_Fn>::type>::value
2316 template <class _Fn, class _A0, class _A1>
2317 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
2318 : public __result_of<_Fn(_A0, _A1),
2319 is_class<typename remove_reference<_Fn>::type>::value ||
2320 is_function<typename remove_reference<_Fn>::type>::value,
2321 is_member_pointer<typename remove_reference<_Fn>::type>::value
2326 template <class _Fn, class _A0, class _A1, class _A2>
2327 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
2328 : public __result_of<_Fn(_A0, _A1, _A2),
2329 is_class<typename remove_reference<_Fn>::type>::value ||
2330 is_function<typename remove_reference<_Fn>::type>::value,
2331 is_member_pointer<typename remove_reference<_Fn>::type>::value
2336 #endif // _LIBCPP_HAS_NO_VARIADICS
2338 // template <class T, class... Args> struct is_constructible;
2340 namespace __is_construct
2345 #if __has_feature(is_constructible)
2347 template <class _Tp, class ..._Args>
2348 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2349 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2354 #ifndef _LIBCPP_HAS_NO_VARIADICS
2356 // main is_constructible test
2358 template <class _Tp, class ..._Args>
2359 typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
2360 __is_constructible_test(_Tp&&, _Args&& ...);
2362 template <class ..._Args>
2364 __is_constructible_test(__any, _Args&& ...);
2366 template <bool, class _Tp, class... _Args>
2367 struct __libcpp_is_constructible // false, _Tp is not a scalar
2368 : public common_type
2370 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
2374 // function types are not constructible
2376 template <class _Rp, class... _A1, class... _A2>
2377 struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
2381 // handle scalars and reference types
2383 // Scalars are default constructible, references are not
2385 template <class _Tp>
2386 struct __libcpp_is_constructible<true, _Tp>
2387 : public is_scalar<_Tp>
2390 // Scalars and references are constructible from one arg if that arg is
2391 // implicitly convertible to the scalar or reference.
2393 template <class _Tp>
2394 struct __is_constructible_ref
2396 true_type static __lxx(_Tp);
2397 false_type static __lxx(...);
2400 template <class _Tp, class _A0>
2401 struct __libcpp_is_constructible<true, _Tp, _A0>
2402 : public common_type
2404 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2408 // Scalars and references are not constructible from multiple args.
2410 template <class _Tp, class _A0, class ..._Args>
2411 struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
2415 // Treat scalars and reference types separately
2417 template <bool, class _Tp, class... _Args>
2418 struct __is_constructible_void_check
2419 : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2423 // If any of T or Args is void, is_constructible should be false
2425 template <class _Tp, class... _Args>
2426 struct __is_constructible_void_check<true, _Tp, _Args...>
2430 template <class ..._Args> struct __contains_void;
2432 template <> struct __contains_void<> : false_type {};
2434 template <class _A0, class ..._Args>
2435 struct __contains_void<_A0, _Args...>
2437 static const bool value = is_void<_A0>::value ||
2438 __contains_void<_Args...>::value;
2441 // is_constructible entry point
2443 template <class _Tp, class... _Args>
2444 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2445 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
2446 || is_abstract<_Tp>::value,
2450 // Array types are default constructible if their element type
2451 // is default constructible
2453 template <class _Ap, size_t _Np>
2454 struct __libcpp_is_constructible<false, _Ap[_Np]>
2455 : public is_constructible<typename remove_all_extents<_Ap>::type>
2458 // Otherwise array types are not constructible by this syntax
2460 template <class _Ap, size_t _Np, class ..._Args>
2461 struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
2465 // Incomplete array types are not constructible
2467 template <class _Ap, class ..._Args>
2468 struct __libcpp_is_constructible<false, _Ap[], _Args...>
2472 #else // _LIBCPP_HAS_NO_VARIADICS
2474 // template <class T> struct is_constructible0;
2476 // main is_constructible0 test
2478 template <class _Tp>
2479 decltype((_Tp(), true_type()))
2480 __is_constructible0_test(_Tp&);
2483 __is_constructible0_test(__any);
2485 template <class _Tp, class _A0>
2486 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
2487 __is_constructible1_test(_Tp&, _A0&);
2489 template <class _A0>
2491 __is_constructible1_test(__any, _A0&);
2493 template <class _Tp, class _A0, class _A1>
2494 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
2495 __is_constructible2_test(_Tp&, _A0&, _A1&);
2497 template <class _A0, class _A1>
2499 __is_constructible2_test(__any, _A0&, _A1&);
2501 template <bool, class _Tp>
2502 struct __is_constructible0_imp // false, _Tp is not a scalar
2503 : public common_type
2505 decltype(__is_constructible0_test(declval<_Tp&>()))
2509 template <bool, class _Tp, class _A0>
2510 struct __is_constructible1_imp // false, _Tp is not a scalar
2511 : public common_type
2513 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
2517 template <bool, class _Tp, class _A0, class _A1>
2518 struct __is_constructible2_imp // false, _Tp is not a scalar
2519 : public common_type
2521 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
2525 // handle scalars and reference types
2527 // Scalars are default constructible, references are not
2529 template <class _Tp>
2530 struct __is_constructible0_imp<true, _Tp>
2531 : public is_scalar<_Tp>
2534 template <class _Tp, class _A0>
2535 struct __is_constructible1_imp<true, _Tp, _A0>
2536 : public is_convertible<_A0, _Tp>
2539 template <class _Tp, class _A0, class _A1>
2540 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
2544 // Treat scalars and reference types separately
2546 template <bool, class _Tp>
2547 struct __is_constructible0_void_check
2548 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2552 template <bool, class _Tp, class _A0>
2553 struct __is_constructible1_void_check
2554 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2558 template <bool, class _Tp, class _A0, class _A1>
2559 struct __is_constructible2_void_check
2560 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2564 // If any of T or Args is void, is_constructible should be false
2566 template <class _Tp>
2567 struct __is_constructible0_void_check<true, _Tp>
2571 template <class _Tp, class _A0>
2572 struct __is_constructible1_void_check<true, _Tp, _A0>
2576 template <class _Tp, class _A0, class _A1>
2577 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
2581 // is_constructible entry point
2583 template <class _Tp, class _A0 = __is_construct::__nat,
2584 class _A1 = __is_construct::__nat>
2585 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2586 : public __is_constructible2_void_check<is_void<_Tp>::value
2587 || is_abstract<_Tp>::value
2588 || is_function<_Tp>::value
2589 || is_void<_A0>::value
2590 || is_void<_A1>::value,
2594 template <class _Tp>
2595 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2596 : public __is_constructible0_void_check<is_void<_Tp>::value
2597 || is_abstract<_Tp>::value
2598 || is_function<_Tp>::value,
2602 template <class _Tp, class _A0>
2603 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
2604 : public __is_constructible1_void_check<is_void<_Tp>::value
2605 || is_abstract<_Tp>::value
2606 || is_function<_Tp>::value
2607 || is_void<_A0>::value,
2611 // Array types are default constructible if their element type
2612 // is default constructible
2614 template <class _Ap, size_t _Np>
2615 struct __is_constructible0_imp<false, _Ap[_Np]>
2616 : public is_constructible<typename remove_all_extents<_Ap>::type>
2619 template <class _Ap, size_t _Np, class _A0>
2620 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
2624 template <class _Ap, size_t _Np, class _A0, class _A1>
2625 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2629 // Incomplete array types are not constructible
2631 template <class _Ap>
2632 struct __is_constructible0_imp<false, _Ap[]>
2636 template <class _Ap, class _A0>
2637 struct __is_constructible1_imp<false, _Ap[], _A0>
2641 template <class _Ap, class _A0, class _A1>
2642 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2646 #endif // _LIBCPP_HAS_NO_VARIADICS
2647 #endif // __has_feature(is_constructible)
2649 // is_default_constructible
2651 template <class _Tp>
2652 struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
2653 : public is_constructible<_Tp>
2656 // is_copy_constructible
2658 template <class _Tp>
2659 struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
2660 : public is_constructible<_Tp,
2661 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2663 // is_move_constructible
2665 template <class _Tp>
2666 struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
2667 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2668 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2670 : public is_copy_constructible<_Tp>
2674 // is_trivially_constructible
2676 #ifndef _LIBCPP_HAS_NO_VARIADICS
2678 #if __has_feature(is_trivially_constructible)
2680 template <class _Tp, class... _Args>
2681 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2682 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2686 #else // !__has_feature(is_trivially_constructible)
2688 template <class _Tp, class... _Args>
2689 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2694 template <class _Tp>
2695 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
2696 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
2697 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2699 : integral_constant<bool, is_scalar<_Tp>::value>
2704 template <class _Tp>
2705 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2706 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
2708 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
2710 : integral_constant<bool, is_scalar<_Tp>::value>
2714 template <class _Tp>
2715 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
2716 : integral_constant<bool, is_scalar<_Tp>::value>
2720 template <class _Tp>
2721 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
2722 : integral_constant<bool, is_scalar<_Tp>::value>
2726 #endif // !__has_feature(is_trivially_constructible)
2728 #else // _LIBCPP_HAS_NO_VARIADICS
2730 template <class _Tp, class _A0 = __is_construct::__nat,
2731 class _A1 = __is_construct::__nat>
2732 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
2737 #if __has_feature(is_trivially_constructible)
2739 template <class _Tp>
2740 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2741 __is_construct::__nat>
2742 : integral_constant<bool, __is_trivially_constructible(_Tp)>
2746 template <class _Tp>
2747 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2748 __is_construct::__nat>
2749 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2753 template <class _Tp>
2754 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2755 __is_construct::__nat>
2756 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2760 template <class _Tp>
2761 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2762 __is_construct::__nat>
2763 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2767 #else // !__has_feature(is_trivially_constructible)
2769 template <class _Tp>
2770 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
2771 __is_construct::__nat>
2772 : integral_constant<bool, is_scalar<_Tp>::value>
2776 template <class _Tp>
2777 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
2778 __is_construct::__nat>
2779 : integral_constant<bool, is_scalar<_Tp>::value>
2783 template <class _Tp>
2784 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
2785 __is_construct::__nat>
2786 : integral_constant<bool, is_scalar<_Tp>::value>
2790 template <class _Tp>
2791 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
2792 __is_construct::__nat>
2793 : integral_constant<bool, is_scalar<_Tp>::value>
2797 #endif // !__has_feature(is_trivially_constructible)
2799 #endif // _LIBCPP_HAS_NO_VARIADICS
2801 // is_trivially_default_constructible
2803 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
2804 : public is_trivially_constructible<_Tp>
2807 // is_trivially_copy_constructible
2809 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
2810 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2813 // is_trivially_move_constructible
2815 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
2816 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2817 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2819 : public is_trivially_copy_constructible<_Tp>
2823 // is_trivially_assignable
2825 #if __has_feature(is_trivially_assignable)
2827 template <class _Tp, class _Arg>
2828 struct is_trivially_assignable
2829 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2833 #else // !__has_feature(is_trivially_assignable)
2835 template <class _Tp, class _Arg>
2836 struct is_trivially_assignable
2837 : public false_type {};
2839 template <class _Tp>
2840 struct is_trivially_assignable<_Tp&, _Tp>
2841 : integral_constant<bool, is_scalar<_Tp>::value> {};
2843 template <class _Tp>
2844 struct is_trivially_assignable<_Tp&, _Tp&>
2845 : integral_constant<bool, is_scalar<_Tp>::value> {};
2847 template <class _Tp>
2848 struct is_trivially_assignable<_Tp&, const _Tp&>
2849 : integral_constant<bool, is_scalar<_Tp>::value> {};
2851 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2853 template <class _Tp>
2854 struct is_trivially_assignable<_Tp&, _Tp&&>
2855 : integral_constant<bool, is_scalar<_Tp>::value> {};
2857 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2859 #endif // !__has_feature(is_trivially_assignable)
2861 // is_trivially_copy_assignable
2863 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
2864 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2865 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2867 // is_trivially_move_assignable
2869 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
2870 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2871 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2872 typename add_rvalue_reference<_Tp>::type>
2874 typename add_lvalue_reference<_Tp>::type>
2878 // is_trivially_destructible
2880 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
2882 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2883 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
2887 template <class _Tp> struct __libcpp_trivial_destructor
2888 : public integral_constant<bool, is_scalar<_Tp>::value ||
2889 is_reference<_Tp>::value> {};
2891 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
2892 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2896 // is_nothrow_constructible
2899 template <class _Tp, class... _Args>
2900 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2901 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
2907 #ifndef _LIBCPP_HAS_NO_VARIADICS
2909 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
2911 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
2913 template <class _Tp, class... _Args>
2914 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
2915 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2919 template <class _Tp>
2920 void __implicit_conversion_to(_Tp) noexcept { }
2922 template <class _Tp, class _Arg>
2923 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
2924 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
2928 template <class _Tp, bool _IsReference, class... _Args>
2929 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
2934 template <class _Tp, class... _Args>
2935 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2936 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
2940 template <class _Tp, size_t _Ns>
2941 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
2942 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
2946 #else // __has_feature(cxx_noexcept)
2948 template <class _Tp, class... _Args>
2949 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
2954 template <class _Tp>
2955 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
2956 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
2957 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2959 : integral_constant<bool, is_scalar<_Tp>::value>
2964 template <class _Tp>
2965 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2966 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
2968 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
2970 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
2971 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2973 : integral_constant<bool, is_scalar<_Tp>::value>
2978 template <class _Tp>
2979 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
2980 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
2981 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2983 : integral_constant<bool, is_scalar<_Tp>::value>
2988 template <class _Tp>
2989 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
2990 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
2991 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2993 : integral_constant<bool, is_scalar<_Tp>::value>
2998 #endif // __has_feature(cxx_noexcept)
3000 #else // _LIBCPP_HAS_NO_VARIADICS
3002 template <class _Tp, class _A0 = __is_construct::__nat,
3003 class _A1 = __is_construct::__nat>
3004 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3009 template <class _Tp>
3010 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
3011 __is_construct::__nat>
3012 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3013 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3015 : integral_constant<bool, is_scalar<_Tp>::value>
3020 template <class _Tp>
3021 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
3022 __is_construct::__nat>
3023 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3024 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3026 : integral_constant<bool, is_scalar<_Tp>::value>
3031 template <class _Tp>
3032 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
3033 __is_construct::__nat>
3034 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3035 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3037 : integral_constant<bool, is_scalar<_Tp>::value>
3042 template <class _Tp>
3043 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
3044 __is_construct::__nat>
3045 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3046 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3048 : integral_constant<bool, is_scalar<_Tp>::value>
3053 #endif // _LIBCPP_HAS_NO_VARIADICS
3054 #endif // __has_feature(is_nothrow_constructible)
3056 // is_nothrow_default_constructible
3058 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
3059 : public is_nothrow_constructible<_Tp>
3062 // is_nothrow_copy_constructible
3064 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
3065 : public is_nothrow_constructible<_Tp,
3066 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3068 // is_nothrow_move_constructible
3070 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
3071 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3072 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3074 : public is_nothrow_copy_constructible<_Tp>
3078 // is_nothrow_assignable
3080 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3082 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3084 template <class _Tp, class _Arg>
3085 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3090 template <class _Tp, class _Arg>
3091 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3092 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3096 template <class _Tp, class _Arg>
3097 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3098 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3102 #else // __has_feature(cxx_noexcept)
3104 template <class _Tp, class _Arg>
3105 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3106 : public false_type {};
3108 template <class _Tp>
3109 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
3110 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3111 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3113 : integral_constant<bool, is_scalar<_Tp>::value> {};
3116 template <class _Tp>
3117 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
3118 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3119 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3121 : integral_constant<bool, is_scalar<_Tp>::value> {};
3124 template <class _Tp>
3125 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
3126 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3127 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3129 : integral_constant<bool, is_scalar<_Tp>::value> {};
3132 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3134 template <class _Tp>
3135 struct is_nothrow_assignable<_Tp&, _Tp&&>
3136 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3137 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3139 : integral_constant<bool, is_scalar<_Tp>::value> {};
3142 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3144 #endif // __has_feature(cxx_noexcept)
3146 // is_nothrow_copy_assignable
3148 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
3149 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3150 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3152 // is_nothrow_move_assignable
3154 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
3155 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3156 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3157 typename add_rvalue_reference<_Tp>::type>
3159 typename add_lvalue_reference<_Tp>::type>
3163 // is_nothrow_destructible
3165 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3167 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3169 template <class _Tp>
3170 struct __libcpp_is_nothrow_destructible<false, _Tp>
3175 template <class _Tp>
3176 struct __libcpp_is_nothrow_destructible<true, _Tp>
3177 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3181 template <class _Tp>
3182 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3183 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3187 template <class _Tp, size_t _Ns>
3188 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
3189 : public is_nothrow_destructible<_Tp>
3193 template <class _Tp>
3194 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
3199 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3201 template <class _Tp>
3202 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
3211 template <class _Tp> struct __libcpp_nothrow_destructor
3212 : public integral_constant<bool, is_scalar<_Tp>::value ||
3213 is_reference<_Tp>::value> {};
3215 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3216 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3222 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
3224 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3225 : public integral_constant<bool, __is_pod(_Tp)> {};
3229 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3230 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3231 is_trivially_copy_constructible<_Tp>::value &&
3232 is_trivially_copy_assignable<_Tp>::value &&
3233 is_trivially_destructible<_Tp>::value> {};
3239 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
3240 #ifdef _LIBCPP_IS_LITERAL
3241 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3243 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3244 is_reference<typename remove_all_extents<_Tp>::type>::value>
3248 // is_standard_layout;
3250 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
3251 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3252 : public integral_constant<bool, __is_standard_layout(_Tp)>
3254 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3258 // is_trivially_copyable;
3260 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
3261 #if __has_feature(is_trivially_copyable)
3262 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3264 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3270 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
3271 #if __has_feature(is_trivial) || (_GNUC_VER >= 407)
3272 : public integral_constant<bool, __is_trivial(_Tp)>
3274 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3275 is_trivially_default_constructible<_Tp>::value>
3279 #ifndef _LIBCPP_HAS_NO_VARIADICS
3281 // Check for complete types
3283 template <class ..._Tp> struct __check_complete;
3286 struct __check_complete<>
3290 template <class _Hp, class _T0, class ..._Tp>
3291 struct __check_complete<_Hp, _T0, _Tp...>
3292 : private __check_complete<_Hp>,
3293 private __check_complete<_T0, _Tp...>
3297 template <class _Hp>
3298 struct __check_complete<_Hp, _Hp>
3299 : private __check_complete<_Hp>
3303 template <class _Tp>
3304 struct __check_complete<_Tp>
3306 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
3309 template <class _Tp>
3310 struct __check_complete<_Tp&>
3311 : private __check_complete<_Tp>
3315 template <class _Tp>
3316 struct __check_complete<_Tp&&>
3317 : private __check_complete<_Tp>
3321 template <class _Rp, class ..._Param>
3322 struct __check_complete<_Rp (*)(_Param...)>
3323 : private __check_complete<_Rp>
3327 template <class ..._Param>
3328 struct __check_complete<void (*)(_Param...)>
3332 template <class _Rp, class ..._Param>
3333 struct __check_complete<_Rp (_Param...)>
3334 : private __check_complete<_Rp>
3338 template <class ..._Param>
3339 struct __check_complete<void (_Param...)>
3343 template <class _Rp, class _Class, class ..._Param>
3344 struct __check_complete<_Rp (_Class::*)(_Param...)>
3345 : private __check_complete<_Class>
3349 template <class _Rp, class _Class, class ..._Param>
3350 struct __check_complete<_Rp (_Class::*)(_Param...) const>
3351 : private __check_complete<_Class>
3355 template <class _Rp, class _Class, class ..._Param>
3356 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
3357 : private __check_complete<_Class>
3361 template <class _Rp, class _Class, class ..._Param>
3362 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
3363 : private __check_complete<_Class>
3367 #if __has_feature(cxx_reference_qualified_functions)
3369 template <class _Rp, class _Class, class ..._Param>
3370 struct __check_complete<_Rp (_Class::*)(_Param...) &>
3371 : private __check_complete<_Class>
3375 template <class _Rp, class _Class, class ..._Param>
3376 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
3377 : private __check_complete<_Class>
3381 template <class _Rp, class _Class, class ..._Param>
3382 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
3383 : private __check_complete<_Class>
3387 template <class _Rp, class _Class, class ..._Param>
3388 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
3389 : private __check_complete<_Class>
3393 template <class _Rp, class _Class, class ..._Param>
3394 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
3395 : private __check_complete<_Class>
3399 template <class _Rp, class _Class, class ..._Param>
3400 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
3401 : private __check_complete<_Class>
3405 template <class _Rp, class _Class, class ..._Param>
3406 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
3407 : private __check_complete<_Class>
3411 template <class _Rp, class _Class, class ..._Param>
3412 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
3413 : private __check_complete<_Class>
3419 template <class _Rp, class _Class>
3420 struct __check_complete<_Rp _Class::*>
3421 : private __check_complete<_Class>
3425 // __invoke forward declarations
3427 // fall back - none of the bullets
3429 template <class ..._Args>
3431 __invoke(__any, _Args&& ...__args)
3436 template <class _Fp, class _A0, class ..._Args,
3437 class = typename enable_if
3439 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3440 is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3441 typename remove_reference<_A0>::type>::value
3444 _LIBCPP_INLINE_VISIBILITY
3446 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3447 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
3449 template <class _Fp, class _A0, class ..._Args,
3450 class = typename enable_if
3452 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
3453 !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
3454 typename remove_reference<_A0>::type>::value
3457 _LIBCPP_INLINE_VISIBILITY
3459 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3460 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
3464 template <class _Fp, class _A0,
3465 class = typename enable_if
3467 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3468 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3469 typename remove_reference<_A0>::type>::value
3472 _LIBCPP_INLINE_VISIBILITY
3474 __invoke(_Fp&& __f, _A0&& __a0)
3475 -> decltype(_VSTD::forward<_A0>(__a0).*__f);
3477 template <class _Fp, class _A0,
3478 class = typename enable_if
3480 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
3481 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
3482 typename remove_reference<_A0>::type>::value
3485 _LIBCPP_INLINE_VISIBILITY
3487 __invoke(_Fp&& __f, _A0&& __a0)
3488 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
3492 template <class _Fp, class ..._Args>
3493 _LIBCPP_INLINE_VISIBILITY
3495 __invoke(_Fp&& __f, _Args&& ...__args)
3496 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
3500 template <class _Fp, class ..._Args>
3501 struct __invokable_imp
3502 : private __check_complete<_Fp>
3505 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
3507 static const bool value = !is_same<type, __nat>::value;
3510 template <class _Fp, class ..._Args>
3512 : public integral_constant<bool,
3513 __invokable_imp<_Fp, _Args...>::value>
3519 template <bool _Invokable, class _Fp, class ..._Args>
3520 struct __invoke_of_imp // false
3524 template <class _Fp, class ..._Args>
3525 struct __invoke_of_imp<true, _Fp, _Args...>
3527 typedef typename __invokable_imp<_Fp, _Args...>::type type;
3530 template <class _Fp, class ..._Args>
3532 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
3536 template <class _Fp, class ..._Args>
3537 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
3538 : public __invoke_of<_Fp, _Args...>
3542 #if _LIBCPP_STD_VER > 11
3543 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3546 #endif // _LIBCPP_HAS_NO_VARIADICS
3548 template <class _Tp>
3549 inline _LIBCPP_INLINE_VISIBILITY
3550 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3553 is_move_constructible<_Tp>::value &&
3554 is_move_assignable<_Tp>::value
3559 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3560 is_nothrow_move_assignable<_Tp>::value)
3562 _Tp __t(_VSTD::move(__x));
3563 __x = _VSTD::move(__y);
3564 __y = _VSTD::move(__t);
3567 template <class _ForwardIterator1, class _ForwardIterator2>
3568 inline _LIBCPP_INLINE_VISIBILITY
3570 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3571 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3572 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3573 *_VSTD::declval<_ForwardIterator2>())))
3584 __nat swap(__any, __any);
3586 template <class _Tp>
3589 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
3590 static const bool value = !is_same<type, __nat>::value;
3595 template <class _Tp>
3596 struct __is_swappable
3597 : public integral_constant<bool, __detail::__swappable<_Tp>::value>
3601 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3603 template <bool, class _Tp>
3604 struct __is_nothrow_swappable_imp
3605 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
3606 _VSTD::declval<_Tp&>()))>
3610 template <class _Tp>
3611 struct __is_nothrow_swappable_imp<false, _Tp>
3616 template <class _Tp>
3617 struct __is_nothrow_swappable
3618 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
3622 #else // __has_feature(cxx_noexcept)
3624 template <class _Tp>
3625 struct __is_nothrow_swappable
3630 #endif // __has_feature(cxx_noexcept)
3632 #ifdef _LIBCPP_UNDERLYING_TYPE
3634 template <class _Tp>
3635 struct underlying_type
3637 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
3640 #if _LIBCPP_STD_VER > 11
3641 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3644 #else // _LIBCPP_UNDERLYING_TYPE
3646 template <class _Tp, bool _Support = false>
3647 struct underlying_type
3649 static_assert(_Support, "The underyling_type trait requires compiler "
3650 "support. Either no such support exists or "
3651 "libc++ does not know how to use it.");
3654 #endif // _LIBCPP_UNDERLYING_TYPE
3656 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
3658 template <class _Tp>
3659 struct __has_operator_addressof_member_imp
3661 template <class _Up>
3662 static auto __test(int)
3663 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
3665 static auto __test(long) -> false_type;
3667 static const bool value = decltype(__test<_Tp>(0))::value;
3670 template <class _Tp>
3671 struct __has_operator_addressof_free_imp
3673 template <class _Up>
3674 static auto __test(int)
3675 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
3677 static auto __test(long) -> false_type;
3679 static const bool value = decltype(__test<_Tp>(0))::value;
3682 template <class _Tp>
3683 struct __has_operator_addressof
3684 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
3685 || __has_operator_addressof_free_imp<_Tp>::value>
3688 #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
3690 #if _LIBCPP_STD_VER > 14
3691 template <class...> using void_t = void;
3694 _LIBCPP_END_NAMESPACE_STD
3696 #endif // _LIBCPP_TYPE_TRAITS