2 //===------------------------ type_traits ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_TYPE_TRAITS
12 #define _LIBCPP_TYPE_TRAITS
21 template <class T, T v> struct integral_constant;
22 typedef integral_constant<bool, true> true_type; // C++11
23 typedef integral_constant<bool, false> false_type; // C++11
25 template <bool B> // C++14
26 using bool_constant = integral_constant<bool, B>; // C++14
27 typedef bool_constant<true> true_type; // C++14
28 typedef bool_constant<false> false_type; // C++14
31 template <bool, class T = void> struct enable_if;
32 template <bool, class T, class F> struct conditional;
34 // Primary classification traits:
35 template <class T> struct is_void;
36 template <class T> struct is_null_pointer; // C++14
37 template <class T> struct is_integral;
38 template <class T> struct is_floating_point;
39 template <class T> struct is_array;
40 template <class T> struct is_pointer;
41 template <class T> struct is_lvalue_reference;
42 template <class T> struct is_rvalue_reference;
43 template <class T> struct is_member_object_pointer;
44 template <class T> struct is_member_function_pointer;
45 template <class T> struct is_enum;
46 template <class T> struct is_union;
47 template <class T> struct is_class;
48 template <class T> struct is_function;
50 // Secondary classification traits:
51 template <class T> struct is_reference;
52 template <class T> struct is_arithmetic;
53 template <class T> struct is_fundamental;
54 template <class T> struct is_member_pointer;
55 template <class T> struct is_scalar;
56 template <class T> struct is_object;
57 template <class T> struct is_compound;
59 // Const-volatile properties and transformations:
60 template <class T> struct is_const;
61 template <class T> struct is_volatile;
62 template <class T> struct remove_const;
63 template <class T> struct remove_volatile;
64 template <class T> struct remove_cv;
65 template <class T> struct add_const;
66 template <class T> struct add_volatile;
67 template <class T> struct add_cv;
69 // Reference transformations:
70 template <class T> struct remove_reference;
71 template <class T> struct add_lvalue_reference;
72 template <class T> struct add_rvalue_reference;
74 // Pointer transformations:
75 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;
78 // Integral properties:
79 template <class T> struct is_signed;
80 template <class T> struct is_unsigned;
81 template <class T> struct make_signed;
82 template <class T> struct make_unsigned;
84 // Array properties and transformations:
85 template <class T> struct rank;
86 template <class T, unsigned I = 0> struct extent;
87 template <class T> struct remove_extent;
88 template <class T> struct remove_all_extents;
90 // Member introspection:
91 template <class T> struct is_pod;
92 template <class T> struct is_trivial;
93 template <class T> struct is_trivially_copyable;
94 template <class T> struct is_standard_layout;
95 template <class T> struct is_literal_type;
96 template <class T> struct is_empty;
97 template <class T> struct is_polymorphic;
98 template <class T> struct is_abstract;
99 template <class T> struct is_final; // C++14
100 template <class T> struct is_aggregate; // C++17
102 template <class T, class... Args> struct is_constructible;
103 template <class T> struct is_default_constructible;
104 template <class T> struct is_copy_constructible;
105 template <class T> struct is_move_constructible;
106 template <class T, class U> struct is_assignable;
107 template <class T> struct is_copy_assignable;
108 template <class T> struct is_move_assignable;
109 template <class T, class U> struct is_swappable_with; // C++17
110 template <class T> struct is_swappable; // C++17
111 template <class T> struct is_destructible;
113 template <class T, class... Args> struct is_trivially_constructible;
114 template <class T> struct is_trivially_default_constructible;
115 template <class T> struct is_trivially_copy_constructible;
116 template <class T> struct is_trivially_move_constructible;
117 template <class T, class U> struct is_trivially_assignable;
118 template <class T> struct is_trivially_copy_assignable;
119 template <class T> struct is_trivially_move_assignable;
120 template <class T> struct is_trivially_destructible;
122 template <class T, class... Args> struct is_nothrow_constructible;
123 template <class T> struct is_nothrow_default_constructible;
124 template <class T> struct is_nothrow_copy_constructible;
125 template <class T> struct is_nothrow_move_constructible;
126 template <class T, class U> struct is_nothrow_assignable;
127 template <class T> struct is_nothrow_copy_assignable;
128 template <class T> struct is_nothrow_move_assignable;
129 template <class T, class U> struct is_nothrow_swappable_with; // C++17
130 template <class T> struct is_nothrow_swappable; // C++17
131 template <class T> struct is_nothrow_destructible;
133 template <class T> struct has_virtual_destructor;
135 template<class T> struct has_unique_object_representations; // C++17
137 // Relationships between types:
138 template <class T, class U> struct is_same;
139 template <class Base, class Derived> struct is_base_of;
140 template <class From, class To> struct is_convertible;
142 template <class Fn, class... ArgTypes> struct is_invocable;
143 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
145 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
146 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
148 // Alignment properties and transformations:
149 template <class T> struct alignment_of;
150 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
151 struct aligned_storage;
152 template <size_t Len, class... Types> struct aligned_union;
153 template <class T> struct remove_cvref; // C++20
155 template <class T> struct decay;
156 template <class... T> struct common_type;
157 template <class T> struct underlying_type;
158 template <class> class result_of; // undefined
159 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
160 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
162 // const-volatile modifications:
164 using remove_const_t = typename remove_const<T>::type; // C++14
166 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
168 using remove_cv_t = typename remove_cv<T>::type; // C++14
170 using add_const_t = typename add_const<T>::type; // C++14
172 using add_volatile_t = typename add_volatile<T>::type; // C++14
174 using add_cv_t = typename add_cv<T>::type; // C++14
176 // reference modifications:
178 using remove_reference_t = typename remove_reference<T>::type; // C++14
180 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
182 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
184 // sign modifications:
186 using make_signed_t = typename make_signed<T>::type; // C++14
188 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
190 // array modifications:
192 using remove_extent_t = typename remove_extent<T>::type; // C++14
194 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
196 // pointer modifications:
198 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
200 using add_pointer_t = typename add_pointer<T>::type; // C++14
202 // other transformations:
203 template <size_t Len, std::size_t Align=default-alignment>
204 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
205 template <std::size_t Len, class... Types>
206 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
208 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
210 using decay_t = typename decay<T>::type; // C++14
211 template <bool b, class T=void>
212 using enable_if_t = typename enable_if<b,T>::type; // C++14
213 template <bool b, class T, class F>
214 using conditional_t = typename conditional<b,T,F>::type; // C++14
215 template <class... T>
216 using common_type_t = typename common_type<T...>::type; // C++14
218 using underlying_type_t = typename underlying_type<T>::type; // C++14
220 using result_of_t = typename result_of<T>::type; // C++14
221 template <class Fn, class... ArgTypes>
222 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
225 using void_t = void; // C++17
227 // See C++14 20.10.4.1, primary type categories
228 template <class T> inline constexpr bool is_void_v
229 = is_void<T>::value; // C++17
230 template <class T> inline constexpr bool is_null_pointer_v
231 = is_null_pointer<T>::value; // C++17
232 template <class T> inline constexpr bool is_integral_v
233 = is_integral<T>::value; // C++17
234 template <class T> inline constexpr bool is_floating_point_v
235 = is_floating_point<T>::value; // C++17
236 template <class T> inline constexpr bool is_array_v
237 = is_array<T>::value; // C++17
238 template <class T> inline constexpr bool is_pointer_v
239 = is_pointer<T>::value; // C++17
240 template <class T> inline constexpr bool is_lvalue_reference_v
241 = is_lvalue_reference<T>::value; // C++17
242 template <class T> inline constexpr bool is_rvalue_reference_v
243 = is_rvalue_reference<T>::value; // C++17
244 template <class T> inline constexpr bool is_member_object_pointer_v
245 = is_member_object_pointer<T>::value; // C++17
246 template <class T> inline constexpr bool is_member_function_pointer_v
247 = is_member_function_pointer<T>::value; // C++17
248 template <class T> inline constexpr bool is_enum_v
249 = is_enum<T>::value; // C++17
250 template <class T> inline constexpr bool is_union_v
251 = is_union<T>::value; // C++17
252 template <class T> inline constexpr bool is_class_v
253 = is_class<T>::value; // C++17
254 template <class T> inline constexpr bool is_function_v
255 = is_function<T>::value; // C++17
257 // See C++14 20.10.4.2, composite type categories
258 template <class T> inline constexpr bool is_reference_v
259 = is_reference<T>::value; // C++17
260 template <class T> inline constexpr bool is_arithmetic_v
261 = is_arithmetic<T>::value; // C++17
262 template <class T> inline constexpr bool is_fundamental_v
263 = is_fundamental<T>::value; // C++17
264 template <class T> inline constexpr bool is_object_v
265 = is_object<T>::value; // C++17
266 template <class T> inline constexpr bool is_scalar_v
267 = is_scalar<T>::value; // C++17
268 template <class T> inline constexpr bool is_compound_v
269 = is_compound<T>::value; // C++17
270 template <class T> inline constexpr bool is_member_pointer_v
271 = is_member_pointer<T>::value; // C++17
273 // See C++14 20.10.4.3, type properties
274 template <class T> inline constexpr bool is_const_v
275 = is_const<T>::value; // C++17
276 template <class T> inline constexpr bool is_volatile_v
277 = is_volatile<T>::value; // C++17
278 template <class T> inline constexpr bool is_trivial_v
279 = is_trivial<T>::value; // C++17
280 template <class T> inline constexpr bool is_trivially_copyable_v
281 = is_trivially_copyable<T>::value; // C++17
282 template <class T> inline constexpr bool is_standard_layout_v
283 = is_standard_layout<T>::value; // C++17
284 template <class T> inline constexpr bool is_pod_v
285 = is_pod<T>::value; // C++17
286 template <class T> inline constexpr bool is_literal_type_v
287 = is_literal_type<T>::value; // C++17
288 template <class T> inline constexpr bool is_empty_v
289 = is_empty<T>::value; // C++17
290 template <class T> inline constexpr bool is_polymorphic_v
291 = is_polymorphic<T>::value; // C++17
292 template <class T> inline constexpr bool is_abstract_v
293 = is_abstract<T>::value; // C++17
294 template <class T> inline constexpr bool is_final_v
295 = is_final<T>::value; // C++17
296 template <class T> inline constexpr bool is_aggregate_v
297 = is_aggregate<T>::value; // C++17
298 template <class T> inline constexpr bool is_signed_v
299 = is_signed<T>::value; // C++17
300 template <class T> inline constexpr bool is_unsigned_v
301 = is_unsigned<T>::value; // C++17
302 template <class T, class... Args> inline constexpr bool is_constructible_v
303 = is_constructible<T, Args...>::value; // C++17
304 template <class T> inline constexpr bool is_default_constructible_v
305 = is_default_constructible<T>::value; // C++17
306 template <class T> inline constexpr bool is_copy_constructible_v
307 = is_copy_constructible<T>::value; // C++17
308 template <class T> inline constexpr bool is_move_constructible_v
309 = is_move_constructible<T>::value; // C++17
310 template <class T, class U> inline constexpr bool is_assignable_v
311 = is_assignable<T, U>::value; // C++17
312 template <class T> inline constexpr bool is_copy_assignable_v
313 = is_copy_assignable<T>::value; // C++17
314 template <class T> inline constexpr bool is_move_assignable_v
315 = is_move_assignable<T>::value; // C++17
316 template <class T, class U> inline constexpr bool is_swappable_with_v
317 = is_swappable_with<T, U>::value; // C++17
318 template <class T> inline constexpr bool is_swappable_v
319 = is_swappable<T>::value; // C++17
320 template <class T> inline constexpr bool is_destructible_v
321 = is_destructible<T>::value; // C++17
322 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
323 = is_trivially_constructible<T, Args...>::value; // C++17
324 template <class T> inline constexpr bool is_trivially_default_constructible_v
325 = is_trivially_default_constructible<T>::value; // C++17
326 template <class T> inline constexpr bool is_trivially_copy_constructible_v
327 = is_trivially_copy_constructible<T>::value; // C++17
328 template <class T> inline constexpr bool is_trivially_move_constructible_v
329 = is_trivially_move_constructible<T>::value; // C++17
330 template <class T, class U> inline constexpr bool is_trivially_assignable_v
331 = is_trivially_assignable<T, U>::value; // C++17
332 template <class T> inline constexpr bool is_trivially_copy_assignable_v
333 = is_trivially_copy_assignable<T>::value; // C++17
334 template <class T> inline constexpr bool is_trivially_move_assignable_v
335 = is_trivially_move_assignable<T>::value; // C++17
336 template <class T> inline constexpr bool is_trivially_destructible_v
337 = is_trivially_destructible<T>::value; // C++17
338 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
339 = is_nothrow_constructible<T, Args...>::value; // C++17
340 template <class T> inline constexpr bool is_nothrow_default_constructible_v
341 = is_nothrow_default_constructible<T>::value; // C++17
342 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
343 = is_nothrow_copy_constructible<T>::value; // C++17
344 template <class T> inline constexpr bool is_nothrow_move_constructible_v
345 = is_nothrow_move_constructible<T>::value; // C++17
346 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
347 = is_nothrow_assignable<T, U>::value; // C++17
348 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
349 = is_nothrow_copy_assignable<T>::value; // C++17
350 template <class T> inline constexpr bool is_nothrow_move_assignable_v
351 = is_nothrow_move_assignable<T>::value; // C++17
352 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
353 = is_nothrow_swappable_with<T, U>::value; // C++17
354 template <class T> inline constexpr bool is_nothrow_swappable_v
355 = is_nothrow_swappable<T>::value; // C++17
356 template <class T> inline constexpr bool is_nothrow_destructible_v
357 = is_nothrow_destructible<T>::value; // C++17
358 template <class T> inline constexpr bool has_virtual_destructor_v
359 = has_virtual_destructor<T>::value; // C++17
360 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
361 = has_unique_object_representations<T>::value;
363 // See C++14 20.10.5, type property queries
364 template <class T> inline constexpr size_t alignment_of_v
365 = alignment_of<T>::value; // C++17
366 template <class T> inline constexpr size_t rank_v
367 = rank<T>::value; // C++17
368 template <class T, unsigned I = 0> inline constexpr size_t extent_v
369 = extent<T, I>::value; // C++17
371 // See C++14 20.10.6, type relations
372 template <class T, class U> inline constexpr bool is_same_v
373 = is_same<T, U>::value; // C++17
374 template <class Base, class Derived> inline constexpr bool is_base_of_v
375 = is_base_of<Base, Derived>::value; // C++17
376 template <class From, class To> inline constexpr bool is_convertible_v
377 = is_convertible<From, To>::value; // C++17
378 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
379 = is_invocable<Fn, ArgTypes...>::value; // C++17
380 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
381 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
382 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
383 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
384 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
385 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
387 // [meta.logical], logical operator traits:
388 template<class... B> struct conjunction; // C++17
390 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
391 template<class... B> struct disjunction; // C++17
393 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
394 template<class B> struct negation; // C++17
396 inline constexpr bool negation_v = negation<B>::value; // C++17
404 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
405 #pragma GCC system_header
408 _LIBCPP_BEGIN_NAMESPACE_STD
410 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
411 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
412 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
415 struct __void_t { typedef void type; };
418 struct __identity { typedef _Tp type; };
420 template <class _Tp, bool>
421 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
423 template <bool _Bp, class _If, class _Then>
424 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
425 template <class _If, class _Then>
426 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
428 #if _LIBCPP_STD_VER > 11
429 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
432 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {};
433 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
435 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
436 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
438 #if _LIBCPP_STD_VER > 11
439 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
443 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
446 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
447 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
449 addressof(_Tp& __x) _NOEXCEPT
451 return __builtin_addressof(__x);
457 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
459 addressof(_Tp& __x) _NOEXCEPT
461 return reinterpret_cast<_Tp *>(
462 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
465 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
467 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
468 // Objective-C++ Automatic Reference Counting uses qualified pointers
469 // that require special addressof() signatures. When
470 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
471 // itself is providing these definitions. Otherwise, we provide them.
473 inline _LIBCPP_INLINE_VISIBILITY
475 addressof(__strong _Tp& __x) _NOEXCEPT
480 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
482 inline _LIBCPP_INLINE_VISIBILITY
484 addressof(__weak _Tp& __x) _NOEXCEPT
491 inline _LIBCPP_INLINE_VISIBILITY
493 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
499 inline _LIBCPP_INLINE_VISIBILITY
500 __unsafe_unretained _Tp*
501 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
507 #if !defined(_LIBCPP_CXX03_LANG)
508 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
511 struct __two {char __lx[2];};
515 template <class _Tp, _Tp __v>
516 struct _LIBCPP_TEMPLATE_VIS integral_constant
518 static _LIBCPP_CONSTEXPR const _Tp value = __v;
519 typedef _Tp value_type;
520 typedef integral_constant type;
521 _LIBCPP_INLINE_VISIBILITY
522 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
523 #if _LIBCPP_STD_VER > 11
524 _LIBCPP_INLINE_VISIBILITY
525 constexpr value_type operator ()() const _NOEXCEPT {return value;}
529 template <class _Tp, _Tp __v>
530 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
532 #if _LIBCPP_STD_VER > 14
534 using bool_constant = integral_constant<bool, __b>;
535 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
537 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
540 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
541 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
543 #if !defined(_LIBCPP_CXX03_LANG)
547 template <bool _Last, class ..._Preds>
548 struct __lazy_and_impl;
550 template <class ..._Preds>
551 struct __lazy_and_impl<false, _Preds...> : false_type {};
554 struct __lazy_and_impl<true> : true_type {};
556 template <class _Pred>
557 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
559 template <class _Hp, class ..._Tp>
560 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
562 template <class _P1, class ..._Pr>
563 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
567 template <bool _List, class ..._Preds>
568 struct __lazy_or_impl;
570 template <class ..._Preds>
571 struct __lazy_or_impl<true, _Preds...> : true_type {};
574 struct __lazy_or_impl<false> : false_type {};
576 template <class _Hp, class ..._Tp>
577 struct __lazy_or_impl<false, _Hp, _Tp...>
578 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
580 template <class _P1, class ..._Pr>
581 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
585 template <class _Pred>
586 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
589 template<class...> struct __and_;
590 template<> struct __and_<> : true_type {};
592 template<class _B0> struct __and_<_B0> : _B0 {};
594 template<class _B0, class _B1>
595 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
597 template<class _B0, class _B1, class _B2, class... _Bn>
598 struct __and_<_B0, _B1, _B2, _Bn...>
599 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
602 template<class...> struct __or_;
603 template<> struct __or_<> : false_type {};
605 template<class _B0> struct __or_<_B0> : _B0 {};
607 template<class _B0, class _B1>
608 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
610 template<class _B0, class _B1, class _B2, class... _Bn>
611 struct __or_<_B0, _B1, _B2, _Bn...>
612 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
616 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
618 #endif // !defined(_LIBCPP_CXX03_LANG)
622 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
623 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
625 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
627 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
628 = is_const<_Tp>::value;
633 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
634 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
636 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
638 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
639 = is_volatile<_Tp>::value;
644 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
645 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
646 #if _LIBCPP_STD_VER > 11
647 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
652 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
653 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
654 #if _LIBCPP_STD_VER > 11
655 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
660 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
661 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
662 #if _LIBCPP_STD_VER > 11
663 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
668 template <class _Tp> struct __libcpp_is_void : public false_type {};
669 template <> struct __libcpp_is_void<void> : public true_type {};
671 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
672 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
674 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
676 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
677 = is_void<_Tp>::value;
682 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
683 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
685 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
686 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
688 #if _LIBCPP_STD_VER > 11
689 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
690 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
692 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
694 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
695 = is_null_pointer<_Tp>::value;
701 template <class _Tp> struct __libcpp_is_integral : public false_type {};
702 template <> struct __libcpp_is_integral<bool> : public true_type {};
703 template <> struct __libcpp_is_integral<char> : public true_type {};
704 template <> struct __libcpp_is_integral<signed char> : public true_type {};
705 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
706 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
707 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
708 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
709 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
710 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
711 template <> struct __libcpp_is_integral<short> : public true_type {};
712 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
713 template <> struct __libcpp_is_integral<int> : public true_type {};
714 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
715 template <> struct __libcpp_is_integral<long> : public true_type {};
716 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
717 template <> struct __libcpp_is_integral<long long> : public true_type {};
718 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
719 #ifndef _LIBCPP_HAS_NO_INT128
720 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
721 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
724 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
725 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
727 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
729 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
730 = is_integral<_Tp>::value;
735 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
736 template <> struct __libcpp_is_floating_point<float> : public true_type {};
737 template <> struct __libcpp_is_floating_point<double> : public true_type {};
738 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
740 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
741 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
743 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
745 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
746 = is_floating_point<_Tp>::value;
751 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
752 : public false_type {};
753 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
754 : public true_type {};
755 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
756 : public true_type {};
758 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
760 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
761 = is_array<_Tp>::value;
766 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
767 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
769 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
770 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
772 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
774 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
775 = is_pointer<_Tp>::value;
780 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
781 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
783 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
784 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
785 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
788 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
789 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
790 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
794 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
796 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
797 = is_reference<_Tp>::value;
800 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
801 = is_lvalue_reference<_Tp>::value;
804 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
805 = is_rvalue_reference<_Tp>::value;
809 #if __has_feature(is_union) || (_GNUC_VER >= 403)
811 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
812 : public integral_constant<bool, __is_union(_Tp)> {};
816 template <class _Tp> struct __libcpp_union : public false_type {};
817 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
818 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
822 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
824 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
825 = is_union<_Tp>::value;
830 #if __has_feature(is_class) || (_GNUC_VER >= 403)
832 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
833 : public integral_constant<bool, __is_class(_Tp)> {};
837 namespace __is_class_imp
839 template <class _Tp> char __test(int _Tp::*);
840 template <class _Tp> __two __test(...);
843 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
844 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
848 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
850 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
851 = is_class<_Tp>::value;
856 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
857 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
859 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
860 template <class _Tp, class _Up>
861 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
862 = is_same<_Tp, _Up>::value;
867 namespace __libcpp_is_function_imp
869 struct __dummy_type {};
870 template <class _Tp> char __test(_Tp*);
871 template <class _Tp> char __test(__dummy_type);
872 template <class _Tp> __two __test(...);
873 template <class _Tp> _Tp& __source(int);
874 template <class _Tp> __dummy_type __source(...);
877 template <class _Tp, bool = is_class<_Tp>::value ||
878 is_union<_Tp>::value ||
879 is_void<_Tp>::value ||
880 is_reference<_Tp>::value ||
881 __is_nullptr_t<_Tp>::value >
882 struct __libcpp_is_function
883 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
885 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
887 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
888 : public __libcpp_is_function<_Tp> {};
890 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
892 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
893 = is_function<_Tp>::value;
896 // is_member_function_pointer
898 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
899 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
902 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
903 struct __member_pointer_traits_imp
904 { // forward declaration; specializations later
908 template <class _Tp> struct __libcpp_is_member_function_pointer
909 : public false_type {};
911 template <class _Ret, class _Class>
912 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
913 : public is_function<_Ret> {};
915 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
916 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
918 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
920 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
921 = is_member_function_pointer<_Tp>::value;
926 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
927 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
929 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
930 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
932 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
934 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
935 = is_member_pointer<_Tp>::value;
938 // is_member_object_pointer
940 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
941 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
942 !is_member_function_pointer<_Tp>::value> {};
944 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
946 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
947 = is_member_object_pointer<_Tp>::value;
952 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
954 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
955 : public integral_constant<bool, __is_enum(_Tp)> {};
959 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
960 : public integral_constant<bool, !is_void<_Tp>::value &&
961 !is_integral<_Tp>::value &&
962 !is_floating_point<_Tp>::value &&
963 !is_array<_Tp>::value &&
964 !is_pointer<_Tp>::value &&
965 !is_reference<_Tp>::value &&
966 !is_member_pointer<_Tp>::value &&
967 !is_union<_Tp>::value &&
968 !is_class<_Tp>::value &&
969 !is_function<_Tp>::value > {};
973 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
975 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
976 = is_enum<_Tp>::value;
981 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
982 : public integral_constant<bool, is_integral<_Tp>::value ||
983 is_floating_point<_Tp>::value> {};
985 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
987 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
988 = is_arithmetic<_Tp>::value;
993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
994 : public integral_constant<bool, is_void<_Tp>::value ||
995 __is_nullptr_t<_Tp>::value ||
996 is_arithmetic<_Tp>::value> {};
998 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1000 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1001 = is_fundamental<_Tp>::value;
1006 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1007 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1008 is_member_pointer<_Tp>::value ||
1009 is_pointer<_Tp>::value ||
1010 __is_nullptr_t<_Tp>::value ||
1011 is_enum<_Tp>::value > {};
1013 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1015 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1016 template <class _Tp>
1017 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1018 = is_scalar<_Tp>::value;
1023 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1024 : public integral_constant<bool, is_scalar<_Tp>::value ||
1025 is_array<_Tp>::value ||
1026 is_union<_Tp>::value ||
1027 is_class<_Tp>::value > {};
1029 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1030 template <class _Tp>
1031 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
1032 = is_object<_Tp>::value;
1037 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1038 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1040 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1041 template <class _Tp>
1042 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1043 = is_compound<_Tp>::value;
1047 // __is_referenceable [defns.referenceable]
1049 struct __is_referenceable_impl {
1050 template <class _Tp> static _Tp& __test(int);
1051 template <class _Tp> static __two __test(...);
1054 template <class _Tp>
1055 struct __is_referenceable : integral_constant<bool,
1056 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1061 template <class _Tp, bool = is_reference<_Tp>::value ||
1062 is_function<_Tp>::value ||
1063 is_const<_Tp>::value >
1064 struct __add_const {typedef _Tp type;};
1066 template <class _Tp>
1067 struct __add_const<_Tp, false> {typedef const _Tp type;};
1069 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1070 {typedef typename __add_const<_Tp>::type type;};
1072 #if _LIBCPP_STD_VER > 11
1073 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1078 template <class _Tp, bool = is_reference<_Tp>::value ||
1079 is_function<_Tp>::value ||
1080 is_volatile<_Tp>::value >
1081 struct __add_volatile {typedef _Tp type;};
1083 template <class _Tp>
1084 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1086 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1087 {typedef typename __add_volatile<_Tp>::type type;};
1089 #if _LIBCPP_STD_VER > 11
1090 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1095 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1096 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1098 #if _LIBCPP_STD_VER > 11
1099 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1104 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;};
1105 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;};
1106 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1107 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
1110 #if _LIBCPP_STD_VER > 11
1111 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1114 // add_lvalue_reference
1116 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1117 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1119 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1120 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1122 #if _LIBCPP_STD_VER > 11
1123 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1126 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1128 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1129 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1131 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1132 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1134 #if _LIBCPP_STD_VER > 11
1135 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1138 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1140 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1142 template <class _Tp> _Tp&& __declval(int);
1143 template <class _Tp> _Tp __declval(long);
1145 template <class _Tp>
1146 decltype(_VSTD::__declval<_Tp>(0))
1147 declval() _NOEXCEPT;
1149 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1151 template <class _Tp>
1152 typename add_lvalue_reference<_Tp>::type
1155 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1159 template <class _Tp>
1161 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1164 template <class _Tp>
1165 struct __unconstref {
1166 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1169 #ifndef _LIBCPP_CXX03_LANG
1170 template <class _Tp>
1171 using __uncvref_t = typename __uncvref<_Tp>::type;
1174 // __is_same_uncvref
1176 template <class _Tp, class _Up>
1177 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1178 typename __uncvref<_Up>::type> {};
1180 #if _LIBCPP_STD_VER > 17
1181 // remove_cvref - same as __uncvref
1182 template <class _Tp>
1183 struct remove_cvref : public __uncvref<_Tp> {};
1185 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1196 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;};
1197 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
1198 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
1199 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
1200 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1202 #if _LIBCPP_STD_VER > 11
1203 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1208 template <class _Tp,
1209 bool = __is_referenceable<_Tp>::value ||
1210 is_same<typename remove_cv<_Tp>::type, void>::value>
1211 struct __add_pointer_impl
1212 {typedef typename remove_reference<_Tp>::type* type;};
1213 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1214 {typedef _Tp type;};
1216 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1217 {typedef typename __add_pointer_impl<_Tp>::type type;};
1219 #if _LIBCPP_STD_VER > 11
1220 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1225 template <class _Tp, bool = is_integral<_Tp>::value>
1226 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1228 template <class _Tp>
1229 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1231 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1232 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1234 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1236 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1238 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1239 template <class _Tp>
1240 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1241 = is_signed<_Tp>::value;
1246 template <class _Tp, bool = is_integral<_Tp>::value>
1247 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1249 template <class _Tp>
1250 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1252 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1253 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1255 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1257 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1259 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1260 template <class _Tp>
1261 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1262 = is_unsigned<_Tp>::value;
1267 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1268 : public integral_constant<size_t, 0> {};
1269 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1270 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1271 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1272 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1274 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1275 template <class _Tp>
1276 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1282 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1283 : public integral_constant<size_t, 0> {};
1284 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1285 : public integral_constant<size_t, 0> {};
1286 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1287 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1288 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1289 : public integral_constant<size_t, _Np> {};
1290 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1291 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1293 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1294 template <class _Tp, unsigned _Ip = 0>
1295 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1296 = extent<_Tp, _Ip>::value;
1301 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1302 {typedef _Tp type;};
1303 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1304 {typedef _Tp type;};
1305 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1306 {typedef _Tp type;};
1308 #if _LIBCPP_STD_VER > 11
1309 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1312 // remove_all_extents
1314 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1315 {typedef _Tp type;};
1316 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1317 {typedef typename remove_all_extents<_Tp>::type type;};
1318 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1319 {typedef typename remove_all_extents<_Tp>::type type;};
1321 #if _LIBCPP_STD_VER > 11
1322 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1327 template <class _Up, bool>
1329 typedef typename remove_cv<_Up>::type type;
1332 template <class _Up>
1333 struct __decay<_Up, true> {
1335 typedef typename conditional
1337 is_array<_Up>::value,
1338 typename remove_extent<_Up>::type*,
1339 typename conditional
1341 is_function<_Up>::value,
1342 typename add_pointer<_Up>::type,
1343 typename remove_cv<_Up>::type
1348 template <class _Tp>
1349 struct _LIBCPP_TEMPLATE_VIS decay
1352 typedef typename remove_reference<_Tp>::type _Up;
1354 typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1357 #if _LIBCPP_STD_VER > 11
1358 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1363 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1364 : public integral_constant<bool, __is_abstract(_Tp)> {};
1366 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1367 template <class _Tp>
1368 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1369 = is_abstract<_Tp>::value;
1374 #if defined(_LIBCPP_HAS_IS_FINAL)
1375 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1376 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1378 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1379 __libcpp_is_final : public false_type {};
1382 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1383 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1384 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1387 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1388 template <class _Tp>
1389 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1390 = is_final<_Tp>::value;
1394 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1396 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1397 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1399 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1400 template <class _Tp>
1401 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1402 = is_aggregate<_Tp>::value;
1405 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1409 #ifdef _LIBCPP_HAS_IS_BASE_OF
1411 template <class _Bp, class _Dp>
1412 struct _LIBCPP_TEMPLATE_VIS is_base_of
1413 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1415 #else // _LIBCPP_HAS_IS_BASE_OF
1417 namespace __is_base_of_imp
1419 template <class _Tp>
1422 _Dst(const volatile _Tp &);
1424 template <class _Tp>
1427 operator const volatile _Tp &();
1428 template <class _Up> operator const _Dst<_Up> &();
1430 template <size_t> struct __one { typedef char type; };
1431 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1432 template <class _Bp, class _Dp> __two __test(...);
1435 template <class _Bp, class _Dp>
1436 struct _LIBCPP_TEMPLATE_VIS is_base_of
1437 : public integral_constant<bool, is_class<_Bp>::value &&
1438 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1440 #endif // _LIBCPP_HAS_IS_BASE_OF
1442 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1443 template <class _Bp, class _Dp>
1444 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1445 = is_base_of<_Bp, _Dp>::value;
1450 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1452 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1453 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1454 !is_abstract<_T2>::value> {};
1456 #else // __has_feature(is_convertible_to)
1458 namespace __is_convertible_imp
1460 template <class _Tp> void __test_convert(_Tp);
1462 template <class _From, class _To, class = void>
1463 struct __is_convertible_test : public false_type {};
1465 template <class _From, class _To>
1466 struct __is_convertible_test<_From, _To,
1467 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1470 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1471 bool _IsFunction = is_function<_Tp>::value,
1472 bool _IsVoid = is_void<_Tp>::value>
1473 struct __is_array_function_or_void {enum {value = 0};};
1474 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1475 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1476 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1479 template <class _Tp,
1480 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1481 struct __is_convertible_check
1483 static const size_t __v = 0;
1486 template <class _Tp>
1487 struct __is_convertible_check<_Tp, 0>
1489 static const size_t __v = sizeof(_Tp);
1492 template <class _T1, class _T2,
1493 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1494 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1495 struct __is_convertible
1496 : public integral_constant<bool,
1497 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1498 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1499 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1500 && (!is_const<typename remove_reference<_T2>::type>::value
1501 || is_volatile<typename remove_reference<_T2>::type>::value)
1502 && (is_same<typename remove_cv<_T1>::type,
1503 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1504 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1509 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1510 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1511 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1512 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1514 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1515 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1516 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1517 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1519 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1520 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1521 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1522 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1524 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1525 : public __is_convertible<_T1, _T2>
1527 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1528 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1531 #endif // __has_feature(is_convertible_to)
1533 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1534 template <class _From, class _To>
1535 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1536 = is_convertible<_From, _To>::value;
1541 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1543 template <class _Tp>
1544 struct _LIBCPP_TEMPLATE_VIS is_empty
1545 : public integral_constant<bool, __is_empty(_Tp)> {};
1547 #else // __has_feature(is_empty)
1549 template <class _Tp>
1561 template <class _Tp, bool = is_class<_Tp>::value>
1562 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1564 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1566 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1568 #endif // __has_feature(is_empty)
1570 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1571 template <class _Tp>
1572 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1573 = is_empty<_Tp>::value;
1578 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1580 template <class _Tp>
1581 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1582 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1586 template<typename _Tp> char &__is_polymorphic_impl(
1587 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1589 template<typename _Tp> __two &__is_polymorphic_impl(...);
1591 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1592 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1594 #endif // __has_feature(is_polymorphic)
1596 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1597 template <class _Tp>
1598 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1599 = is_polymorphic<_Tp>::value;
1602 // has_virtual_destructor
1604 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1606 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1607 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1611 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1612 : public false_type {};
1616 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1617 template <class _Tp>
1618 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1619 = has_virtual_destructor<_Tp>::value;
1622 // has_unique_object_representations
1624 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1626 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1627 : public integral_constant<bool,
1628 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1630 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1631 template <class _Tp>
1632 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1633 = has_unique_object_representations<_Tp>::value;
1640 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1641 : public integral_constant<size_t, __alignof__(_Tp)> {};
1643 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1644 template <class _Tp>
1645 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1646 = alignment_of<_Tp>::value;
1651 template <class _Hp, class _Tp>
1660 #ifndef _LIBCPP_CXX03_LANG
1662 __nat(const __nat&) = delete;
1663 __nat& operator=(const __nat&) = delete;
1668 template <class _Tp>
1671 static const size_t value = alignment_of<_Tp>::value;
1675 struct __struct_double {long double __lx;};
1676 struct __struct_double4 {double __lx[4];};
1679 __type_list<__align_type<unsigned char>,
1680 __type_list<__align_type<unsigned short>,
1681 __type_list<__align_type<unsigned int>,
1682 __type_list<__align_type<unsigned long>,
1683 __type_list<__align_type<unsigned long long>,
1684 __type_list<__align_type<double>,
1685 __type_list<__align_type<long double>,
1686 __type_list<__align_type<__struct_double>,
1687 __type_list<__align_type<__struct_double4>,
1688 __type_list<__align_type<int*>,
1690 > > > > > > > > > > __all_types;
1692 template <class _TL, size_t _Align> struct __find_pod;
1694 template <class _Hp, size_t _Align>
1695 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1697 typedef typename conditional<
1698 _Align == _Hp::value,
1704 template <class _Hp, class _Tp, size_t _Align>
1705 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1707 typedef typename conditional<
1708 _Align == _Hp::value,
1710 typename __find_pod<_Tp, _Align>::type
1714 template <class _TL, size_t _Len> struct __find_max_align;
1716 template <class _Hp, size_t _Len>
1717 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1719 template <size_t _Len, size_t _A1, size_t _A2>
1720 struct __select_align
1723 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1724 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1726 static const size_t value = _Len < __max ? __min : __max;
1729 template <class _Hp, class _Tp, size_t _Len>
1730 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1731 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1733 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1734 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1736 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1737 static_assert(!is_void<_Aligner>::value, "");
1741 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1745 #if _LIBCPP_STD_VER > 11
1746 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1747 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1750 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1751 template <size_t _Len>\
1752 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1754 struct _ALIGNAS(n) type\
1756 unsigned char __lx[(_Len + n - 1)/n * n];\
1760 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1761 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1762 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1763 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1764 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1765 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1766 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1767 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1768 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1769 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1770 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1771 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1772 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1773 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1774 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1775 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1776 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1777 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1779 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1781 #ifndef _LIBCPP_HAS_NO_VARIADICS
1785 template <size_t _I0, size_t ..._In>
1786 struct __static_max;
1788 template <size_t _I0>
1789 struct __static_max<_I0>
1791 static const size_t value = _I0;
1794 template <size_t _I0, size_t _I1, size_t ..._In>
1795 struct __static_max<_I0, _I1, _In...>
1797 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1798 __static_max<_I1, _In...>::value;
1801 template <size_t _Len, class _Type0, class ..._Types>
1802 struct aligned_union
1804 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1805 __alignof__(_Types)...>::value;
1806 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1807 sizeof(_Types)...>::value;
1808 typedef typename aligned_storage<__len, alignment_value>::type type;
1811 #if _LIBCPP_STD_VER > 11
1812 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1815 #endif // _LIBCPP_HAS_NO_VARIADICS
1817 template <class _Tp>
1818 struct __numeric_type
1820 static void __test(...);
1821 static float __test(float);
1822 static double __test(char);
1823 static double __test(int);
1824 static double __test(unsigned);
1825 static double __test(long);
1826 static double __test(unsigned long);
1827 static double __test(long long);
1828 static double __test(unsigned long long);
1829 static double __test(double);
1830 static long double __test(long double);
1832 typedef decltype(__test(declval<_Tp>())) type;
1833 static const bool value = !is_same<type, void>::value;
1837 struct __numeric_type<void>
1839 static const bool value = true;
1844 template <class _A1, class _A2 = void, class _A3 = void,
1845 bool = __numeric_type<_A1>::value &&
1846 __numeric_type<_A2>::value &&
1847 __numeric_type<_A3>::value>
1851 static const bool value = false;
1854 template <class _A1, class _A2, class _A3>
1855 class __promote_imp<_A1, _A2, _A3, true>
1858 typedef typename __promote_imp<_A1>::type __type1;
1859 typedef typename __promote_imp<_A2>::type __type2;
1860 typedef typename __promote_imp<_A3>::type __type3;
1862 typedef decltype(__type1() + __type2() + __type3()) type;
1863 static const bool value = true;
1866 template <class _A1, class _A2>
1867 class __promote_imp<_A1, _A2, void, true>
1870 typedef typename __promote_imp<_A1>::type __type1;
1871 typedef typename __promote_imp<_A2>::type __type2;
1873 typedef decltype(__type1() + __type2()) type;
1874 static const bool value = true;
1877 template <class _A1>
1878 class __promote_imp<_A1, void, void, true>
1881 typedef typename __numeric_type<_A1>::type type;
1882 static const bool value = true;
1885 template <class _A1, class _A2 = void, class _A3 = void>
1886 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1888 // make_signed / make_unsigned
1891 __type_list<signed char,
1892 __type_list<signed short,
1893 __type_list<signed int,
1894 __type_list<signed long,
1895 __type_list<signed long long,
1896 #ifndef _LIBCPP_HAS_NO_INT128
1897 __type_list<__int128_t,
1900 #ifndef _LIBCPP_HAS_NO_INT128
1903 > > > > > __signed_types;
1906 __type_list<unsigned char,
1907 __type_list<unsigned short,
1908 __type_list<unsigned int,
1909 __type_list<unsigned long,
1910 __type_list<unsigned long long,
1911 #ifndef _LIBCPP_HAS_NO_INT128
1912 __type_list<__uint128_t,
1915 #ifndef _LIBCPP_HAS_NO_INT128
1918 > > > > > __unsigned_types;
1920 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1922 template <class _Hp, class _Tp, size_t _Size>
1923 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1928 template <class _Hp, class _Tp, size_t _Size>
1929 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1931 typedef typename __find_first<_Tp, _Size>::type type;
1934 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1935 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1941 template <class _Tp, class _Up>
1942 struct __apply_cv<_Tp, _Up, true, false>
1944 typedef const _Up type;
1947 template <class _Tp, class _Up>
1948 struct __apply_cv<_Tp, _Up, false, true>
1950 typedef volatile _Up type;
1953 template <class _Tp, class _Up>
1954 struct __apply_cv<_Tp, _Up, true, true>
1956 typedef const volatile _Up type;
1959 template <class _Tp, class _Up>
1960 struct __apply_cv<_Tp&, _Up, false, false>
1965 template <class _Tp, class _Up>
1966 struct __apply_cv<_Tp&, _Up, true, false>
1968 typedef const _Up& type;
1971 template <class _Tp, class _Up>
1972 struct __apply_cv<_Tp&, _Up, false, true>
1974 typedef volatile _Up& type;
1977 template <class _Tp, class _Up>
1978 struct __apply_cv<_Tp&, _Up, true, true>
1980 typedef const volatile _Up& type;
1983 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1984 struct __make_signed {};
1986 template <class _Tp>
1987 struct __make_signed<_Tp, true>
1989 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1992 template <> struct __make_signed<bool, true> {};
1993 template <> struct __make_signed< signed short, true> {typedef short type;};
1994 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1995 template <> struct __make_signed< signed int, true> {typedef int type;};
1996 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1997 template <> struct __make_signed< signed long, true> {typedef long type;};
1998 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1999 template <> struct __make_signed< signed long long, true> {typedef long long type;};
2000 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2001 #ifndef _LIBCPP_HAS_NO_INT128
2002 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2003 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2006 template <class _Tp>
2007 struct _LIBCPP_TEMPLATE_VIS make_signed
2009 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2012 #if _LIBCPP_STD_VER > 11
2013 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2016 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2017 struct __make_unsigned {};
2019 template <class _Tp>
2020 struct __make_unsigned<_Tp, true>
2022 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2025 template <> struct __make_unsigned<bool, true> {};
2026 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2027 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2028 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2029 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2030 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2031 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2032 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2033 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2034 #ifndef _LIBCPP_HAS_NO_INT128
2035 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2036 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2039 template <class _Tp>
2040 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2042 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2045 #if _LIBCPP_STD_VER > 11
2046 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2049 #ifdef _LIBCPP_HAS_NO_VARIADICS
2051 template <class _Tp, class _Up = void, class _Vp = void>
2052 struct _LIBCPP_TEMPLATE_VIS common_type
2055 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
2059 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void>
2065 template <class _Tp>
2066 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
2069 typedef typename common_type<_Tp, _Tp>::type type;
2072 template <class _Tp, class _Up>
2073 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
2075 typedef typename decay<decltype(
2076 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2080 #else // _LIBCPP_HAS_NO_VARIADICS
2082 // bullet 1 - sizeof...(Tp) == 0
2084 template <class ..._Tp>
2085 struct _LIBCPP_TEMPLATE_VIS common_type {};
2087 // bullet 2 - sizeof...(Tp) == 1
2089 template <class _Tp>
2090 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2091 : public common_type<_Tp, _Tp> {};
2093 // bullet 3 - sizeof...(Tp) == 2
2095 template <class _Tp, class _Up, class = void>
2096 struct __common_type2_imp {};
2098 template <class _Tp, class _Up>
2099 struct __common_type2_imp<_Tp, _Up,
2100 typename __void_t<decltype(
2101 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2104 typedef typename decay<decltype(
2105 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2109 template <class _Tp, class _Up,
2110 class _DTp = typename decay<_Tp>::type,
2111 class _DUp = typename decay<_Up>::type>
2112 using __common_type2 =
2113 typename conditional<
2114 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
2115 __common_type2_imp<_Tp, _Up>,
2116 common_type<_DTp, _DUp>
2119 template <class _Tp, class _Up>
2120 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2121 : __common_type2<_Tp, _Up> {};
2123 // bullet 4 - sizeof...(Tp) > 2
2125 template <class ...Tp> struct __common_types;
2127 template <class, class = void>
2128 struct __common_type_impl {};
2130 template <class _Tp, class _Up>
2131 struct __common_type_impl<
2132 __common_types<_Tp, _Up>,
2133 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2135 typedef typename common_type<_Tp, _Up>::type type;
2138 template <class _Tp, class _Up, class ..._Vp>
2139 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2140 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2141 : __common_type_impl<
2142 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
2147 template <class _Tp, class _Up, class ..._Vp>
2148 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
2149 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2151 #if _LIBCPP_STD_VER > 11
2152 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2155 #endif // _LIBCPP_HAS_NO_VARIADICS
2159 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2161 template <class _Tp, class _Arg>
2162 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2163 __is_assignable_test(int);
2165 template <class, class>
2166 false_type __is_assignable_test(...);
2169 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2170 struct __is_assignable_imp
2171 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2173 template <class _Tp, class _Arg>
2174 struct __is_assignable_imp<_Tp, _Arg, true>
2179 template <class _Tp, class _Arg>
2180 struct is_assignable
2181 : public __is_assignable_imp<_Tp, _Arg> {};
2183 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2184 template <class _Tp, class _Arg>
2185 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2186 = is_assignable<_Tp, _Arg>::value;
2189 // is_copy_assignable
2191 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2192 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2193 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2195 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2196 template <class _Tp>
2197 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2198 = is_copy_assignable<_Tp>::value;
2201 // is_move_assignable
2203 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2204 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2205 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2206 typename add_rvalue_reference<_Tp>::type> {};
2208 : public is_copy_assignable<_Tp> {};
2211 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2212 template <class _Tp>
2213 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2214 = is_move_assignable<_Tp>::value;
2219 // if it's a reference, return true
2220 // if it's a function, return false
2221 // if it's void, return false
2222 // if it's an array of unknown bound, return false
2223 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2224 // where _Up is remove_all_extents<_Tp>::type
2227 struct __is_destructible_apply { typedef int type; };
2229 template <typename _Tp>
2230 struct __is_destructor_wellformed {
2231 template <typename _Tp1>
2232 static char __test (
2233 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2236 template <typename _Tp1>
2237 static __two __test (...);
2239 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2242 template <class _Tp, bool>
2243 struct __destructible_imp;
2245 template <class _Tp>
2246 struct __destructible_imp<_Tp, false>
2247 : public _VSTD::integral_constant<bool,
2248 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2250 template <class _Tp>
2251 struct __destructible_imp<_Tp, true>
2252 : public _VSTD::true_type {};
2254 template <class _Tp, bool>
2255 struct __destructible_false;
2257 template <class _Tp>
2258 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2260 template <class _Tp>
2261 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2263 template <class _Tp>
2264 struct is_destructible
2265 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2267 template <class _Tp>
2268 struct is_destructible<_Tp[]>
2269 : public _VSTD::false_type {};
2272 struct is_destructible<void>
2273 : public _VSTD::false_type {};
2275 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2276 template <class _Tp>
2277 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2278 = is_destructible<_Tp>::value;
2283 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2285 template <class _Tp>
2286 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2287 typename remove_reference<_Tp>::type&&
2288 move(_Tp&& __t) _NOEXCEPT
2290 typedef typename remove_reference<_Tp>::type _Up;
2291 return static_cast<_Up&&>(__t);
2294 template <class _Tp>
2295 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2297 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2299 return static_cast<_Tp&&>(__t);
2302 template <class _Tp>
2303 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2305 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2307 static_assert(!is_lvalue_reference<_Tp>::value,
2308 "can not forward an rvalue as an lvalue");
2309 return static_cast<_Tp&&>(__t);
2312 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2314 template <class _Tp>
2315 inline _LIBCPP_INLINE_VISIBILITY
2322 template <class _Tp>
2323 inline _LIBCPP_INLINE_VISIBILITY
2325 move(const _Tp& __t)
2330 template <class _Tp>
2331 inline _LIBCPP_INLINE_VISIBILITY
2333 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2339 template <class _Tp>
2342 typedef typename remove_reference<_Tp>::type _Trr;
2345 _LIBCPP_INLINE_VISIBILITY
2346 _Trr* operator->() {return &t_;}
2347 _LIBCPP_INLINE_VISIBILITY
2348 explicit __rv(_Trr& __t) : t_(__t) {}
2351 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2353 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2355 template <class _Tp>
2356 inline _LIBCPP_INLINE_VISIBILITY
2357 typename decay<_Tp>::type
2358 __decay_copy(_Tp&& __t)
2360 return _VSTD::forward<_Tp>(__t);
2365 template <class _Tp>
2366 inline _LIBCPP_INLINE_VISIBILITY
2367 typename decay<_Tp>::type
2368 __decay_copy(const _Tp& __t)
2370 return _VSTD::forward<_Tp>(__t);
2375 #ifndef _LIBCPP_HAS_NO_VARIADICS
2377 template <class _Rp, class _Class, class ..._Param>
2378 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2380 typedef _Class _ClassType;
2381 typedef _Rp _ReturnType;
2382 typedef _Rp (_FnType) (_Param...);
2385 template <class _Rp, class _Class, class ..._Param>
2386 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2388 typedef _Class _ClassType;
2389 typedef _Rp _ReturnType;
2390 typedef _Rp (_FnType) (_Param..., ...);
2393 template <class _Rp, class _Class, class ..._Param>
2394 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2396 typedef _Class const _ClassType;
2397 typedef _Rp _ReturnType;
2398 typedef _Rp (_FnType) (_Param...);
2401 template <class _Rp, class _Class, class ..._Param>
2402 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2404 typedef _Class const _ClassType;
2405 typedef _Rp _ReturnType;
2406 typedef _Rp (_FnType) (_Param..., ...);
2409 template <class _Rp, class _Class, class ..._Param>
2410 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2412 typedef _Class volatile _ClassType;
2413 typedef _Rp _ReturnType;
2414 typedef _Rp (_FnType) (_Param...);
2417 template <class _Rp, class _Class, class ..._Param>
2418 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2420 typedef _Class volatile _ClassType;
2421 typedef _Rp _ReturnType;
2422 typedef _Rp (_FnType) (_Param..., ...);
2425 template <class _Rp, class _Class, class ..._Param>
2426 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2428 typedef _Class const volatile _ClassType;
2429 typedef _Rp _ReturnType;
2430 typedef _Rp (_FnType) (_Param...);
2433 template <class _Rp, class _Class, class ..._Param>
2434 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2436 typedef _Class const volatile _ClassType;
2437 typedef _Rp _ReturnType;
2438 typedef _Rp (_FnType) (_Param..., ...);
2441 #if __has_feature(cxx_reference_qualified_functions) || \
2442 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2444 template <class _Rp, class _Class, class ..._Param>
2445 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2447 typedef _Class& _ClassType;
2448 typedef _Rp _ReturnType;
2449 typedef _Rp (_FnType) (_Param...);
2452 template <class _Rp, class _Class, class ..._Param>
2453 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2455 typedef _Class& _ClassType;
2456 typedef _Rp _ReturnType;
2457 typedef _Rp (_FnType) (_Param..., ...);
2460 template <class _Rp, class _Class, class ..._Param>
2461 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2463 typedef _Class const& _ClassType;
2464 typedef _Rp _ReturnType;
2465 typedef _Rp (_FnType) (_Param...);
2468 template <class _Rp, class _Class, class ..._Param>
2469 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2471 typedef _Class const& _ClassType;
2472 typedef _Rp _ReturnType;
2473 typedef _Rp (_FnType) (_Param..., ...);
2476 template <class _Rp, class _Class, class ..._Param>
2477 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2479 typedef _Class volatile& _ClassType;
2480 typedef _Rp _ReturnType;
2481 typedef _Rp (_FnType) (_Param...);
2484 template <class _Rp, class _Class, class ..._Param>
2485 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2487 typedef _Class volatile& _ClassType;
2488 typedef _Rp _ReturnType;
2489 typedef _Rp (_FnType) (_Param..., ...);
2492 template <class _Rp, class _Class, class ..._Param>
2493 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2495 typedef _Class const volatile& _ClassType;
2496 typedef _Rp _ReturnType;
2497 typedef _Rp (_FnType) (_Param...);
2500 template <class _Rp, class _Class, class ..._Param>
2501 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2503 typedef _Class const volatile& _ClassType;
2504 typedef _Rp _ReturnType;
2505 typedef _Rp (_FnType) (_Param..., ...);
2508 template <class _Rp, class _Class, class ..._Param>
2509 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2511 typedef _Class&& _ClassType;
2512 typedef _Rp _ReturnType;
2513 typedef _Rp (_FnType) (_Param...);
2516 template <class _Rp, class _Class, class ..._Param>
2517 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2519 typedef _Class&& _ClassType;
2520 typedef _Rp _ReturnType;
2521 typedef _Rp (_FnType) (_Param..., ...);
2524 template <class _Rp, class _Class, class ..._Param>
2525 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2527 typedef _Class const&& _ClassType;
2528 typedef _Rp _ReturnType;
2529 typedef _Rp (_FnType) (_Param...);
2532 template <class _Rp, class _Class, class ..._Param>
2533 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2535 typedef _Class const&& _ClassType;
2536 typedef _Rp _ReturnType;
2537 typedef _Rp (_FnType) (_Param..., ...);
2540 template <class _Rp, class _Class, class ..._Param>
2541 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2543 typedef _Class volatile&& _ClassType;
2544 typedef _Rp _ReturnType;
2545 typedef _Rp (_FnType) (_Param...);
2548 template <class _Rp, class _Class, class ..._Param>
2549 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2551 typedef _Class volatile&& _ClassType;
2552 typedef _Rp _ReturnType;
2553 typedef _Rp (_FnType) (_Param..., ...);
2556 template <class _Rp, class _Class, class ..._Param>
2557 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2559 typedef _Class const volatile&& _ClassType;
2560 typedef _Rp _ReturnType;
2561 typedef _Rp (_FnType) (_Param...);
2564 template <class _Rp, class _Class, class ..._Param>
2565 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2567 typedef _Class const volatile&& _ClassType;
2568 typedef _Rp _ReturnType;
2569 typedef _Rp (_FnType) (_Param..., ...);
2572 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2574 #else // _LIBCPP_HAS_NO_VARIADICS
2576 template <class _Rp, class _Class>
2577 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2579 typedef _Class _ClassType;
2580 typedef _Rp _ReturnType;
2581 typedef _Rp (_FnType) ();
2584 template <class _Rp, class _Class>
2585 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2587 typedef _Class _ClassType;
2588 typedef _Rp _ReturnType;
2589 typedef _Rp (_FnType) (...);
2592 template <class _Rp, class _Class, class _P0>
2593 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2595 typedef _Class _ClassType;
2596 typedef _Rp _ReturnType;
2597 typedef _Rp (_FnType) (_P0);
2600 template <class _Rp, class _Class, class _P0>
2601 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2603 typedef _Class _ClassType;
2604 typedef _Rp _ReturnType;
2605 typedef _Rp (_FnType) (_P0, ...);
2608 template <class _Rp, class _Class, class _P0, class _P1>
2609 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2611 typedef _Class _ClassType;
2612 typedef _Rp _ReturnType;
2613 typedef _Rp (_FnType) (_P0, _P1);
2616 template <class _Rp, class _Class, class _P0, class _P1>
2617 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2619 typedef _Class _ClassType;
2620 typedef _Rp _ReturnType;
2621 typedef _Rp (_FnType) (_P0, _P1, ...);
2624 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2625 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2627 typedef _Class _ClassType;
2628 typedef _Rp _ReturnType;
2629 typedef _Rp (_FnType) (_P0, _P1, _P2);
2632 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2633 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2635 typedef _Class _ClassType;
2636 typedef _Rp _ReturnType;
2637 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2640 template <class _Rp, class _Class>
2641 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2643 typedef _Class const _ClassType;
2644 typedef _Rp _ReturnType;
2645 typedef _Rp (_FnType) ();
2648 template <class _Rp, class _Class>
2649 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2651 typedef _Class const _ClassType;
2652 typedef _Rp _ReturnType;
2653 typedef _Rp (_FnType) (...);
2656 template <class _Rp, class _Class, class _P0>
2657 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2659 typedef _Class const _ClassType;
2660 typedef _Rp _ReturnType;
2661 typedef _Rp (_FnType) (_P0);
2664 template <class _Rp, class _Class, class _P0>
2665 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2667 typedef _Class const _ClassType;
2668 typedef _Rp _ReturnType;
2669 typedef _Rp (_FnType) (_P0, ...);
2672 template <class _Rp, class _Class, class _P0, class _P1>
2673 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2675 typedef _Class const _ClassType;
2676 typedef _Rp _ReturnType;
2677 typedef _Rp (_FnType) (_P0, _P1);
2680 template <class _Rp, class _Class, class _P0, class _P1>
2681 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2683 typedef _Class const _ClassType;
2684 typedef _Rp _ReturnType;
2685 typedef _Rp (_FnType) (_P0, _P1, ...);
2688 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2689 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2691 typedef _Class const _ClassType;
2692 typedef _Rp _ReturnType;
2693 typedef _Rp (_FnType) (_P0, _P1, _P2);
2696 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2697 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2699 typedef _Class const _ClassType;
2700 typedef _Rp _ReturnType;
2701 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2704 template <class _Rp, class _Class>
2705 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2707 typedef _Class volatile _ClassType;
2708 typedef _Rp _ReturnType;
2709 typedef _Rp (_FnType) ();
2712 template <class _Rp, class _Class>
2713 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2715 typedef _Class volatile _ClassType;
2716 typedef _Rp _ReturnType;
2717 typedef _Rp (_FnType) (...);
2720 template <class _Rp, class _Class, class _P0>
2721 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2723 typedef _Class volatile _ClassType;
2724 typedef _Rp _ReturnType;
2725 typedef _Rp (_FnType) (_P0);
2728 template <class _Rp, class _Class, class _P0>
2729 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2731 typedef _Class volatile _ClassType;
2732 typedef _Rp _ReturnType;
2733 typedef _Rp (_FnType) (_P0, ...);
2736 template <class _Rp, class _Class, class _P0, class _P1>
2737 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2739 typedef _Class volatile _ClassType;
2740 typedef _Rp _ReturnType;
2741 typedef _Rp (_FnType) (_P0, _P1);
2744 template <class _Rp, class _Class, class _P0, class _P1>
2745 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2747 typedef _Class volatile _ClassType;
2748 typedef _Rp _ReturnType;
2749 typedef _Rp (_FnType) (_P0, _P1, ...);
2752 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2753 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2755 typedef _Class volatile _ClassType;
2756 typedef _Rp _ReturnType;
2757 typedef _Rp (_FnType) (_P0, _P1, _P2);
2760 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2761 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2763 typedef _Class volatile _ClassType;
2764 typedef _Rp _ReturnType;
2765 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2768 template <class _Rp, class _Class>
2769 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2771 typedef _Class const volatile _ClassType;
2772 typedef _Rp _ReturnType;
2773 typedef _Rp (_FnType) ();
2776 template <class _Rp, class _Class>
2777 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2779 typedef _Class const volatile _ClassType;
2780 typedef _Rp _ReturnType;
2781 typedef _Rp (_FnType) (...);
2784 template <class _Rp, class _Class, class _P0>
2785 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2787 typedef _Class const volatile _ClassType;
2788 typedef _Rp _ReturnType;
2789 typedef _Rp (_FnType) (_P0);
2792 template <class _Rp, class _Class, class _P0>
2793 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2795 typedef _Class const volatile _ClassType;
2796 typedef _Rp _ReturnType;
2797 typedef _Rp (_FnType) (_P0, ...);
2800 template <class _Rp, class _Class, class _P0, class _P1>
2801 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2803 typedef _Class const volatile _ClassType;
2804 typedef _Rp _ReturnType;
2805 typedef _Rp (_FnType) (_P0, _P1);
2808 template <class _Rp, class _Class, class _P0, class _P1>
2809 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2811 typedef _Class const volatile _ClassType;
2812 typedef _Rp _ReturnType;
2813 typedef _Rp (_FnType) (_P0, _P1, ...);
2816 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2817 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2819 typedef _Class const volatile _ClassType;
2820 typedef _Rp _ReturnType;
2821 typedef _Rp (_FnType) (_P0, _P1, _P2);
2824 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2825 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2827 typedef _Class const volatile _ClassType;
2828 typedef _Rp _ReturnType;
2829 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2832 #endif // _LIBCPP_HAS_NO_VARIADICS
2834 template <class _Rp, class _Class>
2835 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2837 typedef _Class _ClassType;
2838 typedef _Rp _ReturnType;
2841 template <class _MP>
2842 struct __member_pointer_traits
2843 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2844 is_member_function_pointer<_MP>::value,
2845 is_member_object_pointer<_MP>::value>
2847 // typedef ... _ClassType;
2848 // typedef ... _ReturnType;
2849 // typedef ... _FnType;
2853 template <class _DecayedFp>
2854 struct __member_pointer_class_type {};
2856 template <class _Ret, class _ClassType>
2857 struct __member_pointer_class_type<_Ret _ClassType::*> {
2858 typedef _ClassType type;
2863 template <class _Callable> class result_of;
2865 #ifdef _LIBCPP_HAS_NO_VARIADICS
2867 template <class _Fn, bool, bool>
2872 template <class _Fn>
2873 class __result_of<_Fn(), true, false>
2876 typedef decltype(declval<_Fn>()()) type;
2879 template <class _Fn, class _A0>
2880 class __result_of<_Fn(_A0), true, false>
2883 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2886 template <class _Fn, class _A0, class _A1>
2887 class __result_of<_Fn(_A0, _A1), true, false>
2890 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2893 template <class _Fn, class _A0, class _A1, class _A2>
2894 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2897 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2900 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2901 struct __result_of_mp;
2903 // member function pointer
2905 template <class _MP, class _Tp>
2906 struct __result_of_mp<_MP, _Tp, true>
2907 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2911 // member data pointer
2913 template <class _MP, class _Tp, bool>
2914 struct __result_of_mdp;
2916 template <class _Rp, class _Class, class _Tp>
2917 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2919 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2922 template <class _Rp, class _Class, class _Tp>
2923 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2925 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2928 template <class _Rp, class _Class, class _Tp>
2929 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2930 : public __result_of_mdp<_Rp _Class::*, _Tp,
2931 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2937 template <class _Fn, class _Tp>
2938 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2939 : public __result_of_mp<typename remove_reference<_Fn>::type,
2941 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2945 template <class _Fn, class _Tp, class _A0>
2946 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2947 : public __result_of_mp<typename remove_reference<_Fn>::type,
2949 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2953 template <class _Fn, class _Tp, class _A0, class _A1>
2954 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2955 : public __result_of_mp<typename remove_reference<_Fn>::type,
2957 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2961 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2962 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2963 : public __result_of_mp<typename remove_reference<_Fn>::type,
2965 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2971 template <class _Fn>
2972 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2973 : public __result_of<_Fn(),
2974 is_class<typename remove_reference<_Fn>::type>::value ||
2975 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2976 is_member_pointer<typename remove_reference<_Fn>::type>::value
2981 template <class _Fn, class _A0>
2982 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2983 : public __result_of<_Fn(_A0),
2984 is_class<typename remove_reference<_Fn>::type>::value ||
2985 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2986 is_member_pointer<typename remove_reference<_Fn>::type>::value
2991 template <class _Fn, class _A0, class _A1>
2992 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2993 : public __result_of<_Fn(_A0, _A1),
2994 is_class<typename remove_reference<_Fn>::type>::value ||
2995 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2996 is_member_pointer<typename remove_reference<_Fn>::type>::value
3001 template <class _Fn, class _A0, class _A1, class _A2>
3002 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
3003 : public __result_of<_Fn(_A0, _A1, _A2),
3004 is_class<typename remove_reference<_Fn>::type>::value ||
3005 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3006 is_member_pointer<typename remove_reference<_Fn>::type>::value
3011 #endif // _LIBCPP_HAS_NO_VARIADICS
3013 // template <class T, class... Args> struct is_constructible;
3015 namespace __is_construct
3020 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
3021 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
3023 template <class _Tp, class... _Args>
3024 struct __libcpp_is_constructible;
3026 template <class _To, class _From>
3027 struct __is_invalid_base_to_derived_cast {
3028 static_assert(is_reference<_To>::value, "Wrong specialization");
3029 using _RawFrom = __uncvref_t<_From>;
3030 using _RawTo = __uncvref_t<_To>;
3031 static const bool value = __lazy_and<
3032 __lazy_not<is_same<_RawFrom, _RawTo>>,
3033 is_base_of<_RawFrom, _RawTo>,
3034 __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
3038 template <class _To, class _From>
3039 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
3040 static_assert(is_reference<_To>::value, "Wrong specialization");
3043 template <class _ToRef, class _FromRef>
3044 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
3045 using _RawFrom = __uncvref_t<_FromRef>;
3046 using _RawTo = __uncvref_t<_ToRef>;
3047 static const bool value = __lazy_and<
3048 __lazy_not<is_function<_RawTo>>,
3050 is_same<_RawFrom, _RawTo>,
3051 is_base_of<_RawTo, _RawFrom>>
3055 struct __is_constructible_helper
3057 template <class _To>
3058 static void __eat(_To);
3060 // This overload is needed to work around a Clang bug that disallows
3061 // static_cast<T&&>(e) for non-reference-compatible types.
3062 // Example: static_cast<int&&>(declval<double>());
3063 // NOTE: The static_cast implementation below is required to support
3064 // classes with explicit conversion operators.
3065 template <class _To, class _From,
3066 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
3067 static true_type __test_cast(int);
3069 template <class _To, class _From,
3070 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
3071 static integral_constant<bool,
3072 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
3073 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
3074 > __test_cast(long);
3076 template <class, class>
3077 static false_type __test_cast(...);
3079 template <class _Tp, class ..._Args,
3080 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
3081 static true_type __test_nary(int);
3082 template <class _Tp, class...>
3083 static false_type __test_nary(...);
3085 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
3086 static is_destructible<_Tp> __test_unary(int);
3087 template <class, class>
3088 static false_type __test_unary(...);
3091 template <class _Tp, bool = is_void<_Tp>::value>
3092 struct __is_default_constructible
3093 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
3096 template <class _Tp>
3097 struct __is_default_constructible<_Tp, true> : false_type {};
3099 template <class _Tp>
3100 struct __is_default_constructible<_Tp[], false> : false_type {};
3102 template <class _Tp, size_t _Nx>
3103 struct __is_default_constructible<_Tp[_Nx], false>
3104 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3106 template <class _Tp, class... _Args>
3107 struct __libcpp_is_constructible
3109 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3110 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3114 template <class _Tp>
3115 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3117 template <class _Tp, class _A0>
3118 struct __libcpp_is_constructible<_Tp, _A0>
3119 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3122 template <class _Tp, class _A0>
3123 struct __libcpp_is_constructible<_Tp&, _A0>
3124 : public decltype(__is_constructible_helper::
3125 __test_cast<_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))
3136 #if __has_feature(is_constructible)
3137 template <class _Tp, class ..._Args>
3138 struct _LIBCPP_TEMPLATE_VIS is_constructible
3139 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3141 #elif !defined(_LIBCPP_CXX03_LANG)
3142 template <class _Tp, class... _Args>
3143 struct _LIBCPP_TEMPLATE_VIS is_constructible
3144 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3146 // template <class T> struct is_constructible0;
3148 // main is_constructible0 test
3150 template <class _Tp>
3151 decltype((_Tp(), true_type()))
3152 __is_constructible0_test(_Tp&);
3155 __is_constructible0_test(__any);
3157 template <class _Tp, class _A0>
3158 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3159 __is_constructible1_test(_Tp&, _A0&);
3161 template <class _A0>
3163 __is_constructible1_test(__any, _A0&);
3165 template <class _Tp, class _A0, class _A1>
3166 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3167 __is_constructible2_test(_Tp&, _A0&, _A1&);
3169 template <class _A0, class _A1>
3171 __is_constructible2_test(__any, _A0&, _A1&);
3173 template <class _Tp, class _A0, class _A1, class _A2>
3174 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type()))
3175 __is_constructible3_test(_Tp&, _A0&, _A1&, _A2&);
3177 template <class _A0, class _A1, class _A2>
3179 __is_constructible3_test(__any, _A0&, _A1&, _A2&);
3181 template <bool, class _Tp>
3182 struct __is_constructible0_imp // false, _Tp is not a scalar
3183 : public common_type
3185 decltype(__is_constructible0_test(declval<_Tp&>()))
3189 template <bool, class _Tp, class _A0>
3190 struct __is_constructible1_imp // false, _Tp is not a scalar
3191 : public common_type
3193 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3197 template <bool, class _Tp, class _A0, class _A1>
3198 struct __is_constructible2_imp // false, _Tp is not a scalar
3199 : public common_type
3201 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3205 template <bool, class _Tp, class _A0, class _A1, class _A2>
3206 struct __is_constructible3_imp // false, _Tp is not a scalar
3207 : public common_type
3209 decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>()))
3213 // handle scalars and reference types
3215 // Scalars are default constructible, references are not
3217 template <class _Tp>
3218 struct __is_constructible0_imp<true, _Tp>
3219 : public is_scalar<_Tp>
3222 template <class _Tp, class _A0>
3223 struct __is_constructible1_imp<true, _Tp, _A0>
3224 : public is_convertible<_A0, _Tp>
3227 template <class _Tp, class _A0, class _A1>
3228 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3232 template <class _Tp, class _A0, class _A1, class _A2>
3233 struct __is_constructible3_imp<true, _Tp, _A0, _A1, _A2>
3237 // Treat scalars and reference types separately
3239 template <bool, class _Tp>
3240 struct __is_constructible0_void_check
3241 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3245 template <bool, class _Tp, class _A0>
3246 struct __is_constructible1_void_check
3247 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3251 template <bool, class _Tp, class _A0, class _A1>
3252 struct __is_constructible2_void_check
3253 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3257 template <bool, class _Tp, class _A0, class _A1, class _A2>
3258 struct __is_constructible3_void_check
3259 : public __is_constructible3_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3263 // If any of T or Args is void, is_constructible should be false
3265 template <class _Tp>
3266 struct __is_constructible0_void_check<true, _Tp>
3270 template <class _Tp, class _A0>
3271 struct __is_constructible1_void_check<true, _Tp, _A0>
3275 template <class _Tp, class _A0, class _A1>
3276 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3280 template <class _Tp, class _A0, class _A1, class _A2>
3281 struct __is_constructible3_void_check<true, _Tp, _A0, _A1, _A2>
3285 // is_constructible entry point
3287 template <class _Tp, class _A0 = __is_construct::__nat,
3288 class _A1 = __is_construct::__nat,
3289 class _A2 = __is_construct::__nat>
3290 struct _LIBCPP_TEMPLATE_VIS is_constructible
3291 : public __is_constructible3_void_check<is_void<_Tp>::value
3292 || is_abstract<_Tp>::value
3293 || is_function<_Tp>::value
3294 || is_void<_A0>::value
3295 || is_void<_A1>::value
3296 || is_void<_A2>::value,
3300 template <class _Tp>
3301 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3302 : public __is_constructible0_void_check<is_void<_Tp>::value
3303 || is_abstract<_Tp>::value
3304 || is_function<_Tp>::value,
3308 template <class _Tp, class _A0>
3309 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
3310 : public __is_constructible1_void_check<is_void<_Tp>::value
3311 || is_abstract<_Tp>::value
3312 || is_function<_Tp>::value
3313 || is_void<_A0>::value,
3317 template <class _Tp, class _A0, class _A1>
3318 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, _A1, __is_construct::__nat>
3319 : public __is_constructible2_void_check<is_void<_Tp>::value
3320 || is_abstract<_Tp>::value
3321 || is_function<_Tp>::value
3322 || is_void<_A0>::value
3323 || is_void<_A1>::value,
3327 // Array types are default constructible if their element type
3328 // is default constructible
3330 template <class _Ap, size_t _Np>
3331 struct __is_constructible0_imp<false, _Ap[_Np]>
3332 : public is_constructible<typename remove_all_extents<_Ap>::type>
3335 template <class _Ap, size_t _Np, class _A0>
3336 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3340 template <class _Ap, size_t _Np, class _A0, class _A1>
3341 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3345 template <class _Ap, size_t _Np, class _A0, class _A1, class _A2>
3346 struct __is_constructible3_imp<false, _Ap[_Np], _A0, _A1, _A2>
3350 // Incomplete array types are not constructible
3352 template <class _Ap>
3353 struct __is_constructible0_imp<false, _Ap[]>
3357 template <class _Ap, class _A0>
3358 struct __is_constructible1_imp<false, _Ap[], _A0>
3362 template <class _Ap, class _A0, class _A1>
3363 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3367 template <class _Ap, class _A0, class _A1, class _A2>
3368 struct __is_constructible3_imp<false, _Ap[], _A0, _A1, _A2>
3372 #endif // __has_feature(is_constructible)
3375 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3376 template <class _Tp, class ..._Args>
3377 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
3378 = is_constructible<_Tp, _Args...>::value;
3381 // is_default_constructible
3383 template <class _Tp>
3384 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3385 : public is_constructible<_Tp>
3388 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3389 template <class _Tp>
3390 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
3391 = is_default_constructible<_Tp>::value;
3394 // is_copy_constructible
3396 template <class _Tp>
3397 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3398 : public is_constructible<_Tp,
3399 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3401 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3402 template <class _Tp>
3403 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3404 = is_copy_constructible<_Tp>::value;
3407 // is_move_constructible
3409 template <class _Tp>
3410 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3411 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3412 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3414 : public is_copy_constructible<_Tp>
3418 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3419 template <class _Tp>
3420 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
3421 = is_move_constructible<_Tp>::value;
3424 // is_trivially_constructible
3426 #ifndef _LIBCPP_HAS_NO_VARIADICS
3428 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3430 template <class _Tp, class... _Args>
3431 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3432 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3436 #else // !__has_feature(is_trivially_constructible)
3438 template <class _Tp, class... _Args>
3439 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3444 template <class _Tp>
3445 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3446 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3447 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3449 : integral_constant<bool, is_scalar<_Tp>::value>
3454 template <class _Tp>
3455 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3456 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3458 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
3460 : integral_constant<bool, is_scalar<_Tp>::value>
3464 template <class _Tp>
3465 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3466 : integral_constant<bool, is_scalar<_Tp>::value>
3470 template <class _Tp>
3471 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3472 : integral_constant<bool, is_scalar<_Tp>::value>
3476 #endif // !__has_feature(is_trivially_constructible)
3478 #else // _LIBCPP_HAS_NO_VARIADICS
3480 template <class _Tp, class _A0 = __is_construct::__nat,
3481 class _A1 = __is_construct::__nat>
3482 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3487 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3489 template <class _Tp>
3490 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3491 __is_construct::__nat>
3492 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3496 template <class _Tp>
3497 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3498 __is_construct::__nat>
3499 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3503 template <class _Tp>
3504 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3505 __is_construct::__nat>
3506 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3510 template <class _Tp>
3511 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3512 __is_construct::__nat>
3513 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3517 #else // !__has_feature(is_trivially_constructible)
3519 template <class _Tp>
3520 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3521 __is_construct::__nat>
3522 : integral_constant<bool, is_scalar<_Tp>::value>
3526 template <class _Tp>
3527 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3528 __is_construct::__nat>
3529 : integral_constant<bool, is_scalar<_Tp>::value>
3533 template <class _Tp>
3534 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3535 __is_construct::__nat>
3536 : integral_constant<bool, is_scalar<_Tp>::value>
3540 template <class _Tp>
3541 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3542 __is_construct::__nat>
3543 : integral_constant<bool, is_scalar<_Tp>::value>
3547 #endif // !__has_feature(is_trivially_constructible)
3549 #endif // _LIBCPP_HAS_NO_VARIADICS
3551 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3552 template <class _Tp, class... _Args>
3553 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3554 = is_trivially_constructible<_Tp, _Args...>::value;
3557 // is_trivially_default_constructible
3559 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3560 : public is_trivially_constructible<_Tp>
3563 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3564 template <class _Tp>
3565 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3566 = is_trivially_default_constructible<_Tp>::value;
3569 // is_trivially_copy_constructible
3571 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3572 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3575 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3576 template <class _Tp>
3577 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3578 = is_trivially_copy_constructible<_Tp>::value;
3581 // is_trivially_move_constructible
3583 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3584 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3585 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3587 : public is_trivially_copy_constructible<_Tp>
3591 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3592 template <class _Tp>
3593 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3594 = is_trivially_move_constructible<_Tp>::value;
3597 // is_trivially_assignable
3599 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3601 template <class _Tp, class _Arg>
3602 struct is_trivially_assignable
3603 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3607 #else // !__has_feature(is_trivially_assignable)
3609 template <class _Tp, class _Arg>
3610 struct is_trivially_assignable
3611 : public false_type {};
3613 template <class _Tp>
3614 struct is_trivially_assignable<_Tp&, _Tp>
3615 : integral_constant<bool, is_scalar<_Tp>::value> {};
3617 template <class _Tp>
3618 struct is_trivially_assignable<_Tp&, _Tp&>
3619 : integral_constant<bool, is_scalar<_Tp>::value> {};
3621 template <class _Tp>
3622 struct is_trivially_assignable<_Tp&, const _Tp&>
3623 : integral_constant<bool, is_scalar<_Tp>::value> {};
3625 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3627 template <class _Tp>
3628 struct is_trivially_assignable<_Tp&, _Tp&&>
3629 : integral_constant<bool, is_scalar<_Tp>::value> {};
3631 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3633 #endif // !__has_feature(is_trivially_assignable)
3635 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3636 template <class _Tp, class _Arg>
3637 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3638 = is_trivially_assignable<_Tp, _Arg>::value;
3641 // is_trivially_copy_assignable
3643 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3644 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3645 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3647 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3648 template <class _Tp>
3649 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3650 = is_trivially_copy_assignable<_Tp>::value;
3653 // is_trivially_move_assignable
3655 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3656 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3657 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3658 typename add_rvalue_reference<_Tp>::type>
3660 typename add_lvalue_reference<_Tp>::type>
3664 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3665 template <class _Tp>
3666 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3667 = is_trivially_move_assignable<_Tp>::value;
3670 // is_trivially_destructible
3672 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3674 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3675 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3679 template <class _Tp> struct __libcpp_trivial_destructor
3680 : public integral_constant<bool, is_scalar<_Tp>::value ||
3681 is_reference<_Tp>::value> {};
3683 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3684 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3686 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3687 : public false_type {};
3691 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3692 template <class _Tp>
3693 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3694 = is_trivially_destructible<_Tp>::value;
3697 // is_nothrow_constructible
3700 template <class _Tp, class... _Args>
3701 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3702 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3708 #ifndef _LIBCPP_HAS_NO_VARIADICS
3710 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3712 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3714 template <class _Tp, class... _Args>
3715 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3716 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3720 template <class _Tp>
3721 void __implicit_conversion_to(_Tp) noexcept { }
3723 template <class _Tp, class _Arg>
3724 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3725 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3729 template <class _Tp, bool _IsReference, class... _Args>
3730 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3735 template <class _Tp, class... _Args>
3736 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3737 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3741 template <class _Tp, size_t _Ns>
3742 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3743 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3747 #else // __has_feature(cxx_noexcept)
3749 template <class _Tp, class... _Args>
3750 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3755 template <class _Tp>
3756 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
3757 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3758 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3760 : integral_constant<bool, is_scalar<_Tp>::value>
3765 template <class _Tp>
3766 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3767 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
3769 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
3771 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3772 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3774 : integral_constant<bool, is_scalar<_Tp>::value>
3779 template <class _Tp>
3780 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
3781 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3782 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3784 : integral_constant<bool, is_scalar<_Tp>::value>
3789 template <class _Tp>
3790 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
3791 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3792 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3794 : integral_constant<bool, is_scalar<_Tp>::value>
3799 #endif // __has_feature(cxx_noexcept)
3801 #else // _LIBCPP_HAS_NO_VARIADICS
3803 template <class _Tp, class _A0 = __is_construct::__nat,
3804 class _A1 = __is_construct::__nat>
3805 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3810 template <class _Tp>
3811 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
3812 __is_construct::__nat>
3813 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3814 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3816 : integral_constant<bool, is_scalar<_Tp>::value>
3821 template <class _Tp>
3822 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
3823 __is_construct::__nat>
3824 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3825 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3827 : integral_constant<bool, is_scalar<_Tp>::value>
3832 template <class _Tp>
3833 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
3834 __is_construct::__nat>
3835 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3836 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3838 : integral_constant<bool, is_scalar<_Tp>::value>
3843 template <class _Tp>
3844 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
3845 __is_construct::__nat>
3846 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3847 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3849 : integral_constant<bool, is_scalar<_Tp>::value>
3854 #endif // _LIBCPP_HAS_NO_VARIADICS
3855 #endif // __has_feature(is_nothrow_constructible)
3857 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3858 template <class _Tp, class ..._Args>
3859 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3860 = is_nothrow_constructible<_Tp, _Args...>::value;
3863 // is_nothrow_default_constructible
3865 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3866 : public is_nothrow_constructible<_Tp>
3869 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3870 template <class _Tp>
3871 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3872 = is_nothrow_default_constructible<_Tp>::value;
3875 // is_nothrow_copy_constructible
3877 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3878 : public is_nothrow_constructible<_Tp,
3879 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3881 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3882 template <class _Tp>
3883 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3884 = is_nothrow_copy_constructible<_Tp>::value;
3887 // is_nothrow_move_constructible
3889 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3890 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3891 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3893 : public is_nothrow_copy_constructible<_Tp>
3897 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3898 template <class _Tp>
3899 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3900 = is_nothrow_move_constructible<_Tp>::value;
3903 // is_nothrow_assignable
3905 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3907 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3909 template <class _Tp, class _Arg>
3910 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3915 template <class _Tp, class _Arg>
3916 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3917 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3921 template <class _Tp, class _Arg>
3922 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3923 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3927 #else // __has_feature(cxx_noexcept)
3929 template <class _Tp, class _Arg>
3930 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3931 : public false_type {};
3933 template <class _Tp>
3934 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
3935 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3936 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3938 : integral_constant<bool, is_scalar<_Tp>::value> {};
3941 template <class _Tp>
3942 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
3943 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3944 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3946 : integral_constant<bool, is_scalar<_Tp>::value> {};
3949 template <class _Tp>
3950 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
3951 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3952 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3954 : integral_constant<bool, is_scalar<_Tp>::value> {};
3957 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3959 template <class _Tp>
3960 struct is_nothrow_assignable<_Tp&, _Tp&&>
3961 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3962 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3964 : integral_constant<bool, is_scalar<_Tp>::value> {};
3967 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3969 #endif // __has_feature(cxx_noexcept)
3971 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3972 template <class _Tp, class _Arg>
3973 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3974 = is_nothrow_assignable<_Tp, _Arg>::value;
3977 // is_nothrow_copy_assignable
3979 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3980 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3981 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3983 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3984 template <class _Tp>
3985 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3986 = is_nothrow_copy_assignable<_Tp>::value;
3989 // is_nothrow_move_assignable
3991 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3992 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3993 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3994 typename add_rvalue_reference<_Tp>::type>
3996 typename add_lvalue_reference<_Tp>::type>
4000 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4001 template <class _Tp>
4002 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
4003 = is_nothrow_move_assignable<_Tp>::value;
4006 // is_nothrow_destructible
4008 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
4010 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
4012 template <class _Tp>
4013 struct __libcpp_is_nothrow_destructible<false, _Tp>
4018 template <class _Tp>
4019 struct __libcpp_is_nothrow_destructible<true, _Tp>
4020 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
4024 template <class _Tp>
4025 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4026 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
4030 template <class _Tp, size_t _Ns>
4031 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
4032 : public is_nothrow_destructible<_Tp>
4036 template <class _Tp>
4037 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
4042 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4044 template <class _Tp>
4045 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
4054 template <class _Tp> struct __libcpp_nothrow_destructor
4055 : public integral_constant<bool, is_scalar<_Tp>::value ||
4056 is_reference<_Tp>::value> {};
4058 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
4059 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
4061 template <class _Tp>
4062 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
4063 : public false_type {};
4067 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4068 template <class _Tp>
4069 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
4070 = is_nothrow_destructible<_Tp>::value;
4075 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
4077 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4078 : public integral_constant<bool, __is_pod(_Tp)> {};
4082 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
4083 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
4084 is_trivially_copy_constructible<_Tp>::value &&
4085 is_trivially_copy_assignable<_Tp>::value &&
4086 is_trivially_destructible<_Tp>::value> {};
4090 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4091 template <class _Tp>
4092 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
4093 = is_pod<_Tp>::value;
4098 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
4099 #ifdef _LIBCPP_IS_LITERAL
4100 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
4102 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
4103 is_reference<typename remove_all_extents<_Tp>::type>::value>
4107 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4108 template <class _Tp>
4109 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
4110 = is_literal_type<_Tp>::value;
4113 // is_standard_layout;
4115 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
4116 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
4117 : public integral_constant<bool, __is_standard_layout(_Tp)>
4119 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4123 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4124 template <class _Tp>
4125 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
4126 = is_standard_layout<_Tp>::value;
4129 // is_trivially_copyable;
4131 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
4132 #if __has_feature(is_trivially_copyable)
4133 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
4134 #elif _GNUC_VER >= 501
4135 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
4137 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4141 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4142 template <class _Tp>
4143 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
4144 = is_trivially_copyable<_Tp>::value;
4149 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
4150 #if __has_feature(is_trivial) || _GNUC_VER >= 407
4151 : public integral_constant<bool, __is_trivial(_Tp)>
4153 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
4154 is_trivially_default_constructible<_Tp>::value>
4158 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4159 template <class _Tp>
4160 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
4161 = is_trivial<_Tp>::value;
4164 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
4165 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
4166 template <class _Tp> struct __is_reference_wrapper
4167 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
4169 #ifndef _LIBCPP_CXX03_LANG
4171 template <class _Fp, class _A0,
4172 class _DecayFp = typename decay<_Fp>::type,
4173 class _DecayA0 = typename decay<_A0>::type,
4174 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4175 using __enable_if_bullet1 = typename enable_if
4177 is_member_function_pointer<_DecayFp>::value
4178 && is_base_of<_ClassT, _DecayA0>::value
4181 template <class _Fp, class _A0,
4182 class _DecayFp = typename decay<_Fp>::type,
4183 class _DecayA0 = typename decay<_A0>::type>
4184 using __enable_if_bullet2 = typename enable_if
4186 is_member_function_pointer<_DecayFp>::value
4187 && __is_reference_wrapper<_DecayA0>::value
4190 template <class _Fp, class _A0,
4191 class _DecayFp = typename decay<_Fp>::type,
4192 class _DecayA0 = typename decay<_A0>::type,
4193 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4194 using __enable_if_bullet3 = typename enable_if
4196 is_member_function_pointer<_DecayFp>::value
4197 && !is_base_of<_ClassT, _DecayA0>::value
4198 && !__is_reference_wrapper<_DecayA0>::value
4201 template <class _Fp, class _A0,
4202 class _DecayFp = typename decay<_Fp>::type,
4203 class _DecayA0 = typename decay<_A0>::type,
4204 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4205 using __enable_if_bullet4 = typename enable_if
4207 is_member_object_pointer<_DecayFp>::value
4208 && is_base_of<_ClassT, _DecayA0>::value
4211 template <class _Fp, class _A0,
4212 class _DecayFp = typename decay<_Fp>::type,
4213 class _DecayA0 = typename decay<_A0>::type>
4214 using __enable_if_bullet5 = typename enable_if
4216 is_member_object_pointer<_DecayFp>::value
4217 && __is_reference_wrapper<_DecayA0>::value
4220 template <class _Fp, class _A0,
4221 class _DecayFp = typename decay<_Fp>::type,
4222 class _DecayA0 = typename decay<_A0>::type,
4223 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4224 using __enable_if_bullet6 = typename enable_if
4226 is_member_object_pointer<_DecayFp>::value
4227 && !is_base_of<_ClassT, _DecayA0>::value
4228 && !__is_reference_wrapper<_DecayA0>::value
4231 // __invoke forward declarations
4233 // fall back - none of the bullets
4235 #define _LIBCPP_INVOKE_RETURN(...) \
4236 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4237 { return __VA_ARGS__; }
4239 template <class ..._Args>
4240 auto __invoke(__any, _Args&& ...__args) -> __nat;
4242 template <class ..._Args>
4243 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4245 // bullets 1, 2 and 3
4247 template <class _Fp, class _A0, class ..._Args,
4248 class = __enable_if_bullet1<_Fp, _A0>>
4249 inline _LIBCPP_INLINE_VISIBILITY
4251 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4252 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4254 template <class _Fp, class _A0, class ..._Args,
4255 class = __enable_if_bullet1<_Fp, _A0>>
4256 inline _LIBCPP_INLINE_VISIBILITY
4257 _LIBCPP_CONSTEXPR auto
4258 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4259 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4261 template <class _Fp, class _A0, class ..._Args,
4262 class = __enable_if_bullet2<_Fp, _A0>>
4263 inline _LIBCPP_INLINE_VISIBILITY
4265 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4266 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4268 template <class _Fp, class _A0, class ..._Args,
4269 class = __enable_if_bullet2<_Fp, _A0>>
4270 inline _LIBCPP_INLINE_VISIBILITY
4271 _LIBCPP_CONSTEXPR auto
4272 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4273 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4275 template <class _Fp, class _A0, class ..._Args,
4276 class = __enable_if_bullet3<_Fp, _A0>>
4277 inline _LIBCPP_INLINE_VISIBILITY
4279 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4280 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4282 template <class _Fp, class _A0, class ..._Args,
4283 class = __enable_if_bullet3<_Fp, _A0>>
4284 inline _LIBCPP_INLINE_VISIBILITY
4285 _LIBCPP_CONSTEXPR auto
4286 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4287 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4289 // bullets 4, 5 and 6
4291 template <class _Fp, class _A0,
4292 class = __enable_if_bullet4<_Fp, _A0>>
4293 inline _LIBCPP_INLINE_VISIBILITY
4295 __invoke(_Fp&& __f, _A0&& __a0)
4296 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4298 template <class _Fp, class _A0,
4299 class = __enable_if_bullet4<_Fp, _A0>>
4300 inline _LIBCPP_INLINE_VISIBILITY
4301 _LIBCPP_CONSTEXPR auto
4302 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4303 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4305 template <class _Fp, class _A0,
4306 class = __enable_if_bullet5<_Fp, _A0>>
4307 inline _LIBCPP_INLINE_VISIBILITY
4309 __invoke(_Fp&& __f, _A0&& __a0)
4310 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4312 template <class _Fp, class _A0,
4313 class = __enable_if_bullet5<_Fp, _A0>>
4314 inline _LIBCPP_INLINE_VISIBILITY
4315 _LIBCPP_CONSTEXPR auto
4316 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4317 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4319 template <class _Fp, class _A0,
4320 class = __enable_if_bullet6<_Fp, _A0>>
4321 inline _LIBCPP_INLINE_VISIBILITY
4323 __invoke(_Fp&& __f, _A0&& __a0)
4324 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4326 template <class _Fp, class _A0,
4327 class = __enable_if_bullet6<_Fp, _A0>>
4328 inline _LIBCPP_INLINE_VISIBILITY
4329 _LIBCPP_CONSTEXPR auto
4330 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4331 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4335 template <class _Fp, class ..._Args>
4336 inline _LIBCPP_INLINE_VISIBILITY
4338 __invoke(_Fp&& __f, _Args&& ...__args)
4339 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4341 template <class _Fp, class ..._Args>
4342 inline _LIBCPP_INLINE_VISIBILITY
4343 _LIBCPP_CONSTEXPR auto
4344 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4345 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4347 #undef _LIBCPP_INVOKE_RETURN
4351 template <class _Ret, class _Fp, class ..._Args>
4352 struct __invokable_r
4354 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
4355 // or incomplete array types as required by the standard.
4356 using _Result = decltype(
4357 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4360 typename conditional<
4361 !is_same<_Result, __nat>::value,
4362 typename conditional<
4363 is_void<_Ret>::value,
4365 is_convertible<_Result, _Ret>
4369 static const bool value = type::value;
4372 template <class _Fp, class ..._Args>
4373 using __invokable = __invokable_r<void, _Fp, _Args...>;
4375 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4376 struct __nothrow_invokable_r_imp {
4377 static const bool value = false;
4380 template <class _Ret, class _Fp, class ..._Args>
4381 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4383 typedef __nothrow_invokable_r_imp _ThisT;
4385 template <class _Tp>
4386 static void __test_noexcept(_Tp) noexcept;
4388 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4389 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4392 template <class _Ret, class _Fp, class ..._Args>
4393 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4395 static const bool value = noexcept(
4396 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4399 template <class _Ret, class _Fp, class ..._Args>
4400 using __nothrow_invokable_r =
4401 __nothrow_invokable_r_imp<
4402 __invokable_r<_Ret, _Fp, _Args...>::value,
4403 is_void<_Ret>::value,
4407 template <class _Fp, class ..._Args>
4408 using __nothrow_invokable =
4409 __nothrow_invokable_r_imp<
4410 __invokable<_Fp, _Args...>::value,
4411 true, void, _Fp, _Args...
4414 template <class _Fp, class ..._Args>
4417 __invokable<_Fp, _Args...>::value,
4418 typename __invokable_r<void, _Fp, _Args...>::_Result>
4424 template <class _Fp, class ..._Args>
4425 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
4426 : public __invoke_of<_Fp, _Args...>
4430 #if _LIBCPP_STD_VER > 11
4431 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4434 #if _LIBCPP_STD_VER > 14
4438 template <class _Fn, class... _Args>
4439 struct _LIBCPP_TEMPLATE_VIS invoke_result
4440 : __invoke_of<_Fn, _Args...>
4444 template <class _Fn, class... _Args>
4445 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
4449 template <class _Fn, class ..._Args>
4450 struct _LIBCPP_TEMPLATE_VIS is_invocable
4451 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
4453 template <class _Ret, class _Fn, class ..._Args>
4454 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
4455 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4457 template <class _Fn, class ..._Args>
4458 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
4459 = is_invocable<_Fn, _Args...>::value;
4461 template <class _Ret, class _Fn, class ..._Args>
4462 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
4463 = is_invocable_r<_Ret, _Fn, _Args...>::value;
4465 // is_nothrow_invocable
4467 template <class _Fn, class ..._Args>
4468 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
4469 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
4471 template <class _Ret, class _Fn, class ..._Args>
4472 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
4473 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
4475 template <class _Fn, class ..._Args>
4476 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
4477 = is_nothrow_invocable<_Fn, _Args...>::value;
4479 template <class _Ret, class _Fn, class ..._Args>
4480 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
4481 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
4483 #endif // _LIBCPP_STD_VER > 14
4485 #endif // !defined(_LIBCPP_CXX03_LANG)
4487 template <class _Tp> struct __is_swappable;
4488 template <class _Tp> struct __is_nothrow_swappable;
4490 template <class _Tp>
4491 inline _LIBCPP_INLINE_VISIBILITY
4492 #ifndef _LIBCPP_CXX03_LANG
4495 is_move_constructible<_Tp>::value &&
4496 is_move_assignable<_Tp>::value
4501 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4502 is_nothrow_move_assignable<_Tp>::value)
4504 _Tp __t(_VSTD::move(__x));
4505 __x = _VSTD::move(__y);
4506 __y = _VSTD::move(__t);
4509 template<class _Tp, size_t _Np>
4510 inline _LIBCPP_INLINE_VISIBILITY
4512 __is_swappable<_Tp>::value
4514 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4516 template <class _ForwardIterator1, class _ForwardIterator2>
4517 inline _LIBCPP_INLINE_VISIBILITY
4519 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4520 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4521 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4522 *_VSTD::declval<_ForwardIterator2>())))
4531 // ALL generic swap overloads MUST already have a declaration available at this point.
4533 template <class _Tp, class _Up = _Tp,
4534 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4535 struct __swappable_with
4537 template <class _LHS, class _RHS>
4538 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4540 template <class, class>
4541 static __nat __test_swap(long);
4543 // Extra parens are needed for the C++03 definition of decltype.
4544 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4545 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4547 static const bool value = !is_same<__swap1, __nat>::value
4548 && !is_same<__swap2, __nat>::value;
4551 template <class _Tp, class _Up>
4552 struct __swappable_with<_Tp, _Up, false> : false_type {};
4554 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4555 struct __nothrow_swappable_with {
4556 static const bool value =
4557 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4558 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4559 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4565 template <class _Tp, class _Up>
4566 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4570 template <class _Tp>
4571 struct __is_swappable
4572 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4576 template <class _Tp>
4577 struct __is_nothrow_swappable
4578 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4582 #if _LIBCPP_STD_VER > 14
4584 template <class _Tp, class _Up>
4585 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4586 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4590 template <class _Tp>
4591 struct _LIBCPP_TEMPLATE_VIS is_swappable
4592 : public conditional<
4593 __is_referenceable<_Tp>::value,
4595 typename add_lvalue_reference<_Tp>::type,
4596 typename add_lvalue_reference<_Tp>::type>,
4602 template <class _Tp, class _Up>
4603 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4604 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4608 template <class _Tp>
4609 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4610 : public conditional<
4611 __is_referenceable<_Tp>::value,
4612 is_nothrow_swappable_with<
4613 typename add_lvalue_reference<_Tp>::type,
4614 typename add_lvalue_reference<_Tp>::type>,
4620 template <class _Tp, class _Up>
4621 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
4622 = is_swappable_with<_Tp, _Up>::value;
4624 template <class _Tp>
4625 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
4626 = is_swappable<_Tp>::value;
4628 template <class _Tp, class _Up>
4629 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
4630 = is_nothrow_swappable_with<_Tp, _Up>::value;
4632 template <class _Tp>
4633 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
4634 = is_nothrow_swappable<_Tp>::value;
4636 #endif // _LIBCPP_STD_VER > 14
4638 #ifdef _LIBCPP_UNDERLYING_TYPE
4640 template <class _Tp>
4641 struct underlying_type
4643 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4646 #if _LIBCPP_STD_VER > 11
4647 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4650 #else // _LIBCPP_UNDERLYING_TYPE
4652 template <class _Tp, bool _Support = false>
4653 struct underlying_type
4655 static_assert(_Support, "The underyling_type trait requires compiler "
4656 "support. Either no such support exists or "
4657 "libc++ does not know how to use it.");
4660 #endif // _LIBCPP_UNDERLYING_TYPE
4663 template <class _Tp, bool = is_enum<_Tp>::value>
4664 struct __sfinae_underlying_type
4666 typedef typename underlying_type<_Tp>::type type;
4667 typedef decltype(((type)1) + 0) __promoted_type;
4670 template <class _Tp>
4671 struct __sfinae_underlying_type<_Tp, false> {};
4673 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4674 int __convert_to_integral(int __val) { return __val; }
4676 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4677 unsigned __convert_to_integral(unsigned __val) { return __val; }
4679 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4680 long __convert_to_integral(long __val) { return __val; }
4682 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4683 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4685 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4686 long long __convert_to_integral(long long __val) { return __val; }
4688 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4689 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4691 template<typename _Fp>
4692 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4693 typename enable_if<is_floating_point<_Fp>::value, long long>::type
4694 __convert_to_integral(_Fp __val) { return __val; }
4696 #ifndef _LIBCPP_HAS_NO_INT128
4697 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4698 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4700 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4701 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4704 template <class _Tp>
4705 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4706 typename __sfinae_underlying_type<_Tp>::__promoted_type
4707 __convert_to_integral(_Tp __val) { return __val; }
4709 #ifndef _LIBCPP_CXX03_LANG
4711 template <class _Tp>
4712 struct __has_operator_addressof_member_imp
4714 template <class _Up>
4715 static auto __test(int)
4716 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4718 static auto __test(long) -> false_type;
4720 static const bool value = decltype(__test<_Tp>(0))::value;
4723 template <class _Tp>
4724 struct __has_operator_addressof_free_imp
4726 template <class _Up>
4727 static auto __test(int)
4728 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4730 static auto __test(long) -> false_type;
4732 static const bool value = decltype(__test<_Tp>(0))::value;
4735 template <class _Tp>
4736 struct __has_operator_addressof
4737 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4738 || __has_operator_addressof_free_imp<_Tp>::value>
4741 #endif // _LIBCPP_CXX03_LANG
4743 #if _LIBCPP_STD_VER > 14
4745 #define __cpp_lib_void_t 201411
4746 template <class...> using void_t = void;
4748 # ifndef _LIBCPP_HAS_NO_VARIADICS
4749 template <class... _Args>
4750 struct conjunction : __and_<_Args...> {};
4751 template<class... _Args>
4752 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
4753 = conjunction<_Args...>::value;
4755 template <class... _Args>
4756 struct disjunction : __or_<_Args...> {};
4757 template<class... _Args>
4758 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
4759 = disjunction<_Args...>::value;
4761 template <class _Tp>
4762 struct negation : __not_<_Tp> {};
4764 _LIBCPP_INLINE_VAR constexpr bool negation_v
4765 = negation<_Tp>::value;
4766 # endif // _LIBCPP_HAS_NO_VARIADICS
4767 #endif // _LIBCPP_STD_VER > 14
4769 // These traits are used in __tree and __hash_table
4770 #ifndef _LIBCPP_CXX03_LANG
4771 struct __extract_key_fail_tag {};
4772 struct __extract_key_self_tag {};
4773 struct __extract_key_first_tag {};
4775 template <class _ValTy, class _Key,
4776 class _RawValTy = typename __unconstref<_ValTy>::type>
4777 struct __can_extract_key
4778 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4779 __extract_key_fail_tag>::type {};
4781 template <class _Pair, class _Key, class _First, class _Second>
4782 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4783 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4784 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4786 // __can_extract_map_key uses true_type/false_type instead of the tags.
4787 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4788 // and _ValTy == _Key.
4789 template <class _ValTy, class _Key, class _ContainerValueTy,
4790 class _RawValTy = typename __unconstref<_ValTy>::type>
4791 struct __can_extract_map_key
4792 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4794 // This specialization returns __extract_key_fail_tag for non-map containers
4795 // because _Key == _ContainerValueTy
4796 template <class _ValTy, class _Key, class _RawValTy>
4797 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4802 #if _LIBCPP_STD_VER > 17
4807 #if defined(_LIBCPP_LITTLE_ENDIAN)
4809 #elif defined(_LIBCPP_BIG_ENDIAN)
4817 _LIBCPP_END_NAMESPACE_STD
4819 #if _LIBCPP_STD_VER > 14
4821 namespace std // purposefully not versioned
4823 template <class _Integer>
4824 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4825 operator<<=(byte& __lhs, _Integer __shift) noexcept
4826 { return __lhs = __lhs << __shift; }
4828 template <class _Integer>
4829 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4830 operator<< (byte __lhs, _Integer __shift) noexcept
4831 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
4833 template <class _Integer>
4834 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4835 operator>>=(byte& __lhs, _Integer __shift) noexcept
4836 { return __lhs = __lhs >> __shift; }
4838 template <class _Integer>
4839 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4840 operator>> (byte __lhs, _Integer __shift) noexcept
4841 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4843 template <class _Integer>
4844 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4845 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4850 #endif // _LIBCPP_TYPE_TRAITS