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
100 template <class T> struct is_aggregate; // C++17
102 template <class T, class... Args> struct is_constructible;
103 template <class T> struct is_default_constructible;
104 template <class T> struct is_copy_constructible;
105 template <class T> struct is_move_constructible;
106 template <class T, class U> struct is_assignable;
107 template <class T> struct is_copy_assignable;
108 template <class T> struct is_move_assignable;
109 template <class T, class U> struct is_swappable_with; // C++17
110 template <class T> struct is_swappable; // C++17
111 template <class T> struct is_destructible;
113 template <class T, class... Args> struct is_trivially_constructible;
114 template <class T> struct is_trivially_default_constructible;
115 template <class T> struct is_trivially_copy_constructible;
116 template <class T> struct is_trivially_move_constructible;
117 template <class T, class U> struct is_trivially_assignable;
118 template <class T> struct is_trivially_copy_assignable;
119 template <class T> struct is_trivially_move_assignable;
120 template <class T> struct is_trivially_destructible;
122 template <class T, class... Args> struct is_nothrow_constructible;
123 template <class T> struct is_nothrow_default_constructible;
124 template <class T> struct is_nothrow_copy_constructible;
125 template <class T> struct is_nothrow_move_constructible;
126 template <class T, class U> struct is_nothrow_assignable;
127 template <class T> struct is_nothrow_copy_assignable;
128 template <class T> struct is_nothrow_move_assignable;
129 template <class T, class U> struct is_nothrow_swappable_with; // C++17
130 template <class T> struct is_nothrow_swappable; // C++17
131 template <class T> struct is_nothrow_destructible;
133 template <class T> struct has_virtual_destructor;
135 // Relationships between types:
136 template <class T, class U> struct is_same;
137 template <class Base, class Derived> struct is_base_of;
138 template <class From, class To> struct is_convertible;
140 template <class, class R = void> struct is_callable; // not defined
141 template <class Fn, class... ArgTypes, class R>
142 struct is_callable<Fn(ArgTypes...), R>;
144 template <class, class R = void> struct is_nothrow_callable; // not defined
145 template <class Fn, class... ArgTypes, class R>
146 struct is_nothrow_callable<Fn(ArgTypes...), R>;
148 // Alignment properties and transformations:
149 template <class T> struct alignment_of;
150 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
151 struct aligned_storage;
152 template <size_t Len, class... Types> struct aligned_union;
154 template <class T> struct decay;
155 template <class... T> struct common_type;
156 template <class T> struct underlying_type;
157 template <class> class result_of; // undefined
158 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
160 // const-volatile modifications:
162 using remove_const_t = typename remove_const<T>::type; // C++14
164 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
166 using remove_cv_t = typename remove_cv<T>::type; // C++14
168 using add_const_t = typename add_const<T>::type; // C++14
170 using add_volatile_t = typename add_volatile<T>::type; // C++14
172 using add_cv_t = typename add_cv<T>::type; // C++14
174 // reference modifications:
176 using remove_reference_t = typename remove_reference<T>::type; // C++14
178 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
180 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
182 // sign modifications:
184 using make_signed_t = typename make_signed<T>::type; // C++14
186 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
188 // array modifications:
190 using remove_extent_t = typename remove_extent<T>::type; // C++14
192 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
194 // pointer modifications:
196 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
198 using add_pointer_t = typename add_pointer<T>::type; // C++14
200 // other transformations:
201 template <size_t Len, std::size_t Align=default-alignment>
202 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
203 template <std::size_t Len, class... Types>
204 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
206 using decay_t = typename decay<T>::type; // C++14
207 template <bool b, class T=void>
208 using enable_if_t = typename enable_if<b,T>::type; // C++14
209 template <bool b, class T, class F>
210 using conditional_t = typename conditional<b,T,F>::type; // C++14
211 template <class... T>
212 using common_type_t = typename common_type<T...>::type; // C++14
214 using underlying_type_t = typename underlying_type<T>::type; // C++14
215 template <class F, class... ArgTypes>
216 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
219 using void_t = void; // C++17
221 // See C++14 20.10.4.1, primary type categories
222 template <class T> constexpr bool is_void_v
223 = is_void<T>::value; // C++17
224 template <class T> constexpr bool is_null_pointer_v
225 = is_null_pointer<T>::value; // C++17
226 template <class T> constexpr bool is_integral_v
227 = is_integral<T>::value; // C++17
228 template <class T> constexpr bool is_floating_point_v
229 = is_floating_point<T>::value; // C++17
230 template <class T> constexpr bool is_array_v
231 = is_array<T>::value; // C++17
232 template <class T> constexpr bool is_pointer_v
233 = is_pointer<T>::value; // C++17
234 template <class T> constexpr bool is_lvalue_reference_v
235 = is_lvalue_reference<T>::value; // C++17
236 template <class T> constexpr bool is_rvalue_reference_v
237 = is_rvalue_reference<T>::value; // C++17
238 template <class T> constexpr bool is_member_object_pointer_v
239 = is_member_object_pointer<T>::value; // C++17
240 template <class T> constexpr bool is_member_function_pointer_v
241 = is_member_function_pointer<T>::value; // C++17
242 template <class T> constexpr bool is_enum_v
243 = is_enum<T>::value; // C++17
244 template <class T> constexpr bool is_union_v
245 = is_union<T>::value; // C++17
246 template <class T> constexpr bool is_class_v
247 = is_class<T>::value; // C++17
248 template <class T> constexpr bool is_function_v
249 = is_function<T>::value; // C++17
251 // See C++14 20.10.4.2, composite type categories
252 template <class T> constexpr bool is_reference_v
253 = is_reference<T>::value; // C++17
254 template <class T> constexpr bool is_arithmetic_v
255 = is_arithmetic<T>::value; // C++17
256 template <class T> constexpr bool is_fundamental_v
257 = is_fundamental<T>::value; // C++17
258 template <class T> constexpr bool is_object_v
259 = is_object<T>::value; // C++17
260 template <class T> constexpr bool is_scalar_v
261 = is_scalar<T>::value; // C++17
262 template <class T> constexpr bool is_compound_v
263 = is_compound<T>::value; // C++17
264 template <class T> constexpr bool is_member_pointer_v
265 = is_member_pointer<T>::value; // C++17
267 // See C++14 20.10.4.3, type properties
268 template <class T> constexpr bool is_const_v
269 = is_const<T>::value; // C++17
270 template <class T> constexpr bool is_volatile_v
271 = is_volatile<T>::value; // C++17
272 template <class T> constexpr bool is_trivial_v
273 = is_trivial<T>::value; // C++17
274 template <class T> constexpr bool is_trivially_copyable_v
275 = is_trivially_copyable<T>::value; // C++17
276 template <class T> constexpr bool is_standard_layout_v
277 = is_standard_layout<T>::value; // C++17
278 template <class T> constexpr bool is_pod_v
279 = is_pod<T>::value; // C++17
280 template <class T> constexpr bool is_literal_type_v
281 = is_literal_type<T>::value; // C++17
282 template <class T> constexpr bool is_empty_v
283 = is_empty<T>::value; // C++17
284 template <class T> constexpr bool is_polymorphic_v
285 = is_polymorphic<T>::value; // C++17
286 template <class T> constexpr bool is_abstract_v
287 = is_abstract<T>::value; // C++17
288 template <class T> constexpr bool is_final_v
289 = is_final<T>::value; // C++17
290 template <class T> constexpr bool is_aggregate_v
291 = is_aggregate<T>::value; // C++17
292 template <class T> constexpr bool is_signed_v
293 = is_signed<T>::value; // C++17
294 template <class T> constexpr bool is_unsigned_v
295 = is_unsigned<T>::value; // C++17
296 template <class T, class... Args> constexpr bool is_constructible_v
297 = is_constructible<T, Args...>::value; // C++17
298 template <class T> constexpr bool is_default_constructible_v
299 = is_default_constructible<T>::value; // C++17
300 template <class T> constexpr bool is_copy_constructible_v
301 = is_copy_constructible<T>::value; // C++17
302 template <class T> constexpr bool is_move_constructible_v
303 = is_move_constructible<T>::value; // C++17
304 template <class T, class U> constexpr bool is_assignable_v
305 = is_assignable<T, U>::value; // C++17
306 template <class T> constexpr bool is_copy_assignable_v
307 = is_copy_assignable<T>::value; // C++17
308 template <class T> constexpr bool is_move_assignable_v
309 = is_move_assignable<T>::value; // C++17
310 template <class T, class U> constexpr bool is_swappable_with_v
311 = is_swappable_with<T, U>::value; // C++17
312 template <class T> constexpr bool is_swappable_v
313 = is_swappable<T>::value; // C++17
314 template <class T> constexpr bool is_destructible_v
315 = is_destructible<T>::value; // C++17
316 template <class T, class... Args> constexpr bool is_trivially_constructible_v
317 = is_trivially_constructible<T, Args...>::value; // C++17
318 template <class T> constexpr bool is_trivially_default_constructible_v
319 = is_trivially_default_constructible<T>::value; // C++17
320 template <class T> constexpr bool is_trivially_copy_constructible_v
321 = is_trivially_copy_constructible<T>::value; // C++17
322 template <class T> constexpr bool is_trivially_move_constructible_v
323 = is_trivially_move_constructible<T>::value; // C++17
324 template <class T, class U> constexpr bool is_trivially_assignable_v
325 = is_trivially_assignable<T, U>::value; // C++17
326 template <class T> constexpr bool is_trivially_copy_assignable_v
327 = is_trivially_copy_assignable<T>::value; // C++17
328 template <class T> constexpr bool is_trivially_move_assignable_v
329 = is_trivially_move_assignable<T>::value; // C++17
330 template <class T> constexpr bool is_trivially_destructible_v
331 = is_trivially_destructible<T>::value; // C++17
332 template <class T, class... Args> constexpr bool is_nothrow_constructible_v
333 = is_nothrow_constructible<T, Args...>::value; // C++17
334 template <class T> constexpr bool is_nothrow_default_constructible_v
335 = is_nothrow_default_constructible<T>::value; // C++17
336 template <class T> constexpr bool is_nothrow_copy_constructible_v
337 = is_nothrow_copy_constructible<T>::value; // C++17
338 template <class T> constexpr bool is_nothrow_move_constructible_v
339 = is_nothrow_move_constructible<T>::value; // C++17
340 template <class T, class U> constexpr bool is_nothrow_assignable_v
341 = is_nothrow_assignable<T, U>::value; // C++17
342 template <class T> constexpr bool is_nothrow_copy_assignable_v
343 = is_nothrow_copy_assignable<T>::value; // C++17
344 template <class T> constexpr bool is_nothrow_move_assignable_v
345 = is_nothrow_move_assignable<T>::value; // C++17
346 template <class T, class U> constexpr bool is_nothrow_swappable_with_v
347 = is_nothrow_swappable_with<T, U>::value; // C++17
348 template <class T> constexpr bool is_nothrow_swappable_v
349 = is_nothrow_swappable<T>::value; // C++17
350 template <class T> constexpr bool is_nothrow_destructible_v
351 = is_nothrow_destructible<T>::value; // C++17
352 template <class T> constexpr bool has_virtual_destructor_v
353 = has_virtual_destructor<T>::value; // C++17
355 // See C++14 20.10.5, type property queries
356 template <class T> constexpr size_t alignment_of_v
357 = alignment_of<T>::value; // C++17
358 template <class T> constexpr size_t rank_v
359 = rank<T>::value; // C++17
360 template <class T, unsigned I = 0> constexpr size_t extent_v
361 = extent<T, I>::value; // C++17
363 // See C++14 20.10.6, type relations
364 template <class T, class U> constexpr bool is_same_v
365 = is_same<T, U>::value; // C++17
366 template <class Base, class Derived> constexpr bool is_base_of_v
367 = is_base_of<Base, Derived>::value; // C++17
368 template <class From, class To> constexpr bool is_convertible_v
369 = is_convertible<From, To>::value; // C++17
370 template <class T, class R = void> constexpr bool is_callable_v
371 = is_callable<T, R>::value; // C++17
372 template <class T, class R = void> constexpr bool is_nothrow_callable_v
373 = is_nothrow_callable<T, R>::value; // C++17
375 // [meta.logical], logical operator traits:
376 template<class... B> struct conjunction; // C++17
378 constexpr bool conjunction_v = conjunction<B...>::value; // C++17
379 template<class... B> struct disjunction; // C++17
381 constexpr bool disjunction_v = disjunction<B...>::value; // C++17
382 template<class B> struct negation; // C++17
384 constexpr bool negation_v = negation<B>::value; // C++17
392 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
393 #pragma GCC system_header
396 _LIBCPP_BEGIN_NAMESPACE_STD
398 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
399 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
400 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
403 struct __void_t { typedef void type; };
406 struct __identity { typedef _Tp type; };
408 template <class _Tp, bool>
409 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
411 template <bool _Bp, class _If, class _Then>
412 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
413 template <class _If, class _Then>
414 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
416 #if _LIBCPP_STD_VER > 11
417 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
420 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {};
421 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
423 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
424 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
426 #if _LIBCPP_STD_VER > 11
427 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
431 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
434 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
435 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
437 addressof(_Tp& __x) _NOEXCEPT
439 return __builtin_addressof(__x);
445 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
447 addressof(_Tp& __x) _NOEXCEPT
449 return reinterpret_cast<_Tp *>(
450 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
453 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
455 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
456 // Objective-C++ Automatic Reference Counting uses qualified pointers
457 // that require special addressof() signatures. When
458 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
459 // itself is providing these definitions. Otherwise, we provide them.
461 inline _LIBCPP_INLINE_VISIBILITY
463 addressof(__strong _Tp& __x) _NOEXCEPT
468 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
470 inline _LIBCPP_INLINE_VISIBILITY
472 addressof(__weak _Tp& __x) _NOEXCEPT
479 inline _LIBCPP_INLINE_VISIBILITY
481 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
487 inline _LIBCPP_INLINE_VISIBILITY
488 __unsafe_unretained _Tp*
489 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
495 #if !defined(_LIBCPP_CXX03_LANG)
496 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
499 struct __two {char __lx[2];};
503 template <class _Tp, _Tp __v>
504 struct _LIBCPP_TEMPLATE_VIS integral_constant
506 static _LIBCPP_CONSTEXPR const _Tp value = __v;
507 typedef _Tp value_type;
508 typedef integral_constant type;
509 _LIBCPP_INLINE_VISIBILITY
510 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
511 #if _LIBCPP_STD_VER > 11
512 _LIBCPP_INLINE_VISIBILITY
513 constexpr value_type operator ()() const _NOEXCEPT {return value;}
517 template <class _Tp, _Tp __v>
518 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
520 #if _LIBCPP_STD_VER > 14
522 using bool_constant = integral_constant<bool, __b>;
523 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
525 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
528 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
529 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
531 #if !defined(_LIBCPP_CXX03_LANG)
535 template <bool _Last, class ..._Preds>
536 struct __lazy_and_impl;
538 template <class ..._Preds>
539 struct __lazy_and_impl<false, _Preds...> : false_type {};
542 struct __lazy_and_impl<true> : true_type {};
544 template <class _Pred>
545 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
547 template <class _Hp, class ..._Tp>
548 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
550 template <class _P1, class ..._Pr>
551 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
555 template <bool _List, class ..._Preds>
556 struct __lazy_or_impl;
558 template <class ..._Preds>
559 struct __lazy_or_impl<true, _Preds...> : true_type {};
562 struct __lazy_or_impl<false> : false_type {};
564 template <class _Hp, class ..._Tp>
565 struct __lazy_or_impl<false, _Hp, _Tp...>
566 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
568 template <class _P1, class ..._Pr>
569 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
573 template <class _Pred>
574 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
577 template<class...> struct __and_;
578 template<> struct __and_<> : true_type {};
580 template<class _B0> struct __and_<_B0> : _B0 {};
582 template<class _B0, class _B1>
583 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
585 template<class _B0, class _B1, class _B2, class... _Bn>
586 struct __and_<_B0, _B1, _B2, _Bn...>
587 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
590 template<class...> struct __or_;
591 template<> struct __or_<> : false_type {};
593 template<class _B0> struct __or_<_B0> : _B0 {};
595 template<class _B0, class _B1>
596 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
598 template<class _B0, class _B1, class _B2, class... _Bn>
599 struct __or_<_B0, _B1, _B2, _Bn...>
600 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
604 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
606 #endif // !defined(_LIBCPP_CXX03_LANG)
610 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
611 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
613 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
614 template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
615 = is_const<_Tp>::value;
620 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
621 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
623 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
624 template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
625 = is_volatile<_Tp>::value;
630 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
631 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
632 #if _LIBCPP_STD_VER > 11
633 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
638 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
639 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
640 #if _LIBCPP_STD_VER > 11
641 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
646 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
647 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
648 #if _LIBCPP_STD_VER > 11
649 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
654 template <class _Tp> struct __libcpp_is_void : public false_type {};
655 template <> struct __libcpp_is_void<void> : public true_type {};
657 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
658 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
660 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
661 template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
662 = is_void<_Tp>::value;
667 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
668 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
670 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
671 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
673 #if _LIBCPP_STD_VER > 11
674 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
675 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
677 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
678 template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
679 = is_null_pointer<_Tp>::value;
685 template <class _Tp> struct __libcpp_is_integral : public false_type {};
686 template <> struct __libcpp_is_integral<bool> : public true_type {};
687 template <> struct __libcpp_is_integral<char> : public true_type {};
688 template <> struct __libcpp_is_integral<signed char> : public true_type {};
689 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
690 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
691 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
692 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
693 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
694 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
695 template <> struct __libcpp_is_integral<short> : public true_type {};
696 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
697 template <> struct __libcpp_is_integral<int> : public true_type {};
698 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
699 template <> struct __libcpp_is_integral<long> : public true_type {};
700 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
701 template <> struct __libcpp_is_integral<long long> : public true_type {};
702 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
703 #ifndef _LIBCPP_HAS_NO_INT128
704 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
705 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
708 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
709 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
711 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
712 template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
713 = is_integral<_Tp>::value;
718 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
719 template <> struct __libcpp_is_floating_point<float> : public true_type {};
720 template <> struct __libcpp_is_floating_point<double> : public true_type {};
721 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
723 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
724 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
726 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
727 template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
728 = is_floating_point<_Tp>::value;
733 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
734 : public false_type {};
735 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
736 : public true_type {};
737 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
738 : public true_type {};
740 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
741 template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
742 = is_array<_Tp>::value;
747 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
748 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
750 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
751 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
753 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
754 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
755 = is_pointer<_Tp>::value;
760 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
761 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
763 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
764 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
765 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
768 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
769 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
770 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
771 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
774 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
775 template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
776 = is_reference<_Tp>::value;
778 template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
779 = is_lvalue_reference<_Tp>::value;
781 template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
782 = is_rvalue_reference<_Tp>::value;
786 #if __has_feature(is_union) || (_GNUC_VER >= 403)
788 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
789 : public integral_constant<bool, __is_union(_Tp)> {};
793 template <class _Tp> struct __libcpp_union : public false_type {};
794 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
795 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
799 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
800 template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
801 = is_union<_Tp>::value;
806 #if __has_feature(is_class) || (_GNUC_VER >= 403)
808 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
809 : public integral_constant<bool, __is_class(_Tp)> {};
813 namespace __is_class_imp
815 template <class _Tp> char __test(int _Tp::*);
816 template <class _Tp> __two __test(...);
819 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
820 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
824 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
825 template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
826 = is_class<_Tp>::value;
831 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
832 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
834 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
835 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
836 = is_same<_Tp, _Up>::value;
841 namespace __libcpp_is_function_imp
843 struct __dummy_type {};
844 template <class _Tp> char __test(_Tp*);
845 template <class _Tp> char __test(__dummy_type);
846 template <class _Tp> __two __test(...);
847 template <class _Tp> _Tp& __source(int);
848 template <class _Tp> __dummy_type __source(...);
851 template <class _Tp, bool = is_class<_Tp>::value ||
852 is_union<_Tp>::value ||
853 is_void<_Tp>::value ||
854 is_reference<_Tp>::value ||
855 __is_nullptr_t<_Tp>::value >
856 struct __libcpp_is_function
857 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
859 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
861 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
862 : public __libcpp_is_function<_Tp> {};
864 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
865 template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
866 = is_function<_Tp>::value;
869 // is_member_function_pointer
871 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
872 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
875 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
876 struct __member_pointer_traits_imp
877 { // forward declaration; specializations later
881 template <class _Tp> struct __libcpp_is_member_function_pointer
882 : public false_type {};
884 template <class _Ret, class _Class>
885 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
886 : public is_function<_Ret> {};
888 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
889 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
891 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
892 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
893 = is_member_function_pointer<_Tp>::value;
898 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
899 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
901 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
902 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
904 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
905 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
906 = is_member_pointer<_Tp>::value;
909 // is_member_object_pointer
911 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
912 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
913 !is_member_function_pointer<_Tp>::value> {};
915 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
916 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
917 = is_member_object_pointer<_Tp>::value;
922 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
924 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
925 : public integral_constant<bool, __is_enum(_Tp)> {};
929 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
930 : public integral_constant<bool, !is_void<_Tp>::value &&
931 !is_integral<_Tp>::value &&
932 !is_floating_point<_Tp>::value &&
933 !is_array<_Tp>::value &&
934 !is_pointer<_Tp>::value &&
935 !is_reference<_Tp>::value &&
936 !is_member_pointer<_Tp>::value &&
937 !is_union<_Tp>::value &&
938 !is_class<_Tp>::value &&
939 !is_function<_Tp>::value > {};
943 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
944 template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
945 = is_enum<_Tp>::value;
950 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
951 : public integral_constant<bool, is_integral<_Tp>::value ||
952 is_floating_point<_Tp>::value> {};
954 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
955 template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
956 = is_arithmetic<_Tp>::value;
961 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
962 : public integral_constant<bool, is_void<_Tp>::value ||
963 __is_nullptr_t<_Tp>::value ||
964 is_arithmetic<_Tp>::value> {};
966 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
967 template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
968 = is_fundamental<_Tp>::value;
973 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
974 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
975 is_member_pointer<_Tp>::value ||
976 is_pointer<_Tp>::value ||
977 __is_nullptr_t<_Tp>::value ||
978 is_enum<_Tp>::value > {};
980 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
982 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
983 template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
984 = is_scalar<_Tp>::value;
989 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
990 : public integral_constant<bool, is_scalar<_Tp>::value ||
991 is_array<_Tp>::value ||
992 is_union<_Tp>::value ||
993 is_class<_Tp>::value > {};
995 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
996 template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
997 = is_object<_Tp>::value;
1002 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1003 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1005 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1006 template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
1007 = is_compound<_Tp>::value;
1011 // __is_referenceable [defns.referenceable]
1013 struct __is_referenceable_impl {
1014 template <class _Tp> static _Tp& __test(int);
1015 template <class _Tp> static __two __test(...);
1018 template <class _Tp>
1019 struct __is_referenceable : integral_constant<bool,
1020 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1025 template <class _Tp, bool = is_reference<_Tp>::value ||
1026 is_function<_Tp>::value ||
1027 is_const<_Tp>::value >
1028 struct __add_const {typedef _Tp type;};
1030 template <class _Tp>
1031 struct __add_const<_Tp, false> {typedef const _Tp type;};
1033 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1034 {typedef typename __add_const<_Tp>::type type;};
1036 #if _LIBCPP_STD_VER > 11
1037 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1042 template <class _Tp, bool = is_reference<_Tp>::value ||
1043 is_function<_Tp>::value ||
1044 is_volatile<_Tp>::value >
1045 struct __add_volatile {typedef _Tp type;};
1047 template <class _Tp>
1048 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1050 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1051 {typedef typename __add_volatile<_Tp>::type type;};
1053 #if _LIBCPP_STD_VER > 11
1054 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1059 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1060 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1062 #if _LIBCPP_STD_VER > 11
1063 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1068 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;};
1069 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;};
1070 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1071 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
1074 #if _LIBCPP_STD_VER > 11
1075 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1078 // add_lvalue_reference
1080 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1081 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1083 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1084 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1086 #if _LIBCPP_STD_VER > 11
1087 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1090 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1092 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1093 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1095 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1096 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1098 #if _LIBCPP_STD_VER > 11
1099 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1102 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1104 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1106 template <class _Tp> _Tp&& __declval(int);
1107 template <class _Tp> _Tp __declval(long);
1109 template <class _Tp>
1110 decltype(_VSTD::__declval<_Tp>(0))
1111 declval() _NOEXCEPT;
1113 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1115 template <class _Tp>
1116 typename add_lvalue_reference<_Tp>::type
1119 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1123 template <class _Tp>
1125 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1128 template <class _Tp>
1129 struct __unconstref {
1130 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1133 #ifndef _LIBCPP_CXX03_LANG
1134 template <class _Tp>
1135 using __uncvref_t = typename __uncvref<_Tp>::type;
1138 // __is_same_uncvref
1140 template <class _Tp, class _Up>
1141 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1142 typename __uncvref<_Up>::type> {};
1151 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;};
1152 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
1153 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
1154 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
1155 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1157 #if _LIBCPP_STD_VER > 11
1158 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1163 template <class _Tp,
1164 bool = __is_referenceable<_Tp>::value ||
1165 is_same<typename remove_cv<_Tp>::type, void>::value>
1166 struct __add_pointer_impl
1167 {typedef typename remove_reference<_Tp>::type* type;};
1168 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1169 {typedef _Tp type;};
1171 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1172 {typedef typename __add_pointer_impl<_Tp>::type type;};
1174 #if _LIBCPP_STD_VER > 11
1175 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1180 template <class _Tp, bool = is_integral<_Tp>::value>
1181 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1183 template <class _Tp>
1184 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1186 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1187 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1189 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1191 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1193 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1194 template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
1195 = is_signed<_Tp>::value;
1200 template <class _Tp, bool = is_integral<_Tp>::value>
1201 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1203 template <class _Tp>
1204 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1206 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1207 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1209 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1211 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1213 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1214 template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
1215 = is_unsigned<_Tp>::value;
1220 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1221 : public integral_constant<size_t, 0> {};
1222 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1223 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1224 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1225 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1227 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1228 template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
1234 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1235 : public integral_constant<size_t, 0> {};
1236 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1237 : public integral_constant<size_t, 0> {};
1238 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1239 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1240 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1241 : public integral_constant<size_t, _Np> {};
1242 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1243 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1245 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1246 template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
1247 = extent<_Tp, _Ip>::value;
1252 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1253 {typedef _Tp type;};
1254 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1255 {typedef _Tp type;};
1256 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1257 {typedef _Tp type;};
1259 #if _LIBCPP_STD_VER > 11
1260 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1263 // remove_all_extents
1265 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1266 {typedef _Tp type;};
1267 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1268 {typedef typename remove_all_extents<_Tp>::type type;};
1269 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1270 {typedef typename remove_all_extents<_Tp>::type type;};
1272 #if _LIBCPP_STD_VER > 11
1273 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1278 template <class _Up, bool>
1280 typedef typename remove_cv<_Up>::type type;
1283 template <class _Up>
1284 struct __decay<_Up, true> {
1286 typedef typename conditional
1288 is_array<_Up>::value,
1289 typename remove_extent<_Up>::type*,
1290 typename conditional
1292 is_function<_Up>::value,
1293 typename add_pointer<_Up>::type,
1294 typename remove_cv<_Up>::type
1299 template <class _Tp>
1300 struct _LIBCPP_TEMPLATE_VIS decay
1303 typedef typename remove_reference<_Tp>::type _Up;
1305 typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1308 #if _LIBCPP_STD_VER > 11
1309 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1314 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1315 : public integral_constant<bool, __is_abstract(_Tp)> {};
1317 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1318 template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
1319 = is_abstract<_Tp>::value;
1324 #if defined(_LIBCPP_HAS_IS_FINAL)
1325 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1326 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1328 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1329 __libcpp_is_final : public false_type {};
1332 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1333 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1334 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1337 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1338 template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
1339 = is_final<_Tp>::value;
1343 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1345 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1346 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1348 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1349 template <class _Tp>
1350 constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
1353 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1357 #ifdef _LIBCPP_HAS_IS_BASE_OF
1359 template <class _Bp, class _Dp>
1360 struct _LIBCPP_TEMPLATE_VIS is_base_of
1361 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1363 #else // _LIBCPP_HAS_IS_BASE_OF
1365 namespace __is_base_of_imp
1367 template <class _Tp>
1370 _Dst(const volatile _Tp &);
1372 template <class _Tp>
1375 operator const volatile _Tp &();
1376 template <class _Up> operator const _Dst<_Up> &();
1378 template <size_t> struct __one { typedef char type; };
1379 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1380 template <class _Bp, class _Dp> __two __test(...);
1383 template <class _Bp, class _Dp>
1384 struct _LIBCPP_TEMPLATE_VIS is_base_of
1385 : public integral_constant<bool, is_class<_Bp>::value &&
1386 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1388 #endif // _LIBCPP_HAS_IS_BASE_OF
1390 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1391 template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
1392 = is_base_of<_Bp, _Dp>::value;
1397 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1399 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1400 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1401 !is_abstract<_T2>::value> {};
1403 #else // __has_feature(is_convertible_to)
1405 namespace __is_convertible_imp
1407 template <class _Tp> void __test_convert(_Tp);
1409 template <class _From, class _To, class = void>
1410 struct __is_convertible_test : public false_type {};
1412 template <class _From, class _To>
1413 struct __is_convertible_test<_From, _To,
1414 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1417 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1418 bool _IsFunction = is_function<_Tp>::value,
1419 bool _IsVoid = is_void<_Tp>::value>
1420 struct __is_array_function_or_void {enum {value = 0};};
1421 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1422 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1423 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1426 template <class _Tp,
1427 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1428 struct __is_convertible_check
1430 static const size_t __v = 0;
1433 template <class _Tp>
1434 struct __is_convertible_check<_Tp, 0>
1436 static const size_t __v = sizeof(_Tp);
1439 template <class _T1, class _T2,
1440 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1441 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1442 struct __is_convertible
1443 : public integral_constant<bool,
1444 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1445 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1446 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1447 && (!is_const<typename remove_reference<_T2>::type>::value
1448 || is_volatile<typename remove_reference<_T2>::type>::value)
1449 && (is_same<typename remove_cv<_T1>::type,
1450 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1451 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1456 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1457 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1458 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1459 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1461 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1462 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1463 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1464 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1466 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1467 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1468 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1469 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1471 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1472 : public __is_convertible<_T1, _T2>
1474 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1475 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1478 #endif // __has_feature(is_convertible_to)
1480 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1481 template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
1482 = is_convertible<_From, _To>::value;
1487 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1489 template <class _Tp>
1490 struct _LIBCPP_TEMPLATE_VIS is_empty
1491 : public integral_constant<bool, __is_empty(_Tp)> {};
1493 #else // __has_feature(is_empty)
1495 template <class _Tp>
1507 template <class _Tp, bool = is_class<_Tp>::value>
1508 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1510 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1512 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1514 #endif // __has_feature(is_empty)
1516 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1517 template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
1518 = is_empty<_Tp>::value;
1523 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1525 template <class _Tp>
1526 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1527 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1531 template<typename _Tp> char &__is_polymorphic_impl(
1532 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1534 template<typename _Tp> __two &__is_polymorphic_impl(...);
1536 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1537 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1539 #endif // __has_feature(is_polymorphic)
1541 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1542 template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
1543 = is_polymorphic<_Tp>::value;
1546 // has_virtual_destructor
1548 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1550 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1551 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1555 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1556 : public false_type {};
1560 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1561 template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1562 = has_virtual_destructor<_Tp>::value;
1567 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1568 : public integral_constant<size_t, __alignof__(_Tp)> {};
1570 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1571 template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
1572 = alignment_of<_Tp>::value;
1577 template <class _Hp, class _Tp>
1586 #ifndef _LIBCPP_CXX03_LANG
1588 __nat(const __nat&) = delete;
1589 __nat& operator=(const __nat&) = delete;
1594 template <class _Tp>
1597 static const size_t value = alignment_of<_Tp>::value;
1601 struct __struct_double {long double __lx;};
1602 struct __struct_double4 {double __lx[4];};
1605 __type_list<__align_type<unsigned char>,
1606 __type_list<__align_type<unsigned short>,
1607 __type_list<__align_type<unsigned int>,
1608 __type_list<__align_type<unsigned long>,
1609 __type_list<__align_type<unsigned long long>,
1610 __type_list<__align_type<double>,
1611 __type_list<__align_type<long double>,
1612 __type_list<__align_type<__struct_double>,
1613 __type_list<__align_type<__struct_double4>,
1614 __type_list<__align_type<int*>,
1616 > > > > > > > > > > __all_types;
1618 template <class _TL, size_t _Align> struct __find_pod;
1620 template <class _Hp, size_t _Align>
1621 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1623 typedef typename conditional<
1624 _Align == _Hp::value,
1630 template <class _Hp, class _Tp, size_t _Align>
1631 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1633 typedef typename conditional<
1634 _Align == _Hp::value,
1636 typename __find_pod<_Tp, _Align>::type
1640 template <class _TL, size_t _Len> struct __find_max_align;
1642 template <class _Hp, size_t _Len>
1643 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1645 template <size_t _Len, size_t _A1, size_t _A2>
1646 struct __select_align
1649 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1650 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1652 static const size_t value = _Len < __max ? __min : __max;
1655 template <class _Hp, class _Tp, size_t _Len>
1656 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1657 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1659 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1660 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1662 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1663 static_assert(!is_void<_Aligner>::value, "");
1667 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1671 #if _LIBCPP_STD_VER > 11
1672 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1673 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1676 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1677 template <size_t _Len>\
1678 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1680 struct _ALIGNAS(n) type\
1682 unsigned char __lx[(_Len + n - 1)/n * n];\
1686 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1687 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1688 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1689 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1690 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1691 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1692 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1693 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1694 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1695 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1696 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1697 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1698 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1699 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1700 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1701 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1702 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1703 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1705 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1707 #ifndef _LIBCPP_HAS_NO_VARIADICS
1711 template <size_t _I0, size_t ..._In>
1712 struct __static_max;
1714 template <size_t _I0>
1715 struct __static_max<_I0>
1717 static const size_t value = _I0;
1720 template <size_t _I0, size_t _I1, size_t ..._In>
1721 struct __static_max<_I0, _I1, _In...>
1723 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1724 __static_max<_I1, _In...>::value;
1727 template <size_t _Len, class _Type0, class ..._Types>
1728 struct aligned_union
1730 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1731 __alignof__(_Types)...>::value;
1732 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1733 sizeof(_Types)...>::value;
1734 typedef typename aligned_storage<__len, alignment_value>::type type;
1737 #if _LIBCPP_STD_VER > 11
1738 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1741 #endif // _LIBCPP_HAS_NO_VARIADICS
1743 template <class _Tp>
1744 struct __numeric_type
1746 static void __test(...);
1747 static float __test(float);
1748 static double __test(char);
1749 static double __test(int);
1750 static double __test(unsigned);
1751 static double __test(long);
1752 static double __test(unsigned long);
1753 static double __test(long long);
1754 static double __test(unsigned long long);
1755 static double __test(double);
1756 static long double __test(long double);
1758 typedef decltype(__test(declval<_Tp>())) type;
1759 static const bool value = !is_same<type, void>::value;
1763 struct __numeric_type<void>
1765 static const bool value = true;
1770 template <class _A1, class _A2 = void, class _A3 = void,
1771 bool = __numeric_type<_A1>::value &&
1772 __numeric_type<_A2>::value &&
1773 __numeric_type<_A3>::value>
1777 static const bool value = false;
1780 template <class _A1, class _A2, class _A3>
1781 class __promote_imp<_A1, _A2, _A3, true>
1784 typedef typename __promote_imp<_A1>::type __type1;
1785 typedef typename __promote_imp<_A2>::type __type2;
1786 typedef typename __promote_imp<_A3>::type __type3;
1788 typedef decltype(__type1() + __type2() + __type3()) type;
1789 static const bool value = true;
1792 template <class _A1, class _A2>
1793 class __promote_imp<_A1, _A2, void, true>
1796 typedef typename __promote_imp<_A1>::type __type1;
1797 typedef typename __promote_imp<_A2>::type __type2;
1799 typedef decltype(__type1() + __type2()) type;
1800 static const bool value = true;
1803 template <class _A1>
1804 class __promote_imp<_A1, void, void, true>
1807 typedef typename __numeric_type<_A1>::type type;
1808 static const bool value = true;
1811 template <class _A1, class _A2 = void, class _A3 = void>
1812 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1814 // make_signed / make_unsigned
1817 __type_list<signed char,
1818 __type_list<signed short,
1819 __type_list<signed int,
1820 __type_list<signed long,
1821 __type_list<signed long long,
1822 #ifndef _LIBCPP_HAS_NO_INT128
1823 __type_list<__int128_t,
1826 #ifndef _LIBCPP_HAS_NO_INT128
1829 > > > > > __signed_types;
1832 __type_list<unsigned char,
1833 __type_list<unsigned short,
1834 __type_list<unsigned int,
1835 __type_list<unsigned long,
1836 __type_list<unsigned long long,
1837 #ifndef _LIBCPP_HAS_NO_INT128
1838 __type_list<__uint128_t,
1841 #ifndef _LIBCPP_HAS_NO_INT128
1844 > > > > > __unsigned_types;
1846 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1848 template <class _Hp, class _Tp, size_t _Size>
1849 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1854 template <class _Hp, class _Tp, size_t _Size>
1855 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1857 typedef typename __find_first<_Tp, _Size>::type type;
1860 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1861 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1867 template <class _Tp, class _Up>
1868 struct __apply_cv<_Tp, _Up, true, false>
1870 typedef const _Up type;
1873 template <class _Tp, class _Up>
1874 struct __apply_cv<_Tp, _Up, false, true>
1876 typedef volatile _Up type;
1879 template <class _Tp, class _Up>
1880 struct __apply_cv<_Tp, _Up, true, true>
1882 typedef const volatile _Up type;
1885 template <class _Tp, class _Up>
1886 struct __apply_cv<_Tp&, _Up, false, false>
1891 template <class _Tp, class _Up>
1892 struct __apply_cv<_Tp&, _Up, true, false>
1894 typedef const _Up& type;
1897 template <class _Tp, class _Up>
1898 struct __apply_cv<_Tp&, _Up, false, true>
1900 typedef volatile _Up& type;
1903 template <class _Tp, class _Up>
1904 struct __apply_cv<_Tp&, _Up, true, true>
1906 typedef const volatile _Up& type;
1909 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1910 struct __make_signed {};
1912 template <class _Tp>
1913 struct __make_signed<_Tp, true>
1915 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1918 template <> struct __make_signed<bool, true> {};
1919 template <> struct __make_signed< signed short, true> {typedef short type;};
1920 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1921 template <> struct __make_signed< signed int, true> {typedef int type;};
1922 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1923 template <> struct __make_signed< signed long, true> {typedef long type;};
1924 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1925 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1926 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1927 #ifndef _LIBCPP_HAS_NO_INT128
1928 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1929 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1932 template <class _Tp>
1933 struct _LIBCPP_TEMPLATE_VIS make_signed
1935 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1938 #if _LIBCPP_STD_VER > 11
1939 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1942 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1943 struct __make_unsigned {};
1945 template <class _Tp>
1946 struct __make_unsigned<_Tp, true>
1948 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1951 template <> struct __make_unsigned<bool, true> {};
1952 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1953 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1954 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1955 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1956 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1957 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1958 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1959 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1960 #ifndef _LIBCPP_HAS_NO_INT128
1961 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1962 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1965 template <class _Tp>
1966 struct _LIBCPP_TEMPLATE_VIS make_unsigned
1968 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1971 #if _LIBCPP_STD_VER > 11
1972 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1975 #ifdef _LIBCPP_HAS_NO_VARIADICS
1977 template <class _Tp, class _Up = void, class _Vp = void>
1978 struct _LIBCPP_TEMPLATE_VIS common_type
1981 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
1985 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void>
1991 template <class _Tp>
1992 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
1995 typedef typename common_type<_Tp, _Tp>::type type;
1998 template <class _Tp, class _Up>
1999 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
2001 typedef typename decay<decltype(
2002 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2006 #else // _LIBCPP_HAS_NO_VARIADICS
2008 // bullet 1 - sizeof...(Tp) == 0
2010 template <class ..._Tp>
2011 struct _LIBCPP_TEMPLATE_VIS common_type {};
2013 // bullet 2 - sizeof...(Tp) == 1
2015 template <class _Tp>
2016 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2017 : public common_type<_Tp, _Tp> {};
2019 // bullet 3 - sizeof...(Tp) == 2
2021 template <class _Tp, class _Up, class = void>
2022 struct __common_type2_imp {};
2024 template <class _Tp, class _Up>
2025 struct __common_type2_imp<_Tp, _Up,
2026 typename __void_t<decltype(
2027 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2030 typedef typename decay<decltype(
2031 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2035 template <class _Tp, class _Up,
2036 class _DTp = typename decay<_Tp>::type,
2037 class _DUp = typename decay<_Up>::type>
2038 using __common_type2 =
2039 typename conditional<
2040 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
2041 __common_type2_imp<_Tp, _Up>,
2042 common_type<_DTp, _DUp>
2045 template <class _Tp, class _Up>
2046 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2047 : __common_type2<_Tp, _Up> {};
2049 // bullet 4 - sizeof...(Tp) > 2
2051 template <class ...Tp> struct __common_types;
2053 template <class, class = void>
2054 struct __common_type_impl {};
2056 template <class _Tp, class _Up>
2057 struct __common_type_impl<
2058 __common_types<_Tp, _Up>,
2059 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2061 typedef typename common_type<_Tp, _Up>::type type;
2064 template <class _Tp, class _Up, class ..._Vp>
2065 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2066 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2067 : __common_type_impl<
2068 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
2073 template <class _Tp, class _Up, class ..._Vp>
2074 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
2075 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2077 #if _LIBCPP_STD_VER > 11
2078 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2081 #endif // _LIBCPP_HAS_NO_VARIADICS
2085 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2087 template <class _Tp, class _Arg>
2088 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2089 __is_assignable_test(int);
2091 template <class, class>
2092 false_type __is_assignable_test(...);
2095 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2096 struct __is_assignable_imp
2097 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2099 template <class _Tp, class _Arg>
2100 struct __is_assignable_imp<_Tp, _Arg, true>
2105 template <class _Tp, class _Arg>
2106 struct is_assignable
2107 : public __is_assignable_imp<_Tp, _Arg> {};
2109 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2110 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
2111 = is_assignable<_Tp, _Arg>::value;
2114 // is_copy_assignable
2116 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2117 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2118 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2120 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2121 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2122 = is_copy_assignable<_Tp>::value;
2125 // is_move_assignable
2127 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2128 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2129 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2130 typename add_rvalue_reference<_Tp>::type> {};
2132 : public is_copy_assignable<_Tp> {};
2135 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2136 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
2137 = is_move_assignable<_Tp>::value;
2142 // if it's a reference, return true
2143 // if it's a function, return false
2144 // if it's void, return false
2145 // if it's an array of unknown bound, return false
2146 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2147 // where _Up is remove_all_extents<_Tp>::type
2150 struct __is_destructible_apply { typedef int type; };
2152 template <typename _Tp>
2153 struct __is_destructor_wellformed {
2154 template <typename _Tp1>
2155 static char __test (
2156 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2159 template <typename _Tp1>
2160 static __two __test (...);
2162 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2165 template <class _Tp, bool>
2166 struct __destructible_imp;
2168 template <class _Tp>
2169 struct __destructible_imp<_Tp, false>
2170 : public _VSTD::integral_constant<bool,
2171 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2173 template <class _Tp>
2174 struct __destructible_imp<_Tp, true>
2175 : public _VSTD::true_type {};
2177 template <class _Tp, bool>
2178 struct __destructible_false;
2180 template <class _Tp>
2181 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2183 template <class _Tp>
2184 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2186 template <class _Tp>
2187 struct is_destructible
2188 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2190 template <class _Tp>
2191 struct is_destructible<_Tp[]>
2192 : public _VSTD::false_type {};
2195 struct is_destructible<void>
2196 : public _VSTD::false_type {};
2198 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2199 template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
2200 = is_destructible<_Tp>::value;
2205 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2207 template <class _Tp>
2208 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2209 typename remove_reference<_Tp>::type&&
2210 move(_Tp&& __t) _NOEXCEPT
2212 typedef typename remove_reference<_Tp>::type _Up;
2213 return static_cast<_Up&&>(__t);
2216 template <class _Tp>
2217 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2219 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2221 return static_cast<_Tp&&>(__t);
2224 template <class _Tp>
2225 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2227 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2229 static_assert(!is_lvalue_reference<_Tp>::value,
2230 "can not forward an rvalue as an lvalue");
2231 return static_cast<_Tp&&>(__t);
2234 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2236 template <class _Tp>
2237 inline _LIBCPP_INLINE_VISIBILITY
2244 template <class _Tp>
2245 inline _LIBCPP_INLINE_VISIBILITY
2247 move(const _Tp& __t)
2252 template <class _Tp>
2253 inline _LIBCPP_INLINE_VISIBILITY
2255 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2261 template <class _Tp>
2264 typedef typename remove_reference<_Tp>::type _Trr;
2267 _LIBCPP_INLINE_VISIBILITY
2268 _Trr* operator->() {return &t_;}
2269 _LIBCPP_INLINE_VISIBILITY
2270 explicit __rv(_Trr& __t) : t_(__t) {}
2273 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2275 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2277 template <class _Tp>
2278 inline _LIBCPP_INLINE_VISIBILITY
2279 typename decay<_Tp>::type
2280 __decay_copy(_Tp&& __t)
2282 return _VSTD::forward<_Tp>(__t);
2287 template <class _Tp>
2288 inline _LIBCPP_INLINE_VISIBILITY
2289 typename decay<_Tp>::type
2290 __decay_copy(const _Tp& __t)
2292 return _VSTD::forward<_Tp>(__t);
2297 #ifndef _LIBCPP_HAS_NO_VARIADICS
2299 template <class _Rp, class _Class, class ..._Param>
2300 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2302 typedef _Class _ClassType;
2303 typedef _Rp _ReturnType;
2304 typedef _Rp (_FnType) (_Param...);
2307 template <class _Rp, class _Class, class ..._Param>
2308 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2310 typedef _Class _ClassType;
2311 typedef _Rp _ReturnType;
2312 typedef _Rp (_FnType) (_Param..., ...);
2315 template <class _Rp, class _Class, class ..._Param>
2316 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2318 typedef _Class const _ClassType;
2319 typedef _Rp _ReturnType;
2320 typedef _Rp (_FnType) (_Param...);
2323 template <class _Rp, class _Class, class ..._Param>
2324 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2326 typedef _Class const _ClassType;
2327 typedef _Rp _ReturnType;
2328 typedef _Rp (_FnType) (_Param..., ...);
2331 template <class _Rp, class _Class, class ..._Param>
2332 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2334 typedef _Class volatile _ClassType;
2335 typedef _Rp _ReturnType;
2336 typedef _Rp (_FnType) (_Param...);
2339 template <class _Rp, class _Class, class ..._Param>
2340 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2342 typedef _Class volatile _ClassType;
2343 typedef _Rp _ReturnType;
2344 typedef _Rp (_FnType) (_Param..., ...);
2347 template <class _Rp, class _Class, class ..._Param>
2348 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2350 typedef _Class const volatile _ClassType;
2351 typedef _Rp _ReturnType;
2352 typedef _Rp (_FnType) (_Param...);
2355 template <class _Rp, class _Class, class ..._Param>
2356 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2358 typedef _Class const volatile _ClassType;
2359 typedef _Rp _ReturnType;
2360 typedef _Rp (_FnType) (_Param..., ...);
2363 #if __has_feature(cxx_reference_qualified_functions) || \
2364 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2366 template <class _Rp, class _Class, class ..._Param>
2367 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2369 typedef _Class& _ClassType;
2370 typedef _Rp _ReturnType;
2371 typedef _Rp (_FnType) (_Param...);
2374 template <class _Rp, class _Class, class ..._Param>
2375 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2377 typedef _Class& _ClassType;
2378 typedef _Rp _ReturnType;
2379 typedef _Rp (_FnType) (_Param..., ...);
2382 template <class _Rp, class _Class, class ..._Param>
2383 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2385 typedef _Class const& _ClassType;
2386 typedef _Rp _ReturnType;
2387 typedef _Rp (_FnType) (_Param...);
2390 template <class _Rp, class _Class, class ..._Param>
2391 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2393 typedef _Class const& _ClassType;
2394 typedef _Rp _ReturnType;
2395 typedef _Rp (_FnType) (_Param..., ...);
2398 template <class _Rp, class _Class, class ..._Param>
2399 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2401 typedef _Class volatile& _ClassType;
2402 typedef _Rp _ReturnType;
2403 typedef _Rp (_FnType) (_Param...);
2406 template <class _Rp, class _Class, class ..._Param>
2407 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2409 typedef _Class volatile& _ClassType;
2410 typedef _Rp _ReturnType;
2411 typedef _Rp (_FnType) (_Param..., ...);
2414 template <class _Rp, class _Class, class ..._Param>
2415 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2417 typedef _Class const volatile& _ClassType;
2418 typedef _Rp _ReturnType;
2419 typedef _Rp (_FnType) (_Param...);
2422 template <class _Rp, class _Class, class ..._Param>
2423 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2425 typedef _Class const volatile& _ClassType;
2426 typedef _Rp _ReturnType;
2427 typedef _Rp (_FnType) (_Param..., ...);
2430 template <class _Rp, class _Class, class ..._Param>
2431 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2433 typedef _Class&& _ClassType;
2434 typedef _Rp _ReturnType;
2435 typedef _Rp (_FnType) (_Param...);
2438 template <class _Rp, class _Class, class ..._Param>
2439 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2441 typedef _Class&& _ClassType;
2442 typedef _Rp _ReturnType;
2443 typedef _Rp (_FnType) (_Param..., ...);
2446 template <class _Rp, class _Class, class ..._Param>
2447 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2449 typedef _Class const&& _ClassType;
2450 typedef _Rp _ReturnType;
2451 typedef _Rp (_FnType) (_Param...);
2454 template <class _Rp, class _Class, class ..._Param>
2455 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2457 typedef _Class const&& _ClassType;
2458 typedef _Rp _ReturnType;
2459 typedef _Rp (_FnType) (_Param..., ...);
2462 template <class _Rp, class _Class, class ..._Param>
2463 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2465 typedef _Class volatile&& _ClassType;
2466 typedef _Rp _ReturnType;
2467 typedef _Rp (_FnType) (_Param...);
2470 template <class _Rp, class _Class, class ..._Param>
2471 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2473 typedef _Class volatile&& _ClassType;
2474 typedef _Rp _ReturnType;
2475 typedef _Rp (_FnType) (_Param..., ...);
2478 template <class _Rp, class _Class, class ..._Param>
2479 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2481 typedef _Class const volatile&& _ClassType;
2482 typedef _Rp _ReturnType;
2483 typedef _Rp (_FnType) (_Param...);
2486 template <class _Rp, class _Class, class ..._Param>
2487 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2489 typedef _Class const volatile&& _ClassType;
2490 typedef _Rp _ReturnType;
2491 typedef _Rp (_FnType) (_Param..., ...);
2494 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2496 #else // _LIBCPP_HAS_NO_VARIADICS
2498 template <class _Rp, class _Class>
2499 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2501 typedef _Class _ClassType;
2502 typedef _Rp _ReturnType;
2503 typedef _Rp (_FnType) ();
2506 template <class _Rp, class _Class>
2507 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2509 typedef _Class _ClassType;
2510 typedef _Rp _ReturnType;
2511 typedef _Rp (_FnType) (...);
2514 template <class _Rp, class _Class, class _P0>
2515 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2517 typedef _Class _ClassType;
2518 typedef _Rp _ReturnType;
2519 typedef _Rp (_FnType) (_P0);
2522 template <class _Rp, class _Class, class _P0>
2523 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2525 typedef _Class _ClassType;
2526 typedef _Rp _ReturnType;
2527 typedef _Rp (_FnType) (_P0, ...);
2530 template <class _Rp, class _Class, class _P0, class _P1>
2531 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2533 typedef _Class _ClassType;
2534 typedef _Rp _ReturnType;
2535 typedef _Rp (_FnType) (_P0, _P1);
2538 template <class _Rp, class _Class, class _P0, class _P1>
2539 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2541 typedef _Class _ClassType;
2542 typedef _Rp _ReturnType;
2543 typedef _Rp (_FnType) (_P0, _P1, ...);
2546 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2547 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2549 typedef _Class _ClassType;
2550 typedef _Rp _ReturnType;
2551 typedef _Rp (_FnType) (_P0, _P1, _P2);
2554 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2555 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2557 typedef _Class _ClassType;
2558 typedef _Rp _ReturnType;
2559 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2562 template <class _Rp, class _Class>
2563 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2565 typedef _Class const _ClassType;
2566 typedef _Rp _ReturnType;
2567 typedef _Rp (_FnType) ();
2570 template <class _Rp, class _Class>
2571 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2573 typedef _Class const _ClassType;
2574 typedef _Rp _ReturnType;
2575 typedef _Rp (_FnType) (...);
2578 template <class _Rp, class _Class, class _P0>
2579 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2581 typedef _Class const _ClassType;
2582 typedef _Rp _ReturnType;
2583 typedef _Rp (_FnType) (_P0);
2586 template <class _Rp, class _Class, class _P0>
2587 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2589 typedef _Class const _ClassType;
2590 typedef _Rp _ReturnType;
2591 typedef _Rp (_FnType) (_P0, ...);
2594 template <class _Rp, class _Class, class _P0, class _P1>
2595 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2597 typedef _Class const _ClassType;
2598 typedef _Rp _ReturnType;
2599 typedef _Rp (_FnType) (_P0, _P1);
2602 template <class _Rp, class _Class, class _P0, class _P1>
2603 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2605 typedef _Class const _ClassType;
2606 typedef _Rp _ReturnType;
2607 typedef _Rp (_FnType) (_P0, _P1, ...);
2610 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2611 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2613 typedef _Class const _ClassType;
2614 typedef _Rp _ReturnType;
2615 typedef _Rp (_FnType) (_P0, _P1, _P2);
2618 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2619 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2621 typedef _Class const _ClassType;
2622 typedef _Rp _ReturnType;
2623 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2626 template <class _Rp, class _Class>
2627 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2629 typedef _Class volatile _ClassType;
2630 typedef _Rp _ReturnType;
2631 typedef _Rp (_FnType) ();
2634 template <class _Rp, class _Class>
2635 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2637 typedef _Class volatile _ClassType;
2638 typedef _Rp _ReturnType;
2639 typedef _Rp (_FnType) (...);
2642 template <class _Rp, class _Class, class _P0>
2643 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2645 typedef _Class volatile _ClassType;
2646 typedef _Rp _ReturnType;
2647 typedef _Rp (_FnType) (_P0);
2650 template <class _Rp, class _Class, class _P0>
2651 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2653 typedef _Class volatile _ClassType;
2654 typedef _Rp _ReturnType;
2655 typedef _Rp (_FnType) (_P0, ...);
2658 template <class _Rp, class _Class, class _P0, class _P1>
2659 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2661 typedef _Class volatile _ClassType;
2662 typedef _Rp _ReturnType;
2663 typedef _Rp (_FnType) (_P0, _P1);
2666 template <class _Rp, class _Class, class _P0, class _P1>
2667 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2669 typedef _Class volatile _ClassType;
2670 typedef _Rp _ReturnType;
2671 typedef _Rp (_FnType) (_P0, _P1, ...);
2674 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2675 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2677 typedef _Class volatile _ClassType;
2678 typedef _Rp _ReturnType;
2679 typedef _Rp (_FnType) (_P0, _P1, _P2);
2682 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2683 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2685 typedef _Class volatile _ClassType;
2686 typedef _Rp _ReturnType;
2687 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2690 template <class _Rp, class _Class>
2691 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2693 typedef _Class const volatile _ClassType;
2694 typedef _Rp _ReturnType;
2695 typedef _Rp (_FnType) ();
2698 template <class _Rp, class _Class>
2699 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2701 typedef _Class const volatile _ClassType;
2702 typedef _Rp _ReturnType;
2703 typedef _Rp (_FnType) (...);
2706 template <class _Rp, class _Class, class _P0>
2707 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2709 typedef _Class const volatile _ClassType;
2710 typedef _Rp _ReturnType;
2711 typedef _Rp (_FnType) (_P0);
2714 template <class _Rp, class _Class, class _P0>
2715 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2717 typedef _Class const volatile _ClassType;
2718 typedef _Rp _ReturnType;
2719 typedef _Rp (_FnType) (_P0, ...);
2722 template <class _Rp, class _Class, class _P0, class _P1>
2723 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2725 typedef _Class const volatile _ClassType;
2726 typedef _Rp _ReturnType;
2727 typedef _Rp (_FnType) (_P0, _P1);
2730 template <class _Rp, class _Class, class _P0, class _P1>
2731 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2733 typedef _Class const volatile _ClassType;
2734 typedef _Rp _ReturnType;
2735 typedef _Rp (_FnType) (_P0, _P1, ...);
2738 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2739 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2741 typedef _Class const volatile _ClassType;
2742 typedef _Rp _ReturnType;
2743 typedef _Rp (_FnType) (_P0, _P1, _P2);
2746 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2747 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2749 typedef _Class const volatile _ClassType;
2750 typedef _Rp _ReturnType;
2751 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2754 #endif // _LIBCPP_HAS_NO_VARIADICS
2756 template <class _Rp, class _Class>
2757 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2759 typedef _Class _ClassType;
2760 typedef _Rp _ReturnType;
2763 template <class _MP>
2764 struct __member_pointer_traits
2765 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2766 is_member_function_pointer<_MP>::value,
2767 is_member_object_pointer<_MP>::value>
2769 // typedef ... _ClassType;
2770 // typedef ... _ReturnType;
2771 // typedef ... _FnType;
2775 template <class _DecayedFp>
2776 struct __member_pointer_class_type {};
2778 template <class _Ret, class _ClassType>
2779 struct __member_pointer_class_type<_Ret _ClassType::*> {
2780 typedef _ClassType type;
2785 template <class _Callable> class result_of;
2787 #ifdef _LIBCPP_HAS_NO_VARIADICS
2789 template <class _Fn, bool, bool>
2794 template <class _Fn>
2795 class __result_of<_Fn(), true, false>
2798 typedef decltype(declval<_Fn>()()) type;
2801 template <class _Fn, class _A0>
2802 class __result_of<_Fn(_A0), true, false>
2805 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2808 template <class _Fn, class _A0, class _A1>
2809 class __result_of<_Fn(_A0, _A1), true, false>
2812 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2815 template <class _Fn, class _A0, class _A1, class _A2>
2816 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2819 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2822 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2823 struct __result_of_mp;
2825 // member function pointer
2827 template <class _MP, class _Tp>
2828 struct __result_of_mp<_MP, _Tp, true>
2829 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2833 // member data pointer
2835 template <class _MP, class _Tp, bool>
2836 struct __result_of_mdp;
2838 template <class _Rp, class _Class, class _Tp>
2839 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2841 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2844 template <class _Rp, class _Class, class _Tp>
2845 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2847 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2850 template <class _Rp, class _Class, class _Tp>
2851 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2852 : public __result_of_mdp<_Rp _Class::*, _Tp,
2853 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2859 template <class _Fn, class _Tp>
2860 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2861 : public __result_of_mp<typename remove_reference<_Fn>::type,
2863 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2867 template <class _Fn, class _Tp, class _A0>
2868 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2869 : public __result_of_mp<typename remove_reference<_Fn>::type,
2871 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2875 template <class _Fn, class _Tp, class _A0, class _A1>
2876 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2877 : public __result_of_mp<typename remove_reference<_Fn>::type,
2879 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2883 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2884 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2885 : public __result_of_mp<typename remove_reference<_Fn>::type,
2887 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2893 template <class _Fn>
2894 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2895 : public __result_of<_Fn(),
2896 is_class<typename remove_reference<_Fn>::type>::value ||
2897 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2898 is_member_pointer<typename remove_reference<_Fn>::type>::value
2903 template <class _Fn, class _A0>
2904 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2905 : public __result_of<_Fn(_A0),
2906 is_class<typename remove_reference<_Fn>::type>::value ||
2907 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2908 is_member_pointer<typename remove_reference<_Fn>::type>::value
2913 template <class _Fn, class _A0, class _A1>
2914 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2915 : public __result_of<_Fn(_A0, _A1),
2916 is_class<typename remove_reference<_Fn>::type>::value ||
2917 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2918 is_member_pointer<typename remove_reference<_Fn>::type>::value
2923 template <class _Fn, class _A0, class _A1, class _A2>
2924 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
2925 : public __result_of<_Fn(_A0, _A1, _A2),
2926 is_class<typename remove_reference<_Fn>::type>::value ||
2927 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2928 is_member_pointer<typename remove_reference<_Fn>::type>::value
2933 #endif // _LIBCPP_HAS_NO_VARIADICS
2935 // template <class T, class... Args> struct is_constructible;
2937 namespace __is_construct
2942 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
2943 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
2945 template <class _Tp, class... _Args>
2946 struct __libcpp_is_constructible;
2948 template <class _To, class _From>
2949 struct __is_invalid_base_to_derived_cast {
2950 static_assert(is_reference<_To>::value, "Wrong specialization");
2951 using _RawFrom = __uncvref_t<_From>;
2952 using _RawTo = __uncvref_t<_To>;
2953 static const bool value = __lazy_and<
2954 __lazy_not<is_same<_RawFrom, _RawTo>>,
2955 is_base_of<_RawFrom, _RawTo>,
2956 __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
2960 template <class _To, class _From>
2961 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
2962 static_assert(is_reference<_To>::value, "Wrong specialization");
2965 template <class _ToRef, class _FromRef>
2966 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
2967 using _RawFrom = __uncvref_t<_FromRef>;
2968 using _RawTo = __uncvref_t<_ToRef>;
2969 static const bool value = __lazy_and<
2970 __lazy_not<is_function<_RawTo>>,
2972 is_same<_RawFrom, _RawTo>,
2973 is_base_of<_RawTo, _RawFrom>>
2977 struct __is_constructible_helper
2979 template <class _To>
2980 static void __eat(_To);
2982 // This overload is needed to work around a Clang bug that disallows
2983 // static_cast<T&&>(e) for non-reference-compatible types.
2984 // Example: static_cast<int&&>(declval<double>());
2985 // NOTE: The static_cast implementation below is required to support
2986 // classes with explicit conversion operators.
2987 template <class _To, class _From,
2988 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
2989 static true_type __test_cast(int);
2991 template <class _To, class _From,
2992 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
2993 static integral_constant<bool,
2994 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
2995 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
2996 > __test_cast(long);
2998 template <class, class>
2999 static false_type __test_cast(...);
3001 template <class _Tp, class ..._Args,
3002 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
3003 static true_type __test_nary(int);
3004 template <class _Tp, class...>
3005 static false_type __test_nary(...);
3007 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
3008 static is_destructible<_Tp> __test_unary(int);
3009 template <class, class>
3010 static false_type __test_unary(...);
3013 template <class _Tp, bool = is_void<_Tp>::value>
3014 struct __is_default_constructible
3015 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
3018 template <class _Tp>
3019 struct __is_default_constructible<_Tp, true> : false_type {};
3021 template <class _Tp>
3022 struct __is_default_constructible<_Tp[], false> : false_type {};
3024 template <class _Tp, size_t _Nx>
3025 struct __is_default_constructible<_Tp[_Nx], false>
3026 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3028 template <class _Tp, class... _Args>
3029 struct __libcpp_is_constructible
3031 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3032 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3036 template <class _Tp>
3037 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3039 template <class _Tp, class _A0>
3040 struct __libcpp_is_constructible<_Tp, _A0>
3041 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3044 template <class _Tp, class _A0>
3045 struct __libcpp_is_constructible<_Tp&, _A0>
3046 : public decltype(__is_constructible_helper::
3047 __test_cast<_Tp&, _A0>(0))
3050 template <class _Tp, class _A0>
3051 struct __libcpp_is_constructible<_Tp&&, _A0>
3052 : public decltype(__is_constructible_helper::
3053 __test_cast<_Tp&&, _A0>(0))
3058 #if __has_feature(is_constructible)
3059 template <class _Tp, class ..._Args>
3060 struct _LIBCPP_TEMPLATE_VIS is_constructible
3061 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3063 #elif !defined(_LIBCPP_CXX03_LANG)
3064 template <class _Tp, class... _Args>
3065 struct _LIBCPP_TEMPLATE_VIS is_constructible
3066 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3068 // template <class T> struct is_constructible0;
3070 // main is_constructible0 test
3072 template <class _Tp>
3073 decltype((_Tp(), true_type()))
3074 __is_constructible0_test(_Tp&);
3077 __is_constructible0_test(__any);
3079 template <class _Tp, class _A0>
3080 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3081 __is_constructible1_test(_Tp&, _A0&);
3083 template <class _A0>
3085 __is_constructible1_test(__any, _A0&);
3087 template <class _Tp, class _A0, class _A1>
3088 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3089 __is_constructible2_test(_Tp&, _A0&, _A1&);
3091 template <class _A0, class _A1>
3093 __is_constructible2_test(__any, _A0&, _A1&);
3095 template <bool, class _Tp>
3096 struct __is_constructible0_imp // false, _Tp is not a scalar
3097 : public common_type
3099 decltype(__is_constructible0_test(declval<_Tp&>()))
3103 template <bool, class _Tp, class _A0>
3104 struct __is_constructible1_imp // false, _Tp is not a scalar
3105 : public common_type
3107 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3111 template <bool, class _Tp, class _A0, class _A1>
3112 struct __is_constructible2_imp // false, _Tp is not a scalar
3113 : public common_type
3115 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3119 // handle scalars and reference types
3121 // Scalars are default constructible, references are not
3123 template <class _Tp>
3124 struct __is_constructible0_imp<true, _Tp>
3125 : public is_scalar<_Tp>
3128 template <class _Tp, class _A0>
3129 struct __is_constructible1_imp<true, _Tp, _A0>
3130 : public is_convertible<_A0, _Tp>
3133 template <class _Tp, class _A0, class _A1>
3134 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3138 // Treat scalars and reference types separately
3140 template <bool, class _Tp>
3141 struct __is_constructible0_void_check
3142 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3146 template <bool, class _Tp, class _A0>
3147 struct __is_constructible1_void_check
3148 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3152 template <bool, class _Tp, class _A0, class _A1>
3153 struct __is_constructible2_void_check
3154 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3158 // If any of T or Args is void, is_constructible should be false
3160 template <class _Tp>
3161 struct __is_constructible0_void_check<true, _Tp>
3165 template <class _Tp, class _A0>
3166 struct __is_constructible1_void_check<true, _Tp, _A0>
3170 template <class _Tp, class _A0, class _A1>
3171 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3175 // is_constructible entry point
3177 template <class _Tp, class _A0 = __is_construct::__nat,
3178 class _A1 = __is_construct::__nat>
3179 struct _LIBCPP_TEMPLATE_VIS is_constructible
3180 : public __is_constructible2_void_check<is_void<_Tp>::value
3181 || is_abstract<_Tp>::value
3182 || is_function<_Tp>::value
3183 || is_void<_A0>::value
3184 || is_void<_A1>::value,
3188 template <class _Tp>
3189 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3190 : public __is_constructible0_void_check<is_void<_Tp>::value
3191 || is_abstract<_Tp>::value
3192 || is_function<_Tp>::value,
3196 template <class _Tp, class _A0>
3197 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
3198 : public __is_constructible1_void_check<is_void<_Tp>::value
3199 || is_abstract<_Tp>::value
3200 || is_function<_Tp>::value
3201 || is_void<_A0>::value,
3205 // Array types are default constructible if their element type
3206 // is default constructible
3208 template <class _Ap, size_t _Np>
3209 struct __is_constructible0_imp<false, _Ap[_Np]>
3210 : public is_constructible<typename remove_all_extents<_Ap>::type>
3213 template <class _Ap, size_t _Np, class _A0>
3214 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3218 template <class _Ap, size_t _Np, class _A0, class _A1>
3219 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3223 // Incomplete array types are not constructible
3225 template <class _Ap>
3226 struct __is_constructible0_imp<false, _Ap[]>
3230 template <class _Ap, class _A0>
3231 struct __is_constructible1_imp<false, _Ap[], _A0>
3235 template <class _Ap, class _A0, class _A1>
3236 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3240 #endif // __has_feature(is_constructible)
3243 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3244 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
3245 = is_constructible<_Tp, _Args...>::value;
3248 // is_default_constructible
3250 template <class _Tp>
3251 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3252 : public is_constructible<_Tp>
3255 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3256 template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
3257 = is_default_constructible<_Tp>::value;
3260 // is_copy_constructible
3262 template <class _Tp>
3263 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3264 : public is_constructible<_Tp,
3265 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3267 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3268 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3269 = is_copy_constructible<_Tp>::value;
3272 // is_move_constructible
3274 template <class _Tp>
3275 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3276 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3277 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3279 : public is_copy_constructible<_Tp>
3283 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3284 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
3285 = is_move_constructible<_Tp>::value;
3288 // is_trivially_constructible
3290 #ifndef _LIBCPP_HAS_NO_VARIADICS
3292 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3294 template <class _Tp, class... _Args>
3295 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3296 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3300 #else // !__has_feature(is_trivially_constructible)
3302 template <class _Tp, class... _Args>
3303 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3308 template <class _Tp>
3309 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3310 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3311 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3313 : integral_constant<bool, is_scalar<_Tp>::value>
3318 template <class _Tp>
3319 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3320 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3322 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
3324 : integral_constant<bool, is_scalar<_Tp>::value>
3328 template <class _Tp>
3329 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3330 : integral_constant<bool, is_scalar<_Tp>::value>
3334 template <class _Tp>
3335 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3336 : integral_constant<bool, is_scalar<_Tp>::value>
3340 #endif // !__has_feature(is_trivially_constructible)
3342 #else // _LIBCPP_HAS_NO_VARIADICS
3344 template <class _Tp, class _A0 = __is_construct::__nat,
3345 class _A1 = __is_construct::__nat>
3346 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3351 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3353 template <class _Tp>
3354 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3355 __is_construct::__nat>
3356 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3360 template <class _Tp>
3361 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3362 __is_construct::__nat>
3363 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3367 template <class _Tp>
3368 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3369 __is_construct::__nat>
3370 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3374 template <class _Tp>
3375 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3376 __is_construct::__nat>
3377 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3381 #else // !__has_feature(is_trivially_constructible)
3383 template <class _Tp>
3384 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3385 __is_construct::__nat>
3386 : integral_constant<bool, is_scalar<_Tp>::value>
3390 template <class _Tp>
3391 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3392 __is_construct::__nat>
3393 : integral_constant<bool, is_scalar<_Tp>::value>
3397 template <class _Tp>
3398 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3399 __is_construct::__nat>
3400 : integral_constant<bool, is_scalar<_Tp>::value>
3404 template <class _Tp>
3405 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3406 __is_construct::__nat>
3407 : integral_constant<bool, is_scalar<_Tp>::value>
3411 #endif // !__has_feature(is_trivially_constructible)
3413 #endif // _LIBCPP_HAS_NO_VARIADICS
3415 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3416 template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3417 = is_trivially_constructible<_Tp, _Args...>::value;
3420 // is_trivially_default_constructible
3422 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3423 : public is_trivially_constructible<_Tp>
3426 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3427 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3428 = is_trivially_default_constructible<_Tp>::value;
3431 // is_trivially_copy_constructible
3433 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3434 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3437 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3438 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3439 = is_trivially_copy_constructible<_Tp>::value;
3442 // is_trivially_move_constructible
3444 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3445 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3446 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3448 : public is_trivially_copy_constructible<_Tp>
3452 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3453 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3454 = is_trivially_move_constructible<_Tp>::value;
3457 // is_trivially_assignable
3459 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3461 template <class _Tp, class _Arg>
3462 struct is_trivially_assignable
3463 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3467 #else // !__has_feature(is_trivially_assignable)
3469 template <class _Tp, class _Arg>
3470 struct is_trivially_assignable
3471 : public false_type {};
3473 template <class _Tp>
3474 struct is_trivially_assignable<_Tp&, _Tp>
3475 : integral_constant<bool, is_scalar<_Tp>::value> {};
3477 template <class _Tp>
3478 struct is_trivially_assignable<_Tp&, _Tp&>
3479 : integral_constant<bool, is_scalar<_Tp>::value> {};
3481 template <class _Tp>
3482 struct is_trivially_assignable<_Tp&, const _Tp&>
3483 : integral_constant<bool, is_scalar<_Tp>::value> {};
3485 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3487 template <class _Tp>
3488 struct is_trivially_assignable<_Tp&, _Tp&&>
3489 : integral_constant<bool, is_scalar<_Tp>::value> {};
3491 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3493 #endif // !__has_feature(is_trivially_assignable)
3495 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3496 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3497 = is_trivially_assignable<_Tp, _Arg>::value;
3500 // is_trivially_copy_assignable
3502 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3503 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3504 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3506 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3507 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3508 = is_trivially_copy_assignable<_Tp>::value;
3511 // is_trivially_move_assignable
3513 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3514 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3515 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3516 typename add_rvalue_reference<_Tp>::type>
3518 typename add_lvalue_reference<_Tp>::type>
3522 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3523 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3524 = is_trivially_move_assignable<_Tp>::value;
3527 // is_trivially_destructible
3529 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3531 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3532 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3536 template <class _Tp> struct __libcpp_trivial_destructor
3537 : public integral_constant<bool, is_scalar<_Tp>::value ||
3538 is_reference<_Tp>::value> {};
3540 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3541 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3543 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3544 : public false_type {};
3548 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3549 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3550 = is_trivially_destructible<_Tp>::value;
3553 // is_nothrow_constructible
3556 template <class _Tp, class... _Args>
3557 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3558 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3564 #ifndef _LIBCPP_HAS_NO_VARIADICS
3566 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3568 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3570 template <class _Tp, class... _Args>
3571 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3572 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3576 template <class _Tp>
3577 void __implicit_conversion_to(_Tp) noexcept { }
3579 template <class _Tp, class _Arg>
3580 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3581 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3585 template <class _Tp, bool _IsReference, class... _Args>
3586 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3591 template <class _Tp, class... _Args>
3592 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3593 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3597 template <class _Tp, size_t _Ns>
3598 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3599 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3603 #else // __has_feature(cxx_noexcept)
3605 template <class _Tp, class... _Args>
3606 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3611 template <class _Tp>
3612 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
3613 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3614 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3616 : integral_constant<bool, is_scalar<_Tp>::value>
3621 template <class _Tp>
3622 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3623 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
3625 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
3627 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3628 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3630 : integral_constant<bool, is_scalar<_Tp>::value>
3635 template <class _Tp>
3636 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
3637 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3638 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3640 : integral_constant<bool, is_scalar<_Tp>::value>
3645 template <class _Tp>
3646 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
3647 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3648 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3650 : integral_constant<bool, is_scalar<_Tp>::value>
3655 #endif // __has_feature(cxx_noexcept)
3657 #else // _LIBCPP_HAS_NO_VARIADICS
3659 template <class _Tp, class _A0 = __is_construct::__nat,
3660 class _A1 = __is_construct::__nat>
3661 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3666 template <class _Tp>
3667 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
3668 __is_construct::__nat>
3669 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3670 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3672 : integral_constant<bool, is_scalar<_Tp>::value>
3677 template <class _Tp>
3678 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
3679 __is_construct::__nat>
3680 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3681 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3683 : integral_constant<bool, is_scalar<_Tp>::value>
3688 template <class _Tp>
3689 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
3690 __is_construct::__nat>
3691 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3692 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3694 : integral_constant<bool, is_scalar<_Tp>::value>
3699 template <class _Tp>
3700 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
3701 __is_construct::__nat>
3702 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3703 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3705 : integral_constant<bool, is_scalar<_Tp>::value>
3710 #endif // _LIBCPP_HAS_NO_VARIADICS
3711 #endif // __has_feature(is_nothrow_constructible)
3713 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3714 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3715 = is_nothrow_constructible<_Tp, _Args...>::value;
3718 // is_nothrow_default_constructible
3720 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3721 : public is_nothrow_constructible<_Tp>
3724 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3725 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3726 = is_nothrow_default_constructible<_Tp>::value;
3729 // is_nothrow_copy_constructible
3731 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3732 : public is_nothrow_constructible<_Tp,
3733 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3735 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3736 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3737 = is_nothrow_copy_constructible<_Tp>::value;
3740 // is_nothrow_move_constructible
3742 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3743 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3744 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3746 : public is_nothrow_copy_constructible<_Tp>
3750 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3751 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3752 = is_nothrow_move_constructible<_Tp>::value;
3755 // is_nothrow_assignable
3757 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3759 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3761 template <class _Tp, class _Arg>
3762 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3767 template <class _Tp, class _Arg>
3768 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3769 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3773 template <class _Tp, class _Arg>
3774 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3775 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3779 #else // __has_feature(cxx_noexcept)
3781 template <class _Tp, class _Arg>
3782 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3783 : public false_type {};
3785 template <class _Tp>
3786 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
3787 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3788 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3790 : integral_constant<bool, is_scalar<_Tp>::value> {};
3793 template <class _Tp>
3794 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
3795 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3796 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3798 : integral_constant<bool, is_scalar<_Tp>::value> {};
3801 template <class _Tp>
3802 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
3803 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3804 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3806 : integral_constant<bool, is_scalar<_Tp>::value> {};
3809 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3811 template <class _Tp>
3812 struct is_nothrow_assignable<_Tp&, _Tp&&>
3813 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3814 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3816 : integral_constant<bool, is_scalar<_Tp>::value> {};
3819 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3821 #endif // __has_feature(cxx_noexcept)
3823 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3824 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3825 = is_nothrow_assignable<_Tp, _Arg>::value;
3828 // is_nothrow_copy_assignable
3830 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3831 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3832 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3834 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3835 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3836 = is_nothrow_copy_assignable<_Tp>::value;
3839 // is_nothrow_move_assignable
3841 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3842 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3843 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3844 typename add_rvalue_reference<_Tp>::type>
3846 typename add_lvalue_reference<_Tp>::type>
3850 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3851 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3852 = is_nothrow_move_assignable<_Tp>::value;
3855 // is_nothrow_destructible
3857 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3859 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3861 template <class _Tp>
3862 struct __libcpp_is_nothrow_destructible<false, _Tp>
3867 template <class _Tp>
3868 struct __libcpp_is_nothrow_destructible<true, _Tp>
3869 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3873 template <class _Tp>
3874 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3875 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3879 template <class _Tp, size_t _Ns>
3880 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3881 : public is_nothrow_destructible<_Tp>
3885 template <class _Tp>
3886 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3891 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3893 template <class _Tp>
3894 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3903 template <class _Tp> struct __libcpp_nothrow_destructor
3904 : public integral_constant<bool, is_scalar<_Tp>::value ||
3905 is_reference<_Tp>::value> {};
3907 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3908 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3910 template <class _Tp>
3911 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3912 : public false_type {};
3916 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3917 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3918 = is_nothrow_destructible<_Tp>::value;
3923 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
3925 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3926 : public integral_constant<bool, __is_pod(_Tp)> {};
3930 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3931 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3932 is_trivially_copy_constructible<_Tp>::value &&
3933 is_trivially_copy_assignable<_Tp>::value &&
3934 is_trivially_destructible<_Tp>::value> {};
3938 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3939 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
3940 = is_pod<_Tp>::value;
3945 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
3946 #ifdef _LIBCPP_IS_LITERAL
3947 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3949 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3950 is_reference<typename remove_all_extents<_Tp>::type>::value>
3954 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3955 template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
3956 = is_literal_type<_Tp>::value;
3959 // is_standard_layout;
3961 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3962 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3963 : public integral_constant<bool, __is_standard_layout(_Tp)>
3965 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3969 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3970 template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
3971 = is_standard_layout<_Tp>::value;
3974 // is_trivially_copyable;
3976 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3977 #if __has_feature(is_trivially_copyable)
3978 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3979 #elif _GNUC_VER >= 501
3980 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3982 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3986 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3987 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3988 = is_trivially_copyable<_Tp>::value;
3993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3994 #if __has_feature(is_trivial) || _GNUC_VER >= 407
3995 : public integral_constant<bool, __is_trivial(_Tp)>
3997 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3998 is_trivially_default_constructible<_Tp>::value>
4002 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4003 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
4004 = is_trivial<_Tp>::value;
4007 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
4008 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
4009 template <class _Tp> struct __is_reference_wrapper
4010 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
4012 #ifndef _LIBCPP_CXX03_LANG
4014 // Check for complete types
4016 template <class ..._Tp> struct __check_complete;
4019 struct __check_complete<>
4023 template <class _Hp, class _T0, class ..._Tp>
4024 struct __check_complete<_Hp, _T0, _Tp...>
4025 : private __check_complete<_Hp>,
4026 private __check_complete<_T0, _Tp...>
4030 template <class _Hp>
4031 struct __check_complete<_Hp, _Hp>
4032 : private __check_complete<_Hp>
4036 template <class _Tp>
4037 struct __check_complete<_Tp>
4039 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
4042 template <class _Tp>
4043 struct __check_complete<_Tp&>
4044 : private __check_complete<_Tp>
4048 template <class _Tp>
4049 struct __check_complete<_Tp&&>
4050 : private __check_complete<_Tp>
4054 template <class _Rp, class ..._Param>
4055 struct __check_complete<_Rp (*)(_Param...)>
4056 : private __check_complete<_Rp>
4060 template <class ..._Param>
4061 struct __check_complete<void (*)(_Param...)>
4065 template <class _Rp, class ..._Param>
4066 struct __check_complete<_Rp (_Param...)>
4067 : private __check_complete<_Rp>
4071 template <class ..._Param>
4072 struct __check_complete<void (_Param...)>
4076 template <class _Rp, class _Class, class ..._Param>
4077 struct __check_complete<_Rp (_Class::*)(_Param...)>
4078 : private __check_complete<_Class>
4082 template <class _Rp, class _Class, class ..._Param>
4083 struct __check_complete<_Rp (_Class::*)(_Param...) const>
4084 : private __check_complete<_Class>
4088 template <class _Rp, class _Class, class ..._Param>
4089 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
4090 : private __check_complete<_Class>
4094 template <class _Rp, class _Class, class ..._Param>
4095 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
4096 : private __check_complete<_Class>
4100 template <class _Rp, class _Class, class ..._Param>
4101 struct __check_complete<_Rp (_Class::*)(_Param...) &>
4102 : private __check_complete<_Class>
4106 template <class _Rp, class _Class, class ..._Param>
4107 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
4108 : private __check_complete<_Class>
4112 template <class _Rp, class _Class, class ..._Param>
4113 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
4114 : private __check_complete<_Class>
4118 template <class _Rp, class _Class, class ..._Param>
4119 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
4120 : private __check_complete<_Class>
4124 template <class _Rp, class _Class, class ..._Param>
4125 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
4126 : private __check_complete<_Class>
4130 template <class _Rp, class _Class, class ..._Param>
4131 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
4132 : private __check_complete<_Class>
4136 template <class _Rp, class _Class, class ..._Param>
4137 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
4138 : private __check_complete<_Class>
4142 template <class _Rp, class _Class, class ..._Param>
4143 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
4144 : private __check_complete<_Class>
4148 template <class _Rp, class _Class>
4149 struct __check_complete<_Rp _Class::*>
4150 : private __check_complete<_Class>
4155 template <class _Fp, class _A0,
4156 class _DecayFp = typename decay<_Fp>::type,
4157 class _DecayA0 = typename decay<_A0>::type,
4158 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4159 using __enable_if_bullet1 = typename enable_if
4161 is_member_function_pointer<_DecayFp>::value
4162 && is_base_of<_ClassT, _DecayA0>::value
4165 template <class _Fp, class _A0,
4166 class _DecayFp = typename decay<_Fp>::type,
4167 class _DecayA0 = typename decay<_A0>::type>
4168 using __enable_if_bullet2 = typename enable_if
4170 is_member_function_pointer<_DecayFp>::value
4171 && __is_reference_wrapper<_DecayA0>::value
4174 template <class _Fp, class _A0,
4175 class _DecayFp = typename decay<_Fp>::type,
4176 class _DecayA0 = typename decay<_A0>::type,
4177 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4178 using __enable_if_bullet3 = typename enable_if
4180 is_member_function_pointer<_DecayFp>::value
4181 && !is_base_of<_ClassT, _DecayA0>::value
4182 && !__is_reference_wrapper<_DecayA0>::value
4185 template <class _Fp, class _A0,
4186 class _DecayFp = typename decay<_Fp>::type,
4187 class _DecayA0 = typename decay<_A0>::type,
4188 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4189 using __enable_if_bullet4 = typename enable_if
4191 is_member_object_pointer<_DecayFp>::value
4192 && is_base_of<_ClassT, _DecayA0>::value
4195 template <class _Fp, class _A0,
4196 class _DecayFp = typename decay<_Fp>::type,
4197 class _DecayA0 = typename decay<_A0>::type>
4198 using __enable_if_bullet5 = typename enable_if
4200 is_member_object_pointer<_DecayFp>::value
4201 && __is_reference_wrapper<_DecayA0>::value
4204 template <class _Fp, class _A0,
4205 class _DecayFp = typename decay<_Fp>::type,
4206 class _DecayA0 = typename decay<_A0>::type,
4207 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4208 using __enable_if_bullet6 = typename enable_if
4210 is_member_object_pointer<_DecayFp>::value
4211 && !is_base_of<_ClassT, _DecayA0>::value
4212 && !__is_reference_wrapper<_DecayA0>::value
4215 // __invoke forward declarations
4217 // fall back - none of the bullets
4219 #define _LIBCPP_INVOKE_RETURN(...) \
4220 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4221 { return __VA_ARGS__; }
4223 template <class ..._Args>
4224 auto __invoke(__any, _Args&& ...__args) -> __nat;
4226 template <class ..._Args>
4227 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4229 // bullets 1, 2 and 3
4231 template <class _Fp, class _A0, class ..._Args,
4232 class = __enable_if_bullet1<_Fp, _A0>>
4233 inline _LIBCPP_INLINE_VISIBILITY
4235 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4236 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4238 template <class _Fp, class _A0, class ..._Args,
4239 class = __enable_if_bullet1<_Fp, _A0>>
4240 inline _LIBCPP_INLINE_VISIBILITY
4241 _LIBCPP_CONSTEXPR auto
4242 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4243 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4245 template <class _Fp, class _A0, class ..._Args,
4246 class = __enable_if_bullet2<_Fp, _A0>>
4247 inline _LIBCPP_INLINE_VISIBILITY
4249 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4250 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4252 template <class _Fp, class _A0, class ..._Args,
4253 class = __enable_if_bullet2<_Fp, _A0>>
4254 inline _LIBCPP_INLINE_VISIBILITY
4255 _LIBCPP_CONSTEXPR auto
4256 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4257 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4259 template <class _Fp, class _A0, class ..._Args,
4260 class = __enable_if_bullet3<_Fp, _A0>>
4261 inline _LIBCPP_INLINE_VISIBILITY
4263 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4264 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4266 template <class _Fp, class _A0, class ..._Args,
4267 class = __enable_if_bullet3<_Fp, _A0>>
4268 inline _LIBCPP_INLINE_VISIBILITY
4269 _LIBCPP_CONSTEXPR auto
4270 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4271 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4273 // bullets 4, 5 and 6
4275 template <class _Fp, class _A0,
4276 class = __enable_if_bullet4<_Fp, _A0>>
4277 inline _LIBCPP_INLINE_VISIBILITY
4279 __invoke(_Fp&& __f, _A0&& __a0)
4280 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4282 template <class _Fp, class _A0,
4283 class = __enable_if_bullet4<_Fp, _A0>>
4284 inline _LIBCPP_INLINE_VISIBILITY
4285 _LIBCPP_CONSTEXPR auto
4286 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4287 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4289 template <class _Fp, class _A0,
4290 class = __enable_if_bullet5<_Fp, _A0>>
4291 inline _LIBCPP_INLINE_VISIBILITY
4293 __invoke(_Fp&& __f, _A0&& __a0)
4294 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4296 template <class _Fp, class _A0,
4297 class = __enable_if_bullet5<_Fp, _A0>>
4298 inline _LIBCPP_INLINE_VISIBILITY
4299 _LIBCPP_CONSTEXPR auto
4300 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4301 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4303 template <class _Fp, class _A0,
4304 class = __enable_if_bullet6<_Fp, _A0>>
4305 inline _LIBCPP_INLINE_VISIBILITY
4307 __invoke(_Fp&& __f, _A0&& __a0)
4308 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4310 template <class _Fp, class _A0,
4311 class = __enable_if_bullet6<_Fp, _A0>>
4312 inline _LIBCPP_INLINE_VISIBILITY
4313 _LIBCPP_CONSTEXPR auto
4314 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4315 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4319 template <class _Fp, class ..._Args>
4320 inline _LIBCPP_INLINE_VISIBILITY
4322 __invoke(_Fp&& __f, _Args&& ...__args)
4323 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4325 template <class _Fp, class ..._Args>
4326 inline _LIBCPP_INLINE_VISIBILITY
4327 _LIBCPP_CONSTEXPR auto
4328 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4329 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4331 #undef _LIBCPP_INVOKE_RETURN
4335 template <class _Ret, class _Fp, class ..._Args>
4336 struct __invokable_r
4337 : private __check_complete<_Fp>
4339 using _Result = decltype(
4340 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4342 static const bool value =
4344 !is_same<_Result, __nat>::value,
4345 typename conditional<
4346 is_void<_Ret>::value,
4348 is_convertible<_Result, _Ret>
4354 template <class _Fp, class ..._Args>
4355 using __invokable = __invokable_r<void, _Fp, _Args...>;
4357 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4358 struct __nothrow_invokable_r_imp {
4359 static const bool value = false;
4362 template <class _Ret, class _Fp, class ..._Args>
4363 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4365 typedef __nothrow_invokable_r_imp _ThisT;
4367 template <class _Tp>
4368 static void __test_noexcept(_Tp) noexcept;
4370 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4371 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4374 template <class _Ret, class _Fp, class ..._Args>
4375 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4377 static const bool value = noexcept(
4378 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4381 template <class _Ret, class _Fp, class ..._Args>
4382 using __nothrow_invokable_r =
4383 __nothrow_invokable_r_imp<
4384 __invokable_r<_Ret, _Fp, _Args...>::value,
4385 is_void<_Ret>::value,
4389 template <class _Fp, class ..._Args>
4392 __invokable<_Fp, _Args...>::value,
4393 typename __invokable_r<void, _Fp, _Args...>::_Result>
4399 template <class _Fp, class ..._Args>
4400 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
4401 : public __invoke_of<_Fp, _Args...>
4405 #if _LIBCPP_STD_VER > 11
4406 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4409 #if _LIBCPP_STD_VER > 14
4413 template <class _Fn, class _Ret = void>
4414 struct _LIBCPP_TEMPLATE_VIS is_callable;
4416 template <class _Fn, class ..._Args, class _Ret>
4417 struct _LIBCPP_TEMPLATE_VIS is_callable<_Fn(_Args...), _Ret>
4418 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4420 template <class _Fn, class _Ret = void>
4421 constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
4423 // is_nothrow_callable
4425 template <class _Fn, class _Ret = void>
4426 struct _LIBCPP_TEMPLATE_VIS is_nothrow_callable;
4428 template <class _Fn, class ..._Args, class _Ret>
4429 struct _LIBCPP_TEMPLATE_VIS is_nothrow_callable<_Fn(_Args...), _Ret>
4430 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
4433 template <class _Fn, class _Ret = void>
4434 constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
4436 #endif // _LIBCPP_STD_VER > 14
4438 #endif // !defined(_LIBCPP_CXX03_LANG)
4440 template <class _Tp> struct __is_swappable;
4441 template <class _Tp> struct __is_nothrow_swappable;
4443 template <class _Tp>
4444 inline _LIBCPP_INLINE_VISIBILITY
4445 #ifndef _LIBCPP_CXX03_LANG
4448 is_move_constructible<_Tp>::value &&
4449 is_move_assignable<_Tp>::value
4454 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4455 is_nothrow_move_assignable<_Tp>::value)
4457 _Tp __t(_VSTD::move(__x));
4458 __x = _VSTD::move(__y);
4459 __y = _VSTD::move(__t);
4462 template<class _Tp, size_t _Np>
4463 inline _LIBCPP_INLINE_VISIBILITY
4465 __is_swappable<_Tp>::value
4467 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4469 template <class _ForwardIterator1, class _ForwardIterator2>
4470 inline _LIBCPP_INLINE_VISIBILITY
4472 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4473 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4474 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4475 *_VSTD::declval<_ForwardIterator2>())))
4484 // ALL generic swap overloads MUST already have a declaration available at this point.
4486 template <class _Tp, class _Up = _Tp,
4487 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4488 struct __swappable_with
4490 template <class _LHS, class _RHS>
4491 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4493 template <class, class>
4494 static __nat __test_swap(long);
4496 // Extra parens are needed for the C++03 definition of decltype.
4497 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4498 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4500 static const bool value = !is_same<__swap1, __nat>::value
4501 && !is_same<__swap2, __nat>::value;
4504 template <class _Tp, class _Up>
4505 struct __swappable_with<_Tp, _Up, false> : false_type {};
4507 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4508 struct __nothrow_swappable_with {
4509 static const bool value =
4510 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4511 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4512 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4518 template <class _Tp, class _Up>
4519 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4523 template <class _Tp>
4524 struct __is_swappable
4525 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4529 template <class _Tp>
4530 struct __is_nothrow_swappable
4531 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4535 #if _LIBCPP_STD_VER > 14
4537 template <class _Tp, class _Up>
4538 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4539 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4543 template <class _Tp>
4544 struct _LIBCPP_TEMPLATE_VIS is_swappable
4545 : public conditional<
4546 __is_referenceable<_Tp>::value,
4548 typename add_lvalue_reference<_Tp>::type,
4549 typename add_lvalue_reference<_Tp>::type>,
4555 template <class _Tp, class _Up>
4556 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4557 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4561 template <class _Tp>
4562 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4563 : public conditional<
4564 __is_referenceable<_Tp>::value,
4565 is_nothrow_swappable_with<
4566 typename add_lvalue_reference<_Tp>::type,
4567 typename add_lvalue_reference<_Tp>::type>,
4573 template <class _Tp, class _Up>
4574 constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
4576 template <class _Tp>
4577 constexpr bool is_swappable_v = is_swappable<_Tp>::value;
4579 template <class _Tp, class _Up>
4580 constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
4582 template <class _Tp>
4583 constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
4585 #endif // _LIBCPP_STD_VER > 14
4587 #ifdef _LIBCPP_UNDERLYING_TYPE
4589 template <class _Tp>
4590 struct underlying_type
4592 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4595 #if _LIBCPP_STD_VER > 11
4596 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4599 #else // _LIBCPP_UNDERLYING_TYPE
4601 template <class _Tp, bool _Support = false>
4602 struct underlying_type
4604 static_assert(_Support, "The underyling_type trait requires compiler "
4605 "support. Either no such support exists or "
4606 "libc++ does not know how to use it.");
4609 #endif // _LIBCPP_UNDERLYING_TYPE
4612 template <class _Tp, bool = is_enum<_Tp>::value>
4613 struct __sfinae_underlying_type
4615 typedef typename underlying_type<_Tp>::type type;
4616 typedef decltype(((type)1) + 0) __promoted_type;
4619 template <class _Tp>
4620 struct __sfinae_underlying_type<_Tp, false> {};
4622 inline _LIBCPP_INLINE_VISIBILITY
4623 int __convert_to_integral(int __val) { return __val; }
4625 inline _LIBCPP_INLINE_VISIBILITY
4626 unsigned __convert_to_integral(unsigned __val) { return __val; }
4628 inline _LIBCPP_INLINE_VISIBILITY
4629 long __convert_to_integral(long __val) { return __val; }
4631 inline _LIBCPP_INLINE_VISIBILITY
4632 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4634 inline _LIBCPP_INLINE_VISIBILITY
4635 long long __convert_to_integral(long long __val) { return __val; }
4637 inline _LIBCPP_INLINE_VISIBILITY
4638 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4640 #ifndef _LIBCPP_HAS_NO_INT128
4641 inline _LIBCPP_INLINE_VISIBILITY
4642 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4644 inline _LIBCPP_INLINE_VISIBILITY
4645 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4648 template <class _Tp>
4649 inline _LIBCPP_INLINE_VISIBILITY
4650 typename __sfinae_underlying_type<_Tp>::__promoted_type
4651 __convert_to_integral(_Tp __val) { return __val; }
4653 #ifndef _LIBCPP_CXX03_LANG
4655 template <class _Tp>
4656 struct __has_operator_addressof_member_imp
4658 template <class _Up>
4659 static auto __test(int)
4660 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4662 static auto __test(long) -> false_type;
4664 static const bool value = decltype(__test<_Tp>(0))::value;
4667 template <class _Tp>
4668 struct __has_operator_addressof_free_imp
4670 template <class _Up>
4671 static auto __test(int)
4672 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4674 static auto __test(long) -> false_type;
4676 static const bool value = decltype(__test<_Tp>(0))::value;
4679 template <class _Tp>
4680 struct __has_operator_addressof
4681 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4682 || __has_operator_addressof_free_imp<_Tp>::value>
4685 #endif // _LIBCPP_CXX03_LANG
4687 #if _LIBCPP_STD_VER > 14
4689 #define __cpp_lib_void_t 201411
4690 template <class...> using void_t = void;
4692 # ifndef _LIBCPP_HAS_NO_VARIADICS
4693 template <class... _Args>
4694 struct conjunction : __and_<_Args...> {};
4695 template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
4697 template <class... _Args>
4698 struct disjunction : __or_<_Args...> {};
4699 template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
4701 template <class _Tp>
4702 struct negation : __not_<_Tp> {};
4703 template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
4704 # endif // _LIBCPP_HAS_NO_VARIADICS
4705 #endif // _LIBCPP_STD_VER > 14
4707 // These traits are used in __tree and __hash_table
4708 #ifndef _LIBCPP_CXX03_LANG
4709 struct __extract_key_fail_tag {};
4710 struct __extract_key_self_tag {};
4711 struct __extract_key_first_tag {};
4713 template <class _ValTy, class _Key,
4714 class _RawValTy = typename __unconstref<_ValTy>::type>
4715 struct __can_extract_key
4716 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4717 __extract_key_fail_tag>::type {};
4719 template <class _Pair, class _Key, class _First, class _Second>
4720 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4721 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4722 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4724 // __can_extract_map_key uses true_type/false_type instead of the tags.
4725 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4726 // and _ValTy == _Key.
4727 template <class _ValTy, class _Key, class _ContainerValueTy,
4728 class _RawValTy = typename __unconstref<_ValTy>::type>
4729 struct __can_extract_map_key
4730 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4732 // This specialization returns __extract_key_fail_tag for non-map containers
4733 // because _Key == _ContainerValueTy
4734 template <class _ValTy, class _Key, class _RawValTy>
4735 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4740 _LIBCPP_END_NAMESPACE_STD
4742 #if _LIBCPP_STD_VER > 14
4744 namespace std // purposefully not versioned
4746 template <class _Integer>
4747 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4748 operator<<=(byte& __lhs, _Integer __shift) noexcept
4749 { return __lhs = byte(static_cast<unsigned char>(__lhs) << __shift); }
4751 template <class _Integer>
4752 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4753 operator<< (byte __lhs, _Integer __shift) noexcept
4754 { return byte(static_cast<unsigned char>(__lhs) << __shift); }
4756 template <class _Integer>
4757 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4758 operator>>=(byte& __lhs, _Integer __shift) noexcept
4759 { return __lhs = byte(static_cast<unsigned char>(__lhs) >> __shift); }
4761 template <class _Integer>
4762 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4763 operator>> (byte __lhs, _Integer __shift) noexcept
4764 { return byte(static_cast<unsigned char>(__lhs) >> __shift); }
4766 template <class _Integer>
4767 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4768 to_integer(byte __b) noexcept { return _Integer(__b); }
4773 #endif // _LIBCPP_TYPE_TRAITS