2 //===------------------------ type_traits ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_TYPE_TRAITS
12 #define _LIBCPP_TYPE_TRAITS
21 template <class T, T v> struct integral_constant;
22 typedef integral_constant<bool, true> true_type; // C++11
23 typedef integral_constant<bool, false> false_type; // C++11
25 template <bool B> // C++14
26 using bool_constant = integral_constant<bool, B>; // C++14
27 typedef bool_constant<true> true_type; // C++14
28 typedef bool_constant<false> false_type; // C++14
31 template <bool, class T = void> struct enable_if;
32 template <bool, class T, class F> struct conditional;
34 // Primary classification traits:
35 template <class T> struct is_void;
36 template <class T> struct is_null_pointer; // C++14
37 template <class T> struct is_integral;
38 template <class T> struct is_floating_point;
39 template <class T> struct is_array;
40 template <class T> struct is_pointer;
41 template <class T> struct is_lvalue_reference;
42 template <class T> struct is_rvalue_reference;
43 template <class T> struct is_member_object_pointer;
44 template <class T> struct is_member_function_pointer;
45 template <class T> struct is_enum;
46 template <class T> struct is_union;
47 template <class T> struct is_class;
48 template <class T> struct is_function;
50 // Secondary classification traits:
51 template <class T> struct is_reference;
52 template <class T> struct is_arithmetic;
53 template <class T> struct is_fundamental;
54 template <class T> struct is_member_pointer;
55 template <class T> struct is_scalar;
56 template <class T> struct is_object;
57 template <class T> struct is_compound;
59 // Const-volatile properties and transformations:
60 template <class T> struct is_const;
61 template <class T> struct is_volatile;
62 template <class T> struct remove_const;
63 template <class T> struct remove_volatile;
64 template <class T> struct remove_cv;
65 template <class T> struct add_const;
66 template <class T> struct add_volatile;
67 template <class T> struct add_cv;
69 // Reference transformations:
70 template <class T> struct remove_reference;
71 template <class T> struct add_lvalue_reference;
72 template <class T> struct add_rvalue_reference;
74 // Pointer transformations:
75 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;
78 // Integral properties:
79 template <class T> struct is_signed;
80 template <class T> struct is_unsigned;
81 template <class T> struct make_signed;
82 template <class T> struct make_unsigned;
84 // Array properties and transformations:
85 template <class T> struct rank;
86 template <class T, unsigned I = 0> struct extent;
87 template <class T> struct remove_extent;
88 template <class T> struct remove_all_extents;
90 // Member introspection:
91 template <class T> struct is_pod;
92 template <class T> struct is_trivial;
93 template <class T> struct is_trivially_copyable;
94 template <class T> struct is_standard_layout;
95 template <class T> struct is_literal_type;
96 template <class T> struct is_empty;
97 template <class T> struct is_polymorphic;
98 template <class T> struct is_abstract;
99 template <class T> struct is_final; // C++14
100 template <class T> struct is_aggregate; // C++17
102 template <class T, class... Args> struct is_constructible;
103 template <class T> struct is_default_constructible;
104 template <class T> struct is_copy_constructible;
105 template <class T> struct is_move_constructible;
106 template <class T, class U> struct is_assignable;
107 template <class T> struct is_copy_assignable;
108 template <class T> struct is_move_assignable;
109 template <class T, class U> struct is_swappable_with; // C++17
110 template <class T> struct is_swappable; // C++17
111 template <class T> struct is_destructible;
113 template <class T, class... Args> struct is_trivially_constructible;
114 template <class T> struct is_trivially_default_constructible;
115 template <class T> struct is_trivially_copy_constructible;
116 template <class T> struct is_trivially_move_constructible;
117 template <class T, class U> struct is_trivially_assignable;
118 template <class T> struct is_trivially_copy_assignable;
119 template <class T> struct is_trivially_move_assignable;
120 template <class T> struct is_trivially_destructible;
122 template <class T, class... Args> struct is_nothrow_constructible;
123 template <class T> struct is_nothrow_default_constructible;
124 template <class T> struct is_nothrow_copy_constructible;
125 template <class T> struct is_nothrow_move_constructible;
126 template <class T, class U> struct is_nothrow_assignable;
127 template <class T> struct is_nothrow_copy_assignable;
128 template <class T> struct is_nothrow_move_assignable;
129 template <class T, class U> struct is_nothrow_swappable_with; // C++17
130 template <class T> struct is_nothrow_swappable; // C++17
131 template <class T> struct is_nothrow_destructible;
133 template <class T> struct has_virtual_destructor;
135 template<class T> struct has_unique_object_representations; // C++17
137 // Relationships between types:
138 template <class T, class U> struct is_same;
139 template <class Base, class Derived> struct is_base_of;
140 template <class From, class To> struct is_convertible;
142 template <class Fn, class... ArgTypes> struct is_invocable;
143 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
145 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
146 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
148 // Alignment properties and transformations:
149 template <class T> struct alignment_of;
150 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
151 struct aligned_storage;
152 template <size_t Len, class... Types> struct aligned_union;
153 template <class T> struct remove_cvref; // C++20
155 template <class T> struct decay;
156 template <class... T> struct common_type;
157 template <class T> struct underlying_type;
158 template <class> class result_of; // undefined
159 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
160 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
162 // const-volatile modifications:
164 using remove_const_t = typename remove_const<T>::type; // C++14
166 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
168 using remove_cv_t = typename remove_cv<T>::type; // C++14
170 using add_const_t = typename add_const<T>::type; // C++14
172 using add_volatile_t = typename add_volatile<T>::type; // C++14
174 using add_cv_t = typename add_cv<T>::type; // C++14
176 // reference modifications:
178 using remove_reference_t = typename remove_reference<T>::type; // C++14
180 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
182 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
184 // sign modifications:
186 using make_signed_t = typename make_signed<T>::type; // C++14
188 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
190 // array modifications:
192 using remove_extent_t = typename remove_extent<T>::type; // C++14
194 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
196 // pointer modifications:
198 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
200 using add_pointer_t = typename add_pointer<T>::type; // C++14
202 // other transformations:
203 template <size_t Len, std::size_t Align=default-alignment>
204 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
205 template <std::size_t Len, class... Types>
206 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
208 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
210 using decay_t = typename decay<T>::type; // C++14
211 template <bool b, class T=void>
212 using enable_if_t = typename enable_if<b,T>::type; // C++14
213 template <bool b, class T, class F>
214 using conditional_t = typename conditional<b,T,F>::type; // C++14
215 template <class... T>
216 using common_type_t = typename common_type<T...>::type; // C++14
218 using underlying_type_t = typename underlying_type<T>::type; // C++14
220 using result_of_t = typename result_of<T>::type; // C++14
221 template <class Fn, class... ArgTypes>
222 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
225 using void_t = void; // C++17
227 // See C++14 20.10.4.1, primary type categories
228 template <class T> inline constexpr bool is_void_v
229 = is_void<T>::value; // C++17
230 template <class T> inline constexpr bool is_null_pointer_v
231 = is_null_pointer<T>::value; // C++17
232 template <class T> inline constexpr bool is_integral_v
233 = is_integral<T>::value; // C++17
234 template <class T> inline constexpr bool is_floating_point_v
235 = is_floating_point<T>::value; // C++17
236 template <class T> inline constexpr bool is_array_v
237 = is_array<T>::value; // C++17
238 template <class T> inline constexpr bool is_pointer_v
239 = is_pointer<T>::value; // C++17
240 template <class T> inline constexpr bool is_lvalue_reference_v
241 = is_lvalue_reference<T>::value; // C++17
242 template <class T> inline constexpr bool is_rvalue_reference_v
243 = is_rvalue_reference<T>::value; // C++17
244 template <class T> inline constexpr bool is_member_object_pointer_v
245 = is_member_object_pointer<T>::value; // C++17
246 template <class T> inline constexpr bool is_member_function_pointer_v
247 = is_member_function_pointer<T>::value; // C++17
248 template <class T> inline constexpr bool is_enum_v
249 = is_enum<T>::value; // C++17
250 template <class T> inline constexpr bool is_union_v
251 = is_union<T>::value; // C++17
252 template <class T> inline constexpr bool is_class_v
253 = is_class<T>::value; // C++17
254 template <class T> inline constexpr bool is_function_v
255 = is_function<T>::value; // C++17
257 // See C++14 20.10.4.2, composite type categories
258 template <class T> inline constexpr bool is_reference_v
259 = is_reference<T>::value; // C++17
260 template <class T> inline constexpr bool is_arithmetic_v
261 = is_arithmetic<T>::value; // C++17
262 template <class T> inline constexpr bool is_fundamental_v
263 = is_fundamental<T>::value; // C++17
264 template <class T> inline constexpr bool is_object_v
265 = is_object<T>::value; // C++17
266 template <class T> inline constexpr bool is_scalar_v
267 = is_scalar<T>::value; // C++17
268 template <class T> inline constexpr bool is_compound_v
269 = is_compound<T>::value; // C++17
270 template <class T> inline constexpr bool is_member_pointer_v
271 = is_member_pointer<T>::value; // C++17
273 // See C++14 20.10.4.3, type properties
274 template <class T> inline constexpr bool is_const_v
275 = is_const<T>::value; // C++17
276 template <class T> inline constexpr bool is_volatile_v
277 = is_volatile<T>::value; // C++17
278 template <class T> inline constexpr bool is_trivial_v
279 = is_trivial<T>::value; // C++17
280 template <class T> inline constexpr bool is_trivially_copyable_v
281 = is_trivially_copyable<T>::value; // C++17
282 template <class T> inline constexpr bool is_standard_layout_v
283 = is_standard_layout<T>::value; // C++17
284 template <class T> inline constexpr bool is_pod_v
285 = is_pod<T>::value; // C++17
286 template <class T> inline constexpr bool is_literal_type_v
287 = is_literal_type<T>::value; // C++17
288 template <class T> inline constexpr bool is_empty_v
289 = is_empty<T>::value; // C++17
290 template <class T> inline constexpr bool is_polymorphic_v
291 = is_polymorphic<T>::value; // C++17
292 template <class T> inline constexpr bool is_abstract_v
293 = is_abstract<T>::value; // C++17
294 template <class T> inline constexpr bool is_final_v
295 = is_final<T>::value; // C++17
296 template <class T> inline constexpr bool is_aggregate_v
297 = is_aggregate<T>::value; // C++17
298 template <class T> inline constexpr bool is_signed_v
299 = is_signed<T>::value; // C++17
300 template <class T> inline constexpr bool is_unsigned_v
301 = is_unsigned<T>::value; // C++17
302 template <class T, class... Args> inline constexpr bool is_constructible_v
303 = is_constructible<T, Args...>::value; // C++17
304 template <class T> inline constexpr bool is_default_constructible_v
305 = is_default_constructible<T>::value; // C++17
306 template <class T> inline constexpr bool is_copy_constructible_v
307 = is_copy_constructible<T>::value; // C++17
308 template <class T> inline constexpr bool is_move_constructible_v
309 = is_move_constructible<T>::value; // C++17
310 template <class T, class U> inline constexpr bool is_assignable_v
311 = is_assignable<T, U>::value; // C++17
312 template <class T> inline constexpr bool is_copy_assignable_v
313 = is_copy_assignable<T>::value; // C++17
314 template <class T> inline constexpr bool is_move_assignable_v
315 = is_move_assignable<T>::value; // C++17
316 template <class T, class U> inline constexpr bool is_swappable_with_v
317 = is_swappable_with<T, U>::value; // C++17
318 template <class T> inline constexpr bool is_swappable_v
319 = is_swappable<T>::value; // C++17
320 template <class T> inline constexpr bool is_destructible_v
321 = is_destructible<T>::value; // C++17
322 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
323 = is_trivially_constructible<T, Args...>::value; // C++17
324 template <class T> inline constexpr bool is_trivially_default_constructible_v
325 = is_trivially_default_constructible<T>::value; // C++17
326 template <class T> inline constexpr bool is_trivially_copy_constructible_v
327 = is_trivially_copy_constructible<T>::value; // C++17
328 template <class T> inline constexpr bool is_trivially_move_constructible_v
329 = is_trivially_move_constructible<T>::value; // C++17
330 template <class T, class U> inline constexpr bool is_trivially_assignable_v
331 = is_trivially_assignable<T, U>::value; // C++17
332 template <class T> inline constexpr bool is_trivially_copy_assignable_v
333 = is_trivially_copy_assignable<T>::value; // C++17
334 template <class T> inline constexpr bool is_trivially_move_assignable_v
335 = is_trivially_move_assignable<T>::value; // C++17
336 template <class T> inline constexpr bool is_trivially_destructible_v
337 = is_trivially_destructible<T>::value; // C++17
338 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
339 = is_nothrow_constructible<T, Args...>::value; // C++17
340 template <class T> inline constexpr bool is_nothrow_default_constructible_v
341 = is_nothrow_default_constructible<T>::value; // C++17
342 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
343 = is_nothrow_copy_constructible<T>::value; // C++17
344 template <class T> inline constexpr bool is_nothrow_move_constructible_v
345 = is_nothrow_move_constructible<T>::value; // C++17
346 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
347 = is_nothrow_assignable<T, U>::value; // C++17
348 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
349 = is_nothrow_copy_assignable<T>::value; // C++17
350 template <class T> inline constexpr bool is_nothrow_move_assignable_v
351 = is_nothrow_move_assignable<T>::value; // C++17
352 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
353 = is_nothrow_swappable_with<T, U>::value; // C++17
354 template <class T> inline constexpr bool is_nothrow_swappable_v
355 = is_nothrow_swappable<T>::value; // C++17
356 template <class T> inline constexpr bool is_nothrow_destructible_v
357 = is_nothrow_destructible<T>::value; // C++17
358 template <class T> inline constexpr bool has_virtual_destructor_v
359 = has_virtual_destructor<T>::value; // C++17
360 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
361 = has_unique_object_representations<T>::value;
363 // See C++14 20.10.5, type property queries
364 template <class T> inline constexpr size_t alignment_of_v
365 = alignment_of<T>::value; // C++17
366 template <class T> inline constexpr size_t rank_v
367 = rank<T>::value; // C++17
368 template <class T, unsigned I = 0> inline constexpr size_t extent_v
369 = extent<T, I>::value; // C++17
371 // See C++14 20.10.6, type relations
372 template <class T, class U> inline constexpr bool is_same_v
373 = is_same<T, U>::value; // C++17
374 template <class Base, class Derived> inline constexpr bool is_base_of_v
375 = is_base_of<Base, Derived>::value; // C++17
376 template <class From, class To> inline constexpr bool is_convertible_v
377 = is_convertible<From, To>::value; // C++17
378 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
379 = is_invocable<Fn, ArgTypes...>::value; // C++17
380 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
381 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
382 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
383 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
384 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
385 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
387 // [meta.logical], logical operator traits:
388 template<class... B> struct conjunction; // C++17
390 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
391 template<class... B> struct disjunction; // C++17
393 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
394 template<class B> struct negation; // C++17
396 inline constexpr bool negation_v = negation<B>::value; // C++17
404 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
405 #pragma GCC system_header
408 _LIBCPP_BEGIN_NAMESPACE_STD
410 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
411 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
412 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
415 struct __void_t { typedef void type; };
418 struct __identity { typedef _Tp type; };
420 template <class _Tp, bool>
421 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
423 template <bool _Bp, class _If, class _Then>
424 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
425 template <class _If, class _Then>
426 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
428 #if _LIBCPP_STD_VER > 11
429 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
432 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {};
433 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
435 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
436 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
438 #if _LIBCPP_STD_VER > 11
439 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
443 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
446 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
447 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
449 addressof(_Tp& __x) _NOEXCEPT
451 return __builtin_addressof(__x);
457 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
459 addressof(_Tp& __x) _NOEXCEPT
461 return reinterpret_cast<_Tp *>(
462 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
465 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
467 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
468 // Objective-C++ Automatic Reference Counting uses qualified pointers
469 // that require special addressof() signatures. When
470 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
471 // itself is providing these definitions. Otherwise, we provide them.
473 inline _LIBCPP_INLINE_VISIBILITY
475 addressof(__strong _Tp& __x) _NOEXCEPT
480 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
482 inline _LIBCPP_INLINE_VISIBILITY
484 addressof(__weak _Tp& __x) _NOEXCEPT
491 inline _LIBCPP_INLINE_VISIBILITY
493 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
499 inline _LIBCPP_INLINE_VISIBILITY
500 __unsafe_unretained _Tp*
501 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
507 #if !defined(_LIBCPP_CXX03_LANG)
508 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
511 struct __two {char __lx[2];};
515 template <class _Tp, _Tp __v>
516 struct _LIBCPP_TEMPLATE_VIS integral_constant
518 static _LIBCPP_CONSTEXPR const _Tp value = __v;
519 typedef _Tp value_type;
520 typedef integral_constant type;
521 _LIBCPP_INLINE_VISIBILITY
522 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
523 #if _LIBCPP_STD_VER > 11
524 _LIBCPP_INLINE_VISIBILITY
525 constexpr value_type operator ()() const _NOEXCEPT {return value;}
529 template <class _Tp, _Tp __v>
530 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
532 #if _LIBCPP_STD_VER > 14
534 using bool_constant = integral_constant<bool, __b>;
535 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
537 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
540 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
541 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
543 #if !defined(_LIBCPP_CXX03_LANG)
547 template <bool _Last, class ..._Preds>
548 struct __lazy_and_impl;
550 template <class ..._Preds>
551 struct __lazy_and_impl<false, _Preds...> : false_type {};
554 struct __lazy_and_impl<true> : true_type {};
556 template <class _Pred>
557 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
559 template <class _Hp, class ..._Tp>
560 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
562 template <class _P1, class ..._Pr>
563 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
567 template <bool _List, class ..._Preds>
568 struct __lazy_or_impl;
570 template <class ..._Preds>
571 struct __lazy_or_impl<true, _Preds...> : true_type {};
574 struct __lazy_or_impl<false> : false_type {};
576 template <class _Hp, class ..._Tp>
577 struct __lazy_or_impl<false, _Hp, _Tp...>
578 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
580 template <class _P1, class ..._Pr>
581 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
585 template <class _Pred>
586 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
589 template<class...> struct __and_;
590 template<> struct __and_<> : true_type {};
592 template<class _B0> struct __and_<_B0> : _B0 {};
594 template<class _B0, class _B1>
595 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
597 template<class _B0, class _B1, class _B2, class... _Bn>
598 struct __and_<_B0, _B1, _B2, _Bn...>
599 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
602 template<class...> struct __or_;
603 template<> struct __or_<> : false_type {};
605 template<class _B0> struct __or_<_B0> : _B0 {};
607 template<class _B0, class _B1>
608 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
610 template<class _B0, class _B1, class _B2, class... _Bn>
611 struct __or_<_B0, _B1, _B2, _Bn...>
612 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
616 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
618 #endif // !defined(_LIBCPP_CXX03_LANG)
622 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
623 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
625 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
627 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
628 = is_const<_Tp>::value;
633 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
634 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
636 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
638 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
639 = is_volatile<_Tp>::value;
644 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
645 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
646 #if _LIBCPP_STD_VER > 11
647 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
652 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
653 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
654 #if _LIBCPP_STD_VER > 11
655 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
660 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
661 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
662 #if _LIBCPP_STD_VER > 11
663 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
668 template <class _Tp> struct __libcpp_is_void : public false_type {};
669 template <> struct __libcpp_is_void<void> : public true_type {};
671 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
672 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
674 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
676 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
677 = is_void<_Tp>::value;
682 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
683 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
685 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
686 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
688 #if _LIBCPP_STD_VER > 11
689 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
690 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
692 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
694 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
695 = is_null_pointer<_Tp>::value;
701 template <class _Tp> struct __libcpp_is_integral : public false_type {};
702 template <> struct __libcpp_is_integral<bool> : public true_type {};
703 template <> struct __libcpp_is_integral<char> : public true_type {};
704 template <> struct __libcpp_is_integral<signed char> : public true_type {};
705 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
706 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
707 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
708 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
709 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
710 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
711 template <> struct __libcpp_is_integral<short> : public true_type {};
712 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
713 template <> struct __libcpp_is_integral<int> : public true_type {};
714 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
715 template <> struct __libcpp_is_integral<long> : public true_type {};
716 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
717 template <> struct __libcpp_is_integral<long long> : public true_type {};
718 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
719 #ifndef _LIBCPP_HAS_NO_INT128
720 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
721 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
724 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
725 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
727 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
729 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
730 = is_integral<_Tp>::value;
735 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
736 template <> struct __libcpp_is_floating_point<float> : public true_type {};
737 template <> struct __libcpp_is_floating_point<double> : public true_type {};
738 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
740 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
741 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
743 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
745 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
746 = is_floating_point<_Tp>::value;
751 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
752 : public false_type {};
753 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
754 : public true_type {};
755 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
756 : public true_type {};
758 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
760 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
761 = is_array<_Tp>::value;
766 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
767 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
769 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
770 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
772 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
774 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
775 = is_pointer<_Tp>::value;
780 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
781 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
783 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
784 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
785 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
788 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
789 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
790 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
794 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
796 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
797 = is_reference<_Tp>::value;
800 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
801 = is_lvalue_reference<_Tp>::value;
804 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
805 = is_rvalue_reference<_Tp>::value;
809 #if __has_feature(is_union) || (_GNUC_VER >= 403)
811 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
812 : public integral_constant<bool, __is_union(_Tp)> {};
816 template <class _Tp> struct __libcpp_union : public false_type {};
817 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
818 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
822 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
824 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
825 = is_union<_Tp>::value;
830 #if __has_feature(is_class) || (_GNUC_VER >= 403)
832 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
833 : public integral_constant<bool, __is_class(_Tp)> {};
837 namespace __is_class_imp
839 template <class _Tp> char __test(int _Tp::*);
840 template <class _Tp> __two __test(...);
843 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
844 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
848 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
850 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
851 = is_class<_Tp>::value;
856 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
857 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
859 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
860 template <class _Tp, class _Up>
861 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
862 = is_same<_Tp, _Up>::value;
867 namespace __libcpp_is_function_imp
869 struct __dummy_type {};
870 template <class _Tp> char __test(_Tp*);
871 template <class _Tp> char __test(__dummy_type);
872 template <class _Tp> __two __test(...);
873 template <class _Tp> _Tp& __source(int);
874 template <class _Tp> __dummy_type __source(...);
877 template <class _Tp, bool = is_class<_Tp>::value ||
878 is_union<_Tp>::value ||
879 is_void<_Tp>::value ||
880 is_reference<_Tp>::value ||
881 __is_nullptr_t<_Tp>::value >
882 struct __libcpp_is_function
883 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
885 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
887 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
888 : public __libcpp_is_function<_Tp> {};
890 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
892 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
893 = is_function<_Tp>::value;
896 // is_member_function_pointer
898 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
899 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
902 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
903 struct __member_pointer_traits_imp
904 { // forward declaration; specializations later
908 template <class _Tp> struct __libcpp_is_member_function_pointer
909 : public false_type {};
911 template <class _Ret, class _Class>
912 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
913 : public is_function<_Ret> {};
915 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
916 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
918 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
920 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
921 = is_member_function_pointer<_Tp>::value;
926 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
927 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
929 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
930 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
932 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
934 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
935 = is_member_pointer<_Tp>::value;
938 // is_member_object_pointer
940 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
941 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
942 !is_member_function_pointer<_Tp>::value> {};
944 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
946 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
947 = is_member_object_pointer<_Tp>::value;
952 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
954 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
955 : public integral_constant<bool, __is_enum(_Tp)> {};
959 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
960 : public integral_constant<bool, !is_void<_Tp>::value &&
961 !is_integral<_Tp>::value &&
962 !is_floating_point<_Tp>::value &&
963 !is_array<_Tp>::value &&
964 !is_pointer<_Tp>::value &&
965 !is_reference<_Tp>::value &&
966 !is_member_pointer<_Tp>::value &&
967 !is_union<_Tp>::value &&
968 !is_class<_Tp>::value &&
969 !is_function<_Tp>::value > {};
973 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
975 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
976 = is_enum<_Tp>::value;
981 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
982 : public integral_constant<bool, is_integral<_Tp>::value ||
983 is_floating_point<_Tp>::value> {};
985 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
987 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
988 = is_arithmetic<_Tp>::value;
993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
994 : public integral_constant<bool, is_void<_Tp>::value ||
995 __is_nullptr_t<_Tp>::value ||
996 is_arithmetic<_Tp>::value> {};
998 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1000 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1001 = is_fundamental<_Tp>::value;
1006 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1007 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1008 is_member_pointer<_Tp>::value ||
1009 is_pointer<_Tp>::value ||
1010 __is_nullptr_t<_Tp>::value ||
1011 is_enum<_Tp>::value > {};
1013 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1015 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1016 template <class _Tp>
1017 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1018 = is_scalar<_Tp>::value;
1023 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1024 : public integral_constant<bool, is_scalar<_Tp>::value ||
1025 is_array<_Tp>::value ||
1026 is_union<_Tp>::value ||
1027 is_class<_Tp>::value > {};
1029 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1030 template <class _Tp>
1031 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
1032 = is_object<_Tp>::value;
1037 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1038 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1040 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1041 template <class _Tp>
1042 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1043 = is_compound<_Tp>::value;
1047 // __is_referenceable [defns.referenceable]
1049 struct __is_referenceable_impl {
1050 template <class _Tp> static _Tp& __test(int);
1051 template <class _Tp> static __two __test(...);
1054 template <class _Tp>
1055 struct __is_referenceable : integral_constant<bool,
1056 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1061 template <class _Tp, bool = is_reference<_Tp>::value ||
1062 is_function<_Tp>::value ||
1063 is_const<_Tp>::value >
1064 struct __add_const {typedef _Tp type;};
1066 template <class _Tp>
1067 struct __add_const<_Tp, false> {typedef const _Tp type;};
1069 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1070 {typedef typename __add_const<_Tp>::type type;};
1072 #if _LIBCPP_STD_VER > 11
1073 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1078 template <class _Tp, bool = is_reference<_Tp>::value ||
1079 is_function<_Tp>::value ||
1080 is_volatile<_Tp>::value >
1081 struct __add_volatile {typedef _Tp type;};
1083 template <class _Tp>
1084 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1086 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1087 {typedef typename __add_volatile<_Tp>::type type;};
1089 #if _LIBCPP_STD_VER > 11
1090 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1095 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1096 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1098 #if _LIBCPP_STD_VER > 11
1099 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1104 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;};
1105 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;};
1106 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1107 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
1110 #if _LIBCPP_STD_VER > 11
1111 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1114 // add_lvalue_reference
1116 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1117 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1119 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1120 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1122 #if _LIBCPP_STD_VER > 11
1123 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1126 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1128 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1129 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1131 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1132 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1134 #if _LIBCPP_STD_VER > 11
1135 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1138 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1140 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1142 template <class _Tp> _Tp&& __declval(int);
1143 template <class _Tp> _Tp __declval(long);
1145 template <class _Tp>
1146 decltype(_VSTD::__declval<_Tp>(0))
1147 declval() _NOEXCEPT;
1149 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1151 template <class _Tp>
1152 typename add_lvalue_reference<_Tp>::type
1155 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1159 template <class _Tp>
1161 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1164 template <class _Tp>
1165 struct __unconstref {
1166 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1169 #ifndef _LIBCPP_CXX03_LANG
1170 template <class _Tp>
1171 using __uncvref_t = typename __uncvref<_Tp>::type;
1174 // __is_same_uncvref
1176 template <class _Tp, class _Up>
1177 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1178 typename __uncvref<_Up>::type> {};
1180 #if _LIBCPP_STD_VER > 17
1181 // aligned_union - same as __uncvref
1182 template <class _Tp>
1183 struct remove_cvref {
1184 using type = remove_cv_t<remove_reference_t<_Tp>>;
1187 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1198 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;};
1199 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
1200 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
1201 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
1202 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1204 #if _LIBCPP_STD_VER > 11
1205 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1210 template <class _Tp,
1211 bool = __is_referenceable<_Tp>::value ||
1212 is_same<typename remove_cv<_Tp>::type, void>::value>
1213 struct __add_pointer_impl
1214 {typedef typename remove_reference<_Tp>::type* type;};
1215 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1216 {typedef _Tp type;};
1218 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1219 {typedef typename __add_pointer_impl<_Tp>::type type;};
1221 #if _LIBCPP_STD_VER > 11
1222 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1227 template <class _Tp, bool = is_integral<_Tp>::value>
1228 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1230 template <class _Tp>
1231 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1233 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1234 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1236 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1238 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1240 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1241 template <class _Tp>
1242 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1243 = is_signed<_Tp>::value;
1248 template <class _Tp, bool = is_integral<_Tp>::value>
1249 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1251 template <class _Tp>
1252 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1254 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1255 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1257 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1259 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1261 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1262 template <class _Tp>
1263 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1264 = is_unsigned<_Tp>::value;
1269 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1270 : public integral_constant<size_t, 0> {};
1271 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1272 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1273 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1274 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1276 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1277 template <class _Tp>
1278 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1284 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1285 : public integral_constant<size_t, 0> {};
1286 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1287 : public integral_constant<size_t, 0> {};
1288 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1289 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1290 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1291 : public integral_constant<size_t, _Np> {};
1292 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1293 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1295 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1296 template <class _Tp, unsigned _Ip = 0>
1297 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1298 = extent<_Tp, _Ip>::value;
1303 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1304 {typedef _Tp type;};
1305 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1306 {typedef _Tp type;};
1307 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1308 {typedef _Tp type;};
1310 #if _LIBCPP_STD_VER > 11
1311 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1314 // remove_all_extents
1316 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1317 {typedef _Tp type;};
1318 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1319 {typedef typename remove_all_extents<_Tp>::type type;};
1320 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1321 {typedef typename remove_all_extents<_Tp>::type type;};
1323 #if _LIBCPP_STD_VER > 11
1324 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1329 template <class _Up, bool>
1331 typedef typename remove_cv<_Up>::type type;
1334 template <class _Up>
1335 struct __decay<_Up, true> {
1337 typedef typename conditional
1339 is_array<_Up>::value,
1340 typename remove_extent<_Up>::type*,
1341 typename conditional
1343 is_function<_Up>::value,
1344 typename add_pointer<_Up>::type,
1345 typename remove_cv<_Up>::type
1350 template <class _Tp>
1351 struct _LIBCPP_TEMPLATE_VIS decay
1354 typedef typename remove_reference<_Tp>::type _Up;
1356 typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1359 #if _LIBCPP_STD_VER > 11
1360 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1365 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1366 : public integral_constant<bool, __is_abstract(_Tp)> {};
1368 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1369 template <class _Tp>
1370 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1371 = is_abstract<_Tp>::value;
1376 #if defined(_LIBCPP_HAS_IS_FINAL)
1377 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1378 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1380 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1381 __libcpp_is_final : public false_type {};
1384 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1385 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1386 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1389 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1390 template <class _Tp>
1391 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1392 = is_final<_Tp>::value;
1396 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1398 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1399 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1401 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1402 template <class _Tp>
1403 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1404 = is_aggregate<_Tp>::value;
1407 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1411 #ifdef _LIBCPP_HAS_IS_BASE_OF
1413 template <class _Bp, class _Dp>
1414 struct _LIBCPP_TEMPLATE_VIS is_base_of
1415 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1417 #else // _LIBCPP_HAS_IS_BASE_OF
1419 namespace __is_base_of_imp
1421 template <class _Tp>
1424 _Dst(const volatile _Tp &);
1426 template <class _Tp>
1429 operator const volatile _Tp &();
1430 template <class _Up> operator const _Dst<_Up> &();
1432 template <size_t> struct __one { typedef char type; };
1433 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1434 template <class _Bp, class _Dp> __two __test(...);
1437 template <class _Bp, class _Dp>
1438 struct _LIBCPP_TEMPLATE_VIS is_base_of
1439 : public integral_constant<bool, is_class<_Bp>::value &&
1440 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1442 #endif // _LIBCPP_HAS_IS_BASE_OF
1444 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1445 template <class _Bp, class _Dp>
1446 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1447 = is_base_of<_Bp, _Dp>::value;
1452 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1454 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1455 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1456 !is_abstract<_T2>::value> {};
1458 #else // __has_feature(is_convertible_to)
1460 namespace __is_convertible_imp
1462 template <class _Tp> void __test_convert(_Tp);
1464 template <class _From, class _To, class = void>
1465 struct __is_convertible_test : public false_type {};
1467 template <class _From, class _To>
1468 struct __is_convertible_test<_From, _To,
1469 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1472 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1473 bool _IsFunction = is_function<_Tp>::value,
1474 bool _IsVoid = is_void<_Tp>::value>
1475 struct __is_array_function_or_void {enum {value = 0};};
1476 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1477 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1478 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1481 template <class _Tp,
1482 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1483 struct __is_convertible_check
1485 static const size_t __v = 0;
1488 template <class _Tp>
1489 struct __is_convertible_check<_Tp, 0>
1491 static const size_t __v = sizeof(_Tp);
1494 template <class _T1, class _T2,
1495 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1496 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1497 struct __is_convertible
1498 : public integral_constant<bool,
1499 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1500 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1501 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1502 && (!is_const<typename remove_reference<_T2>::type>::value
1503 || is_volatile<typename remove_reference<_T2>::type>::value)
1504 && (is_same<typename remove_cv<_T1>::type,
1505 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1506 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1511 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1512 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1513 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1514 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1516 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1517 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1518 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1519 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1521 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1522 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1523 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1524 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1526 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1527 : public __is_convertible<_T1, _T2>
1529 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1530 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1533 #endif // __has_feature(is_convertible_to)
1535 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1536 template <class _From, class _To>
1537 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1538 = is_convertible<_From, _To>::value;
1543 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1545 template <class _Tp>
1546 struct _LIBCPP_TEMPLATE_VIS is_empty
1547 : public integral_constant<bool, __is_empty(_Tp)> {};
1549 #else // __has_feature(is_empty)
1551 template <class _Tp>
1563 template <class _Tp, bool = is_class<_Tp>::value>
1564 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1566 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1568 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1570 #endif // __has_feature(is_empty)
1572 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1573 template <class _Tp>
1574 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1575 = is_empty<_Tp>::value;
1580 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1582 template <class _Tp>
1583 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1584 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1588 template<typename _Tp> char &__is_polymorphic_impl(
1589 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1591 template<typename _Tp> __two &__is_polymorphic_impl(...);
1593 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1594 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1596 #endif // __has_feature(is_polymorphic)
1598 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1599 template <class _Tp>
1600 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1601 = is_polymorphic<_Tp>::value;
1604 // has_virtual_destructor
1606 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1608 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1609 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1613 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1614 : public false_type {};
1618 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1619 template <class _Tp>
1620 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1621 = has_virtual_destructor<_Tp>::value;
1624 // has_unique_object_representations
1626 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1628 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1629 : public integral_constant<bool,
1630 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1632 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1633 template <class _Tp>
1634 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1635 = has_unique_object_representations<_Tp>::value;
1642 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1643 : public integral_constant<size_t, __alignof__(_Tp)> {};
1645 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1646 template <class _Tp>
1647 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1648 = alignment_of<_Tp>::value;
1653 template <class _Hp, class _Tp>
1662 #ifndef _LIBCPP_CXX03_LANG
1664 __nat(const __nat&) = delete;
1665 __nat& operator=(const __nat&) = delete;
1670 template <class _Tp>
1673 static const size_t value = alignment_of<_Tp>::value;
1677 struct __struct_double {long double __lx;};
1678 struct __struct_double4 {double __lx[4];};
1681 __type_list<__align_type<unsigned char>,
1682 __type_list<__align_type<unsigned short>,
1683 __type_list<__align_type<unsigned int>,
1684 __type_list<__align_type<unsigned long>,
1685 __type_list<__align_type<unsigned long long>,
1686 __type_list<__align_type<double>,
1687 __type_list<__align_type<long double>,
1688 __type_list<__align_type<__struct_double>,
1689 __type_list<__align_type<__struct_double4>,
1690 __type_list<__align_type<int*>,
1692 > > > > > > > > > > __all_types;
1694 template <class _TL, size_t _Align> struct __find_pod;
1696 template <class _Hp, size_t _Align>
1697 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1699 typedef typename conditional<
1700 _Align == _Hp::value,
1706 template <class _Hp, class _Tp, size_t _Align>
1707 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1709 typedef typename conditional<
1710 _Align == _Hp::value,
1712 typename __find_pod<_Tp, _Align>::type
1716 template <class _TL, size_t _Len> struct __find_max_align;
1718 template <class _Hp, size_t _Len>
1719 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1721 template <size_t _Len, size_t _A1, size_t _A2>
1722 struct __select_align
1725 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1726 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1728 static const size_t value = _Len < __max ? __min : __max;
1731 template <class _Hp, class _Tp, size_t _Len>
1732 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1733 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1735 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1736 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1738 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1739 static_assert(!is_void<_Aligner>::value, "");
1743 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1747 #if _LIBCPP_STD_VER > 11
1748 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1749 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1752 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1753 template <size_t _Len>\
1754 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1756 struct _ALIGNAS(n) type\
1758 unsigned char __lx[(_Len + n - 1)/n * n];\
1762 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1763 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1764 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1765 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1766 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1767 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1768 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1769 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1770 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1771 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1772 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1773 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1774 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1775 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1776 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1777 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1778 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1779 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1781 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1783 #ifndef _LIBCPP_HAS_NO_VARIADICS
1787 template <size_t _I0, size_t ..._In>
1788 struct __static_max;
1790 template <size_t _I0>
1791 struct __static_max<_I0>
1793 static const size_t value = _I0;
1796 template <size_t _I0, size_t _I1, size_t ..._In>
1797 struct __static_max<_I0, _I1, _In...>
1799 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1800 __static_max<_I1, _In...>::value;
1803 template <size_t _Len, class _Type0, class ..._Types>
1804 struct aligned_union
1806 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1807 __alignof__(_Types)...>::value;
1808 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1809 sizeof(_Types)...>::value;
1810 typedef typename aligned_storage<__len, alignment_value>::type type;
1813 #if _LIBCPP_STD_VER > 11
1814 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1817 #endif // _LIBCPP_HAS_NO_VARIADICS
1819 template <class _Tp>
1820 struct __numeric_type
1822 static void __test(...);
1823 static float __test(float);
1824 static double __test(char);
1825 static double __test(int);
1826 static double __test(unsigned);
1827 static double __test(long);
1828 static double __test(unsigned long);
1829 static double __test(long long);
1830 static double __test(unsigned long long);
1831 static double __test(double);
1832 static long double __test(long double);
1834 typedef decltype(__test(declval<_Tp>())) type;
1835 static const bool value = !is_same<type, void>::value;
1839 struct __numeric_type<void>
1841 static const bool value = true;
1846 template <class _A1, class _A2 = void, class _A3 = void,
1847 bool = __numeric_type<_A1>::value &&
1848 __numeric_type<_A2>::value &&
1849 __numeric_type<_A3>::value>
1853 static const bool value = false;
1856 template <class _A1, class _A2, class _A3>
1857 class __promote_imp<_A1, _A2, _A3, true>
1860 typedef typename __promote_imp<_A1>::type __type1;
1861 typedef typename __promote_imp<_A2>::type __type2;
1862 typedef typename __promote_imp<_A3>::type __type3;
1864 typedef decltype(__type1() + __type2() + __type3()) type;
1865 static const bool value = true;
1868 template <class _A1, class _A2>
1869 class __promote_imp<_A1, _A2, void, true>
1872 typedef typename __promote_imp<_A1>::type __type1;
1873 typedef typename __promote_imp<_A2>::type __type2;
1875 typedef decltype(__type1() + __type2()) type;
1876 static const bool value = true;
1879 template <class _A1>
1880 class __promote_imp<_A1, void, void, true>
1883 typedef typename __numeric_type<_A1>::type type;
1884 static const bool value = true;
1887 template <class _A1, class _A2 = void, class _A3 = void>
1888 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1890 // make_signed / make_unsigned
1893 __type_list<signed char,
1894 __type_list<signed short,
1895 __type_list<signed int,
1896 __type_list<signed long,
1897 __type_list<signed long long,
1898 #ifndef _LIBCPP_HAS_NO_INT128
1899 __type_list<__int128_t,
1902 #ifndef _LIBCPP_HAS_NO_INT128
1905 > > > > > __signed_types;
1908 __type_list<unsigned char,
1909 __type_list<unsigned short,
1910 __type_list<unsigned int,
1911 __type_list<unsigned long,
1912 __type_list<unsigned long long,
1913 #ifndef _LIBCPP_HAS_NO_INT128
1914 __type_list<__uint128_t,
1917 #ifndef _LIBCPP_HAS_NO_INT128
1920 > > > > > __unsigned_types;
1922 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1924 template <class _Hp, class _Tp, size_t _Size>
1925 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1930 template <class _Hp, class _Tp, size_t _Size>
1931 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1933 typedef typename __find_first<_Tp, _Size>::type type;
1936 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1937 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1943 template <class _Tp, class _Up>
1944 struct __apply_cv<_Tp, _Up, true, false>
1946 typedef const _Up type;
1949 template <class _Tp, class _Up>
1950 struct __apply_cv<_Tp, _Up, false, true>
1952 typedef volatile _Up type;
1955 template <class _Tp, class _Up>
1956 struct __apply_cv<_Tp, _Up, true, true>
1958 typedef const volatile _Up type;
1961 template <class _Tp, class _Up>
1962 struct __apply_cv<_Tp&, _Up, false, false>
1967 template <class _Tp, class _Up>
1968 struct __apply_cv<_Tp&, _Up, true, false>
1970 typedef const _Up& type;
1973 template <class _Tp, class _Up>
1974 struct __apply_cv<_Tp&, _Up, false, true>
1976 typedef volatile _Up& type;
1979 template <class _Tp, class _Up>
1980 struct __apply_cv<_Tp&, _Up, true, true>
1982 typedef const volatile _Up& type;
1985 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1986 struct __make_signed {};
1988 template <class _Tp>
1989 struct __make_signed<_Tp, true>
1991 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1994 template <> struct __make_signed<bool, true> {};
1995 template <> struct __make_signed< signed short, true> {typedef short type;};
1996 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1997 template <> struct __make_signed< signed int, true> {typedef int type;};
1998 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1999 template <> struct __make_signed< signed long, true> {typedef long type;};
2000 template <> struct __make_signed<unsigned long, true> {typedef long type;};
2001 template <> struct __make_signed< signed long long, true> {typedef long long type;};
2002 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2003 #ifndef _LIBCPP_HAS_NO_INT128
2004 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2005 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2008 template <class _Tp>
2009 struct _LIBCPP_TEMPLATE_VIS make_signed
2011 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2014 #if _LIBCPP_STD_VER > 11
2015 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2018 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2019 struct __make_unsigned {};
2021 template <class _Tp>
2022 struct __make_unsigned<_Tp, true>
2024 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2027 template <> struct __make_unsigned<bool, true> {};
2028 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2029 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2030 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2031 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2032 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2033 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2034 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2035 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2036 #ifndef _LIBCPP_HAS_NO_INT128
2037 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2038 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2041 template <class _Tp>
2042 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2044 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2047 #if _LIBCPP_STD_VER > 11
2048 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2051 #ifdef _LIBCPP_HAS_NO_VARIADICS
2053 template <class _Tp, class _Up = void, class _Vp = void>
2054 struct _LIBCPP_TEMPLATE_VIS common_type
2057 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
2061 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void>
2067 template <class _Tp>
2068 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
2071 typedef typename common_type<_Tp, _Tp>::type type;
2074 template <class _Tp, class _Up>
2075 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
2077 typedef typename decay<decltype(
2078 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2082 #else // _LIBCPP_HAS_NO_VARIADICS
2084 // bullet 1 - sizeof...(Tp) == 0
2086 template <class ..._Tp>
2087 struct _LIBCPP_TEMPLATE_VIS common_type {};
2089 // bullet 2 - sizeof...(Tp) == 1
2091 template <class _Tp>
2092 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2093 : public common_type<_Tp, _Tp> {};
2095 // bullet 3 - sizeof...(Tp) == 2
2097 template <class _Tp, class _Up, class = void>
2098 struct __common_type2_imp {};
2100 template <class _Tp, class _Up>
2101 struct __common_type2_imp<_Tp, _Up,
2102 typename __void_t<decltype(
2103 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2106 typedef typename decay<decltype(
2107 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2111 template <class _Tp, class _Up,
2112 class _DTp = typename decay<_Tp>::type,
2113 class _DUp = typename decay<_Up>::type>
2114 using __common_type2 =
2115 typename conditional<
2116 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
2117 __common_type2_imp<_Tp, _Up>,
2118 common_type<_DTp, _DUp>
2121 template <class _Tp, class _Up>
2122 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2123 : __common_type2<_Tp, _Up> {};
2125 // bullet 4 - sizeof...(Tp) > 2
2127 template <class ...Tp> struct __common_types;
2129 template <class, class = void>
2130 struct __common_type_impl {};
2132 template <class _Tp, class _Up>
2133 struct __common_type_impl<
2134 __common_types<_Tp, _Up>,
2135 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2137 typedef typename common_type<_Tp, _Up>::type type;
2140 template <class _Tp, class _Up, class ..._Vp>
2141 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2142 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2143 : __common_type_impl<
2144 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
2149 template <class _Tp, class _Up, class ..._Vp>
2150 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
2151 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2153 #if _LIBCPP_STD_VER > 11
2154 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2157 #endif // _LIBCPP_HAS_NO_VARIADICS
2161 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2163 template <class _Tp, class _Arg>
2164 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2165 __is_assignable_test(int);
2167 template <class, class>
2168 false_type __is_assignable_test(...);
2171 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2172 struct __is_assignable_imp
2173 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2175 template <class _Tp, class _Arg>
2176 struct __is_assignable_imp<_Tp, _Arg, true>
2181 template <class _Tp, class _Arg>
2182 struct is_assignable
2183 : public __is_assignable_imp<_Tp, _Arg> {};
2185 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2186 template <class _Tp, class _Arg>
2187 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2188 = is_assignable<_Tp, _Arg>::value;
2191 // is_copy_assignable
2193 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2194 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2195 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2197 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2198 template <class _Tp>
2199 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2200 = is_copy_assignable<_Tp>::value;
2203 // is_move_assignable
2205 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2206 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2207 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2208 typename add_rvalue_reference<_Tp>::type> {};
2210 : public is_copy_assignable<_Tp> {};
2213 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2214 template <class _Tp>
2215 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2216 = is_move_assignable<_Tp>::value;
2221 // if it's a reference, return true
2222 // if it's a function, return false
2223 // if it's void, return false
2224 // if it's an array of unknown bound, return false
2225 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2226 // where _Up is remove_all_extents<_Tp>::type
2229 struct __is_destructible_apply { typedef int type; };
2231 template <typename _Tp>
2232 struct __is_destructor_wellformed {
2233 template <typename _Tp1>
2234 static char __test (
2235 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2238 template <typename _Tp1>
2239 static __two __test (...);
2241 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2244 template <class _Tp, bool>
2245 struct __destructible_imp;
2247 template <class _Tp>
2248 struct __destructible_imp<_Tp, false>
2249 : public _VSTD::integral_constant<bool,
2250 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2252 template <class _Tp>
2253 struct __destructible_imp<_Tp, true>
2254 : public _VSTD::true_type {};
2256 template <class _Tp, bool>
2257 struct __destructible_false;
2259 template <class _Tp>
2260 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2262 template <class _Tp>
2263 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2265 template <class _Tp>
2266 struct is_destructible
2267 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2269 template <class _Tp>
2270 struct is_destructible<_Tp[]>
2271 : public _VSTD::false_type {};
2274 struct is_destructible<void>
2275 : public _VSTD::false_type {};
2277 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2278 template <class _Tp>
2279 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2280 = is_destructible<_Tp>::value;
2285 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2287 template <class _Tp>
2288 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2289 typename remove_reference<_Tp>::type&&
2290 move(_Tp&& __t) _NOEXCEPT
2292 typedef typename remove_reference<_Tp>::type _Up;
2293 return static_cast<_Up&&>(__t);
2296 template <class _Tp>
2297 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2299 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2301 return static_cast<_Tp&&>(__t);
2304 template <class _Tp>
2305 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2307 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2309 static_assert(!is_lvalue_reference<_Tp>::value,
2310 "can not forward an rvalue as an lvalue");
2311 return static_cast<_Tp&&>(__t);
2314 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2316 template <class _Tp>
2317 inline _LIBCPP_INLINE_VISIBILITY
2324 template <class _Tp>
2325 inline _LIBCPP_INLINE_VISIBILITY
2327 move(const _Tp& __t)
2332 template <class _Tp>
2333 inline _LIBCPP_INLINE_VISIBILITY
2335 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2341 template <class _Tp>
2344 typedef typename remove_reference<_Tp>::type _Trr;
2347 _LIBCPP_INLINE_VISIBILITY
2348 _Trr* operator->() {return &t_;}
2349 _LIBCPP_INLINE_VISIBILITY
2350 explicit __rv(_Trr& __t) : t_(__t) {}
2353 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2355 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2357 template <class _Tp>
2358 inline _LIBCPP_INLINE_VISIBILITY
2359 typename decay<_Tp>::type
2360 __decay_copy(_Tp&& __t)
2362 return _VSTD::forward<_Tp>(__t);
2367 template <class _Tp>
2368 inline _LIBCPP_INLINE_VISIBILITY
2369 typename decay<_Tp>::type
2370 __decay_copy(const _Tp& __t)
2372 return _VSTD::forward<_Tp>(__t);
2377 #ifndef _LIBCPP_HAS_NO_VARIADICS
2379 template <class _Rp, class _Class, class ..._Param>
2380 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2382 typedef _Class _ClassType;
2383 typedef _Rp _ReturnType;
2384 typedef _Rp (_FnType) (_Param...);
2387 template <class _Rp, class _Class, class ..._Param>
2388 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2390 typedef _Class _ClassType;
2391 typedef _Rp _ReturnType;
2392 typedef _Rp (_FnType) (_Param..., ...);
2395 template <class _Rp, class _Class, class ..._Param>
2396 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2398 typedef _Class const _ClassType;
2399 typedef _Rp _ReturnType;
2400 typedef _Rp (_FnType) (_Param...);
2403 template <class _Rp, class _Class, class ..._Param>
2404 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2406 typedef _Class const _ClassType;
2407 typedef _Rp _ReturnType;
2408 typedef _Rp (_FnType) (_Param..., ...);
2411 template <class _Rp, class _Class, class ..._Param>
2412 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2414 typedef _Class volatile _ClassType;
2415 typedef _Rp _ReturnType;
2416 typedef _Rp (_FnType) (_Param...);
2419 template <class _Rp, class _Class, class ..._Param>
2420 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2422 typedef _Class volatile _ClassType;
2423 typedef _Rp _ReturnType;
2424 typedef _Rp (_FnType) (_Param..., ...);
2427 template <class _Rp, class _Class, class ..._Param>
2428 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2430 typedef _Class const volatile _ClassType;
2431 typedef _Rp _ReturnType;
2432 typedef _Rp (_FnType) (_Param...);
2435 template <class _Rp, class _Class, class ..._Param>
2436 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2438 typedef _Class const volatile _ClassType;
2439 typedef _Rp _ReturnType;
2440 typedef _Rp (_FnType) (_Param..., ...);
2443 #if __has_feature(cxx_reference_qualified_functions) || \
2444 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2446 template <class _Rp, class _Class, class ..._Param>
2447 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2449 typedef _Class& _ClassType;
2450 typedef _Rp _ReturnType;
2451 typedef _Rp (_FnType) (_Param...);
2454 template <class _Rp, class _Class, class ..._Param>
2455 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2457 typedef _Class& _ClassType;
2458 typedef _Rp _ReturnType;
2459 typedef _Rp (_FnType) (_Param..., ...);
2462 template <class _Rp, class _Class, class ..._Param>
2463 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2465 typedef _Class const& _ClassType;
2466 typedef _Rp _ReturnType;
2467 typedef _Rp (_FnType) (_Param...);
2470 template <class _Rp, class _Class, class ..._Param>
2471 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2473 typedef _Class const& _ClassType;
2474 typedef _Rp _ReturnType;
2475 typedef _Rp (_FnType) (_Param..., ...);
2478 template <class _Rp, class _Class, class ..._Param>
2479 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2481 typedef _Class volatile& _ClassType;
2482 typedef _Rp _ReturnType;
2483 typedef _Rp (_FnType) (_Param...);
2486 template <class _Rp, class _Class, class ..._Param>
2487 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2489 typedef _Class volatile& _ClassType;
2490 typedef _Rp _ReturnType;
2491 typedef _Rp (_FnType) (_Param..., ...);
2494 template <class _Rp, class _Class, class ..._Param>
2495 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2497 typedef _Class const volatile& _ClassType;
2498 typedef _Rp _ReturnType;
2499 typedef _Rp (_FnType) (_Param...);
2502 template <class _Rp, class _Class, class ..._Param>
2503 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2505 typedef _Class const volatile& _ClassType;
2506 typedef _Rp _ReturnType;
2507 typedef _Rp (_FnType) (_Param..., ...);
2510 template <class _Rp, class _Class, class ..._Param>
2511 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2513 typedef _Class&& _ClassType;
2514 typedef _Rp _ReturnType;
2515 typedef _Rp (_FnType) (_Param...);
2518 template <class _Rp, class _Class, class ..._Param>
2519 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2521 typedef _Class&& _ClassType;
2522 typedef _Rp _ReturnType;
2523 typedef _Rp (_FnType) (_Param..., ...);
2526 template <class _Rp, class _Class, class ..._Param>
2527 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2529 typedef _Class const&& _ClassType;
2530 typedef _Rp _ReturnType;
2531 typedef _Rp (_FnType) (_Param...);
2534 template <class _Rp, class _Class, class ..._Param>
2535 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2537 typedef _Class const&& _ClassType;
2538 typedef _Rp _ReturnType;
2539 typedef _Rp (_FnType) (_Param..., ...);
2542 template <class _Rp, class _Class, class ..._Param>
2543 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2545 typedef _Class volatile&& _ClassType;
2546 typedef _Rp _ReturnType;
2547 typedef _Rp (_FnType) (_Param...);
2550 template <class _Rp, class _Class, class ..._Param>
2551 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2553 typedef _Class volatile&& _ClassType;
2554 typedef _Rp _ReturnType;
2555 typedef _Rp (_FnType) (_Param..., ...);
2558 template <class _Rp, class _Class, class ..._Param>
2559 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2561 typedef _Class const volatile&& _ClassType;
2562 typedef _Rp _ReturnType;
2563 typedef _Rp (_FnType) (_Param...);
2566 template <class _Rp, class _Class, class ..._Param>
2567 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2569 typedef _Class const volatile&& _ClassType;
2570 typedef _Rp _ReturnType;
2571 typedef _Rp (_FnType) (_Param..., ...);
2574 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2576 #else // _LIBCPP_HAS_NO_VARIADICS
2578 template <class _Rp, class _Class>
2579 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2581 typedef _Class _ClassType;
2582 typedef _Rp _ReturnType;
2583 typedef _Rp (_FnType) ();
2586 template <class _Rp, class _Class>
2587 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2589 typedef _Class _ClassType;
2590 typedef _Rp _ReturnType;
2591 typedef _Rp (_FnType) (...);
2594 template <class _Rp, class _Class, class _P0>
2595 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2597 typedef _Class _ClassType;
2598 typedef _Rp _ReturnType;
2599 typedef _Rp (_FnType) (_P0);
2602 template <class _Rp, class _Class, class _P0>
2603 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2605 typedef _Class _ClassType;
2606 typedef _Rp _ReturnType;
2607 typedef _Rp (_FnType) (_P0, ...);
2610 template <class _Rp, class _Class, class _P0, class _P1>
2611 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2613 typedef _Class _ClassType;
2614 typedef _Rp _ReturnType;
2615 typedef _Rp (_FnType) (_P0, _P1);
2618 template <class _Rp, class _Class, class _P0, class _P1>
2619 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2621 typedef _Class _ClassType;
2622 typedef _Rp _ReturnType;
2623 typedef _Rp (_FnType) (_P0, _P1, ...);
2626 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2627 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2629 typedef _Class _ClassType;
2630 typedef _Rp _ReturnType;
2631 typedef _Rp (_FnType) (_P0, _P1, _P2);
2634 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2635 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2637 typedef _Class _ClassType;
2638 typedef _Rp _ReturnType;
2639 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2642 template <class _Rp, class _Class>
2643 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2645 typedef _Class const _ClassType;
2646 typedef _Rp _ReturnType;
2647 typedef _Rp (_FnType) ();
2650 template <class _Rp, class _Class>
2651 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2653 typedef _Class const _ClassType;
2654 typedef _Rp _ReturnType;
2655 typedef _Rp (_FnType) (...);
2658 template <class _Rp, class _Class, class _P0>
2659 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2661 typedef _Class const _ClassType;
2662 typedef _Rp _ReturnType;
2663 typedef _Rp (_FnType) (_P0);
2666 template <class _Rp, class _Class, class _P0>
2667 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2669 typedef _Class const _ClassType;
2670 typedef _Rp _ReturnType;
2671 typedef _Rp (_FnType) (_P0, ...);
2674 template <class _Rp, class _Class, class _P0, class _P1>
2675 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2677 typedef _Class const _ClassType;
2678 typedef _Rp _ReturnType;
2679 typedef _Rp (_FnType) (_P0, _P1);
2682 template <class _Rp, class _Class, class _P0, class _P1>
2683 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2685 typedef _Class const _ClassType;
2686 typedef _Rp _ReturnType;
2687 typedef _Rp (_FnType) (_P0, _P1, ...);
2690 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2691 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2693 typedef _Class const _ClassType;
2694 typedef _Rp _ReturnType;
2695 typedef _Rp (_FnType) (_P0, _P1, _P2);
2698 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2699 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2701 typedef _Class const _ClassType;
2702 typedef _Rp _ReturnType;
2703 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2706 template <class _Rp, class _Class>
2707 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2709 typedef _Class volatile _ClassType;
2710 typedef _Rp _ReturnType;
2711 typedef _Rp (_FnType) ();
2714 template <class _Rp, class _Class>
2715 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2717 typedef _Class volatile _ClassType;
2718 typedef _Rp _ReturnType;
2719 typedef _Rp (_FnType) (...);
2722 template <class _Rp, class _Class, class _P0>
2723 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2725 typedef _Class volatile _ClassType;
2726 typedef _Rp _ReturnType;
2727 typedef _Rp (_FnType) (_P0);
2730 template <class _Rp, class _Class, class _P0>
2731 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2733 typedef _Class volatile _ClassType;
2734 typedef _Rp _ReturnType;
2735 typedef _Rp (_FnType) (_P0, ...);
2738 template <class _Rp, class _Class, class _P0, class _P1>
2739 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2741 typedef _Class volatile _ClassType;
2742 typedef _Rp _ReturnType;
2743 typedef _Rp (_FnType) (_P0, _P1);
2746 template <class _Rp, class _Class, class _P0, class _P1>
2747 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2749 typedef _Class volatile _ClassType;
2750 typedef _Rp _ReturnType;
2751 typedef _Rp (_FnType) (_P0, _P1, ...);
2754 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2755 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2757 typedef _Class volatile _ClassType;
2758 typedef _Rp _ReturnType;
2759 typedef _Rp (_FnType) (_P0, _P1, _P2);
2762 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2763 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2765 typedef _Class volatile _ClassType;
2766 typedef _Rp _ReturnType;
2767 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2770 template <class _Rp, class _Class>
2771 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2773 typedef _Class const volatile _ClassType;
2774 typedef _Rp _ReturnType;
2775 typedef _Rp (_FnType) ();
2778 template <class _Rp, class _Class>
2779 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2781 typedef _Class const volatile _ClassType;
2782 typedef _Rp _ReturnType;
2783 typedef _Rp (_FnType) (...);
2786 template <class _Rp, class _Class, class _P0>
2787 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2789 typedef _Class const volatile _ClassType;
2790 typedef _Rp _ReturnType;
2791 typedef _Rp (_FnType) (_P0);
2794 template <class _Rp, class _Class, class _P0>
2795 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2797 typedef _Class const volatile _ClassType;
2798 typedef _Rp _ReturnType;
2799 typedef _Rp (_FnType) (_P0, ...);
2802 template <class _Rp, class _Class, class _P0, class _P1>
2803 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2805 typedef _Class const volatile _ClassType;
2806 typedef _Rp _ReturnType;
2807 typedef _Rp (_FnType) (_P0, _P1);
2810 template <class _Rp, class _Class, class _P0, class _P1>
2811 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2813 typedef _Class const volatile _ClassType;
2814 typedef _Rp _ReturnType;
2815 typedef _Rp (_FnType) (_P0, _P1, ...);
2818 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2819 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2821 typedef _Class const volatile _ClassType;
2822 typedef _Rp _ReturnType;
2823 typedef _Rp (_FnType) (_P0, _P1, _P2);
2826 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2827 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2829 typedef _Class const volatile _ClassType;
2830 typedef _Rp _ReturnType;
2831 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2834 #endif // _LIBCPP_HAS_NO_VARIADICS
2836 template <class _Rp, class _Class>
2837 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2839 typedef _Class _ClassType;
2840 typedef _Rp _ReturnType;
2843 template <class _MP>
2844 struct __member_pointer_traits
2845 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2846 is_member_function_pointer<_MP>::value,
2847 is_member_object_pointer<_MP>::value>
2849 // typedef ... _ClassType;
2850 // typedef ... _ReturnType;
2851 // typedef ... _FnType;
2855 template <class _DecayedFp>
2856 struct __member_pointer_class_type {};
2858 template <class _Ret, class _ClassType>
2859 struct __member_pointer_class_type<_Ret _ClassType::*> {
2860 typedef _ClassType type;
2865 template <class _Callable> class result_of;
2867 #ifdef _LIBCPP_HAS_NO_VARIADICS
2869 template <class _Fn, bool, bool>
2874 template <class _Fn>
2875 class __result_of<_Fn(), true, false>
2878 typedef decltype(declval<_Fn>()()) type;
2881 template <class _Fn, class _A0>
2882 class __result_of<_Fn(_A0), true, false>
2885 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2888 template <class _Fn, class _A0, class _A1>
2889 class __result_of<_Fn(_A0, _A1), true, false>
2892 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2895 template <class _Fn, class _A0, class _A1, class _A2>
2896 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2899 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2902 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2903 struct __result_of_mp;
2905 // member function pointer
2907 template <class _MP, class _Tp>
2908 struct __result_of_mp<_MP, _Tp, true>
2909 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2913 // member data pointer
2915 template <class _MP, class _Tp, bool>
2916 struct __result_of_mdp;
2918 template <class _Rp, class _Class, class _Tp>
2919 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2921 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2924 template <class _Rp, class _Class, class _Tp>
2925 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2927 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2930 template <class _Rp, class _Class, class _Tp>
2931 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2932 : public __result_of_mdp<_Rp _Class::*, _Tp,
2933 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2939 template <class _Fn, class _Tp>
2940 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2941 : public __result_of_mp<typename remove_reference<_Fn>::type,
2943 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2947 template <class _Fn, class _Tp, class _A0>
2948 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2949 : public __result_of_mp<typename remove_reference<_Fn>::type,
2951 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2955 template <class _Fn, class _Tp, class _A0, class _A1>
2956 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2957 : public __result_of_mp<typename remove_reference<_Fn>::type,
2959 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2963 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2964 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2965 : public __result_of_mp<typename remove_reference<_Fn>::type,
2967 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2973 template <class _Fn>
2974 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2975 : public __result_of<_Fn(),
2976 is_class<typename remove_reference<_Fn>::type>::value ||
2977 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2978 is_member_pointer<typename remove_reference<_Fn>::type>::value
2983 template <class _Fn, class _A0>
2984 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2985 : public __result_of<_Fn(_A0),
2986 is_class<typename remove_reference<_Fn>::type>::value ||
2987 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2988 is_member_pointer<typename remove_reference<_Fn>::type>::value
2993 template <class _Fn, class _A0, class _A1>
2994 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2995 : public __result_of<_Fn(_A0, _A1),
2996 is_class<typename remove_reference<_Fn>::type>::value ||
2997 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2998 is_member_pointer<typename remove_reference<_Fn>::type>::value
3003 template <class _Fn, class _A0, class _A1, class _A2>
3004 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
3005 : public __result_of<_Fn(_A0, _A1, _A2),
3006 is_class<typename remove_reference<_Fn>::type>::value ||
3007 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3008 is_member_pointer<typename remove_reference<_Fn>::type>::value
3013 #endif // _LIBCPP_HAS_NO_VARIADICS
3015 // template <class T, class... Args> struct is_constructible;
3017 namespace __is_construct
3022 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
3023 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
3025 template <class _Tp, class... _Args>
3026 struct __libcpp_is_constructible;
3028 template <class _To, class _From>
3029 struct __is_invalid_base_to_derived_cast {
3030 static_assert(is_reference<_To>::value, "Wrong specialization");
3031 using _RawFrom = __uncvref_t<_From>;
3032 using _RawTo = __uncvref_t<_To>;
3033 static const bool value = __lazy_and<
3034 __lazy_not<is_same<_RawFrom, _RawTo>>,
3035 is_base_of<_RawFrom, _RawTo>,
3036 __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
3040 template <class _To, class _From>
3041 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
3042 static_assert(is_reference<_To>::value, "Wrong specialization");
3045 template <class _ToRef, class _FromRef>
3046 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
3047 using _RawFrom = __uncvref_t<_FromRef>;
3048 using _RawTo = __uncvref_t<_ToRef>;
3049 static const bool value = __lazy_and<
3050 __lazy_not<is_function<_RawTo>>,
3052 is_same<_RawFrom, _RawTo>,
3053 is_base_of<_RawTo, _RawFrom>>
3057 struct __is_constructible_helper
3059 template <class _To>
3060 static void __eat(_To);
3062 // This overload is needed to work around a Clang bug that disallows
3063 // static_cast<T&&>(e) for non-reference-compatible types.
3064 // Example: static_cast<int&&>(declval<double>());
3065 // NOTE: The static_cast implementation below is required to support
3066 // classes with explicit conversion operators.
3067 template <class _To, class _From,
3068 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
3069 static true_type __test_cast(int);
3071 template <class _To, class _From,
3072 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
3073 static integral_constant<bool,
3074 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
3075 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
3076 > __test_cast(long);
3078 template <class, class>
3079 static false_type __test_cast(...);
3081 template <class _Tp, class ..._Args,
3082 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
3083 static true_type __test_nary(int);
3084 template <class _Tp, class...>
3085 static false_type __test_nary(...);
3087 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
3088 static is_destructible<_Tp> __test_unary(int);
3089 template <class, class>
3090 static false_type __test_unary(...);
3093 template <class _Tp, bool = is_void<_Tp>::value>
3094 struct __is_default_constructible
3095 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
3098 template <class _Tp>
3099 struct __is_default_constructible<_Tp, true> : false_type {};
3101 template <class _Tp>
3102 struct __is_default_constructible<_Tp[], false> : false_type {};
3104 template <class _Tp, size_t _Nx>
3105 struct __is_default_constructible<_Tp[_Nx], false>
3106 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3108 template <class _Tp, class... _Args>
3109 struct __libcpp_is_constructible
3111 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3112 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3116 template <class _Tp>
3117 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3119 template <class _Tp, class _A0>
3120 struct __libcpp_is_constructible<_Tp, _A0>
3121 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3124 template <class _Tp, class _A0>
3125 struct __libcpp_is_constructible<_Tp&, _A0>
3126 : public decltype(__is_constructible_helper::
3127 __test_cast<_Tp&, _A0>(0))
3130 template <class _Tp, class _A0>
3131 struct __libcpp_is_constructible<_Tp&&, _A0>
3132 : public decltype(__is_constructible_helper::
3133 __test_cast<_Tp&&, _A0>(0))
3138 #if __has_feature(is_constructible)
3139 template <class _Tp, class ..._Args>
3140 struct _LIBCPP_TEMPLATE_VIS is_constructible
3141 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3143 #elif !defined(_LIBCPP_CXX03_LANG)
3144 template <class _Tp, class... _Args>
3145 struct _LIBCPP_TEMPLATE_VIS is_constructible
3146 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3148 // template <class T> struct is_constructible0;
3150 // main is_constructible0 test
3152 template <class _Tp>
3153 decltype((_Tp(), true_type()))
3154 __is_constructible0_test(_Tp&);
3157 __is_constructible0_test(__any);
3159 template <class _Tp, class _A0>
3160 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3161 __is_constructible1_test(_Tp&, _A0&);
3163 template <class _A0>
3165 __is_constructible1_test(__any, _A0&);
3167 template <class _Tp, class _A0, class _A1>
3168 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3169 __is_constructible2_test(_Tp&, _A0&, _A1&);
3171 template <class _A0, class _A1>
3173 __is_constructible2_test(__any, _A0&, _A1&);
3175 template <class _Tp, class _A0, class _A1, class _A2>
3176 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type()))
3177 __is_constructible3_test(_Tp&, _A0&, _A1&, _A2&);
3179 template <class _A0, class _A1, class _A2>
3181 __is_constructible3_test(__any, _A0&, _A1&, _A2&);
3183 template <bool, class _Tp>
3184 struct __is_constructible0_imp // false, _Tp is not a scalar
3185 : public common_type
3187 decltype(__is_constructible0_test(declval<_Tp&>()))
3191 template <bool, class _Tp, class _A0>
3192 struct __is_constructible1_imp // false, _Tp is not a scalar
3193 : public common_type
3195 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3199 template <bool, class _Tp, class _A0, class _A1>
3200 struct __is_constructible2_imp // false, _Tp is not a scalar
3201 : public common_type
3203 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3207 template <bool, class _Tp, class _A0, class _A1, class _A2>
3208 struct __is_constructible3_imp // false, _Tp is not a scalar
3209 : public common_type
3211 decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>()))
3215 // handle scalars and reference types
3217 // Scalars are default constructible, references are not
3219 template <class _Tp>
3220 struct __is_constructible0_imp<true, _Tp>
3221 : public is_scalar<_Tp>
3224 template <class _Tp, class _A0>
3225 struct __is_constructible1_imp<true, _Tp, _A0>
3226 : public is_convertible<_A0, _Tp>
3229 template <class _Tp, class _A0, class _A1>
3230 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3234 template <class _Tp, class _A0, class _A1, class _A2>
3235 struct __is_constructible3_imp<true, _Tp, _A0, _A1, _A2>
3239 // Treat scalars and reference types separately
3241 template <bool, class _Tp>
3242 struct __is_constructible0_void_check
3243 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3247 template <bool, class _Tp, class _A0>
3248 struct __is_constructible1_void_check
3249 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3253 template <bool, class _Tp, class _A0, class _A1>
3254 struct __is_constructible2_void_check
3255 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3259 template <bool, class _Tp, class _A0, class _A1, class _A2>
3260 struct __is_constructible3_void_check
3261 : public __is_constructible3_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3265 // If any of T or Args is void, is_constructible should be false
3267 template <class _Tp>
3268 struct __is_constructible0_void_check<true, _Tp>
3272 template <class _Tp, class _A0>
3273 struct __is_constructible1_void_check<true, _Tp, _A0>
3277 template <class _Tp, class _A0, class _A1>
3278 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3282 template <class _Tp, class _A0, class _A1, class _A2>
3283 struct __is_constructible3_void_check<true, _Tp, _A0, _A1, _A2>
3287 // is_constructible entry point
3289 template <class _Tp, class _A0 = __is_construct::__nat,
3290 class _A1 = __is_construct::__nat,
3291 class _A2 = __is_construct::__nat>
3292 struct _LIBCPP_TEMPLATE_VIS is_constructible
3293 : public __is_constructible3_void_check<is_void<_Tp>::value
3294 || is_abstract<_Tp>::value
3295 || is_function<_Tp>::value
3296 || is_void<_A0>::value
3297 || is_void<_A1>::value
3298 || is_void<_A2>::value,
3302 template <class _Tp>
3303 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3304 : public __is_constructible0_void_check<is_void<_Tp>::value
3305 || is_abstract<_Tp>::value
3306 || is_function<_Tp>::value,
3310 template <class _Tp, class _A0>
3311 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
3312 : public __is_constructible1_void_check<is_void<_Tp>::value
3313 || is_abstract<_Tp>::value
3314 || is_function<_Tp>::value
3315 || is_void<_A0>::value,
3319 template <class _Tp, class _A0, class _A1>
3320 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, _A1, __is_construct::__nat>
3321 : public __is_constructible2_void_check<is_void<_Tp>::value
3322 || is_abstract<_Tp>::value
3323 || is_function<_Tp>::value
3324 || is_void<_A0>::value
3325 || is_void<_A1>::value,
3329 // Array types are default constructible if their element type
3330 // is default constructible
3332 template <class _Ap, size_t _Np>
3333 struct __is_constructible0_imp<false, _Ap[_Np]>
3334 : public is_constructible<typename remove_all_extents<_Ap>::type>
3337 template <class _Ap, size_t _Np, class _A0>
3338 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3342 template <class _Ap, size_t _Np, class _A0, class _A1>
3343 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3347 template <class _Ap, size_t _Np, class _A0, class _A1, class _A2>
3348 struct __is_constructible3_imp<false, _Ap[_Np], _A0, _A1, _A2>
3352 // Incomplete array types are not constructible
3354 template <class _Ap>
3355 struct __is_constructible0_imp<false, _Ap[]>
3359 template <class _Ap, class _A0>
3360 struct __is_constructible1_imp<false, _Ap[], _A0>
3364 template <class _Ap, class _A0, class _A1>
3365 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3369 template <class _Ap, class _A0, class _A1, class _A2>
3370 struct __is_constructible3_imp<false, _Ap[], _A0, _A1, _A2>
3374 #endif // __has_feature(is_constructible)
3377 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3378 template <class _Tp, class ..._Args>
3379 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
3380 = is_constructible<_Tp, _Args...>::value;
3383 // is_default_constructible
3385 template <class _Tp>
3386 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3387 : public is_constructible<_Tp>
3390 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3391 template <class _Tp>
3392 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
3393 = is_default_constructible<_Tp>::value;
3396 // is_copy_constructible
3398 template <class _Tp>
3399 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3400 : public is_constructible<_Tp,
3401 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3403 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3404 template <class _Tp>
3405 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3406 = is_copy_constructible<_Tp>::value;
3409 // is_move_constructible
3411 template <class _Tp>
3412 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3413 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3414 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3416 : public is_copy_constructible<_Tp>
3420 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3421 template <class _Tp>
3422 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
3423 = is_move_constructible<_Tp>::value;
3426 // is_trivially_constructible
3428 #ifndef _LIBCPP_HAS_NO_VARIADICS
3430 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3432 template <class _Tp, class... _Args>
3433 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3434 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3438 #else // !__has_feature(is_trivially_constructible)
3440 template <class _Tp, class... _Args>
3441 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3446 template <class _Tp>
3447 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3448 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3449 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3451 : integral_constant<bool, is_scalar<_Tp>::value>
3456 template <class _Tp>
3457 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3458 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3460 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
3462 : integral_constant<bool, is_scalar<_Tp>::value>
3466 template <class _Tp>
3467 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3468 : integral_constant<bool, is_scalar<_Tp>::value>
3472 template <class _Tp>
3473 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3474 : integral_constant<bool, is_scalar<_Tp>::value>
3478 #endif // !__has_feature(is_trivially_constructible)
3480 #else // _LIBCPP_HAS_NO_VARIADICS
3482 template <class _Tp, class _A0 = __is_construct::__nat,
3483 class _A1 = __is_construct::__nat>
3484 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3489 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3491 template <class _Tp>
3492 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3493 __is_construct::__nat>
3494 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3498 template <class _Tp>
3499 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3500 __is_construct::__nat>
3501 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3505 template <class _Tp>
3506 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3507 __is_construct::__nat>
3508 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3512 template <class _Tp>
3513 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3514 __is_construct::__nat>
3515 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3519 #else // !__has_feature(is_trivially_constructible)
3521 template <class _Tp>
3522 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3523 __is_construct::__nat>
3524 : integral_constant<bool, is_scalar<_Tp>::value>
3528 template <class _Tp>
3529 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3530 __is_construct::__nat>
3531 : integral_constant<bool, is_scalar<_Tp>::value>
3535 template <class _Tp>
3536 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3537 __is_construct::__nat>
3538 : integral_constant<bool, is_scalar<_Tp>::value>
3542 template <class _Tp>
3543 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3544 __is_construct::__nat>
3545 : integral_constant<bool, is_scalar<_Tp>::value>
3549 #endif // !__has_feature(is_trivially_constructible)
3551 #endif // _LIBCPP_HAS_NO_VARIADICS
3553 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3554 template <class _Tp, class... _Args>
3555 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3556 = is_trivially_constructible<_Tp, _Args...>::value;
3559 // is_trivially_default_constructible
3561 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3562 : public is_trivially_constructible<_Tp>
3565 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3566 template <class _Tp>
3567 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3568 = is_trivially_default_constructible<_Tp>::value;
3571 // is_trivially_copy_constructible
3573 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3574 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
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_copy_constructible_v
3580 = is_trivially_copy_constructible<_Tp>::value;
3583 // is_trivially_move_constructible
3585 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3586 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3587 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3589 : public is_trivially_copy_constructible<_Tp>
3593 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3594 template <class _Tp>
3595 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3596 = is_trivially_move_constructible<_Tp>::value;
3599 // is_trivially_assignable
3601 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3603 template <class _Tp, class _Arg>
3604 struct is_trivially_assignable
3605 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3609 #else // !__has_feature(is_trivially_assignable)
3611 template <class _Tp, class _Arg>
3612 struct is_trivially_assignable
3613 : public false_type {};
3615 template <class _Tp>
3616 struct is_trivially_assignable<_Tp&, _Tp>
3617 : integral_constant<bool, is_scalar<_Tp>::value> {};
3619 template <class _Tp>
3620 struct is_trivially_assignable<_Tp&, _Tp&>
3621 : integral_constant<bool, is_scalar<_Tp>::value> {};
3623 template <class _Tp>
3624 struct is_trivially_assignable<_Tp&, const _Tp&>
3625 : integral_constant<bool, is_scalar<_Tp>::value> {};
3627 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3629 template <class _Tp>
3630 struct is_trivially_assignable<_Tp&, _Tp&&>
3631 : integral_constant<bool, is_scalar<_Tp>::value> {};
3633 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3635 #endif // !__has_feature(is_trivially_assignable)
3637 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3638 template <class _Tp, class _Arg>
3639 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3640 = is_trivially_assignable<_Tp, _Arg>::value;
3643 // is_trivially_copy_assignable
3645 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3646 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3647 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3649 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3650 template <class _Tp>
3651 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3652 = is_trivially_copy_assignable<_Tp>::value;
3655 // is_trivially_move_assignable
3657 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3658 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3659 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3660 typename add_rvalue_reference<_Tp>::type>
3662 typename add_lvalue_reference<_Tp>::type>
3666 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3667 template <class _Tp>
3668 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3669 = is_trivially_move_assignable<_Tp>::value;
3672 // is_trivially_destructible
3674 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3676 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3677 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3681 template <class _Tp> struct __libcpp_trivial_destructor
3682 : public integral_constant<bool, is_scalar<_Tp>::value ||
3683 is_reference<_Tp>::value> {};
3685 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3686 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3688 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3689 : public false_type {};
3693 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3694 template <class _Tp>
3695 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3696 = is_trivially_destructible<_Tp>::value;
3699 // is_nothrow_constructible
3702 template <class _Tp, class... _Args>
3703 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3704 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3710 #ifndef _LIBCPP_HAS_NO_VARIADICS
3712 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3714 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3716 template <class _Tp, class... _Args>
3717 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3718 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3722 template <class _Tp>
3723 void __implicit_conversion_to(_Tp) noexcept { }
3725 template <class _Tp, class _Arg>
3726 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3727 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3731 template <class _Tp, bool _IsReference, class... _Args>
3732 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3737 template <class _Tp, class... _Args>
3738 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3739 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3743 template <class _Tp, size_t _Ns>
3744 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3745 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3749 #else // __has_feature(cxx_noexcept)
3751 template <class _Tp, class... _Args>
3752 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3757 template <class _Tp>
3758 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
3759 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3760 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3762 : integral_constant<bool, is_scalar<_Tp>::value>
3767 template <class _Tp>
3768 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3769 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
3771 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
3773 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3774 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3776 : integral_constant<bool, is_scalar<_Tp>::value>
3781 template <class _Tp>
3782 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
3783 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3784 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3786 : integral_constant<bool, is_scalar<_Tp>::value>
3791 template <class _Tp>
3792 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
3793 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3794 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3796 : integral_constant<bool, is_scalar<_Tp>::value>
3801 #endif // __has_feature(cxx_noexcept)
3803 #else // _LIBCPP_HAS_NO_VARIADICS
3805 template <class _Tp, class _A0 = __is_construct::__nat,
3806 class _A1 = __is_construct::__nat>
3807 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3812 template <class _Tp>
3813 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
3814 __is_construct::__nat>
3815 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3816 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3818 : integral_constant<bool, is_scalar<_Tp>::value>
3823 template <class _Tp>
3824 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
3825 __is_construct::__nat>
3826 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3827 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3829 : integral_constant<bool, is_scalar<_Tp>::value>
3834 template <class _Tp>
3835 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
3836 __is_construct::__nat>
3837 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3838 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3840 : integral_constant<bool, is_scalar<_Tp>::value>
3845 template <class _Tp>
3846 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
3847 __is_construct::__nat>
3848 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3849 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3851 : integral_constant<bool, is_scalar<_Tp>::value>
3856 #endif // _LIBCPP_HAS_NO_VARIADICS
3857 #endif // __has_feature(is_nothrow_constructible)
3859 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3860 template <class _Tp, class ..._Args>
3861 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3862 = is_nothrow_constructible<_Tp, _Args...>::value;
3865 // is_nothrow_default_constructible
3867 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3868 : public is_nothrow_constructible<_Tp>
3871 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3872 template <class _Tp>
3873 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3874 = is_nothrow_default_constructible<_Tp>::value;
3877 // is_nothrow_copy_constructible
3879 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3880 : public is_nothrow_constructible<_Tp,
3881 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
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_copy_constructible_v
3886 = is_nothrow_copy_constructible<_Tp>::value;
3889 // is_nothrow_move_constructible
3891 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3892 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3893 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3895 : public is_nothrow_copy_constructible<_Tp>
3899 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3900 template <class _Tp>
3901 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3902 = is_nothrow_move_constructible<_Tp>::value;
3905 // is_nothrow_assignable
3907 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3909 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3911 template <class _Tp, class _Arg>
3912 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3917 template <class _Tp, class _Arg>
3918 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3919 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3923 template <class _Tp, class _Arg>
3924 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3925 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3929 #else // __has_feature(cxx_noexcept)
3931 template <class _Tp, class _Arg>
3932 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3933 : public false_type {};
3935 template <class _Tp>
3936 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
3937 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3938 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3940 : integral_constant<bool, is_scalar<_Tp>::value> {};
3943 template <class _Tp>
3944 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
3945 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3946 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3948 : integral_constant<bool, is_scalar<_Tp>::value> {};
3951 template <class _Tp>
3952 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
3953 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3954 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3956 : integral_constant<bool, is_scalar<_Tp>::value> {};
3959 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3961 template <class _Tp>
3962 struct is_nothrow_assignable<_Tp&, _Tp&&>
3963 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3964 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3966 : integral_constant<bool, is_scalar<_Tp>::value> {};
3969 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3971 #endif // __has_feature(cxx_noexcept)
3973 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3974 template <class _Tp, class _Arg>
3975 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3976 = is_nothrow_assignable<_Tp, _Arg>::value;
3979 // is_nothrow_copy_assignable
3981 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3982 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3983 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3985 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3986 template <class _Tp>
3987 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3988 = is_nothrow_copy_assignable<_Tp>::value;
3991 // is_nothrow_move_assignable
3993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3994 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3995 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3996 typename add_rvalue_reference<_Tp>::type>
3998 typename add_lvalue_reference<_Tp>::type>
4002 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4003 template <class _Tp>
4004 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
4005 = is_nothrow_move_assignable<_Tp>::value;
4008 // is_nothrow_destructible
4010 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
4012 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
4014 template <class _Tp>
4015 struct __libcpp_is_nothrow_destructible<false, _Tp>
4020 template <class _Tp>
4021 struct __libcpp_is_nothrow_destructible<true, _Tp>
4022 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
4026 template <class _Tp>
4027 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4028 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
4032 template <class _Tp, size_t _Ns>
4033 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
4034 : public is_nothrow_destructible<_Tp>
4038 template <class _Tp>
4039 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
4044 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4046 template <class _Tp>
4047 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
4056 template <class _Tp> struct __libcpp_nothrow_destructor
4057 : public integral_constant<bool, is_scalar<_Tp>::value ||
4058 is_reference<_Tp>::value> {};
4060 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4061 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
4063 template <class _Tp>
4064 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
4065 : public false_type {};
4069 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4070 template <class _Tp>
4071 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
4072 = is_nothrow_destructible<_Tp>::value;
4077 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
4079 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4080 : public integral_constant<bool, __is_pod(_Tp)> {};
4084 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4085 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
4086 is_trivially_copy_constructible<_Tp>::value &&
4087 is_trivially_copy_assignable<_Tp>::value &&
4088 is_trivially_destructible<_Tp>::value> {};
4092 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4093 template <class _Tp>
4094 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
4095 = is_pod<_Tp>::value;
4100 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
4101 #ifdef _LIBCPP_IS_LITERAL
4102 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
4104 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
4105 is_reference<typename remove_all_extents<_Tp>::type>::value>
4109 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4110 template <class _Tp>
4111 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
4112 = is_literal_type<_Tp>::value;
4115 // is_standard_layout;
4117 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
4118 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
4119 : public integral_constant<bool, __is_standard_layout(_Tp)>
4121 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4125 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4126 template <class _Tp>
4127 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
4128 = is_standard_layout<_Tp>::value;
4131 // is_trivially_copyable;
4133 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
4134 #if __has_feature(is_trivially_copyable)
4135 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
4136 #elif _GNUC_VER >= 501
4137 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
4139 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4143 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4144 template <class _Tp>
4145 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
4146 = is_trivially_copyable<_Tp>::value;
4151 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
4152 #if __has_feature(is_trivial) || _GNUC_VER >= 407
4153 : public integral_constant<bool, __is_trivial(_Tp)>
4155 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
4156 is_trivially_default_constructible<_Tp>::value>
4160 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4161 template <class _Tp>
4162 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
4163 = is_trivial<_Tp>::value;
4166 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
4167 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
4168 template <class _Tp> struct __is_reference_wrapper
4169 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
4171 #ifndef _LIBCPP_CXX03_LANG
4173 // Check for complete types
4175 template <class ..._Tp> struct __check_complete;
4178 struct __check_complete<>
4182 template <class _Hp, class _T0, class ..._Tp>
4183 struct __check_complete<_Hp, _T0, _Tp...>
4184 : private __check_complete<_Hp>,
4185 private __check_complete<_T0, _Tp...>
4189 template <class _Hp>
4190 struct __check_complete<_Hp, _Hp>
4191 : private __check_complete<_Hp>
4195 template <class _Tp>
4196 struct __check_complete<_Tp>
4198 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
4201 template <class _Tp>
4202 struct __check_complete<_Tp&>
4203 : private __check_complete<_Tp>
4207 template <class _Tp>
4208 struct __check_complete<_Tp&&>
4209 : private __check_complete<_Tp>
4213 template <class _Rp, class ..._Param>
4214 struct __check_complete<_Rp (*)(_Param...)>
4215 : private __check_complete<_Rp>
4219 template <class ..._Param>
4220 struct __check_complete<void (*)(_Param...)>
4224 template <class _Rp, class ..._Param>
4225 struct __check_complete<_Rp (_Param...)>
4226 : private __check_complete<_Rp>
4230 template <class ..._Param>
4231 struct __check_complete<void (_Param...)>
4235 template <class _Rp, class _Class, class ..._Param>
4236 struct __check_complete<_Rp (_Class::*)(_Param...)>
4237 : private __check_complete<_Class>
4241 template <class _Rp, class _Class, class ..._Param>
4242 struct __check_complete<_Rp (_Class::*)(_Param...) const>
4243 : private __check_complete<_Class>
4247 template <class _Rp, class _Class, class ..._Param>
4248 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
4249 : private __check_complete<_Class>
4253 template <class _Rp, class _Class, class ..._Param>
4254 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
4255 : private __check_complete<_Class>
4259 template <class _Rp, class _Class, class ..._Param>
4260 struct __check_complete<_Rp (_Class::*)(_Param...) &>
4261 : private __check_complete<_Class>
4265 template <class _Rp, class _Class, class ..._Param>
4266 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
4267 : private __check_complete<_Class>
4271 template <class _Rp, class _Class, class ..._Param>
4272 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
4273 : private __check_complete<_Class>
4277 template <class _Rp, class _Class, class ..._Param>
4278 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
4279 : private __check_complete<_Class>
4283 template <class _Rp, class _Class, class ..._Param>
4284 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
4285 : private __check_complete<_Class>
4289 template <class _Rp, class _Class, class ..._Param>
4290 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
4291 : private __check_complete<_Class>
4295 template <class _Rp, class _Class, class ..._Param>
4296 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
4297 : private __check_complete<_Class>
4301 template <class _Rp, class _Class, class ..._Param>
4302 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
4303 : private __check_complete<_Class>
4307 template <class _Rp, class _Class>
4308 struct __check_complete<_Rp _Class::*>
4309 : private __check_complete<_Class>
4314 template <class _Fp, class _A0,
4315 class _DecayFp = typename decay<_Fp>::type,
4316 class _DecayA0 = typename decay<_A0>::type,
4317 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4318 using __enable_if_bullet1 = typename enable_if
4320 is_member_function_pointer<_DecayFp>::value
4321 && is_base_of<_ClassT, _DecayA0>::value
4324 template <class _Fp, class _A0,
4325 class _DecayFp = typename decay<_Fp>::type,
4326 class _DecayA0 = typename decay<_A0>::type>
4327 using __enable_if_bullet2 = typename enable_if
4329 is_member_function_pointer<_DecayFp>::value
4330 && __is_reference_wrapper<_DecayA0>::value
4333 template <class _Fp, class _A0,
4334 class _DecayFp = typename decay<_Fp>::type,
4335 class _DecayA0 = typename decay<_A0>::type,
4336 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4337 using __enable_if_bullet3 = typename enable_if
4339 is_member_function_pointer<_DecayFp>::value
4340 && !is_base_of<_ClassT, _DecayA0>::value
4341 && !__is_reference_wrapper<_DecayA0>::value
4344 template <class _Fp, class _A0,
4345 class _DecayFp = typename decay<_Fp>::type,
4346 class _DecayA0 = typename decay<_A0>::type,
4347 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4348 using __enable_if_bullet4 = typename enable_if
4350 is_member_object_pointer<_DecayFp>::value
4351 && is_base_of<_ClassT, _DecayA0>::value
4354 template <class _Fp, class _A0,
4355 class _DecayFp = typename decay<_Fp>::type,
4356 class _DecayA0 = typename decay<_A0>::type>
4357 using __enable_if_bullet5 = typename enable_if
4359 is_member_object_pointer<_DecayFp>::value
4360 && __is_reference_wrapper<_DecayA0>::value
4363 template <class _Fp, class _A0,
4364 class _DecayFp = typename decay<_Fp>::type,
4365 class _DecayA0 = typename decay<_A0>::type,
4366 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4367 using __enable_if_bullet6 = typename enable_if
4369 is_member_object_pointer<_DecayFp>::value
4370 && !is_base_of<_ClassT, _DecayA0>::value
4371 && !__is_reference_wrapper<_DecayA0>::value
4374 // __invoke forward declarations
4376 // fall back - none of the bullets
4378 #define _LIBCPP_INVOKE_RETURN(...) \
4379 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4380 { return __VA_ARGS__; }
4382 template <class ..._Args>
4383 auto __invoke(__any, _Args&& ...__args) -> __nat;
4385 template <class ..._Args>
4386 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4388 // bullets 1, 2 and 3
4390 template <class _Fp, class _A0, class ..._Args,
4391 class = __enable_if_bullet1<_Fp, _A0>>
4392 inline _LIBCPP_INLINE_VISIBILITY
4394 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4395 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4397 template <class _Fp, class _A0, class ..._Args,
4398 class = __enable_if_bullet1<_Fp, _A0>>
4399 inline _LIBCPP_INLINE_VISIBILITY
4400 _LIBCPP_CONSTEXPR auto
4401 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4402 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4404 template <class _Fp, class _A0, class ..._Args,
4405 class = __enable_if_bullet2<_Fp, _A0>>
4406 inline _LIBCPP_INLINE_VISIBILITY
4408 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4409 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4411 template <class _Fp, class _A0, class ..._Args,
4412 class = __enable_if_bullet2<_Fp, _A0>>
4413 inline _LIBCPP_INLINE_VISIBILITY
4414 _LIBCPP_CONSTEXPR auto
4415 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4416 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4418 template <class _Fp, class _A0, class ..._Args,
4419 class = __enable_if_bullet3<_Fp, _A0>>
4420 inline _LIBCPP_INLINE_VISIBILITY
4422 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4423 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4425 template <class _Fp, class _A0, class ..._Args,
4426 class = __enable_if_bullet3<_Fp, _A0>>
4427 inline _LIBCPP_INLINE_VISIBILITY
4428 _LIBCPP_CONSTEXPR auto
4429 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4430 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4432 // bullets 4, 5 and 6
4434 template <class _Fp, class _A0,
4435 class = __enable_if_bullet4<_Fp, _A0>>
4436 inline _LIBCPP_INLINE_VISIBILITY
4438 __invoke(_Fp&& __f, _A0&& __a0)
4439 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4441 template <class _Fp, class _A0,
4442 class = __enable_if_bullet4<_Fp, _A0>>
4443 inline _LIBCPP_INLINE_VISIBILITY
4444 _LIBCPP_CONSTEXPR auto
4445 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4446 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4448 template <class _Fp, class _A0,
4449 class = __enable_if_bullet5<_Fp, _A0>>
4450 inline _LIBCPP_INLINE_VISIBILITY
4452 __invoke(_Fp&& __f, _A0&& __a0)
4453 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4455 template <class _Fp, class _A0,
4456 class = __enable_if_bullet5<_Fp, _A0>>
4457 inline _LIBCPP_INLINE_VISIBILITY
4458 _LIBCPP_CONSTEXPR auto
4459 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4460 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4462 template <class _Fp, class _A0,
4463 class = __enable_if_bullet6<_Fp, _A0>>
4464 inline _LIBCPP_INLINE_VISIBILITY
4466 __invoke(_Fp&& __f, _A0&& __a0)
4467 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4469 template <class _Fp, class _A0,
4470 class = __enable_if_bullet6<_Fp, _A0>>
4471 inline _LIBCPP_INLINE_VISIBILITY
4472 _LIBCPP_CONSTEXPR auto
4473 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4474 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4478 template <class _Fp, class ..._Args>
4479 inline _LIBCPP_INLINE_VISIBILITY
4481 __invoke(_Fp&& __f, _Args&& ...__args)
4482 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4484 template <class _Fp, class ..._Args>
4485 inline _LIBCPP_INLINE_VISIBILITY
4486 _LIBCPP_CONSTEXPR auto
4487 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4488 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4490 #undef _LIBCPP_INVOKE_RETURN
4494 template <class _Ret, class _Fp, class ..._Args>
4495 struct __invokable_r
4496 : private __check_complete<_Fp>
4498 using _Result = decltype(
4499 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4502 typename conditional<
4503 !is_same<_Result, __nat>::value,
4504 typename conditional<
4505 is_void<_Ret>::value,
4507 is_convertible<_Result, _Ret>
4511 static const bool value = type::value;
4514 template <class _Fp, class ..._Args>
4515 using __invokable = __invokable_r<void, _Fp, _Args...>;
4517 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4518 struct __nothrow_invokable_r_imp {
4519 static const bool value = false;
4522 template <class _Ret, class _Fp, class ..._Args>
4523 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4525 typedef __nothrow_invokable_r_imp _ThisT;
4527 template <class _Tp>
4528 static void __test_noexcept(_Tp) noexcept;
4530 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4531 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4534 template <class _Ret, class _Fp, class ..._Args>
4535 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4537 static const bool value = noexcept(
4538 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4541 template <class _Ret, class _Fp, class ..._Args>
4542 using __nothrow_invokable_r =
4543 __nothrow_invokable_r_imp<
4544 __invokable_r<_Ret, _Fp, _Args...>::value,
4545 is_void<_Ret>::value,
4549 template <class _Fp, class ..._Args>
4550 using __nothrow_invokable =
4551 __nothrow_invokable_r_imp<
4552 __invokable<_Fp, _Args...>::value,
4553 true, void, _Fp, _Args...
4556 template <class _Fp, class ..._Args>
4559 __invokable<_Fp, _Args...>::value,
4560 typename __invokable_r<void, _Fp, _Args...>::_Result>
4566 template <class _Fp, class ..._Args>
4567 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
4568 : public __invoke_of<_Fp, _Args...>
4572 #if _LIBCPP_STD_VER > 11
4573 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4576 #if _LIBCPP_STD_VER > 14
4580 template <class _Fn, class... _Args>
4581 struct _LIBCPP_TEMPLATE_VIS invoke_result
4582 : __invoke_of<_Fn, _Args...>
4586 template <class _Fn, class... _Args>
4587 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
4591 template <class _Fn, class ..._Args>
4592 struct _LIBCPP_TEMPLATE_VIS is_invocable
4593 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
4595 template <class _Ret, class _Fn, class ..._Args>
4596 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
4597 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4599 template <class _Fn, class ..._Args>
4600 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
4601 = is_invocable<_Fn, _Args...>::value;
4603 template <class _Ret, class _Fn, class ..._Args>
4604 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
4605 = is_invocable_r<_Ret, _Fn, _Args...>::value;
4607 // is_nothrow_invocable
4609 template <class _Fn, class ..._Args>
4610 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
4611 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
4613 template <class _Ret, class _Fn, class ..._Args>
4614 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
4615 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
4617 template <class _Fn, class ..._Args>
4618 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
4619 = is_nothrow_invocable<_Fn, _Args...>::value;
4621 template <class _Ret, class _Fn, class ..._Args>
4622 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
4623 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
4625 #endif // _LIBCPP_STD_VER > 14
4627 #endif // !defined(_LIBCPP_CXX03_LANG)
4629 template <class _Tp> struct __is_swappable;
4630 template <class _Tp> struct __is_nothrow_swappable;
4632 template <class _Tp>
4633 inline _LIBCPP_INLINE_VISIBILITY
4634 #ifndef _LIBCPP_CXX03_LANG
4637 is_move_constructible<_Tp>::value &&
4638 is_move_assignable<_Tp>::value
4643 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4644 is_nothrow_move_assignable<_Tp>::value)
4646 _Tp __t(_VSTD::move(__x));
4647 __x = _VSTD::move(__y);
4648 __y = _VSTD::move(__t);
4651 template<class _Tp, size_t _Np>
4652 inline _LIBCPP_INLINE_VISIBILITY
4654 __is_swappable<_Tp>::value
4656 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4658 template <class _ForwardIterator1, class _ForwardIterator2>
4659 inline _LIBCPP_INLINE_VISIBILITY
4661 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4662 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4663 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4664 *_VSTD::declval<_ForwardIterator2>())))
4673 // ALL generic swap overloads MUST already have a declaration available at this point.
4675 template <class _Tp, class _Up = _Tp,
4676 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4677 struct __swappable_with
4679 template <class _LHS, class _RHS>
4680 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4682 template <class, class>
4683 static __nat __test_swap(long);
4685 // Extra parens are needed for the C++03 definition of decltype.
4686 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4687 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4689 static const bool value = !is_same<__swap1, __nat>::value
4690 && !is_same<__swap2, __nat>::value;
4693 template <class _Tp, class _Up>
4694 struct __swappable_with<_Tp, _Up, false> : false_type {};
4696 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4697 struct __nothrow_swappable_with {
4698 static const bool value =
4699 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4700 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4701 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4707 template <class _Tp, class _Up>
4708 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4712 template <class _Tp>
4713 struct __is_swappable
4714 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4718 template <class _Tp>
4719 struct __is_nothrow_swappable
4720 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4724 #if _LIBCPP_STD_VER > 14
4726 template <class _Tp, class _Up>
4727 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4728 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4732 template <class _Tp>
4733 struct _LIBCPP_TEMPLATE_VIS is_swappable
4734 : public conditional<
4735 __is_referenceable<_Tp>::value,
4737 typename add_lvalue_reference<_Tp>::type,
4738 typename add_lvalue_reference<_Tp>::type>,
4744 template <class _Tp, class _Up>
4745 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4746 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4750 template <class _Tp>
4751 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4752 : public conditional<
4753 __is_referenceable<_Tp>::value,
4754 is_nothrow_swappable_with<
4755 typename add_lvalue_reference<_Tp>::type,
4756 typename add_lvalue_reference<_Tp>::type>,
4762 template <class _Tp, class _Up>
4763 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
4764 = is_swappable_with<_Tp, _Up>::value;
4766 template <class _Tp>
4767 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
4768 = is_swappable<_Tp>::value;
4770 template <class _Tp, class _Up>
4771 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
4772 = is_nothrow_swappable_with<_Tp, _Up>::value;
4774 template <class _Tp>
4775 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
4776 = is_nothrow_swappable<_Tp>::value;
4778 #endif // _LIBCPP_STD_VER > 14
4780 #ifdef _LIBCPP_UNDERLYING_TYPE
4782 template <class _Tp>
4783 struct underlying_type
4785 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4788 #if _LIBCPP_STD_VER > 11
4789 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4792 #else // _LIBCPP_UNDERLYING_TYPE
4794 template <class _Tp, bool _Support = false>
4795 struct underlying_type
4797 static_assert(_Support, "The underyling_type trait requires compiler "
4798 "support. Either no such support exists or "
4799 "libc++ does not know how to use it.");
4802 #endif // _LIBCPP_UNDERLYING_TYPE
4805 template <class _Tp, bool = is_enum<_Tp>::value>
4806 struct __sfinae_underlying_type
4808 typedef typename underlying_type<_Tp>::type type;
4809 typedef decltype(((type)1) + 0) __promoted_type;
4812 template <class _Tp>
4813 struct __sfinae_underlying_type<_Tp, false> {};
4815 inline _LIBCPP_INLINE_VISIBILITY
4816 int __convert_to_integral(int __val) { return __val; }
4818 inline _LIBCPP_INLINE_VISIBILITY
4819 unsigned __convert_to_integral(unsigned __val) { return __val; }
4821 inline _LIBCPP_INLINE_VISIBILITY
4822 long __convert_to_integral(long __val) { return __val; }
4824 inline _LIBCPP_INLINE_VISIBILITY
4825 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4827 inline _LIBCPP_INLINE_VISIBILITY
4828 long long __convert_to_integral(long long __val) { return __val; }
4830 inline _LIBCPP_INLINE_VISIBILITY
4831 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4833 template<typename _Fp>
4834 inline _LIBCPP_INLINE_VISIBILITY
4835 typename enable_if<is_floating_point<_Fp>::value, long long>::type
4836 __convert_to_integral(_Fp __val) { return __val; }
4838 #ifndef _LIBCPP_HAS_NO_INT128
4839 inline _LIBCPP_INLINE_VISIBILITY
4840 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4842 inline _LIBCPP_INLINE_VISIBILITY
4843 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4846 template <class _Tp>
4847 inline _LIBCPP_INLINE_VISIBILITY
4848 typename __sfinae_underlying_type<_Tp>::__promoted_type
4849 __convert_to_integral(_Tp __val) { return __val; }
4851 #ifndef _LIBCPP_CXX03_LANG
4853 template <class _Tp>
4854 struct __has_operator_addressof_member_imp
4856 template <class _Up>
4857 static auto __test(int)
4858 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4860 static auto __test(long) -> false_type;
4862 static const bool value = decltype(__test<_Tp>(0))::value;
4865 template <class _Tp>
4866 struct __has_operator_addressof_free_imp
4868 template <class _Up>
4869 static auto __test(int)
4870 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4872 static auto __test(long) -> false_type;
4874 static const bool value = decltype(__test<_Tp>(0))::value;
4877 template <class _Tp>
4878 struct __has_operator_addressof
4879 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4880 || __has_operator_addressof_free_imp<_Tp>::value>
4883 #endif // _LIBCPP_CXX03_LANG
4885 #if _LIBCPP_STD_VER > 14
4887 #define __cpp_lib_void_t 201411
4888 template <class...> using void_t = void;
4890 # ifndef _LIBCPP_HAS_NO_VARIADICS
4891 template <class... _Args>
4892 struct conjunction : __and_<_Args...> {};
4893 template<class... _Args>
4894 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
4895 = conjunction<_Args...>::value;
4897 template <class... _Args>
4898 struct disjunction : __or_<_Args...> {};
4899 template<class... _Args>
4900 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
4901 = disjunction<_Args...>::value;
4903 template <class _Tp>
4904 struct negation : __not_<_Tp> {};
4906 _LIBCPP_INLINE_VAR constexpr bool negation_v
4907 = negation<_Tp>::value;
4908 # endif // _LIBCPP_HAS_NO_VARIADICS
4909 #endif // _LIBCPP_STD_VER > 14
4911 // These traits are used in __tree and __hash_table
4912 #ifndef _LIBCPP_CXX03_LANG
4913 struct __extract_key_fail_tag {};
4914 struct __extract_key_self_tag {};
4915 struct __extract_key_first_tag {};
4917 template <class _ValTy, class _Key,
4918 class _RawValTy = typename __unconstref<_ValTy>::type>
4919 struct __can_extract_key
4920 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4921 __extract_key_fail_tag>::type {};
4923 template <class _Pair, class _Key, class _First, class _Second>
4924 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4925 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4926 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4928 // __can_extract_map_key uses true_type/false_type instead of the tags.
4929 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4930 // and _ValTy == _Key.
4931 template <class _ValTy, class _Key, class _ContainerValueTy,
4932 class _RawValTy = typename __unconstref<_ValTy>::type>
4933 struct __can_extract_map_key
4934 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4936 // This specialization returns __extract_key_fail_tag for non-map containers
4937 // because _Key == _ContainerValueTy
4938 template <class _ValTy, class _Key, class _RawValTy>
4939 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4944 _LIBCPP_END_NAMESPACE_STD
4946 #if _LIBCPP_STD_VER > 14
4948 namespace std // purposefully not versioned
4950 template <class _Integer>
4951 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4952 operator<<=(byte& __lhs, _Integer __shift) noexcept
4953 { return __lhs = __lhs << __shift; }
4955 template <class _Integer>
4956 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4957 operator<< (byte __lhs, _Integer __shift) noexcept
4958 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
4960 template <class _Integer>
4961 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4962 operator>>=(byte& __lhs, _Integer __shift) noexcept
4963 { return __lhs = __lhs >> __shift; }
4965 template <class _Integer>
4966 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4967 operator>> (byte __lhs, _Integer __shift) noexcept
4968 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4970 template <class _Integer>
4971 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4972 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4977 #endif // _LIBCPP_TYPE_TRAITS