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 {};
737 template <> struct __libcpp_is_floating_point<__fp16> : public true_type {};
739 #ifdef __FLT16_MANT_DIG__
740 template <> struct __libcpp_is_floating_point<_Float16> : public true_type {};
742 template <> struct __libcpp_is_floating_point<float> : public true_type {};
743 template <> struct __libcpp_is_floating_point<double> : public true_type {};
744 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
746 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
747 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
749 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
751 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
752 = is_floating_point<_Tp>::value;
757 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
758 : public false_type {};
759 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
760 : public true_type {};
761 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
762 : public true_type {};
764 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
766 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
767 = is_array<_Tp>::value;
772 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
773 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
775 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
776 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
778 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
780 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
781 = is_pointer<_Tp>::value;
786 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
787 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
789 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
790 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
794 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
795 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
796 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
797 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
800 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
802 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
803 = is_reference<_Tp>::value;
806 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
807 = is_lvalue_reference<_Tp>::value;
810 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
811 = is_rvalue_reference<_Tp>::value;
815 #if __has_feature(is_union) || (_GNUC_VER >= 403)
817 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
818 : public integral_constant<bool, __is_union(_Tp)> {};
822 template <class _Tp> struct __libcpp_union : public false_type {};
823 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
824 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
828 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
830 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
831 = is_union<_Tp>::value;
836 #if __has_feature(is_class) || (_GNUC_VER >= 403)
838 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
839 : public integral_constant<bool, __is_class(_Tp)> {};
843 namespace __is_class_imp
845 template <class _Tp> char __test(int _Tp::*);
846 template <class _Tp> __two __test(...);
849 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
850 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
854 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
856 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
857 = is_class<_Tp>::value;
862 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
863 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
865 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
866 template <class _Tp, class _Up>
867 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
868 = is_same<_Tp, _Up>::value;
873 namespace __libcpp_is_function_imp
875 struct __dummy_type {};
876 template <class _Tp> char __test(_Tp*);
877 template <class _Tp> char __test(__dummy_type);
878 template <class _Tp> __two __test(...);
879 template <class _Tp> _Tp& __source(int);
880 template <class _Tp> __dummy_type __source(...);
883 template <class _Tp, bool = is_class<_Tp>::value ||
884 is_union<_Tp>::value ||
885 is_void<_Tp>::value ||
886 is_reference<_Tp>::value ||
887 __is_nullptr_t<_Tp>::value >
888 struct __libcpp_is_function
889 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
891 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
893 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
894 : public __libcpp_is_function<_Tp> {};
896 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
898 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
899 = is_function<_Tp>::value;
902 // is_member_function_pointer
904 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
905 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
908 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
909 struct __member_pointer_traits_imp
910 { // forward declaration; specializations later
914 template <class _Tp> struct __libcpp_is_member_function_pointer
915 : public false_type {};
917 template <class _Ret, class _Class>
918 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
919 : public is_function<_Ret> {};
921 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
922 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
924 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
926 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
927 = is_member_function_pointer<_Tp>::value;
932 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
933 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
935 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
936 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
938 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
940 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
941 = is_member_pointer<_Tp>::value;
944 // is_member_object_pointer
946 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
947 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
948 !is_member_function_pointer<_Tp>::value> {};
950 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
952 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
953 = is_member_object_pointer<_Tp>::value;
958 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
960 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
961 : public integral_constant<bool, __is_enum(_Tp)> {};
965 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
966 : public integral_constant<bool, !is_void<_Tp>::value &&
967 !is_integral<_Tp>::value &&
968 !is_floating_point<_Tp>::value &&
969 !is_array<_Tp>::value &&
970 !is_pointer<_Tp>::value &&
971 !is_reference<_Tp>::value &&
972 !is_member_pointer<_Tp>::value &&
973 !is_union<_Tp>::value &&
974 !is_class<_Tp>::value &&
975 !is_function<_Tp>::value > {};
979 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
981 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
982 = is_enum<_Tp>::value;
987 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
988 : public integral_constant<bool, is_integral<_Tp>::value ||
989 is_floating_point<_Tp>::value> {};
991 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
993 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
994 = is_arithmetic<_Tp>::value;
999 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
1000 : public integral_constant<bool, is_void<_Tp>::value ||
1001 __is_nullptr_t<_Tp>::value ||
1002 is_arithmetic<_Tp>::value> {};
1004 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1005 template <class _Tp>
1006 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1007 = is_fundamental<_Tp>::value;
1012 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1013 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1014 is_member_pointer<_Tp>::value ||
1015 is_pointer<_Tp>::value ||
1016 __is_nullptr_t<_Tp>::value ||
1017 is_enum<_Tp>::value > {};
1019 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1021 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1022 template <class _Tp>
1023 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1024 = is_scalar<_Tp>::value;
1029 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1030 : public integral_constant<bool, is_scalar<_Tp>::value ||
1031 is_array<_Tp>::value ||
1032 is_union<_Tp>::value ||
1033 is_class<_Tp>::value > {};
1035 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1036 template <class _Tp>
1037 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
1038 = is_object<_Tp>::value;
1043 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1044 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1046 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1047 template <class _Tp>
1048 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1049 = is_compound<_Tp>::value;
1053 // __is_referenceable [defns.referenceable]
1055 struct __is_referenceable_impl {
1056 template <class _Tp> static _Tp& __test(int);
1057 template <class _Tp> static __two __test(...);
1060 template <class _Tp>
1061 struct __is_referenceable : integral_constant<bool,
1062 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1067 template <class _Tp, bool = is_reference<_Tp>::value ||
1068 is_function<_Tp>::value ||
1069 is_const<_Tp>::value >
1070 struct __add_const {typedef _Tp type;};
1072 template <class _Tp>
1073 struct __add_const<_Tp, false> {typedef const _Tp type;};
1075 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1076 {typedef typename __add_const<_Tp>::type type;};
1078 #if _LIBCPP_STD_VER > 11
1079 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1084 template <class _Tp, bool = is_reference<_Tp>::value ||
1085 is_function<_Tp>::value ||
1086 is_volatile<_Tp>::value >
1087 struct __add_volatile {typedef _Tp type;};
1089 template <class _Tp>
1090 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1092 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1093 {typedef typename __add_volatile<_Tp>::type type;};
1095 #if _LIBCPP_STD_VER > 11
1096 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1101 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1102 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1104 #if _LIBCPP_STD_VER > 11
1105 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1110 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;};
1111 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;};
1112 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1113 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
1116 #if _LIBCPP_STD_VER > 11
1117 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1120 // add_lvalue_reference
1122 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1123 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1125 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1126 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1128 #if _LIBCPP_STD_VER > 11
1129 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1132 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1134 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1135 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1137 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1138 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1140 #if _LIBCPP_STD_VER > 11
1141 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1144 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1146 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1148 template <class _Tp> _Tp&& __declval(int);
1149 template <class _Tp> _Tp __declval(long);
1151 template <class _Tp>
1152 decltype(_VSTD::__declval<_Tp>(0))
1153 declval() _NOEXCEPT;
1155 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1157 template <class _Tp>
1158 typename add_lvalue_reference<_Tp>::type
1161 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1165 template <class _Tp>
1167 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1170 template <class _Tp>
1171 struct __unconstref {
1172 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1175 #ifndef _LIBCPP_CXX03_LANG
1176 template <class _Tp>
1177 using __uncvref_t = typename __uncvref<_Tp>::type;
1180 // __is_same_uncvref
1182 template <class _Tp, class _Up>
1183 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1184 typename __uncvref<_Up>::type> {};
1186 #if _LIBCPP_STD_VER > 17
1187 // remove_cvref - same as __uncvref
1188 template <class _Tp>
1189 struct remove_cvref : public __uncvref<_Tp> {};
1191 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1202 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;};
1203 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
1204 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
1205 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
1206 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1208 #if _LIBCPP_STD_VER > 11
1209 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1214 template <class _Tp,
1215 bool = __is_referenceable<_Tp>::value ||
1216 is_same<typename remove_cv<_Tp>::type, void>::value>
1217 struct __add_pointer_impl
1218 {typedef typename remove_reference<_Tp>::type* type;};
1219 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1220 {typedef _Tp type;};
1222 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1223 {typedef typename __add_pointer_impl<_Tp>::type type;};
1225 #if _LIBCPP_STD_VER > 11
1226 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1231 template <class _Tp, bool = is_integral<_Tp>::value>
1232 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1234 template <class _Tp>
1235 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1237 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1238 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1240 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1242 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1244 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1245 template <class _Tp>
1246 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1247 = is_signed<_Tp>::value;
1252 template <class _Tp, bool = is_integral<_Tp>::value>
1253 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1255 template <class _Tp>
1256 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1258 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1259 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1261 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1263 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1265 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1266 template <class _Tp>
1267 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1268 = is_unsigned<_Tp>::value;
1273 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1274 : public integral_constant<size_t, 0> {};
1275 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1276 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1277 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1278 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1280 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1281 template <class _Tp>
1282 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1288 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1289 : public integral_constant<size_t, 0> {};
1290 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1291 : public integral_constant<size_t, 0> {};
1292 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1293 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1294 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1295 : public integral_constant<size_t, _Np> {};
1296 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1297 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1299 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1300 template <class _Tp, unsigned _Ip = 0>
1301 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1302 = extent<_Tp, _Ip>::value;
1307 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1308 {typedef _Tp type;};
1309 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1310 {typedef _Tp type;};
1311 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1312 {typedef _Tp type;};
1314 #if _LIBCPP_STD_VER > 11
1315 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1318 // remove_all_extents
1320 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1321 {typedef _Tp type;};
1322 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1323 {typedef typename remove_all_extents<_Tp>::type type;};
1324 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1325 {typedef typename remove_all_extents<_Tp>::type type;};
1327 #if _LIBCPP_STD_VER > 11
1328 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1333 template <class _Up, bool>
1335 typedef typename remove_cv<_Up>::type type;
1338 template <class _Up>
1339 struct __decay<_Up, true> {
1341 typedef typename conditional
1343 is_array<_Up>::value,
1344 typename remove_extent<_Up>::type*,
1345 typename conditional
1347 is_function<_Up>::value,
1348 typename add_pointer<_Up>::type,
1349 typename remove_cv<_Up>::type
1354 template <class _Tp>
1355 struct _LIBCPP_TEMPLATE_VIS decay
1358 typedef typename remove_reference<_Tp>::type _Up;
1360 typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1363 #if _LIBCPP_STD_VER > 11
1364 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1369 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1370 : public integral_constant<bool, __is_abstract(_Tp)> {};
1372 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1373 template <class _Tp>
1374 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1375 = is_abstract<_Tp>::value;
1380 #if defined(_LIBCPP_HAS_IS_FINAL)
1381 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1382 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1384 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1385 __libcpp_is_final : public false_type {};
1388 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1389 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1390 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1393 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1394 template <class _Tp>
1395 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1396 = is_final<_Tp>::value;
1400 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1402 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1403 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1405 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1406 template <class _Tp>
1407 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1408 = is_aggregate<_Tp>::value;
1411 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1415 #ifdef _LIBCPP_HAS_IS_BASE_OF
1417 template <class _Bp, class _Dp>
1418 struct _LIBCPP_TEMPLATE_VIS is_base_of
1419 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1421 #else // _LIBCPP_HAS_IS_BASE_OF
1423 namespace __is_base_of_imp
1425 template <class _Tp>
1428 _Dst(const volatile _Tp &);
1430 template <class _Tp>
1433 operator const volatile _Tp &();
1434 template <class _Up> operator const _Dst<_Up> &();
1436 template <size_t> struct __one { typedef char type; };
1437 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1438 template <class _Bp, class _Dp> __two __test(...);
1441 template <class _Bp, class _Dp>
1442 struct _LIBCPP_TEMPLATE_VIS is_base_of
1443 : public integral_constant<bool, is_class<_Bp>::value &&
1444 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1446 #endif // _LIBCPP_HAS_IS_BASE_OF
1448 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1449 template <class _Bp, class _Dp>
1450 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1451 = is_base_of<_Bp, _Dp>::value;
1456 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1458 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1459 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1460 !is_abstract<_T2>::value> {};
1462 #else // __has_feature(is_convertible_to)
1464 namespace __is_convertible_imp
1466 template <class _Tp> void __test_convert(_Tp);
1468 template <class _From, class _To, class = void>
1469 struct __is_convertible_test : public false_type {};
1471 template <class _From, class _To>
1472 struct __is_convertible_test<_From, _To,
1473 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1476 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1477 bool _IsFunction = is_function<_Tp>::value,
1478 bool _IsVoid = is_void<_Tp>::value>
1479 struct __is_array_function_or_void {enum {value = 0};};
1480 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1481 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1482 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1485 template <class _Tp,
1486 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1487 struct __is_convertible_check
1489 static const size_t __v = 0;
1492 template <class _Tp>
1493 struct __is_convertible_check<_Tp, 0>
1495 static const size_t __v = sizeof(_Tp);
1498 template <class _T1, class _T2,
1499 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1500 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1501 struct __is_convertible
1502 : public integral_constant<bool,
1503 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1504 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1505 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1506 && (!is_const<typename remove_reference<_T2>::type>::value
1507 || is_volatile<typename remove_reference<_T2>::type>::value)
1508 && (is_same<typename remove_cv<_T1>::type,
1509 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1510 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1515 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1516 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1517 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1518 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1520 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1521 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1522 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1523 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1525 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1526 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1527 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1528 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1530 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1531 : public __is_convertible<_T1, _T2>
1533 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1534 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1537 #endif // __has_feature(is_convertible_to)
1539 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1540 template <class _From, class _To>
1541 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1542 = is_convertible<_From, _To>::value;
1547 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1549 template <class _Tp>
1550 struct _LIBCPP_TEMPLATE_VIS is_empty
1551 : public integral_constant<bool, __is_empty(_Tp)> {};
1553 #else // __has_feature(is_empty)
1555 template <class _Tp>
1567 template <class _Tp, bool = is_class<_Tp>::value>
1568 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1570 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1572 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1574 #endif // __has_feature(is_empty)
1576 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1577 template <class _Tp>
1578 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1579 = is_empty<_Tp>::value;
1584 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1586 template <class _Tp>
1587 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1588 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1592 template<typename _Tp> char &__is_polymorphic_impl(
1593 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1595 template<typename _Tp> __two &__is_polymorphic_impl(...);
1597 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1598 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1600 #endif // __has_feature(is_polymorphic)
1602 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1603 template <class _Tp>
1604 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1605 = is_polymorphic<_Tp>::value;
1608 // has_virtual_destructor
1610 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1612 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1613 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1617 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1618 : public false_type {};
1622 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1623 template <class _Tp>
1624 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1625 = has_virtual_destructor<_Tp>::value;
1628 // has_unique_object_representations
1630 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1632 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1633 : public integral_constant<bool,
1634 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1636 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1637 template <class _Tp>
1638 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1639 = has_unique_object_representations<_Tp>::value;
1646 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1647 : public integral_constant<size_t, __alignof__(_Tp)> {};
1649 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1650 template <class _Tp>
1651 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1652 = alignment_of<_Tp>::value;
1657 template <class _Hp, class _Tp>
1666 #ifndef _LIBCPP_CXX03_LANG
1668 __nat(const __nat&) = delete;
1669 __nat& operator=(const __nat&) = delete;
1674 template <class _Tp>
1677 static const size_t value = alignment_of<_Tp>::value;
1681 struct __struct_double {long double __lx;};
1682 struct __struct_double4 {double __lx[4];};
1685 __type_list<__align_type<unsigned char>,
1686 __type_list<__align_type<unsigned short>,
1687 __type_list<__align_type<unsigned int>,
1688 __type_list<__align_type<unsigned long>,
1689 __type_list<__align_type<unsigned long long>,
1690 __type_list<__align_type<double>,
1691 __type_list<__align_type<long double>,
1692 __type_list<__align_type<__struct_double>,
1693 __type_list<__align_type<__struct_double4>,
1694 __type_list<__align_type<int*>,
1696 > > > > > > > > > > __all_types;
1698 template <class _TL, size_t _Align> struct __find_pod;
1700 template <class _Hp, size_t _Align>
1701 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1703 typedef typename conditional<
1704 _Align == _Hp::value,
1710 template <class _Hp, class _Tp, size_t _Align>
1711 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1713 typedef typename conditional<
1714 _Align == _Hp::value,
1716 typename __find_pod<_Tp, _Align>::type
1720 template <class _TL, size_t _Len> struct __find_max_align;
1722 template <class _Hp, size_t _Len>
1723 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1725 template <size_t _Len, size_t _A1, size_t _A2>
1726 struct __select_align
1729 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1730 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1732 static const size_t value = _Len < __max ? __min : __max;
1735 template <class _Hp, class _Tp, size_t _Len>
1736 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1737 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1739 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1740 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1742 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1743 static_assert(!is_void<_Aligner>::value, "");
1747 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1751 #if _LIBCPP_STD_VER > 11
1752 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1753 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1756 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1757 template <size_t _Len>\
1758 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1760 struct _ALIGNAS(n) type\
1762 unsigned char __lx[(_Len + n - 1)/n * n];\
1766 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1767 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1768 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1769 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1770 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1771 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1772 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1773 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1774 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1775 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1776 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1777 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1778 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1779 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1780 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1781 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1782 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1783 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1785 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1787 #ifndef _LIBCPP_HAS_NO_VARIADICS
1791 template <size_t _I0, size_t ..._In>
1792 struct __static_max;
1794 template <size_t _I0>
1795 struct __static_max<_I0>
1797 static const size_t value = _I0;
1800 template <size_t _I0, size_t _I1, size_t ..._In>
1801 struct __static_max<_I0, _I1, _In...>
1803 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1804 __static_max<_I1, _In...>::value;
1807 template <size_t _Len, class _Type0, class ..._Types>
1808 struct aligned_union
1810 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1811 __alignof__(_Types)...>::value;
1812 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1813 sizeof(_Types)...>::value;
1814 typedef typename aligned_storage<__len, alignment_value>::type type;
1817 #if _LIBCPP_STD_VER > 11
1818 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1821 #endif // _LIBCPP_HAS_NO_VARIADICS
1823 template <class _Tp>
1824 struct __numeric_type
1826 static void __test(...);
1827 static float __test(float);
1828 static double __test(char);
1829 static double __test(int);
1830 static double __test(unsigned);
1831 static double __test(long);
1832 static double __test(unsigned long);
1833 static double __test(long long);
1834 static double __test(unsigned long long);
1835 static double __test(double);
1836 static long double __test(long double);
1838 typedef decltype(__test(declval<_Tp>())) type;
1839 static const bool value = !is_same<type, void>::value;
1843 struct __numeric_type<void>
1845 static const bool value = true;
1850 template <class _A1, class _A2 = void, class _A3 = void,
1851 bool = __numeric_type<_A1>::value &&
1852 __numeric_type<_A2>::value &&
1853 __numeric_type<_A3>::value>
1857 static const bool value = false;
1860 template <class _A1, class _A2, class _A3>
1861 class __promote_imp<_A1, _A2, _A3, true>
1864 typedef typename __promote_imp<_A1>::type __type1;
1865 typedef typename __promote_imp<_A2>::type __type2;
1866 typedef typename __promote_imp<_A3>::type __type3;
1868 typedef decltype(__type1() + __type2() + __type3()) type;
1869 static const bool value = true;
1872 template <class _A1, class _A2>
1873 class __promote_imp<_A1, _A2, void, true>
1876 typedef typename __promote_imp<_A1>::type __type1;
1877 typedef typename __promote_imp<_A2>::type __type2;
1879 typedef decltype(__type1() + __type2()) type;
1880 static const bool value = true;
1883 template <class _A1>
1884 class __promote_imp<_A1, void, void, true>
1887 typedef typename __numeric_type<_A1>::type type;
1888 static const bool value = true;
1891 template <class _A1, class _A2 = void, class _A3 = void>
1892 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1894 // make_signed / make_unsigned
1897 __type_list<signed char,
1898 __type_list<signed short,
1899 __type_list<signed int,
1900 __type_list<signed long,
1901 __type_list<signed long long,
1902 #ifndef _LIBCPP_HAS_NO_INT128
1903 __type_list<__int128_t,
1906 #ifndef _LIBCPP_HAS_NO_INT128
1909 > > > > > __signed_types;
1912 __type_list<unsigned char,
1913 __type_list<unsigned short,
1914 __type_list<unsigned int,
1915 __type_list<unsigned long,
1916 __type_list<unsigned long long,
1917 #ifndef _LIBCPP_HAS_NO_INT128
1918 __type_list<__uint128_t,
1921 #ifndef _LIBCPP_HAS_NO_INT128
1924 > > > > > __unsigned_types;
1926 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1928 template <class _Hp, class _Tp, size_t _Size>
1929 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1934 template <class _Hp, class _Tp, size_t _Size>
1935 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1937 typedef typename __find_first<_Tp, _Size>::type type;
1940 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1941 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1947 template <class _Tp, class _Up>
1948 struct __apply_cv<_Tp, _Up, true, false>
1950 typedef const _Up type;
1953 template <class _Tp, class _Up>
1954 struct __apply_cv<_Tp, _Up, false, true>
1956 typedef volatile _Up type;
1959 template <class _Tp, class _Up>
1960 struct __apply_cv<_Tp, _Up, true, true>
1962 typedef const volatile _Up type;
1965 template <class _Tp, class _Up>
1966 struct __apply_cv<_Tp&, _Up, false, false>
1971 template <class _Tp, class _Up>
1972 struct __apply_cv<_Tp&, _Up, true, false>
1974 typedef const _Up& type;
1977 template <class _Tp, class _Up>
1978 struct __apply_cv<_Tp&, _Up, false, true>
1980 typedef volatile _Up& type;
1983 template <class _Tp, class _Up>
1984 struct __apply_cv<_Tp&, _Up, true, true>
1986 typedef const volatile _Up& type;
1989 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1990 struct __make_signed {};
1992 template <class _Tp>
1993 struct __make_signed<_Tp, true>
1995 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1998 template <> struct __make_signed<bool, true> {};
1999 template <> struct __make_signed< signed short, true> {typedef short type;};
2000 template <> struct __make_signed<unsigned short, true> {typedef short type;};
2001 template <> struct __make_signed< signed int, true> {typedef int type;};
2002 template <> struct __make_signed<unsigned int, true> {typedef int type;};
2003 template <> struct __make_signed< signed long, true> {typedef long type;};
2004 template <> struct __make_signed<unsigned long, true> {typedef long type;};
2005 template <> struct __make_signed< signed long long, true> {typedef long long type;};
2006 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2007 #ifndef _LIBCPP_HAS_NO_INT128
2008 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2009 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2012 template <class _Tp>
2013 struct _LIBCPP_TEMPLATE_VIS make_signed
2015 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2018 #if _LIBCPP_STD_VER > 11
2019 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2022 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2023 struct __make_unsigned {};
2025 template <class _Tp>
2026 struct __make_unsigned<_Tp, true>
2028 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2031 template <> struct __make_unsigned<bool, true> {};
2032 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2033 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2034 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2035 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2036 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2037 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2038 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2039 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2040 #ifndef _LIBCPP_HAS_NO_INT128
2041 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2042 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2045 template <class _Tp>
2046 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2048 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2051 #if _LIBCPP_STD_VER > 11
2052 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2055 #ifdef _LIBCPP_HAS_NO_VARIADICS
2057 template <class _Tp, class _Up = void, class _Vp = void>
2058 struct _LIBCPP_TEMPLATE_VIS common_type
2061 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
2065 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void>
2071 template <class _Tp>
2072 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
2075 typedef typename common_type<_Tp, _Tp>::type type;
2078 template <class _Tp, class _Up>
2079 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
2081 typedef typename decay<decltype(
2082 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2086 #else // _LIBCPP_HAS_NO_VARIADICS
2088 // bullet 1 - sizeof...(Tp) == 0
2090 template <class ..._Tp>
2091 struct _LIBCPP_TEMPLATE_VIS common_type {};
2093 // bullet 2 - sizeof...(Tp) == 1
2095 template <class _Tp>
2096 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2097 : public common_type<_Tp, _Tp> {};
2099 // bullet 3 - sizeof...(Tp) == 2
2101 template <class _Tp, class _Up, class = void>
2102 struct __common_type2_imp {};
2104 template <class _Tp, class _Up>
2105 struct __common_type2_imp<_Tp, _Up,
2106 typename __void_t<decltype(
2107 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2110 typedef typename decay<decltype(
2111 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2115 template <class _Tp, class _Up,
2116 class _DTp = typename decay<_Tp>::type,
2117 class _DUp = typename decay<_Up>::type>
2118 using __common_type2 =
2119 typename conditional<
2120 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
2121 __common_type2_imp<_Tp, _Up>,
2122 common_type<_DTp, _DUp>
2125 template <class _Tp, class _Up>
2126 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2127 : __common_type2<_Tp, _Up> {};
2129 // bullet 4 - sizeof...(Tp) > 2
2131 template <class ...Tp> struct __common_types;
2133 template <class, class = void>
2134 struct __common_type_impl {};
2136 template <class _Tp, class _Up>
2137 struct __common_type_impl<
2138 __common_types<_Tp, _Up>,
2139 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2141 typedef typename common_type<_Tp, _Up>::type type;
2144 template <class _Tp, class _Up, class ..._Vp>
2145 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2146 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2147 : __common_type_impl<
2148 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
2153 template <class _Tp, class _Up, class ..._Vp>
2154 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
2155 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2157 #if _LIBCPP_STD_VER > 11
2158 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2161 #endif // _LIBCPP_HAS_NO_VARIADICS
2165 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2167 template <class _Tp, class _Arg>
2168 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2169 __is_assignable_test(int);
2171 template <class, class>
2172 false_type __is_assignable_test(...);
2175 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2176 struct __is_assignable_imp
2177 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2179 template <class _Tp, class _Arg>
2180 struct __is_assignable_imp<_Tp, _Arg, true>
2185 template <class _Tp, class _Arg>
2186 struct is_assignable
2187 : public __is_assignable_imp<_Tp, _Arg> {};
2189 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2190 template <class _Tp, class _Arg>
2191 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2192 = is_assignable<_Tp, _Arg>::value;
2195 // is_copy_assignable
2197 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2198 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2199 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2201 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2202 template <class _Tp>
2203 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2204 = is_copy_assignable<_Tp>::value;
2207 // is_move_assignable
2209 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2210 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2211 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2212 typename add_rvalue_reference<_Tp>::type> {};
2214 : public is_copy_assignable<_Tp> {};
2217 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2218 template <class _Tp>
2219 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2220 = is_move_assignable<_Tp>::value;
2225 // if it's a reference, return true
2226 // if it's a function, return false
2227 // if it's void, return false
2228 // if it's an array of unknown bound, return false
2229 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2230 // where _Up is remove_all_extents<_Tp>::type
2233 struct __is_destructible_apply { typedef int type; };
2235 template <typename _Tp>
2236 struct __is_destructor_wellformed {
2237 template <typename _Tp1>
2238 static char __test (
2239 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2242 template <typename _Tp1>
2243 static __two __test (...);
2245 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2248 template <class _Tp, bool>
2249 struct __destructible_imp;
2251 template <class _Tp>
2252 struct __destructible_imp<_Tp, false>
2253 : public _VSTD::integral_constant<bool,
2254 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2256 template <class _Tp>
2257 struct __destructible_imp<_Tp, true>
2258 : public _VSTD::true_type {};
2260 template <class _Tp, bool>
2261 struct __destructible_false;
2263 template <class _Tp>
2264 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2266 template <class _Tp>
2267 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2269 template <class _Tp>
2270 struct is_destructible
2271 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2273 template <class _Tp>
2274 struct is_destructible<_Tp[]>
2275 : public _VSTD::false_type {};
2278 struct is_destructible<void>
2279 : public _VSTD::false_type {};
2281 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2282 template <class _Tp>
2283 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2284 = is_destructible<_Tp>::value;
2289 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2291 template <class _Tp>
2292 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2293 typename remove_reference<_Tp>::type&&
2294 move(_Tp&& __t) _NOEXCEPT
2296 typedef typename remove_reference<_Tp>::type _Up;
2297 return static_cast<_Up&&>(__t);
2300 template <class _Tp>
2301 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2303 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2305 return static_cast<_Tp&&>(__t);
2308 template <class _Tp>
2309 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2311 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2313 static_assert(!is_lvalue_reference<_Tp>::value,
2314 "can not forward an rvalue as an lvalue");
2315 return static_cast<_Tp&&>(__t);
2318 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2320 template <class _Tp>
2321 inline _LIBCPP_INLINE_VISIBILITY
2328 template <class _Tp>
2329 inline _LIBCPP_INLINE_VISIBILITY
2331 move(const _Tp& __t)
2336 template <class _Tp>
2337 inline _LIBCPP_INLINE_VISIBILITY
2339 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2345 template <class _Tp>
2348 typedef typename remove_reference<_Tp>::type _Trr;
2351 _LIBCPP_INLINE_VISIBILITY
2352 _Trr* operator->() {return &t_;}
2353 _LIBCPP_INLINE_VISIBILITY
2354 explicit __rv(_Trr& __t) : t_(__t) {}
2357 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2359 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2361 template <class _Tp>
2362 inline _LIBCPP_INLINE_VISIBILITY
2363 typename decay<_Tp>::type
2364 __decay_copy(_Tp&& __t)
2366 return _VSTD::forward<_Tp>(__t);
2371 template <class _Tp>
2372 inline _LIBCPP_INLINE_VISIBILITY
2373 typename decay<_Tp>::type
2374 __decay_copy(const _Tp& __t)
2376 return _VSTD::forward<_Tp>(__t);
2381 #ifndef _LIBCPP_HAS_NO_VARIADICS
2383 template <class _Rp, class _Class, class ..._Param>
2384 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2386 typedef _Class _ClassType;
2387 typedef _Rp _ReturnType;
2388 typedef _Rp (_FnType) (_Param...);
2391 template <class _Rp, class _Class, class ..._Param>
2392 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2394 typedef _Class _ClassType;
2395 typedef _Rp _ReturnType;
2396 typedef _Rp (_FnType) (_Param..., ...);
2399 template <class _Rp, class _Class, class ..._Param>
2400 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2402 typedef _Class const _ClassType;
2403 typedef _Rp _ReturnType;
2404 typedef _Rp (_FnType) (_Param...);
2407 template <class _Rp, class _Class, class ..._Param>
2408 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2410 typedef _Class const _ClassType;
2411 typedef _Rp _ReturnType;
2412 typedef _Rp (_FnType) (_Param..., ...);
2415 template <class _Rp, class _Class, class ..._Param>
2416 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2418 typedef _Class volatile _ClassType;
2419 typedef _Rp _ReturnType;
2420 typedef _Rp (_FnType) (_Param...);
2423 template <class _Rp, class _Class, class ..._Param>
2424 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2426 typedef _Class volatile _ClassType;
2427 typedef _Rp _ReturnType;
2428 typedef _Rp (_FnType) (_Param..., ...);
2431 template <class _Rp, class _Class, class ..._Param>
2432 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2434 typedef _Class const volatile _ClassType;
2435 typedef _Rp _ReturnType;
2436 typedef _Rp (_FnType) (_Param...);
2439 template <class _Rp, class _Class, class ..._Param>
2440 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2442 typedef _Class const volatile _ClassType;
2443 typedef _Rp _ReturnType;
2444 typedef _Rp (_FnType) (_Param..., ...);
2447 #if __has_feature(cxx_reference_qualified_functions) || \
2448 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2450 template <class _Rp, class _Class, class ..._Param>
2451 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2453 typedef _Class& _ClassType;
2454 typedef _Rp _ReturnType;
2455 typedef _Rp (_FnType) (_Param...);
2458 template <class _Rp, class _Class, class ..._Param>
2459 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2461 typedef _Class& _ClassType;
2462 typedef _Rp _ReturnType;
2463 typedef _Rp (_FnType) (_Param..., ...);
2466 template <class _Rp, class _Class, class ..._Param>
2467 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2469 typedef _Class const& _ClassType;
2470 typedef _Rp _ReturnType;
2471 typedef _Rp (_FnType) (_Param...);
2474 template <class _Rp, class _Class, class ..._Param>
2475 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2477 typedef _Class const& _ClassType;
2478 typedef _Rp _ReturnType;
2479 typedef _Rp (_FnType) (_Param..., ...);
2482 template <class _Rp, class _Class, class ..._Param>
2483 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2485 typedef _Class volatile& _ClassType;
2486 typedef _Rp _ReturnType;
2487 typedef _Rp (_FnType) (_Param...);
2490 template <class _Rp, class _Class, class ..._Param>
2491 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2493 typedef _Class volatile& _ClassType;
2494 typedef _Rp _ReturnType;
2495 typedef _Rp (_FnType) (_Param..., ...);
2498 template <class _Rp, class _Class, class ..._Param>
2499 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2501 typedef _Class const volatile& _ClassType;
2502 typedef _Rp _ReturnType;
2503 typedef _Rp (_FnType) (_Param...);
2506 template <class _Rp, class _Class, class ..._Param>
2507 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2509 typedef _Class const volatile& _ClassType;
2510 typedef _Rp _ReturnType;
2511 typedef _Rp (_FnType) (_Param..., ...);
2514 template <class _Rp, class _Class, class ..._Param>
2515 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2517 typedef _Class&& _ClassType;
2518 typedef _Rp _ReturnType;
2519 typedef _Rp (_FnType) (_Param...);
2522 template <class _Rp, class _Class, class ..._Param>
2523 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2525 typedef _Class&& _ClassType;
2526 typedef _Rp _ReturnType;
2527 typedef _Rp (_FnType) (_Param..., ...);
2530 template <class _Rp, class _Class, class ..._Param>
2531 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2533 typedef _Class const&& _ClassType;
2534 typedef _Rp _ReturnType;
2535 typedef _Rp (_FnType) (_Param...);
2538 template <class _Rp, class _Class, class ..._Param>
2539 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2541 typedef _Class const&& _ClassType;
2542 typedef _Rp _ReturnType;
2543 typedef _Rp (_FnType) (_Param..., ...);
2546 template <class _Rp, class _Class, class ..._Param>
2547 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2549 typedef _Class volatile&& _ClassType;
2550 typedef _Rp _ReturnType;
2551 typedef _Rp (_FnType) (_Param...);
2554 template <class _Rp, class _Class, class ..._Param>
2555 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2557 typedef _Class volatile&& _ClassType;
2558 typedef _Rp _ReturnType;
2559 typedef _Rp (_FnType) (_Param..., ...);
2562 template <class _Rp, class _Class, class ..._Param>
2563 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2565 typedef _Class const volatile&& _ClassType;
2566 typedef _Rp _ReturnType;
2567 typedef _Rp (_FnType) (_Param...);
2570 template <class _Rp, class _Class, class ..._Param>
2571 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2573 typedef _Class const volatile&& _ClassType;
2574 typedef _Rp _ReturnType;
2575 typedef _Rp (_FnType) (_Param..., ...);
2578 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2580 #else // _LIBCPP_HAS_NO_VARIADICS
2582 template <class _Rp, class _Class>
2583 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2585 typedef _Class _ClassType;
2586 typedef _Rp _ReturnType;
2587 typedef _Rp (_FnType) ();
2590 template <class _Rp, class _Class>
2591 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2593 typedef _Class _ClassType;
2594 typedef _Rp _ReturnType;
2595 typedef _Rp (_FnType) (...);
2598 template <class _Rp, class _Class, class _P0>
2599 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2601 typedef _Class _ClassType;
2602 typedef _Rp _ReturnType;
2603 typedef _Rp (_FnType) (_P0);
2606 template <class _Rp, class _Class, class _P0>
2607 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2609 typedef _Class _ClassType;
2610 typedef _Rp _ReturnType;
2611 typedef _Rp (_FnType) (_P0, ...);
2614 template <class _Rp, class _Class, class _P0, class _P1>
2615 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2617 typedef _Class _ClassType;
2618 typedef _Rp _ReturnType;
2619 typedef _Rp (_FnType) (_P0, _P1);
2622 template <class _Rp, class _Class, class _P0, class _P1>
2623 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2625 typedef _Class _ClassType;
2626 typedef _Rp _ReturnType;
2627 typedef _Rp (_FnType) (_P0, _P1, ...);
2630 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2631 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2633 typedef _Class _ClassType;
2634 typedef _Rp _ReturnType;
2635 typedef _Rp (_FnType) (_P0, _P1, _P2);
2638 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2639 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2641 typedef _Class _ClassType;
2642 typedef _Rp _ReturnType;
2643 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2646 template <class _Rp, class _Class>
2647 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2649 typedef _Class const _ClassType;
2650 typedef _Rp _ReturnType;
2651 typedef _Rp (_FnType) ();
2654 template <class _Rp, class _Class>
2655 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2657 typedef _Class const _ClassType;
2658 typedef _Rp _ReturnType;
2659 typedef _Rp (_FnType) (...);
2662 template <class _Rp, class _Class, class _P0>
2663 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2665 typedef _Class const _ClassType;
2666 typedef _Rp _ReturnType;
2667 typedef _Rp (_FnType) (_P0);
2670 template <class _Rp, class _Class, class _P0>
2671 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2673 typedef _Class const _ClassType;
2674 typedef _Rp _ReturnType;
2675 typedef _Rp (_FnType) (_P0, ...);
2678 template <class _Rp, class _Class, class _P0, class _P1>
2679 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2681 typedef _Class const _ClassType;
2682 typedef _Rp _ReturnType;
2683 typedef _Rp (_FnType) (_P0, _P1);
2686 template <class _Rp, class _Class, class _P0, class _P1>
2687 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2689 typedef _Class const _ClassType;
2690 typedef _Rp _ReturnType;
2691 typedef _Rp (_FnType) (_P0, _P1, ...);
2694 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2695 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2697 typedef _Class const _ClassType;
2698 typedef _Rp _ReturnType;
2699 typedef _Rp (_FnType) (_P0, _P1, _P2);
2702 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2703 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2705 typedef _Class const _ClassType;
2706 typedef _Rp _ReturnType;
2707 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2710 template <class _Rp, class _Class>
2711 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2713 typedef _Class volatile _ClassType;
2714 typedef _Rp _ReturnType;
2715 typedef _Rp (_FnType) ();
2718 template <class _Rp, class _Class>
2719 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2721 typedef _Class volatile _ClassType;
2722 typedef _Rp _ReturnType;
2723 typedef _Rp (_FnType) (...);
2726 template <class _Rp, class _Class, class _P0>
2727 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2729 typedef _Class volatile _ClassType;
2730 typedef _Rp _ReturnType;
2731 typedef _Rp (_FnType) (_P0);
2734 template <class _Rp, class _Class, class _P0>
2735 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2737 typedef _Class volatile _ClassType;
2738 typedef _Rp _ReturnType;
2739 typedef _Rp (_FnType) (_P0, ...);
2742 template <class _Rp, class _Class, class _P0, class _P1>
2743 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2745 typedef _Class volatile _ClassType;
2746 typedef _Rp _ReturnType;
2747 typedef _Rp (_FnType) (_P0, _P1);
2750 template <class _Rp, class _Class, class _P0, class _P1>
2751 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2753 typedef _Class volatile _ClassType;
2754 typedef _Rp _ReturnType;
2755 typedef _Rp (_FnType) (_P0, _P1, ...);
2758 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2759 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2761 typedef _Class volatile _ClassType;
2762 typedef _Rp _ReturnType;
2763 typedef _Rp (_FnType) (_P0, _P1, _P2);
2766 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2767 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2769 typedef _Class volatile _ClassType;
2770 typedef _Rp _ReturnType;
2771 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2774 template <class _Rp, class _Class>
2775 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2777 typedef _Class const volatile _ClassType;
2778 typedef _Rp _ReturnType;
2779 typedef _Rp (_FnType) ();
2782 template <class _Rp, class _Class>
2783 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2785 typedef _Class const volatile _ClassType;
2786 typedef _Rp _ReturnType;
2787 typedef _Rp (_FnType) (...);
2790 template <class _Rp, class _Class, class _P0>
2791 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2793 typedef _Class const volatile _ClassType;
2794 typedef _Rp _ReturnType;
2795 typedef _Rp (_FnType) (_P0);
2798 template <class _Rp, class _Class, class _P0>
2799 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2801 typedef _Class const volatile _ClassType;
2802 typedef _Rp _ReturnType;
2803 typedef _Rp (_FnType) (_P0, ...);
2806 template <class _Rp, class _Class, class _P0, class _P1>
2807 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2809 typedef _Class const volatile _ClassType;
2810 typedef _Rp _ReturnType;
2811 typedef _Rp (_FnType) (_P0, _P1);
2814 template <class _Rp, class _Class, class _P0, class _P1>
2815 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2817 typedef _Class const volatile _ClassType;
2818 typedef _Rp _ReturnType;
2819 typedef _Rp (_FnType) (_P0, _P1, ...);
2822 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2823 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2825 typedef _Class const volatile _ClassType;
2826 typedef _Rp _ReturnType;
2827 typedef _Rp (_FnType) (_P0, _P1, _P2);
2830 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2831 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2833 typedef _Class const volatile _ClassType;
2834 typedef _Rp _ReturnType;
2835 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2838 #endif // _LIBCPP_HAS_NO_VARIADICS
2840 template <class _Rp, class _Class>
2841 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2843 typedef _Class _ClassType;
2844 typedef _Rp _ReturnType;
2847 template <class _MP>
2848 struct __member_pointer_traits
2849 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2850 is_member_function_pointer<_MP>::value,
2851 is_member_object_pointer<_MP>::value>
2853 // typedef ... _ClassType;
2854 // typedef ... _ReturnType;
2855 // typedef ... _FnType;
2859 template <class _DecayedFp>
2860 struct __member_pointer_class_type {};
2862 template <class _Ret, class _ClassType>
2863 struct __member_pointer_class_type<_Ret _ClassType::*> {
2864 typedef _ClassType type;
2869 template <class _Callable> class result_of;
2871 #ifdef _LIBCPP_HAS_NO_VARIADICS
2873 template <class _Fn, bool, bool>
2878 template <class _Fn>
2879 class __result_of<_Fn(), true, false>
2882 typedef decltype(declval<_Fn>()()) type;
2885 template <class _Fn, class _A0>
2886 class __result_of<_Fn(_A0), true, false>
2889 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2892 template <class _Fn, class _A0, class _A1>
2893 class __result_of<_Fn(_A0, _A1), true, false>
2896 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2899 template <class _Fn, class _A0, class _A1, class _A2>
2900 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2903 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2906 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2907 struct __result_of_mp;
2909 // member function pointer
2911 template <class _MP, class _Tp>
2912 struct __result_of_mp<_MP, _Tp, true>
2913 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2917 // member data pointer
2919 template <class _MP, class _Tp, bool>
2920 struct __result_of_mdp;
2922 template <class _Rp, class _Class, class _Tp>
2923 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2925 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2928 template <class _Rp, class _Class, class _Tp>
2929 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2931 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2934 template <class _Rp, class _Class, class _Tp>
2935 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2936 : public __result_of_mdp<_Rp _Class::*, _Tp,
2937 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2943 template <class _Fn, class _Tp>
2944 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2945 : public __result_of_mp<typename remove_reference<_Fn>::type,
2947 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2951 template <class _Fn, class _Tp, class _A0>
2952 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2953 : public __result_of_mp<typename remove_reference<_Fn>::type,
2955 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2959 template <class _Fn, class _Tp, class _A0, class _A1>
2960 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2961 : public __result_of_mp<typename remove_reference<_Fn>::type,
2963 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2967 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2968 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2969 : public __result_of_mp<typename remove_reference<_Fn>::type,
2971 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2977 template <class _Fn>
2978 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2979 : public __result_of<_Fn(),
2980 is_class<typename remove_reference<_Fn>::type>::value ||
2981 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2982 is_member_pointer<typename remove_reference<_Fn>::type>::value
2987 template <class _Fn, class _A0>
2988 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2989 : public __result_of<_Fn(_A0),
2990 is_class<typename remove_reference<_Fn>::type>::value ||
2991 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2992 is_member_pointer<typename remove_reference<_Fn>::type>::value
2997 template <class _Fn, class _A0, class _A1>
2998 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2999 : public __result_of<_Fn(_A0, _A1),
3000 is_class<typename remove_reference<_Fn>::type>::value ||
3001 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3002 is_member_pointer<typename remove_reference<_Fn>::type>::value
3007 template <class _Fn, class _A0, class _A1, class _A2>
3008 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
3009 : public __result_of<_Fn(_A0, _A1, _A2),
3010 is_class<typename remove_reference<_Fn>::type>::value ||
3011 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3012 is_member_pointer<typename remove_reference<_Fn>::type>::value
3017 #endif // _LIBCPP_HAS_NO_VARIADICS
3019 // template <class T, class... Args> struct is_constructible;
3021 namespace __is_construct
3026 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
3027 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
3029 template <class _Tp, class... _Args>
3030 struct __libcpp_is_constructible;
3032 template <class _To, class _From>
3033 struct __is_invalid_base_to_derived_cast {
3034 static_assert(is_reference<_To>::value, "Wrong specialization");
3035 using _RawFrom = __uncvref_t<_From>;
3036 using _RawTo = __uncvref_t<_To>;
3037 static const bool value = __lazy_and<
3038 __lazy_not<is_same<_RawFrom, _RawTo>>,
3039 is_base_of<_RawFrom, _RawTo>,
3040 __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
3044 template <class _To, class _From>
3045 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
3046 static_assert(is_reference<_To>::value, "Wrong specialization");
3049 template <class _ToRef, class _FromRef>
3050 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
3051 using _RawFrom = __uncvref_t<_FromRef>;
3052 using _RawTo = __uncvref_t<_ToRef>;
3053 static const bool value = __lazy_and<
3054 __lazy_not<is_function<_RawTo>>,
3056 is_same<_RawFrom, _RawTo>,
3057 is_base_of<_RawTo, _RawFrom>>
3061 struct __is_constructible_helper
3063 template <class _To>
3064 static void __eat(_To);
3066 // This overload is needed to work around a Clang bug that disallows
3067 // static_cast<T&&>(e) for non-reference-compatible types.
3068 // Example: static_cast<int&&>(declval<double>());
3069 // NOTE: The static_cast implementation below is required to support
3070 // classes with explicit conversion operators.
3071 template <class _To, class _From,
3072 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
3073 static true_type __test_cast(int);
3075 template <class _To, class _From,
3076 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
3077 static integral_constant<bool,
3078 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
3079 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
3080 > __test_cast(long);
3082 template <class, class>
3083 static false_type __test_cast(...);
3085 template <class _Tp, class ..._Args,
3086 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
3087 static true_type __test_nary(int);
3088 template <class _Tp, class...>
3089 static false_type __test_nary(...);
3091 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
3092 static is_destructible<_Tp> __test_unary(int);
3093 template <class, class>
3094 static false_type __test_unary(...);
3097 template <class _Tp, bool = is_void<_Tp>::value>
3098 struct __is_default_constructible
3099 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
3102 template <class _Tp>
3103 struct __is_default_constructible<_Tp, true> : false_type {};
3105 template <class _Tp>
3106 struct __is_default_constructible<_Tp[], false> : false_type {};
3108 template <class _Tp, size_t _Nx>
3109 struct __is_default_constructible<_Tp[_Nx], false>
3110 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3112 template <class _Tp, class... _Args>
3113 struct __libcpp_is_constructible
3115 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3116 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3120 template <class _Tp>
3121 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3123 template <class _Tp, class _A0>
3124 struct __libcpp_is_constructible<_Tp, _A0>
3125 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3128 template <class _Tp, class _A0>
3129 struct __libcpp_is_constructible<_Tp&, _A0>
3130 : public decltype(__is_constructible_helper::
3131 __test_cast<_Tp&, _A0>(0))
3134 template <class _Tp, class _A0>
3135 struct __libcpp_is_constructible<_Tp&&, _A0>
3136 : public decltype(__is_constructible_helper::
3137 __test_cast<_Tp&&, _A0>(0))
3142 #if __has_feature(is_constructible)
3143 template <class _Tp, class ..._Args>
3144 struct _LIBCPP_TEMPLATE_VIS is_constructible
3145 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3147 #elif !defined(_LIBCPP_CXX03_LANG)
3148 template <class _Tp, class... _Args>
3149 struct _LIBCPP_TEMPLATE_VIS is_constructible
3150 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3152 // template <class T> struct is_constructible0;
3154 // main is_constructible0 test
3156 template <class _Tp>
3157 decltype((_Tp(), true_type()))
3158 __is_constructible0_test(_Tp&);
3161 __is_constructible0_test(__any);
3163 template <class _Tp, class _A0>
3164 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3165 __is_constructible1_test(_Tp&, _A0&);
3167 template <class _A0>
3169 __is_constructible1_test(__any, _A0&);
3171 template <class _Tp, class _A0, class _A1>
3172 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3173 __is_constructible2_test(_Tp&, _A0&, _A1&);
3175 template <class _A0, class _A1>
3177 __is_constructible2_test(__any, _A0&, _A1&);
3179 template <class _Tp, class _A0, class _A1, class _A2>
3180 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type()))
3181 __is_constructible3_test(_Tp&, _A0&, _A1&, _A2&);
3183 template <class _A0, class _A1, class _A2>
3185 __is_constructible3_test(__any, _A0&, _A1&, _A2&);
3187 template <bool, class _Tp>
3188 struct __is_constructible0_imp // false, _Tp is not a scalar
3189 : public common_type
3191 decltype(__is_constructible0_test(declval<_Tp&>()))
3195 template <bool, class _Tp, class _A0>
3196 struct __is_constructible1_imp // false, _Tp is not a scalar
3197 : public common_type
3199 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3203 template <bool, class _Tp, class _A0, class _A1>
3204 struct __is_constructible2_imp // false, _Tp is not a scalar
3205 : public common_type
3207 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3211 template <bool, class _Tp, class _A0, class _A1, class _A2>
3212 struct __is_constructible3_imp // false, _Tp is not a scalar
3213 : public common_type
3215 decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>()))
3219 // handle scalars and reference types
3221 // Scalars are default constructible, references are not
3223 template <class _Tp>
3224 struct __is_constructible0_imp<true, _Tp>
3225 : public is_scalar<_Tp>
3228 template <class _Tp, class _A0>
3229 struct __is_constructible1_imp<true, _Tp, _A0>
3230 : public is_convertible<_A0, _Tp>
3233 template <class _Tp, class _A0, class _A1>
3234 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3238 template <class _Tp, class _A0, class _A1, class _A2>
3239 struct __is_constructible3_imp<true, _Tp, _A0, _A1, _A2>
3243 // Treat scalars and reference types separately
3245 template <bool, class _Tp>
3246 struct __is_constructible0_void_check
3247 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3251 template <bool, class _Tp, class _A0>
3252 struct __is_constructible1_void_check
3253 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3257 template <bool, class _Tp, class _A0, class _A1>
3258 struct __is_constructible2_void_check
3259 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3263 template <bool, class _Tp, class _A0, class _A1, class _A2>
3264 struct __is_constructible3_void_check
3265 : public __is_constructible3_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3269 // If any of T or Args is void, is_constructible should be false
3271 template <class _Tp>
3272 struct __is_constructible0_void_check<true, _Tp>
3276 template <class _Tp, class _A0>
3277 struct __is_constructible1_void_check<true, _Tp, _A0>
3281 template <class _Tp, class _A0, class _A1>
3282 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3286 template <class _Tp, class _A0, class _A1, class _A2>
3287 struct __is_constructible3_void_check<true, _Tp, _A0, _A1, _A2>
3291 // is_constructible entry point
3293 template <class _Tp, class _A0 = __is_construct::__nat,
3294 class _A1 = __is_construct::__nat,
3295 class _A2 = __is_construct::__nat>
3296 struct _LIBCPP_TEMPLATE_VIS is_constructible
3297 : public __is_constructible3_void_check<is_void<_Tp>::value
3298 || is_abstract<_Tp>::value
3299 || is_function<_Tp>::value
3300 || is_void<_A0>::value
3301 || is_void<_A1>::value
3302 || is_void<_A2>::value,
3306 template <class _Tp>
3307 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3308 : public __is_constructible0_void_check<is_void<_Tp>::value
3309 || is_abstract<_Tp>::value
3310 || is_function<_Tp>::value,
3314 template <class _Tp, class _A0>
3315 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
3316 : public __is_constructible1_void_check<is_void<_Tp>::value
3317 || is_abstract<_Tp>::value
3318 || is_function<_Tp>::value
3319 || is_void<_A0>::value,
3323 template <class _Tp, class _A0, class _A1>
3324 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, _A1, __is_construct::__nat>
3325 : public __is_constructible2_void_check<is_void<_Tp>::value
3326 || is_abstract<_Tp>::value
3327 || is_function<_Tp>::value
3328 || is_void<_A0>::value
3329 || is_void<_A1>::value,
3333 // Array types are default constructible if their element type
3334 // is default constructible
3336 template <class _Ap, size_t _Np>
3337 struct __is_constructible0_imp<false, _Ap[_Np]>
3338 : public is_constructible<typename remove_all_extents<_Ap>::type>
3341 template <class _Ap, size_t _Np, class _A0>
3342 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3346 template <class _Ap, size_t _Np, class _A0, class _A1>
3347 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3351 template <class _Ap, size_t _Np, class _A0, class _A1, class _A2>
3352 struct __is_constructible3_imp<false, _Ap[_Np], _A0, _A1, _A2>
3356 // Incomplete array types are not constructible
3358 template <class _Ap>
3359 struct __is_constructible0_imp<false, _Ap[]>
3363 template <class _Ap, class _A0>
3364 struct __is_constructible1_imp<false, _Ap[], _A0>
3368 template <class _Ap, class _A0, class _A1>
3369 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3373 template <class _Ap, class _A0, class _A1, class _A2>
3374 struct __is_constructible3_imp<false, _Ap[], _A0, _A1, _A2>
3378 #endif // __has_feature(is_constructible)
3381 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3382 template <class _Tp, class ..._Args>
3383 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
3384 = is_constructible<_Tp, _Args...>::value;
3387 // is_default_constructible
3389 template <class _Tp>
3390 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3391 : public is_constructible<_Tp>
3394 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3395 template <class _Tp>
3396 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
3397 = is_default_constructible<_Tp>::value;
3400 // is_copy_constructible
3402 template <class _Tp>
3403 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3404 : public is_constructible<_Tp,
3405 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3407 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3408 template <class _Tp>
3409 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3410 = is_copy_constructible<_Tp>::value;
3413 // is_move_constructible
3415 template <class _Tp>
3416 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3417 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3418 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3420 : public is_copy_constructible<_Tp>
3424 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3425 template <class _Tp>
3426 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
3427 = is_move_constructible<_Tp>::value;
3430 // is_trivially_constructible
3432 #ifndef _LIBCPP_HAS_NO_VARIADICS
3434 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3436 template <class _Tp, class... _Args>
3437 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3438 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3442 #else // !__has_feature(is_trivially_constructible)
3444 template <class _Tp, class... _Args>
3445 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3450 template <class _Tp>
3451 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3452 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3453 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3455 : integral_constant<bool, is_scalar<_Tp>::value>
3460 template <class _Tp>
3461 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3462 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3464 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
3466 : integral_constant<bool, is_scalar<_Tp>::value>
3470 template <class _Tp>
3471 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3472 : integral_constant<bool, is_scalar<_Tp>::value>
3476 template <class _Tp>
3477 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3478 : integral_constant<bool, is_scalar<_Tp>::value>
3482 #endif // !__has_feature(is_trivially_constructible)
3484 #else // _LIBCPP_HAS_NO_VARIADICS
3486 template <class _Tp, class _A0 = __is_construct::__nat,
3487 class _A1 = __is_construct::__nat>
3488 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3493 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3495 template <class _Tp>
3496 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3497 __is_construct::__nat>
3498 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3502 template <class _Tp>
3503 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3504 __is_construct::__nat>
3505 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3509 template <class _Tp>
3510 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3511 __is_construct::__nat>
3512 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3516 template <class _Tp>
3517 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3518 __is_construct::__nat>
3519 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3523 #else // !__has_feature(is_trivially_constructible)
3525 template <class _Tp>
3526 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3527 __is_construct::__nat>
3528 : integral_constant<bool, is_scalar<_Tp>::value>
3532 template <class _Tp>
3533 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3534 __is_construct::__nat>
3535 : integral_constant<bool, is_scalar<_Tp>::value>
3539 template <class _Tp>
3540 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3541 __is_construct::__nat>
3542 : integral_constant<bool, is_scalar<_Tp>::value>
3546 template <class _Tp>
3547 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3548 __is_construct::__nat>
3549 : integral_constant<bool, is_scalar<_Tp>::value>
3553 #endif // !__has_feature(is_trivially_constructible)
3555 #endif // _LIBCPP_HAS_NO_VARIADICS
3557 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3558 template <class _Tp, class... _Args>
3559 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3560 = is_trivially_constructible<_Tp, _Args...>::value;
3563 // is_trivially_default_constructible
3565 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3566 : public is_trivially_constructible<_Tp>
3569 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3570 template <class _Tp>
3571 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3572 = is_trivially_default_constructible<_Tp>::value;
3575 // is_trivially_copy_constructible
3577 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3578 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3581 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3582 template <class _Tp>
3583 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3584 = is_trivially_copy_constructible<_Tp>::value;
3587 // is_trivially_move_constructible
3589 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3590 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3591 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3593 : public is_trivially_copy_constructible<_Tp>
3597 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3598 template <class _Tp>
3599 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3600 = is_trivially_move_constructible<_Tp>::value;
3603 // is_trivially_assignable
3605 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3607 template <class _Tp, class _Arg>
3608 struct is_trivially_assignable
3609 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3613 #else // !__has_feature(is_trivially_assignable)
3615 template <class _Tp, class _Arg>
3616 struct is_trivially_assignable
3617 : public false_type {};
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&, _Tp&>
3625 : integral_constant<bool, is_scalar<_Tp>::value> {};
3627 template <class _Tp>
3628 struct is_trivially_assignable<_Tp&, const _Tp&>
3629 : integral_constant<bool, is_scalar<_Tp>::value> {};
3631 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3633 template <class _Tp>
3634 struct is_trivially_assignable<_Tp&, _Tp&&>
3635 : integral_constant<bool, is_scalar<_Tp>::value> {};
3637 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3639 #endif // !__has_feature(is_trivially_assignable)
3641 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3642 template <class _Tp, class _Arg>
3643 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3644 = is_trivially_assignable<_Tp, _Arg>::value;
3647 // is_trivially_copy_assignable
3649 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3650 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3651 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3653 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3654 template <class _Tp>
3655 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3656 = is_trivially_copy_assignable<_Tp>::value;
3659 // is_trivially_move_assignable
3661 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3662 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3663 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3664 typename add_rvalue_reference<_Tp>::type>
3666 typename add_lvalue_reference<_Tp>::type>
3670 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3671 template <class _Tp>
3672 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3673 = is_trivially_move_assignable<_Tp>::value;
3676 // is_trivially_destructible
3678 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3680 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3681 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3685 template <class _Tp> struct __libcpp_trivial_destructor
3686 : public integral_constant<bool, is_scalar<_Tp>::value ||
3687 is_reference<_Tp>::value> {};
3689 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3690 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3692 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3693 : public false_type {};
3697 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3698 template <class _Tp>
3699 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3700 = is_trivially_destructible<_Tp>::value;
3703 // is_nothrow_constructible
3706 template <class _Tp, class... _Args>
3707 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3708 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3714 #ifndef _LIBCPP_HAS_NO_VARIADICS
3716 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3718 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3720 template <class _Tp, class... _Args>
3721 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3722 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3726 template <class _Tp>
3727 void __implicit_conversion_to(_Tp) noexcept { }
3729 template <class _Tp, class _Arg>
3730 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3731 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3735 template <class _Tp, bool _IsReference, class... _Args>
3736 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3741 template <class _Tp, class... _Args>
3742 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3743 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3747 template <class _Tp, size_t _Ns>
3748 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3749 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3753 #else // __has_feature(cxx_noexcept)
3755 template <class _Tp, class... _Args>
3756 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3761 template <class _Tp>
3762 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
3763 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3764 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3766 : integral_constant<bool, is_scalar<_Tp>::value>
3771 template <class _Tp>
3772 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3773 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
3775 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
3777 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3778 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3780 : integral_constant<bool, is_scalar<_Tp>::value>
3785 template <class _Tp>
3786 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
3787 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3788 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3790 : integral_constant<bool, is_scalar<_Tp>::value>
3795 template <class _Tp>
3796 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
3797 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3798 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3800 : integral_constant<bool, is_scalar<_Tp>::value>
3805 #endif // __has_feature(cxx_noexcept)
3807 #else // _LIBCPP_HAS_NO_VARIADICS
3809 template <class _Tp, class _A0 = __is_construct::__nat,
3810 class _A1 = __is_construct::__nat>
3811 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3816 template <class _Tp>
3817 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
3818 __is_construct::__nat>
3819 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3820 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3822 : integral_constant<bool, is_scalar<_Tp>::value>
3827 template <class _Tp>
3828 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
3829 __is_construct::__nat>
3830 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3831 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3833 : integral_constant<bool, is_scalar<_Tp>::value>
3838 template <class _Tp>
3839 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
3840 __is_construct::__nat>
3841 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3842 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3844 : integral_constant<bool, is_scalar<_Tp>::value>
3849 template <class _Tp>
3850 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
3851 __is_construct::__nat>
3852 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3853 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3855 : integral_constant<bool, is_scalar<_Tp>::value>
3860 #endif // _LIBCPP_HAS_NO_VARIADICS
3861 #endif // __has_feature(is_nothrow_constructible)
3863 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3864 template <class _Tp, class ..._Args>
3865 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3866 = is_nothrow_constructible<_Tp, _Args...>::value;
3869 // is_nothrow_default_constructible
3871 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3872 : public is_nothrow_constructible<_Tp>
3875 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3876 template <class _Tp>
3877 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3878 = is_nothrow_default_constructible<_Tp>::value;
3881 // is_nothrow_copy_constructible
3883 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3884 : public is_nothrow_constructible<_Tp,
3885 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3887 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3888 template <class _Tp>
3889 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3890 = is_nothrow_copy_constructible<_Tp>::value;
3893 // is_nothrow_move_constructible
3895 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3896 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3897 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3899 : public is_nothrow_copy_constructible<_Tp>
3903 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3904 template <class _Tp>
3905 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3906 = is_nothrow_move_constructible<_Tp>::value;
3909 // is_nothrow_assignable
3911 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3913 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3915 template <class _Tp, class _Arg>
3916 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3921 template <class _Tp, class _Arg>
3922 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3923 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3927 template <class _Tp, class _Arg>
3928 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3929 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3933 #else // __has_feature(cxx_noexcept)
3935 template <class _Tp, class _Arg>
3936 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3937 : public false_type {};
3939 template <class _Tp>
3940 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
3941 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3942 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3944 : integral_constant<bool, is_scalar<_Tp>::value> {};
3947 template <class _Tp>
3948 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
3949 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3950 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3952 : integral_constant<bool, is_scalar<_Tp>::value> {};
3955 template <class _Tp>
3956 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
3957 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3958 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3960 : integral_constant<bool, is_scalar<_Tp>::value> {};
3963 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3965 template <class _Tp>
3966 struct is_nothrow_assignable<_Tp&, _Tp&&>
3967 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3968 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3970 : integral_constant<bool, is_scalar<_Tp>::value> {};
3973 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3975 #endif // __has_feature(cxx_noexcept)
3977 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3978 template <class _Tp, class _Arg>
3979 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3980 = is_nothrow_assignable<_Tp, _Arg>::value;
3983 // is_nothrow_copy_assignable
3985 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3986 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3987 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3989 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3990 template <class _Tp>
3991 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3992 = is_nothrow_copy_assignable<_Tp>::value;
3995 // is_nothrow_move_assignable
3997 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3998 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3999 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4000 typename add_rvalue_reference<_Tp>::type>
4002 typename add_lvalue_reference<_Tp>::type>
4006 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4007 template <class _Tp>
4008 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
4009 = is_nothrow_move_assignable<_Tp>::value;
4012 // is_nothrow_destructible
4014 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
4016 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
4018 template <class _Tp>
4019 struct __libcpp_is_nothrow_destructible<false, _Tp>
4024 template <class _Tp>
4025 struct __libcpp_is_nothrow_destructible<true, _Tp>
4026 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
4030 template <class _Tp>
4031 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4032 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
4036 template <class _Tp, size_t _Ns>
4037 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
4038 : public is_nothrow_destructible<_Tp>
4042 template <class _Tp>
4043 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
4048 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4050 template <class _Tp>
4051 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
4060 template <class _Tp> struct __libcpp_nothrow_destructor
4061 : public integral_constant<bool, is_scalar<_Tp>::value ||
4062 is_reference<_Tp>::value> {};
4064 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4065 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
4067 template <class _Tp>
4068 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
4069 : public false_type {};
4073 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4074 template <class _Tp>
4075 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
4076 = is_nothrow_destructible<_Tp>::value;
4081 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
4083 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4084 : public integral_constant<bool, __is_pod(_Tp)> {};
4088 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4089 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
4090 is_trivially_copy_constructible<_Tp>::value &&
4091 is_trivially_copy_assignable<_Tp>::value &&
4092 is_trivially_destructible<_Tp>::value> {};
4096 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4097 template <class _Tp>
4098 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
4099 = is_pod<_Tp>::value;
4104 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
4105 #ifdef _LIBCPP_IS_LITERAL
4106 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
4108 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
4109 is_reference<typename remove_all_extents<_Tp>::type>::value>
4113 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4114 template <class _Tp>
4115 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
4116 = is_literal_type<_Tp>::value;
4119 // is_standard_layout;
4121 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
4122 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
4123 : public integral_constant<bool, __is_standard_layout(_Tp)>
4125 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4129 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4130 template <class _Tp>
4131 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
4132 = is_standard_layout<_Tp>::value;
4135 // is_trivially_copyable;
4137 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
4138 #if __has_feature(is_trivially_copyable)
4139 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
4140 #elif _GNUC_VER >= 501
4141 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
4143 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4147 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4148 template <class _Tp>
4149 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
4150 = is_trivially_copyable<_Tp>::value;
4155 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
4156 #if __has_feature(is_trivial) || _GNUC_VER >= 407
4157 : public integral_constant<bool, __is_trivial(_Tp)>
4159 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
4160 is_trivially_default_constructible<_Tp>::value>
4164 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4165 template <class _Tp>
4166 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
4167 = is_trivial<_Tp>::value;
4170 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
4171 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
4172 template <class _Tp> struct __is_reference_wrapper
4173 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
4175 #ifndef _LIBCPP_CXX03_LANG
4177 template <class _Fp, class _A0,
4178 class _DecayFp = typename decay<_Fp>::type,
4179 class _DecayA0 = typename decay<_A0>::type,
4180 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4181 using __enable_if_bullet1 = typename enable_if
4183 is_member_function_pointer<_DecayFp>::value
4184 && is_base_of<_ClassT, _DecayA0>::value
4187 template <class _Fp, class _A0,
4188 class _DecayFp = typename decay<_Fp>::type,
4189 class _DecayA0 = typename decay<_A0>::type>
4190 using __enable_if_bullet2 = typename enable_if
4192 is_member_function_pointer<_DecayFp>::value
4193 && __is_reference_wrapper<_DecayA0>::value
4196 template <class _Fp, class _A0,
4197 class _DecayFp = typename decay<_Fp>::type,
4198 class _DecayA0 = typename decay<_A0>::type,
4199 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4200 using __enable_if_bullet3 = typename enable_if
4202 is_member_function_pointer<_DecayFp>::value
4203 && !is_base_of<_ClassT, _DecayA0>::value
4204 && !__is_reference_wrapper<_DecayA0>::value
4207 template <class _Fp, class _A0,
4208 class _DecayFp = typename decay<_Fp>::type,
4209 class _DecayA0 = typename decay<_A0>::type,
4210 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4211 using __enable_if_bullet4 = typename enable_if
4213 is_member_object_pointer<_DecayFp>::value
4214 && is_base_of<_ClassT, _DecayA0>::value
4217 template <class _Fp, class _A0,
4218 class _DecayFp = typename decay<_Fp>::type,
4219 class _DecayA0 = typename decay<_A0>::type>
4220 using __enable_if_bullet5 = typename enable_if
4222 is_member_object_pointer<_DecayFp>::value
4223 && __is_reference_wrapper<_DecayA0>::value
4226 template <class _Fp, class _A0,
4227 class _DecayFp = typename decay<_Fp>::type,
4228 class _DecayA0 = typename decay<_A0>::type,
4229 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4230 using __enable_if_bullet6 = typename enable_if
4232 is_member_object_pointer<_DecayFp>::value
4233 && !is_base_of<_ClassT, _DecayA0>::value
4234 && !__is_reference_wrapper<_DecayA0>::value
4237 // __invoke forward declarations
4239 // fall back - none of the bullets
4241 #define _LIBCPP_INVOKE_RETURN(...) \
4242 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4243 { return __VA_ARGS__; }
4245 template <class ..._Args>
4246 auto __invoke(__any, _Args&& ...__args) -> __nat;
4248 template <class ..._Args>
4249 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4251 // bullets 1, 2 and 3
4253 template <class _Fp, class _A0, class ..._Args,
4254 class = __enable_if_bullet1<_Fp, _A0>>
4255 inline _LIBCPP_INLINE_VISIBILITY
4257 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4258 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4260 template <class _Fp, class _A0, class ..._Args,
4261 class = __enable_if_bullet1<_Fp, _A0>>
4262 inline _LIBCPP_INLINE_VISIBILITY
4263 _LIBCPP_CONSTEXPR auto
4264 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4265 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4267 template <class _Fp, class _A0, class ..._Args,
4268 class = __enable_if_bullet2<_Fp, _A0>>
4269 inline _LIBCPP_INLINE_VISIBILITY
4271 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4272 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4274 template <class _Fp, class _A0, class ..._Args,
4275 class = __enable_if_bullet2<_Fp, _A0>>
4276 inline _LIBCPP_INLINE_VISIBILITY
4277 _LIBCPP_CONSTEXPR auto
4278 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4279 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4281 template <class _Fp, class _A0, class ..._Args,
4282 class = __enable_if_bullet3<_Fp, _A0>>
4283 inline _LIBCPP_INLINE_VISIBILITY
4285 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4286 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4288 template <class _Fp, class _A0, class ..._Args,
4289 class = __enable_if_bullet3<_Fp, _A0>>
4290 inline _LIBCPP_INLINE_VISIBILITY
4291 _LIBCPP_CONSTEXPR auto
4292 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4293 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4295 // bullets 4, 5 and 6
4297 template <class _Fp, class _A0,
4298 class = __enable_if_bullet4<_Fp, _A0>>
4299 inline _LIBCPP_INLINE_VISIBILITY
4301 __invoke(_Fp&& __f, _A0&& __a0)
4302 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4304 template <class _Fp, class _A0,
4305 class = __enable_if_bullet4<_Fp, _A0>>
4306 inline _LIBCPP_INLINE_VISIBILITY
4307 _LIBCPP_CONSTEXPR auto
4308 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4309 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4311 template <class _Fp, class _A0,
4312 class = __enable_if_bullet5<_Fp, _A0>>
4313 inline _LIBCPP_INLINE_VISIBILITY
4315 __invoke(_Fp&& __f, _A0&& __a0)
4316 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4318 template <class _Fp, class _A0,
4319 class = __enable_if_bullet5<_Fp, _A0>>
4320 inline _LIBCPP_INLINE_VISIBILITY
4321 _LIBCPP_CONSTEXPR auto
4322 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4323 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4325 template <class _Fp, class _A0,
4326 class = __enable_if_bullet6<_Fp, _A0>>
4327 inline _LIBCPP_INLINE_VISIBILITY
4329 __invoke(_Fp&& __f, _A0&& __a0)
4330 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4332 template <class _Fp, class _A0,
4333 class = __enable_if_bullet6<_Fp, _A0>>
4334 inline _LIBCPP_INLINE_VISIBILITY
4335 _LIBCPP_CONSTEXPR auto
4336 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4337 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4341 template <class _Fp, class ..._Args>
4342 inline _LIBCPP_INLINE_VISIBILITY
4344 __invoke(_Fp&& __f, _Args&& ...__args)
4345 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4347 template <class _Fp, class ..._Args>
4348 inline _LIBCPP_INLINE_VISIBILITY
4349 _LIBCPP_CONSTEXPR auto
4350 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4351 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4353 #undef _LIBCPP_INVOKE_RETURN
4357 template <class _Ret, class _Fp, class ..._Args>
4358 struct __invokable_r
4360 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
4361 // or incomplete array types as required by the standard.
4362 using _Result = decltype(
4363 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4366 typename conditional<
4367 !is_same<_Result, __nat>::value,
4368 typename conditional<
4369 is_void<_Ret>::value,
4371 is_convertible<_Result, _Ret>
4375 static const bool value = type::value;
4378 template <class _Fp, class ..._Args>
4379 using __invokable = __invokable_r<void, _Fp, _Args...>;
4381 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4382 struct __nothrow_invokable_r_imp {
4383 static const bool value = false;
4386 template <class _Ret, class _Fp, class ..._Args>
4387 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4389 typedef __nothrow_invokable_r_imp _ThisT;
4391 template <class _Tp>
4392 static void __test_noexcept(_Tp) noexcept;
4394 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4395 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4398 template <class _Ret, class _Fp, class ..._Args>
4399 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4401 static const bool value = noexcept(
4402 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4405 template <class _Ret, class _Fp, class ..._Args>
4406 using __nothrow_invokable_r =
4407 __nothrow_invokable_r_imp<
4408 __invokable_r<_Ret, _Fp, _Args...>::value,
4409 is_void<_Ret>::value,
4413 template <class _Fp, class ..._Args>
4414 using __nothrow_invokable =
4415 __nothrow_invokable_r_imp<
4416 __invokable<_Fp, _Args...>::value,
4417 true, void, _Fp, _Args...
4420 template <class _Fp, class ..._Args>
4423 __invokable<_Fp, _Args...>::value,
4424 typename __invokable_r<void, _Fp, _Args...>::_Result>
4430 template <class _Fp, class ..._Args>
4431 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
4432 : public __invoke_of<_Fp, _Args...>
4436 #if _LIBCPP_STD_VER > 11
4437 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4440 #if _LIBCPP_STD_VER > 14
4444 template <class _Fn, class... _Args>
4445 struct _LIBCPP_TEMPLATE_VIS invoke_result
4446 : __invoke_of<_Fn, _Args...>
4450 template <class _Fn, class... _Args>
4451 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
4455 template <class _Fn, class ..._Args>
4456 struct _LIBCPP_TEMPLATE_VIS is_invocable
4457 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
4459 template <class _Ret, class _Fn, class ..._Args>
4460 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
4461 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4463 template <class _Fn, class ..._Args>
4464 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
4465 = is_invocable<_Fn, _Args...>::value;
4467 template <class _Ret, class _Fn, class ..._Args>
4468 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
4469 = is_invocable_r<_Ret, _Fn, _Args...>::value;
4471 // is_nothrow_invocable
4473 template <class _Fn, class ..._Args>
4474 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
4475 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
4477 template <class _Ret, class _Fn, class ..._Args>
4478 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
4479 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
4481 template <class _Fn, class ..._Args>
4482 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
4483 = is_nothrow_invocable<_Fn, _Args...>::value;
4485 template <class _Ret, class _Fn, class ..._Args>
4486 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
4487 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
4489 #endif // _LIBCPP_STD_VER > 14
4491 #endif // !defined(_LIBCPP_CXX03_LANG)
4493 template <class _Tp> struct __is_swappable;
4494 template <class _Tp> struct __is_nothrow_swappable;
4496 template <class _Tp>
4497 inline _LIBCPP_INLINE_VISIBILITY
4498 #ifndef _LIBCPP_CXX03_LANG
4501 is_move_constructible<_Tp>::value &&
4502 is_move_assignable<_Tp>::value
4507 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4508 is_nothrow_move_assignable<_Tp>::value)
4510 _Tp __t(_VSTD::move(__x));
4511 __x = _VSTD::move(__y);
4512 __y = _VSTD::move(__t);
4515 template<class _Tp, size_t _Np>
4516 inline _LIBCPP_INLINE_VISIBILITY
4518 __is_swappable<_Tp>::value
4520 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4522 template <class _ForwardIterator1, class _ForwardIterator2>
4523 inline _LIBCPP_INLINE_VISIBILITY
4525 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4526 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4527 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4528 *_VSTD::declval<_ForwardIterator2>())))
4537 // ALL generic swap overloads MUST already have a declaration available at this point.
4539 template <class _Tp, class _Up = _Tp,
4540 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4541 struct __swappable_with
4543 template <class _LHS, class _RHS>
4544 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4546 template <class, class>
4547 static __nat __test_swap(long);
4549 // Extra parens are needed for the C++03 definition of decltype.
4550 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4551 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4553 static const bool value = !is_same<__swap1, __nat>::value
4554 && !is_same<__swap2, __nat>::value;
4557 template <class _Tp, class _Up>
4558 struct __swappable_with<_Tp, _Up, false> : false_type {};
4560 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4561 struct __nothrow_swappable_with {
4562 static const bool value =
4563 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4564 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4565 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4571 template <class _Tp, class _Up>
4572 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4576 template <class _Tp>
4577 struct __is_swappable
4578 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4582 template <class _Tp>
4583 struct __is_nothrow_swappable
4584 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4588 #if _LIBCPP_STD_VER > 14
4590 template <class _Tp, class _Up>
4591 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4592 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4596 template <class _Tp>
4597 struct _LIBCPP_TEMPLATE_VIS is_swappable
4598 : public conditional<
4599 __is_referenceable<_Tp>::value,
4601 typename add_lvalue_reference<_Tp>::type,
4602 typename add_lvalue_reference<_Tp>::type>,
4608 template <class _Tp, class _Up>
4609 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4610 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4614 template <class _Tp>
4615 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4616 : public conditional<
4617 __is_referenceable<_Tp>::value,
4618 is_nothrow_swappable_with<
4619 typename add_lvalue_reference<_Tp>::type,
4620 typename add_lvalue_reference<_Tp>::type>,
4626 template <class _Tp, class _Up>
4627 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
4628 = is_swappable_with<_Tp, _Up>::value;
4630 template <class _Tp>
4631 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
4632 = is_swappable<_Tp>::value;
4634 template <class _Tp, class _Up>
4635 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
4636 = is_nothrow_swappable_with<_Tp, _Up>::value;
4638 template <class _Tp>
4639 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
4640 = is_nothrow_swappable<_Tp>::value;
4642 #endif // _LIBCPP_STD_VER > 14
4644 #ifdef _LIBCPP_UNDERLYING_TYPE
4646 template <class _Tp>
4647 struct underlying_type
4649 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4652 #if _LIBCPP_STD_VER > 11
4653 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4656 #else // _LIBCPP_UNDERLYING_TYPE
4658 template <class _Tp, bool _Support = false>
4659 struct underlying_type
4661 static_assert(_Support, "The underyling_type trait requires compiler "
4662 "support. Either no such support exists or "
4663 "libc++ does not know how to use it.");
4666 #endif // _LIBCPP_UNDERLYING_TYPE
4669 template <class _Tp, bool = is_enum<_Tp>::value>
4670 struct __sfinae_underlying_type
4672 typedef typename underlying_type<_Tp>::type type;
4673 typedef decltype(((type)1) + 0) __promoted_type;
4676 template <class _Tp>
4677 struct __sfinae_underlying_type<_Tp, false> {};
4679 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4680 int __convert_to_integral(int __val) { return __val; }
4682 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4683 unsigned __convert_to_integral(unsigned __val) { return __val; }
4685 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4686 long __convert_to_integral(long __val) { return __val; }
4688 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4689 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4691 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4692 long long __convert_to_integral(long long __val) { return __val; }
4694 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4695 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4697 template<typename _Fp>
4698 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4699 typename enable_if<is_floating_point<_Fp>::value, long long>::type
4700 __convert_to_integral(_Fp __val) { return __val; }
4702 #ifndef _LIBCPP_HAS_NO_INT128
4703 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4704 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4706 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4707 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4710 template <class _Tp>
4711 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4712 typename __sfinae_underlying_type<_Tp>::__promoted_type
4713 __convert_to_integral(_Tp __val) { return __val; }
4715 #ifndef _LIBCPP_CXX03_LANG
4717 template <class _Tp>
4718 struct __has_operator_addressof_member_imp
4720 template <class _Up>
4721 static auto __test(int)
4722 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4724 static auto __test(long) -> false_type;
4726 static const bool value = decltype(__test<_Tp>(0))::value;
4729 template <class _Tp>
4730 struct __has_operator_addressof_free_imp
4732 template <class _Up>
4733 static auto __test(int)
4734 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4736 static auto __test(long) -> false_type;
4738 static const bool value = decltype(__test<_Tp>(0))::value;
4741 template <class _Tp>
4742 struct __has_operator_addressof
4743 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4744 || __has_operator_addressof_free_imp<_Tp>::value>
4747 #endif // _LIBCPP_CXX03_LANG
4749 #if _LIBCPP_STD_VER > 14
4751 #define __cpp_lib_void_t 201411
4752 template <class...> using void_t = void;
4754 # ifndef _LIBCPP_HAS_NO_VARIADICS
4755 template <class... _Args>
4756 struct conjunction : __and_<_Args...> {};
4757 template<class... _Args>
4758 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
4759 = conjunction<_Args...>::value;
4761 template <class... _Args>
4762 struct disjunction : __or_<_Args...> {};
4763 template<class... _Args>
4764 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
4765 = disjunction<_Args...>::value;
4767 template <class _Tp>
4768 struct negation : __not_<_Tp> {};
4770 _LIBCPP_INLINE_VAR constexpr bool negation_v
4771 = negation<_Tp>::value;
4772 # endif // _LIBCPP_HAS_NO_VARIADICS
4773 #endif // _LIBCPP_STD_VER > 14
4775 // These traits are used in __tree and __hash_table
4776 #ifndef _LIBCPP_CXX03_LANG
4777 struct __extract_key_fail_tag {};
4778 struct __extract_key_self_tag {};
4779 struct __extract_key_first_tag {};
4781 template <class _ValTy, class _Key,
4782 class _RawValTy = typename __unconstref<_ValTy>::type>
4783 struct __can_extract_key
4784 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4785 __extract_key_fail_tag>::type {};
4787 template <class _Pair, class _Key, class _First, class _Second>
4788 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4789 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4790 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4792 // __can_extract_map_key uses true_type/false_type instead of the tags.
4793 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4794 // and _ValTy == _Key.
4795 template <class _ValTy, class _Key, class _ContainerValueTy,
4796 class _RawValTy = typename __unconstref<_ValTy>::type>
4797 struct __can_extract_map_key
4798 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4800 // This specialization returns __extract_key_fail_tag for non-map containers
4801 // because _Key == _ContainerValueTy
4802 template <class _ValTy, class _Key, class _RawValTy>
4803 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4808 #if _LIBCPP_STD_VER > 17
4813 #if defined(_LIBCPP_LITTLE_ENDIAN)
4815 #elif defined(_LIBCPP_BIG_ENDIAN)
4823 _LIBCPP_END_NAMESPACE_STD
4825 #if _LIBCPP_STD_VER > 14
4827 namespace std // purposefully not versioned
4829 template <class _Integer>
4830 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4831 operator<<=(byte& __lhs, _Integer __shift) noexcept
4832 { return __lhs = __lhs << __shift; }
4834 template <class _Integer>
4835 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4836 operator<< (byte __lhs, _Integer __shift) noexcept
4837 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
4839 template <class _Integer>
4840 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4841 operator>>=(byte& __lhs, _Integer __shift) noexcept
4842 { return __lhs = __lhs >> __shift; }
4844 template <class _Integer>
4845 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4846 operator>> (byte __lhs, _Integer __shift) noexcept
4847 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4849 template <class _Integer>
4850 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4851 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4856 #endif // _LIBCPP_TYPE_TRAITS