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 template<class T> struct type_identity; // C++20
80 using type_identity_t = typename type_identity<T>::type; // C++20
82 // Integral properties:
83 template <class T> struct is_signed;
84 template <class T> struct is_unsigned;
85 template <class T> struct make_signed;
86 template <class T> struct make_unsigned;
88 // Array properties and transformations:
89 template <class T> struct rank;
90 template <class T, unsigned I = 0> struct extent;
91 template <class T> struct remove_extent;
92 template <class T> struct remove_all_extents;
94 // Member introspection:
95 template <class T> struct is_pod;
96 template <class T> struct is_trivial;
97 template <class T> struct is_trivially_copyable;
98 template <class T> struct is_standard_layout;
99 template <class T> struct is_literal_type;
100 template <class T> struct is_empty;
101 template <class T> struct is_polymorphic;
102 template <class T> struct is_abstract;
103 template <class T> struct is_final; // C++14
104 template <class T> struct is_aggregate; // C++17
106 template <class T, class... Args> struct is_constructible;
107 template <class T> struct is_default_constructible;
108 template <class T> struct is_copy_constructible;
109 template <class T> struct is_move_constructible;
110 template <class T, class U> struct is_assignable;
111 template <class T> struct is_copy_assignable;
112 template <class T> struct is_move_assignable;
113 template <class T, class U> struct is_swappable_with; // C++17
114 template <class T> struct is_swappable; // C++17
115 template <class T> struct is_destructible;
117 template <class T, class... Args> struct is_trivially_constructible;
118 template <class T> struct is_trivially_default_constructible;
119 template <class T> struct is_trivially_copy_constructible;
120 template <class T> struct is_trivially_move_constructible;
121 template <class T, class U> struct is_trivially_assignable;
122 template <class T> struct is_trivially_copy_assignable;
123 template <class T> struct is_trivially_move_assignable;
124 template <class T> struct is_trivially_destructible;
126 template <class T, class... Args> struct is_nothrow_constructible;
127 template <class T> struct is_nothrow_default_constructible;
128 template <class T> struct is_nothrow_copy_constructible;
129 template <class T> struct is_nothrow_move_constructible;
130 template <class T, class U> struct is_nothrow_assignable;
131 template <class T> struct is_nothrow_copy_assignable;
132 template <class T> struct is_nothrow_move_assignable;
133 template <class T, class U> struct is_nothrow_swappable_with; // C++17
134 template <class T> struct is_nothrow_swappable; // C++17
135 template <class T> struct is_nothrow_destructible;
137 template <class T> struct has_virtual_destructor;
139 template<class T> struct has_unique_object_representations; // C++17
141 // Relationships between types:
142 template <class T, class U> struct is_same;
143 template <class Base, class Derived> struct is_base_of;
144 template <class From, class To> struct is_convertible;
146 template <class Fn, class... ArgTypes> struct is_invocable;
147 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
149 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
150 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
152 // Alignment properties and transformations:
153 template <class T> struct alignment_of;
154 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
155 struct aligned_storage;
156 template <size_t Len, class... Types> struct aligned_union;
157 template <class T> struct remove_cvref; // C++20
159 template <class T> struct decay;
160 template <class... T> struct common_type;
161 template <class T> struct underlying_type;
162 template <class> class result_of; // undefined
163 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
164 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
166 // const-volatile modifications:
168 using remove_const_t = typename remove_const<T>::type; // C++14
170 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
172 using remove_cv_t = typename remove_cv<T>::type; // C++14
174 using add_const_t = typename add_const<T>::type; // C++14
176 using add_volatile_t = typename add_volatile<T>::type; // C++14
178 using add_cv_t = typename add_cv<T>::type; // C++14
180 // reference modifications:
182 using remove_reference_t = typename remove_reference<T>::type; // C++14
184 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
186 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
188 // sign modifications:
190 using make_signed_t = typename make_signed<T>::type; // C++14
192 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
194 // array modifications:
196 using remove_extent_t = typename remove_extent<T>::type; // C++14
198 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
200 // pointer modifications:
202 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
204 using add_pointer_t = typename add_pointer<T>::type; // C++14
206 // other transformations:
207 template <size_t Len, std::size_t Align=default-alignment>
208 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
209 template <std::size_t Len, class... Types>
210 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
212 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
214 using decay_t = typename decay<T>::type; // C++14
215 template <bool b, class T=void>
216 using enable_if_t = typename enable_if<b,T>::type; // C++14
217 template <bool b, class T, class F>
218 using conditional_t = typename conditional<b,T,F>::type; // C++14
219 template <class... T>
220 using common_type_t = typename common_type<T...>::type; // C++14
222 using underlying_type_t = typename underlying_type<T>::type; // C++14
224 using result_of_t = typename result_of<T>::type; // C++14
225 template <class Fn, class... ArgTypes>
226 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
229 using void_t = void; // C++17
231 // See C++14 20.10.4.1, primary type categories
232 template <class T> inline constexpr bool is_void_v
233 = is_void<T>::value; // C++17
234 template <class T> inline constexpr bool is_null_pointer_v
235 = is_null_pointer<T>::value; // C++17
236 template <class T> inline constexpr bool is_integral_v
237 = is_integral<T>::value; // C++17
238 template <class T> inline constexpr bool is_floating_point_v
239 = is_floating_point<T>::value; // C++17
240 template <class T> inline constexpr bool is_array_v
241 = is_array<T>::value; // C++17
242 template <class T> inline constexpr bool is_pointer_v
243 = is_pointer<T>::value; // C++17
244 template <class T> inline constexpr bool is_lvalue_reference_v
245 = is_lvalue_reference<T>::value; // C++17
246 template <class T> inline constexpr bool is_rvalue_reference_v
247 = is_rvalue_reference<T>::value; // C++17
248 template <class T> inline constexpr bool is_member_object_pointer_v
249 = is_member_object_pointer<T>::value; // C++17
250 template <class T> inline constexpr bool is_member_function_pointer_v
251 = is_member_function_pointer<T>::value; // C++17
252 template <class T> inline constexpr bool is_enum_v
253 = is_enum<T>::value; // C++17
254 template <class T> inline constexpr bool is_union_v
255 = is_union<T>::value; // C++17
256 template <class T> inline constexpr bool is_class_v
257 = is_class<T>::value; // C++17
258 template <class T> inline constexpr bool is_function_v
259 = is_function<T>::value; // C++17
261 // See C++14 20.10.4.2, composite type categories
262 template <class T> inline constexpr bool is_reference_v
263 = is_reference<T>::value; // C++17
264 template <class T> inline constexpr bool is_arithmetic_v
265 = is_arithmetic<T>::value; // C++17
266 template <class T> inline constexpr bool is_fundamental_v
267 = is_fundamental<T>::value; // C++17
268 template <class T> inline constexpr bool is_object_v
269 = is_object<T>::value; // C++17
270 template <class T> inline constexpr bool is_scalar_v
271 = is_scalar<T>::value; // C++17
272 template <class T> inline constexpr bool is_compound_v
273 = is_compound<T>::value; // C++17
274 template <class T> inline constexpr bool is_member_pointer_v
275 = is_member_pointer<T>::value; // C++17
277 // See C++14 20.10.4.3, type properties
278 template <class T> inline constexpr bool is_const_v
279 = is_const<T>::value; // C++17
280 template <class T> inline constexpr bool is_volatile_v
281 = is_volatile<T>::value; // C++17
282 template <class T> inline constexpr bool is_trivial_v
283 = is_trivial<T>::value; // C++17
284 template <class T> inline constexpr bool is_trivially_copyable_v
285 = is_trivially_copyable<T>::value; // C++17
286 template <class T> inline constexpr bool is_standard_layout_v
287 = is_standard_layout<T>::value; // C++17
288 template <class T> inline constexpr bool is_pod_v
289 = is_pod<T>::value; // C++17
290 template <class T> inline constexpr bool is_literal_type_v
291 = is_literal_type<T>::value; // C++17
292 template <class T> inline constexpr bool is_empty_v
293 = is_empty<T>::value; // C++17
294 template <class T> inline constexpr bool is_polymorphic_v
295 = is_polymorphic<T>::value; // C++17
296 template <class T> inline constexpr bool is_abstract_v
297 = is_abstract<T>::value; // C++17
298 template <class T> inline constexpr bool is_final_v
299 = is_final<T>::value; // C++17
300 template <class T> inline constexpr bool is_aggregate_v
301 = is_aggregate<T>::value; // C++17
302 template <class T> inline constexpr bool is_signed_v
303 = is_signed<T>::value; // C++17
304 template <class T> inline constexpr bool is_unsigned_v
305 = is_unsigned<T>::value; // C++17
306 template <class T, class... Args> inline constexpr bool is_constructible_v
307 = is_constructible<T, Args...>::value; // C++17
308 template <class T> inline constexpr bool is_default_constructible_v
309 = is_default_constructible<T>::value; // C++17
310 template <class T> inline constexpr bool is_copy_constructible_v
311 = is_copy_constructible<T>::value; // C++17
312 template <class T> inline constexpr bool is_move_constructible_v
313 = is_move_constructible<T>::value; // C++17
314 template <class T, class U> inline constexpr bool is_assignable_v
315 = is_assignable<T, U>::value; // C++17
316 template <class T> inline constexpr bool is_copy_assignable_v
317 = is_copy_assignable<T>::value; // C++17
318 template <class T> inline constexpr bool is_move_assignable_v
319 = is_move_assignable<T>::value; // C++17
320 template <class T, class U> inline constexpr bool is_swappable_with_v
321 = is_swappable_with<T, U>::value; // C++17
322 template <class T> inline constexpr bool is_swappable_v
323 = is_swappable<T>::value; // C++17
324 template <class T> inline constexpr bool is_destructible_v
325 = is_destructible<T>::value; // C++17
326 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
327 = is_trivially_constructible<T, Args...>::value; // C++17
328 template <class T> inline constexpr bool is_trivially_default_constructible_v
329 = is_trivially_default_constructible<T>::value; // C++17
330 template <class T> inline constexpr bool is_trivially_copy_constructible_v
331 = is_trivially_copy_constructible<T>::value; // C++17
332 template <class T> inline constexpr bool is_trivially_move_constructible_v
333 = is_trivially_move_constructible<T>::value; // C++17
334 template <class T, class U> inline constexpr bool is_trivially_assignable_v
335 = is_trivially_assignable<T, U>::value; // C++17
336 template <class T> inline constexpr bool is_trivially_copy_assignable_v
337 = is_trivially_copy_assignable<T>::value; // C++17
338 template <class T> inline constexpr bool is_trivially_move_assignable_v
339 = is_trivially_move_assignable<T>::value; // C++17
340 template <class T> inline constexpr bool is_trivially_destructible_v
341 = is_trivially_destructible<T>::value; // C++17
342 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
343 = is_nothrow_constructible<T, Args...>::value; // C++17
344 template <class T> inline constexpr bool is_nothrow_default_constructible_v
345 = is_nothrow_default_constructible<T>::value; // C++17
346 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
347 = is_nothrow_copy_constructible<T>::value; // C++17
348 template <class T> inline constexpr bool is_nothrow_move_constructible_v
349 = is_nothrow_move_constructible<T>::value; // C++17
350 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
351 = is_nothrow_assignable<T, U>::value; // C++17
352 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
353 = is_nothrow_copy_assignable<T>::value; // C++17
354 template <class T> inline constexpr bool is_nothrow_move_assignable_v
355 = is_nothrow_move_assignable<T>::value; // C++17
356 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
357 = is_nothrow_swappable_with<T, U>::value; // C++17
358 template <class T> inline constexpr bool is_nothrow_swappable_v
359 = is_nothrow_swappable<T>::value; // C++17
360 template <class T> inline constexpr bool is_nothrow_destructible_v
361 = is_nothrow_destructible<T>::value; // C++17
362 template <class T> inline constexpr bool has_virtual_destructor_v
363 = has_virtual_destructor<T>::value; // C++17
364 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
365 = has_unique_object_representations<T>::value;
367 // See C++14 20.10.5, type property queries
368 template <class T> inline constexpr size_t alignment_of_v
369 = alignment_of<T>::value; // C++17
370 template <class T> inline constexpr size_t rank_v
371 = rank<T>::value; // C++17
372 template <class T, unsigned I = 0> inline constexpr size_t extent_v
373 = extent<T, I>::value; // C++17
375 // See C++14 20.10.6, type relations
376 template <class T, class U> inline constexpr bool is_same_v
377 = is_same<T, U>::value; // C++17
378 template <class Base, class Derived> inline constexpr bool is_base_of_v
379 = is_base_of<Base, Derived>::value; // C++17
380 template <class From, class To> inline constexpr bool is_convertible_v
381 = is_convertible<From, To>::value; // C++17
382 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
383 = is_invocable<Fn, ArgTypes...>::value; // C++17
384 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
385 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
386 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
387 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
388 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
389 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
391 // [meta.logical], logical operator traits:
392 template<class... B> struct conjunction; // C++17
394 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
395 template<class... B> struct disjunction; // C++17
397 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
398 template<class B> struct negation; // C++17
400 inline constexpr bool negation_v = negation<B>::value; // C++17
409 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
410 #pragma GCC system_header
413 _LIBCPP_BEGIN_NAMESPACE_STD
415 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
416 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
417 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
420 struct __void_t { typedef void type; };
423 struct __identity { typedef _Tp type; };
425 template <class _Tp, bool>
426 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
428 template <bool _Bp, class _If, class _Then>
429 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
430 template <class _If, class _Then>
431 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
433 #if _LIBCPP_STD_VER > 11
434 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
437 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {};
438 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
440 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
441 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
443 #if _LIBCPP_STD_VER > 11
444 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
448 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
451 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
452 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
454 addressof(_Tp& __x) _NOEXCEPT
456 return __builtin_addressof(__x);
462 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
464 addressof(_Tp& __x) _NOEXCEPT
466 return reinterpret_cast<_Tp *>(
467 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
470 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
472 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
473 // Objective-C++ Automatic Reference Counting uses qualified pointers
474 // that require special addressof() signatures. When
475 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
476 // itself is providing these definitions. Otherwise, we provide them.
478 inline _LIBCPP_INLINE_VISIBILITY
480 addressof(__strong _Tp& __x) _NOEXCEPT
485 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
487 inline _LIBCPP_INLINE_VISIBILITY
489 addressof(__weak _Tp& __x) _NOEXCEPT
496 inline _LIBCPP_INLINE_VISIBILITY
498 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
504 inline _LIBCPP_INLINE_VISIBILITY
505 __unsafe_unretained _Tp*
506 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
512 #if !defined(_LIBCPP_CXX03_LANG)
513 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
516 struct __two {char __lx[2];};
520 template <class _Tp, _Tp __v>
521 struct _LIBCPP_TEMPLATE_VIS integral_constant
523 static _LIBCPP_CONSTEXPR const _Tp value = __v;
524 typedef _Tp value_type;
525 typedef integral_constant type;
526 _LIBCPP_INLINE_VISIBILITY
527 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
528 #if _LIBCPP_STD_VER > 11
529 _LIBCPP_INLINE_VISIBILITY
530 constexpr value_type operator ()() const _NOEXCEPT {return value;}
534 template <class _Tp, _Tp __v>
535 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
537 #if _LIBCPP_STD_VER > 14
539 using bool_constant = integral_constant<bool, __b>;
540 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
542 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
545 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
546 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
548 #if !defined(_LIBCPP_CXX03_LANG)
552 template <bool _Last, class ..._Preds>
553 struct __lazy_and_impl;
555 template <class ..._Preds>
556 struct __lazy_and_impl<false, _Preds...> : false_type {};
559 struct __lazy_and_impl<true> : true_type {};
561 template <class _Pred>
562 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
564 template <class _Hp, class ..._Tp>
565 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
567 template <class _P1, class ..._Pr>
568 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
572 template <bool _List, class ..._Preds>
573 struct __lazy_or_impl;
575 template <class ..._Preds>
576 struct __lazy_or_impl<true, _Preds...> : true_type {};
579 struct __lazy_or_impl<false> : false_type {};
581 template <class _Hp, class ..._Tp>
582 struct __lazy_or_impl<false, _Hp, _Tp...>
583 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
585 template <class _P1, class ..._Pr>
586 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
590 template <class _Pred>
591 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
594 template<class...> struct __and_;
595 template<> struct __and_<> : true_type {};
597 template<class _B0> struct __and_<_B0> : _B0 {};
599 template<class _B0, class _B1>
600 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
602 template<class _B0, class _B1, class _B2, class... _Bn>
603 struct __and_<_B0, _B1, _B2, _Bn...>
604 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
607 template<class...> struct __or_;
608 template<> struct __or_<> : false_type {};
610 template<class _B0> struct __or_<_B0> : _B0 {};
612 template<class _B0, class _B1>
613 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
615 template<class _B0, class _B1, class _B2, class... _Bn>
616 struct __or_<_B0, _B1, _B2, _Bn...>
617 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
621 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
623 #endif // !defined(_LIBCPP_CXX03_LANG)
627 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
628 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
630 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
632 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
633 = is_const<_Tp>::value;
638 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
639 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
641 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
643 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
644 = is_volatile<_Tp>::value;
649 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
650 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
651 #if _LIBCPP_STD_VER > 11
652 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
657 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
658 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
659 #if _LIBCPP_STD_VER > 11
660 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
665 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
666 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
667 #if _LIBCPP_STD_VER > 11
668 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
673 template <class _Tp> struct __libcpp_is_void : public false_type {};
674 template <> struct __libcpp_is_void<void> : public true_type {};
676 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
677 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
679 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
681 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
682 = is_void<_Tp>::value;
687 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
688 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
690 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
691 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
693 #if _LIBCPP_STD_VER > 11
694 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
695 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
697 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
699 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
700 = is_null_pointer<_Tp>::value;
706 template <class _Tp> struct __libcpp_is_integral : public false_type {};
707 template <> struct __libcpp_is_integral<bool> : public true_type {};
708 template <> struct __libcpp_is_integral<char> : public true_type {};
709 template <> struct __libcpp_is_integral<signed char> : public true_type {};
710 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
711 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
712 #ifndef _LIBCPP_NO_HAS_CHAR8_T
713 template <> struct __libcpp_is_integral<char8_t> : public true_type {};
715 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
716 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
717 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
718 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
719 template <> struct __libcpp_is_integral<short> : public true_type {};
720 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
721 template <> struct __libcpp_is_integral<int> : public true_type {};
722 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
723 template <> struct __libcpp_is_integral<long> : public true_type {};
724 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
725 template <> struct __libcpp_is_integral<long long> : public true_type {};
726 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
727 #ifndef _LIBCPP_HAS_NO_INT128
728 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
729 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
732 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
733 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
735 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
737 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
738 = is_integral<_Tp>::value;
743 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
744 template <> struct __libcpp_is_floating_point<float> : public true_type {};
745 template <> struct __libcpp_is_floating_point<double> : public true_type {};
746 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
748 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
749 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
751 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
753 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
754 = is_floating_point<_Tp>::value;
759 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
760 : public false_type {};
761 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
762 : public true_type {};
763 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
764 : public true_type {};
766 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
768 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
769 = is_array<_Tp>::value;
774 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
775 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
777 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
778 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
780 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
782 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
783 = is_pointer<_Tp>::value;
788 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
789 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
792 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
793 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
796 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
797 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
798 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
799 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
802 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
804 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
805 = is_reference<_Tp>::value;
808 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
809 = is_lvalue_reference<_Tp>::value;
812 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
813 = is_rvalue_reference<_Tp>::value;
817 #if __has_feature(is_union) || (_GNUC_VER >= 403)
819 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
820 : public integral_constant<bool, __is_union(_Tp)> {};
824 template <class _Tp> struct __libcpp_union : public false_type {};
825 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
826 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
830 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
832 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
833 = is_union<_Tp>::value;
838 #if __has_feature(is_class) || (_GNUC_VER >= 403)
840 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
841 : public integral_constant<bool, __is_class(_Tp)> {};
845 namespace __is_class_imp
847 template <class _Tp> char __test(int _Tp::*);
848 template <class _Tp> __two __test(...);
851 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
852 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
856 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
858 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
859 = is_class<_Tp>::value;
864 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
865 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
867 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
868 template <class _Tp, class _Up>
869 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
870 = is_same<_Tp, _Up>::value;
875 namespace __libcpp_is_function_imp
877 struct __dummy_type {};
878 template <class _Tp> char __test(_Tp*);
879 template <class _Tp> char __test(__dummy_type);
880 template <class _Tp> __two __test(...);
881 template <class _Tp> _Tp& __source(int);
882 template <class _Tp> __dummy_type __source(...);
885 template <class _Tp, bool = is_class<_Tp>::value ||
886 is_union<_Tp>::value ||
887 is_void<_Tp>::value ||
888 is_reference<_Tp>::value ||
889 __is_nullptr_t<_Tp>::value >
890 struct __libcpp_is_function
891 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
893 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
895 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
896 : public __libcpp_is_function<_Tp> {};
898 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
900 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
901 = is_function<_Tp>::value;
904 // is_member_function_pointer
906 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
907 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
910 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
911 struct __member_pointer_traits_imp
912 { // forward declaration; specializations later
916 template <class _Tp> struct __libcpp_is_member_function_pointer
917 : public false_type {};
919 template <class _Ret, class _Class>
920 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
921 : public is_function<_Ret> {};
923 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
924 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
926 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
928 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
929 = is_member_function_pointer<_Tp>::value;
934 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
935 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
937 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
938 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
940 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
942 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
943 = is_member_pointer<_Tp>::value;
946 // is_member_object_pointer
948 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
949 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
950 !is_member_function_pointer<_Tp>::value> {};
952 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
954 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
955 = is_member_object_pointer<_Tp>::value;
960 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
962 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
963 : public integral_constant<bool, __is_enum(_Tp)> {};
967 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
968 : public integral_constant<bool, !is_void<_Tp>::value &&
969 !is_integral<_Tp>::value &&
970 !is_floating_point<_Tp>::value &&
971 !is_array<_Tp>::value &&
972 !is_pointer<_Tp>::value &&
973 !is_reference<_Tp>::value &&
974 !is_member_pointer<_Tp>::value &&
975 !is_union<_Tp>::value &&
976 !is_class<_Tp>::value &&
977 !is_function<_Tp>::value > {};
981 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
983 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
984 = is_enum<_Tp>::value;
989 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
990 : public integral_constant<bool, is_integral<_Tp>::value ||
991 is_floating_point<_Tp>::value> {};
993 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
995 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
996 = is_arithmetic<_Tp>::value;
1001 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
1002 : public integral_constant<bool, is_void<_Tp>::value ||
1003 __is_nullptr_t<_Tp>::value ||
1004 is_arithmetic<_Tp>::value> {};
1006 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1007 template <class _Tp>
1008 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1009 = is_fundamental<_Tp>::value;
1014 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1015 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1016 is_member_pointer<_Tp>::value ||
1017 is_pointer<_Tp>::value ||
1018 __is_nullptr_t<_Tp>::value ||
1019 is_enum<_Tp>::value > {};
1021 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1023 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1024 template <class _Tp>
1025 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1026 = is_scalar<_Tp>::value;
1031 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1032 : public integral_constant<bool, is_scalar<_Tp>::value ||
1033 is_array<_Tp>::value ||
1034 is_union<_Tp>::value ||
1035 is_class<_Tp>::value > {};
1037 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1038 template <class _Tp>
1039 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
1040 = is_object<_Tp>::value;
1045 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1046 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1048 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1049 template <class _Tp>
1050 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1051 = is_compound<_Tp>::value;
1055 // __is_referenceable [defns.referenceable]
1057 struct __is_referenceable_impl {
1058 template <class _Tp> static _Tp& __test(int);
1059 template <class _Tp> static __two __test(...);
1062 template <class _Tp>
1063 struct __is_referenceable : integral_constant<bool,
1064 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1069 template <class _Tp, bool = is_reference<_Tp>::value ||
1070 is_function<_Tp>::value ||
1071 is_const<_Tp>::value >
1072 struct __add_const {typedef _Tp type;};
1074 template <class _Tp>
1075 struct __add_const<_Tp, false> {typedef const _Tp type;};
1077 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1078 {typedef typename __add_const<_Tp>::type type;};
1080 #if _LIBCPP_STD_VER > 11
1081 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1086 template <class _Tp, bool = is_reference<_Tp>::value ||
1087 is_function<_Tp>::value ||
1088 is_volatile<_Tp>::value >
1089 struct __add_volatile {typedef _Tp type;};
1091 template <class _Tp>
1092 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1094 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1095 {typedef typename __add_volatile<_Tp>::type type;};
1097 #if _LIBCPP_STD_VER > 11
1098 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1103 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1104 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1106 #if _LIBCPP_STD_VER > 11
1107 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1112 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;};
1113 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;};
1114 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1115 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
1118 #if _LIBCPP_STD_VER > 11
1119 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1122 // add_lvalue_reference
1124 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1125 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1127 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1128 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1130 #if _LIBCPP_STD_VER > 11
1131 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1134 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1136 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1137 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1139 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1140 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1142 #if _LIBCPP_STD_VER > 11
1143 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1146 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1148 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1150 template <class _Tp> _Tp&& __declval(int);
1151 template <class _Tp> _Tp __declval(long);
1153 template <class _Tp>
1154 decltype(_VSTD::__declval<_Tp>(0))
1155 declval() _NOEXCEPT;
1157 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1159 template <class _Tp>
1160 typename add_lvalue_reference<_Tp>::type
1163 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1167 template <class _Tp>
1169 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1172 template <class _Tp>
1173 struct __unconstref {
1174 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1177 #ifndef _LIBCPP_CXX03_LANG
1178 template <class _Tp>
1179 using __uncvref_t = typename __uncvref<_Tp>::type;
1182 // __is_same_uncvref
1184 template <class _Tp, class _Up>
1185 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1186 typename __uncvref<_Up>::type> {};
1188 #if _LIBCPP_STD_VER > 17
1189 // remove_cvref - same as __uncvref
1190 template <class _Tp>
1191 struct remove_cvref : public __uncvref<_Tp> {};
1193 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1204 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;};
1205 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
1206 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
1207 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
1208 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1210 #if _LIBCPP_STD_VER > 11
1211 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1216 template <class _Tp,
1217 bool = __is_referenceable<_Tp>::value ||
1218 is_same<typename remove_cv<_Tp>::type, void>::value>
1219 struct __add_pointer_impl
1220 {typedef typename remove_reference<_Tp>::type* type;};
1221 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1222 {typedef _Tp type;};
1224 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1225 {typedef typename __add_pointer_impl<_Tp>::type type;};
1227 #if _LIBCPP_STD_VER > 11
1228 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1232 #if _LIBCPP_STD_VER > 17
1233 template<class _Tp> struct type_identity { typedef _Tp type; };
1234 template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
1239 template <class _Tp, bool = is_integral<_Tp>::value>
1240 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1242 template <class _Tp>
1243 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1245 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1246 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1248 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1250 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1252 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1253 template <class _Tp>
1254 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1255 = is_signed<_Tp>::value;
1260 template <class _Tp, bool = is_integral<_Tp>::value>
1261 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1263 template <class _Tp>
1264 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1266 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1267 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1269 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1271 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1273 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1274 template <class _Tp>
1275 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1276 = is_unsigned<_Tp>::value;
1281 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1282 : public integral_constant<size_t, 0> {};
1283 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1284 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1285 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1286 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1288 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1289 template <class _Tp>
1290 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1296 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1297 : public integral_constant<size_t, 0> {};
1298 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1299 : public integral_constant<size_t, 0> {};
1300 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1301 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1302 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1303 : public integral_constant<size_t, _Np> {};
1304 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1305 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1307 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1308 template <class _Tp, unsigned _Ip = 0>
1309 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1310 = extent<_Tp, _Ip>::value;
1315 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1316 {typedef _Tp type;};
1317 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1318 {typedef _Tp type;};
1319 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1320 {typedef _Tp type;};
1322 #if _LIBCPP_STD_VER > 11
1323 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1326 // remove_all_extents
1328 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1329 {typedef _Tp type;};
1330 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1331 {typedef typename remove_all_extents<_Tp>::type type;};
1332 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1333 {typedef typename remove_all_extents<_Tp>::type type;};
1335 #if _LIBCPP_STD_VER > 11
1336 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1341 template <class _Up, bool>
1343 typedef typename remove_cv<_Up>::type type;
1346 template <class _Up>
1347 struct __decay<_Up, true> {
1349 typedef typename conditional
1351 is_array<_Up>::value,
1352 typename remove_extent<_Up>::type*,
1353 typename conditional
1355 is_function<_Up>::value,
1356 typename add_pointer<_Up>::type,
1357 typename remove_cv<_Up>::type
1362 template <class _Tp>
1363 struct _LIBCPP_TEMPLATE_VIS decay
1366 typedef typename remove_reference<_Tp>::type _Up;
1368 typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1371 #if _LIBCPP_STD_VER > 11
1372 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1377 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1378 : public integral_constant<bool, __is_abstract(_Tp)> {};
1380 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1381 template <class _Tp>
1382 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1383 = is_abstract<_Tp>::value;
1388 #if defined(_LIBCPP_HAS_IS_FINAL)
1389 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1390 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1392 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1393 __libcpp_is_final : public false_type {};
1396 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1397 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1398 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1401 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1402 template <class _Tp>
1403 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1404 = is_final<_Tp>::value;
1408 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1410 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1411 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1413 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1414 template <class _Tp>
1415 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1416 = is_aggregate<_Tp>::value;
1419 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1423 #ifdef _LIBCPP_HAS_IS_BASE_OF
1425 template <class _Bp, class _Dp>
1426 struct _LIBCPP_TEMPLATE_VIS is_base_of
1427 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1429 #else // _LIBCPP_HAS_IS_BASE_OF
1431 namespace __is_base_of_imp
1433 template <class _Tp>
1436 _Dst(const volatile _Tp &);
1438 template <class _Tp>
1441 operator const volatile _Tp &();
1442 template <class _Up> operator const _Dst<_Up> &();
1444 template <size_t> struct __one { typedef char type; };
1445 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1446 template <class _Bp, class _Dp> __two __test(...);
1449 template <class _Bp, class _Dp>
1450 struct _LIBCPP_TEMPLATE_VIS is_base_of
1451 : public integral_constant<bool, is_class<_Bp>::value &&
1452 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1454 #endif // _LIBCPP_HAS_IS_BASE_OF
1456 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1457 template <class _Bp, class _Dp>
1458 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1459 = is_base_of<_Bp, _Dp>::value;
1464 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1466 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1467 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1468 !is_abstract<_T2>::value> {};
1470 #else // __has_feature(is_convertible_to)
1472 namespace __is_convertible_imp
1474 template <class _Tp> void __test_convert(_Tp);
1476 template <class _From, class _To, class = void>
1477 struct __is_convertible_test : public false_type {};
1479 template <class _From, class _To>
1480 struct __is_convertible_test<_From, _To,
1481 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1484 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1485 bool _IsFunction = is_function<_Tp>::value,
1486 bool _IsVoid = is_void<_Tp>::value>
1487 struct __is_array_function_or_void {enum {value = 0};};
1488 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1489 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1490 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1493 template <class _Tp,
1494 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1495 struct __is_convertible_check
1497 static const size_t __v = 0;
1500 template <class _Tp>
1501 struct __is_convertible_check<_Tp, 0>
1503 static const size_t __v = sizeof(_Tp);
1506 template <class _T1, class _T2,
1507 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1508 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1509 struct __is_convertible
1510 : public integral_constant<bool,
1511 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1512 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1513 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1514 && (!is_const<typename remove_reference<_T2>::type>::value
1515 || is_volatile<typename remove_reference<_T2>::type>::value)
1516 && (is_same<typename remove_cv<_T1>::type,
1517 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1518 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1523 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1524 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1525 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1526 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1528 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1529 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1530 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1531 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1533 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1534 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1535 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1536 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1538 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1539 : public __is_convertible<_T1, _T2>
1541 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1542 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1545 #endif // __has_feature(is_convertible_to)
1547 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1548 template <class _From, class _To>
1549 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1550 = is_convertible<_From, _To>::value;
1555 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1557 template <class _Tp>
1558 struct _LIBCPP_TEMPLATE_VIS is_empty
1559 : public integral_constant<bool, __is_empty(_Tp)> {};
1561 #else // __has_feature(is_empty)
1563 template <class _Tp>
1575 template <class _Tp, bool = is_class<_Tp>::value>
1576 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1578 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1580 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1582 #endif // __has_feature(is_empty)
1584 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1585 template <class _Tp>
1586 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1587 = is_empty<_Tp>::value;
1592 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1594 template <class _Tp>
1595 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1596 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1600 template<typename _Tp> char &__is_polymorphic_impl(
1601 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1603 template<typename _Tp> __two &__is_polymorphic_impl(...);
1605 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1606 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1608 #endif // __has_feature(is_polymorphic)
1610 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1611 template <class _Tp>
1612 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1613 = is_polymorphic<_Tp>::value;
1616 // has_virtual_destructor
1618 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1620 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1621 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1625 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1626 : public false_type {};
1630 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1631 template <class _Tp>
1632 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1633 = has_virtual_destructor<_Tp>::value;
1636 // has_unique_object_representations
1638 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1640 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1641 : public integral_constant<bool,
1642 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1644 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1645 template <class _Tp>
1646 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1647 = has_unique_object_representations<_Tp>::value;
1654 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1655 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
1657 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1658 template <class _Tp>
1659 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1660 = alignment_of<_Tp>::value;
1665 template <class _Hp, class _Tp>
1674 #ifndef _LIBCPP_CXX03_LANG
1676 __nat(const __nat&) = delete;
1677 __nat& operator=(const __nat&) = delete;
1682 template <class _Tp>
1685 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
1689 struct __struct_double {long double __lx;};
1690 struct __struct_double4 {double __lx[4];};
1693 __type_list<__align_type<unsigned char>,
1694 __type_list<__align_type<unsigned short>,
1695 __type_list<__align_type<unsigned int>,
1696 __type_list<__align_type<unsigned long>,
1697 __type_list<__align_type<unsigned long long>,
1698 __type_list<__align_type<double>,
1699 __type_list<__align_type<long double>,
1700 __type_list<__align_type<__struct_double>,
1701 __type_list<__align_type<__struct_double4>,
1702 __type_list<__align_type<int*>,
1704 > > > > > > > > > > __all_types;
1706 template <class _TL, size_t _Align> struct __find_pod;
1708 template <class _Hp, size_t _Align>
1709 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1711 typedef typename conditional<
1712 _Align == _Hp::value,
1718 template <class _Hp, class _Tp, size_t _Align>
1719 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1721 typedef typename conditional<
1722 _Align == _Hp::value,
1724 typename __find_pod<_Tp, _Align>::type
1728 template <class _TL, size_t _Len> struct __find_max_align;
1730 template <class _Hp, size_t _Len>
1731 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1733 template <size_t _Len, size_t _A1, size_t _A2>
1734 struct __select_align
1737 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1738 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1740 static const size_t value = _Len < __max ? __min : __max;
1743 template <class _Hp, class _Tp, size_t _Len>
1744 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1745 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1747 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1748 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1750 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1751 static_assert(!is_void<_Aligner>::value, "");
1755 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1759 #if _LIBCPP_STD_VER > 11
1760 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1761 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1764 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1765 template <size_t _Len>\
1766 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1768 struct _ALIGNAS(n) type\
1770 unsigned char __lx[(_Len + n - 1)/n * n];\
1774 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1775 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1776 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1777 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1778 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1779 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1780 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1781 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1782 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1783 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1784 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1785 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1786 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1787 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1788 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1789 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1790 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1791 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1793 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1795 #ifndef _LIBCPP_HAS_NO_VARIADICS
1799 template <size_t _I0, size_t ..._In>
1800 struct __static_max;
1802 template <size_t _I0>
1803 struct __static_max<_I0>
1805 static const size_t value = _I0;
1808 template <size_t _I0, size_t _I1, size_t ..._In>
1809 struct __static_max<_I0, _I1, _In...>
1811 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1812 __static_max<_I1, _In...>::value;
1815 template <size_t _Len, class _Type0, class ..._Types>
1816 struct aligned_union
1818 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
1819 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
1820 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1821 sizeof(_Types)...>::value;
1822 typedef typename aligned_storage<__len, alignment_value>::type type;
1825 #if _LIBCPP_STD_VER > 11
1826 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1829 #endif // _LIBCPP_HAS_NO_VARIADICS
1831 template <class _Tp>
1832 struct __numeric_type
1834 static void __test(...);
1835 static float __test(float);
1836 static double __test(char);
1837 static double __test(int);
1838 static double __test(unsigned);
1839 static double __test(long);
1840 static double __test(unsigned long);
1841 static double __test(long long);
1842 static double __test(unsigned long long);
1843 static double __test(double);
1844 static long double __test(long double);
1846 typedef decltype(__test(declval<_Tp>())) type;
1847 static const bool value = !is_same<type, void>::value;
1851 struct __numeric_type<void>
1853 static const bool value = true;
1858 template <class _A1, class _A2 = void, class _A3 = void,
1859 bool = __numeric_type<_A1>::value &&
1860 __numeric_type<_A2>::value &&
1861 __numeric_type<_A3>::value>
1865 static const bool value = false;
1868 template <class _A1, class _A2, class _A3>
1869 class __promote_imp<_A1, _A2, _A3, true>
1872 typedef typename __promote_imp<_A1>::type __type1;
1873 typedef typename __promote_imp<_A2>::type __type2;
1874 typedef typename __promote_imp<_A3>::type __type3;
1876 typedef decltype(__type1() + __type2() + __type3()) type;
1877 static const bool value = true;
1880 template <class _A1, class _A2>
1881 class __promote_imp<_A1, _A2, void, true>
1884 typedef typename __promote_imp<_A1>::type __type1;
1885 typedef typename __promote_imp<_A2>::type __type2;
1887 typedef decltype(__type1() + __type2()) type;
1888 static const bool value = true;
1891 template <class _A1>
1892 class __promote_imp<_A1, void, void, true>
1895 typedef typename __numeric_type<_A1>::type type;
1896 static const bool value = true;
1899 template <class _A1, class _A2 = void, class _A3 = void>
1900 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1902 // make_signed / make_unsigned
1905 __type_list<signed char,
1906 __type_list<signed short,
1907 __type_list<signed int,
1908 __type_list<signed long,
1909 __type_list<signed long long,
1910 #ifndef _LIBCPP_HAS_NO_INT128
1911 __type_list<__int128_t,
1914 #ifndef _LIBCPP_HAS_NO_INT128
1917 > > > > > __signed_types;
1920 __type_list<unsigned char,
1921 __type_list<unsigned short,
1922 __type_list<unsigned int,
1923 __type_list<unsigned long,
1924 __type_list<unsigned long long,
1925 #ifndef _LIBCPP_HAS_NO_INT128
1926 __type_list<__uint128_t,
1929 #ifndef _LIBCPP_HAS_NO_INT128
1932 > > > > > __unsigned_types;
1934 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1936 template <class _Hp, class _Tp, size_t _Size>
1937 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1942 template <class _Hp, class _Tp, size_t _Size>
1943 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1945 typedef typename __find_first<_Tp, _Size>::type type;
1948 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1949 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1955 template <class _Tp, class _Up>
1956 struct __apply_cv<_Tp, _Up, true, false>
1958 typedef const _Up type;
1961 template <class _Tp, class _Up>
1962 struct __apply_cv<_Tp, _Up, false, true>
1964 typedef volatile _Up type;
1967 template <class _Tp, class _Up>
1968 struct __apply_cv<_Tp, _Up, true, true>
1970 typedef const volatile _Up type;
1973 template <class _Tp, class _Up>
1974 struct __apply_cv<_Tp&, _Up, false, false>
1979 template <class _Tp, class _Up>
1980 struct __apply_cv<_Tp&, _Up, true, false>
1982 typedef const _Up& type;
1985 template <class _Tp, class _Up>
1986 struct __apply_cv<_Tp&, _Up, false, true>
1988 typedef volatile _Up& type;
1991 template <class _Tp, class _Up>
1992 struct __apply_cv<_Tp&, _Up, true, true>
1994 typedef const volatile _Up& type;
1997 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1998 struct __make_signed {};
2000 template <class _Tp>
2001 struct __make_signed<_Tp, true>
2003 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
2006 template <> struct __make_signed<bool, true> {};
2007 template <> struct __make_signed< signed short, true> {typedef short type;};
2008 template <> struct __make_signed<unsigned short, true> {typedef short type;};
2009 template <> struct __make_signed< signed int, true> {typedef int type;};
2010 template <> struct __make_signed<unsigned int, true> {typedef int type;};
2011 template <> struct __make_signed< signed long, true> {typedef long type;};
2012 template <> struct __make_signed<unsigned long, true> {typedef long type;};
2013 template <> struct __make_signed< signed long long, true> {typedef long long type;};
2014 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2015 #ifndef _LIBCPP_HAS_NO_INT128
2016 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2017 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2020 template <class _Tp>
2021 struct _LIBCPP_TEMPLATE_VIS make_signed
2023 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2026 #if _LIBCPP_STD_VER > 11
2027 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2030 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2031 struct __make_unsigned {};
2033 template <class _Tp>
2034 struct __make_unsigned<_Tp, true>
2036 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2039 template <> struct __make_unsigned<bool, true> {};
2040 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2041 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2042 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2043 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2044 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2045 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2046 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2047 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2048 #ifndef _LIBCPP_HAS_NO_INT128
2049 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2050 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2053 template <class _Tp>
2054 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2056 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2059 #if _LIBCPP_STD_VER > 11
2060 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2063 #ifdef _LIBCPP_HAS_NO_VARIADICS
2065 template <class _Tp, class _Up = void, class _Vp = void>
2066 struct _LIBCPP_TEMPLATE_VIS common_type
2069 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
2073 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void>
2079 template <class _Tp>
2080 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
2083 typedef typename common_type<_Tp, _Tp>::type type;
2086 template <class _Tp, class _Up>
2087 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
2089 typedef typename decay<decltype(
2090 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2094 #else // _LIBCPP_HAS_NO_VARIADICS
2096 // bullet 1 - sizeof...(Tp) == 0
2098 template <class ..._Tp>
2099 struct _LIBCPP_TEMPLATE_VIS common_type {};
2101 // bullet 2 - sizeof...(Tp) == 1
2103 template <class _Tp>
2104 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2105 : public common_type<_Tp, _Tp> {};
2107 // bullet 3 - sizeof...(Tp) == 2
2109 template <class _Tp, class _Up, class = void>
2110 struct __common_type2_imp {};
2112 template <class _Tp, class _Up>
2113 struct __common_type2_imp<_Tp, _Up,
2114 typename __void_t<decltype(
2115 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2118 typedef typename decay<decltype(
2119 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2123 template <class _Tp, class _Up,
2124 class _DTp = typename decay<_Tp>::type,
2125 class _DUp = typename decay<_Up>::type>
2126 using __common_type2 =
2127 typename conditional<
2128 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
2129 __common_type2_imp<_Tp, _Up>,
2130 common_type<_DTp, _DUp>
2133 template <class _Tp, class _Up>
2134 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2135 : __common_type2<_Tp, _Up> {};
2137 // bullet 4 - sizeof...(Tp) > 2
2139 template <class ...Tp> struct __common_types;
2141 template <class, class = void>
2142 struct __common_type_impl {};
2144 template <class _Tp, class _Up>
2145 struct __common_type_impl<
2146 __common_types<_Tp, _Up>,
2147 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2149 typedef typename common_type<_Tp, _Up>::type type;
2152 template <class _Tp, class _Up, class ..._Vp>
2153 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2154 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2155 : __common_type_impl<
2156 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
2161 template <class _Tp, class _Up, class ..._Vp>
2162 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
2163 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2165 #if _LIBCPP_STD_VER > 11
2166 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2169 #endif // _LIBCPP_HAS_NO_VARIADICS
2173 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2175 template <class _Tp, class _Arg>
2176 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2177 __is_assignable_test(int);
2179 template <class, class>
2180 false_type __is_assignable_test(...);
2183 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2184 struct __is_assignable_imp
2185 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2187 template <class _Tp, class _Arg>
2188 struct __is_assignable_imp<_Tp, _Arg, true>
2193 template <class _Tp, class _Arg>
2194 struct is_assignable
2195 : public __is_assignable_imp<_Tp, _Arg> {};
2197 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2198 template <class _Tp, class _Arg>
2199 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2200 = is_assignable<_Tp, _Arg>::value;
2203 // is_copy_assignable
2205 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2206 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2207 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2209 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2210 template <class _Tp>
2211 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2212 = is_copy_assignable<_Tp>::value;
2215 // is_move_assignable
2217 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2218 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2219 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2220 typename add_rvalue_reference<_Tp>::type> {};
2222 : public is_copy_assignable<_Tp> {};
2225 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2226 template <class _Tp>
2227 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2228 = is_move_assignable<_Tp>::value;
2233 // if it's a reference, return true
2234 // if it's a function, return false
2235 // if it's void, return false
2236 // if it's an array of unknown bound, return false
2237 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2238 // where _Up is remove_all_extents<_Tp>::type
2241 struct __is_destructible_apply { typedef int type; };
2243 template <typename _Tp>
2244 struct __is_destructor_wellformed {
2245 template <typename _Tp1>
2246 static char __test (
2247 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2250 template <typename _Tp1>
2251 static __two __test (...);
2253 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2256 template <class _Tp, bool>
2257 struct __destructible_imp;
2259 template <class _Tp>
2260 struct __destructible_imp<_Tp, false>
2261 : public _VSTD::integral_constant<bool,
2262 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2264 template <class _Tp>
2265 struct __destructible_imp<_Tp, true>
2266 : public _VSTD::true_type {};
2268 template <class _Tp, bool>
2269 struct __destructible_false;
2271 template <class _Tp>
2272 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2274 template <class _Tp>
2275 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2277 template <class _Tp>
2278 struct is_destructible
2279 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2281 template <class _Tp>
2282 struct is_destructible<_Tp[]>
2283 : public _VSTD::false_type {};
2286 struct is_destructible<void>
2287 : public _VSTD::false_type {};
2289 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2290 template <class _Tp>
2291 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2292 = is_destructible<_Tp>::value;
2297 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2299 template <class _Tp>
2300 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2301 typename remove_reference<_Tp>::type&&
2302 move(_Tp&& __t) _NOEXCEPT
2304 typedef typename remove_reference<_Tp>::type _Up;
2305 return static_cast<_Up&&>(__t);
2308 template <class _Tp>
2309 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2311 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2313 return static_cast<_Tp&&>(__t);
2316 template <class _Tp>
2317 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2319 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2321 static_assert(!is_lvalue_reference<_Tp>::value,
2322 "can not forward an rvalue as an lvalue");
2323 return static_cast<_Tp&&>(__t);
2326 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2328 template <class _Tp>
2329 inline _LIBCPP_INLINE_VISIBILITY
2336 template <class _Tp>
2337 inline _LIBCPP_INLINE_VISIBILITY
2339 move(const _Tp& __t)
2344 template <class _Tp>
2345 inline _LIBCPP_INLINE_VISIBILITY
2347 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2353 template <class _Tp>
2356 typedef typename remove_reference<_Tp>::type _Trr;
2359 _LIBCPP_INLINE_VISIBILITY
2360 _Trr* operator->() {return &t_;}
2361 _LIBCPP_INLINE_VISIBILITY
2362 explicit __rv(_Trr& __t) : t_(__t) {}
2365 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2367 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2369 template <class _Tp>
2370 inline _LIBCPP_INLINE_VISIBILITY
2371 typename decay<_Tp>::type
2372 __decay_copy(_Tp&& __t)
2374 return _VSTD::forward<_Tp>(__t);
2379 template <class _Tp>
2380 inline _LIBCPP_INLINE_VISIBILITY
2381 typename decay<_Tp>::type
2382 __decay_copy(const _Tp& __t)
2384 return _VSTD::forward<_Tp>(__t);
2389 #ifndef _LIBCPP_HAS_NO_VARIADICS
2391 template <class _Rp, class _Class, class ..._Param>
2392 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2394 typedef _Class _ClassType;
2395 typedef _Rp _ReturnType;
2396 typedef _Rp (_FnType) (_Param...);
2399 template <class _Rp, class _Class, class ..._Param>
2400 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2402 typedef _Class _ClassType;
2403 typedef _Rp _ReturnType;
2404 typedef _Rp (_FnType) (_Param..., ...);
2407 template <class _Rp, class _Class, class ..._Param>
2408 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2410 typedef _Class const _ClassType;
2411 typedef _Rp _ReturnType;
2412 typedef _Rp (_FnType) (_Param...);
2415 template <class _Rp, class _Class, class ..._Param>
2416 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2418 typedef _Class const _ClassType;
2419 typedef _Rp _ReturnType;
2420 typedef _Rp (_FnType) (_Param..., ...);
2423 template <class _Rp, class _Class, class ..._Param>
2424 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2426 typedef _Class volatile _ClassType;
2427 typedef _Rp _ReturnType;
2428 typedef _Rp (_FnType) (_Param...);
2431 template <class _Rp, class _Class, class ..._Param>
2432 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2434 typedef _Class volatile _ClassType;
2435 typedef _Rp _ReturnType;
2436 typedef _Rp (_FnType) (_Param..., ...);
2439 template <class _Rp, class _Class, class ..._Param>
2440 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2442 typedef _Class const volatile _ClassType;
2443 typedef _Rp _ReturnType;
2444 typedef _Rp (_FnType) (_Param...);
2447 template <class _Rp, class _Class, class ..._Param>
2448 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2450 typedef _Class const volatile _ClassType;
2451 typedef _Rp _ReturnType;
2452 typedef _Rp (_FnType) (_Param..., ...);
2455 #if __has_feature(cxx_reference_qualified_functions) || \
2456 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2458 template <class _Rp, class _Class, class ..._Param>
2459 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2461 typedef _Class& _ClassType;
2462 typedef _Rp _ReturnType;
2463 typedef _Rp (_FnType) (_Param...);
2466 template <class _Rp, class _Class, class ..._Param>
2467 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2469 typedef _Class& _ClassType;
2470 typedef _Rp _ReturnType;
2471 typedef _Rp (_FnType) (_Param..., ...);
2474 template <class _Rp, class _Class, class ..._Param>
2475 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2477 typedef _Class const& _ClassType;
2478 typedef _Rp _ReturnType;
2479 typedef _Rp (_FnType) (_Param...);
2482 template <class _Rp, class _Class, class ..._Param>
2483 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2485 typedef _Class const& _ClassType;
2486 typedef _Rp _ReturnType;
2487 typedef _Rp (_FnType) (_Param..., ...);
2490 template <class _Rp, class _Class, class ..._Param>
2491 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2493 typedef _Class volatile& _ClassType;
2494 typedef _Rp _ReturnType;
2495 typedef _Rp (_FnType) (_Param...);
2498 template <class _Rp, class _Class, class ..._Param>
2499 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2501 typedef _Class volatile& _ClassType;
2502 typedef _Rp _ReturnType;
2503 typedef _Rp (_FnType) (_Param..., ...);
2506 template <class _Rp, class _Class, class ..._Param>
2507 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2509 typedef _Class const volatile& _ClassType;
2510 typedef _Rp _ReturnType;
2511 typedef _Rp (_FnType) (_Param...);
2514 template <class _Rp, class _Class, class ..._Param>
2515 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2517 typedef _Class const volatile& _ClassType;
2518 typedef _Rp _ReturnType;
2519 typedef _Rp (_FnType) (_Param..., ...);
2522 template <class _Rp, class _Class, class ..._Param>
2523 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2525 typedef _Class&& _ClassType;
2526 typedef _Rp _ReturnType;
2527 typedef _Rp (_FnType) (_Param...);
2530 template <class _Rp, class _Class, class ..._Param>
2531 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2533 typedef _Class&& _ClassType;
2534 typedef _Rp _ReturnType;
2535 typedef _Rp (_FnType) (_Param..., ...);
2538 template <class _Rp, class _Class, class ..._Param>
2539 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2541 typedef _Class const&& _ClassType;
2542 typedef _Rp _ReturnType;
2543 typedef _Rp (_FnType) (_Param...);
2546 template <class _Rp, class _Class, class ..._Param>
2547 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2549 typedef _Class const&& _ClassType;
2550 typedef _Rp _ReturnType;
2551 typedef _Rp (_FnType) (_Param..., ...);
2554 template <class _Rp, class _Class, class ..._Param>
2555 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2557 typedef _Class volatile&& _ClassType;
2558 typedef _Rp _ReturnType;
2559 typedef _Rp (_FnType) (_Param...);
2562 template <class _Rp, class _Class, class ..._Param>
2563 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2565 typedef _Class volatile&& _ClassType;
2566 typedef _Rp _ReturnType;
2567 typedef _Rp (_FnType) (_Param..., ...);
2570 template <class _Rp, class _Class, class ..._Param>
2571 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2573 typedef _Class const volatile&& _ClassType;
2574 typedef _Rp _ReturnType;
2575 typedef _Rp (_FnType) (_Param...);
2578 template <class _Rp, class _Class, class ..._Param>
2579 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2581 typedef _Class const volatile&& _ClassType;
2582 typedef _Rp _ReturnType;
2583 typedef _Rp (_FnType) (_Param..., ...);
2586 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2588 #else // _LIBCPP_HAS_NO_VARIADICS
2590 template <class _Rp, class _Class>
2591 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2593 typedef _Class _ClassType;
2594 typedef _Rp _ReturnType;
2595 typedef _Rp (_FnType) ();
2598 template <class _Rp, class _Class>
2599 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2601 typedef _Class _ClassType;
2602 typedef _Rp _ReturnType;
2603 typedef _Rp (_FnType) (...);
2606 template <class _Rp, class _Class, class _P0>
2607 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2609 typedef _Class _ClassType;
2610 typedef _Rp _ReturnType;
2611 typedef _Rp (_FnType) (_P0);
2614 template <class _Rp, class _Class, class _P0>
2615 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2617 typedef _Class _ClassType;
2618 typedef _Rp _ReturnType;
2619 typedef _Rp (_FnType) (_P0, ...);
2622 template <class _Rp, class _Class, class _P0, class _P1>
2623 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2625 typedef _Class _ClassType;
2626 typedef _Rp _ReturnType;
2627 typedef _Rp (_FnType) (_P0, _P1);
2630 template <class _Rp, class _Class, class _P0, class _P1>
2631 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2633 typedef _Class _ClassType;
2634 typedef _Rp _ReturnType;
2635 typedef _Rp (_FnType) (_P0, _P1, ...);
2638 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2639 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2641 typedef _Class _ClassType;
2642 typedef _Rp _ReturnType;
2643 typedef _Rp (_FnType) (_P0, _P1, _P2);
2646 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2647 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2649 typedef _Class _ClassType;
2650 typedef _Rp _ReturnType;
2651 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2654 template <class _Rp, class _Class>
2655 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2657 typedef _Class const _ClassType;
2658 typedef _Rp _ReturnType;
2659 typedef _Rp (_FnType) ();
2662 template <class _Rp, class _Class>
2663 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2665 typedef _Class const _ClassType;
2666 typedef _Rp _ReturnType;
2667 typedef _Rp (_FnType) (...);
2670 template <class _Rp, class _Class, class _P0>
2671 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2673 typedef _Class const _ClassType;
2674 typedef _Rp _ReturnType;
2675 typedef _Rp (_FnType) (_P0);
2678 template <class _Rp, class _Class, class _P0>
2679 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2681 typedef _Class const _ClassType;
2682 typedef _Rp _ReturnType;
2683 typedef _Rp (_FnType) (_P0, ...);
2686 template <class _Rp, class _Class, class _P0, class _P1>
2687 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2689 typedef _Class const _ClassType;
2690 typedef _Rp _ReturnType;
2691 typedef _Rp (_FnType) (_P0, _P1);
2694 template <class _Rp, class _Class, class _P0, class _P1>
2695 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2697 typedef _Class const _ClassType;
2698 typedef _Rp _ReturnType;
2699 typedef _Rp (_FnType) (_P0, _P1, ...);
2702 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2703 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2705 typedef _Class const _ClassType;
2706 typedef _Rp _ReturnType;
2707 typedef _Rp (_FnType) (_P0, _P1, _P2);
2710 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2711 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2713 typedef _Class const _ClassType;
2714 typedef _Rp _ReturnType;
2715 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2718 template <class _Rp, class _Class>
2719 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2721 typedef _Class volatile _ClassType;
2722 typedef _Rp _ReturnType;
2723 typedef _Rp (_FnType) ();
2726 template <class _Rp, class _Class>
2727 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2729 typedef _Class volatile _ClassType;
2730 typedef _Rp _ReturnType;
2731 typedef _Rp (_FnType) (...);
2734 template <class _Rp, class _Class, class _P0>
2735 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2737 typedef _Class volatile _ClassType;
2738 typedef _Rp _ReturnType;
2739 typedef _Rp (_FnType) (_P0);
2742 template <class _Rp, class _Class, class _P0>
2743 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2745 typedef _Class volatile _ClassType;
2746 typedef _Rp _ReturnType;
2747 typedef _Rp (_FnType) (_P0, ...);
2750 template <class _Rp, class _Class, class _P0, class _P1>
2751 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2753 typedef _Class volatile _ClassType;
2754 typedef _Rp _ReturnType;
2755 typedef _Rp (_FnType) (_P0, _P1);
2758 template <class _Rp, class _Class, class _P0, class _P1>
2759 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2761 typedef _Class volatile _ClassType;
2762 typedef _Rp _ReturnType;
2763 typedef _Rp (_FnType) (_P0, _P1, ...);
2766 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2767 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2769 typedef _Class volatile _ClassType;
2770 typedef _Rp _ReturnType;
2771 typedef _Rp (_FnType) (_P0, _P1, _P2);
2774 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2775 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2777 typedef _Class volatile _ClassType;
2778 typedef _Rp _ReturnType;
2779 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2782 template <class _Rp, class _Class>
2783 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2785 typedef _Class const volatile _ClassType;
2786 typedef _Rp _ReturnType;
2787 typedef _Rp (_FnType) ();
2790 template <class _Rp, class _Class>
2791 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2793 typedef _Class const volatile _ClassType;
2794 typedef _Rp _ReturnType;
2795 typedef _Rp (_FnType) (...);
2798 template <class _Rp, class _Class, class _P0>
2799 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2801 typedef _Class const volatile _ClassType;
2802 typedef _Rp _ReturnType;
2803 typedef _Rp (_FnType) (_P0);
2806 template <class _Rp, class _Class, class _P0>
2807 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2809 typedef _Class const volatile _ClassType;
2810 typedef _Rp _ReturnType;
2811 typedef _Rp (_FnType) (_P0, ...);
2814 template <class _Rp, class _Class, class _P0, class _P1>
2815 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2817 typedef _Class const volatile _ClassType;
2818 typedef _Rp _ReturnType;
2819 typedef _Rp (_FnType) (_P0, _P1);
2822 template <class _Rp, class _Class, class _P0, class _P1>
2823 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2825 typedef _Class const volatile _ClassType;
2826 typedef _Rp _ReturnType;
2827 typedef _Rp (_FnType) (_P0, _P1, ...);
2830 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2831 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2833 typedef _Class const volatile _ClassType;
2834 typedef _Rp _ReturnType;
2835 typedef _Rp (_FnType) (_P0, _P1, _P2);
2838 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2839 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2841 typedef _Class const volatile _ClassType;
2842 typedef _Rp _ReturnType;
2843 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2846 #endif // _LIBCPP_HAS_NO_VARIADICS
2848 template <class _Rp, class _Class>
2849 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2851 typedef _Class _ClassType;
2852 typedef _Rp _ReturnType;
2855 template <class _MP>
2856 struct __member_pointer_traits
2857 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2858 is_member_function_pointer<_MP>::value,
2859 is_member_object_pointer<_MP>::value>
2861 // typedef ... _ClassType;
2862 // typedef ... _ReturnType;
2863 // typedef ... _FnType;
2867 template <class _DecayedFp>
2868 struct __member_pointer_class_type {};
2870 template <class _Ret, class _ClassType>
2871 struct __member_pointer_class_type<_Ret _ClassType::*> {
2872 typedef _ClassType type;
2877 template <class _Callable> class result_of;
2879 #ifdef _LIBCPP_HAS_NO_VARIADICS
2881 template <class _Fn, bool, bool>
2886 template <class _Fn>
2887 class __result_of<_Fn(), true, false>
2890 typedef decltype(declval<_Fn>()()) type;
2893 template <class _Fn, class _A0>
2894 class __result_of<_Fn(_A0), true, false>
2897 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2900 template <class _Fn, class _A0, class _A1>
2901 class __result_of<_Fn(_A0, _A1), true, false>
2904 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2907 template <class _Fn, class _A0, class _A1, class _A2>
2908 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2911 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2914 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2915 struct __result_of_mp;
2917 // member function pointer
2919 template <class _MP, class _Tp>
2920 struct __result_of_mp<_MP, _Tp, true>
2921 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2925 // member data pointer
2927 template <class _MP, class _Tp, bool>
2928 struct __result_of_mdp;
2930 template <class _Rp, class _Class, class _Tp>
2931 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2933 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2936 template <class _Rp, class _Class, class _Tp>
2937 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2939 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2942 template <class _Rp, class _Class, class _Tp>
2943 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2944 : public __result_of_mdp<_Rp _Class::*, _Tp,
2945 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2951 template <class _Fn, class _Tp>
2952 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2953 : public __result_of_mp<typename remove_reference<_Fn>::type,
2955 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2959 template <class _Fn, class _Tp, class _A0>
2960 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2961 : public __result_of_mp<typename remove_reference<_Fn>::type,
2963 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2967 template <class _Fn, class _Tp, class _A0, class _A1>
2968 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2969 : public __result_of_mp<typename remove_reference<_Fn>::type,
2971 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2975 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2976 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2977 : public __result_of_mp<typename remove_reference<_Fn>::type,
2979 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2985 template <class _Fn>
2986 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2987 : public __result_of<_Fn(),
2988 is_class<typename remove_reference<_Fn>::type>::value ||
2989 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2990 is_member_pointer<typename remove_reference<_Fn>::type>::value
2995 template <class _Fn, class _A0>
2996 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2997 : public __result_of<_Fn(_A0),
2998 is_class<typename remove_reference<_Fn>::type>::value ||
2999 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3000 is_member_pointer<typename remove_reference<_Fn>::type>::value
3005 template <class _Fn, class _A0, class _A1>
3006 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
3007 : public __result_of<_Fn(_A0, _A1),
3008 is_class<typename remove_reference<_Fn>::type>::value ||
3009 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3010 is_member_pointer<typename remove_reference<_Fn>::type>::value
3015 template <class _Fn, class _A0, class _A1, class _A2>
3016 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
3017 : public __result_of<_Fn(_A0, _A1, _A2),
3018 is_class<typename remove_reference<_Fn>::type>::value ||
3019 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3020 is_member_pointer<typename remove_reference<_Fn>::type>::value
3025 #endif // _LIBCPP_HAS_NO_VARIADICS
3027 // template <class T, class... Args> struct is_constructible;
3029 namespace __is_construct
3034 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
3035 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
3037 template <class _Tp, class... _Args>
3038 struct __libcpp_is_constructible;
3040 template <class _To, class _From>
3041 struct __is_invalid_base_to_derived_cast {
3042 static_assert(is_reference<_To>::value, "Wrong specialization");
3043 using _RawFrom = __uncvref_t<_From>;
3044 using _RawTo = __uncvref_t<_To>;
3045 static const bool value = __lazy_and<
3046 __lazy_not<is_same<_RawFrom, _RawTo>>,
3047 is_base_of<_RawFrom, _RawTo>,
3048 __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
3052 template <class _To, class _From>
3053 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
3054 static_assert(is_reference<_To>::value, "Wrong specialization");
3057 template <class _ToRef, class _FromRef>
3058 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
3059 using _RawFrom = __uncvref_t<_FromRef>;
3060 using _RawTo = __uncvref_t<_ToRef>;
3061 static const bool value = __lazy_and<
3062 __lazy_not<is_function<_RawTo>>,
3064 is_same<_RawFrom, _RawTo>,
3065 is_base_of<_RawTo, _RawFrom>>
3069 struct __is_constructible_helper
3071 template <class _To>
3072 static void __eat(_To);
3074 // This overload is needed to work around a Clang bug that disallows
3075 // static_cast<T&&>(e) for non-reference-compatible types.
3076 // Example: static_cast<int&&>(declval<double>());
3077 // NOTE: The static_cast implementation below is required to support
3078 // classes with explicit conversion operators.
3079 template <class _To, class _From,
3080 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
3081 static true_type __test_cast(int);
3083 template <class _To, class _From,
3084 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
3085 static integral_constant<bool,
3086 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
3087 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
3088 > __test_cast(long);
3090 template <class, class>
3091 static false_type __test_cast(...);
3093 template <class _Tp, class ..._Args,
3094 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
3095 static true_type __test_nary(int);
3096 template <class _Tp, class...>
3097 static false_type __test_nary(...);
3099 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
3100 static is_destructible<_Tp> __test_unary(int);
3101 template <class, class>
3102 static false_type __test_unary(...);
3105 template <class _Tp, bool = is_void<_Tp>::value>
3106 struct __is_default_constructible
3107 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
3110 template <class _Tp>
3111 struct __is_default_constructible<_Tp, true> : false_type {};
3113 template <class _Tp>
3114 struct __is_default_constructible<_Tp[], false> : false_type {};
3116 template <class _Tp, size_t _Nx>
3117 struct __is_default_constructible<_Tp[_Nx], false>
3118 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3120 template <class _Tp, class... _Args>
3121 struct __libcpp_is_constructible
3123 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3124 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3128 template <class _Tp>
3129 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3131 template <class _Tp, class _A0>
3132 struct __libcpp_is_constructible<_Tp, _A0>
3133 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3136 template <class _Tp, class _A0>
3137 struct __libcpp_is_constructible<_Tp&, _A0>
3138 : public decltype(__is_constructible_helper::
3139 __test_cast<_Tp&, _A0>(0))
3142 template <class _Tp, class _A0>
3143 struct __libcpp_is_constructible<_Tp&&, _A0>
3144 : public decltype(__is_constructible_helper::
3145 __test_cast<_Tp&&, _A0>(0))
3150 #if __has_feature(is_constructible)
3151 template <class _Tp, class ..._Args>
3152 struct _LIBCPP_TEMPLATE_VIS is_constructible
3153 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3155 #elif !defined(_LIBCPP_CXX03_LANG)
3156 template <class _Tp, class... _Args>
3157 struct _LIBCPP_TEMPLATE_VIS is_constructible
3158 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3160 // template <class T> struct is_constructible0;
3162 // main is_constructible0 test
3164 template <class _Tp>
3165 decltype((_Tp(), true_type()))
3166 __is_constructible0_test(_Tp&);
3169 __is_constructible0_test(__any);
3171 template <class _Tp, class _A0>
3172 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3173 __is_constructible1_test(_Tp&, _A0&);
3175 template <class _A0>
3177 __is_constructible1_test(__any, _A0&);
3179 template <class _Tp, class _A0, class _A1>
3180 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3181 __is_constructible2_test(_Tp&, _A0&, _A1&);
3183 template <class _A0, class _A1>
3185 __is_constructible2_test(__any, _A0&, _A1&);
3187 template <class _Tp, class _A0, class _A1, class _A2>
3188 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type()))
3189 __is_constructible3_test(_Tp&, _A0&, _A1&, _A2&);
3191 template <class _A0, class _A1, class _A2>
3193 __is_constructible3_test(__any, _A0&, _A1&, _A2&);
3195 template <bool, class _Tp>
3196 struct __is_constructible0_imp // false, _Tp is not a scalar
3197 : public common_type
3199 decltype(__is_constructible0_test(declval<_Tp&>()))
3203 template <bool, class _Tp, class _A0>
3204 struct __is_constructible1_imp // false, _Tp is not a scalar
3205 : public common_type
3207 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3211 template <bool, class _Tp, class _A0, class _A1>
3212 struct __is_constructible2_imp // false, _Tp is not a scalar
3213 : public common_type
3215 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3219 template <bool, class _Tp, class _A0, class _A1, class _A2>
3220 struct __is_constructible3_imp // false, _Tp is not a scalar
3221 : public common_type
3223 decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>()))
3227 // handle scalars and reference types
3229 // Scalars are default constructible, references are not
3231 template <class _Tp>
3232 struct __is_constructible0_imp<true, _Tp>
3233 : public is_scalar<_Tp>
3236 template <class _Tp, class _A0>
3237 struct __is_constructible1_imp<true, _Tp, _A0>
3238 : public is_convertible<_A0, _Tp>
3241 template <class _Tp, class _A0, class _A1>
3242 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3246 template <class _Tp, class _A0, class _A1, class _A2>
3247 struct __is_constructible3_imp<true, _Tp, _A0, _A1, _A2>
3251 // Treat scalars and reference types separately
3253 template <bool, class _Tp>
3254 struct __is_constructible0_void_check
3255 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3259 template <bool, class _Tp, class _A0>
3260 struct __is_constructible1_void_check
3261 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3265 template <bool, class _Tp, class _A0, class _A1>
3266 struct __is_constructible2_void_check
3267 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3271 template <bool, class _Tp, class _A0, class _A1, class _A2>
3272 struct __is_constructible3_void_check
3273 : public __is_constructible3_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3277 // If any of T or Args is void, is_constructible should be false
3279 template <class _Tp>
3280 struct __is_constructible0_void_check<true, _Tp>
3284 template <class _Tp, class _A0>
3285 struct __is_constructible1_void_check<true, _Tp, _A0>
3289 template <class _Tp, class _A0, class _A1>
3290 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3294 template <class _Tp, class _A0, class _A1, class _A2>
3295 struct __is_constructible3_void_check<true, _Tp, _A0, _A1, _A2>
3299 // is_constructible entry point
3301 template <class _Tp, class _A0 = __is_construct::__nat,
3302 class _A1 = __is_construct::__nat,
3303 class _A2 = __is_construct::__nat>
3304 struct _LIBCPP_TEMPLATE_VIS is_constructible
3305 : public __is_constructible3_void_check<is_void<_Tp>::value
3306 || is_abstract<_Tp>::value
3307 || is_function<_Tp>::value
3308 || is_void<_A0>::value
3309 || is_void<_A1>::value
3310 || is_void<_A2>::value,
3314 template <class _Tp>
3315 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3316 : public __is_constructible0_void_check<is_void<_Tp>::value
3317 || is_abstract<_Tp>::value
3318 || is_function<_Tp>::value,
3322 template <class _Tp, class _A0>
3323 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
3324 : public __is_constructible1_void_check<is_void<_Tp>::value
3325 || is_abstract<_Tp>::value
3326 || is_function<_Tp>::value
3327 || is_void<_A0>::value,
3331 template <class _Tp, class _A0, class _A1>
3332 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, _A1, __is_construct::__nat>
3333 : public __is_constructible2_void_check<is_void<_Tp>::value
3334 || is_abstract<_Tp>::value
3335 || is_function<_Tp>::value
3336 || is_void<_A0>::value
3337 || is_void<_A1>::value,
3341 // Array types are default constructible if their element type
3342 // is default constructible
3344 template <class _Ap, size_t _Np>
3345 struct __is_constructible0_imp<false, _Ap[_Np]>
3346 : public is_constructible<typename remove_all_extents<_Ap>::type>
3349 template <class _Ap, size_t _Np, class _A0>
3350 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3354 template <class _Ap, size_t _Np, class _A0, class _A1>
3355 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3359 template <class _Ap, size_t _Np, class _A0, class _A1, class _A2>
3360 struct __is_constructible3_imp<false, _Ap[_Np], _A0, _A1, _A2>
3364 // Incomplete array types are not constructible
3366 template <class _Ap>
3367 struct __is_constructible0_imp<false, _Ap[]>
3371 template <class _Ap, class _A0>
3372 struct __is_constructible1_imp<false, _Ap[], _A0>
3376 template <class _Ap, class _A0, class _A1>
3377 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3381 template <class _Ap, class _A0, class _A1, class _A2>
3382 struct __is_constructible3_imp<false, _Ap[], _A0, _A1, _A2>
3386 #endif // __has_feature(is_constructible)
3389 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3390 template <class _Tp, class ..._Args>
3391 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
3392 = is_constructible<_Tp, _Args...>::value;
3395 // is_default_constructible
3397 template <class _Tp>
3398 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3399 : public is_constructible<_Tp>
3402 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3403 template <class _Tp>
3404 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
3405 = is_default_constructible<_Tp>::value;
3408 // is_copy_constructible
3410 template <class _Tp>
3411 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3412 : public is_constructible<_Tp,
3413 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3415 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3416 template <class _Tp>
3417 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3418 = is_copy_constructible<_Tp>::value;
3421 // is_move_constructible
3423 template <class _Tp>
3424 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3425 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3426 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3428 : public is_copy_constructible<_Tp>
3432 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3433 template <class _Tp>
3434 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
3435 = is_move_constructible<_Tp>::value;
3438 // is_trivially_constructible
3440 #ifndef _LIBCPP_HAS_NO_VARIADICS
3442 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3444 template <class _Tp, class... _Args>
3445 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3446 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3450 #else // !__has_feature(is_trivially_constructible)
3452 template <class _Tp, class... _Args>
3453 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3458 template <class _Tp>
3459 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3460 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3461 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3463 : integral_constant<bool, is_scalar<_Tp>::value>
3468 template <class _Tp>
3469 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3470 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3472 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
3474 : integral_constant<bool, is_scalar<_Tp>::value>
3478 template <class _Tp>
3479 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3480 : integral_constant<bool, is_scalar<_Tp>::value>
3484 template <class _Tp>
3485 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3486 : integral_constant<bool, is_scalar<_Tp>::value>
3490 #endif // !__has_feature(is_trivially_constructible)
3492 #else // _LIBCPP_HAS_NO_VARIADICS
3494 template <class _Tp, class _A0 = __is_construct::__nat,
3495 class _A1 = __is_construct::__nat>
3496 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3501 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3503 template <class _Tp>
3504 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3505 __is_construct::__nat>
3506 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3510 template <class _Tp>
3511 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3512 __is_construct::__nat>
3513 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3517 template <class _Tp>
3518 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3519 __is_construct::__nat>
3520 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3524 template <class _Tp>
3525 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3526 __is_construct::__nat>
3527 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3531 #else // !__has_feature(is_trivially_constructible)
3533 template <class _Tp>
3534 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3535 __is_construct::__nat>
3536 : integral_constant<bool, is_scalar<_Tp>::value>
3540 template <class _Tp>
3541 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3542 __is_construct::__nat>
3543 : integral_constant<bool, is_scalar<_Tp>::value>
3547 template <class _Tp>
3548 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3549 __is_construct::__nat>
3550 : integral_constant<bool, is_scalar<_Tp>::value>
3554 template <class _Tp>
3555 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3556 __is_construct::__nat>
3557 : integral_constant<bool, is_scalar<_Tp>::value>
3561 #endif // !__has_feature(is_trivially_constructible)
3563 #endif // _LIBCPP_HAS_NO_VARIADICS
3565 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3566 template <class _Tp, class... _Args>
3567 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3568 = is_trivially_constructible<_Tp, _Args...>::value;
3571 // is_trivially_default_constructible
3573 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3574 : public is_trivially_constructible<_Tp>
3577 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3578 template <class _Tp>
3579 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3580 = is_trivially_default_constructible<_Tp>::value;
3583 // is_trivially_copy_constructible
3585 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3586 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3589 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3590 template <class _Tp>
3591 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3592 = is_trivially_copy_constructible<_Tp>::value;
3595 // is_trivially_move_constructible
3597 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3598 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3599 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3601 : public is_trivially_copy_constructible<_Tp>
3605 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3606 template <class _Tp>
3607 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3608 = is_trivially_move_constructible<_Tp>::value;
3611 // is_trivially_assignable
3613 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3615 template <class _Tp, class _Arg>
3616 struct is_trivially_assignable
3617 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3621 #else // !__has_feature(is_trivially_assignable)
3623 template <class _Tp, class _Arg>
3624 struct is_trivially_assignable
3625 : public false_type {};
3627 template <class _Tp>
3628 struct is_trivially_assignable<_Tp&, _Tp>
3629 : integral_constant<bool, is_scalar<_Tp>::value> {};
3631 template <class _Tp>
3632 struct is_trivially_assignable<_Tp&, _Tp&>
3633 : integral_constant<bool, is_scalar<_Tp>::value> {};
3635 template <class _Tp>
3636 struct is_trivially_assignable<_Tp&, const _Tp&>
3637 : integral_constant<bool, is_scalar<_Tp>::value> {};
3639 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3641 template <class _Tp>
3642 struct is_trivially_assignable<_Tp&, _Tp&&>
3643 : integral_constant<bool, is_scalar<_Tp>::value> {};
3645 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3647 #endif // !__has_feature(is_trivially_assignable)
3649 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3650 template <class _Tp, class _Arg>
3651 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3652 = is_trivially_assignable<_Tp, _Arg>::value;
3655 // is_trivially_copy_assignable
3657 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3658 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3659 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3661 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3662 template <class _Tp>
3663 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3664 = is_trivially_copy_assignable<_Tp>::value;
3667 // is_trivially_move_assignable
3669 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3670 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3671 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3672 typename add_rvalue_reference<_Tp>::type>
3674 typename add_lvalue_reference<_Tp>::type>
3678 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3679 template <class _Tp>
3680 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3681 = is_trivially_move_assignable<_Tp>::value;
3684 // is_trivially_destructible
3686 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3688 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3689 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3693 template <class _Tp> struct __libcpp_trivial_destructor
3694 : public integral_constant<bool, is_scalar<_Tp>::value ||
3695 is_reference<_Tp>::value> {};
3697 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3698 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3700 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3701 : public false_type {};
3705 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3706 template <class _Tp>
3707 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3708 = is_trivially_destructible<_Tp>::value;
3711 // is_nothrow_constructible
3714 template <class _Tp, class... _Args>
3715 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3716 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3722 #ifndef _LIBCPP_HAS_NO_VARIADICS
3724 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3726 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3728 template <class _Tp, class... _Args>
3729 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3730 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3734 template <class _Tp>
3735 void __implicit_conversion_to(_Tp) noexcept { }
3737 template <class _Tp, class _Arg>
3738 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3739 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3743 template <class _Tp, bool _IsReference, class... _Args>
3744 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3749 template <class _Tp, class... _Args>
3750 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3751 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3755 template <class _Tp, size_t _Ns>
3756 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3757 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3761 #else // __has_feature(cxx_noexcept)
3763 template <class _Tp, class... _Args>
3764 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3769 template <class _Tp>
3770 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
3771 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3772 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3774 : integral_constant<bool, is_scalar<_Tp>::value>
3779 template <class _Tp>
3780 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3781 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
3783 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
3785 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3786 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3788 : integral_constant<bool, is_scalar<_Tp>::value>
3793 template <class _Tp>
3794 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
3795 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3796 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3798 : integral_constant<bool, is_scalar<_Tp>::value>
3803 template <class _Tp>
3804 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
3805 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3806 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3808 : integral_constant<bool, is_scalar<_Tp>::value>
3813 #endif // __has_feature(cxx_noexcept)
3815 #else // _LIBCPP_HAS_NO_VARIADICS
3817 template <class _Tp, class _A0 = __is_construct::__nat,
3818 class _A1 = __is_construct::__nat>
3819 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3824 template <class _Tp>
3825 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
3826 __is_construct::__nat>
3827 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3828 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3830 : integral_constant<bool, is_scalar<_Tp>::value>
3835 template <class _Tp>
3836 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
3837 __is_construct::__nat>
3838 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3839 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3841 : integral_constant<bool, is_scalar<_Tp>::value>
3846 template <class _Tp>
3847 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
3848 __is_construct::__nat>
3849 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3850 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3852 : integral_constant<bool, is_scalar<_Tp>::value>
3857 template <class _Tp>
3858 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
3859 __is_construct::__nat>
3860 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3861 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3863 : integral_constant<bool, is_scalar<_Tp>::value>
3868 #endif // _LIBCPP_HAS_NO_VARIADICS
3869 #endif // __has_feature(is_nothrow_constructible)
3871 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3872 template <class _Tp, class ..._Args>
3873 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3874 = is_nothrow_constructible<_Tp, _Args...>::value;
3877 // is_nothrow_default_constructible
3879 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3880 : public is_nothrow_constructible<_Tp>
3883 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3884 template <class _Tp>
3885 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3886 = is_nothrow_default_constructible<_Tp>::value;
3889 // is_nothrow_copy_constructible
3891 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3892 : public is_nothrow_constructible<_Tp,
3893 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3895 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3896 template <class _Tp>
3897 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3898 = is_nothrow_copy_constructible<_Tp>::value;
3901 // is_nothrow_move_constructible
3903 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3904 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3905 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3907 : public is_nothrow_copy_constructible<_Tp>
3911 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3912 template <class _Tp>
3913 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3914 = is_nothrow_move_constructible<_Tp>::value;
3917 // is_nothrow_assignable
3919 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3921 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3923 template <class _Tp, class _Arg>
3924 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3929 template <class _Tp, class _Arg>
3930 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3931 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3935 template <class _Tp, class _Arg>
3936 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3937 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3941 #else // __has_feature(cxx_noexcept)
3943 template <class _Tp, class _Arg>
3944 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3945 : public false_type {};
3947 template <class _Tp>
3948 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
3949 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3950 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3952 : integral_constant<bool, is_scalar<_Tp>::value> {};
3955 template <class _Tp>
3956 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
3957 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3958 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3960 : integral_constant<bool, is_scalar<_Tp>::value> {};
3963 template <class _Tp>
3964 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
3965 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3966 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3968 : integral_constant<bool, is_scalar<_Tp>::value> {};
3971 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3973 template <class _Tp>
3974 struct is_nothrow_assignable<_Tp&, _Tp&&>
3975 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3976 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3978 : integral_constant<bool, is_scalar<_Tp>::value> {};
3981 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3983 #endif // __has_feature(cxx_noexcept)
3985 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3986 template <class _Tp, class _Arg>
3987 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3988 = is_nothrow_assignable<_Tp, _Arg>::value;
3991 // is_nothrow_copy_assignable
3993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3994 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3995 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3997 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3998 template <class _Tp>
3999 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
4000 = is_nothrow_copy_assignable<_Tp>::value;
4003 // is_nothrow_move_assignable
4005 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
4006 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
4007 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4008 typename add_rvalue_reference<_Tp>::type>
4010 typename add_lvalue_reference<_Tp>::type>
4014 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4015 template <class _Tp>
4016 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
4017 = is_nothrow_move_assignable<_Tp>::value;
4020 // is_nothrow_destructible
4022 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
4024 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
4026 template <class _Tp>
4027 struct __libcpp_is_nothrow_destructible<false, _Tp>
4032 template <class _Tp>
4033 struct __libcpp_is_nothrow_destructible<true, _Tp>
4034 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
4038 template <class _Tp>
4039 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4040 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
4044 template <class _Tp, size_t _Ns>
4045 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
4046 : public is_nothrow_destructible<_Tp>
4050 template <class _Tp>
4051 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
4056 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4058 template <class _Tp>
4059 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
4068 template <class _Tp> struct __libcpp_nothrow_destructor
4069 : public integral_constant<bool, is_scalar<_Tp>::value ||
4070 is_reference<_Tp>::value> {};
4072 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4073 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
4075 template <class _Tp>
4076 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
4077 : public false_type {};
4081 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4082 template <class _Tp>
4083 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
4084 = is_nothrow_destructible<_Tp>::value;
4089 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
4091 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4092 : public integral_constant<bool, __is_pod(_Tp)> {};
4096 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4097 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
4098 is_trivially_copy_constructible<_Tp>::value &&
4099 is_trivially_copy_assignable<_Tp>::value &&
4100 is_trivially_destructible<_Tp>::value> {};
4104 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4105 template <class _Tp>
4106 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
4107 = is_pod<_Tp>::value;
4112 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
4113 #ifdef _LIBCPP_IS_LITERAL
4114 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
4116 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
4117 is_reference<typename remove_all_extents<_Tp>::type>::value>
4121 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4122 template <class _Tp>
4123 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
4124 = is_literal_type<_Tp>::value;
4127 // is_standard_layout;
4129 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
4130 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
4131 : public integral_constant<bool, __is_standard_layout(_Tp)>
4133 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4137 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4138 template <class _Tp>
4139 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
4140 = is_standard_layout<_Tp>::value;
4143 // is_trivially_copyable;
4145 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
4146 #if __has_feature(is_trivially_copyable)
4147 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
4148 #elif _GNUC_VER >= 501
4149 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
4151 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4155 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4156 template <class _Tp>
4157 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
4158 = is_trivially_copyable<_Tp>::value;
4163 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
4164 #if __has_feature(is_trivial) || _GNUC_VER >= 407
4165 : public integral_constant<bool, __is_trivial(_Tp)>
4167 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
4168 is_trivially_default_constructible<_Tp>::value>
4172 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4173 template <class _Tp>
4174 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
4175 = is_trivial<_Tp>::value;
4178 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
4179 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
4180 template <class _Tp> struct __is_reference_wrapper
4181 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
4183 #ifndef _LIBCPP_CXX03_LANG
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_bullet1 = typename enable_if
4191 is_member_function_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_bullet2 = typename enable_if
4200 is_member_function_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_bullet3 = typename enable_if
4210 is_member_function_pointer<_DecayFp>::value
4211 && !is_base_of<_ClassT, _DecayA0>::value
4212 && !__is_reference_wrapper<_DecayA0>::value
4215 template <class _Fp, class _A0,
4216 class _DecayFp = typename decay<_Fp>::type,
4217 class _DecayA0 = typename decay<_A0>::type,
4218 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4219 using __enable_if_bullet4 = typename enable_if
4221 is_member_object_pointer<_DecayFp>::value
4222 && is_base_of<_ClassT, _DecayA0>::value
4225 template <class _Fp, class _A0,
4226 class _DecayFp = typename decay<_Fp>::type,
4227 class _DecayA0 = typename decay<_A0>::type>
4228 using __enable_if_bullet5 = typename enable_if
4230 is_member_object_pointer<_DecayFp>::value
4231 && __is_reference_wrapper<_DecayA0>::value
4234 template <class _Fp, class _A0,
4235 class _DecayFp = typename decay<_Fp>::type,
4236 class _DecayA0 = typename decay<_A0>::type,
4237 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4238 using __enable_if_bullet6 = typename enable_if
4240 is_member_object_pointer<_DecayFp>::value
4241 && !is_base_of<_ClassT, _DecayA0>::value
4242 && !__is_reference_wrapper<_DecayA0>::value
4245 // __invoke forward declarations
4247 // fall back - none of the bullets
4249 #define _LIBCPP_INVOKE_RETURN(...) \
4250 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4251 { return __VA_ARGS__; }
4253 template <class ..._Args>
4254 auto __invoke(__any, _Args&& ...__args) -> __nat;
4256 template <class ..._Args>
4257 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4259 // bullets 1, 2 and 3
4261 template <class _Fp, class _A0, class ..._Args,
4262 class = __enable_if_bullet1<_Fp, _A0>>
4263 inline _LIBCPP_INLINE_VISIBILITY
4265 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4266 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4268 template <class _Fp, class _A0, class ..._Args,
4269 class = __enable_if_bullet1<_Fp, _A0>>
4270 inline _LIBCPP_INLINE_VISIBILITY
4271 _LIBCPP_CONSTEXPR auto
4272 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4273 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4275 template <class _Fp, class _A0, class ..._Args,
4276 class = __enable_if_bullet2<_Fp, _A0>>
4277 inline _LIBCPP_INLINE_VISIBILITY
4279 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4280 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4282 template <class _Fp, class _A0, class ..._Args,
4283 class = __enable_if_bullet2<_Fp, _A0>>
4284 inline _LIBCPP_INLINE_VISIBILITY
4285 _LIBCPP_CONSTEXPR auto
4286 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4287 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4289 template <class _Fp, class _A0, class ..._Args,
4290 class = __enable_if_bullet3<_Fp, _A0>>
4291 inline _LIBCPP_INLINE_VISIBILITY
4293 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4294 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4296 template <class _Fp, class _A0, class ..._Args,
4297 class = __enable_if_bullet3<_Fp, _A0>>
4298 inline _LIBCPP_INLINE_VISIBILITY
4299 _LIBCPP_CONSTEXPR auto
4300 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4301 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4303 // bullets 4, 5 and 6
4305 template <class _Fp, class _A0,
4306 class = __enable_if_bullet4<_Fp, _A0>>
4307 inline _LIBCPP_INLINE_VISIBILITY
4309 __invoke(_Fp&& __f, _A0&& __a0)
4310 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4312 template <class _Fp, class _A0,
4313 class = __enable_if_bullet4<_Fp, _A0>>
4314 inline _LIBCPP_INLINE_VISIBILITY
4315 _LIBCPP_CONSTEXPR auto
4316 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4317 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4319 template <class _Fp, class _A0,
4320 class = __enable_if_bullet5<_Fp, _A0>>
4321 inline _LIBCPP_INLINE_VISIBILITY
4323 __invoke(_Fp&& __f, _A0&& __a0)
4324 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4326 template <class _Fp, class _A0,
4327 class = __enable_if_bullet5<_Fp, _A0>>
4328 inline _LIBCPP_INLINE_VISIBILITY
4329 _LIBCPP_CONSTEXPR auto
4330 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4331 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4333 template <class _Fp, class _A0,
4334 class = __enable_if_bullet6<_Fp, _A0>>
4335 inline _LIBCPP_INLINE_VISIBILITY
4337 __invoke(_Fp&& __f, _A0&& __a0)
4338 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4340 template <class _Fp, class _A0,
4341 class = __enable_if_bullet6<_Fp, _A0>>
4342 inline _LIBCPP_INLINE_VISIBILITY
4343 _LIBCPP_CONSTEXPR auto
4344 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4345 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4349 template <class _Fp, class ..._Args>
4350 inline _LIBCPP_INLINE_VISIBILITY
4352 __invoke(_Fp&& __f, _Args&& ...__args)
4353 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4355 template <class _Fp, class ..._Args>
4356 inline _LIBCPP_INLINE_VISIBILITY
4357 _LIBCPP_CONSTEXPR auto
4358 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4359 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4361 #undef _LIBCPP_INVOKE_RETURN
4365 template <class _Ret, class _Fp, class ..._Args>
4366 struct __invokable_r
4368 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
4369 // or incomplete array types as required by the standard.
4370 using _Result = decltype(
4371 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4374 typename conditional<
4375 !is_same<_Result, __nat>::value,
4376 typename conditional<
4377 is_void<_Ret>::value,
4379 is_convertible<_Result, _Ret>
4383 static const bool value = type::value;
4386 template <class _Fp, class ..._Args>
4387 using __invokable = __invokable_r<void, _Fp, _Args...>;
4389 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4390 struct __nothrow_invokable_r_imp {
4391 static const bool value = false;
4394 template <class _Ret, class _Fp, class ..._Args>
4395 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4397 typedef __nothrow_invokable_r_imp _ThisT;
4399 template <class _Tp>
4400 static void __test_noexcept(_Tp) noexcept;
4402 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4403 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4406 template <class _Ret, class _Fp, class ..._Args>
4407 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4409 static const bool value = noexcept(
4410 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4413 template <class _Ret, class _Fp, class ..._Args>
4414 using __nothrow_invokable_r =
4415 __nothrow_invokable_r_imp<
4416 __invokable_r<_Ret, _Fp, _Args...>::value,
4417 is_void<_Ret>::value,
4421 template <class _Fp, class ..._Args>
4422 using __nothrow_invokable =
4423 __nothrow_invokable_r_imp<
4424 __invokable<_Fp, _Args...>::value,
4425 true, void, _Fp, _Args...
4428 template <class _Fp, class ..._Args>
4431 __invokable<_Fp, _Args...>::value,
4432 typename __invokable_r<void, _Fp, _Args...>::_Result>
4438 template <class _Fp, class ..._Args>
4439 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
4440 : public __invoke_of<_Fp, _Args...>
4444 #if _LIBCPP_STD_VER > 11
4445 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4448 #if _LIBCPP_STD_VER > 14
4452 template <class _Fn, class... _Args>
4453 struct _LIBCPP_TEMPLATE_VIS invoke_result
4454 : __invoke_of<_Fn, _Args...>
4458 template <class _Fn, class... _Args>
4459 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
4463 template <class _Fn, class ..._Args>
4464 struct _LIBCPP_TEMPLATE_VIS is_invocable
4465 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
4467 template <class _Ret, class _Fn, class ..._Args>
4468 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
4469 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4471 template <class _Fn, class ..._Args>
4472 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
4473 = is_invocable<_Fn, _Args...>::value;
4475 template <class _Ret, class _Fn, class ..._Args>
4476 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
4477 = is_invocable_r<_Ret, _Fn, _Args...>::value;
4479 // is_nothrow_invocable
4481 template <class _Fn, class ..._Args>
4482 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
4483 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
4485 template <class _Ret, class _Fn, class ..._Args>
4486 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
4487 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
4489 template <class _Fn, class ..._Args>
4490 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
4491 = is_nothrow_invocable<_Fn, _Args...>::value;
4493 template <class _Ret, class _Fn, class ..._Args>
4494 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
4495 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
4497 #endif // _LIBCPP_STD_VER > 14
4499 #endif // !defined(_LIBCPP_CXX03_LANG)
4501 template <class _Tp> struct __is_swappable;
4502 template <class _Tp> struct __is_nothrow_swappable;
4504 template <class _Tp>
4505 inline _LIBCPP_INLINE_VISIBILITY
4506 #ifndef _LIBCPP_CXX03_LANG
4509 is_move_constructible<_Tp>::value &&
4510 is_move_assignable<_Tp>::value
4515 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4516 is_nothrow_move_assignable<_Tp>::value)
4518 _Tp __t(_VSTD::move(__x));
4519 __x = _VSTD::move(__y);
4520 __y = _VSTD::move(__t);
4523 template<class _Tp, size_t _Np>
4524 inline _LIBCPP_INLINE_VISIBILITY
4526 __is_swappable<_Tp>::value
4528 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4530 template <class _ForwardIterator1, class _ForwardIterator2>
4531 inline _LIBCPP_INLINE_VISIBILITY
4533 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4534 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4535 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4536 *_VSTD::declval<_ForwardIterator2>())))
4545 // ALL generic swap overloads MUST already have a declaration available at this point.
4547 template <class _Tp, class _Up = _Tp,
4548 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4549 struct __swappable_with
4551 template <class _LHS, class _RHS>
4552 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4554 template <class, class>
4555 static __nat __test_swap(long);
4557 // Extra parens are needed for the C++03 definition of decltype.
4558 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4559 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4561 static const bool value = !is_same<__swap1, __nat>::value
4562 && !is_same<__swap2, __nat>::value;
4565 template <class _Tp, class _Up>
4566 struct __swappable_with<_Tp, _Up, false> : false_type {};
4568 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4569 struct __nothrow_swappable_with {
4570 static const bool value =
4571 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4572 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4573 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4579 template <class _Tp, class _Up>
4580 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4584 template <class _Tp>
4585 struct __is_swappable
4586 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4590 template <class _Tp>
4591 struct __is_nothrow_swappable
4592 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4596 #if _LIBCPP_STD_VER > 14
4598 template <class _Tp, class _Up>
4599 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4600 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4604 template <class _Tp>
4605 struct _LIBCPP_TEMPLATE_VIS is_swappable
4606 : public conditional<
4607 __is_referenceable<_Tp>::value,
4609 typename add_lvalue_reference<_Tp>::type,
4610 typename add_lvalue_reference<_Tp>::type>,
4616 template <class _Tp, class _Up>
4617 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4618 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4622 template <class _Tp>
4623 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4624 : public conditional<
4625 __is_referenceable<_Tp>::value,
4626 is_nothrow_swappable_with<
4627 typename add_lvalue_reference<_Tp>::type,
4628 typename add_lvalue_reference<_Tp>::type>,
4634 template <class _Tp, class _Up>
4635 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
4636 = is_swappable_with<_Tp, _Up>::value;
4638 template <class _Tp>
4639 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
4640 = is_swappable<_Tp>::value;
4642 template <class _Tp, class _Up>
4643 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
4644 = is_nothrow_swappable_with<_Tp, _Up>::value;
4646 template <class _Tp>
4647 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
4648 = is_nothrow_swappable<_Tp>::value;
4650 #endif // _LIBCPP_STD_VER > 14
4652 #ifdef _LIBCPP_UNDERLYING_TYPE
4654 template <class _Tp>
4655 struct underlying_type
4657 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4660 #if _LIBCPP_STD_VER > 11
4661 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4664 #else // _LIBCPP_UNDERLYING_TYPE
4666 template <class _Tp, bool _Support = false>
4667 struct underlying_type
4669 static_assert(_Support, "The underyling_type trait requires compiler "
4670 "support. Either no such support exists or "
4671 "libc++ does not know how to use it.");
4674 #endif // _LIBCPP_UNDERLYING_TYPE
4677 template <class _Tp, bool = is_enum<_Tp>::value>
4678 struct __sfinae_underlying_type
4680 typedef typename underlying_type<_Tp>::type type;
4681 typedef decltype(((type)1) + 0) __promoted_type;
4684 template <class _Tp>
4685 struct __sfinae_underlying_type<_Tp, false> {};
4687 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4688 int __convert_to_integral(int __val) { return __val; }
4690 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4691 unsigned __convert_to_integral(unsigned __val) { return __val; }
4693 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4694 long __convert_to_integral(long __val) { return __val; }
4696 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4697 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4699 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4700 long long __convert_to_integral(long long __val) { return __val; }
4702 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4703 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4705 template<typename _Fp>
4706 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4707 typename enable_if<is_floating_point<_Fp>::value, long long>::type
4708 __convert_to_integral(_Fp __val) { return __val; }
4710 #ifndef _LIBCPP_HAS_NO_INT128
4711 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4712 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4714 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4715 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4718 template <class _Tp>
4719 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4720 typename __sfinae_underlying_type<_Tp>::__promoted_type
4721 __convert_to_integral(_Tp __val) { return __val; }
4723 #ifndef _LIBCPP_CXX03_LANG
4725 template <class _Tp>
4726 struct __has_operator_addressof_member_imp
4728 template <class _Up>
4729 static auto __test(int)
4730 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4732 static auto __test(long) -> false_type;
4734 static const bool value = decltype(__test<_Tp>(0))::value;
4737 template <class _Tp>
4738 struct __has_operator_addressof_free_imp
4740 template <class _Up>
4741 static auto __test(int)
4742 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4744 static auto __test(long) -> false_type;
4746 static const bool value = decltype(__test<_Tp>(0))::value;
4749 template <class _Tp>
4750 struct __has_operator_addressof
4751 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4752 || __has_operator_addressof_free_imp<_Tp>::value>
4755 #endif // _LIBCPP_CXX03_LANG
4757 #if _LIBCPP_STD_VER > 14
4759 template <class...> using void_t = void;
4761 # ifndef _LIBCPP_HAS_NO_VARIADICS
4762 template <class... _Args>
4763 struct conjunction : __and_<_Args...> {};
4764 template<class... _Args>
4765 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
4766 = conjunction<_Args...>::value;
4768 template <class... _Args>
4769 struct disjunction : __or_<_Args...> {};
4770 template<class... _Args>
4771 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
4772 = disjunction<_Args...>::value;
4774 template <class _Tp>
4775 struct negation : __not_<_Tp> {};
4777 _LIBCPP_INLINE_VAR constexpr bool negation_v
4778 = negation<_Tp>::value;
4779 # endif // _LIBCPP_HAS_NO_VARIADICS
4780 #endif // _LIBCPP_STD_VER > 14
4782 // These traits are used in __tree and __hash_table
4783 #ifndef _LIBCPP_CXX03_LANG
4784 struct __extract_key_fail_tag {};
4785 struct __extract_key_self_tag {};
4786 struct __extract_key_first_tag {};
4788 template <class _ValTy, class _Key,
4789 class _RawValTy = typename __unconstref<_ValTy>::type>
4790 struct __can_extract_key
4791 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4792 __extract_key_fail_tag>::type {};
4794 template <class _Pair, class _Key, class _First, class _Second>
4795 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4796 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4797 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4799 // __can_extract_map_key uses true_type/false_type instead of the tags.
4800 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4801 // and _ValTy == _Key.
4802 template <class _ValTy, class _Key, class _ContainerValueTy,
4803 class _RawValTy = typename __unconstref<_ValTy>::type>
4804 struct __can_extract_map_key
4805 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4807 // This specialization returns __extract_key_fail_tag for non-map containers
4808 // because _Key == _ContainerValueTy
4809 template <class _ValTy, class _Key, class _RawValTy>
4810 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4815 #if _LIBCPP_STD_VER > 17
4820 #if defined(_LIBCPP_LITTLE_ENDIAN)
4822 #elif defined(_LIBCPP_BIG_ENDIAN)
4830 _LIBCPP_END_NAMESPACE_STD
4832 #if _LIBCPP_STD_VER > 14
4834 namespace std // purposefully not versioned
4836 template <class _Integer>
4837 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4838 operator<<=(byte& __lhs, _Integer __shift) noexcept
4839 { return __lhs = __lhs << __shift; }
4841 template <class _Integer>
4842 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4843 operator<< (byte __lhs, _Integer __shift) noexcept
4844 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
4846 template <class _Integer>
4847 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4848 operator>>=(byte& __lhs, _Integer __shift) noexcept
4849 { return __lhs = __lhs >> __shift; }
4851 template <class _Integer>
4852 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4853 operator>> (byte __lhs, _Integer __shift) noexcept
4854 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4856 template <class _Integer>
4857 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4858 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4863 #endif // _LIBCPP_TYPE_TRAITS