2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_TYPE_TRAITS
11 #define _LIBCPP_TYPE_TRAITS
20 template <class T, T v> struct integral_constant;
21 typedef integral_constant<bool, true> true_type; // C++11
22 typedef integral_constant<bool, false> false_type; // C++11
24 template <bool B> // C++14
25 using bool_constant = integral_constant<bool, B>; // C++14
26 typedef bool_constant<true> true_type; // C++14
27 typedef bool_constant<false> false_type; // C++14
30 template <bool, class T = void> struct enable_if;
31 template <bool, class T, class F> struct conditional;
33 // Primary classification traits:
34 template <class T> struct is_void;
35 template <class T> struct is_null_pointer; // C++14
36 template <class T> struct is_integral;
37 template <class T> struct is_floating_point;
38 template <class T> struct is_array;
39 template <class T> struct is_pointer;
40 template <class T> struct is_lvalue_reference;
41 template <class T> struct is_rvalue_reference;
42 template <class T> struct is_member_object_pointer;
43 template <class T> struct is_member_function_pointer;
44 template <class T> struct is_enum;
45 template <class T> struct is_union;
46 template <class T> struct is_class;
47 template <class T> struct is_function;
49 // Secondary classification traits:
50 template <class T> struct is_reference;
51 template <class T> struct is_arithmetic;
52 template <class T> struct is_fundamental;
53 template <class T> struct is_member_pointer;
54 template <class T> struct is_scoped_enum; // C++2b
55 template <class T> struct is_scalar;
56 template <class T> struct is_object;
57 template <class T> struct is_compound;
59 // Const-volatile properties and transformations:
60 template <class T> struct is_const;
61 template <class T> struct is_volatile;
62 template <class T> struct remove_const;
63 template <class T> struct remove_volatile;
64 template <class T> struct remove_cv;
65 template <class T> struct add_const;
66 template <class T> struct add_volatile;
67 template <class T> struct add_cv;
69 // Reference transformations:
70 template <class T> struct remove_reference;
71 template <class T> struct add_lvalue_reference;
72 template <class T> struct add_rvalue_reference;
74 // Pointer transformations:
75 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;
78 template<class T> struct type_identity; // C++20
80 using type_identity_t = typename type_identity<T>::type; // C++20
82 // Integral properties:
83 template <class T> struct is_signed;
84 template <class T> struct is_unsigned;
85 template <class T> struct make_signed;
86 template <class T> struct make_unsigned;
88 // Array properties and transformations:
89 template <class T> struct rank;
90 template <class T, unsigned I = 0> struct extent;
91 template <class T> struct remove_extent;
92 template <class T> struct remove_all_extents;
94 template <class T> struct is_bounded_array; // C++20
95 template <class T> struct is_unbounded_array; // C++20
97 // Member introspection:
98 template <class T> struct is_pod;
99 template <class T> struct is_trivial;
100 template <class T> struct is_trivially_copyable;
101 template <class T> struct is_standard_layout;
102 template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20
103 template <class T> struct is_empty;
104 template <class T> struct is_polymorphic;
105 template <class T> struct is_abstract;
106 template <class T> struct is_final; // C++14
107 template <class T> struct is_aggregate; // C++17
109 template <class T, class... Args> struct is_constructible;
110 template <class T> struct is_default_constructible;
111 template <class T> struct is_copy_constructible;
112 template <class T> struct is_move_constructible;
113 template <class T, class U> struct is_assignable;
114 template <class T> struct is_copy_assignable;
115 template <class T> struct is_move_assignable;
116 template <class T, class U> struct is_swappable_with; // C++17
117 template <class T> struct is_swappable; // C++17
118 template <class T> struct is_destructible;
120 template <class T, class... Args> struct is_trivially_constructible;
121 template <class T> struct is_trivially_default_constructible;
122 template <class T> struct is_trivially_copy_constructible;
123 template <class T> struct is_trivially_move_constructible;
124 template <class T, class U> struct is_trivially_assignable;
125 template <class T> struct is_trivially_copy_assignable;
126 template <class T> struct is_trivially_move_assignable;
127 template <class T> struct is_trivially_destructible;
129 template <class T, class... Args> struct is_nothrow_constructible;
130 template <class T> struct is_nothrow_default_constructible;
131 template <class T> struct is_nothrow_copy_constructible;
132 template <class T> struct is_nothrow_move_constructible;
133 template <class T, class U> struct is_nothrow_assignable;
134 template <class T> struct is_nothrow_copy_assignable;
135 template <class T> struct is_nothrow_move_assignable;
136 template <class T, class U> struct is_nothrow_swappable_with; // C++17
137 template <class T> struct is_nothrow_swappable; // C++17
138 template <class T> struct is_nothrow_destructible;
140 template <class T> struct has_virtual_destructor;
142 template<class T> struct has_unique_object_representations; // C++17
144 // Relationships between types:
145 template <class T, class U> struct is_same;
146 template <class Base, class Derived> struct is_base_of;
148 template <class From, class To> struct is_convertible;
149 template <typename From, typename To> struct is_nothrow_convertible; // C++20
150 template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20
152 template <class Fn, class... ArgTypes> struct is_invocable;
153 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
155 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
156 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
158 // Alignment properties and transformations:
159 template <class T> struct alignment_of;
160 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
161 struct aligned_storage;
162 template <size_t Len, class... Types> struct aligned_union;
163 template <class T> struct remove_cvref; // C++20
165 template <class T> struct decay;
166 template <class... T> struct common_type;
167 template <class T> struct underlying_type;
168 template <class> class result_of; // undefined; deprecated in C++17; removed in C++20
169 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20
170 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
172 // const-volatile modifications:
174 using remove_const_t = typename remove_const<T>::type; // C++14
176 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
178 using remove_cv_t = typename remove_cv<T>::type; // C++14
180 using add_const_t = typename add_const<T>::type; // C++14
182 using add_volatile_t = typename add_volatile<T>::type; // C++14
184 using add_cv_t = typename add_cv<T>::type; // C++14
186 // reference modifications:
188 using remove_reference_t = typename remove_reference<T>::type; // C++14
190 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
192 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
194 // sign modifications:
196 using make_signed_t = typename make_signed<T>::type; // C++14
198 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
200 // array modifications:
202 using remove_extent_t = typename remove_extent<T>::type; // C++14
204 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
207 inline constexpr bool is_bounded_array_v
208 = is_bounded_array<T>::value; // C++20
209 inline constexpr bool is_unbounded_array_v
210 = is_unbounded_array<T>::value; // C++20
212 // pointer modifications:
214 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
216 using add_pointer_t = typename add_pointer<T>::type; // C++14
218 // other transformations:
219 template <size_t Len, size_t Align=default-alignment>
220 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
221 template <size_t Len, class... Types>
222 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
224 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
226 using decay_t = typename decay<T>::type; // C++14
227 template <bool b, class T=void>
228 using enable_if_t = typename enable_if<b,T>::type; // C++14
229 template <bool b, class T, class F>
230 using conditional_t = typename conditional<b,T,F>::type; // C++14
231 template <class... T>
232 using common_type_t = typename common_type<T...>::type; // C++14
234 using underlying_type_t = typename underlying_type<T>::type; // C++14
236 using result_of_t = typename result_of<T>::type; // C++14; deprecated in C++17; removed in C++20
237 template <class Fn, class... ArgTypes>
238 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
241 using void_t = void; // C++17
243 // See C++14 20.10.4.1, primary type categories
244 template <class T> inline constexpr bool is_void_v
245 = is_void<T>::value; // C++17
246 template <class T> inline constexpr bool is_null_pointer_v
247 = is_null_pointer<T>::value; // C++17
248 template <class T> inline constexpr bool is_integral_v
249 = is_integral<T>::value; // C++17
250 template <class T> inline constexpr bool is_floating_point_v
251 = is_floating_point<T>::value; // C++17
252 template <class T> inline constexpr bool is_array_v
253 = is_array<T>::value; // C++17
254 template <class T> inline constexpr bool is_pointer_v
255 = is_pointer<T>::value; // C++17
256 template <class T> inline constexpr bool is_lvalue_reference_v
257 = is_lvalue_reference<T>::value; // C++17
258 template <class T> inline constexpr bool is_rvalue_reference_v
259 = is_rvalue_reference<T>::value; // C++17
260 template <class T> inline constexpr bool is_member_object_pointer_v
261 = is_member_object_pointer<T>::value; // C++17
262 template <class T> inline constexpr bool is_member_function_pointer_v
263 = is_member_function_pointer<T>::value; // C++17
264 template <class T> inline constexpr bool is_enum_v
265 = is_enum<T>::value; // C++17
266 template <class T> inline constexpr bool is_union_v
267 = is_union<T>::value; // C++17
268 template <class T> inline constexpr bool is_class_v
269 = is_class<T>::value; // C++17
270 template <class T> inline constexpr bool is_function_v
271 = is_function<T>::value; // C++17
273 // See C++14 20.10.4.2, composite type categories
274 template <class T> inline constexpr bool is_reference_v
275 = is_reference<T>::value; // C++17
276 template <class T> inline constexpr bool is_arithmetic_v
277 = is_arithmetic<T>::value; // C++17
278 template <class T> inline constexpr bool is_fundamental_v
279 = is_fundamental<T>::value; // C++17
280 template <class T> inline constexpr bool is_object_v
281 = is_object<T>::value; // C++17
282 template <class T> inline constexpr bool is_scalar_v
283 = is_scalar<T>::value; // C++17
284 template <class T> inline constexpr bool is_compound_v
285 = is_compound<T>::value; // C++17
286 template <class T> inline constexpr bool is_member_pointer_v
287 = is_member_pointer<T>::value; // C++17
288 template <class T> inline constexpr bool is_scoped_enum_v
289 = is_scoped_enum<T>::value; // C++2b
291 // See C++14 20.10.4.3, type properties
292 template <class T> inline constexpr bool is_const_v
293 = is_const<T>::value; // C++17
294 template <class T> inline constexpr bool is_volatile_v
295 = is_volatile<T>::value; // C++17
296 template <class T> inline constexpr bool is_trivial_v
297 = is_trivial<T>::value; // C++17
298 template <class T> inline constexpr bool is_trivially_copyable_v
299 = is_trivially_copyable<T>::value; // C++17
300 template <class T> inline constexpr bool is_standard_layout_v
301 = is_standard_layout<T>::value; // C++17
302 template <class T> inline constexpr bool is_pod_v
303 = is_pod<T>::value; // C++17
304 template <class T> inline constexpr bool is_literal_type_v
305 = is_literal_type<T>::value; // C++17; deprecated in C++17; removed in C++20
306 template <class T> inline constexpr bool is_empty_v
307 = is_empty<T>::value; // C++17
308 template <class T> inline constexpr bool is_polymorphic_v
309 = is_polymorphic<T>::value; // C++17
310 template <class T> inline constexpr bool is_abstract_v
311 = is_abstract<T>::value; // C++17
312 template <class T> inline constexpr bool is_final_v
313 = is_final<T>::value; // C++17
314 template <class T> inline constexpr bool is_aggregate_v
315 = is_aggregate<T>::value; // C++17
316 template <class T> inline constexpr bool is_signed_v
317 = is_signed<T>::value; // C++17
318 template <class T> inline constexpr bool is_unsigned_v
319 = is_unsigned<T>::value; // C++17
320 template <class T, class... Args> inline constexpr bool is_constructible_v
321 = is_constructible<T, Args...>::value; // C++17
322 template <class T> inline constexpr bool is_default_constructible_v
323 = is_default_constructible<T>::value; // C++17
324 template <class T> inline constexpr bool is_copy_constructible_v
325 = is_copy_constructible<T>::value; // C++17
326 template <class T> inline constexpr bool is_move_constructible_v
327 = is_move_constructible<T>::value; // C++17
328 template <class T, class U> inline constexpr bool is_assignable_v
329 = is_assignable<T, U>::value; // C++17
330 template <class T> inline constexpr bool is_copy_assignable_v
331 = is_copy_assignable<T>::value; // C++17
332 template <class T> inline constexpr bool is_move_assignable_v
333 = is_move_assignable<T>::value; // C++17
334 template <class T, class U> inline constexpr bool is_swappable_with_v
335 = is_swappable_with<T, U>::value; // C++17
336 template <class T> inline constexpr bool is_swappable_v
337 = is_swappable<T>::value; // C++17
338 template <class T> inline constexpr bool is_destructible_v
339 = is_destructible<T>::value; // C++17
340 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
341 = is_trivially_constructible<T, Args...>::value; // C++17
342 template <class T> inline constexpr bool is_trivially_default_constructible_v
343 = is_trivially_default_constructible<T>::value; // C++17
344 template <class T> inline constexpr bool is_trivially_copy_constructible_v
345 = is_trivially_copy_constructible<T>::value; // C++17
346 template <class T> inline constexpr bool is_trivially_move_constructible_v
347 = is_trivially_move_constructible<T>::value; // C++17
348 template <class T, class U> inline constexpr bool is_trivially_assignable_v
349 = is_trivially_assignable<T, U>::value; // C++17
350 template <class T> inline constexpr bool is_trivially_copy_assignable_v
351 = is_trivially_copy_assignable<T>::value; // C++17
352 template <class T> inline constexpr bool is_trivially_move_assignable_v
353 = is_trivially_move_assignable<T>::value; // C++17
354 template <class T> inline constexpr bool is_trivially_destructible_v
355 = is_trivially_destructible<T>::value; // C++17
356 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
357 = is_nothrow_constructible<T, Args...>::value; // C++17
358 template <class T> inline constexpr bool is_nothrow_default_constructible_v
359 = is_nothrow_default_constructible<T>::value; // C++17
360 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
361 = is_nothrow_copy_constructible<T>::value; // C++17
362 template <class T> inline constexpr bool is_nothrow_move_constructible_v
363 = is_nothrow_move_constructible<T>::value; // C++17
364 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
365 = is_nothrow_assignable<T, U>::value; // C++17
366 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
367 = is_nothrow_copy_assignable<T>::value; // C++17
368 template <class T> inline constexpr bool is_nothrow_move_assignable_v
369 = is_nothrow_move_assignable<T>::value; // C++17
370 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
371 = is_nothrow_swappable_with<T, U>::value; // C++17
372 template <class T> inline constexpr bool is_nothrow_swappable_v
373 = is_nothrow_swappable<T>::value; // C++17
374 template <class T> inline constexpr bool is_nothrow_destructible_v
375 = is_nothrow_destructible<T>::value; // C++17
376 template <class T> inline constexpr bool has_virtual_destructor_v
377 = has_virtual_destructor<T>::value; // C++17
378 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
379 = has_unique_object_representations<T>::value;
381 // See C++14 20.10.5, type property queries
382 template <class T> inline constexpr size_t alignment_of_v
383 = alignment_of<T>::value; // C++17
384 template <class T> inline constexpr size_t rank_v
385 = rank<T>::value; // C++17
386 template <class T, unsigned I = 0> inline constexpr size_t extent_v
387 = extent<T, I>::value; // C++17
389 // See C++14 20.10.6, type relations
390 template <class T, class U> inline constexpr bool is_same_v
391 = is_same<T, U>::value; // C++17
392 template <class Base, class Derived> inline constexpr bool is_base_of_v
393 = is_base_of<Base, Derived>::value; // C++17
394 template <class From, class To> inline constexpr bool is_convertible_v
395 = is_convertible<From, To>::value; // C++17
396 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
397 = is_invocable<Fn, ArgTypes...>::value; // C++17
398 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
399 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
400 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
401 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
402 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
403 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
405 // [meta.logical], logical operator traits:
406 template<class... B> struct conjunction; // C++17
408 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
409 template<class... B> struct disjunction; // C++17
411 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
412 template<class B> struct negation; // C++17
414 inline constexpr bool negation_v = negation<B>::value; // C++17
423 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
424 #pragma GCC system_header
427 _LIBCPP_BEGIN_NAMESPACE_STD
429 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
430 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
431 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
433 template <class _Tp, _Tp __v>
434 struct _LIBCPP_TEMPLATE_VIS integral_constant
436 static _LIBCPP_CONSTEXPR const _Tp value = __v;
437 typedef _Tp value_type;
438 typedef integral_constant type;
439 _LIBCPP_INLINE_VISIBILITY
440 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
441 #if _LIBCPP_STD_VER > 11
442 _LIBCPP_INLINE_VISIBILITY
443 constexpr value_type operator ()() const _NOEXCEPT {return value;}
447 template <class _Tp, _Tp __v>
448 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
450 #if _LIBCPP_STD_VER > 14
452 using bool_constant = integral_constant<bool, __b>;
453 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
455 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
458 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
459 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
461 template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;
463 #if _LIBCPP_STD_VER > 11
464 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
467 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
468 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
471 using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>;
473 template <bool> struct _MetaBase;
475 struct _MetaBase<true> {
476 template <class _Tp, class _Up>
477 using _SelectImpl _LIBCPP_NODEBUG = _Tp;
478 template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
479 using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>;
480 template <class _First, class...>
481 using _FirstImpl _LIBCPP_NODEBUG = _First;
482 template <class, class _Second, class...>
483 using _SecondImpl _LIBCPP_NODEBUG = _Second;
484 template <class _Result, class _First, class ..._Rest>
485 using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
489 struct _MetaBase<false> {
490 template <class _Tp, class _Up>
491 using _SelectImpl _LIBCPP_NODEBUG = _Up;
492 template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
493 using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>;
494 template <class _Result, class ...>
495 using _OrImpl _LIBCPP_NODEBUG = _Result;
497 template <bool _Cond, class _IfRes, class _ElseRes>
498 using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
499 template <class ..._Rest>
500 using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
501 template <class _Pred>
502 struct _Not : _BoolConstant<!_Pred::value> {};
503 template <class ..._Args>
504 using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
505 template <class ..._Args>
506 using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
508 template <class ...> using __expand_to_true = true_type;
509 template <class ..._Pred>
510 __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
512 false_type __and_helper(...);
513 template <class ..._Pred>
514 using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
516 template <template <class...> class _Func, class ..._Args>
517 struct _Lazy : _Func<_Args...> {};
519 // Member detector base
521 template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
522 true_type __sfinae_test_impl(int);
523 template <template <class...> class, class ...>
524 false_type __sfinae_test_impl(...);
526 template <template <class ...> class _Templ, class ..._Args>
527 using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
530 struct __void_t { typedef void type; };
533 struct __identity { typedef _Tp type; };
536 using __identity_t _LIBCPP_NODEBUG = typename __identity<_Tp>::type;
538 template <class _Tp, bool>
539 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
542 template <bool _Bp, class _If, class _Then>
543 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
544 template <class _If, class _Then>
545 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
547 #if _LIBCPP_STD_VER > 11
548 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
553 template <class _Tp, class _Up>
554 struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
556 #if _LIBCPP_STD_VER > 14
557 template <class _Tp, class _Up>
558 inline constexpr bool is_same_v = __is_same(_Tp, _Up);
561 // _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
562 // is_same<A,B> and is_same<C,D> are guaranteed to be different types, but
563 // _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type).
564 // Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame
565 // mustn't be directly used anywhere that contributes to name-mangling
566 // (such as in a dependent return type).
568 template <class _Tp, class _Up>
569 using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;
571 template <class _Tp, class _Up>
572 using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;
575 using __test_for_primary_template = __enable_if_t<
576 _IsSame<_Tp, typename _Tp::__primary_template>::value
579 using __is_primary_template = _IsValidExpansion<
580 __test_for_primary_template, _Tp
585 struct __two {char __lx[2];};
589 #if __has_keyword(__is_const)
592 struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
594 #if _LIBCPP_STD_VER > 14
596 inline constexpr bool is_const_v = __is_const(_Tp);
601 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
602 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
604 #if _LIBCPP_STD_VER > 14
606 inline constexpr bool is_const_v = is_const<_Tp>::value;
609 #endif // __has_keyword(__is_const)
613 #if __has_keyword(__is_volatile)
616 struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
618 #if _LIBCPP_STD_VER > 14
620 inline constexpr bool is_volatile_v = __is_volatile(_Tp);
625 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
626 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
628 #if _LIBCPP_STD_VER > 14
630 inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
633 #endif // __has_keyword(__is_volatile)
637 #if __has_keyword(__remove_const)
640 struct _LIBCPP_TEMPLATE_VIS remove_const {typedef __remove_const(_Tp) type;};
642 #if _LIBCPP_STD_VER > 11
643 template <class _Tp> using remove_const_t = __remove_const(_Tp);
648 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
649 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
650 #if _LIBCPP_STD_VER > 11
651 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
654 #endif // __has_keyword(__remove_const)
658 #if __has_keyword(__remove_volatile)
661 struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef __remove_volatile(_Tp) type;};
663 #if _LIBCPP_STD_VER > 11
664 template <class _Tp> using remove_volatile_t = __remove_volatile(_Tp);
669 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
670 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
671 #if _LIBCPP_STD_VER > 11
672 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
675 #endif // __has_keyword(__remove_volatile)
679 #if __has_keyword(__remove_cv)
682 struct _LIBCPP_TEMPLATE_VIS remove_cv {typedef __remove_cv(_Tp) type;};
684 #if _LIBCPP_STD_VER > 11
685 template <class _Tp> using remove_cv_t = __remove_cv(_Tp);
690 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
691 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
692 #if _LIBCPP_STD_VER > 11
693 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
696 #endif // __has_keyword(__remove_cv)
700 #if __has_keyword(__is_void)
703 struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
705 #if _LIBCPP_STD_VER > 14
707 inline constexpr bool is_void_v = __is_void(_Tp);
712 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
713 : public is_same<typename remove_cv<_Tp>::type, void> {};
715 #if _LIBCPP_STD_VER > 14
717 inline constexpr bool is_void_v = is_void<_Tp>::value;
720 #endif // __has_keyword(__is_void)
724 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
725 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
727 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
728 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
730 #if _LIBCPP_STD_VER > 11
731 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
732 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
734 #if _LIBCPP_STD_VER > 14
736 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
738 #endif // _LIBCPP_STD_VER > 11
742 #if __has_keyword(__is_integral)
745 struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
747 #if _LIBCPP_STD_VER > 14
749 inline constexpr bool is_integral_v = __is_integral(_Tp);
754 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
755 : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
757 #if _LIBCPP_STD_VER > 14
759 inline constexpr bool is_integral_v = is_integral<_Tp>::value;
762 #endif // __has_keyword(__is_integral)
764 // [basic.fundamental] defines five standard signed integer types;
765 // __int128_t is an extended signed integer type.
766 // The signed and unsigned integer types, plus bool and the
767 // five types with "char" in their name, compose the "integral" types.
769 template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
770 template <> struct __libcpp_is_signed_integer<signed char> : public true_type {};
771 template <> struct __libcpp_is_signed_integer<signed short> : public true_type {};
772 template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
773 template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
774 template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
775 #ifndef _LIBCPP_HAS_NO_INT128
776 template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
779 template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
780 template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {};
781 template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {};
782 template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
783 template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
784 template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
785 #ifndef _LIBCPP_HAS_NO_INT128
786 template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
790 // <concepts> implements __libcpp_floating_point
792 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
793 template <> struct __libcpp_is_floating_point<float> : public true_type {};
794 template <> struct __libcpp_is_floating_point<double> : public true_type {};
795 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
797 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
798 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
800 #if _LIBCPP_STD_VER > 14
802 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
807 #if __has_keyword(__is_array)
810 struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
812 #if _LIBCPP_STD_VER > 14
814 inline constexpr bool is_array_v = __is_array(_Tp);
819 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
820 : public false_type {};
821 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
822 : public true_type {};
823 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
824 : public true_type {};
826 #if _LIBCPP_STD_VER > 14
828 inline constexpr bool is_array_v = is_array<_Tp>::value;
831 #endif // __has_keyword(__is_array)
835 // Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types.
836 #if __has_keyword(__is_pointer) && \
837 !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205)
840 struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
842 #if _LIBCPP_STD_VER > 14
844 inline constexpr bool is_pointer_v = __is_pointer(_Tp);
847 #else // __has_keyword(__is_pointer)
849 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
850 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
852 template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
853 #if defined(_LIBCPP_HAS_OBJC_ARC)
854 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
855 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
856 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
857 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
860 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
861 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
863 #if _LIBCPP_STD_VER > 14
865 inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
868 #endif // __has_keyword(__is_pointer)
872 #if __has_keyword(__is_lvalue_reference) && \
873 __has_keyword(__is_rvalue_reference) && \
874 __has_keyword(__is_reference)
877 struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
880 struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
883 struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
885 #if _LIBCPP_STD_VER > 14
887 inline constexpr bool is_reference_v = __is_reference(_Tp);
889 inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
891 inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
894 #else // __has_keyword(__is_lvalue_reference) && etc...
896 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
897 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
899 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
900 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
902 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
903 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
904 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
906 #if _LIBCPP_STD_VER > 14
908 inline constexpr bool is_reference_v = is_reference<_Tp>::value;
911 inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
914 inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
917 #endif // __has_keyword(__is_lvalue_reference) && etc...
921 #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
923 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
924 : public integral_constant<bool, __is_union(_Tp)> {};
928 template <class _Tp> struct __libcpp_union : public false_type {};
929 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
930 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
934 #if _LIBCPP_STD_VER > 14
936 inline constexpr bool is_union_v = is_union<_Tp>::value;
941 #if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
943 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
944 : public integral_constant<bool, __is_class(_Tp)> {};
948 namespace __is_class_imp
950 template <class _Tp> char __test(int _Tp::*);
951 template <class _Tp> __two __test(...);
954 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
955 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
959 #if _LIBCPP_STD_VER > 14
961 inline constexpr bool is_class_v = is_class<_Tp>::value;
966 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
967 : public _BoolConstant<
971 !(is_reference<_Tp>::value || is_const<const _Tp>::value)
976 #if _LIBCPP_STD_VER > 14
978 inline constexpr bool is_function_v = is_function<_Tp>::value;
981 template <class _Tp> struct __libcpp_is_member_pointer {
988 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
991 __is_func = is_function<_Tp>::value,
992 __is_obj = !__is_func,
996 #if __has_keyword(__is_member_function_pointer)
999 struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
1000 : _BoolConstant<__is_member_function_pointer(_Tp)> { };
1002 #if _LIBCPP_STD_VER > 14
1003 template <class _Tp>
1004 inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
1007 #else // __has_keyword(__is_member_function_pointer)
1009 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
1010 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
1012 #if _LIBCPP_STD_VER > 14
1013 template <class _Tp>
1014 inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
1017 #endif // __has_keyword(__is_member_function_pointer)
1019 // is_member_pointer
1021 #if __has_keyword(__is_member_pointer)
1024 struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
1026 #if _LIBCPP_STD_VER > 14
1027 template <class _Tp>
1028 inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
1031 #else // __has_keyword(__is_member_pointer)
1033 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
1034 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
1036 #if _LIBCPP_STD_VER > 14
1037 template <class _Tp>
1038 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
1041 #endif // __has_keyword(__is_member_pointer)
1043 // is_member_object_pointer
1045 #if __has_keyword(__is_member_object_pointer)
1048 struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
1049 : _BoolConstant<__is_member_object_pointer(_Tp)> { };
1051 #if _LIBCPP_STD_VER > 14
1052 template <class _Tp>
1053 inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
1056 #else // __has_keyword(__is_member_object_pointer)
1058 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
1059 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
1061 #if _LIBCPP_STD_VER > 14
1062 template <class _Tp>
1063 inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
1066 #endif // __has_keyword(__is_member_object_pointer)
1070 #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
1072 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
1073 : public integral_constant<bool, __is_enum(_Tp)> {};
1075 #if _LIBCPP_STD_VER > 14
1076 template <class _Tp>
1077 inline constexpr bool is_enum_v = __is_enum(_Tp);
1082 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
1083 : public integral_constant<bool, !is_void<_Tp>::value &&
1084 !is_integral<_Tp>::value &&
1085 !is_floating_point<_Tp>::value &&
1086 !is_array<_Tp>::value &&
1087 !is_pointer<_Tp>::value &&
1088 !is_reference<_Tp>::value &&
1089 !is_member_pointer<_Tp>::value &&
1090 !is_union<_Tp>::value &&
1091 !is_class<_Tp>::value &&
1092 !is_function<_Tp>::value > {};
1094 #if _LIBCPP_STD_VER > 14
1095 template <class _Tp>
1096 inline constexpr bool is_enum_v = is_enum<_Tp>::value;
1099 #endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
1104 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
1105 : public integral_constant<bool, is_integral<_Tp>::value ||
1106 is_floating_point<_Tp>::value> {};
1108 #if _LIBCPP_STD_VER > 14
1109 template <class _Tp>
1110 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
1115 // Before Clang 10, __is_fundamental didn't work for nullptr_t.
1116 // In C++03 nullptr_t is library-provided but must still count as "fundamental."
1117 #if __has_keyword(__is_fundamental) && \
1118 !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) && \
1119 !defined(_LIBCPP_CXX03_LANG)
1122 struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
1124 #if _LIBCPP_STD_VER > 14
1125 template <class _Tp>
1126 inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
1129 #else // __has_keyword(__is_fundamental)
1131 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
1132 : public integral_constant<bool, is_void<_Tp>::value ||
1133 __is_nullptr_t<_Tp>::value ||
1134 is_arithmetic<_Tp>::value> {};
1136 #if _LIBCPP_STD_VER > 14
1137 template <class _Tp>
1138 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
1141 #endif // __has_keyword(__is_fundamental)
1145 // In C++03 nullptr_t is library-provided but must still count as "scalar."
1146 #if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG)
1149 struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
1151 #if _LIBCPP_STD_VER > 14
1152 template <class _Tp>
1153 inline constexpr bool is_scalar_v = __is_scalar(_Tp);
1156 #else // __has_keyword(__is_scalar)
1158 template <class _Tp> struct __is_block : false_type {};
1159 #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
1160 template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
1163 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1164 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1165 is_member_pointer<_Tp>::value ||
1166 is_pointer<_Tp>::value ||
1167 __is_nullptr_t<_Tp>::value ||
1168 __is_block<_Tp>::value ||
1169 is_enum<_Tp>::value > {};
1171 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1173 #if _LIBCPP_STD_VER > 14
1174 template <class _Tp>
1175 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
1178 #endif // __has_keyword(__is_scalar)
1182 #if __has_keyword(__is_object)
1185 struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
1187 #if _LIBCPP_STD_VER > 14
1188 template <class _Tp>
1189 inline constexpr bool is_object_v = __is_object(_Tp);
1192 #else // __has_keyword(__is_object)
1194 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1195 : public integral_constant<bool, is_scalar<_Tp>::value ||
1196 is_array<_Tp>::value ||
1197 is_union<_Tp>::value ||
1198 is_class<_Tp>::value > {};
1200 #if _LIBCPP_STD_VER > 14
1201 template <class _Tp>
1202 inline constexpr bool is_object_v = is_object<_Tp>::value;
1205 #endif // __has_keyword(__is_object)
1209 // >= 11 because in C++03 nullptr isn't actually nullptr
1210 #if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG)
1213 struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
1215 #if _LIBCPP_STD_VER > 14
1216 template <class _Tp>
1217 inline constexpr bool is_compound_v = __is_compound(_Tp);
1220 #else // __has_keyword(__is_compound)
1222 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1223 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1225 #if _LIBCPP_STD_VER > 14
1226 template <class _Tp>
1227 inline constexpr bool is_compound_v = is_compound<_Tp>::value;
1230 #endif // __has_keyword(__is_compound)
1232 // __is_referenceable [defns.referenceable]
1234 struct __is_referenceable_impl {
1235 template <class _Tp> static _Tp& __test(int);
1236 template <class _Tp> static __two __test(...);
1239 template <class _Tp>
1240 struct __is_referenceable : integral_constant<bool,
1241 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1246 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
1247 typedef _LIBCPP_NODEBUG const _Tp type;
1250 #if _LIBCPP_STD_VER > 11
1251 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1256 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
1257 typedef _LIBCPP_NODEBUG volatile _Tp type;
1260 #if _LIBCPP_STD_VER > 11
1261 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1265 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
1266 typedef _LIBCPP_NODEBUG const volatile _Tp type;
1269 #if _LIBCPP_STD_VER > 11
1270 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1275 #if __has_keyword(__remove_reference)
1278 struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) type; };
1280 #else // __has_keyword(__remove_reference)
1282 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
1283 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
1284 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
1286 #if _LIBCPP_STD_VER > 11
1287 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1290 #endif // __has_keyword(__remove_reference)
1292 // add_lvalue_reference
1294 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
1295 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
1297 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1298 {typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
1300 #if _LIBCPP_STD_VER > 11
1301 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1304 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
1305 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
1307 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1308 {typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
1310 #if _LIBCPP_STD_VER > 11
1311 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1314 // Suppress deprecation notice for volatile-qualified return type resulting
1315 // from volatile-qualified types _Tp.
1316 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1317 template <class _Tp> _Tp&& __declval(int);
1318 template <class _Tp> _Tp __declval(long);
1319 _LIBCPP_SUPPRESS_DEPRECATED_POP
1321 template <class _Tp>
1322 decltype(__declval<_Tp>(0))
1323 declval() _NOEXCEPT;
1327 template <class _Tp>
1329 typedef _LIBCPP_NODEBUG typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1332 template <class _Tp>
1333 struct __unconstref {
1334 typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
1337 #ifndef _LIBCPP_CXX03_LANG
1338 template <class _Tp>
1339 using __uncvref_t _LIBCPP_NODEBUG = typename __uncvref<_Tp>::type;
1342 // __is_same_uncvref
1344 template <class _Tp, class _Up>
1345 struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
1346 typename __uncvref<_Up>::type> {};
1348 #if _LIBCPP_STD_VER > 17
1349 // remove_cvref - same as __uncvref
1350 template <class _Tp>
1351 struct remove_cvref : public __uncvref<_Tp> {};
1353 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1364 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
1365 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
1366 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
1367 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
1368 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
1370 #if _LIBCPP_STD_VER > 11
1371 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1376 template <class _Tp,
1377 bool = __is_referenceable<_Tp>::value ||
1378 _IsSame<typename remove_cv<_Tp>::type, void>::value>
1379 struct __add_pointer_impl
1380 {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};
1381 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1382 {typedef _LIBCPP_NODEBUG _Tp type;};
1384 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1385 {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};
1387 #if _LIBCPP_STD_VER > 11
1388 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1392 #if _LIBCPP_STD_VER > 17
1393 template<class _Tp> struct type_identity { typedef _Tp type; };
1394 template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
1399 #if __has_keyword(__is_signed)
1402 struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
1404 #if _LIBCPP_STD_VER > 14
1405 template <class _Tp>
1406 inline constexpr bool is_signed_v = __is_signed(_Tp);
1409 #else // __has_keyword(__is_signed)
1411 template <class _Tp, bool = is_integral<_Tp>::value>
1412 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1414 template <class _Tp>
1415 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1417 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1418 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1420 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1422 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1424 #if _LIBCPP_STD_VER > 14
1425 template <class _Tp>
1426 inline constexpr bool is_signed_v = is_signed<_Tp>::value;
1429 #endif // __has_keyword(__is_signed)
1433 // Before Clang 13, __is_unsigned returned true for enums with signed underlying type.
1434 // No currently-released version of AppleClang contains the fixed intrinsic.
1435 #if __has_keyword(__is_unsigned) && \
1436 !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1300) && \
1437 !defined(_LIBCPP_APPLE_CLANG_VER)
1440 struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
1442 #if _LIBCPP_STD_VER > 14
1443 template <class _Tp>
1444 inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
1447 #else // __has_keyword(__is_unsigned)
1449 template <class _Tp, bool = is_integral<_Tp>::value>
1450 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1452 template <class _Tp>
1453 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1455 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1456 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1458 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1460 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1462 #if _LIBCPP_STD_VER > 14
1463 template <class _Tp>
1464 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
1467 #endif // __has_keyword(__is_unsigned)
1471 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1472 : public integral_constant<size_t, 0> {};
1473 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1474 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1475 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1476 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1478 #if _LIBCPP_STD_VER > 14
1479 template <class _Tp>
1480 inline constexpr size_t rank_v = rank<_Tp>::value;
1485 #if __has_keyword(__array_extent)
1487 template<class _Tp, size_t _Dim = 0>
1488 struct _LIBCPP_TEMPLATE_VIS extent
1489 : integral_constant<size_t, __array_extent(_Tp, _Dim)> { };
1491 #if _LIBCPP_STD_VER > 14
1492 template <class _Tp, unsigned _Ip = 0>
1493 inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
1496 #else // __has_keyword(__array_extent)
1498 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1499 : public integral_constant<size_t, 0> {};
1500 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1501 : public integral_constant<size_t, 0> {};
1502 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1503 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1504 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1505 : public integral_constant<size_t, _Np> {};
1506 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1507 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1509 #if _LIBCPP_STD_VER > 14
1510 template <class _Tp, unsigned _Ip = 0>
1511 inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
1514 #endif // __has_keyword(__array_extent)
1518 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1519 {typedef _Tp type;};
1520 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1521 {typedef _Tp type;};
1522 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1523 {typedef _Tp type;};
1525 #if _LIBCPP_STD_VER > 11
1526 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1529 // remove_all_extents
1531 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1532 {typedef _Tp type;};
1533 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1534 {typedef typename remove_all_extents<_Tp>::type type;};
1535 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1536 {typedef typename remove_all_extents<_Tp>::type type;};
1538 #if _LIBCPP_STD_VER > 11
1539 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1542 #if _LIBCPP_STD_VER > 17
1545 template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
1546 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
1548 template <class _Tp>
1550 bool is_bounded_array_v = is_bounded_array<_Tp>::value;
1552 // is_unbounded_array
1554 template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
1555 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
1557 template <class _Tp>
1559 bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
1564 template <class _Up, bool>
1566 typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
1569 template <class _Up>
1570 struct __decay<_Up, true> {
1572 typedef _LIBCPP_NODEBUG typename conditional
1574 is_array<_Up>::value,
1575 typename remove_extent<_Up>::type*,
1576 typename conditional
1578 is_function<_Up>::value,
1579 typename add_pointer<_Up>::type,
1580 typename remove_cv<_Up>::type
1585 template <class _Tp>
1586 struct _LIBCPP_TEMPLATE_VIS decay
1589 typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
1591 typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1594 #if _LIBCPP_STD_VER > 11
1595 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1600 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1601 : public integral_constant<bool, __is_abstract(_Tp)> {};
1603 #if _LIBCPP_STD_VER > 14
1604 template <class _Tp>
1605 inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
1610 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1611 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1613 #if _LIBCPP_STD_VER > 11
1614 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1615 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1618 #if _LIBCPP_STD_VER > 14
1619 template <class _Tp>
1620 inline constexpr bool is_final_v = is_final<_Tp>::value;
1624 #if _LIBCPP_STD_VER > 14
1626 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1627 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1629 template <class _Tp>
1630 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
1632 #endif // _LIBCPP_STD_VER > 14
1636 template <class _Bp, class _Dp>
1637 struct _LIBCPP_TEMPLATE_VIS is_base_of
1638 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1640 #if _LIBCPP_STD_VER > 14
1641 template <class _Bp, class _Dp>
1642 inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value;
1645 // __is_core_convertible
1647 // [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
1648 // We can't test for that, but we can test implicit convertibility by passing it
1649 // to a function. Notice that __is_core_convertible<void,void> is false,
1650 // and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
1652 template <class _Tp, class _Up, class = void>
1653 struct __is_core_convertible : public false_type {};
1655 template <class _Tp, class _Up>
1656 struct __is_core_convertible<_Tp, _Up, decltype(
1657 static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
1658 )> : public true_type {};
1662 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1664 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1665 : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
1667 #else // __has_feature(is_convertible_to)
1669 namespace __is_convertible_imp
1671 template <class _Tp> void __test_convert(_Tp);
1673 template <class _From, class _To, class = void>
1674 struct __is_convertible_test : public false_type {};
1676 template <class _From, class _To>
1677 struct __is_convertible_test<_From, _To,
1678 decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
1681 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1682 bool _IsFunction = is_function<_Tp>::value,
1683 bool _IsVoid = is_void<_Tp>::value>
1684 struct __is_array_function_or_void {enum {value = 0};};
1685 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1686 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1687 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1690 template <class _Tp,
1691 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1692 struct __is_convertible_check
1694 static const size_t __v = 0;
1697 template <class _Tp>
1698 struct __is_convertible_check<_Tp, 0>
1700 static const size_t __v = sizeof(_Tp);
1703 template <class _T1, class _T2,
1704 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1705 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1706 struct __is_convertible
1707 : public integral_constant<bool,
1708 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1712 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1713 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1714 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1715 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1717 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1718 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1719 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1720 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1722 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1723 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1724 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1725 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1727 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1728 : public __is_convertible<_T1, _T2>
1730 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1731 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1734 #endif // __has_feature(is_convertible_to)
1736 #if _LIBCPP_STD_VER > 14
1737 template <class _From, class _To>
1738 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
1741 // is_nothrow_convertible
1743 #if _LIBCPP_STD_VER > 17
1745 template <typename _Tp>
1746 static void __test_noexcept(_Tp) noexcept;
1748 template<typename _Fm, typename _To>
1749 static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
1750 __is_nothrow_convertible_test();
1752 template <typename _Fm, typename _To>
1753 struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
1756 template <typename _Fm, typename _To>
1757 struct is_nothrow_convertible : _Or<
1758 _And<is_void<_To>, is_void<_Fm>>,
1759 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
1762 template <typename _Fm, typename _To>
1763 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
1765 #endif // _LIBCPP_STD_VER > 17
1769 #if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
1771 template <class _Tp>
1772 struct _LIBCPP_TEMPLATE_VIS is_empty
1773 : public integral_constant<bool, __is_empty(_Tp)> {};
1775 #else // __has_feature(is_empty)
1777 template <class _Tp>
1789 template <class _Tp, bool = is_class<_Tp>::value>
1790 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1792 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1794 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1796 #endif // __has_feature(is_empty)
1798 #if _LIBCPP_STD_VER > 14
1799 template <class _Tp>
1800 inline constexpr bool is_empty_v = is_empty<_Tp>::value;
1805 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1807 template <class _Tp>
1808 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1809 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1813 template<typename _Tp> char &__is_polymorphic_impl(
1814 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1816 template<typename _Tp> __two &__is_polymorphic_impl(...);
1818 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1819 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1821 #endif // __has_feature(is_polymorphic)
1823 #if _LIBCPP_STD_VER > 14
1824 template <class _Tp>
1825 inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
1828 // has_virtual_destructor
1830 #if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
1832 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1833 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1837 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1838 : public false_type {};
1842 #if _LIBCPP_STD_VER > 14
1843 template <class _Tp>
1844 inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
1847 // has_unique_object_representations
1849 #if _LIBCPP_STD_VER > 14
1851 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1852 : public integral_constant<bool,
1853 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1855 template <class _Tp>
1856 inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
1862 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1863 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
1865 #if _LIBCPP_STD_VER > 14
1866 template <class _Tp>
1867 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
1872 template <class _Hp, class _Tp>
1881 #ifndef _LIBCPP_CXX03_LANG
1883 __nat(const __nat&) = delete;
1884 __nat& operator=(const __nat&) = delete;
1889 template <class _Tp>
1892 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
1896 struct __struct_double {long double __lx;};
1897 struct __struct_double4 {double __lx[4];};
1900 __type_list<__align_type<unsigned char>,
1901 __type_list<__align_type<unsigned short>,
1902 __type_list<__align_type<unsigned int>,
1903 __type_list<__align_type<unsigned long>,
1904 __type_list<__align_type<unsigned long long>,
1905 __type_list<__align_type<double>,
1906 __type_list<__align_type<long double>,
1907 __type_list<__align_type<__struct_double>,
1908 __type_list<__align_type<__struct_double4>,
1909 __type_list<__align_type<int*>,
1911 > > > > > > > > > > __all_types;
1913 template <size_t _Align>
1914 struct _ALIGNAS(_Align) __fallback_overaligned {};
1916 template <class _TL, size_t _Align> struct __find_pod;
1918 template <class _Hp, size_t _Align>
1919 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1921 typedef typename conditional<
1922 _Align == _Hp::value,
1924 __fallback_overaligned<_Align>
1928 template <class _Hp, class _Tp, size_t _Align>
1929 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1931 typedef typename conditional<
1932 _Align == _Hp::value,
1934 typename __find_pod<_Tp, _Align>::type
1938 template <class _TL, size_t _Len> struct __find_max_align;
1940 template <class _Hp, size_t _Len>
1941 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1943 template <size_t _Len, size_t _A1, size_t _A2>
1944 struct __select_align
1947 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1948 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1950 static const size_t value = _Len < __max ? __min : __max;
1953 template <class _Hp, class _Tp, size_t _Len>
1954 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1955 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1957 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1958 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1960 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1964 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1968 #if _LIBCPP_STD_VER > 11
1969 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1970 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1973 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1974 template <size_t _Len>\
1975 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1977 struct _ALIGNAS(n) type\
1979 unsigned char __lx[(_Len + n - 1)/n * n];\
1983 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1984 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1985 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1986 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1987 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1988 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1989 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1990 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1991 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1992 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1993 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1994 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1995 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1996 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1997 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1998 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1999 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
2000 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
2002 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
2007 template <size_t _I0, size_t ..._In>
2008 struct __static_max;
2010 template <size_t _I0>
2011 struct __static_max<_I0>
2013 static const size_t value = _I0;
2016 template <size_t _I0, size_t _I1, size_t ..._In>
2017 struct __static_max<_I0, _I1, _In...>
2019 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
2020 __static_max<_I1, _In...>::value;
2023 template <size_t _Len, class _Type0, class ..._Types>
2024 struct aligned_union
2026 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
2027 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
2028 static const size_t __len = __static_max<_Len, sizeof(_Type0),
2029 sizeof(_Types)...>::value;
2030 typedef typename aligned_storage<__len, alignment_value>::type type;
2033 #if _LIBCPP_STD_VER > 11
2034 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2037 template <class _Tp>
2038 struct __numeric_type
2040 static void __test(...);
2041 static float __test(float);
2042 static double __test(char);
2043 static double __test(int);
2044 static double __test(unsigned);
2045 static double __test(long);
2046 static double __test(unsigned long);
2047 static double __test(long long);
2048 static double __test(unsigned long long);
2049 static double __test(double);
2050 static long double __test(long double);
2052 typedef decltype(__test(declval<_Tp>())) type;
2053 static const bool value = _IsNotSame<type, void>::value;
2057 struct __numeric_type<void>
2059 static const bool value = true;
2064 template <class _A1, class _A2 = void, class _A3 = void,
2065 bool = __numeric_type<_A1>::value &&
2066 __numeric_type<_A2>::value &&
2067 __numeric_type<_A3>::value>
2071 static const bool value = false;
2074 template <class _A1, class _A2, class _A3>
2075 class __promote_imp<_A1, _A2, _A3, true>
2078 typedef typename __promote_imp<_A1>::type __type1;
2079 typedef typename __promote_imp<_A2>::type __type2;
2080 typedef typename __promote_imp<_A3>::type __type3;
2082 typedef decltype(__type1() + __type2() + __type3()) type;
2083 static const bool value = true;
2086 template <class _A1, class _A2>
2087 class __promote_imp<_A1, _A2, void, true>
2090 typedef typename __promote_imp<_A1>::type __type1;
2091 typedef typename __promote_imp<_A2>::type __type2;
2093 typedef decltype(__type1() + __type2()) type;
2094 static const bool value = true;
2097 template <class _A1>
2098 class __promote_imp<_A1, void, void, true>
2101 typedef typename __numeric_type<_A1>::type type;
2102 static const bool value = true;
2105 template <class _A1, class _A2 = void, class _A3 = void>
2106 class __promote : public __promote_imp<_A1, _A2, _A3> {};
2108 // make_signed / make_unsigned
2111 __type_list<signed char,
2112 __type_list<signed short,
2113 __type_list<signed int,
2114 __type_list<signed long,
2115 __type_list<signed long long,
2116 #ifndef _LIBCPP_HAS_NO_INT128
2117 __type_list<__int128_t,
2120 #ifndef _LIBCPP_HAS_NO_INT128
2123 > > > > > __signed_types;
2126 __type_list<unsigned char,
2127 __type_list<unsigned short,
2128 __type_list<unsigned int,
2129 __type_list<unsigned long,
2130 __type_list<unsigned long long,
2131 #ifndef _LIBCPP_HAS_NO_INT128
2132 __type_list<__uint128_t,
2135 #ifndef _LIBCPP_HAS_NO_INT128
2138 > > > > > __unsigned_types;
2140 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
2142 template <class _Hp, class _Tp, size_t _Size>
2143 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
2145 typedef _LIBCPP_NODEBUG _Hp type;
2148 template <class _Hp, class _Tp, size_t _Size>
2149 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
2151 typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
2154 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
2155 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
2158 typedef _LIBCPP_NODEBUG _Up type;
2161 template <class _Tp, class _Up>
2162 struct __apply_cv<_Tp, _Up, true, false>
2164 typedef _LIBCPP_NODEBUG const _Up type;
2167 template <class _Tp, class _Up>
2168 struct __apply_cv<_Tp, _Up, false, true>
2170 typedef volatile _Up type;
2173 template <class _Tp, class _Up>
2174 struct __apply_cv<_Tp, _Up, true, true>
2176 typedef const volatile _Up type;
2179 template <class _Tp, class _Up>
2180 struct __apply_cv<_Tp&, _Up, false, false>
2185 template <class _Tp, class _Up>
2186 struct __apply_cv<_Tp&, _Up, true, false>
2188 typedef const _Up& type;
2191 template <class _Tp, class _Up>
2192 struct __apply_cv<_Tp&, _Up, false, true>
2194 typedef volatile _Up& type;
2197 template <class _Tp, class _Up>
2198 struct __apply_cv<_Tp&, _Up, true, true>
2200 typedef const volatile _Up& type;
2203 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2204 struct __make_signed {};
2206 template <class _Tp>
2207 struct __make_signed<_Tp, true>
2209 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
2212 template <> struct __make_signed<bool, true> {};
2213 template <> struct __make_signed< signed short, true> {typedef short type;};
2214 template <> struct __make_signed<unsigned short, true> {typedef short type;};
2215 template <> struct __make_signed< signed int, true> {typedef int type;};
2216 template <> struct __make_signed<unsigned int, true> {typedef int type;};
2217 template <> struct __make_signed< signed long, true> {typedef long type;};
2218 template <> struct __make_signed<unsigned long, true> {typedef long type;};
2219 template <> struct __make_signed< signed long long, true> {typedef long long type;};
2220 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2221 #ifndef _LIBCPP_HAS_NO_INT128
2222 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2223 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2226 template <class _Tp>
2227 struct _LIBCPP_TEMPLATE_VIS make_signed
2229 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2232 #if _LIBCPP_STD_VER > 11
2233 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2236 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2237 struct __make_unsigned {};
2239 template <class _Tp>
2240 struct __make_unsigned<_Tp, true>
2242 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2245 template <> struct __make_unsigned<bool, true> {};
2246 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2247 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2248 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2249 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2250 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2251 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2252 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2253 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2254 #ifndef _LIBCPP_HAS_NO_INT128
2255 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2256 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2259 template <class _Tp>
2260 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2262 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2265 #if _LIBCPP_STD_VER > 11
2266 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2269 #ifndef _LIBCPP_CXX03_LANG
2270 template <class _Tp>
2271 _LIBCPP_HIDE_FROM_ABI constexpr
2272 typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
2273 return static_cast<typename make_unsigned<_Tp>::type>(__x);
2277 #if _LIBCPP_STD_VER > 14
2278 template <class...> using void_t = void;
2281 #if _LIBCPP_STD_VER > 17
2282 // Let COND_RES(X, Y) be:
2283 template <class _Tp, class _Up>
2284 using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
2286 template <class _Tp, class _Up, class = void>
2287 struct __common_type3 {};
2289 // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
2290 template <class _Tp, class _Up>
2291 struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
2293 using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
2296 template <class _Tp, class _Up, class = void>
2297 struct __common_type2_imp : __common_type3<_Tp, _Up> {};
2299 template <class _Tp, class _Up, class = void>
2300 struct __common_type2_imp {};
2303 // sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
2304 template <class _Tp, class _Up>
2305 struct __common_type2_imp<_Tp, _Up,
2306 typename __void_t<decltype(
2307 true ? declval<_Tp>() : declval<_Up>()
2310 typedef _LIBCPP_NODEBUG typename decay<decltype(
2311 true ? declval<_Tp>() : declval<_Up>()
2315 template <class, class = void>
2316 struct __common_type_impl {};
2318 // Clang provides variadic templates in C++03 as an extension.
2319 #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
2320 # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
2321 template <class... _Tp>
2322 struct __common_types;
2323 template <class... _Tp>
2324 struct _LIBCPP_TEMPLATE_VIS common_type;
2326 # define _LIBCPP_OPTIONAL_PACK(...)
2328 template <class _Tp, class _Up, class = __no_arg>
2329 struct __common_types;
2330 template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
2331 class _Unused = __no_arg>
2332 struct common_type {
2333 static_assert(sizeof(_Unused) == 0,
2334 "common_type accepts at most 3 arguments in C++03");
2336 #endif // _LIBCPP_CXX03_LANG
2338 template <class _Tp, class _Up>
2339 struct __common_type_impl<
2340 __common_types<_Tp, _Up>,
2341 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2343 typedef typename common_type<_Tp, _Up>::type type;
2346 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2347 struct __common_type_impl<
2348 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
2349 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2350 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
2351 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
2354 // bullet 1 - sizeof...(Tp) == 0
2357 struct _LIBCPP_TEMPLATE_VIS common_type<> {};
2359 // bullet 2 - sizeof...(Tp) == 1
2361 template <class _Tp>
2362 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2363 : public common_type<_Tp, _Tp> {};
2365 // bullet 3 - sizeof...(Tp) == 2
2367 // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
2368 template <class _Tp, class _Up>
2369 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2371 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
2372 __common_type2_imp<_Tp, _Up>,
2373 common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
2377 // bullet 4 - sizeof...(Tp) > 2
2379 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2380 struct _LIBCPP_TEMPLATE_VIS
2381 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
2382 : __common_type_impl<
2383 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
2385 #undef _LIBCPP_OPTIONAL_PACK
2387 #if _LIBCPP_STD_VER > 11
2388 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2391 #if _LIBCPP_STD_VER > 11
2392 // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
2393 // top-level cv-qualifiers.
2394 template <class _From, class _To>
2400 template <class _From, class _To>
2401 struct __copy_cv<const _From, _To>
2403 using type = add_const_t<_To>;
2406 template <class _From, class _To>
2407 struct __copy_cv<volatile _From, _To>
2409 using type = add_volatile_t<_To>;
2412 template <class _From, class _To>
2413 struct __copy_cv<const volatile _From, _To>
2415 using type = add_cv_t<_To>;
2418 template <class _From, class _To>
2419 using __copy_cv_t = typename __copy_cv<_From, _To>::type;
2421 template <class _From, class _To>
2424 using type = __copy_cv_t<_From, _To>;
2427 template <class _From, class _To>
2428 struct __copy_cvref<_From&, _To>
2430 using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>;
2433 template <class _From, class _To>
2434 struct __copy_cvref<_From&&, _To>
2436 using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>;
2439 template <class _From, class _To>
2440 using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
2442 #endif // _LIBCPP_STD_VER > 11
2445 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
2446 // Let COND_RES(X, Y) be:
2447 template <class _Xp, class _Yp>
2449 decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
2451 // Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
2452 // with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
2454 // [Note: `XREF(A)` is `__xref<A>::template __apply`]
2455 template <class _Tp>
2458 using __apply = __copy_cvref_t<_Tp, _Up>;
2461 // Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
2462 // and let COMMON-REF(A, B) be:
2463 template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
2464 struct __common_ref;
2466 template<class _Xp, class _Yp>
2467 using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
2469 template<class _Xp, class _Yp>
2470 using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
2473 // If A and B are both lvalue reference types, COMMON-REF(A, B) is
2474 // COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
2475 template<class _Ap, class _Bp, class _Xp, class _Yp>
2476 requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
2477 struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
2479 using __type = __cv_cond_res<_Xp, _Yp>;
2482 // Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
2483 template <class _Xp, class _Yp>
2484 using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
2487 // .... If A and B are both rvalue reference types, C is well-formed, and
2488 // is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
2489 template<class _Ap, class _Bp, class _Xp, class _Yp>
2491 requires { typename __common_ref_C<_Xp, _Yp>; } &&
2492 is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
2493 is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
2494 struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
2496 using __type = __common_ref_C<_Xp, _Yp>;
2499 // Otherwise, let D be COMMON-REF(const X&, Y&). ...
2500 template <class _Tp, class _Up>
2501 using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
2503 // ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
2504 // is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
2505 template<class _Ap, class _Bp, class _Xp, class _Yp>
2506 requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
2507 is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
2508 struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
2510 using __type = __common_ref_D<_Xp, _Yp>;
2513 // Otherwise, if A is an lvalue reference and B is an rvalue reference, then
2514 // COMMON-REF(A, B) is COMMON-REF(B, A).
2515 template<class _Ap, class _Bp, class _Xp, class _Yp>
2516 struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
2518 // Otherwise, COMMON-REF(A, B) is ill-formed.
2519 template<class _Ap, class _Bp, class _Xp, class _Yp>
2520 struct __common_ref {};
2522 // Note C: For the common_reference trait applied to a parameter pack [...]
2525 struct common_reference;
2527 template <class... _Types>
2528 using common_reference_t = typename common_reference<_Types...>::type;
2530 // bullet 1 - sizeof...(T) == 0
2532 struct common_reference<> {};
2534 // bullet 2 - sizeof...(T) == 1
2535 template <class _Tp>
2536 struct common_reference<_Tp>
2541 // bullet 3 - sizeof...(T) == 2
2542 template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
2543 template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
2544 template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
2546 // sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
2547 // the member typedef `type` denotes that type.
2548 template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
2550 template <class _Tp, class _Up>
2551 requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
2552 struct __common_reference_sub_bullet1<_Tp, _Up>
2554 using type = __common_ref_t<_Tp, _Up>;
2557 // sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
2558 // is well-formed, then the member typedef `type` denotes that type.
2559 template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
2561 template <class _Tp, class _Up>
2562 using __basic_common_reference_t = typename basic_common_reference<
2563 remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
2564 __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
2566 template <class _Tp, class _Up>
2567 requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
2568 struct __common_reference_sub_bullet2<_Tp, _Up>
2570 using type = __basic_common_reference_t<_Tp, _Up>;
2573 // sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
2574 // then the member typedef `type` denotes that type.
2575 template <class _Tp, class _Up>
2576 requires requires { typename __cond_res<_Tp, _Up>; }
2577 struct __common_reference_sub_bullet3<_Tp, _Up>
2579 using type = __cond_res<_Tp, _Up>;
2583 // sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
2584 // then the member typedef `type` denotes that type.
2585 // - Otherwise, there shall be no member `type`.
2586 template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
2588 // bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
2589 // any, as `common_reference_t<C, Rest...>`.
2590 template <class _Tp, class _Up, class _Vp, class... _Rest>
2591 requires requires { typename common_reference_t<_Tp, _Up>; }
2592 struct common_reference<_Tp, _Up, _Vp, _Rest...>
2593 : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
2596 // bullet 5 - Otherwise, there shall be no member `type`.
2597 template <class...> struct common_reference {};
2599 #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
2603 template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
2605 #if __has_keyword(__is_assignable)
2607 template<class _Tp, class _Up>
2608 struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
2610 #if _LIBCPP_STD_VER > 14
2611 template <class _Tp, class _Arg>
2612 inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
2615 #else // __has_keyword(__is_assignable)
2617 template <class _Tp, class _Arg>
2618 typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
2619 __is_assignable_test(int);
2621 template <class, class>
2622 false_type __is_assignable_test(...);
2625 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2626 struct __is_assignable_imp
2627 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2629 template <class _Tp, class _Arg>
2630 struct __is_assignable_imp<_Tp, _Arg, true>
2635 template <class _Tp, class _Arg>
2636 struct is_assignable
2637 : public __is_assignable_imp<_Tp, _Arg> {};
2639 #if _LIBCPP_STD_VER > 14
2640 template <class _Tp, class _Arg>
2641 inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
2644 #endif // __has_keyword(__is_assignable)
2646 // is_copy_assignable
2648 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2649 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2650 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2652 #if _LIBCPP_STD_VER > 14
2653 template <class _Tp>
2654 inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
2657 // is_move_assignable
2659 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2660 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2661 typename add_rvalue_reference<_Tp>::type> {};
2663 #if _LIBCPP_STD_VER > 14
2664 template <class _Tp>
2665 inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
2670 #if __has_keyword(__is_destructible)
2673 struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
2675 #if _LIBCPP_STD_VER > 14
2676 template <class _Tp>
2677 inline constexpr bool is_destructible_v = __is_destructible(_Tp);
2680 #else // __has_keyword(__is_destructible)
2682 // if it's a reference, return true
2683 // if it's a function, return false
2684 // if it's void, return false
2685 // if it's an array of unknown bound, return false
2686 // Otherwise, return "declval<_Up&>().~_Up()" is well-formed
2687 // where _Up is remove_all_extents<_Tp>::type
2690 struct __is_destructible_apply { typedef int type; };
2692 template <typename _Tp>
2693 struct __is_destructor_wellformed {
2694 template <typename _Tp1>
2695 static char __test (
2696 typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
2699 template <typename _Tp1>
2700 static __two __test (...);
2702 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2705 template <class _Tp, bool>
2706 struct __destructible_imp;
2708 template <class _Tp>
2709 struct __destructible_imp<_Tp, false>
2710 : public integral_constant<bool,
2711 __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
2713 template <class _Tp>
2714 struct __destructible_imp<_Tp, true>
2715 : public true_type {};
2717 template <class _Tp, bool>
2718 struct __destructible_false;
2720 template <class _Tp>
2721 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
2723 template <class _Tp>
2724 struct __destructible_false<_Tp, true> : public false_type {};
2726 template <class _Tp>
2727 struct is_destructible
2728 : public __destructible_false<_Tp, is_function<_Tp>::value> {};
2730 template <class _Tp>
2731 struct is_destructible<_Tp[]>
2732 : public false_type {};
2735 struct is_destructible<void>
2736 : public false_type {};
2738 #if _LIBCPP_STD_VER > 14
2739 template <class _Tp>
2740 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
2743 #endif // __has_keyword(__is_destructible)
2745 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
2746 struct __member_pointer_traits_imp
2750 template <class _Rp, class _Class, class ..._Param>
2751 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2753 typedef _Class _ClassType;
2754 typedef _Rp _ReturnType;
2755 typedef _Rp (_FnType) (_Param...);
2758 template <class _Rp, class _Class, class ..._Param>
2759 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2761 typedef _Class _ClassType;
2762 typedef _Rp _ReturnType;
2763 typedef _Rp (_FnType) (_Param..., ...);
2766 template <class _Rp, class _Class, class ..._Param>
2767 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2769 typedef _Class const _ClassType;
2770 typedef _Rp _ReturnType;
2771 typedef _Rp (_FnType) (_Param...);
2774 template <class _Rp, class _Class, class ..._Param>
2775 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2777 typedef _Class const _ClassType;
2778 typedef _Rp _ReturnType;
2779 typedef _Rp (_FnType) (_Param..., ...);
2782 template <class _Rp, class _Class, class ..._Param>
2783 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2785 typedef _Class volatile _ClassType;
2786 typedef _Rp _ReturnType;
2787 typedef _Rp (_FnType) (_Param...);
2790 template <class _Rp, class _Class, class ..._Param>
2791 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2793 typedef _Class volatile _ClassType;
2794 typedef _Rp _ReturnType;
2795 typedef _Rp (_FnType) (_Param..., ...);
2798 template <class _Rp, class _Class, class ..._Param>
2799 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2801 typedef _Class const volatile _ClassType;
2802 typedef _Rp _ReturnType;
2803 typedef _Rp (_FnType) (_Param...);
2806 template <class _Rp, class _Class, class ..._Param>
2807 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2809 typedef _Class const volatile _ClassType;
2810 typedef _Rp _ReturnType;
2811 typedef _Rp (_FnType) (_Param..., ...);
2814 #if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2816 template <class _Rp, class _Class, class ..._Param>
2817 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2819 typedef _Class& _ClassType;
2820 typedef _Rp _ReturnType;
2821 typedef _Rp (_FnType) (_Param...);
2824 template <class _Rp, class _Class, class ..._Param>
2825 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2827 typedef _Class& _ClassType;
2828 typedef _Rp _ReturnType;
2829 typedef _Rp (_FnType) (_Param..., ...);
2832 template <class _Rp, class _Class, class ..._Param>
2833 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2835 typedef _Class const& _ClassType;
2836 typedef _Rp _ReturnType;
2837 typedef _Rp (_FnType) (_Param...);
2840 template <class _Rp, class _Class, class ..._Param>
2841 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2843 typedef _Class const& _ClassType;
2844 typedef _Rp _ReturnType;
2845 typedef _Rp (_FnType) (_Param..., ...);
2848 template <class _Rp, class _Class, class ..._Param>
2849 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2851 typedef _Class volatile& _ClassType;
2852 typedef _Rp _ReturnType;
2853 typedef _Rp (_FnType) (_Param...);
2856 template <class _Rp, class _Class, class ..._Param>
2857 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2859 typedef _Class volatile& _ClassType;
2860 typedef _Rp _ReturnType;
2861 typedef _Rp (_FnType) (_Param..., ...);
2864 template <class _Rp, class _Class, class ..._Param>
2865 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2867 typedef _Class const volatile& _ClassType;
2868 typedef _Rp _ReturnType;
2869 typedef _Rp (_FnType) (_Param...);
2872 template <class _Rp, class _Class, class ..._Param>
2873 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2875 typedef _Class const volatile& _ClassType;
2876 typedef _Rp _ReturnType;
2877 typedef _Rp (_FnType) (_Param..., ...);
2880 template <class _Rp, class _Class, class ..._Param>
2881 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2883 typedef _Class&& _ClassType;
2884 typedef _Rp _ReturnType;
2885 typedef _Rp (_FnType) (_Param...);
2888 template <class _Rp, class _Class, class ..._Param>
2889 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2891 typedef _Class&& _ClassType;
2892 typedef _Rp _ReturnType;
2893 typedef _Rp (_FnType) (_Param..., ...);
2896 template <class _Rp, class _Class, class ..._Param>
2897 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2899 typedef _Class const&& _ClassType;
2900 typedef _Rp _ReturnType;
2901 typedef _Rp (_FnType) (_Param...);
2904 template <class _Rp, class _Class, class ..._Param>
2905 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2907 typedef _Class const&& _ClassType;
2908 typedef _Rp _ReturnType;
2909 typedef _Rp (_FnType) (_Param..., ...);
2912 template <class _Rp, class _Class, class ..._Param>
2913 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2915 typedef _Class volatile&& _ClassType;
2916 typedef _Rp _ReturnType;
2917 typedef _Rp (_FnType) (_Param...);
2920 template <class _Rp, class _Class, class ..._Param>
2921 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2923 typedef _Class volatile&& _ClassType;
2924 typedef _Rp _ReturnType;
2925 typedef _Rp (_FnType) (_Param..., ...);
2928 template <class _Rp, class _Class, class ..._Param>
2929 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2931 typedef _Class const volatile&& _ClassType;
2932 typedef _Rp _ReturnType;
2933 typedef _Rp (_FnType) (_Param...);
2936 template <class _Rp, class _Class, class ..._Param>
2937 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2939 typedef _Class const volatile&& _ClassType;
2940 typedef _Rp _ReturnType;
2941 typedef _Rp (_FnType) (_Param..., ...);
2944 #endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2947 template <class _Rp, class _Class>
2948 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2950 typedef _Class _ClassType;
2951 typedef _Rp _ReturnType;
2954 template <class _MP>
2955 struct __member_pointer_traits
2956 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2957 is_member_function_pointer<_MP>::value,
2958 is_member_object_pointer<_MP>::value>
2960 // typedef ... _ClassType;
2961 // typedef ... _ReturnType;
2962 // typedef ... _FnType;
2966 template <class _DecayedFp>
2967 struct __member_pointer_class_type {};
2969 template <class _Ret, class _ClassType>
2970 struct __member_pointer_class_type<_Ret _ClassType::*> {
2971 typedef _ClassType type;
2974 // template <class T, class... Args> struct is_constructible;
2976 template <class _Tp, class ..._Args>
2977 struct _LIBCPP_TEMPLATE_VIS is_constructible
2978 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2981 #if _LIBCPP_STD_VER > 14
2982 template <class _Tp, class ..._Args>
2983 inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
2986 // is_default_constructible
2988 template <class _Tp>
2989 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
2990 : public is_constructible<_Tp>
2993 #if _LIBCPP_STD_VER > 14
2994 template <class _Tp>
2995 inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
2998 #ifndef _LIBCPP_CXX03_LANG
2999 // First of all, we can't implement this check in C++03 mode because the {}
3000 // default initialization syntax isn't valid.
3001 // Second, we implement the trait in a funny manner with two defaulted template
3002 // arguments to workaround Clang's PR43454.
3003 template <class _Tp>
3004 void __test_implicit_default_constructible(_Tp);
3006 template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
3007 struct __is_implicitly_default_constructible
3011 template <class _Tp>
3012 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
3016 template <class _Tp>
3017 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
3022 // is_copy_constructible
3024 template <class _Tp>
3025 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3026 : public is_constructible<_Tp,
3027 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3029 #if _LIBCPP_STD_VER > 14
3030 template <class _Tp>
3031 inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
3034 // is_move_constructible
3036 template <class _Tp>
3037 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3038 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3041 #if _LIBCPP_STD_VER > 14
3042 template <class _Tp>
3043 inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
3046 // is_trivially_constructible
3048 template <class _Tp, class... _Args>
3049 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3050 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3054 #if _LIBCPP_STD_VER > 14
3055 template <class _Tp, class... _Args>
3056 inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
3059 // is_trivially_default_constructible
3061 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3062 : public is_trivially_constructible<_Tp>
3065 #if _LIBCPP_STD_VER > 14
3066 template <class _Tp>
3067 inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
3070 // is_trivially_copy_constructible
3072 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3073 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3076 #if _LIBCPP_STD_VER > 14
3077 template <class _Tp>
3078 inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
3081 // is_trivially_move_constructible
3083 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3084 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3087 #if _LIBCPP_STD_VER > 14
3088 template <class _Tp>
3089 inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
3092 // is_trivially_assignable
3094 template <class _Tp, class _Arg>
3095 struct is_trivially_assignable
3096 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3099 #if _LIBCPP_STD_VER > 14
3100 template <class _Tp, class _Arg>
3101 inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
3104 // is_trivially_copy_assignable
3106 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3107 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3108 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3110 #if _LIBCPP_STD_VER > 14
3111 template <class _Tp>
3112 inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
3115 // is_trivially_move_assignable
3117 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3118 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3119 typename add_rvalue_reference<_Tp>::type>
3122 #if _LIBCPP_STD_VER > 14
3123 template <class _Tp>
3124 inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
3127 // is_trivially_destructible
3129 #if __has_keyword(__is_trivially_destructible)
3131 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3132 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
3134 #elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
3136 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3137 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3141 template <class _Tp> struct __libcpp_trivial_destructor
3142 : public integral_constant<bool, is_scalar<_Tp>::value ||
3143 is_reference<_Tp>::value> {};
3145 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3146 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3148 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3149 : public false_type {};
3153 #if _LIBCPP_STD_VER > 14
3154 template <class _Tp>
3155 inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
3158 // is_nothrow_constructible
3160 #if __has_keyword(__is_nothrow_constructible)
3162 template <class _Tp, class... _Args>
3163 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3164 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
3168 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3170 template <class _Tp, class... _Args>
3171 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3172 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3176 template <class _Tp>
3177 void __implicit_conversion_to(_Tp) noexcept { }
3179 template <class _Tp, class _Arg>
3180 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3181 : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3185 template <class _Tp, bool _IsReference, class... _Args>
3186 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3191 template <class _Tp, class... _Args>
3192 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3193 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3197 template <class _Tp, size_t _Ns>
3198 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3199 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3203 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3206 #if _LIBCPP_STD_VER > 14
3207 template <class _Tp, class ..._Args>
3208 inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
3211 // is_nothrow_default_constructible
3213 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3214 : public is_nothrow_constructible<_Tp>
3217 #if _LIBCPP_STD_VER > 14
3218 template <class _Tp>
3219 inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
3222 // is_nothrow_copy_constructible
3224 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3225 : public is_nothrow_constructible<_Tp,
3226 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3228 #if _LIBCPP_STD_VER > 14
3229 template <class _Tp>
3230 inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
3233 // is_nothrow_move_constructible
3235 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3236 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3239 #if _LIBCPP_STD_VER > 14
3240 template <class _Tp>
3241 inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
3244 // is_nothrow_assignable
3246 #if __has_keyword(__is_nothrow_assignable)
3248 template <class _Tp, class _Arg>
3249 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3250 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
3254 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3256 template <class _Tp, class _Arg>
3257 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3262 template <class _Tp, class _Arg>
3263 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3264 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
3268 template <class _Tp, class _Arg>
3269 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3270 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3274 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3276 #if _LIBCPP_STD_VER > 14
3277 template <class _Tp, class _Arg>
3278 inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
3281 // is_nothrow_copy_assignable
3283 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3284 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3285 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3287 #if _LIBCPP_STD_VER > 14
3288 template <class _Tp>
3289 inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
3292 // is_nothrow_move_assignable
3294 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3295 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3296 typename add_rvalue_reference<_Tp>::type>
3299 #if _LIBCPP_STD_VER > 14
3300 template <class _Tp>
3301 inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
3304 // is_nothrow_destructible
3306 #if !defined(_LIBCPP_CXX03_LANG)
3308 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3310 template <class _Tp>
3311 struct __libcpp_is_nothrow_destructible<false, _Tp>
3316 template <class _Tp>
3317 struct __libcpp_is_nothrow_destructible<true, _Tp>
3318 : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
3322 template <class _Tp>
3323 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3324 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3328 template <class _Tp, size_t _Ns>
3329 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3330 : public is_nothrow_destructible<_Tp>
3334 template <class _Tp>
3335 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3340 template <class _Tp>
3341 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3348 template <class _Tp> struct __libcpp_nothrow_destructor
3349 : public integral_constant<bool, is_scalar<_Tp>::value ||
3350 is_reference<_Tp>::value> {};
3352 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3353 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3355 template <class _Tp>
3356 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3357 : public false_type {};
3361 #if _LIBCPP_STD_VER > 14
3362 template <class _Tp>
3363 inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
3368 #if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
3370 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3371 : public integral_constant<bool, __is_pod(_Tp)> {};
3375 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3376 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3377 is_trivially_copy_constructible<_Tp>::value &&
3378 is_trivially_copy_assignable<_Tp>::value &&
3379 is_trivially_destructible<_Tp>::value> {};
3383 #if _LIBCPP_STD_VER > 14
3384 template <class _Tp>
3385 inline constexpr bool is_pod_v = is_pod<_Tp>::value;
3390 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3391 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
3392 : public integral_constant<bool, __is_literal_type(_Tp)>
3395 #if _LIBCPP_STD_VER > 14
3396 template <class _Tp>
3397 _LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
3398 #endif // _LIBCPP_STD_VER > 14
3399 #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3401 // is_standard_layout;
3403 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3404 #if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
3405 : public integral_constant<bool, __is_standard_layout(_Tp)>
3407 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3411 #if _LIBCPP_STD_VER > 14
3412 template <class _Tp>
3413 inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
3416 // is_trivially_copyable;
3418 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3419 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3422 #if _LIBCPP_STD_VER > 14
3423 template <class _Tp>
3424 inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
3429 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3430 #if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
3431 : public integral_constant<bool, __is_trivial(_Tp)>
3433 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3434 is_trivially_default_constructible<_Tp>::value>
3438 #if _LIBCPP_STD_VER > 14
3439 template <class _Tp>
3440 inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
3443 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3444 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3445 template <class _Tp> struct __is_reference_wrapper
3446 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3448 #ifndef _LIBCPP_CXX03_LANG
3450 template <class _Fp, class _A0,
3451 class _DecayFp = typename decay<_Fp>::type,
3452 class _DecayA0 = typename decay<_A0>::type,
3453 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3454 using __enable_if_bullet1 = typename enable_if
3456 is_member_function_pointer<_DecayFp>::value
3457 && is_base_of<_ClassT, _DecayA0>::value
3460 template <class _Fp, class _A0,
3461 class _DecayFp = typename decay<_Fp>::type,
3462 class _DecayA0 = typename decay<_A0>::type>
3463 using __enable_if_bullet2 = typename enable_if
3465 is_member_function_pointer<_DecayFp>::value
3466 && __is_reference_wrapper<_DecayA0>::value
3469 template <class _Fp, class _A0,
3470 class _DecayFp = typename decay<_Fp>::type,
3471 class _DecayA0 = typename decay<_A0>::type,
3472 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3473 using __enable_if_bullet3 = typename enable_if
3475 is_member_function_pointer<_DecayFp>::value
3476 && !is_base_of<_ClassT, _DecayA0>::value
3477 && !__is_reference_wrapper<_DecayA0>::value
3480 template <class _Fp, class _A0,
3481 class _DecayFp = typename decay<_Fp>::type,
3482 class _DecayA0 = typename decay<_A0>::type,
3483 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3484 using __enable_if_bullet4 = typename enable_if
3486 is_member_object_pointer<_DecayFp>::value
3487 && is_base_of<_ClassT, _DecayA0>::value
3490 template <class _Fp, class _A0,
3491 class _DecayFp = typename decay<_Fp>::type,
3492 class _DecayA0 = typename decay<_A0>::type>
3493 using __enable_if_bullet5 = typename enable_if
3495 is_member_object_pointer<_DecayFp>::value
3496 && __is_reference_wrapper<_DecayA0>::value
3499 template <class _Fp, class _A0,
3500 class _DecayFp = typename decay<_Fp>::type,
3501 class _DecayA0 = typename decay<_A0>::type,
3502 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3503 using __enable_if_bullet6 = typename enable_if
3505 is_member_object_pointer<_DecayFp>::value
3506 && !is_base_of<_ClassT, _DecayA0>::value
3507 && !__is_reference_wrapper<_DecayA0>::value
3510 // __invoke forward declarations
3512 // fall back - none of the bullets
3514 template <class ..._Args>
3515 auto __invoke(__any, _Args&& ...__args) -> __nat;
3517 template <class ..._Args>
3518 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
3520 // bullets 1, 2 and 3
3522 template <class _Fp, class _A0, class ..._Args,
3523 class = __enable_if_bullet1<_Fp, _A0>>
3524 inline _LIBCPP_INLINE_VISIBILITY
3525 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3526 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3527 noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
3528 -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
3529 { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
3531 template <class _Fp, class _A0, class ..._Args,
3532 class = __enable_if_bullet1<_Fp, _A0>>
3533 inline _LIBCPP_INLINE_VISIBILITY
3534 _LIBCPP_CONSTEXPR auto
3535 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3536 noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
3537 -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
3538 { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
3540 template <class _Fp, class _A0, class ..._Args,
3541 class = __enable_if_bullet2<_Fp, _A0>>
3542 inline _LIBCPP_INLINE_VISIBILITY
3543 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3544 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3545 noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
3546 -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
3547 { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
3549 template <class _Fp, class _A0, class ..._Args,
3550 class = __enable_if_bullet2<_Fp, _A0>>
3551 inline _LIBCPP_INLINE_VISIBILITY
3552 _LIBCPP_CONSTEXPR auto
3553 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3554 noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
3555 -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
3556 { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
3558 template <class _Fp, class _A0, class ..._Args,
3559 class = __enable_if_bullet3<_Fp, _A0>>
3560 inline _LIBCPP_INLINE_VISIBILITY
3561 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3562 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3563 noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
3564 -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
3565 { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
3567 template <class _Fp, class _A0, class ..._Args,
3568 class = __enable_if_bullet3<_Fp, _A0>>
3569 inline _LIBCPP_INLINE_VISIBILITY
3570 _LIBCPP_CONSTEXPR auto
3571 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3572 noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
3573 -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
3574 { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
3576 // bullets 4, 5 and 6
3578 template <class _Fp, class _A0,
3579 class = __enable_if_bullet4<_Fp, _A0>>
3580 inline _LIBCPP_INLINE_VISIBILITY
3581 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3582 __invoke(_Fp&& __f, _A0&& __a0)
3583 noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
3584 -> decltype( static_cast<_A0&&>(__a0).*__f)
3585 { return static_cast<_A0&&>(__a0).*__f; }
3587 template <class _Fp, class _A0,
3588 class = __enable_if_bullet4<_Fp, _A0>>
3589 inline _LIBCPP_INLINE_VISIBILITY
3590 _LIBCPP_CONSTEXPR auto
3591 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3592 noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
3593 -> decltype( static_cast<_A0&&>(__a0).*__f)
3594 { return static_cast<_A0&&>(__a0).*__f; }
3596 template <class _Fp, class _A0,
3597 class = __enable_if_bullet5<_Fp, _A0>>
3598 inline _LIBCPP_INLINE_VISIBILITY
3599 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3600 __invoke(_Fp&& __f, _A0&& __a0)
3601 noexcept(noexcept(__a0.get().*__f))
3602 -> decltype( __a0.get().*__f)
3603 { return __a0.get().*__f; }
3605 template <class _Fp, class _A0,
3606 class = __enable_if_bullet5<_Fp, _A0>>
3607 inline _LIBCPP_INLINE_VISIBILITY
3608 _LIBCPP_CONSTEXPR auto
3609 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3610 noexcept(noexcept(__a0.get().*__f))
3611 -> decltype( __a0.get().*__f)
3612 { return __a0.get().*__f; }
3614 template <class _Fp, class _A0,
3615 class = __enable_if_bullet6<_Fp, _A0>>
3616 inline _LIBCPP_INLINE_VISIBILITY
3617 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3618 __invoke(_Fp&& __f, _A0&& __a0)
3619 noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
3620 -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
3621 { return (*static_cast<_A0&&>(__a0)).*__f; }
3623 template <class _Fp, class _A0,
3624 class = __enable_if_bullet6<_Fp, _A0>>
3625 inline _LIBCPP_INLINE_VISIBILITY
3626 _LIBCPP_CONSTEXPR auto
3627 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3628 noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
3629 -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
3630 { return (*static_cast<_A0&&>(__a0)).*__f; }
3634 template <class _Fp, class ..._Args>
3635 inline _LIBCPP_INLINE_VISIBILITY
3636 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto
3637 __invoke(_Fp&& __f, _Args&& ...__args)
3638 noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
3639 -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
3640 { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
3642 template <class _Fp, class ..._Args>
3643 inline _LIBCPP_INLINE_VISIBILITY
3644 _LIBCPP_CONSTEXPR auto
3645 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
3646 noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
3647 -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
3648 { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
3651 template <class _Ret, class _Fp, class ..._Args>
3652 struct __invokable_r
3654 template <class _XFp, class ..._XArgs>
3655 static auto __try_call(int) -> decltype(
3656 _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...));
3657 template <class _XFp, class ..._XArgs>
3658 static __nat __try_call(...);
3660 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
3661 // or incomplete array types as required by the standard.
3662 using _Result = decltype(__try_call<_Fp, _Args...>(0));
3665 typename conditional<
3666 _IsNotSame<_Result, __nat>::value,
3667 typename conditional<
3668 is_void<_Ret>::value,
3670 is_convertible<_Result, _Ret>
3674 static const bool value = type::value;
3676 template <class _Fp, class ..._Args>
3677 using __invokable = __invokable_r<void, _Fp, _Args...>;
3679 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
3680 struct __nothrow_invokable_r_imp {
3681 static const bool value = false;
3684 template <class _Ret, class _Fp, class ..._Args>
3685 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
3687 typedef __nothrow_invokable_r_imp _ThisT;
3689 template <class _Tp>
3690 static void __test_noexcept(_Tp) noexcept;
3692 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
3693 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
3696 template <class _Ret, class _Fp, class ..._Args>
3697 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
3699 static const bool value = noexcept(
3700 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
3703 template <class _Ret, class _Fp, class ..._Args>
3704 using __nothrow_invokable_r =
3705 __nothrow_invokable_r_imp<
3706 __invokable_r<_Ret, _Fp, _Args...>::value,
3707 is_void<_Ret>::value,
3711 template <class _Fp, class ..._Args>
3712 using __nothrow_invokable =
3713 __nothrow_invokable_r_imp<
3714 __invokable<_Fp, _Args...>::value,
3715 true, void, _Fp, _Args...
3718 template <class _Fp, class ..._Args>
3721 __invokable<_Fp, _Args...>::value,
3722 typename __invokable_r<void, _Fp, _Args...>::_Result>
3726 #endif // _LIBCPP_CXX03_LANG
3730 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3731 template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
3733 #ifndef _LIBCPP_CXX03_LANG
3735 template <class _Fp, class ..._Args>
3736 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
3737 : public __invoke_of<_Fp, _Args...>
3743 template <class _Fn, bool, bool>
3748 template <class _Fn, class ..._Args>
3749 class __result_of<_Fn(_Args...), true, false>
3752 typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
3755 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
3756 struct __result_of_mp;
3758 // member function pointer
3760 template <class _MP, class _Tp>
3761 struct __result_of_mp<_MP, _Tp, true>
3763 using type = typename __member_pointer_traits<_MP>::_ReturnType;
3766 // member data pointer
3768 template <class _MP, class _Tp, bool>
3769 struct __result_of_mdp;
3771 template <class _Rp, class _Class, class _Tp>
3772 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
3774 using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&;
3777 template <class _Rp, class _Class, class _Tp>
3778 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
3780 using type = typename __apply_cv<_Tp, _Rp>::type&;
3783 template <class _Rp, class _Class, class _Tp>
3784 struct __result_of_mp<_Rp _Class::*, _Tp, false>
3785 : public __result_of_mdp<_Rp _Class::*, _Tp,
3786 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
3790 template <class _Fn, class _Tp>
3791 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
3792 : public __result_of_mp<typename remove_reference<_Fn>::type,
3794 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
3798 template <class _Fn, class _Tp, class ..._Args>
3799 class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer
3800 : public __result_of_mp<typename remove_reference<_Fn>::type,
3802 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
3806 template <class _Fn, class ..._Args>
3807 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
3808 : public __result_of<_Fn(_Args...),
3809 is_class<typename remove_reference<_Fn>::type>::value ||
3810 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3811 is_member_pointer<typename remove_reference<_Fn>::type>::value
3818 #if _LIBCPP_STD_VER > 11
3819 template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
3820 #endif // _LIBCPP_STD_VER > 11
3821 #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3823 #if _LIBCPP_STD_VER > 14
3827 template <class _Fn, class... _Args>
3828 struct _LIBCPP_TEMPLATE_VIS invoke_result
3829 : __invoke_of<_Fn, _Args...>
3833 template <class _Fn, class... _Args>
3834 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
3838 template <class _Fn, class ..._Args>
3839 struct _LIBCPP_TEMPLATE_VIS is_invocable
3840 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
3842 template <class _Ret, class _Fn, class ..._Args>
3843 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
3844 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
3846 template <class _Fn, class ..._Args>
3847 inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
3849 template <class _Ret, class _Fn, class ..._Args>
3850 inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
3852 // is_nothrow_invocable
3854 template <class _Fn, class ..._Args>
3855 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
3856 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
3858 template <class _Ret, class _Fn, class ..._Args>
3859 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
3860 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
3862 template <class _Fn, class ..._Args>
3863 inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
3865 template <class _Ret, class _Fn, class ..._Args>
3866 inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
3868 #endif // _LIBCPP_STD_VER > 14
3872 template <class _Tp> struct __is_swappable;
3873 template <class _Tp> struct __is_nothrow_swappable;
3876 #ifndef _LIBCPP_CXX03_LANG
3877 template <class _Tp>
3878 using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
3881 using __swap_result_t = void;
3884 template <class _Tp>
3885 inline _LIBCPP_INLINE_VISIBILITY
3886 _LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp>
3887 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3888 is_nothrow_move_assignable<_Tp>::value);
3890 template<class _Tp, size_t _Np>
3891 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3893 __is_swappable<_Tp>::value
3895 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
3899 // ALL generic swap overloads MUST already have a declaration available at this point.
3901 template <class _Tp, class _Up = _Tp,
3902 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
3903 struct __swappable_with
3905 template <class _LHS, class _RHS>
3906 static decltype(swap(declval<_LHS>(), declval<_RHS>()))
3908 template <class, class>
3909 static __nat __test_swap(long);
3911 // Extra parens are needed for the C++03 definition of decltype.
3912 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
3913 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
3915 static const bool value = _IsNotSame<__swap1, __nat>::value
3916 && _IsNotSame<__swap2, __nat>::value;
3919 template <class _Tp, class _Up>
3920 struct __swappable_with<_Tp, _Up, false> : false_type {};
3922 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
3923 struct __nothrow_swappable_with {
3924 static const bool value =
3925 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
3926 noexcept(swap(declval<_Tp>(), declval<_Up>()))
3927 && noexcept(swap(declval<_Up>(), declval<_Tp>()));
3933 template <class _Tp, class _Up>
3934 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
3936 } // namespace __detail
3938 template <class _Tp>
3939 struct __is_swappable
3940 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
3944 template <class _Tp>
3945 struct __is_nothrow_swappable
3946 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
3950 #if _LIBCPP_STD_VER > 14
3952 template <class _Tp, class _Up>
3953 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
3954 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
3958 template <class _Tp>
3959 struct _LIBCPP_TEMPLATE_VIS is_swappable
3960 : public conditional<
3961 __is_referenceable<_Tp>::value,
3963 typename add_lvalue_reference<_Tp>::type,
3964 typename add_lvalue_reference<_Tp>::type>,
3970 template <class _Tp, class _Up>
3971 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
3972 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
3976 template <class _Tp>
3977 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
3978 : public conditional<
3979 __is_referenceable<_Tp>::value,
3980 is_nothrow_swappable_with<
3981 typename add_lvalue_reference<_Tp>::type,
3982 typename add_lvalue_reference<_Tp>::type>,
3988 template <class _Tp, class _Up>
3989 inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
3991 template <class _Tp>
3992 inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
3994 template <class _Tp, class _Up>
3995 inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
3997 template <class _Tp>
3998 inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
4000 #endif // _LIBCPP_STD_VER > 14
4002 template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
4004 template <class _Tp>
4005 struct __underlying_type_impl<_Tp, false> {};
4007 template <class _Tp>
4008 struct __underlying_type_impl<_Tp, true>
4010 typedef __underlying_type(_Tp) type;
4013 template <class _Tp>
4014 struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
4016 #if _LIBCPP_STD_VER > 11
4017 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4020 template <class _Tp, bool = is_enum<_Tp>::value>
4021 struct __sfinae_underlying_type
4023 typedef typename underlying_type<_Tp>::type type;
4024 typedef decltype(((type)1) + 0) __promoted_type;
4027 template <class _Tp>
4028 struct __sfinae_underlying_type<_Tp, false> {};
4030 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4031 int __convert_to_integral(int __val) { return __val; }
4033 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4034 unsigned __convert_to_integral(unsigned __val) { return __val; }
4036 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4037 long __convert_to_integral(long __val) { return __val; }
4039 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4040 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4042 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4043 long long __convert_to_integral(long long __val) { return __val; }
4045 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4046 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4048 template<typename _Fp>
4049 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4050 typename enable_if<is_floating_point<_Fp>::value, long long>::type
4051 __convert_to_integral(_Fp __val) { return __val; }
4053 #ifndef _LIBCPP_HAS_NO_INT128
4054 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4055 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4057 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4058 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4061 template <class _Tp>
4062 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4063 typename __sfinae_underlying_type<_Tp>::__promoted_type
4064 __convert_to_integral(_Tp __val) { return __val; }
4066 // is_scoped_enum [meta.unary.prop]
4068 #if _LIBCPP_STD_VER > 20
4069 template <class _Tp, bool = is_enum_v<_Tp> >
4070 struct __is_scoped_enum_helper : false_type {};
4072 template <class _Tp>
4073 struct __is_scoped_enum_helper<_Tp, true>
4074 : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
4076 template <class _Tp>
4077 struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
4078 : public __is_scoped_enum_helper<_Tp> {};
4080 template <class _Tp>
4081 inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
4084 #if _LIBCPP_STD_VER > 14
4086 template <class... _Args>
4087 struct conjunction : _And<_Args...> {};
4088 template<class... _Args>
4089 inline constexpr bool conjunction_v = conjunction<_Args...>::value;
4091 template <class... _Args>
4092 struct disjunction : _Or<_Args...> {};
4093 template<class... _Args>
4094 inline constexpr bool disjunction_v = disjunction<_Args...>::value;
4096 template <class _Tp>
4097 struct negation : _Not<_Tp> {};
4099 inline constexpr bool negation_v = negation<_Tp>::value;
4100 #endif // _LIBCPP_STD_VER > 14
4102 // These traits are used in __tree and __hash_table
4103 struct __extract_key_fail_tag {};
4104 struct __extract_key_self_tag {};
4105 struct __extract_key_first_tag {};
4107 template <class _ValTy, class _Key,
4108 class _RawValTy = typename __unconstref<_ValTy>::type>
4109 struct __can_extract_key
4110 : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
4111 __extract_key_fail_tag>::type {};
4113 template <class _Pair, class _Key, class _First, class _Second>
4114 struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
4115 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
4116 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4118 // __can_extract_map_key uses true_type/false_type instead of the tags.
4119 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4120 // and _ValTy == _Key.
4121 template <class _ValTy, class _Key, class _ContainerValueTy,
4122 class _RawValTy = typename __unconstref<_ValTy>::type>
4123 struct __can_extract_map_key
4124 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
4126 // This specialization returns __extract_key_fail_tag for non-map containers
4127 // because _Key == _ContainerValueTy
4128 template <class _ValTy, class _Key, class _RawValTy>
4129 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4132 #if _LIBCPP_STD_VER > 17
4133 _LIBCPP_INLINE_VISIBILITY
4134 inline constexpr bool is_constant_evaluated() noexcept {
4135 return __builtin_is_constant_evaluated();
4139 inline _LIBCPP_CONSTEXPR
4140 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
4142 template <class _CharT>
4143 using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
4146 using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;
4148 #if _LIBCPP_STD_VER > 17
4149 template<bool _Const, class _Tp>
4150 using __maybe_const = conditional_t<_Const, const _Tp, _Tp>;
4151 #endif // _LIBCPP_STD_VER > 17
4153 _LIBCPP_END_NAMESPACE_STD
4155 #endif // _LIBCPP_TYPE_TRAITS