2 //===------------------------ type_traits ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_TYPE_TRAITS
12 #define _LIBCPP_TYPE_TRAITS
21 template <class T, T v> struct integral_constant;
22 typedef integral_constant<bool, true> true_type;
23 typedef integral_constant<bool, false> false_type;
26 template <bool, class T = void> struct enable_if;
27 template <bool, class T, class F> struct conditional;
29 // Primary classification traits:
30 template <class T> struct is_void;
31 template <class T> struct is_integral;
32 template <class T> struct is_floating_point;
33 template <class T> struct is_array;
34 template <class T> struct is_pointer;
35 template <class T> struct is_lvalue_reference;
36 template <class T> struct is_rvalue_reference;
37 template <class T> struct is_member_object_pointer;
38 template <class T> struct is_member_function_pointer;
39 template <class T> struct is_enum;
40 template <class T> struct is_union;
41 template <class T> struct is_class;
42 template <class T> struct is_function;
44 // Secondary classification traits:
45 template <class T> struct is_reference;
46 template <class T> struct is_arithmetic;
47 template <class T> struct is_fundamental;
48 template <class T> struct is_member_pointer;
49 template <class T> struct is_scalar;
50 template <class T> struct is_object;
51 template <class T> struct is_compound;
53 // Const-volatile properties and transformations:
54 template <class T> struct is_const;
55 template <class T> struct is_volatile;
56 template <class T> struct remove_const;
57 template <class T> struct remove_volatile;
58 template <class T> struct remove_cv;
59 template <class T> struct add_const;
60 template <class T> struct add_volatile;
61 template <class T> struct add_cv;
63 // Reference transformations:
64 template <class T> struct remove_reference;
65 template <class T> struct add_lvalue_reference;
66 template <class T> struct add_rvalue_reference;
68 // Pointer transformations:
69 template <class T> struct remove_pointer;
70 template <class T> struct add_pointer;
72 // Integral properties:
73 template <class T> struct is_signed;
74 template <class T> struct is_unsigned;
75 template <class T> struct make_signed;
76 template <class T> struct make_unsigned;
78 // Array properties and transformations:
79 template <class T> struct rank;
80 template <class T, unsigned I = 0> struct extent;
81 template <class T> struct remove_extent;
82 template <class T> struct remove_all_extents;
84 // Member introspection:
85 template <class T> struct is_pod;
86 template <class T> struct is_trivial;
87 template <class T> struct is_trivially_copyable;
88 template <class T> struct is_standard_layout;
89 template <class T> struct is_literal_type;
90 template <class T> struct is_empty;
91 template <class T> struct is_polymorphic;
92 template <class T> struct is_abstract;
94 template <class T, class... Args> struct is_constructible;
95 template <class T> struct is_default_constructible;
96 template <class T> struct is_copy_constructible;
97 template <class T> struct is_move_constructible;
98 template <class T, class U> struct is_assignable;
99 template <class T> struct is_copy_assignable;
100 template <class T> struct is_move_assignable;
101 template <class T> struct is_destructible;
103 template <class T, class... Args> struct is_trivially_constructible;
104 template <class T> struct is_trivially_default_constructible;
105 template <class T> struct is_trivially_copy_constructible;
106 template <class T> struct is_trivially_move_constructible;
107 template <class T, class U> struct is_trivially_assignable;
108 template <class T> struct is_trivially_copy_assignable;
109 template <class T> struct is_trivially_move_assignable;
110 template <class T> struct is_trivially_destructible;
112 template <class T, class... Args> struct is_nothrow_constructible;
113 template <class T> struct is_nothrow_default_constructible;
114 template <class T> struct is_nothrow_copy_constructible;
115 template <class T> struct is_nothrow_move_constructible;
116 template <class T, class U> struct is_nothrow_assignable;
117 template <class T> struct is_nothrow_copy_assignable;
118 template <class T> struct is_nothrow_move_assignable;
119 template <class T> struct is_nothrow_destructible;
121 template <class T> struct has_virtual_destructor;
123 // Relationships between types:
124 template <class T, class U> struct is_same;
125 template <class Base, class Derived> struct is_base_of;
126 template <class From, class To> struct is_convertible;
128 // Alignment properties and transformations:
129 template <class T> struct alignment_of;
130 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
131 struct aligned_storage;
133 template <class T> struct decay;
134 template <class... T> struct common_type;
135 template <class T> struct underlying_type;
136 template <class> class result_of; // undefined
137 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
145 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146 #pragma GCC system_header
149 _LIBCPP_BEGIN_NAMESPACE_STD
151 template <bool _Bp, class _If, class _Then>
152 struct _LIBCPP_VISIBLE conditional {typedef _If type;};
153 template <class _If, class _Then>
154 struct _LIBCPP_VISIBLE conditional<false, _If, _Then> {typedef _Then type;};
156 template <bool, class _Tp = void> struct _LIBCPP_VISIBLE enable_if {};
157 template <class _Tp> struct _LIBCPP_VISIBLE enable_if<true, _Tp> {typedef _Tp type;};
159 struct __two {char _[2];};
163 template <class _Tp, _Tp __v>
164 struct _LIBCPP_VISIBLE integral_constant
166 static _LIBCPP_CONSTEXPR const _Tp value = __v;
167 typedef _Tp value_type;
168 typedef integral_constant type;
169 _LIBCPP_INLINE_VISIBILITY
170 _LIBCPP_CONSTEXPR operator value_type() const {return value;}
173 template <class _Tp, _Tp __v>
174 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
176 typedef integral_constant<bool, true> true_type;
177 typedef integral_constant<bool, false> false_type;
181 template <class _Tp> struct _LIBCPP_VISIBLE is_const : public false_type {};
182 template <class _Tp> struct _LIBCPP_VISIBLE is_const<_Tp const> : public true_type {};
186 template <class _Tp> struct _LIBCPP_VISIBLE is_volatile : public false_type {};
187 template <class _Tp> struct _LIBCPP_VISIBLE is_volatile<_Tp volatile> : public true_type {};
191 template <class _Tp> struct _LIBCPP_VISIBLE remove_const {typedef _Tp type;};
192 template <class _Tp> struct _LIBCPP_VISIBLE remove_const<const _Tp> {typedef _Tp type;};
196 template <class _Tp> struct _LIBCPP_VISIBLE remove_volatile {typedef _Tp type;};
197 template <class _Tp> struct _LIBCPP_VISIBLE remove_volatile<volatile _Tp> {typedef _Tp type;};
201 template <class _Tp> struct _LIBCPP_VISIBLE remove_cv
202 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
206 template <class _Tp> struct __is_void : public false_type {};
207 template <> struct __is_void<void> : public true_type {};
209 template <class _Tp> struct _LIBCPP_VISIBLE is_void
210 : public __is_void<typename remove_cv<_Tp>::type> {};
214 template <class _Tp> struct ____is_nullptr_t : public false_type {};
215 template <> struct ____is_nullptr_t<nullptr_t> : public true_type {};
217 template <class _Tp> struct _LIBCPP_VISIBLE __is_nullptr_t
218 : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {};
222 template <class _Tp> struct __is_integral : public false_type {};
223 template <> struct __is_integral<bool> : public true_type {};
224 template <> struct __is_integral<char> : public true_type {};
225 template <> struct __is_integral<signed char> : public true_type {};
226 template <> struct __is_integral<unsigned char> : public true_type {};
227 template <> struct __is_integral<wchar_t> : public true_type {};
228 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
229 template <> struct __is_integral<char16_t> : public true_type {};
230 template <> struct __is_integral<char32_t> : public true_type {};
231 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
232 template <> struct __is_integral<short> : public true_type {};
233 template <> struct __is_integral<unsigned short> : public true_type {};
234 template <> struct __is_integral<int> : public true_type {};
235 template <> struct __is_integral<unsigned int> : public true_type {};
236 template <> struct __is_integral<long> : public true_type {};
237 template <> struct __is_integral<unsigned long> : public true_type {};
238 template <> struct __is_integral<long long> : public true_type {};
239 template <> struct __is_integral<unsigned long long> : public true_type {};
241 template <class _Tp> struct _LIBCPP_VISIBLE is_integral
242 : public __is_integral<typename remove_cv<_Tp>::type> {};
246 template <class _Tp> struct __is_floating_point : public false_type {};
247 template <> struct __is_floating_point<float> : public true_type {};
248 template <> struct __is_floating_point<double> : public true_type {};
249 template <> struct __is_floating_point<long double> : public true_type {};
251 template <class _Tp> struct _LIBCPP_VISIBLE is_floating_point
252 : public __is_floating_point<typename remove_cv<_Tp>::type> {};
256 template <class _Tp> struct _LIBCPP_VISIBLE is_array
257 : public false_type {};
258 template <class _Tp> struct _LIBCPP_VISIBLE is_array<_Tp[]>
259 : public true_type {};
260 template <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE is_array<_Tp[_Np]>
261 : public true_type {};
265 template <class _Tp> struct __is_pointer : public false_type {};
266 template <class _Tp> struct __is_pointer<_Tp*> : public true_type {};
268 template <class _Tp> struct _LIBCPP_VISIBLE is_pointer
269 : public __is_pointer<typename remove_cv<_Tp>::type> {};
273 template <class _Tp> struct _LIBCPP_VISIBLE is_lvalue_reference : public false_type {};
274 template <class _Tp> struct _LIBCPP_VISIBLE is_lvalue_reference<_Tp&> : public true_type {};
276 template <class _Tp> struct _LIBCPP_VISIBLE is_rvalue_reference : public false_type {};
277 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
278 template <class _Tp> struct _LIBCPP_VISIBLE is_rvalue_reference<_Tp&&> : public true_type {};
281 template <class _Tp> struct _LIBCPP_VISIBLE is_reference : public false_type {};
282 template <class _Tp> struct _LIBCPP_VISIBLE is_reference<_Tp&> : public true_type {};
283 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
284 template <class _Tp> struct _LIBCPP_VISIBLE is_reference<_Tp&&> : public true_type {};
287 #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
288 #define _LIBCPP_HAS_TYPE_TRAITS
293 #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
295 template <class _Tp> struct _LIBCPP_VISIBLE is_union
296 : public integral_constant<bool, __is_union(_Tp)> {};
300 template <class _Tp> struct __libcpp_union : public false_type {};
301 template <class _Tp> struct _LIBCPP_VISIBLE is_union
302 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
308 #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
310 template <class _Tp> struct _LIBCPP_VISIBLE is_class
311 : public integral_constant<bool, __is_class(_Tp)> {};
315 namespace __is_class_imp
317 template <class _Tp> char __test(int _Tp::*);
318 template <class _Tp> __two __test(...);
321 template <class _Tp> struct _LIBCPP_VISIBLE is_class
322 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
328 template <class _Tp, class _Up> struct _LIBCPP_VISIBLE is_same : public false_type {};
329 template <class _Tp> struct _LIBCPP_VISIBLE is_same<_Tp, _Tp> : public true_type {};
333 namespace __is_function_imp
335 template <class _Tp> char __test(_Tp*);
336 template <class _Tp> __two __test(...);
337 template <class _Tp> _Tp& __source();
340 template <class _Tp, bool = is_class<_Tp>::value ||
341 is_union<_Tp>::value ||
342 is_void<_Tp>::value ||
343 is_reference<_Tp>::value ||
344 is_same<_Tp, nullptr_t>::value >
346 : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1>
348 template <class _Tp> struct __is_function<_Tp, true> : public false_type {};
350 template <class _Tp> struct _LIBCPP_VISIBLE is_function
351 : public __is_function<_Tp> {};
353 // is_member_function_pointer
355 template <class _Tp> struct __is_member_function_pointer : public false_type {};
356 template <class _Tp, class _Up> struct __is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
358 template <class _Tp> struct _LIBCPP_VISIBLE is_member_function_pointer
359 : public __is_member_function_pointer<typename remove_cv<_Tp>::type> {};
363 template <class _Tp> struct __is_member_pointer : public false_type {};
364 template <class _Tp, class _Up> struct __is_member_pointer<_Tp _Up::*> : public true_type {};
366 template <class _Tp> struct _LIBCPP_VISIBLE is_member_pointer
367 : public __is_member_pointer<typename remove_cv<_Tp>::type> {};
369 // is_member_object_pointer
371 template <class _Tp> struct _LIBCPP_VISIBLE is_member_object_pointer
372 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
373 !is_member_function_pointer<_Tp>::value> {};
377 #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
379 template <class _Tp> struct _LIBCPP_VISIBLE is_enum
380 : public integral_constant<bool, __is_enum(_Tp)> {};
384 template <class _Tp> struct _LIBCPP_VISIBLE is_enum
385 : public integral_constant<bool, !is_void<_Tp>::value &&
386 !is_integral<_Tp>::value &&
387 !is_floating_point<_Tp>::value &&
388 !is_array<_Tp>::value &&
389 !is_pointer<_Tp>::value &&
390 !is_reference<_Tp>::value &&
391 !is_member_pointer<_Tp>::value &&
392 !is_union<_Tp>::value &&
393 !is_class<_Tp>::value &&
394 !is_function<_Tp>::value > {};
400 template <class _Tp> struct _LIBCPP_VISIBLE is_arithmetic
401 : public integral_constant<bool, is_integral<_Tp>::value ||
402 is_floating_point<_Tp>::value> {};
406 template <class _Tp> struct _LIBCPP_VISIBLE is_fundamental
407 : public integral_constant<bool, is_void<_Tp>::value ||
408 __is_nullptr_t<_Tp>::value ||
409 is_arithmetic<_Tp>::value> {};
413 template <class _Tp> struct _LIBCPP_VISIBLE is_scalar
414 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
415 is_member_pointer<_Tp>::value ||
416 is_pointer<_Tp>::value ||
417 __is_nullptr_t<_Tp>::value ||
418 is_enum<_Tp>::value > {};
420 template <> struct _LIBCPP_VISIBLE is_scalar<nullptr_t> : public true_type {};
424 template <class _Tp> struct _LIBCPP_VISIBLE is_object
425 : public integral_constant<bool, is_scalar<_Tp>::value ||
426 is_array<_Tp>::value ||
427 is_union<_Tp>::value ||
428 is_class<_Tp>::value > {};
432 template <class _Tp> struct _LIBCPP_VISIBLE is_compound
433 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
437 template <class _Tp, bool = is_reference<_Tp>::value ||
438 is_function<_Tp>::value ||
439 is_const<_Tp>::value >
440 struct __add_const {typedef _Tp type;};
443 struct __add_const<_Tp, false> {typedef const _Tp type;};
445 template <class _Tp> struct _LIBCPP_VISIBLE add_const
446 {typedef typename __add_const<_Tp>::type type;};
450 template <class _Tp, bool = is_reference<_Tp>::value ||
451 is_function<_Tp>::value ||
452 is_volatile<_Tp>::value >
453 struct __add_volatile {typedef _Tp type;};
456 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
458 template <class _Tp> struct _LIBCPP_VISIBLE add_volatile
459 {typedef typename __add_volatile<_Tp>::type type;};
463 template <class _Tp> struct _LIBCPP_VISIBLE add_cv
464 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
468 template <class _Tp> struct _LIBCPP_VISIBLE remove_reference {typedef _Tp type;};
469 template <class _Tp> struct _LIBCPP_VISIBLE remove_reference<_Tp&> {typedef _Tp type;};
470 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
471 template <class _Tp> struct _LIBCPP_VISIBLE remove_reference<_Tp&&> {typedef _Tp type;};
474 // add_lvalue_reference
476 template <class _Tp> struct _LIBCPP_VISIBLE add_lvalue_reference {typedef _Tp& type;};
477 template <class _Tp> struct _LIBCPP_VISIBLE add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
478 template <> struct _LIBCPP_VISIBLE add_lvalue_reference<void> {typedef void type;};
479 template <> struct _LIBCPP_VISIBLE add_lvalue_reference<const void> {typedef const void type;};
480 template <> struct _LIBCPP_VISIBLE add_lvalue_reference<volatile void> {typedef volatile void type;};
481 template <> struct _LIBCPP_VISIBLE add_lvalue_reference<const volatile void> {typedef const volatile void type;};
483 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
485 template <class _Tp> struct _LIBCPP_VISIBLE add_rvalue_reference {typedef _Tp&& type;};
486 template <> struct _LIBCPP_VISIBLE add_rvalue_reference<void> {typedef void type;};
487 template <> struct _LIBCPP_VISIBLE add_rvalue_reference<const void> {typedef const void type;};
488 template <> struct _LIBCPP_VISIBLE add_rvalue_reference<volatile void> {typedef volatile void type;};
489 template <> struct _LIBCPP_VISIBLE add_rvalue_reference<const volatile void> {typedef const volatile void type;};
491 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
493 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
496 typename add_rvalue_reference<_Tp>::type
499 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
502 typename add_lvalue_reference<_Tp>::type
505 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
514 template <class _Tp> struct _LIBCPP_VISIBLE remove_pointer {typedef _Tp type;};
515 template <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp*> {typedef _Tp type;};
516 template <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* const> {typedef _Tp type;};
517 template <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* volatile> {typedef _Tp type;};
518 template <class _Tp> struct _LIBCPP_VISIBLE remove_pointer<_Tp* const volatile> {typedef _Tp type;};
522 template <class _Tp> struct _LIBCPP_VISIBLE add_pointer
523 {typedef typename remove_reference<_Tp>::type* type;};
527 template <class _Tp, bool = is_integral<_Tp>::value>
528 struct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
531 struct ___is_signed<_Tp, false> : public true_type {}; // floating point
533 template <class _Tp, bool = is_arithmetic<_Tp>::value>
534 struct __is_signed : public ___is_signed<_Tp> {};
536 template <class _Tp> struct __is_signed<_Tp, false> : public false_type {};
538 template <class _Tp> struct _LIBCPP_VISIBLE is_signed : public __is_signed<_Tp> {};
542 template <class _Tp, bool = is_integral<_Tp>::value>
543 struct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
546 struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point
548 template <class _Tp, bool = is_arithmetic<_Tp>::value>
549 struct __is_unsigned : public ___is_unsigned<_Tp> {};
551 template <class _Tp> struct __is_unsigned<_Tp, false> : public false_type {};
553 template <class _Tp> struct _LIBCPP_VISIBLE is_unsigned : public __is_unsigned<_Tp> {};
557 template <class _Tp> struct _LIBCPP_VISIBLE rank
558 : public integral_constant<size_t, 0> {};
559 template <class _Tp> struct _LIBCPP_VISIBLE rank<_Tp[]>
560 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
561 template <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE rank<_Tp[_Np]>
562 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
566 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_VISIBLE extent
567 : public integral_constant<size_t, 0> {};
568 template <class _Tp> struct _LIBCPP_VISIBLE extent<_Tp[], 0>
569 : public integral_constant<size_t, 0> {};
570 template <class _Tp, unsigned _Ip> struct _LIBCPP_VISIBLE extent<_Tp[], _Ip>
571 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
572 template <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE extent<_Tp[_Np], 0>
573 : public integral_constant<size_t, _Np> {};
574 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_VISIBLE extent<_Tp[_Np], _Ip>
575 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
579 template <class _Tp> struct _LIBCPP_VISIBLE remove_extent
581 template <class _Tp> struct _LIBCPP_VISIBLE remove_extent<_Tp[]>
583 template <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE remove_extent<_Tp[_Np]>
586 // remove_all_extents
588 template <class _Tp> struct _LIBCPP_VISIBLE remove_all_extents
590 template <class _Tp> struct _LIBCPP_VISIBLE remove_all_extents<_Tp[]>
591 {typedef typename remove_all_extents<_Tp>::type type;};
592 template <class _Tp, size_t _Np> struct _LIBCPP_VISIBLE remove_all_extents<_Tp[_Np]>
593 {typedef typename remove_all_extents<_Tp>::type type;};
597 namespace __is_abstract_imp
599 template <class _Tp> char __test(_Tp (*)[1]);
600 template <class _Tp> __two __test(...);
603 template <class _Tp, bool = is_class<_Tp>::value>
604 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
606 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
608 template <class _Tp> struct _LIBCPP_VISIBLE is_abstract : public __libcpp_abstract<_Tp> {};
612 #ifdef _LIBCP_HAS_IS_BASE_OF
614 template <class _Bp, class _Dp>
615 struct _LIBCPP_VISIBLE is_base_of
616 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
618 #else // __has_feature(is_base_of)
620 #error is_base_of not implemented.
622 #endif // __has_feature(is_base_of)
626 #if __has_feature(is_convertible_to)
628 template <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
629 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
630 !is_abstract<_T2>::value> {};
632 #else // __has_feature(is_convertible_to)
634 namespace __is_convertible_imp
636 template <class _Tp> char __test(_Tp);
637 template <class _Tp> __two __test(...);
638 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
639 template <class _Tp> _Tp&& __source();
641 template <class _Tp> typename remove_reference<_Tp>::type& __source();
644 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
645 bool _IsFunction = is_function<_Tp>::value,
646 bool _IsVoid = is_void<_Tp>::value>
647 struct __is_array_function_or_void {enum {value = 0};};
648 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
649 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
650 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
654 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
655 struct __is_convertible_check
657 static const size_t __v = 0;
661 struct __is_convertible_check<_Tp, 0>
663 static const size_t __v = sizeof(_Tp);
666 template <class _T1, class _T2,
667 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
668 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
669 struct __is_convertible
670 : public integral_constant<bool,
671 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
672 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
674 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
675 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
676 && (!is_const<typename remove_reference<_T2>::type>::value
677 || is_volatile<typename remove_reference<_T2>::type>::value)
678 && (is_same<typename remove_cv<_T1>::type,
679 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
680 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
685 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
687 template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
688 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
689 template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
690 template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
691 template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
692 template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
693 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
695 template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
696 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
698 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
699 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
701 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
702 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
704 template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
705 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
707 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
708 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
709 template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
711 template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
712 template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
713 template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
714 template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
715 template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
717 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
719 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
720 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
721 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
722 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
724 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
725 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
726 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
727 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
729 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
730 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
731 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
732 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
734 template <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
735 : public __is_convertible<_T1, _T2>
737 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
738 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
741 #endif // __has_feature(is_convertible_to)
745 #if __has_feature(is_empty)
748 struct _LIBCPP_VISIBLE is_empty
749 : public integral_constant<bool, __is_empty(_Tp)> {};
751 #else // __has_feature(is_empty)
765 template <class _Tp, bool = is_class<_Tp>::value>
766 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
768 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
770 template <class _Tp> struct _LIBCPP_VISIBLE is_empty : public __libcpp_empty<_Tp> {};
772 #endif // __has_feature(is_empty)
776 #if __has_feature(is_polymorphic)
779 struct _LIBCPP_VISIBLE is_polymorphic
780 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
784 template <class _Tp> struct __is_polymorphic1 : public _Tp {};
785 template <class _Tp> struct __is_polymorphic2 : public _Tp {virtual ~__is_polymorphic2() throw();};
787 template <class _Tp, bool = is_class<_Tp>::value>
788 struct __libcpp_polymorphic
789 : public integral_constant<bool, sizeof(__is_polymorphic1<_Tp>) == sizeof(__is_polymorphic2<_Tp>)> {};
791 template <class _Tp> struct __libcpp_polymorphic<_Tp, false> : public false_type {};
793 template <class _Tp> struct _LIBCPP_VISIBLE is_polymorphic
794 : public __libcpp_polymorphic<_Tp> {};
796 #endif // __has_feature(is_polymorphic)
798 // has_virtual_destructor
800 #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
802 template <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
803 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
805 #else // _LIBCPP_HAS_TYPE_TRAITS
807 template <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
808 : public false_type {};
810 #endif // _LIBCPP_HAS_TYPE_TRAITS
814 template <class _Tp> struct __alignment_of {_Tp _;};
816 template <class _Tp> struct _LIBCPP_VISIBLE alignment_of
817 : public integral_constant<size_t, __alignof__(__alignment_of<typename remove_all_extents<_Tp>::type>)> {};
821 template <class _Hp, class _Tp>
830 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
832 __nat(const __nat&) = delete;
833 __nat& operator=(const __nat&) = delete;
841 static const size_t value = alignment_of<_Tp>::value;
845 struct __struct_double {long double _;};
846 struct __struct_double4 {double _[4];};
849 __type_list<__align_type<unsigned char>,
850 __type_list<__align_type<unsigned short>,
851 __type_list<__align_type<unsigned int>,
852 __type_list<__align_type<unsigned long>,
853 __type_list<__align_type<unsigned long long>,
854 __type_list<__align_type<double>,
855 __type_list<__align_type<long double>,
856 __type_list<__align_type<__struct_double>,
857 __type_list<__align_type<__struct_double4>,
858 __type_list<__align_type<int*>,
860 > > > > > > > > > > __all_types;
862 template <class _TL, size_t _Align> struct __find_pod;
864 template <class _Hp, size_t _Align>
865 struct __find_pod<__type_list<_Hp, __nat>, _Align>
867 typedef typename conditional<
868 _Align == _Hp::value,
874 template <class _Hp, class _Tp, size_t _Align>
875 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
877 typedef typename conditional<
878 _Align == _Hp::value,
880 typename __find_pod<_Tp, _Align>::type
884 template <class _TL, size_t _Len> struct __find_max_align;
886 template <class _Hp, size_t _Len>
887 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
889 template <size_t _Len, size_t _A1, size_t _A2>
890 struct __select_align
893 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
894 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
896 static const size_t value = _Len < __max ? __min : __max;
899 template <class _Hp, class _Tp, size_t _Len>
900 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
901 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
903 template <size_t _Len, const size_t _Align = __find_max_align<__all_types, _Len>::value>
904 struct _LIBCPP_VISIBLE aligned_storage
906 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
907 static_assert(!is_void<_Aligner>::value, "");
911 unsigned char __data[_Len];
915 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
916 template <size_t _Len>\
917 struct _LIBCPP_VISIBLE aligned_storage<_Len, n>\
919 struct _ALIGNAS(n) type\
921 unsigned char _[_Len];\
925 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
926 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
927 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
928 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
929 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
930 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
931 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
932 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
933 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
934 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
935 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
936 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
937 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
938 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
939 // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
940 #if !defined(_MSC_VER)
941 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
944 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
948 template <class _A1, class _A2 = void, class _A3 = void,
949 bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) &&
950 (is_arithmetic<_A2>::value || is_void<_A2>::value) &&
951 (is_arithmetic<_A3>::value || is_void<_A3>::value)>
954 template <class _A1, class _A2, class _A3>
955 class __promote<_A1, _A2, _A3, true>
958 typedef typename __promote<_A1>::type __type1;
959 typedef typename __promote<_A2>::type __type2;
960 typedef typename __promote<_A3>::type __type3;
962 typedef decltype(__type1() + __type2() + __type3()) type;
965 template <class _A1, class _A2>
966 class __promote<_A1, _A2, void, true>
969 typedef typename __promote<_A1>::type __type1;
970 typedef typename __promote<_A2>::type __type2;
972 typedef decltype(__type1() + __type2()) type;
976 class __promote<_A1, void, void, true>
979 typedef typename conditional<is_arithmetic<_A1>::value,
980 typename conditional<is_integral<_A1>::value, double, _A1>::type,
985 #ifdef _LIBCPP_STORE_AS_OPTIMIZATION
989 template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
990 template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;};
991 template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;};
992 template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;};
993 template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
995 #endif // _LIBCPP_STORE_AS_OPTIMIZATION
997 // make_signed / make_unsigned
1000 __type_list<signed char,
1001 __type_list<signed short,
1002 __type_list<signed int,
1003 __type_list<signed long,
1004 __type_list<signed long long,
1006 > > > > > __signed_types;
1009 __type_list<unsigned char,
1010 __type_list<unsigned short,
1011 __type_list<unsigned int,
1012 __type_list<unsigned long,
1013 __type_list<unsigned long long,
1015 > > > > > __unsigned_types;
1017 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1019 template <class _Hp, class _Tp, size_t _Size>
1020 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1025 template <class _Hp, class _Tp, size_t _Size>
1026 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1028 typedef typename __find_first<_Tp, _Size>::type type;
1031 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1032 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1038 template <class _Tp, class _Up>
1039 struct __apply_cv<_Tp, _Up, true, false>
1041 typedef const _Up type;
1044 template <class _Tp, class _Up>
1045 struct __apply_cv<_Tp, _Up, false, true>
1047 typedef volatile _Up type;
1050 template <class _Tp, class _Up>
1051 struct __apply_cv<_Tp, _Up, true, true>
1053 typedef const volatile _Up type;
1056 template <class _Tp, class _Up>
1057 struct __apply_cv<_Tp&, _Up, false, false>
1062 template <class _Tp, class _Up>
1063 struct __apply_cv<_Tp&, _Up, true, false>
1065 typedef const _Up& type;
1068 template <class _Tp, class _Up>
1069 struct __apply_cv<_Tp&, _Up, false, true>
1071 typedef volatile _Up& type;
1074 template <class _Tp, class _Up>
1075 struct __apply_cv<_Tp&, _Up, true, true>
1077 typedef const volatile _Up& type;
1080 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1081 struct __make_signed {};
1083 template <class _Tp>
1084 struct __make_signed<_Tp, true>
1086 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1089 template <> struct __make_signed<bool, true> {};
1090 template <> struct __make_signed< signed short, true> {typedef short type;};
1091 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1092 template <> struct __make_signed< signed int, true> {typedef int type;};
1093 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1094 template <> struct __make_signed< signed long, true> {typedef long type;};
1095 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1096 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1097 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1099 template <class _Tp>
1100 struct _LIBCPP_VISIBLE make_signed
1102 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1105 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1106 struct __make_unsigned {};
1108 template <class _Tp>
1109 struct __make_unsigned<_Tp, true>
1111 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1114 template <> struct __make_unsigned<bool, true> {};
1115 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1116 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1117 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1118 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1119 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1120 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1121 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1122 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1124 template <class _Tp>
1125 struct _LIBCPP_VISIBLE make_unsigned
1127 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1130 #ifdef _LIBCPP_HAS_NO_VARIADICS
1132 template <class _Tp, class _Up = void, class V = void>
1133 struct _LIBCPP_VISIBLE common_type
1136 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
1139 template <class _Tp>
1140 struct _LIBCPP_VISIBLE common_type<_Tp, void, void>
1146 template <class _Tp, class _Up>
1147 struct _LIBCPP_VISIBLE common_type<_Tp, _Up, void>
1150 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1153 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1156 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1158 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
1161 #else // _LIBCPP_HAS_NO_VARIADICS
1163 template <class ..._Tp> struct common_type;
1165 template <class _Tp>
1166 struct _LIBCPP_VISIBLE common_type<_Tp>
1171 template <class _Tp, class _Up>
1172 struct _LIBCPP_VISIBLE common_type<_Tp, _Up>
1179 typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type;
1182 template <class _Tp, class _Up, class ..._Vp>
1183 struct _LIBCPP_VISIBLE common_type<_Tp, _Up, _Vp...>
1185 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1188 #endif // _LIBCPP_HAS_NO_VARIADICS
1192 template <class _Tp, class _Arg>
1193 decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type()))
1194 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1195 __is_assignable_test(_Tp&&, _Arg&&);
1197 __is_assignable_test(_Tp, _Arg&);
1200 template <class _Arg>
1202 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1203 __is_assignable_test(__any, _Arg&&);
1205 __is_assignable_test(__any, _Arg&);
1208 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1209 struct __is_assignable_imp
1210 : public common_type
1212 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
1215 template <class _Tp, class _Arg>
1216 struct __is_assignable_imp<_Tp, _Arg, true>
1221 template <class _Tp, class _Arg>
1222 struct is_assignable
1223 : public __is_assignable_imp<_Tp, _Arg> {};
1225 // is_copy_assignable
1227 template <class _Tp> struct _LIBCPP_VISIBLE is_copy_assignable
1228 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1229 const typename add_lvalue_reference<_Tp>::type> {};
1231 // is_move_assignable
1233 template <class _Tp> struct _LIBCPP_VISIBLE is_move_assignable
1234 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1235 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1236 const typename add_rvalue_reference<_Tp>::type> {};
1238 : public is_copy_assignable<_Tp> {};
1243 template <class _Tp>
1244 struct __destructible_test
1249 template <class _Tp>
1250 decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
1251 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1252 __is_destructible_test(_Tp&&);
1254 __is_destructible_test(_Tp&);
1258 __is_destructible_test(__any);
1260 template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value>
1261 struct __destructible_imp
1262 : public common_type
1264 decltype(__is_destructible_test(declval<_Tp>()))
1267 template <class _Tp>
1268 struct __destructible_imp<_Tp, true>
1269 : public false_type {};
1271 template <class _Tp>
1272 struct is_destructible
1273 : public __destructible_imp<_Tp> {};
1277 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1279 template <class _Tp>
1280 inline _LIBCPP_INLINE_VISIBILITY
1281 typename remove_reference<_Tp>::type&&
1282 move(_Tp&& __t) _NOEXCEPT
1284 typedef typename remove_reference<_Tp>::type _Up;
1285 return static_cast<_Up&&>(__t);
1288 template <class _Tp>
1289 inline _LIBCPP_INLINE_VISIBILITY
1291 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1293 return static_cast<_Tp&&>(__t);
1296 template <class _Tp>
1297 inline _LIBCPP_INLINE_VISIBILITY
1299 forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
1301 static_assert(!std::is_lvalue_reference<_Tp>::value,
1302 "Can not forward an rvalue as an lvalue.");
1303 return static_cast<_Tp&&>(__t);
1306 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1308 template <class _Tp>
1309 inline _LIBCPP_INLINE_VISIBILITY
1316 template <class _Tp>
1317 inline _LIBCPP_INLINE_VISIBILITY
1319 move(const _Tp& __t)
1324 template <class _Tp>
1325 inline _LIBCPP_INLINE_VISIBILITY
1327 forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
1333 template <class _Tp>
1336 typedef typename remove_reference<_Tp>::type _Trr;
1339 _LIBCPP_INLINE_VISIBILITY
1340 _Trr* operator->() {return &t_;}
1341 _LIBCPP_INLINE_VISIBILITY
1342 explicit __rv(_Trr& __t) : t_(__t) {}
1345 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1347 template <class _Tp>
1348 struct _LIBCPP_VISIBLE decay
1351 typedef typename remove_reference<_Tp>::type _Up;
1353 typedef typename conditional
1355 is_array<_Up>::value,
1356 typename remove_extent<_Up>::type*,
1357 typename conditional
1359 is_function<_Up>::value,
1360 typename add_pointer<_Up>::type,
1361 typename remove_cv<_Up>::type
1366 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1368 template <class _Tp>
1369 inline _LIBCPP_INLINE_VISIBILITY
1370 typename decay<_Tp>::type
1371 __decay_copy(_Tp&& __t)
1373 return _VSTD::forward<_Tp>(__t);
1378 template <class _Tp>
1379 inline _LIBCPP_INLINE_VISIBILITY
1380 typename decay<_Tp>::type
1381 __decay_copy(const _Tp& __t)
1383 return _VSTD::forward<_Tp>(__t);
1388 template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
1389 struct __member_pointer_traits_imp
1393 #ifndef _LIBCPP_HAS_NO_VARIADICS
1395 template <class _Rp, class _Class, class ..._Param>
1396 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1398 typedef _Class _ClassType;
1399 typedef _Rp _ReturnType;
1402 template <class _Rp, class _Class, class ..._Param>
1403 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1405 typedef _Class const _ClassType;
1406 typedef _Rp _ReturnType;
1409 template <class _Rp, class _Class, class ..._Param>
1410 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1412 typedef _Class volatile _ClassType;
1413 typedef _Rp _ReturnType;
1416 template <class _Rp, class _Class, class ..._Param>
1417 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1419 typedef _Class const volatile _ClassType;
1420 typedef _Rp _ReturnType;
1423 #if __has_feature(cxx_reference_qualified_functions)
1425 template <class _Rp, class _Class, class ..._Param>
1426 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1428 typedef _Class& _ClassType;
1429 typedef _Rp _ReturnType;
1432 template <class _Rp, class _Class, class ..._Param>
1433 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1435 typedef _Class const& _ClassType;
1436 typedef _Rp _ReturnType;
1439 template <class _Rp, class _Class, class ..._Param>
1440 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1442 typedef _Class volatile& _ClassType;
1443 typedef _Rp _ReturnType;
1446 template <class _Rp, class _Class, class ..._Param>
1447 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1449 typedef _Class const volatile& _ClassType;
1450 typedef _Rp _ReturnType;
1453 template <class _Rp, class _Class, class ..._Param>
1454 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1456 typedef _Class&& _ClassType;
1457 typedef _Rp _ReturnType;
1460 template <class _Rp, class _Class, class ..._Param>
1461 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1463 typedef _Class const&& _ClassType;
1464 typedef _Rp _ReturnType;
1467 template <class _Rp, class _Class, class ..._Param>
1468 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1470 typedef _Class volatile&& _ClassType;
1471 typedef _Rp _ReturnType;
1474 template <class _Rp, class _Class, class ..._Param>
1475 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1477 typedef _Class const volatile&& _ClassType;
1478 typedef _Rp _ReturnType;
1481 #endif // __has_feature(cxx_reference_qualified_functions)
1483 #else // _LIBCPP_HAS_NO_VARIADICS
1485 template <class _Rp, class _Class>
1486 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
1488 typedef _Class _ClassType;
1489 typedef _Rp _ReturnType;
1492 template <class _Rp, class _Class, class _P0>
1493 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
1495 typedef _Class _ClassType;
1496 typedef _Rp _ReturnType;
1499 template <class _Rp, class _Class, class _P0, class _P1>
1500 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
1502 typedef _Class _ClassType;
1503 typedef _Rp _ReturnType;
1506 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1507 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
1509 typedef _Class _ClassType;
1510 typedef _Rp _ReturnType;
1513 template <class _Rp, class _Class>
1514 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
1516 typedef _Class const _ClassType;
1517 typedef _Rp _ReturnType;
1520 template <class _Rp, class _Class, class _P0>
1521 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
1523 typedef _Class const _ClassType;
1524 typedef _Rp _ReturnType;
1527 template <class _Rp, class _Class, class _P0, class _P1>
1528 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
1530 typedef _Class const _ClassType;
1531 typedef _Rp _ReturnType;
1534 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1535 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
1537 typedef _Class const _ClassType;
1538 typedef _Rp _ReturnType;
1541 template <class _Rp, class _Class>
1542 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
1544 typedef _Class volatile _ClassType;
1545 typedef _Rp _ReturnType;
1548 template <class _Rp, class _Class, class _P0>
1549 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
1551 typedef _Class volatile _ClassType;
1552 typedef _Rp _ReturnType;
1555 template <class _Rp, class _Class, class _P0, class _P1>
1556 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
1558 typedef _Class volatile _ClassType;
1559 typedef _Rp _ReturnType;
1562 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1563 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
1565 typedef _Class volatile _ClassType;
1566 typedef _Rp _ReturnType;
1569 template <class _Rp, class _Class>
1570 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
1572 typedef _Class const volatile _ClassType;
1573 typedef _Rp _ReturnType;
1576 template <class _Rp, class _Class, class _P0>
1577 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
1579 typedef _Class const volatile _ClassType;
1580 typedef _Rp _ReturnType;
1583 template <class _Rp, class _Class, class _P0, class _P1>
1584 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
1586 typedef _Class const volatile _ClassType;
1587 typedef _Rp _ReturnType;
1590 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
1591 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
1593 typedef _Class const volatile _ClassType;
1594 typedef _Rp _ReturnType;
1597 #endif // _LIBCPP_HAS_NO_VARIADICS
1599 template <class _Rp, class _Class>
1600 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1602 typedef _Class _ClassType;
1603 typedef _Rp _ReturnType;
1606 template <class _MP>
1607 struct __member_pointer_traits
1608 : public __member_pointer_traits_imp<_MP,
1609 is_member_function_pointer<_MP>::value,
1610 is_member_object_pointer<_MP>::value>
1612 // typedef ... _ClassType;
1613 // typedef ... _ReturnType;
1618 template <class _Callable> class result_of;
1620 #ifdef _LIBCPP_HAS_NO_VARIADICS
1622 template <class _Fn, bool, bool>
1627 template <class _Fn>
1628 class __result_of<_Fn(), true, false>
1631 typedef decltype(declval<_Fn>()()) type;
1634 template <class _Fn, class _A0>
1635 class __result_of<_Fn(_A0), true, false>
1638 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
1641 template <class _Fn, class _A0, class _A1>
1642 class __result_of<_Fn(_A0, _A1), true, false>
1645 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
1648 template <class _Fn, class _A0, class _A1, class _A2>
1649 class __result_of<_Fn(_A0, _A1, _A2), true, false>
1652 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
1655 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1656 struct __result_of_mp;
1658 // member function pointer
1660 template <class _MP, class _Tp>
1661 struct __result_of_mp<_MP, _Tp, true>
1662 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
1666 // member data pointer
1668 template <class _MP, class _Tp, bool>
1669 struct __result_of_mdp;
1671 template <class _Rp, class _Class, class _Tp>
1672 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
1674 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
1677 template <class _Rp, class _Class, class _Tp>
1678 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
1680 typedef typename __apply_cv<_Tp, _Rp>::type& type;
1683 template <class _Rp, class _Class, class _Tp>
1684 struct __result_of_mp<_Rp _Class::*, _Tp, false>
1685 : public __result_of_mdp<_Rp _Class::*, _Tp,
1686 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1692 template <class _Fn, class _Tp>
1693 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
1694 : public __result_of_mp<typename remove_reference<_Fn>::type,
1696 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1700 template <class _Fn, class _Tp, class _A0>
1701 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
1702 : public __result_of_mp<typename remove_reference<_Fn>::type,
1704 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1708 template <class _Fn, class _Tp, class _A0, class _A1>
1709 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
1710 : public __result_of_mp<typename remove_reference<_Fn>::type,
1712 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1716 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
1717 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
1718 : public __result_of_mp<typename remove_reference<_Fn>::type,
1720 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1726 template <class _Fn>
1727 class _LIBCPP_VISIBLE result_of<_Fn()>
1728 : public __result_of<_Fn(),
1729 is_class<typename remove_reference<_Fn>::type>::value ||
1730 is_function<typename remove_reference<_Fn>::type>::value,
1731 is_member_pointer<typename remove_reference<_Fn>::type>::value
1736 template <class _Fn, class _A0>
1737 class _LIBCPP_VISIBLE result_of<_Fn(_A0)>
1738 : public __result_of<_Fn(_A0),
1739 is_class<typename remove_reference<_Fn>::type>::value ||
1740 is_function<typename remove_reference<_Fn>::type>::value,
1741 is_member_pointer<typename remove_reference<_Fn>::type>::value
1746 template <class _Fn, class _A0, class _A1>
1747 class _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1)>
1748 : public __result_of<_Fn(_A0, _A1),
1749 is_class<typename remove_reference<_Fn>::type>::value ||
1750 is_function<typename remove_reference<_Fn>::type>::value,
1751 is_member_pointer<typename remove_reference<_Fn>::type>::value
1756 template <class _Fn, class _A0, class _A1, class _A2>
1757 class _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1, _A2)>
1758 : public __result_of<_Fn(_A0, _A1, _A2),
1759 is_class<typename remove_reference<_Fn>::type>::value ||
1760 is_function<typename remove_reference<_Fn>::type>::value,
1761 is_member_pointer<typename remove_reference<_Fn>::type>::value
1766 #endif // _LIBCPP_HAS_NO_VARIADICS
1768 #ifndef _LIBCPP_HAS_NO_VARIADICS
1770 // template <class T, class... Args> struct is_constructible;
1772 // main is_constructible test
1774 template <class _Tp, class ..._Args>
1775 decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...)), true_type())
1776 __is_constructible_test(_Tp&&, _Args&& ...);
1778 template <class ..._Args>
1780 __is_constructible_test(__any, _Args&& ...);
1782 template <bool, class _Tp, class... _Args>
1783 struct __is_constructible // false, _Tp is not a scalar
1784 : public common_type
1786 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
1790 // function types are not constructible
1792 template <class _Rp, class... _A1, class... _A2>
1793 struct __is_constructible<false, _Rp(_A1...), _A2...>
1797 // handle scalars and reference types
1799 // Scalars are default constructible, references are not
1801 template <class _Tp>
1802 struct __is_constructible<true, _Tp>
1803 : public is_scalar<_Tp>
1806 // Scalars and references are constructible from one arg if that arg is
1807 // implicitly convertible to the scalar or reference.
1809 template <class _Tp>
1810 struct __is_constructible_ref
1812 true_type static __(_Tp);
1813 false_type static __(...);
1816 template <class _Tp, class _A0>
1817 struct __is_constructible<true, _Tp, _A0>
1818 : public common_type
1820 decltype(__is_constructible_ref<_Tp>::__(declval<_A0>()))
1824 // Scalars and references are not constructible from multiple args.
1826 template <class _Tp, class _A0, class ..._Args>
1827 struct __is_constructible<true, _Tp, _A0, _Args...>
1831 // Treat scalars and reference types separately
1833 template <bool, class _Tp, class... _Args>
1834 struct __is_constructible_void_check
1835 : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1839 // If any of T or Args is void, is_constructible should be false
1841 template <class _Tp, class... _Args>
1842 struct __is_constructible_void_check<true, _Tp, _Args...>
1846 template <class ..._Args> struct __contains_void;
1848 template <> struct __contains_void<> : false_type {};
1850 template <class _A0, class ..._Args>
1851 struct __contains_void<_A0, _Args...>
1853 static const bool value = is_void<_A0>::value ||
1854 __contains_void<_Args...>::value;
1857 // is_constructible entry point
1859 template <class _Tp, class... _Args>
1860 struct _LIBCPP_VISIBLE is_constructible
1861 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
1862 || is_abstract<_Tp>::value,
1866 // Array types are default constructible if their element type
1867 // is default constructible
1869 template <class _Ap, size_t _Np>
1870 struct __is_constructible<false, _Ap[_Np]>
1871 : public is_constructible<typename remove_all_extents<_Ap>::type>
1874 // Otherwise array types are not constructible by this syntax
1876 template <class _Ap, size_t _Np, class ..._Args>
1877 struct __is_constructible<false, _Ap[_Np], _Args...>
1881 // Incomplete array types are not constructible
1883 template <class _Ap, class ..._Args>
1884 struct __is_constructible<false, _Ap[], _Args...>
1888 #else // _LIBCPP_HAS_NO_VARIADICS
1890 // template <class T> struct is_constructible0;
1892 // main is_constructible0 test
1894 template <class _Tp>
1895 decltype((_Tp(), true_type()))
1896 __is_constructible0_test(_Tp&);
1899 __is_constructible0_test(__any);
1901 template <class _Tp, class _A0>
1902 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
1903 __is_constructible1_test(_Tp&, _A0&);
1905 template <class _A0>
1907 __is_constructible1_test(__any, _A0&);
1909 template <class _Tp, class _A0, class _A1>
1910 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
1911 __is_constructible2_test(_Tp&, _A0&, _A1&);
1913 template <class _A0, class _A1>
1915 __is_constructible2_test(__any, _A0&, _A1&);
1917 template <bool, class _Tp>
1918 struct __is_constructible0_imp // false, _Tp is not a scalar
1919 : public common_type
1921 decltype(__is_constructible0_test(declval<_Tp&>()))
1925 template <bool, class _Tp, class _A0>
1926 struct __is_constructible1_imp // false, _Tp is not a scalar
1927 : public common_type
1929 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
1933 template <bool, class _Tp, class _A0, class _A1>
1934 struct __is_constructible2_imp // false, _Tp is not a scalar
1935 : public common_type
1937 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
1941 // handle scalars and reference types
1943 // Scalars are default constructible, references are not
1945 template <class _Tp>
1946 struct __is_constructible0_imp<true, _Tp>
1947 : public is_scalar<_Tp>
1950 template <class _Tp, class _A0>
1951 struct __is_constructible1_imp<true, _Tp, _A0>
1952 : public is_convertible<_A0, _Tp>
1955 template <class _Tp, class _A0, class _A1>
1956 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
1960 // Treat scalars and reference types separately
1962 template <bool, class _Tp>
1963 struct __is_constructible0_void_check
1964 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1968 template <bool, class _Tp, class _A0>
1969 struct __is_constructible1_void_check
1970 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1974 template <bool, class _Tp, class _A0, class _A1>
1975 struct __is_constructible2_void_check
1976 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
1980 // If any of T or Args is void, is_constructible should be false
1982 template <class _Tp>
1983 struct __is_constructible0_void_check<true, _Tp>
1987 template <class _Tp, class _A0>
1988 struct __is_constructible1_void_check<true, _Tp, _A0>
1992 template <class _Tp, class _A0, class _A1>
1993 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
1997 // is_constructible entry point
1999 namespace __is_construct
2006 template <class _Tp, class _A0 = __is_construct::__nat,
2007 class _A1 = __is_construct::__nat>
2008 struct _LIBCPP_VISIBLE is_constructible
2009 : public __is_constructible2_void_check<is_void<_Tp>::value
2010 || is_abstract<_Tp>::value
2011 || is_function<_Tp>::value
2012 || is_void<_A0>::value
2013 || is_void<_A1>::value,
2017 template <class _Tp>
2018 struct _LIBCPP_VISIBLE is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
2019 : public __is_constructible0_void_check<is_void<_Tp>::value
2020 || is_abstract<_Tp>::value
2021 || is_function<_Tp>::value,
2025 template <class _Tp, class _A0>
2026 struct _LIBCPP_VISIBLE is_constructible<_Tp, _A0, __is_construct::__nat>
2027 : public __is_constructible1_void_check<is_void<_Tp>::value
2028 || is_abstract<_Tp>::value
2029 || is_function<_Tp>::value
2030 || is_void<_A0>::value,
2034 // Array types are default constructible if their element type
2035 // is default constructible
2037 template <class _Ap, size_t _Np>
2038 struct __is_constructible0_imp<false, _Ap[_Np]>
2039 : public is_constructible<typename remove_all_extents<_Ap>::type>
2042 template <class _Ap, size_t _Np, class _A0>
2043 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
2047 template <class _Ap, size_t _Np, class _A0, class _A1>
2048 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
2052 // Incomplete array types are not constructible
2054 template <class _Ap>
2055 struct __is_constructible0_imp<false, _Ap[]>
2059 template <class _Ap, class _A0>
2060 struct __is_constructible1_imp<false, _Ap[], _A0>
2064 template <class _Ap, class _A0, class _A1>
2065 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
2069 #endif // _LIBCPP_HAS_NO_VARIADICS
2071 // is_default_constructible
2073 template <class _Tp>
2074 struct _LIBCPP_VISIBLE is_default_constructible
2075 : public is_constructible<_Tp>
2078 // is_copy_constructible
2080 template <class _Tp>
2081 struct _LIBCPP_VISIBLE is_copy_constructible
2082 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2085 // is_move_constructible
2087 template <class _Tp>
2088 struct _LIBCPP_VISIBLE is_move_constructible
2089 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2090 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2092 : public is_copy_constructible<_Tp>
2096 // is_trivially_constructible
2098 #ifndef _LIBCPP_HAS_NO_VARIADICS
2100 #if __has_feature(is_trivially_constructible)
2102 template <class _Tp, class... _Args>
2103 struct _LIBCPP_VISIBLE is_trivially_constructible
2104 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2108 #else // !__has_feature(is_trivially_constructible)
2110 template <class _Tp, class... _Args>
2111 struct _LIBCPP_VISIBLE is_trivially_constructible
2116 template <class _Tp>
2117 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp>
2118 #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2119 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2121 : integral_constant<bool, is_scalar<_Tp>::value>
2126 template <class _Tp>
2127 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2128 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&&>
2130 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp>
2132 : integral_constant<bool, is_scalar<_Tp>::value>
2136 template <class _Tp>
2137 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&>
2138 : integral_constant<bool, is_scalar<_Tp>::value>
2142 template <class _Tp>
2143 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&>
2144 : integral_constant<bool, is_scalar<_Tp>::value>
2148 #endif // !__has_feature(is_trivially_constructible)
2150 #else // _LIBCPP_HAS_NO_VARIADICS
2152 template <class _Tp, class _A0 = __is_construct::__nat,
2153 class _A1 = __is_construct::__nat>
2154 struct _LIBCPP_VISIBLE is_trivially_constructible
2159 #if __has_feature(is_trivially_constructible)
2161 template <class _Tp>
2162 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2163 __is_construct::__nat>
2164 : integral_constant<bool, __is_trivially_constructible(_Tp)>
2168 template <class _Tp>
2169 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2170 __is_construct::__nat>
2171 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
2175 template <class _Tp>
2176 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2177 __is_construct::__nat>
2178 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
2182 template <class _Tp>
2183 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2184 __is_construct::__nat>
2185 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
2189 #else // !__has_feature(is_trivially_constructible)
2191 template <class _Tp>
2192 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
2193 __is_construct::__nat>
2194 : integral_constant<bool, is_scalar<_Tp>::value>
2198 template <class _Tp>
2199 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
2200 __is_construct::__nat>
2201 : integral_constant<bool, is_scalar<_Tp>::value>
2205 template <class _Tp>
2206 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
2207 __is_construct::__nat>
2208 : integral_constant<bool, is_scalar<_Tp>::value>
2212 template <class _Tp>
2213 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
2214 __is_construct::__nat>
2215 : integral_constant<bool, is_scalar<_Tp>::value>
2219 #endif // !__has_feature(is_trivially_constructible)
2221 #endif // _LIBCPP_HAS_NO_VARIADICS
2223 // is_trivially_default_constructible
2225 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_default_constructible
2226 : public is_trivially_constructible<_Tp>
2229 // is_trivially_copy_constructible
2231 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_constructible
2232 : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2235 // is_trivially_move_constructible
2237 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_constructible
2238 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2239 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2241 : public is_trivially_copy_constructible<_Tp>
2245 // is_trivially_assignable
2247 #if __has_feature(is_trivially_constructible)
2249 template <class _Tp, class _Arg>
2250 struct is_trivially_assignable
2251 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2255 #else // !__has_feature(is_trivially_constructible)
2257 template <class _Tp, class _Arg>
2258 struct is_trivially_assignable
2259 : public false_type {};
2261 template <class _Tp>
2262 struct is_trivially_assignable<_Tp&, _Tp>
2263 : integral_constant<bool, is_scalar<_Tp>::value> {};
2265 template <class _Tp>
2266 struct is_trivially_assignable<_Tp&, _Tp&>
2267 : integral_constant<bool, is_scalar<_Tp>::value> {};
2269 template <class _Tp>
2270 struct is_trivially_assignable<_Tp&, const _Tp&>
2271 : integral_constant<bool, is_scalar<_Tp>::value> {};
2273 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2275 template <class _Tp>
2276 struct is_trivially_assignable<_Tp&, _Tp&&>
2277 : integral_constant<bool, is_scalar<_Tp>::value> {};
2279 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2281 #endif // !__has_feature(is_trivially_constructible)
2283 // is_trivially_copy_assignable
2285 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_assignable
2286 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2287 const typename add_lvalue_reference<_Tp>::type>
2290 // is_trivially_move_assignable
2292 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_assignable
2293 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2294 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2295 typename add_rvalue_reference<_Tp>::type>
2297 typename add_lvalue_reference<_Tp>::type>
2301 // is_trivially_destructible
2303 #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2305 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2306 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
2308 #else // _LIBCPP_HAS_TYPE_TRAITS
2310 template <class _Tp> struct __libcpp_trivial_destructor
2311 : public integral_constant<bool, is_scalar<_Tp>::value ||
2312 is_reference<_Tp>::value> {};
2314 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
2315 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2317 #endif // _LIBCPP_HAS_TYPE_TRAITS
2319 // is_nothrow_constructible
2321 #ifndef _LIBCPP_HAS_NO_VARIADICS
2323 #if __has_feature(cxx_noexcept)
2325 template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
2327 template <class _Tp, class... _Args>
2328 struct __is_nothrow_constructible<true, _Tp, _Args...>
2329 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2333 template <class _Tp, class... _Args>
2334 struct __is_nothrow_constructible<false, _Tp, _Args...>
2339 template <class _Tp, class... _Args>
2340 struct _LIBCPP_VISIBLE is_nothrow_constructible
2341 : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
2345 template <class _Tp, size_t _Ns>
2346 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp[_Ns]>
2347 : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
2351 #else // __has_feature(cxx_noexcept)
2353 template <class _Tp, class... _Args>
2354 struct _LIBCPP_VISIBLE is_nothrow_constructible
2359 template <class _Tp>
2360 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp>
2361 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2362 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2364 : integral_constant<bool, is_scalar<_Tp>::value>
2369 template <class _Tp>
2370 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2371 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&&>
2373 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp>
2375 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2376 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2378 : integral_constant<bool, is_scalar<_Tp>::value>
2383 template <class _Tp>
2384 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&>
2385 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2386 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2388 : integral_constant<bool, is_scalar<_Tp>::value>
2393 template <class _Tp>
2394 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&>
2395 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2396 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2398 : integral_constant<bool, is_scalar<_Tp>::value>
2403 #endif // __has_feature(cxx_noexcept)
2405 #else // _LIBCPP_HAS_NO_VARIADICS
2407 template <class _Tp, class _A0 = __is_construct::__nat,
2408 class _A1 = __is_construct::__nat>
2409 struct _LIBCPP_VISIBLE is_nothrow_constructible
2414 template <class _Tp>
2415 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, __is_construct::__nat,
2416 __is_construct::__nat>
2417 #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2418 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
2420 : integral_constant<bool, is_scalar<_Tp>::value>
2425 template <class _Tp>
2426 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp,
2427 __is_construct::__nat>
2428 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2429 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2431 : integral_constant<bool, is_scalar<_Tp>::value>
2436 template <class _Tp>
2437 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&,
2438 __is_construct::__nat>
2439 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2440 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2442 : integral_constant<bool, is_scalar<_Tp>::value>
2447 template <class _Tp>
2448 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&,
2449 __is_construct::__nat>
2450 #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2451 : integral_constant<bool, __has_nothrow_copy(_Tp)>
2453 : integral_constant<bool, is_scalar<_Tp>::value>
2458 #endif // _LIBCPP_HAS_NO_VARIADICS
2460 // is_nothrow_default_constructible
2462 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_default_constructible
2463 : public is_nothrow_constructible<_Tp>
2466 // is_nothrow_copy_constructible
2468 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_constructible
2469 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
2472 // is_nothrow_move_constructible
2474 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_constructible
2475 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2476 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2478 : public is_nothrow_copy_constructible<_Tp>
2482 // is_nothrow_assignable
2484 #if __has_feature(cxx_noexcept)
2486 template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
2488 template <class _Tp, class _Arg>
2489 struct __is_nothrow_assignable<false, _Tp, _Arg>
2494 template <class _Tp, class _Arg>
2495 struct __is_nothrow_assignable<true, _Tp, _Arg>
2496 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
2500 template <class _Tp, class _Arg>
2501 struct _LIBCPP_VISIBLE is_nothrow_assignable
2502 : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2506 #else // __has_feature(cxx_noexcept)
2508 template <class _Tp, class _Arg>
2509 struct _LIBCPP_VISIBLE is_nothrow_assignable
2510 : public false_type {};
2512 template <class _Tp>
2513 struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp>
2514 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2515 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2517 : integral_constant<bool, is_scalar<_Tp>::value> {};
2520 template <class _Tp>
2521 struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&>
2522 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2523 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2525 : integral_constant<bool, is_scalar<_Tp>::value> {};
2528 template <class _Tp>
2529 struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&>
2530 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2531 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2533 : integral_constant<bool, is_scalar<_Tp>::value> {};
2536 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2538 template <class _Tp>
2539 struct is_nothrow_assignable<_Tp&, _Tp&&>
2540 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2541 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
2543 : integral_constant<bool, is_scalar<_Tp>::value> {};
2546 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2548 #endif // __has_feature(cxx_noexcept)
2550 // is_nothrow_copy_assignable
2552 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
2553 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2554 const typename add_lvalue_reference<_Tp>::type>
2557 // is_nothrow_move_assignable
2559 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_assignable
2560 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2561 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2562 typename add_rvalue_reference<_Tp>::type>
2564 typename add_lvalue_reference<_Tp>::type>
2568 // is_nothrow_destructible
2570 #if __has_feature(cxx_noexcept)
2572 template <bool, class _Tp> struct __is_nothrow_destructible;
2574 template <class _Tp>
2575 struct __is_nothrow_destructible<false, _Tp>
2580 template <class _Tp>
2581 struct __is_nothrow_destructible<true, _Tp>
2582 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
2586 template <class _Tp>
2587 struct _LIBCPP_VISIBLE is_nothrow_destructible
2588 : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2592 template <class _Tp, size_t _Ns>
2593 struct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp[_Ns]>
2594 : public is_nothrow_destructible<_Tp>
2598 template <class _Tp>
2599 struct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&>
2604 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2606 template <class _Tp>
2607 struct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&&>
2616 template <class _Tp> struct __libcpp_nothrow_destructor
2617 : public integral_constant<bool, is_scalar<_Tp>::value ||
2618 is_reference<_Tp>::value> {};
2620 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
2621 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2627 #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
2629 template <class _Tp> struct _LIBCPP_VISIBLE is_pod
2630 : public integral_constant<bool, __is_pod(_Tp)> {};
2632 #else // _LIBCPP_HAS_TYPE_TRAITS
2634 template <class _Tp> struct _LIBCPP_VISIBLE is_pod
2635 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
2636 is_trivially_copy_constructible<_Tp>::value &&
2637 is_trivially_copy_assignable<_Tp>::value &&
2638 is_trivially_destructible<_Tp>::value> {};
2640 #endif // _LIBCPP_HAS_TYPE_TRAITS
2644 template <class _Tp> struct _LIBCPP_VISIBLE is_literal_type
2645 #if __has_feature(is_literal)
2646 : public integral_constant<bool, __is_literal(_Tp)>
2648 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
2649 is_reference<typename remove_all_extents<_Tp>::type>::value>
2653 // is_standard_layout;
2655 template <class _Tp> struct _LIBCPP_VISIBLE is_standard_layout
2656 #if __has_feature(is_standard_layout)
2657 : public integral_constant<bool, __is_standard_layout(_Tp)>
2659 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2663 // is_trivially_copyable;
2665 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copyable
2666 #if __has_feature(is_trivially_copyable)
2667 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2669 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2675 template <class _Tp> struct _LIBCPP_VISIBLE is_trivial
2676 #if __has_feature(is_trivial)
2677 : public integral_constant<bool, __is_trivial(_Tp)>
2679 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2680 is_trivially_default_constructible<_Tp>::value>
2684 #ifndef _LIBCPP_HAS_NO_VARIADICS
2686 // Check for complete types
2688 template <class ..._Tp> struct __check_complete;
2691 struct __check_complete<>
2695 template <class _Hp, class _T0, class ..._Tp>
2696 struct __check_complete<_Hp, _T0, _Tp...>
2697 : private __check_complete<_Hp>,
2698 private __check_complete<_T0, _Tp...>
2702 template <class _Hp>
2703 struct __check_complete<_Hp, _Hp>
2704 : private __check_complete<_Hp>
2708 template <class _Tp>
2709 struct __check_complete<_Tp>
2711 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
2714 template <class _Tp>
2715 struct __check_complete<_Tp&>
2716 : private __check_complete<_Tp>
2720 template <class _Tp>
2721 struct __check_complete<_Tp&&>
2722 : private __check_complete<_Tp>
2726 template <class _Rp, class ..._Param>
2727 struct __check_complete<_Rp (*)(_Param...)>
2728 : private __check_complete<_Rp>
2732 template <class _Rp, class ..._Param>
2733 struct __check_complete<_Rp (_Param...)>
2734 : private __check_complete<_Rp>
2738 template <class _Rp, class _Class, class ..._Param>
2739 struct __check_complete<_Rp (_Class::*)(_Param...)>
2740 : private __check_complete<_Class>
2744 template <class _Rp, class _Class, class ..._Param>
2745 struct __check_complete<_Rp (_Class::*)(_Param...) const>
2746 : private __check_complete<_Class>
2750 template <class _Rp, class _Class, class ..._Param>
2751 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
2752 : private __check_complete<_Class>
2756 template <class _Rp, class _Class, class ..._Param>
2757 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
2758 : private __check_complete<_Class>
2762 #if __has_feature(cxx_reference_qualified_functions)
2764 template <class _Rp, class _Class, class ..._Param>
2765 struct __check_complete<_Rp (_Class::*)(_Param...) &>
2766 : private __check_complete<_Class>
2770 template <class _Rp, class _Class, class ..._Param>
2771 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
2772 : private __check_complete<_Class>
2776 template <class _Rp, class _Class, class ..._Param>
2777 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
2778 : private __check_complete<_Class>
2782 template <class _Rp, class _Class, class ..._Param>
2783 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
2784 : private __check_complete<_Class>
2788 template <class _Rp, class _Class, class ..._Param>
2789 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
2790 : private __check_complete<_Class>
2794 template <class _Rp, class _Class, class ..._Param>
2795 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
2796 : private __check_complete<_Class>
2800 template <class _Rp, class _Class, class ..._Param>
2801 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
2802 : private __check_complete<_Class>
2806 template <class _Rp, class _Class, class ..._Param>
2807 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
2808 : private __check_complete<_Class>
2814 template <class _Rp, class _Class>
2815 struct __check_complete<_Rp _Class::*>
2816 : private __check_complete<_Class>
2820 // __invoke forward declarations
2822 // fall back - none of the bullets
2824 template <class ..._Args>
2826 __invoke(__any, _Args&& ...__args)
2831 template <class _Fp, class _A0, class ..._Args>
2832 _LIBCPP_INLINE_VISIBILITY
2834 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2835 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
2837 template <class _Fp, class _A0, class ..._Args>
2838 _LIBCPP_INLINE_VISIBILITY
2840 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2841 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
2845 template <class _Fp, class _A0>
2846 _LIBCPP_INLINE_VISIBILITY
2848 __invoke(_Fp&& __f, _A0&& __a0)
2849 -> decltype(_VSTD::forward<_A0>(__a0).*__f);
2851 template <class _Fp, class _A0>
2852 _LIBCPP_INLINE_VISIBILITY
2854 __invoke(_Fp&& __f, _A0&& __a0)
2855 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
2859 template <class _Fp, class ..._Args>
2860 _LIBCPP_INLINE_VISIBILITY
2862 __invoke(_Fp&& __f, _Args&& ...__args)
2863 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
2867 template <class _Fp, class ..._Args>
2868 struct __invokable_imp
2869 : private __check_complete<_Fp>
2872 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
2874 static const bool value = !is_same<type, __nat>::value;
2877 template <class _Fp, class ..._Args>
2879 : public integral_constant<bool,
2880 __invokable_imp<_Fp, _Args...>::value>
2886 template <bool _Invokable, class _Fp, class ..._Args>
2887 struct __invoke_of_imp // false
2891 template <class _Fp, class ..._Args>
2892 struct __invoke_of_imp<true, _Fp, _Args...>
2894 typedef typename __invokable_imp<_Fp, _Args...>::type type;
2897 template <class _Fp, class ..._Args>
2899 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
2903 template <class _Fp, class ..._Args>
2904 class _LIBCPP_VISIBLE result_of<_Fp(_Args...)>
2905 : public __invoke_of<_Fp, _Args...>
2909 #endif // _LIBCPP_HAS_NO_VARIADICS
2911 template <class _Tp>
2912 inline _LIBCPP_INLINE_VISIBILITY
2913 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
2916 is_move_constructible<_Tp>::value &&
2917 is_move_assignable<_Tp>::value
2922 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
2923 is_nothrow_move_assignable<_Tp>::value)
2925 _Tp __t(_VSTD::move(__x));
2926 __x = _VSTD::move(__y);
2927 __y = _VSTD::move(__t);
2930 template <class _ForwardIterator1, class _ForwardIterator2>
2931 inline _LIBCPP_INLINE_VISIBILITY
2933 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
2934 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
2935 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
2936 *_VSTD::declval<_ForwardIterator2>())))
2947 __nat swap(__any, __any);
2949 template <class _Tp>
2952 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
2953 static const bool value = !is_same<type, __nat>::value;
2958 template <class _Tp>
2959 struct __is_swappable
2960 : public integral_constant<bool, __detail::__swappable<_Tp>::value>
2964 #if __has_feature(cxx_noexcept)
2966 template <bool, class _Tp>
2967 struct __is_nothrow_swappable_imp
2968 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
2969 _VSTD::declval<_Tp&>()))>
2973 template <class _Tp>
2974 struct __is_nothrow_swappable_imp<false, _Tp>
2979 template <class _Tp>
2980 struct __is_nothrow_swappable
2981 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
2985 #else // __has_feature(cxx_noexcept)
2987 template <class _Tp>
2988 struct __is_nothrow_swappable
2993 #endif // __has_feature(cxx_noexcept)
2995 #ifdef _LIBCXX_UNDERLYING_TYPE
2997 template <class _Tp>
2998 struct underlying_type
3000 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
3003 #else // _LIBCXX_UNDERLYING_TYPE
3005 template <class _Tp, bool _Support = false>
3006 struct underlying_type
3008 static_assert(_Support, "The underyling_type trait requires compiler "
3009 "support. Either no such support exists or "
3010 "libc++ does not know how to use it.");
3013 #endif // _LIBCXX_UNDERLYING_TYPE
3015 _LIBCPP_END_NAMESPACE_STD
3017 #endif // _LIBCPP_TYPE_TRAITS