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; // C++11
23 typedef integral_constant<bool, false> false_type; // C++11
25 template <bool B> // C++14
26 using bool_constant = integral_constant<bool, B>; // C++14
27 typedef bool_constant<true> true_type; // C++14
28 typedef bool_constant<false> false_type; // C++14
31 template <bool, class T = void> struct enable_if;
32 template <bool, class T, class F> struct conditional;
34 // Primary classification traits:
35 template <class T> struct is_void;
36 template <class T> struct is_null_pointer; // C++14
37 template <class T> struct is_integral;
38 template <class T> struct is_floating_point;
39 template <class T> struct is_array;
40 template <class T> struct is_pointer;
41 template <class T> struct is_lvalue_reference;
42 template <class T> struct is_rvalue_reference;
43 template <class T> struct is_member_object_pointer;
44 template <class T> struct is_member_function_pointer;
45 template <class T> struct is_enum;
46 template <class T> struct is_union;
47 template <class T> struct is_class;
48 template <class T> struct is_function;
50 // Secondary classification traits:
51 template <class T> struct is_reference;
52 template <class T> struct is_arithmetic;
53 template <class T> struct is_fundamental;
54 template <class T> struct is_member_pointer;
55 template <class T> struct is_scalar;
56 template <class T> struct is_object;
57 template <class T> struct is_compound;
59 // Const-volatile properties and transformations:
60 template <class T> struct is_const;
61 template <class T> struct is_volatile;
62 template <class T> struct remove_const;
63 template <class T> struct remove_volatile;
64 template <class T> struct remove_cv;
65 template <class T> struct add_const;
66 template <class T> struct add_volatile;
67 template <class T> struct add_cv;
69 // Reference transformations:
70 template <class T> struct remove_reference;
71 template <class T> struct add_lvalue_reference;
72 template <class T> struct add_rvalue_reference;
74 // Pointer transformations:
75 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;
78 // Integral properties:
79 template <class T> struct is_signed;
80 template <class T> struct is_unsigned;
81 template <class T> struct make_signed;
82 template <class T> struct make_unsigned;
84 // Array properties and transformations:
85 template <class T> struct rank;
86 template <class T, unsigned I = 0> struct extent;
87 template <class T> struct remove_extent;
88 template <class T> struct remove_all_extents;
90 // Member introspection:
91 template <class T> struct is_pod;
92 template <class T> struct is_trivial;
93 template <class T> struct is_trivially_copyable;
94 template <class T> struct is_standard_layout;
95 template <class T> struct is_literal_type;
96 template <class T> struct is_empty;
97 template <class T> struct is_polymorphic;
98 template <class T> struct is_abstract;
99 template <class T> struct is_final; // C++14
101 template <class T, class... Args> struct is_constructible;
102 template <class T> struct is_default_constructible;
103 template <class T> struct is_copy_constructible;
104 template <class T> struct is_move_constructible;
105 template <class T, class U> struct is_assignable;
106 template <class T> struct is_copy_assignable;
107 template <class T> struct is_move_assignable;
108 template <class T, class U> struct is_swappable_with; // C++17
109 template <class T> struct is_swappable; // C++17
110 template <class T> struct is_destructible;
112 template <class T, class... Args> struct is_trivially_constructible;
113 template <class T> struct is_trivially_default_constructible;
114 template <class T> struct is_trivially_copy_constructible;
115 template <class T> struct is_trivially_move_constructible;
116 template <class T, class U> struct is_trivially_assignable;
117 template <class T> struct is_trivially_copy_assignable;
118 template <class T> struct is_trivially_move_assignable;
119 template <class T> struct is_trivially_destructible;
121 template <class T, class... Args> struct is_nothrow_constructible;
122 template <class T> struct is_nothrow_default_constructible;
123 template <class T> struct is_nothrow_copy_constructible;
124 template <class T> struct is_nothrow_move_constructible;
125 template <class T, class U> struct is_nothrow_assignable;
126 template <class T> struct is_nothrow_copy_assignable;
127 template <class T> struct is_nothrow_move_assignable;
128 template <class T, class U> struct is_nothrow_swappable_with; // C++17
129 template <class T> struct is_nothrow_swappable; // C++17
130 template <class T> struct is_nothrow_destructible;
132 template <class T> struct has_virtual_destructor;
134 // Relationships between types:
135 template <class T, class U> struct is_same;
136 template <class Base, class Derived> struct is_base_of;
137 template <class From, class To> struct is_convertible;
139 template <class, class R = void> struct is_callable; // not defined
140 template <class Fn, class... ArgTypes, class R>
141 struct is_callable<Fn(ArgTypes...), R>;
143 template <class, class R = void> struct is_nothrow_callable; // not defined
144 template <class Fn, class... ArgTypes, class R>
145 struct is_nothrow_callable<Fn(ArgTypes...), R>;
147 // Alignment properties and transformations:
148 template <class T> struct alignment_of;
149 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
150 struct aligned_storage;
151 template <size_t Len, class... Types> struct aligned_union;
153 template <class T> struct decay;
154 template <class... T> struct common_type;
155 template <class T> struct underlying_type;
156 template <class> class result_of; // undefined
157 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
159 // const-volatile modifications:
161 using remove_const_t = typename remove_const<T>::type; // C++14
163 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
165 using remove_cv_t = typename remove_cv<T>::type; // C++14
167 using add_const_t = typename add_const<T>::type; // C++14
169 using add_volatile_t = typename add_volatile<T>::type; // C++14
171 using add_cv_t = typename add_cv<T>::type; // C++14
173 // reference modifications:
175 using remove_reference_t = typename remove_reference<T>::type; // C++14
177 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
179 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
181 // sign modifications:
183 using make_signed_t = typename make_signed<T>::type; // C++14
185 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
187 // array modifications:
189 using remove_extent_t = typename remove_extent<T>::type; // C++14
191 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
193 // pointer modifications:
195 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
197 using add_pointer_t = typename add_pointer<T>::type; // C++14
199 // other transformations:
200 template <size_t Len, std::size_t Align=default-alignment>
201 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
202 template <std::size_t Len, class... Types>
203 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
205 using decay_t = typename decay<T>::type; // C++14
206 template <bool b, class T=void>
207 using enable_if_t = typename enable_if<b,T>::type; // C++14
208 template <bool b, class T, class F>
209 using conditional_t = typename conditional<b,T,F>::type; // C++14
210 template <class... T>
211 using common_type_t = typename common_type<T...>::type; // C++14
213 using underlying_type_t = typename underlying_type<T>::type; // C++14
214 template <class F, class... ArgTypes>
215 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
218 using void_t = void; // C++17
220 // See C++14 20.10.4.1, primary type categories
221 template <class T> constexpr bool is_void_v
222 = is_void<T>::value; // C++17
223 template <class T> constexpr bool is_null_pointer_v
224 = is_null_pointer<T>::value; // C++17
225 template <class T> constexpr bool is_integral_v
226 = is_integral<T>::value; // C++17
227 template <class T> constexpr bool is_floating_point_v
228 = is_floating_point<T>::value; // C++17
229 template <class T> constexpr bool is_array_v
230 = is_array<T>::value; // C++17
231 template <class T> constexpr bool is_pointer_v
232 = is_pointer<T>::value; // C++17
233 template <class T> constexpr bool is_lvalue_reference_v
234 = is_lvalue_reference<T>::value; // C++17
235 template <class T> constexpr bool is_rvalue_reference_v
236 = is_rvalue_reference<T>::value; // C++17
237 template <class T> constexpr bool is_member_object_pointer_v
238 = is_member_object_pointer<T>::value; // C++17
239 template <class T> constexpr bool is_member_function_pointer_v
240 = is_member_function_pointer<T>::value; // C++17
241 template <class T> constexpr bool is_enum_v
242 = is_enum<T>::value; // C++17
243 template <class T> constexpr bool is_union_v
244 = is_union<T>::value; // C++17
245 template <class T> constexpr bool is_class_v
246 = is_class<T>::value; // C++17
247 template <class T> constexpr bool is_function_v
248 = is_function<T>::value; // C++17
250 // See C++14 20.10.4.2, composite type categories
251 template <class T> constexpr bool is_reference_v
252 = is_reference<T>::value; // C++17
253 template <class T> constexpr bool is_arithmetic_v
254 = is_arithmetic<T>::value; // C++17
255 template <class T> constexpr bool is_fundamental_v
256 = is_fundamental<T>::value; // C++17
257 template <class T> constexpr bool is_object_v
258 = is_object<T>::value; // C++17
259 template <class T> constexpr bool is_scalar_v
260 = is_scalar<T>::value; // C++17
261 template <class T> constexpr bool is_compound_v
262 = is_compound<T>::value; // C++17
263 template <class T> constexpr bool is_member_pointer_v
264 = is_member_pointer<T>::value; // C++17
266 // See C++14 20.10.4.3, type properties
267 template <class T> constexpr bool is_const_v
268 = is_const<T>::value; // C++17
269 template <class T> constexpr bool is_volatile_v
270 = is_volatile<T>::value; // C++17
271 template <class T> constexpr bool is_trivial_v
272 = is_trivial<T>::value; // C++17
273 template <class T> constexpr bool is_trivially_copyable_v
274 = is_trivially_copyable<T>::value; // C++17
275 template <class T> constexpr bool is_standard_layout_v
276 = is_standard_layout<T>::value; // C++17
277 template <class T> constexpr bool is_pod_v
278 = is_pod<T>::value; // C++17
279 template <class T> constexpr bool is_literal_type_v
280 = is_literal_type<T>::value; // C++17
281 template <class T> constexpr bool is_empty_v
282 = is_empty<T>::value; // C++17
283 template <class T> constexpr bool is_polymorphic_v
284 = is_polymorphic<T>::value; // C++17
285 template <class T> constexpr bool is_abstract_v
286 = is_abstract<T>::value; // C++17
287 template <class T> constexpr bool is_final_v
288 = is_final<T>::value; // C++17
289 template <class T> constexpr bool is_signed_v
290 = is_signed<T>::value; // C++17
291 template <class T> constexpr bool is_unsigned_v
292 = is_unsigned<T>::value; // C++17
293 template <class T, class... Args> constexpr bool is_constructible_v
294 = is_constructible<T, Args...>::value; // C++17
295 template <class T> constexpr bool is_default_constructible_v
296 = is_default_constructible<T>::value; // C++17
297 template <class T> constexpr bool is_copy_constructible_v
298 = is_copy_constructible<T>::value; // C++17
299 template <class T> constexpr bool is_move_constructible_v
300 = is_move_constructible<T>::value; // C++17
301 template <class T, class U> constexpr bool is_assignable_v
302 = is_assignable<T, U>::value; // C++17
303 template <class T> constexpr bool is_copy_assignable_v
304 = is_copy_assignable<T>::value; // C++17
305 template <class T> constexpr bool is_move_assignable_v
306 = is_move_assignable<T>::value; // C++17
307 template <class T, class U> constexpr bool is_swappable_with_v
308 = is_swappable_with<T, U>::value; // C++17
309 template <class T> constexpr bool is_swappable_v
310 = is_swappable<T>::value; // C++17
311 template <class T> constexpr bool is_destructible_v
312 = is_destructible<T>::value; // C++17
313 template <class T, class... Args> constexpr bool is_trivially_constructible_v
314 = is_trivially_constructible<T, Args...>::value; // C++17
315 template <class T> constexpr bool is_trivially_default_constructible_v
316 = is_trivially_default_constructible<T>::value; // C++17
317 template <class T> constexpr bool is_trivially_copy_constructible_v
318 = is_trivially_copy_constructible<T>::value; // C++17
319 template <class T> constexpr bool is_trivially_move_constructible_v
320 = is_trivially_move_constructible<T>::value; // C++17
321 template <class T, class U> constexpr bool is_trivially_assignable_v
322 = is_trivially_assignable<T, U>::value; // C++17
323 template <class T> constexpr bool is_trivially_copy_assignable_v
324 = is_trivially_copy_assignable<T>::value; // C++17
325 template <class T> constexpr bool is_trivially_move_assignable_v
326 = is_trivially_move_assignable<T>::value; // C++17
327 template <class T> constexpr bool is_trivially_destructible_v
328 = is_trivially_destructible<T>::value; // C++17
329 template <class T, class... Args> constexpr bool is_nothrow_constructible_v
330 = is_nothrow_constructible<T, Args...>::value; // C++17
331 template <class T> constexpr bool is_nothrow_default_constructible_v
332 = is_nothrow_default_constructible<T>::value; // C++17
333 template <class T> constexpr bool is_nothrow_copy_constructible_v
334 = is_nothrow_copy_constructible<T>::value; // C++17
335 template <class T> constexpr bool is_nothrow_move_constructible_v
336 = is_nothrow_move_constructible<T>::value; // C++17
337 template <class T, class U> constexpr bool is_nothrow_assignable_v
338 = is_nothrow_assignable<T, U>::value; // C++17
339 template <class T> constexpr bool is_nothrow_copy_assignable_v
340 = is_nothrow_copy_assignable<T>::value; // C++17
341 template <class T> constexpr bool is_nothrow_move_assignable_v
342 = is_nothrow_move_assignable<T>::value; // C++17
343 template <class T, class U> constexpr bool is_nothrow_swappable_with_v
344 = is_nothrow_swappable_with<T, U>::value; // C++17
345 template <class T> constexpr bool is_nothrow_swappable_v
346 = is_nothrow_swappable<T>::value; // C++17
347 template <class T> constexpr bool is_nothrow_destructible_v
348 = is_nothrow_destructible<T>::value; // C++17
349 template <class T> constexpr bool has_virtual_destructor_v
350 = has_virtual_destructor<T>::value; // C++17
352 // See C++14 20.10.5, type property queries
353 template <class T> constexpr size_t alignment_of_v
354 = alignment_of<T>::value; // C++17
355 template <class T> constexpr size_t rank_v
356 = rank<T>::value; // C++17
357 template <class T, unsigned I = 0> constexpr size_t extent_v
358 = extent<T, I>::value; // C++17
360 // See C++14 20.10.6, type relations
361 template <class T, class U> constexpr bool is_same_v
362 = is_same<T, U>::value; // C++17
363 template <class Base, class Derived> constexpr bool is_base_of_v
364 = is_base_of<Base, Derived>::value; // C++17
365 template <class From, class To> constexpr bool is_convertible_v
366 = is_convertible<From, To>::value; // C++17
367 template <class T, class R = void> constexpr bool is_callable_v
368 = is_callable<T, R>::value; // C++17
369 template <class T, class R = void> constexpr bool is_nothrow_callable_v
370 = is_nothrow_callable<T, R>::value; // C++17
372 // [meta.logical], logical operator traits:
373 template<class... B> struct conjunction; // C++17
375 constexpr bool conjunction_v = conjunction<B...>::value; // C++17
376 template<class... B> struct disjunction; // C++17
378 constexpr bool disjunction_v = disjunction<B...>::value; // C++17
379 template<class B> struct negation; // C++17
381 constexpr bool negation_v = negation<B>::value; // C++17
389 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
390 #pragma GCC system_header
393 _LIBCPP_BEGIN_NAMESPACE_STD
395 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
396 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
397 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
400 struct __void_t { typedef void type; };
403 struct __identity { typedef _Tp type; };
405 template <class _Tp, bool>
406 struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
408 template <bool _Bp, class _If, class _Then>
409 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
410 template <class _If, class _Then>
411 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
413 #if _LIBCPP_STD_VER > 11
414 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
417 template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
418 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
420 template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
421 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
423 #if _LIBCPP_STD_VER > 11
424 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
428 #if __has_builtin(__builtin_addressof)
431 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
432 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
434 addressof(_Tp& __x) _NOEXCEPT
436 return __builtin_addressof(__x);
442 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
444 addressof(_Tp& __x) _NOEXCEPT
446 return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
449 #endif // __has_builtin(__builtin_addressof)
451 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
452 // Objective-C++ Automatic Reference Counting uses qualified pointers
453 // that require special addressof() signatures. When
454 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
455 // itself is providing these definitions. Otherwise, we provide them.
457 inline _LIBCPP_INLINE_VISIBILITY
459 addressof(__strong _Tp& __x) _NOEXCEPT
464 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
466 inline _LIBCPP_INLINE_VISIBILITY
468 addressof(__weak _Tp& __x) _NOEXCEPT
475 inline _LIBCPP_INLINE_VISIBILITY
477 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
483 inline _LIBCPP_INLINE_VISIBILITY
484 __unsafe_unretained _Tp*
485 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
491 struct __two {char __lx[2];};
495 template <class _Tp, _Tp __v>
496 struct _LIBCPP_TYPE_VIS_ONLY integral_constant
498 static _LIBCPP_CONSTEXPR const _Tp value = __v;
499 typedef _Tp value_type;
500 typedef integral_constant type;
501 _LIBCPP_INLINE_VISIBILITY
502 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
503 #if _LIBCPP_STD_VER > 11
504 _LIBCPP_INLINE_VISIBILITY
505 constexpr value_type operator ()() const _NOEXCEPT {return value;}
509 template <class _Tp, _Tp __v>
510 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
512 #if _LIBCPP_STD_VER > 14
514 using bool_constant = integral_constant<bool, __b>;
515 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
517 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
520 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
521 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
523 #if !defined(_LIBCPP_HAS_NO_VARIADICS)
527 template <bool _Last, class ..._Preds>
528 struct __lazy_and_impl;
530 template <class ..._Preds>
531 struct __lazy_and_impl<false, _Preds...> : false_type {};
534 struct __lazy_and_impl<true> : true_type {};
536 template <class _Pred>
537 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
539 template <class _Hp, class ..._Tp>
540 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
542 template <class _P1, class ..._Pr>
543 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
547 template <bool _List, class ..._Preds>
548 struct __lazy_or_impl;
550 template <class ..._Preds>
551 struct __lazy_or_impl<true, _Preds...> : true_type {};
554 struct __lazy_or_impl<false> : false_type {};
556 template <class _Hp, class ..._Tp>
557 struct __lazy_or_impl<false, _Hp, _Tp...>
558 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
560 template <class _P1, class ..._Pr>
561 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
565 template <class _Pred>
566 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
569 template<class...> struct __and_;
570 template<> struct __and_<> : true_type {};
572 template<class _B0> struct __and_<_B0> : _B0 {};
574 template<class _B0, class _B1>
575 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
577 template<class _B0, class _B1, class _B2, class... _Bn>
578 struct __and_<_B0, _B1, _B2, _Bn...>
579 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
582 template<class...> struct __or_;
583 template<> struct __or_<> : false_type {};
585 template<class _B0> struct __or_<_B0> : _B0 {};
587 template<class _B0, class _B1>
588 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
590 template<class _B0, class _B1, class _B2, class... _Bn>
591 struct __or_<_B0, _B1, _B2, _Bn...>
592 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
596 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
598 #endif // !defined(_LIBCPP_HAS_NO_VARIADICS)
602 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
603 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
605 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
606 template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
607 = is_const<_Tp>::value;
612 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
613 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
615 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
616 template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
617 = is_volatile<_Tp>::value;
622 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
623 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
624 #if _LIBCPP_STD_VER > 11
625 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
630 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
631 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
632 #if _LIBCPP_STD_VER > 11
633 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
638 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
639 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
640 #if _LIBCPP_STD_VER > 11
641 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
646 template <class _Tp> struct __libcpp_is_void : public false_type {};
647 template <> struct __libcpp_is_void<void> : public true_type {};
649 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
650 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
652 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
653 template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
654 = is_void<_Tp>::value;
659 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
660 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
662 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
663 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
665 #if _LIBCPP_STD_VER > 11
666 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
667 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
669 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
670 template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
671 = is_null_pointer<_Tp>::value;
677 template <class _Tp> struct __libcpp_is_integral : public false_type {};
678 template <> struct __libcpp_is_integral<bool> : public true_type {};
679 template <> struct __libcpp_is_integral<char> : public true_type {};
680 template <> struct __libcpp_is_integral<signed char> : public true_type {};
681 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
682 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
683 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
684 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
685 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
686 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
687 template <> struct __libcpp_is_integral<short> : public true_type {};
688 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
689 template <> struct __libcpp_is_integral<int> : public true_type {};
690 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
691 template <> struct __libcpp_is_integral<long> : public true_type {};
692 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
693 template <> struct __libcpp_is_integral<long long> : public true_type {};
694 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
695 #ifndef _LIBCPP_HAS_NO_INT128
696 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
697 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
700 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
701 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
703 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
704 template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
705 = is_integral<_Tp>::value;
710 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
711 template <> struct __libcpp_is_floating_point<float> : public true_type {};
712 template <> struct __libcpp_is_floating_point<double> : public true_type {};
713 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
715 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
716 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
718 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
719 template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
720 = is_floating_point<_Tp>::value;
725 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
726 : public false_type {};
727 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
728 : public true_type {};
729 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
730 : public true_type {};
732 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
733 template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
734 = is_array<_Tp>::value;
739 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
740 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
742 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
743 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
745 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
746 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
747 = is_pointer<_Tp>::value;
752 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
753 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
755 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
756 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
757 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
760 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
761 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
762 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
763 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
766 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
767 template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
768 = is_reference<_Tp>::value;
770 template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
771 = is_lvalue_reference<_Tp>::value;
773 template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
774 = is_rvalue_reference<_Tp>::value;
778 #if __has_feature(is_union) || (_GNUC_VER >= 403)
780 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
781 : public integral_constant<bool, __is_union(_Tp)> {};
785 template <class _Tp> struct __libcpp_union : public false_type {};
786 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
787 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
791 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
792 template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
793 = is_union<_Tp>::value;
798 #if __has_feature(is_class) || (_GNUC_VER >= 403)
800 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
801 : public integral_constant<bool, __is_class(_Tp)> {};
805 namespace __is_class_imp
807 template <class _Tp> char __test(int _Tp::*);
808 template <class _Tp> __two __test(...);
811 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
812 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
816 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
817 template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
818 = is_class<_Tp>::value;
823 template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
824 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
826 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
827 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
828 = is_same<_Tp, _Up>::value;
833 namespace __libcpp_is_function_imp
835 struct __dummy_type {};
836 template <class _Tp> char __test(_Tp*);
837 template <class _Tp> char __test(__dummy_type);
838 template <class _Tp> __two __test(...);
839 template <class _Tp> _Tp& __source(int);
840 template <class _Tp> __dummy_type __source(...);
843 template <class _Tp, bool = is_class<_Tp>::value ||
844 is_union<_Tp>::value ||
845 is_void<_Tp>::value ||
846 is_reference<_Tp>::value ||
847 __is_nullptr_t<_Tp>::value >
848 struct __libcpp_is_function
849 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
851 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
853 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
854 : public __libcpp_is_function<_Tp> {};
856 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
857 template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
858 = is_function<_Tp>::value;
861 // is_member_function_pointer
863 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
864 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
867 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
868 struct __member_pointer_traits_imp
869 { // forward declaration; specializations later
873 template <class _Tp> struct __libcpp_is_member_function_pointer
874 : public false_type {};
876 template <class _Ret, class _Class>
877 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
878 : public is_function<_Ret> {};
880 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
881 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
883 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
884 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
885 = is_member_function_pointer<_Tp>::value;
890 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
891 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
893 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
894 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
896 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
897 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
898 = is_member_pointer<_Tp>::value;
901 // is_member_object_pointer
903 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
904 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
905 !is_member_function_pointer<_Tp>::value> {};
907 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
908 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
909 = is_member_object_pointer<_Tp>::value;
914 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
916 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
917 : public integral_constant<bool, __is_enum(_Tp)> {};
921 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
922 : public integral_constant<bool, !is_void<_Tp>::value &&
923 !is_integral<_Tp>::value &&
924 !is_floating_point<_Tp>::value &&
925 !is_array<_Tp>::value &&
926 !is_pointer<_Tp>::value &&
927 !is_reference<_Tp>::value &&
928 !is_member_pointer<_Tp>::value &&
929 !is_union<_Tp>::value &&
930 !is_class<_Tp>::value &&
931 !is_function<_Tp>::value > {};
935 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
936 template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
937 = is_enum<_Tp>::value;
942 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
943 : public integral_constant<bool, is_integral<_Tp>::value ||
944 is_floating_point<_Tp>::value> {};
946 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
947 template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
948 = is_arithmetic<_Tp>::value;
953 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
954 : public integral_constant<bool, is_void<_Tp>::value ||
955 __is_nullptr_t<_Tp>::value ||
956 is_arithmetic<_Tp>::value> {};
958 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
959 template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
960 = is_fundamental<_Tp>::value;
965 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
966 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
967 is_member_pointer<_Tp>::value ||
968 is_pointer<_Tp>::value ||
969 __is_nullptr_t<_Tp>::value ||
970 is_enum<_Tp>::value > {};
972 template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
974 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
975 template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
976 = is_scalar<_Tp>::value;
981 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
982 : public integral_constant<bool, is_scalar<_Tp>::value ||
983 is_array<_Tp>::value ||
984 is_union<_Tp>::value ||
985 is_class<_Tp>::value > {};
987 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
988 template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
989 = is_object<_Tp>::value;
994 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
995 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
997 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
998 template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
999 = is_compound<_Tp>::value;
1003 // __is_referenceable [defns.referenceable]
1005 struct __is_referenceable_impl {
1006 template <class _Tp> static _Tp& __test(int);
1007 template <class _Tp> static __two __test(...);
1010 template <class _Tp>
1011 struct __is_referenceable : integral_constant<bool,
1012 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1017 template <class _Tp, bool = is_reference<_Tp>::value ||
1018 is_function<_Tp>::value ||
1019 is_const<_Tp>::value >
1020 struct __add_const {typedef _Tp type;};
1022 template <class _Tp>
1023 struct __add_const<_Tp, false> {typedef const _Tp type;};
1025 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
1026 {typedef typename __add_const<_Tp>::type type;};
1028 #if _LIBCPP_STD_VER > 11
1029 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1034 template <class _Tp, bool = is_reference<_Tp>::value ||
1035 is_function<_Tp>::value ||
1036 is_volatile<_Tp>::value >
1037 struct __add_volatile {typedef _Tp type;};
1039 template <class _Tp>
1040 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1042 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
1043 {typedef typename __add_volatile<_Tp>::type type;};
1045 #if _LIBCPP_STD_VER > 11
1046 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1051 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
1052 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1054 #if _LIBCPP_STD_VER > 11
1055 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1060 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
1061 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
1062 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1063 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
1066 #if _LIBCPP_STD_VER > 11
1067 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1070 // add_lvalue_reference
1072 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1073 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1075 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference
1076 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1078 #if _LIBCPP_STD_VER > 11
1079 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1082 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1084 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1085 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1087 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference
1088 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1090 #if _LIBCPP_STD_VER > 11
1091 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1094 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1096 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1098 template <class _Tp> _Tp&& __declval(int);
1099 template <class _Tp> _Tp __declval(long);
1101 template <class _Tp>
1102 decltype(_VSTD::__declval<_Tp>(0))
1103 declval() _NOEXCEPT;
1105 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1107 template <class _Tp>
1108 typename add_lvalue_reference<_Tp>::type
1111 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1115 template <class _Tp>
1117 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1120 template <class _Tp>
1121 struct __unconstref {
1122 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1125 // __is_same_uncvref
1127 template <class _Tp, class _Up>
1128 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1129 typename __uncvref<_Up>::type> {};
1138 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
1139 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
1140 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
1141 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
1142 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1144 #if _LIBCPP_STD_VER > 11
1145 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1150 template <class _Tp,
1151 bool = __is_referenceable<_Tp>::value ||
1152 is_same<typename remove_cv<_Tp>::type, void>::value>
1153 struct __add_pointer_impl
1154 {typedef typename remove_reference<_Tp>::type* type;};
1155 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1156 {typedef _Tp type;};
1158 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
1159 {typedef typename __add_pointer_impl<_Tp>::type type;};
1161 #if _LIBCPP_STD_VER > 11
1162 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1167 template <class _Tp, bool = is_integral<_Tp>::value>
1168 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1170 template <class _Tp>
1171 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1173 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1174 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1176 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1178 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
1180 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1181 template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
1182 = is_signed<_Tp>::value;
1187 template <class _Tp, bool = is_integral<_Tp>::value>
1188 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1190 template <class _Tp>
1191 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1193 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1194 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1196 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1198 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1200 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1201 template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
1202 = is_unsigned<_Tp>::value;
1207 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
1208 : public integral_constant<size_t, 0> {};
1209 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
1210 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1211 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
1212 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1214 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1215 template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
1221 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
1222 : public integral_constant<size_t, 0> {};
1223 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
1224 : public integral_constant<size_t, 0> {};
1225 template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
1226 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1227 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
1228 : public integral_constant<size_t, _Np> {};
1229 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
1230 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1232 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1233 template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
1234 = extent<_Tp, _Ip>::value;
1239 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
1240 {typedef _Tp type;};
1241 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
1242 {typedef _Tp type;};
1243 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
1244 {typedef _Tp type;};
1246 #if _LIBCPP_STD_VER > 11
1247 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1250 // remove_all_extents
1252 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
1253 {typedef _Tp type;};
1254 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
1255 {typedef typename remove_all_extents<_Tp>::type type;};
1256 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
1257 {typedef typename remove_all_extents<_Tp>::type type;};
1259 #if _LIBCPP_STD_VER > 11
1260 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1265 template <class _Tp>
1266 struct _LIBCPP_TYPE_VIS_ONLY decay
1269 typedef typename remove_reference<_Tp>::type _Up;
1271 typedef typename conditional
1273 is_array<_Up>::value,
1274 typename remove_extent<_Up>::type*,
1275 typename conditional
1277 is_function<_Up>::value,
1278 typename add_pointer<_Up>::type,
1279 typename remove_cv<_Up>::type
1284 #if _LIBCPP_STD_VER > 11
1285 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1290 namespace __is_abstract_imp
1292 template <class _Tp> char __test(_Tp (*)[1]);
1293 template <class _Tp> __two __test(...);
1296 template <class _Tp, bool = is_class<_Tp>::value>
1297 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
1299 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
1301 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
1303 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1304 template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
1305 = is_abstract<_Tp>::value;
1310 #if defined(_LIBCPP_HAS_IS_FINAL)
1311 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1312 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1314 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1315 __libcpp_is_final : public false_type {};
1318 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1319 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
1320 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1323 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1324 template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
1325 = is_final<_Tp>::value;
1330 #ifdef _LIBCPP_HAS_IS_BASE_OF
1332 template <class _Bp, class _Dp>
1333 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
1334 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1336 #else // _LIBCPP_HAS_IS_BASE_OF
1338 namespace __is_base_of_imp
1340 template <class _Tp>
1343 _Dst(const volatile _Tp &);
1345 template <class _Tp>
1348 operator const volatile _Tp &();
1349 template <class _Up> operator const _Dst<_Up> &();
1351 template <size_t> struct __one { typedef char type; };
1352 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1353 template <class _Bp, class _Dp> __two __test(...);
1356 template <class _Bp, class _Dp>
1357 struct _LIBCPP_TYPE_VIS_ONLY is_base_of
1358 : public integral_constant<bool, is_class<_Bp>::value &&
1359 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1361 #endif // _LIBCPP_HAS_IS_BASE_OF
1363 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1364 template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
1365 = is_base_of<_Bp, _Dp>::value;
1370 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1372 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
1373 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1374 !is_abstract<_T2>::value> {};
1376 #else // __has_feature(is_convertible_to)
1378 namespace __is_convertible_imp
1380 template <class _Tp> void __test_convert(_Tp);
1382 template <class _From, class _To, class = void>
1383 struct __is_convertible_test : public false_type {};
1385 template <class _From, class _To>
1386 struct __is_convertible_test<_From, _To,
1387 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1390 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1391 bool _IsFunction = is_function<_Tp>::value,
1392 bool _IsVoid = is_void<_Tp>::value>
1393 struct __is_array_function_or_void {enum {value = 0};};
1394 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1395 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1396 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1399 template <class _Tp,
1400 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1401 struct __is_convertible_check
1403 static const size_t __v = 0;
1406 template <class _Tp>
1407 struct __is_convertible_check<_Tp, 0>
1409 static const size_t __v = sizeof(_Tp);
1412 template <class _T1, class _T2,
1413 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1414 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1415 struct __is_convertible
1416 : public integral_constant<bool,
1417 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1418 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1419 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1420 && (!is_const<typename remove_reference<_T2>::type>::value
1421 || is_volatile<typename remove_reference<_T2>::type>::value)
1422 && (is_same<typename remove_cv<_T1>::type,
1423 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1424 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1429 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1430 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1431 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1432 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1434 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1435 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1436 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1437 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1439 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1440 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1441 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1442 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1444 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
1445 : public __is_convertible<_T1, _T2>
1447 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1448 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1451 #endif // __has_feature(is_convertible_to)
1453 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1454 template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
1455 = is_convertible<_From, _To>::value;
1460 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1462 template <class _Tp>
1463 struct _LIBCPP_TYPE_VIS_ONLY is_empty
1464 : public integral_constant<bool, __is_empty(_Tp)> {};
1466 #else // __has_feature(is_empty)
1468 template <class _Tp>
1480 template <class _Tp, bool = is_class<_Tp>::value>
1481 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1483 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1485 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
1487 #endif // __has_feature(is_empty)
1489 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1490 template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
1491 = is_empty<_Tp>::value;
1496 #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
1498 template <class _Tp>
1499 struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1500 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1504 template<typename _Tp> char &__is_polymorphic_impl(
1505 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1507 template<typename _Tp> __two &__is_polymorphic_impl(...);
1509 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
1510 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1512 #endif // __has_feature(is_polymorphic)
1514 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1515 template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
1516 = is_polymorphic<_Tp>::value;
1519 // has_virtual_destructor
1521 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1523 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1524 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1528 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
1529 : public false_type {};
1533 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1534 template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1535 = has_virtual_destructor<_Tp>::value;
1540 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
1541 : public integral_constant<size_t, __alignof__(_Tp)> {};
1543 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1544 template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
1545 = alignment_of<_Tp>::value;
1550 template <class _Hp, class _Tp>
1559 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1561 __nat(const __nat&) = delete;
1562 __nat& operator=(const __nat&) = delete;
1567 template <class _Tp>
1570 static const size_t value = alignment_of<_Tp>::value;
1574 struct __struct_double {long double __lx;};
1575 struct __struct_double4 {double __lx[4];};
1578 __type_list<__align_type<unsigned char>,
1579 __type_list<__align_type<unsigned short>,
1580 __type_list<__align_type<unsigned int>,
1581 __type_list<__align_type<unsigned long>,
1582 __type_list<__align_type<unsigned long long>,
1583 __type_list<__align_type<double>,
1584 __type_list<__align_type<long double>,
1585 __type_list<__align_type<__struct_double>,
1586 __type_list<__align_type<__struct_double4>,
1587 __type_list<__align_type<int*>,
1589 > > > > > > > > > > __all_types;
1591 template <class _TL, size_t _Align> struct __find_pod;
1593 template <class _Hp, size_t _Align>
1594 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1596 typedef typename conditional<
1597 _Align == _Hp::value,
1603 template <class _Hp, class _Tp, size_t _Align>
1604 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1606 typedef typename conditional<
1607 _Align == _Hp::value,
1609 typename __find_pod<_Tp, _Align>::type
1613 template <class _TL, size_t _Len> struct __find_max_align;
1615 template <class _Hp, size_t _Len>
1616 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1618 template <size_t _Len, size_t _A1, size_t _A2>
1619 struct __select_align
1622 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1623 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1625 static const size_t value = _Len < __max ? __min : __max;
1628 template <class _Hp, class _Tp, size_t _Len>
1629 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1630 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1632 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1633 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
1635 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1636 static_assert(!is_void<_Aligner>::value, "");
1640 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1644 #if _LIBCPP_STD_VER > 11
1645 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1646 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1649 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1650 template <size_t _Len>\
1651 struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
1653 struct _ALIGNAS(n) type\
1655 unsigned char __lx[(_Len + n - 1)/n * n];\
1659 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1660 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1661 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1662 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1663 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1664 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1665 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1666 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1667 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1668 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1669 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1670 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1671 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1672 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1673 // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
1674 #if !defined(_LIBCPP_MSVC)
1675 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1676 #endif // !_LIBCPP_MSVC
1678 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1680 #ifndef _LIBCPP_HAS_NO_VARIADICS
1684 template <size_t _I0, size_t ..._In>
1685 struct __static_max;
1687 template <size_t _I0>
1688 struct __static_max<_I0>
1690 static const size_t value = _I0;
1693 template <size_t _I0, size_t _I1, size_t ..._In>
1694 struct __static_max<_I0, _I1, _In...>
1696 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1697 __static_max<_I1, _In...>::value;
1700 template <size_t _Len, class _Type0, class ..._Types>
1701 struct aligned_union
1703 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1704 __alignof__(_Types)...>::value;
1705 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1706 sizeof(_Types)...>::value;
1707 typedef typename aligned_storage<__len, alignment_value>::type type;
1710 #if _LIBCPP_STD_VER > 11
1711 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1714 #endif // _LIBCPP_HAS_NO_VARIADICS
1716 template <class _Tp>
1717 struct __numeric_type
1719 static void __test(...);
1720 static float __test(float);
1721 static double __test(char);
1722 static double __test(int);
1723 static double __test(unsigned);
1724 static double __test(long);
1725 static double __test(unsigned long);
1726 static double __test(long long);
1727 static double __test(unsigned long long);
1728 static double __test(double);
1729 static long double __test(long double);
1731 typedef decltype(__test(declval<_Tp>())) type;
1732 static const bool value = !is_same<type, void>::value;
1736 struct __numeric_type<void>
1738 static const bool value = true;
1743 template <class _A1, class _A2 = void, class _A3 = void,
1744 bool = __numeric_type<_A1>::value &&
1745 __numeric_type<_A2>::value &&
1746 __numeric_type<_A3>::value>
1750 static const bool value = false;
1753 template <class _A1, class _A2, class _A3>
1754 class __promote_imp<_A1, _A2, _A3, true>
1757 typedef typename __promote_imp<_A1>::type __type1;
1758 typedef typename __promote_imp<_A2>::type __type2;
1759 typedef typename __promote_imp<_A3>::type __type3;
1761 typedef decltype(__type1() + __type2() + __type3()) type;
1762 static const bool value = true;
1765 template <class _A1, class _A2>
1766 class __promote_imp<_A1, _A2, void, true>
1769 typedef typename __promote_imp<_A1>::type __type1;
1770 typedef typename __promote_imp<_A2>::type __type2;
1772 typedef decltype(__type1() + __type2()) type;
1773 static const bool value = true;
1776 template <class _A1>
1777 class __promote_imp<_A1, void, void, true>
1780 typedef typename __numeric_type<_A1>::type type;
1781 static const bool value = true;
1784 template <class _A1, class _A2 = void, class _A3 = void>
1785 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1787 // make_signed / make_unsigned
1790 __type_list<signed char,
1791 __type_list<signed short,
1792 __type_list<signed int,
1793 __type_list<signed long,
1794 __type_list<signed long long,
1795 #ifndef _LIBCPP_HAS_NO_INT128
1796 __type_list<__int128_t,
1799 #ifndef _LIBCPP_HAS_NO_INT128
1802 > > > > > __signed_types;
1805 __type_list<unsigned char,
1806 __type_list<unsigned short,
1807 __type_list<unsigned int,
1808 __type_list<unsigned long,
1809 __type_list<unsigned long long,
1810 #ifndef _LIBCPP_HAS_NO_INT128
1811 __type_list<__uint128_t,
1814 #ifndef _LIBCPP_HAS_NO_INT128
1817 > > > > > __unsigned_types;
1819 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1821 template <class _Hp, class _Tp, size_t _Size>
1822 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1827 template <class _Hp, class _Tp, size_t _Size>
1828 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1830 typedef typename __find_first<_Tp, _Size>::type type;
1833 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1834 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1840 template <class _Tp, class _Up>
1841 struct __apply_cv<_Tp, _Up, true, false>
1843 typedef const _Up type;
1846 template <class _Tp, class _Up>
1847 struct __apply_cv<_Tp, _Up, false, true>
1849 typedef volatile _Up type;
1852 template <class _Tp, class _Up>
1853 struct __apply_cv<_Tp, _Up, true, true>
1855 typedef const volatile _Up type;
1858 template <class _Tp, class _Up>
1859 struct __apply_cv<_Tp&, _Up, false, false>
1864 template <class _Tp, class _Up>
1865 struct __apply_cv<_Tp&, _Up, true, false>
1867 typedef const _Up& type;
1870 template <class _Tp, class _Up>
1871 struct __apply_cv<_Tp&, _Up, false, true>
1873 typedef volatile _Up& type;
1876 template <class _Tp, class _Up>
1877 struct __apply_cv<_Tp&, _Up, true, true>
1879 typedef const volatile _Up& type;
1882 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1883 struct __make_signed {};
1885 template <class _Tp>
1886 struct __make_signed<_Tp, true>
1888 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1891 template <> struct __make_signed<bool, true> {};
1892 template <> struct __make_signed< signed short, true> {typedef short type;};
1893 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1894 template <> struct __make_signed< signed int, true> {typedef int type;};
1895 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1896 template <> struct __make_signed< signed long, true> {typedef long type;};
1897 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1898 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1899 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1900 #ifndef _LIBCPP_HAS_NO_INT128
1901 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1902 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1905 template <class _Tp>
1906 struct _LIBCPP_TYPE_VIS_ONLY make_signed
1908 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1911 #if _LIBCPP_STD_VER > 11
1912 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1915 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1916 struct __make_unsigned {};
1918 template <class _Tp>
1919 struct __make_unsigned<_Tp, true>
1921 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1924 template <> struct __make_unsigned<bool, true> {};
1925 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1926 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1927 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1928 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1929 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1930 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1931 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1932 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1933 #ifndef _LIBCPP_HAS_NO_INT128
1934 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1935 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1938 template <class _Tp>
1939 struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
1941 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1944 #if _LIBCPP_STD_VER > 11
1945 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1948 #ifdef _LIBCPP_HAS_NO_VARIADICS
1950 template <class _Tp, class _Up = void, class _Vp = void>
1951 struct _LIBCPP_TYPE_VIS_ONLY common_type
1954 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
1957 template <class _Tp>
1958 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
1961 typedef typename decay<_Tp>::type type;
1964 template <class _Tp, class _Up>
1965 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
1967 typedef typename decay<decltype(
1968 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1972 #else // _LIBCPP_HAS_NO_VARIADICS
1974 // bullet 1 - sizeof...(Tp) == 0
1976 template <class ..._Tp>
1977 struct _LIBCPP_TYPE_VIS_ONLY common_type {};
1979 // bullet 2 - sizeof...(Tp) == 1
1981 template <class _Tp>
1982 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
1984 typedef typename decay<_Tp>::type type;
1987 // bullet 3 - sizeof...(Tp) == 2
1989 template <class _Tp, class _Up, class = void>
1990 struct __common_type2 {};
1992 template <class _Tp, class _Up>
1993 struct __common_type2<_Tp, _Up,
1994 typename __void_t<decltype(
1995 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1998 typedef typename decay<decltype(
1999 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2003 template <class _Tp, class _Up>
2004 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
2005 : __common_type2<_Tp, _Up> {};
2007 // bullet 4 - sizeof...(Tp) > 2
2009 template <class ...Tp> struct __common_types;
2011 template <class, class = void>
2012 struct __common_type_impl {};
2014 template <class _Tp, class _Up, class ..._Vp>
2015 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2016 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2018 typedef typename common_type<
2019 typename common_type<_Tp, _Up>::type, _Vp...
2023 template <class _Tp, class _Up, class ..._Vp>
2024 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
2025 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2027 #if _LIBCPP_STD_VER > 11
2028 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2031 #endif // _LIBCPP_HAS_NO_VARIADICS
2035 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2037 template <class _Tp, class _Arg>
2038 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2039 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2040 __is_assignable_test(_Tp&&, _Arg&&);
2042 __is_assignable_test(_Tp, _Arg&);
2045 template <class _Arg>
2047 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2048 __is_assignable_test(__any, _Arg&&);
2050 __is_assignable_test(__any, _Arg&);
2053 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2054 struct __is_assignable_imp
2055 : public common_type
2057 decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
2060 template <class _Tp, class _Arg>
2061 struct __is_assignable_imp<_Tp, _Arg, true>
2066 template <class _Tp, class _Arg>
2067 struct is_assignable
2068 : public __is_assignable_imp<_Tp, _Arg> {};
2070 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2071 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
2072 = is_assignable<_Tp, _Arg>::value;
2075 // is_copy_assignable
2077 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
2078 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2079 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2081 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2082 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2083 = is_copy_assignable<_Tp>::value;
2086 // is_move_assignable
2088 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
2089 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2090 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2091 const typename add_rvalue_reference<_Tp>::type> {};
2093 : public is_copy_assignable<_Tp> {};
2096 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2097 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
2098 = is_move_assignable<_Tp>::value;
2103 // if it's a reference, return true
2104 // if it's a function, return false
2105 // if it's void, return false
2106 // if it's an array of unknown bound, return false
2107 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2108 // where _Up is remove_all_extents<_Tp>::type
2111 struct __is_destructible_apply { typedef int type; };
2113 template <typename _Tp>
2114 struct __is_destructor_wellformed {
2115 template <typename _Tp1>
2116 static char __test (
2117 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2120 template <typename _Tp1>
2121 static __two __test (...);
2123 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2126 template <class _Tp, bool>
2127 struct __destructible_imp;
2129 template <class _Tp>
2130 struct __destructible_imp<_Tp, false>
2131 : public _VSTD::integral_constant<bool,
2132 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2134 template <class _Tp>
2135 struct __destructible_imp<_Tp, true>
2136 : public _VSTD::true_type {};
2138 template <class _Tp, bool>
2139 struct __destructible_false;
2141 template <class _Tp>
2142 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2144 template <class _Tp>
2145 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2147 template <class _Tp>
2148 struct is_destructible
2149 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2151 template <class _Tp>
2152 struct is_destructible<_Tp[]>
2153 : public _VSTD::false_type {};
2156 struct is_destructible<void>
2157 : public _VSTD::false_type {};
2159 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2160 template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
2161 = is_destructible<_Tp>::value;
2166 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2168 template <class _Tp>
2169 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2170 typename remove_reference<_Tp>::type&&
2171 move(_Tp&& __t) _NOEXCEPT
2173 typedef typename remove_reference<_Tp>::type _Up;
2174 return static_cast<_Up&&>(__t);
2177 template <class _Tp>
2178 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2180 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2182 return static_cast<_Tp&&>(__t);
2185 template <class _Tp>
2186 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2188 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2190 static_assert(!is_lvalue_reference<_Tp>::value,
2191 "Can not forward an rvalue as an lvalue.");
2192 return static_cast<_Tp&&>(__t);
2195 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2197 template <class _Tp>
2198 inline _LIBCPP_INLINE_VISIBILITY
2205 template <class _Tp>
2206 inline _LIBCPP_INLINE_VISIBILITY
2208 move(const _Tp& __t)
2213 template <class _Tp>
2214 inline _LIBCPP_INLINE_VISIBILITY
2216 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2222 template <class _Tp>
2225 typedef typename remove_reference<_Tp>::type _Trr;
2228 _LIBCPP_INLINE_VISIBILITY
2229 _Trr* operator->() {return &t_;}
2230 _LIBCPP_INLINE_VISIBILITY
2231 explicit __rv(_Trr& __t) : t_(__t) {}
2234 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2236 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2238 template <class _Tp>
2239 inline _LIBCPP_INLINE_VISIBILITY
2240 typename decay<_Tp>::type
2241 __decay_copy(_Tp&& __t)
2243 return _VSTD::forward<_Tp>(__t);
2248 template <class _Tp>
2249 inline _LIBCPP_INLINE_VISIBILITY
2250 typename decay<_Tp>::type
2251 __decay_copy(const _Tp& __t)
2253 return _VSTD::forward<_Tp>(__t);
2258 #ifndef _LIBCPP_HAS_NO_VARIADICS
2260 template <class _Rp, class _Class, class ..._Param>
2261 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2263 typedef _Class _ClassType;
2264 typedef _Rp _ReturnType;
2265 typedef _Rp (_FnType) (_Param...);
2268 template <class _Rp, class _Class, class ..._Param>
2269 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2271 typedef _Class _ClassType;
2272 typedef _Rp _ReturnType;
2273 typedef _Rp (_FnType) (_Param..., ...);
2276 template <class _Rp, class _Class, class ..._Param>
2277 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2279 typedef _Class const _ClassType;
2280 typedef _Rp _ReturnType;
2281 typedef _Rp (_FnType) (_Param...);
2284 template <class _Rp, class _Class, class ..._Param>
2285 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2287 typedef _Class const _ClassType;
2288 typedef _Rp _ReturnType;
2289 typedef _Rp (_FnType) (_Param..., ...);
2292 template <class _Rp, class _Class, class ..._Param>
2293 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2295 typedef _Class volatile _ClassType;
2296 typedef _Rp _ReturnType;
2297 typedef _Rp (_FnType) (_Param...);
2300 template <class _Rp, class _Class, class ..._Param>
2301 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2303 typedef _Class volatile _ClassType;
2304 typedef _Rp _ReturnType;
2305 typedef _Rp (_FnType) (_Param..., ...);
2308 template <class _Rp, class _Class, class ..._Param>
2309 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2311 typedef _Class const volatile _ClassType;
2312 typedef _Rp _ReturnType;
2313 typedef _Rp (_FnType) (_Param...);
2316 template <class _Rp, class _Class, class ..._Param>
2317 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2319 typedef _Class const volatile _ClassType;
2320 typedef _Rp _ReturnType;
2321 typedef _Rp (_FnType) (_Param..., ...);
2324 #if __has_feature(cxx_reference_qualified_functions) || \
2325 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2327 template <class _Rp, class _Class, class ..._Param>
2328 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2330 typedef _Class& _ClassType;
2331 typedef _Rp _ReturnType;
2332 typedef _Rp (_FnType) (_Param...);
2335 template <class _Rp, class _Class, class ..._Param>
2336 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2338 typedef _Class& _ClassType;
2339 typedef _Rp _ReturnType;
2340 typedef _Rp (_FnType) (_Param..., ...);
2343 template <class _Rp, class _Class, class ..._Param>
2344 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2346 typedef _Class const& _ClassType;
2347 typedef _Rp _ReturnType;
2348 typedef _Rp (_FnType) (_Param...);
2351 template <class _Rp, class _Class, class ..._Param>
2352 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2354 typedef _Class const& _ClassType;
2355 typedef _Rp _ReturnType;
2356 typedef _Rp (_FnType) (_Param..., ...);
2359 template <class _Rp, class _Class, class ..._Param>
2360 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2362 typedef _Class volatile& _ClassType;
2363 typedef _Rp _ReturnType;
2364 typedef _Rp (_FnType) (_Param...);
2367 template <class _Rp, class _Class, class ..._Param>
2368 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2370 typedef _Class volatile& _ClassType;
2371 typedef _Rp _ReturnType;
2372 typedef _Rp (_FnType) (_Param..., ...);
2375 template <class _Rp, class _Class, class ..._Param>
2376 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2378 typedef _Class const volatile& _ClassType;
2379 typedef _Rp _ReturnType;
2380 typedef _Rp (_FnType) (_Param...);
2383 template <class _Rp, class _Class, class ..._Param>
2384 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2386 typedef _Class const volatile& _ClassType;
2387 typedef _Rp _ReturnType;
2388 typedef _Rp (_FnType) (_Param..., ...);
2391 template <class _Rp, class _Class, class ..._Param>
2392 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2394 typedef _Class&& _ClassType;
2395 typedef _Rp _ReturnType;
2396 typedef _Rp (_FnType) (_Param...);
2399 template <class _Rp, class _Class, class ..._Param>
2400 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2402 typedef _Class&& _ClassType;
2403 typedef _Rp _ReturnType;
2404 typedef _Rp (_FnType) (_Param..., ...);
2407 template <class _Rp, class _Class, class ..._Param>
2408 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2410 typedef _Class const&& _ClassType;
2411 typedef _Rp _ReturnType;
2412 typedef _Rp (_FnType) (_Param...);
2415 template <class _Rp, class _Class, class ..._Param>
2416 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2418 typedef _Class const&& _ClassType;
2419 typedef _Rp _ReturnType;
2420 typedef _Rp (_FnType) (_Param..., ...);
2423 template <class _Rp, class _Class, class ..._Param>
2424 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2426 typedef _Class volatile&& _ClassType;
2427 typedef _Rp _ReturnType;
2428 typedef _Rp (_FnType) (_Param...);
2431 template <class _Rp, class _Class, class ..._Param>
2432 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2434 typedef _Class volatile&& _ClassType;
2435 typedef _Rp _ReturnType;
2436 typedef _Rp (_FnType) (_Param..., ...);
2439 template <class _Rp, class _Class, class ..._Param>
2440 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2442 typedef _Class const volatile&& _ClassType;
2443 typedef _Rp _ReturnType;
2444 typedef _Rp (_FnType) (_Param...);
2447 template <class _Rp, class _Class, class ..._Param>
2448 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2450 typedef _Class const volatile&& _ClassType;
2451 typedef _Rp _ReturnType;
2452 typedef _Rp (_FnType) (_Param..., ...);
2455 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2457 #else // _LIBCPP_HAS_NO_VARIADICS
2459 template <class _Rp, class _Class>
2460 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2462 typedef _Class _ClassType;
2463 typedef _Rp _ReturnType;
2464 typedef _Rp (_FnType) ();
2467 template <class _Rp, class _Class>
2468 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2470 typedef _Class _ClassType;
2471 typedef _Rp _ReturnType;
2472 typedef _Rp (_FnType) (...);
2475 template <class _Rp, class _Class, class _P0>
2476 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2478 typedef _Class _ClassType;
2479 typedef _Rp _ReturnType;
2480 typedef _Rp (_FnType) (_P0);
2483 template <class _Rp, class _Class, class _P0>
2484 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2486 typedef _Class _ClassType;
2487 typedef _Rp _ReturnType;
2488 typedef _Rp (_FnType) (_P0, ...);
2491 template <class _Rp, class _Class, class _P0, class _P1>
2492 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2494 typedef _Class _ClassType;
2495 typedef _Rp _ReturnType;
2496 typedef _Rp (_FnType) (_P0, _P1);
2499 template <class _Rp, class _Class, class _P0, class _P1>
2500 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2502 typedef _Class _ClassType;
2503 typedef _Rp _ReturnType;
2504 typedef _Rp (_FnType) (_P0, _P1, ...);
2507 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2508 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2510 typedef _Class _ClassType;
2511 typedef _Rp _ReturnType;
2512 typedef _Rp (_FnType) (_P0, _P1, _P2);
2515 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2516 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2518 typedef _Class _ClassType;
2519 typedef _Rp _ReturnType;
2520 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2523 template <class _Rp, class _Class>
2524 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2526 typedef _Class const _ClassType;
2527 typedef _Rp _ReturnType;
2528 typedef _Rp (_FnType) ();
2531 template <class _Rp, class _Class>
2532 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2534 typedef _Class const _ClassType;
2535 typedef _Rp _ReturnType;
2536 typedef _Rp (_FnType) (...);
2539 template <class _Rp, class _Class, class _P0>
2540 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2542 typedef _Class const _ClassType;
2543 typedef _Rp _ReturnType;
2544 typedef _Rp (_FnType) (_P0);
2547 template <class _Rp, class _Class, class _P0>
2548 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2550 typedef _Class const _ClassType;
2551 typedef _Rp _ReturnType;
2552 typedef _Rp (_FnType) (_P0, ...);
2555 template <class _Rp, class _Class, class _P0, class _P1>
2556 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2558 typedef _Class const _ClassType;
2559 typedef _Rp _ReturnType;
2560 typedef _Rp (_FnType) (_P0, _P1);
2563 template <class _Rp, class _Class, class _P0, class _P1>
2564 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2566 typedef _Class const _ClassType;
2567 typedef _Rp _ReturnType;
2568 typedef _Rp (_FnType) (_P0, _P1, ...);
2571 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2572 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2574 typedef _Class const _ClassType;
2575 typedef _Rp _ReturnType;
2576 typedef _Rp (_FnType) (_P0, _P1, _P2);
2579 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2580 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2582 typedef _Class const _ClassType;
2583 typedef _Rp _ReturnType;
2584 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2587 template <class _Rp, class _Class>
2588 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2590 typedef _Class volatile _ClassType;
2591 typedef _Rp _ReturnType;
2592 typedef _Rp (_FnType) ();
2595 template <class _Rp, class _Class>
2596 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2598 typedef _Class volatile _ClassType;
2599 typedef _Rp _ReturnType;
2600 typedef _Rp (_FnType) (...);
2603 template <class _Rp, class _Class, class _P0>
2604 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2606 typedef _Class volatile _ClassType;
2607 typedef _Rp _ReturnType;
2608 typedef _Rp (_FnType) (_P0);
2611 template <class _Rp, class _Class, class _P0>
2612 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2614 typedef _Class volatile _ClassType;
2615 typedef _Rp _ReturnType;
2616 typedef _Rp (_FnType) (_P0, ...);
2619 template <class _Rp, class _Class, class _P0, class _P1>
2620 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2622 typedef _Class volatile _ClassType;
2623 typedef _Rp _ReturnType;
2624 typedef _Rp (_FnType) (_P0, _P1);
2627 template <class _Rp, class _Class, class _P0, class _P1>
2628 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2630 typedef _Class volatile _ClassType;
2631 typedef _Rp _ReturnType;
2632 typedef _Rp (_FnType) (_P0, _P1, ...);
2635 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2636 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2638 typedef _Class volatile _ClassType;
2639 typedef _Rp _ReturnType;
2640 typedef _Rp (_FnType) (_P0, _P1, _P2);
2643 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2644 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2646 typedef _Class volatile _ClassType;
2647 typedef _Rp _ReturnType;
2648 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2651 template <class _Rp, class _Class>
2652 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2654 typedef _Class const volatile _ClassType;
2655 typedef _Rp _ReturnType;
2656 typedef _Rp (_FnType) ();
2659 template <class _Rp, class _Class>
2660 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2662 typedef _Class const volatile _ClassType;
2663 typedef _Rp _ReturnType;
2664 typedef _Rp (_FnType) (...);
2667 template <class _Rp, class _Class, class _P0>
2668 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2670 typedef _Class const volatile _ClassType;
2671 typedef _Rp _ReturnType;
2672 typedef _Rp (_FnType) (_P0);
2675 template <class _Rp, class _Class, class _P0>
2676 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2678 typedef _Class const volatile _ClassType;
2679 typedef _Rp _ReturnType;
2680 typedef _Rp (_FnType) (_P0, ...);
2683 template <class _Rp, class _Class, class _P0, class _P1>
2684 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2686 typedef _Class const volatile _ClassType;
2687 typedef _Rp _ReturnType;
2688 typedef _Rp (_FnType) (_P0, _P1);
2691 template <class _Rp, class _Class, class _P0, class _P1>
2692 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2694 typedef _Class const volatile _ClassType;
2695 typedef _Rp _ReturnType;
2696 typedef _Rp (_FnType) (_P0, _P1, ...);
2699 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2700 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2702 typedef _Class const volatile _ClassType;
2703 typedef _Rp _ReturnType;
2704 typedef _Rp (_FnType) (_P0, _P1, _P2);
2707 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2708 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2710 typedef _Class const volatile _ClassType;
2711 typedef _Rp _ReturnType;
2712 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2715 #endif // _LIBCPP_HAS_NO_VARIADICS
2717 template <class _Rp, class _Class>
2718 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2720 typedef _Class _ClassType;
2721 typedef _Rp _ReturnType;
2724 template <class _MP>
2725 struct __member_pointer_traits
2726 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2727 is_member_function_pointer<_MP>::value,
2728 is_member_object_pointer<_MP>::value>
2730 // typedef ... _ClassType;
2731 // typedef ... _ReturnType;
2732 // typedef ... _FnType;
2736 template <class _DecayedFp>
2737 struct __member_pointer_class_type {};
2739 template <class _Ret, class _ClassType>
2740 struct __member_pointer_class_type<_Ret _ClassType::*> {
2741 typedef _ClassType type;
2746 template <class _Callable> class result_of;
2748 #ifdef _LIBCPP_HAS_NO_VARIADICS
2750 template <class _Fn, bool, bool>
2755 template <class _Fn>
2756 class __result_of<_Fn(), true, false>
2759 typedef decltype(declval<_Fn>()()) type;
2762 template <class _Fn, class _A0>
2763 class __result_of<_Fn(_A0), true, false>
2766 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2769 template <class _Fn, class _A0, class _A1>
2770 class __result_of<_Fn(_A0, _A1), true, false>
2773 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2776 template <class _Fn, class _A0, class _A1, class _A2>
2777 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2780 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2783 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2784 struct __result_of_mp;
2786 // member function pointer
2788 template <class _MP, class _Tp>
2789 struct __result_of_mp<_MP, _Tp, true>
2790 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2794 // member data pointer
2796 template <class _MP, class _Tp, bool>
2797 struct __result_of_mdp;
2799 template <class _Rp, class _Class, class _Tp>
2800 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2802 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2805 template <class _Rp, class _Class, class _Tp>
2806 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2808 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2811 template <class _Rp, class _Class, class _Tp>
2812 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2813 : public __result_of_mdp<_Rp _Class::*, _Tp,
2814 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2820 template <class _Fn, class _Tp>
2821 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2822 : public __result_of_mp<typename remove_reference<_Fn>::type,
2824 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2828 template <class _Fn, class _Tp, class _A0>
2829 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2830 : public __result_of_mp<typename remove_reference<_Fn>::type,
2832 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2836 template <class _Fn, class _Tp, class _A0, class _A1>
2837 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2838 : public __result_of_mp<typename remove_reference<_Fn>::type,
2840 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2844 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2845 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2846 : public __result_of_mp<typename remove_reference<_Fn>::type,
2848 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2854 template <class _Fn>
2855 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
2856 : public __result_of<_Fn(),
2857 is_class<typename remove_reference<_Fn>::type>::value ||
2858 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2859 is_member_pointer<typename remove_reference<_Fn>::type>::value
2864 template <class _Fn, class _A0>
2865 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
2866 : public __result_of<_Fn(_A0),
2867 is_class<typename remove_reference<_Fn>::type>::value ||
2868 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2869 is_member_pointer<typename remove_reference<_Fn>::type>::value
2874 template <class _Fn, class _A0, class _A1>
2875 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
2876 : public __result_of<_Fn(_A0, _A1),
2877 is_class<typename remove_reference<_Fn>::type>::value ||
2878 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2879 is_member_pointer<typename remove_reference<_Fn>::type>::value
2884 template <class _Fn, class _A0, class _A1, class _A2>
2885 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
2886 : public __result_of<_Fn(_A0, _A1, _A2),
2887 is_class<typename remove_reference<_Fn>::type>::value ||
2888 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2889 is_member_pointer<typename remove_reference<_Fn>::type>::value
2894 #endif // _LIBCPP_HAS_NO_VARIADICS
2896 // template <class T, class... Args> struct is_constructible;
2898 namespace __is_construct
2903 #if __has_feature(is_constructible)
2905 template <class _Tp, class ..._Args>
2906 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
2907 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2912 #ifndef _LIBCPP_HAS_NO_VARIADICS
2914 // main is_constructible test
2916 template <class _Tp, class ..._Args>
2917 typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
2918 __is_constructible_test(_Tp&&, _Args&& ...);
2920 template <class ..._Args>
2922 __is_constructible_test(__any, _Args&& ...);
2924 template <bool, class _Tp, class... _Args>
2925 struct __libcpp_is_constructible // false, _Tp is not a scalar
2926 : public common_type
2928 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
2932 // function types are not constructible
2934 template <class _Rp, class... _A1, class... _A2>
2935 struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
2939 // handle scalars and reference types
2941 // Scalars are default constructible, references are not
2943 template <class _Tp>
2944 struct __libcpp_is_constructible<true, _Tp>
2945 : public is_scalar<_Tp>
2948 // Scalars and references are constructible from one arg if that arg is
2949 // implicitly convertible to the scalar or reference.
2951 template <class _Tp>
2952 struct __is_constructible_ref
2954 true_type static __lxx(_Tp);
2955 false_type static __lxx(...);
2958 template <class _Tp, class _A0>
2959 struct __libcpp_is_constructible<true, _Tp, _A0>
2960 : public common_type
2962 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
2966 // Scalars and references are not constructible from multiple args.
2968 template <class _Tp, class _A0, class ..._Args>
2969 struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
2973 // Treat scalars and reference types separately
2975 template <bool, class _Tp, class... _Args>
2976 struct __is_constructible_void_check
2977 : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
2981 // If any of T or Args is void, is_constructible should be false
2983 template <class _Tp, class... _Args>
2984 struct __is_constructible_void_check<true, _Tp, _Args...>
2988 template <class ..._Args> struct __contains_void;
2990 template <> struct __contains_void<> : false_type {};
2992 template <class _A0, class ..._Args>
2993 struct __contains_void<_A0, _Args...>
2995 static const bool value = is_void<_A0>::value ||
2996 __contains_void<_Args...>::value;
2999 // is_constructible entry point
3001 template <class _Tp, class... _Args>
3002 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
3003 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
3004 || is_abstract<_Tp>::value,
3008 // Array types are default constructible if their element type
3009 // is default constructible
3011 template <class _Ap, size_t _Np>
3012 struct __libcpp_is_constructible<false, _Ap[_Np]>
3013 : public is_constructible<typename remove_all_extents<_Ap>::type>
3016 // Otherwise array types are not constructible by this syntax
3018 template <class _Ap, size_t _Np, class ..._Args>
3019 struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
3023 // Incomplete array types are not constructible
3025 template <class _Ap, class ..._Args>
3026 struct __libcpp_is_constructible<false, _Ap[], _Args...>
3030 #else // _LIBCPP_HAS_NO_VARIADICS
3032 // template <class T> struct is_constructible0;
3034 // main is_constructible0 test
3036 template <class _Tp>
3037 decltype((_Tp(), true_type()))
3038 __is_constructible0_test(_Tp&);
3041 __is_constructible0_test(__any);
3043 template <class _Tp, class _A0>
3044 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3045 __is_constructible1_test(_Tp&, _A0&);
3047 template <class _A0>
3049 __is_constructible1_test(__any, _A0&);
3051 template <class _Tp, class _A0, class _A1>
3052 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3053 __is_constructible2_test(_Tp&, _A0&, _A1&);
3055 template <class _A0, class _A1>
3057 __is_constructible2_test(__any, _A0&, _A1&);
3059 template <bool, class _Tp>
3060 struct __is_constructible0_imp // false, _Tp is not a scalar
3061 : public common_type
3063 decltype(__is_constructible0_test(declval<_Tp&>()))
3067 template <bool, class _Tp, class _A0>
3068 struct __is_constructible1_imp // false, _Tp is not a scalar
3069 : public common_type
3071 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3075 template <bool, class _Tp, class _A0, class _A1>
3076 struct __is_constructible2_imp // false, _Tp is not a scalar
3077 : public common_type
3079 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3083 // handle scalars and reference types
3085 // Scalars are default constructible, references are not
3087 template <class _Tp>
3088 struct __is_constructible0_imp<true, _Tp>
3089 : public is_scalar<_Tp>
3092 template <class _Tp, class _A0>
3093 struct __is_constructible1_imp<true, _Tp, _A0>
3094 : public is_convertible<_A0, _Tp>
3097 template <class _Tp, class _A0, class _A1>
3098 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3102 // Treat scalars and reference types separately
3104 template <bool, class _Tp>
3105 struct __is_constructible0_void_check
3106 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3110 template <bool, class _Tp, class _A0>
3111 struct __is_constructible1_void_check
3112 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3116 template <bool, class _Tp, class _A0, class _A1>
3117 struct __is_constructible2_void_check
3118 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3122 // If any of T or Args is void, is_constructible should be false
3124 template <class _Tp>
3125 struct __is_constructible0_void_check<true, _Tp>
3129 template <class _Tp, class _A0>
3130 struct __is_constructible1_void_check<true, _Tp, _A0>
3134 template <class _Tp, class _A0, class _A1>
3135 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3139 // is_constructible entry point
3141 template <class _Tp, class _A0 = __is_construct::__nat,
3142 class _A1 = __is_construct::__nat>
3143 struct _LIBCPP_TYPE_VIS_ONLY is_constructible
3144 : public __is_constructible2_void_check<is_void<_Tp>::value
3145 || is_abstract<_Tp>::value
3146 || is_function<_Tp>::value
3147 || is_void<_A0>::value
3148 || is_void<_A1>::value,
3152 template <class _Tp>
3153 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3154 : public __is_constructible0_void_check<is_void<_Tp>::value
3155 || is_abstract<_Tp>::value
3156 || is_function<_Tp>::value,
3160 template <class _Tp, class _A0>
3161 struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
3162 : public __is_constructible1_void_check<is_void<_Tp>::value
3163 || is_abstract<_Tp>::value
3164 || is_function<_Tp>::value
3165 || is_void<_A0>::value,
3169 // Array types are default constructible if their element type
3170 // is default constructible
3172 template <class _Ap, size_t _Np>
3173 struct __is_constructible0_imp<false, _Ap[_Np]>
3174 : public is_constructible<typename remove_all_extents<_Ap>::type>
3177 template <class _Ap, size_t _Np, class _A0>
3178 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3182 template <class _Ap, size_t _Np, class _A0, class _A1>
3183 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3187 // Incomplete array types are not constructible
3189 template <class _Ap>
3190 struct __is_constructible0_imp<false, _Ap[]>
3194 template <class _Ap, class _A0>
3195 struct __is_constructible1_imp<false, _Ap[], _A0>
3199 template <class _Ap, class _A0, class _A1>
3200 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3204 #endif // _LIBCPP_HAS_NO_VARIADICS
3205 #endif // __has_feature(is_constructible)
3207 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3208 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
3209 = is_constructible<_Tp, _Args...>::value;
3212 // is_default_constructible
3214 template <class _Tp>
3215 struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
3216 : public is_constructible<_Tp>
3219 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3220 template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
3221 = is_default_constructible<_Tp>::value;
3224 // is_copy_constructible
3226 template <class _Tp>
3227 struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
3228 : public is_constructible<_Tp,
3229 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3231 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3232 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3233 = is_copy_constructible<_Tp>::value;
3236 // is_move_constructible
3238 template <class _Tp>
3239 struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
3240 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3241 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3243 : public is_copy_constructible<_Tp>
3247 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3248 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
3249 = is_move_constructible<_Tp>::value;
3252 // is_trivially_constructible
3254 #ifndef _LIBCPP_HAS_NO_VARIADICS
3256 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3258 template <class _Tp, class... _Args>
3259 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
3260 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3264 #else // !__has_feature(is_trivially_constructible)
3266 template <class _Tp, class... _Args>
3267 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
3272 template <class _Tp>
3273 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
3274 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3275 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3277 : integral_constant<bool, is_scalar<_Tp>::value>
3282 template <class _Tp>
3283 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3284 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
3286 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
3288 : integral_constant<bool, is_scalar<_Tp>::value>
3292 template <class _Tp>
3293 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
3294 : integral_constant<bool, is_scalar<_Tp>::value>
3298 template <class _Tp>
3299 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
3300 : integral_constant<bool, is_scalar<_Tp>::value>
3304 #endif // !__has_feature(is_trivially_constructible)
3306 #else // _LIBCPP_HAS_NO_VARIADICS
3308 template <class _Tp, class _A0 = __is_construct::__nat,
3309 class _A1 = __is_construct::__nat>
3310 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
3315 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3317 template <class _Tp>
3318 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
3319 __is_construct::__nat>
3320 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3324 template <class _Tp>
3325 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
3326 __is_construct::__nat>
3327 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3331 template <class _Tp>
3332 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
3333 __is_construct::__nat>
3334 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3338 template <class _Tp>
3339 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
3340 __is_construct::__nat>
3341 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3345 #else // !__has_feature(is_trivially_constructible)
3347 template <class _Tp>
3348 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
3349 __is_construct::__nat>
3350 : integral_constant<bool, is_scalar<_Tp>::value>
3354 template <class _Tp>
3355 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
3356 __is_construct::__nat>
3357 : integral_constant<bool, is_scalar<_Tp>::value>
3361 template <class _Tp>
3362 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
3363 __is_construct::__nat>
3364 : integral_constant<bool, is_scalar<_Tp>::value>
3368 template <class _Tp>
3369 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
3370 __is_construct::__nat>
3371 : integral_constant<bool, is_scalar<_Tp>::value>
3375 #endif // !__has_feature(is_trivially_constructible)
3377 #endif // _LIBCPP_HAS_NO_VARIADICS
3379 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3380 template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3381 = is_trivially_constructible<_Tp, _Args...>::value;
3384 // is_trivially_default_constructible
3386 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
3387 : public is_trivially_constructible<_Tp>
3390 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3391 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3392 = is_trivially_default_constructible<_Tp>::value;
3395 // is_trivially_copy_constructible
3397 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
3398 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3401 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3402 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3403 = is_trivially_copy_constructible<_Tp>::value;
3406 // is_trivially_move_constructible
3408 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
3409 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3410 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3412 : public is_trivially_copy_constructible<_Tp>
3416 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3417 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3418 = is_trivially_move_constructible<_Tp>::value;
3421 // is_trivially_assignable
3423 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3425 template <class _Tp, class _Arg>
3426 struct is_trivially_assignable
3427 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3431 #else // !__has_feature(is_trivially_assignable)
3433 template <class _Tp, class _Arg>
3434 struct is_trivially_assignable
3435 : public false_type {};
3437 template <class _Tp>
3438 struct is_trivially_assignable<_Tp&, _Tp>
3439 : integral_constant<bool, is_scalar<_Tp>::value> {};
3441 template <class _Tp>
3442 struct is_trivially_assignable<_Tp&, _Tp&>
3443 : integral_constant<bool, is_scalar<_Tp>::value> {};
3445 template <class _Tp>
3446 struct is_trivially_assignable<_Tp&, const _Tp&>
3447 : integral_constant<bool, is_scalar<_Tp>::value> {};
3449 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3451 template <class _Tp>
3452 struct is_trivially_assignable<_Tp&, _Tp&&>
3453 : integral_constant<bool, is_scalar<_Tp>::value> {};
3455 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3457 #endif // !__has_feature(is_trivially_assignable)
3459 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3460 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3461 = is_trivially_assignable<_Tp, _Arg>::value;
3464 // is_trivially_copy_assignable
3466 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
3467 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3468 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3470 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3471 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3472 = is_trivially_copy_assignable<_Tp>::value;
3475 // is_trivially_move_assignable
3477 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
3478 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3479 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3480 typename add_rvalue_reference<_Tp>::type>
3482 typename add_lvalue_reference<_Tp>::type>
3486 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3487 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3488 = is_trivially_move_assignable<_Tp>::value;
3491 // is_trivially_destructible
3493 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3495 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
3496 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3500 template <class _Tp> struct __libcpp_trivial_destructor
3501 : public integral_constant<bool, is_scalar<_Tp>::value ||
3502 is_reference<_Tp>::value> {};
3504 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
3505 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3507 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
3508 : public false_type {};
3512 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3513 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3514 = is_trivially_destructible<_Tp>::value;
3517 // is_nothrow_constructible
3520 template <class _Tp, class... _Args>
3521 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3522 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3528 #ifndef _LIBCPP_HAS_NO_VARIADICS
3530 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3532 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3534 template <class _Tp, class... _Args>
3535 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3536 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3540 template <class _Tp>
3541 void __implicit_conversion_to(_Tp) noexcept { }
3543 template <class _Tp, class _Arg>
3544 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3545 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3549 template <class _Tp, bool _IsReference, class... _Args>
3550 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3555 template <class _Tp, class... _Args>
3556 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3557 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3561 template <class _Tp, size_t _Ns>
3562 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
3563 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3567 #else // __has_feature(cxx_noexcept)
3569 template <class _Tp, class... _Args>
3570 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3575 template <class _Tp>
3576 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
3577 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3578 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3580 : integral_constant<bool, is_scalar<_Tp>::value>
3585 template <class _Tp>
3586 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3587 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
3589 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
3591 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3592 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3594 : integral_constant<bool, is_scalar<_Tp>::value>
3599 template <class _Tp>
3600 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
3601 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3602 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3604 : integral_constant<bool, is_scalar<_Tp>::value>
3609 template <class _Tp>
3610 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
3611 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3612 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3614 : integral_constant<bool, is_scalar<_Tp>::value>
3619 #endif // __has_feature(cxx_noexcept)
3621 #else // _LIBCPP_HAS_NO_VARIADICS
3623 template <class _Tp, class _A0 = __is_construct::__nat,
3624 class _A1 = __is_construct::__nat>
3625 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
3630 template <class _Tp>
3631 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
3632 __is_construct::__nat>
3633 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3634 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3636 : integral_constant<bool, is_scalar<_Tp>::value>
3641 template <class _Tp>
3642 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
3643 __is_construct::__nat>
3644 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3645 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3647 : integral_constant<bool, is_scalar<_Tp>::value>
3652 template <class _Tp>
3653 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
3654 __is_construct::__nat>
3655 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3656 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3658 : integral_constant<bool, is_scalar<_Tp>::value>
3663 template <class _Tp>
3664 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
3665 __is_construct::__nat>
3666 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3667 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3669 : integral_constant<bool, is_scalar<_Tp>::value>
3674 #endif // _LIBCPP_HAS_NO_VARIADICS
3675 #endif // __has_feature(is_nothrow_constructible)
3677 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3678 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3679 = is_nothrow_constructible<_Tp, _Args...>::value;
3682 // is_nothrow_default_constructible
3684 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
3685 : public is_nothrow_constructible<_Tp>
3688 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3689 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3690 = is_nothrow_default_constructible<_Tp>::value;
3693 // is_nothrow_copy_constructible
3695 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
3696 : public is_nothrow_constructible<_Tp,
3697 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3699 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3700 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3701 = is_nothrow_copy_constructible<_Tp>::value;
3704 // is_nothrow_move_constructible
3706 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
3707 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3708 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3710 : public is_nothrow_copy_constructible<_Tp>
3714 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3715 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3716 = is_nothrow_move_constructible<_Tp>::value;
3719 // is_nothrow_assignable
3721 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3723 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3725 template <class _Tp, class _Arg>
3726 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3731 template <class _Tp, class _Arg>
3732 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3733 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3737 template <class _Tp, class _Arg>
3738 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3739 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3743 #else // __has_feature(cxx_noexcept)
3745 template <class _Tp, class _Arg>
3746 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
3747 : public false_type {};
3749 template <class _Tp>
3750 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
3751 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3752 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3754 : integral_constant<bool, is_scalar<_Tp>::value> {};
3757 template <class _Tp>
3758 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
3759 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3760 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3762 : integral_constant<bool, is_scalar<_Tp>::value> {};
3765 template <class _Tp>
3766 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
3767 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3768 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3770 : integral_constant<bool, is_scalar<_Tp>::value> {};
3773 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3775 template <class _Tp>
3776 struct is_nothrow_assignable<_Tp&, _Tp&&>
3777 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3778 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3780 : integral_constant<bool, is_scalar<_Tp>::value> {};
3783 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3785 #endif // __has_feature(cxx_noexcept)
3787 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3788 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3789 = is_nothrow_assignable<_Tp, _Arg>::value;
3792 // is_nothrow_copy_assignable
3794 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
3795 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3796 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3798 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3799 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3800 = is_nothrow_copy_assignable<_Tp>::value;
3803 // is_nothrow_move_assignable
3805 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
3806 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3807 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3808 typename add_rvalue_reference<_Tp>::type>
3810 typename add_lvalue_reference<_Tp>::type>
3814 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3815 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3816 = is_nothrow_move_assignable<_Tp>::value;
3819 // is_nothrow_destructible
3821 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3823 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3825 template <class _Tp>
3826 struct __libcpp_is_nothrow_destructible<false, _Tp>
3831 template <class _Tp>
3832 struct __libcpp_is_nothrow_destructible<true, _Tp>
3833 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3837 template <class _Tp>
3838 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3839 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3843 template <class _Tp, size_t _Ns>
3844 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
3845 : public is_nothrow_destructible<_Tp>
3849 template <class _Tp>
3850 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
3855 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3857 template <class _Tp>
3858 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
3867 template <class _Tp> struct __libcpp_nothrow_destructor
3868 : public integral_constant<bool, is_scalar<_Tp>::value ||
3869 is_reference<_Tp>::value> {};
3871 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
3872 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3874 template <class _Tp>
3875 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
3876 : public false_type {};
3880 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3881 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3882 = is_nothrow_destructible<_Tp>::value;
3887 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
3889 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3890 : public integral_constant<bool, __is_pod(_Tp)> {};
3894 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
3895 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3896 is_trivially_copy_constructible<_Tp>::value &&
3897 is_trivially_copy_assignable<_Tp>::value &&
3898 is_trivially_destructible<_Tp>::value> {};
3902 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3903 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
3904 = is_pod<_Tp>::value;
3909 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
3910 #ifdef _LIBCPP_IS_LITERAL
3911 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3913 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3914 is_reference<typename remove_all_extents<_Tp>::type>::value>
3918 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3919 template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
3920 = is_literal_type<_Tp>::value;
3923 // is_standard_layout;
3925 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
3926 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3927 : public integral_constant<bool, __is_standard_layout(_Tp)>
3929 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3933 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3934 template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
3935 = is_standard_layout<_Tp>::value;
3938 // is_trivially_copyable;
3940 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
3941 #if __has_feature(is_trivially_copyable)
3942 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3943 #elif _GNUC_VER >= 501
3944 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3946 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3950 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3951 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3952 = is_trivially_copyable<_Tp>::value;
3957 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
3958 #if __has_feature(is_trivial) || _GNUC_VER >= 407
3959 : public integral_constant<bool, __is_trivial(_Tp)>
3961 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3962 is_trivially_default_constructible<_Tp>::value>
3966 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3967 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
3968 = is_trivial<_Tp>::value;
3971 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3972 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3973 template <class _Tp> struct __is_reference_wrapper
3974 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3976 #ifndef _LIBCPP_CXX03_LANG
3978 // Check for complete types
3980 template <class ..._Tp> struct __check_complete;
3983 struct __check_complete<>
3987 template <class _Hp, class _T0, class ..._Tp>
3988 struct __check_complete<_Hp, _T0, _Tp...>
3989 : private __check_complete<_Hp>,
3990 private __check_complete<_T0, _Tp...>
3994 template <class _Hp>
3995 struct __check_complete<_Hp, _Hp>
3996 : private __check_complete<_Hp>
4000 template <class _Tp>
4001 struct __check_complete<_Tp>
4003 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
4006 template <class _Tp>
4007 struct __check_complete<_Tp&>
4008 : private __check_complete<_Tp>
4012 template <class _Tp>
4013 struct __check_complete<_Tp&&>
4014 : private __check_complete<_Tp>
4018 template <class _Rp, class ..._Param>
4019 struct __check_complete<_Rp (*)(_Param...)>
4020 : private __check_complete<_Rp>
4024 template <class ..._Param>
4025 struct __check_complete<void (*)(_Param...)>
4029 template <class _Rp, class ..._Param>
4030 struct __check_complete<_Rp (_Param...)>
4031 : private __check_complete<_Rp>
4035 template <class ..._Param>
4036 struct __check_complete<void (_Param...)>
4040 template <class _Rp, class _Class, class ..._Param>
4041 struct __check_complete<_Rp (_Class::*)(_Param...)>
4042 : private __check_complete<_Class>
4046 template <class _Rp, class _Class, class ..._Param>
4047 struct __check_complete<_Rp (_Class::*)(_Param...) const>
4048 : private __check_complete<_Class>
4052 template <class _Rp, class _Class, class ..._Param>
4053 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
4054 : private __check_complete<_Class>
4058 template <class _Rp, class _Class, class ..._Param>
4059 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
4060 : private __check_complete<_Class>
4064 template <class _Rp, class _Class, class ..._Param>
4065 struct __check_complete<_Rp (_Class::*)(_Param...) &>
4066 : private __check_complete<_Class>
4070 template <class _Rp, class _Class, class ..._Param>
4071 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
4072 : private __check_complete<_Class>
4076 template <class _Rp, class _Class, class ..._Param>
4077 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
4078 : private __check_complete<_Class>
4082 template <class _Rp, class _Class, class ..._Param>
4083 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
4084 : private __check_complete<_Class>
4088 template <class _Rp, class _Class, class ..._Param>
4089 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
4090 : private __check_complete<_Class>
4094 template <class _Rp, class _Class, class ..._Param>
4095 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
4096 : private __check_complete<_Class>
4100 template <class _Rp, class _Class, class ..._Param>
4101 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
4102 : private __check_complete<_Class>
4106 template <class _Rp, class _Class, class ..._Param>
4107 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
4108 : private __check_complete<_Class>
4112 template <class _Rp, class _Class>
4113 struct __check_complete<_Rp _Class::*>
4114 : private __check_complete<_Class>
4119 template <class _Fp, class _A0,
4120 class _DecayFp = typename decay<_Fp>::type,
4121 class _DecayA0 = typename decay<_A0>::type,
4122 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4123 using __enable_if_bullet1 = typename enable_if
4125 is_member_function_pointer<_DecayFp>::value
4126 && is_base_of<_ClassT, _DecayA0>::value
4129 template <class _Fp, class _A0,
4130 class _DecayFp = typename decay<_Fp>::type,
4131 class _DecayA0 = typename decay<_A0>::type>
4132 using __enable_if_bullet2 = typename enable_if
4134 is_member_function_pointer<_DecayFp>::value
4135 && __is_reference_wrapper<_DecayA0>::value
4138 template <class _Fp, class _A0,
4139 class _DecayFp = typename decay<_Fp>::type,
4140 class _DecayA0 = typename decay<_A0>::type,
4141 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4142 using __enable_if_bullet3 = typename enable_if
4144 is_member_function_pointer<_DecayFp>::value
4145 && !is_base_of<_ClassT, _DecayA0>::value
4146 && !__is_reference_wrapper<_DecayA0>::value
4149 template <class _Fp, class _A0,
4150 class _DecayFp = typename decay<_Fp>::type,
4151 class _DecayA0 = typename decay<_A0>::type,
4152 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4153 using __enable_if_bullet4 = typename enable_if
4155 is_member_object_pointer<_DecayFp>::value
4156 && is_base_of<_ClassT, _DecayA0>::value
4159 template <class _Fp, class _A0,
4160 class _DecayFp = typename decay<_Fp>::type,
4161 class _DecayA0 = typename decay<_A0>::type>
4162 using __enable_if_bullet5 = typename enable_if
4164 is_member_object_pointer<_DecayFp>::value
4165 && __is_reference_wrapper<_DecayA0>::value
4168 template <class _Fp, class _A0,
4169 class _DecayFp = typename decay<_Fp>::type,
4170 class _DecayA0 = typename decay<_A0>::type,
4171 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4172 using __enable_if_bullet6 = typename enable_if
4174 is_member_object_pointer<_DecayFp>::value
4175 && !is_base_of<_ClassT, _DecayA0>::value
4176 && !__is_reference_wrapper<_DecayA0>::value
4179 // __invoke forward declarations
4181 // fall back - none of the bullets
4183 #define _LIBCPP_INVOKE_RETURN(...) \
4184 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4185 { return __VA_ARGS__; }
4187 template <class ..._Args>
4188 auto __invoke(__any, _Args&& ...__args) -> __nat;
4190 template <class ..._Args>
4191 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4193 // bullets 1, 2 and 3
4195 template <class _Fp, class _A0, class ..._Args,
4196 class = __enable_if_bullet1<_Fp, _A0>>
4197 inline _LIBCPP_INLINE_VISIBILITY
4199 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4200 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4202 template <class _Fp, class _A0, class ..._Args,
4203 class = __enable_if_bullet1<_Fp, _A0>>
4204 inline _LIBCPP_INLINE_VISIBILITY
4205 _LIBCPP_CONSTEXPR auto
4206 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4207 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4209 template <class _Fp, class _A0, class ..._Args,
4210 class = __enable_if_bullet2<_Fp, _A0>>
4211 inline _LIBCPP_INLINE_VISIBILITY
4213 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4214 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4216 template <class _Fp, class _A0, class ..._Args,
4217 class = __enable_if_bullet2<_Fp, _A0>>
4218 inline _LIBCPP_INLINE_VISIBILITY
4219 _LIBCPP_CONSTEXPR auto
4220 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4221 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4223 template <class _Fp, class _A0, class ..._Args,
4224 class = __enable_if_bullet3<_Fp, _A0>>
4225 inline _LIBCPP_INLINE_VISIBILITY
4227 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4228 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4230 template <class _Fp, class _A0, class ..._Args,
4231 class = __enable_if_bullet3<_Fp, _A0>>
4232 inline _LIBCPP_INLINE_VISIBILITY
4233 _LIBCPP_CONSTEXPR auto
4234 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4235 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4237 // bullets 4, 5 and 6
4239 template <class _Fp, class _A0,
4240 class = __enable_if_bullet4<_Fp, _A0>>
4241 inline _LIBCPP_INLINE_VISIBILITY
4243 __invoke(_Fp&& __f, _A0&& __a0)
4244 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4246 template <class _Fp, class _A0,
4247 class = __enable_if_bullet4<_Fp, _A0>>
4248 inline _LIBCPP_INLINE_VISIBILITY
4249 _LIBCPP_CONSTEXPR auto
4250 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4251 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4253 template <class _Fp, class _A0,
4254 class = __enable_if_bullet5<_Fp, _A0>>
4255 inline _LIBCPP_INLINE_VISIBILITY
4257 __invoke(_Fp&& __f, _A0&& __a0)
4258 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4260 template <class _Fp, class _A0,
4261 class = __enable_if_bullet5<_Fp, _A0>>
4262 inline _LIBCPP_INLINE_VISIBILITY
4263 _LIBCPP_CONSTEXPR auto
4264 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4265 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4267 template <class _Fp, class _A0,
4268 class = __enable_if_bullet6<_Fp, _A0>>
4269 inline _LIBCPP_INLINE_VISIBILITY
4271 __invoke(_Fp&& __f, _A0&& __a0)
4272 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4274 template <class _Fp, class _A0,
4275 class = __enable_if_bullet6<_Fp, _A0>>
4276 inline _LIBCPP_INLINE_VISIBILITY
4277 _LIBCPP_CONSTEXPR auto
4278 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4279 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4283 template <class _Fp, class ..._Args>
4284 inline _LIBCPP_INLINE_VISIBILITY
4286 __invoke(_Fp&& __f, _Args&& ...__args)
4287 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4289 template <class _Fp, class ..._Args>
4290 inline _LIBCPP_INLINE_VISIBILITY
4291 _LIBCPP_CONSTEXPR auto
4292 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4293 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4295 #undef _LIBCPP_INVOKE_RETURN
4299 template <class _Ret, class _Fp, class ..._Args>
4300 struct __invokable_r
4301 : private __check_complete<_Fp>
4303 using _Result = decltype(
4304 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4306 static const bool value =
4308 !is_same<_Result, __nat>::value,
4309 typename conditional<
4310 is_void<_Ret>::value,
4312 is_convertible<_Result, _Ret>
4318 template <class _Fp, class ..._Args>
4319 using __invokable = __invokable_r<void, _Fp, _Args...>;
4321 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4322 struct __nothrow_invokable_r_imp {
4323 static const bool value = false;
4326 template <class _Ret, class _Fp, class ..._Args>
4327 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4329 typedef __nothrow_invokable_r_imp _ThisT;
4331 template <class _Tp>
4332 static void __test_noexcept(_Tp) noexcept;
4334 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4335 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4338 template <class _Ret, class _Fp, class ..._Args>
4339 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4341 static const bool value = noexcept(
4342 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4345 template <class _Ret, class _Fp, class ..._Args>
4346 using __nothrow_invokable_r =
4347 __nothrow_invokable_r_imp<
4348 __invokable_r<_Ret, _Fp, _Args...>::value,
4349 is_void<_Ret>::value,
4353 template <class _Fp, class ..._Args>
4356 __invokable<_Fp, _Args...>::value,
4357 typename __invokable_r<void, _Fp, _Args...>::_Result>
4363 template <class _Fp, class ..._Args>
4364 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
4365 : public __invoke_of<_Fp, _Args...>
4369 #if _LIBCPP_STD_VER > 11
4370 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4373 #if _LIBCPP_STD_VER > 14
4377 template <class _Fn, class _Ret = void>
4378 struct _LIBCPP_TYPE_VIS_ONLY is_callable;
4380 template <class _Fn, class ..._Args, class _Ret>
4381 struct _LIBCPP_TYPE_VIS_ONLY is_callable<_Fn(_Args...), _Ret>
4382 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4384 template <class _Fn, class _Ret = void>
4385 constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
4387 // is_nothrow_callable
4389 template <class _Fn, class _Ret = void>
4390 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable;
4392 template <class _Fn, class ..._Args, class _Ret>
4393 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable<_Fn(_Args...), _Ret>
4394 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
4397 template <class _Fn, class _Ret = void>
4398 constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
4400 #endif // _LIBCPP_STD_VER > 14
4402 #endif // !defined(_LIBCPP_CXX03_LANG)
4404 template <class _Tp> struct __is_swappable;
4405 template <class _Tp> struct __is_nothrow_swappable;
4407 template <class _Tp>
4408 inline _LIBCPP_INLINE_VISIBILITY
4409 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
4412 is_move_constructible<_Tp>::value &&
4413 is_move_assignable<_Tp>::value
4418 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4419 is_nothrow_move_assignable<_Tp>::value)
4421 _Tp __t(_VSTD::move(__x));
4422 __x = _VSTD::move(__y);
4423 __y = _VSTD::move(__t);
4426 template<class _Tp, size_t _Np>
4427 inline _LIBCPP_INLINE_VISIBILITY
4429 __is_swappable<_Tp>::value
4431 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4433 template <class _ForwardIterator1, class _ForwardIterator2>
4434 inline _LIBCPP_INLINE_VISIBILITY
4436 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4437 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4438 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4439 *_VSTD::declval<_ForwardIterator2>())))
4448 // ALL generic swap overloads MUST already have a declaration available at this point.
4450 template <class _Tp, class _Up = _Tp,
4451 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4452 struct __swappable_with
4454 template <class _LHS, class _RHS>
4455 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4457 template <class, class>
4458 static __nat __test_swap(long);
4460 // Extra parens are needed for the C++03 definition of decltype.
4461 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4462 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4464 static const bool value = !is_same<__swap1, __nat>::value
4465 && !is_same<__swap2, __nat>::value;
4468 template <class _Tp, class _Up>
4469 struct __swappable_with<_Tp, _Up, false> : false_type {};
4471 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4472 struct __nothrow_swappable_with {
4473 static const bool value =
4474 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4475 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4476 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4482 template <class _Tp, class _Up>
4483 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4487 template <class _Tp>
4488 struct __is_swappable
4489 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4493 template <class _Tp>
4494 struct __is_nothrow_swappable
4495 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4499 #if _LIBCPP_STD_VER > 14
4501 template <class _Tp, class _Up>
4502 struct _LIBCPP_TYPE_VIS_ONLY is_swappable_with
4503 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4507 template <class _Tp>
4508 struct _LIBCPP_TYPE_VIS_ONLY is_swappable
4509 : public conditional<
4510 __is_referenceable<_Tp>::value,
4512 typename add_lvalue_reference<_Tp>::type,
4513 typename add_lvalue_reference<_Tp>::type>,
4519 template <class _Tp, class _Up>
4520 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable_with
4521 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4525 template <class _Tp>
4526 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable
4527 : public conditional<
4528 __is_referenceable<_Tp>::value,
4529 is_nothrow_swappable_with<
4530 typename add_lvalue_reference<_Tp>::type,
4531 typename add_lvalue_reference<_Tp>::type>,
4537 template <class _Tp, class _Up>
4538 constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
4540 template <class _Tp>
4541 constexpr bool is_swappable_v = is_swappable<_Tp>::value;
4543 template <class _Tp, class _Up>
4544 constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
4546 template <class _Tp>
4547 constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
4549 #endif // _LIBCPP_STD_VER > 14
4551 #ifdef _LIBCPP_UNDERLYING_TYPE
4553 template <class _Tp>
4554 struct underlying_type
4556 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4559 #if _LIBCPP_STD_VER > 11
4560 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4563 #else // _LIBCPP_UNDERLYING_TYPE
4565 template <class _Tp, bool _Support = false>
4566 struct underlying_type
4568 static_assert(_Support, "The underyling_type trait requires compiler "
4569 "support. Either no such support exists or "
4570 "libc++ does not know how to use it.");
4573 #endif // _LIBCPP_UNDERLYING_TYPE
4576 template <class _Tp, bool = is_enum<_Tp>::value>
4577 struct __sfinae_underlying_type
4579 typedef typename underlying_type<_Tp>::type type;
4580 typedef decltype(((type)1) + 0) __promoted_type;
4583 template <class _Tp>
4584 struct __sfinae_underlying_type<_Tp, false> {};
4586 inline _LIBCPP_INLINE_VISIBILITY
4587 int __convert_to_integral(int __val) { return __val; }
4589 inline _LIBCPP_INLINE_VISIBILITY
4590 unsigned __convert_to_integral(unsigned __val) { return __val; }
4592 inline _LIBCPP_INLINE_VISIBILITY
4593 long __convert_to_integral(long __val) { return __val; }
4595 inline _LIBCPP_INLINE_VISIBILITY
4596 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4598 inline _LIBCPP_INLINE_VISIBILITY
4599 long long __convert_to_integral(long long __val) { return __val; }
4601 inline _LIBCPP_INLINE_VISIBILITY
4602 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4604 #ifndef _LIBCPP_HAS_NO_INT128
4605 inline _LIBCPP_INLINE_VISIBILITY
4606 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4608 inline _LIBCPP_INLINE_VISIBILITY
4609 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4612 template <class _Tp>
4613 inline _LIBCPP_INLINE_VISIBILITY
4614 typename __sfinae_underlying_type<_Tp>::__promoted_type
4615 __convert_to_integral(_Tp __val) { return __val; }
4617 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
4619 template <class _Tp>
4620 struct __has_operator_addressof_member_imp
4622 template <class _Up>
4623 static auto __test(int)
4624 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4626 static auto __test(long) -> false_type;
4628 static const bool value = decltype(__test<_Tp>(0))::value;
4631 template <class _Tp>
4632 struct __has_operator_addressof_free_imp
4634 template <class _Up>
4635 static auto __test(int)
4636 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4638 static auto __test(long) -> false_type;
4640 static const bool value = decltype(__test<_Tp>(0))::value;
4643 template <class _Tp>
4644 struct __has_operator_addressof
4645 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4646 || __has_operator_addressof_free_imp<_Tp>::value>
4649 #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
4651 #if _LIBCPP_STD_VER > 14
4652 template <class...> using void_t = void;
4654 # ifndef _LIBCPP_HAS_NO_VARIADICS
4655 template <class... _Args>
4656 struct conjunction : __and_<_Args...> {};
4657 template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
4659 template <class... _Args>
4660 struct disjunction : __or_<_Args...> {};
4661 template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
4663 template <class _Tp>
4664 struct negation : __not_<_Tp> {};
4665 template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
4666 # endif // _LIBCPP_HAS_NO_VARIADICS
4667 #endif // _LIBCPP_STD_VER > 14
4669 // These traits are used in __tree and __hash_table
4670 #ifndef _LIBCPP_CXX03_LANG
4671 struct __extract_key_fail_tag {};
4672 struct __extract_key_self_tag {};
4673 struct __extract_key_first_tag {};
4675 template <class _ValTy, class _Key,
4676 class _RawValTy = typename __unconstref<_ValTy>::type>
4677 struct __can_extract_key
4678 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4679 __extract_key_fail_tag>::type {};
4681 template <class _Pair, class _Key, class _First, class _Second>
4682 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4683 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4684 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4686 // __can_extract_map_key uses true_type/false_type instead of the tags.
4687 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4688 // and _ValTy == _Key.
4689 template <class _ValTy, class _Key, class _ContainerValueTy,
4690 class _RawValTy = typename __unconstref<_ValTy>::type>
4691 struct __can_extract_map_key
4692 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4694 // This specialization returns __extract_key_fail_tag for non-map containers
4695 // because _Key == _ContainerValueTy
4696 template <class _ValTy, class _Key, class _RawValTy>
4697 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4702 _LIBCPP_END_NAMESPACE_STD
4704 #endif // _LIBCPP_TYPE_TRAITS