2 //===------------------------ type_traits ---------------------------------===//
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_scalar;
55 template <class T> struct is_object;
56 template <class T> struct is_compound;
58 // Const-volatile properties and transformations:
59 template <class T> struct is_const;
60 template <class T> struct is_volatile;
61 template <class T> struct remove_const;
62 template <class T> struct remove_volatile;
63 template <class T> struct remove_cv;
64 template <class T> struct add_const;
65 template <class T> struct add_volatile;
66 template <class T> struct add_cv;
68 // Reference transformations:
69 template <class T> struct remove_reference;
70 template <class T> struct add_lvalue_reference;
71 template <class T> struct add_rvalue_reference;
73 // Pointer transformations:
74 template <class T> struct remove_pointer;
75 template <class T> struct add_pointer;
77 template<class T> struct type_identity; // C++20
79 using type_identity_t = typename type_identity<T>::type; // C++20
81 // Integral properties:
82 template <class T> struct is_signed;
83 template <class T> struct is_unsigned;
84 template <class T> struct make_signed;
85 template <class T> struct make_unsigned;
87 // Array properties and transformations:
88 template <class T> struct rank;
89 template <class T, unsigned I = 0> struct extent;
90 template <class T> struct remove_extent;
91 template <class T> struct remove_all_extents;
93 template <class T> struct is_bounded_array; // C++20
94 template <class T> struct is_unbounded_array; // C++20
96 // Member introspection:
97 template <class T> struct is_pod;
98 template <class T> struct is_trivial;
99 template <class T> struct is_trivially_copyable;
100 template <class T> struct is_standard_layout;
101 template <class T> struct is_literal_type;
102 template <class T> struct is_empty;
103 template <class T> struct is_polymorphic;
104 template <class T> struct is_abstract;
105 template <class T> struct is_final; // C++14
106 template <class T> struct is_aggregate; // C++17
108 template <class T, class... Args> struct is_constructible;
109 template <class T> struct is_default_constructible;
110 template <class T> struct is_copy_constructible;
111 template <class T> struct is_move_constructible;
112 template <class T, class U> struct is_assignable;
113 template <class T> struct is_copy_assignable;
114 template <class T> struct is_move_assignable;
115 template <class T, class U> struct is_swappable_with; // C++17
116 template <class T> struct is_swappable; // C++17
117 template <class T> struct is_destructible;
119 template <class T, class... Args> struct is_trivially_constructible;
120 template <class T> struct is_trivially_default_constructible;
121 template <class T> struct is_trivially_copy_constructible;
122 template <class T> struct is_trivially_move_constructible;
123 template <class T, class U> struct is_trivially_assignable;
124 template <class T> struct is_trivially_copy_assignable;
125 template <class T> struct is_trivially_move_assignable;
126 template <class T> struct is_trivially_destructible;
128 template <class T, class... Args> struct is_nothrow_constructible;
129 template <class T> struct is_nothrow_default_constructible;
130 template <class T> struct is_nothrow_copy_constructible;
131 template <class T> struct is_nothrow_move_constructible;
132 template <class T, class U> struct is_nothrow_assignable;
133 template <class T> struct is_nothrow_copy_assignable;
134 template <class T> struct is_nothrow_move_assignable;
135 template <class T, class U> struct is_nothrow_swappable_with; // C++17
136 template <class T> struct is_nothrow_swappable; // C++17
137 template <class T> struct is_nothrow_destructible;
139 template <class T> struct has_virtual_destructor;
141 template<class T> struct has_unique_object_representations; // C++17
143 // Relationships between types:
144 template <class T, class U> struct is_same;
145 template <class Base, class Derived> struct is_base_of;
147 template <class From, class To> struct is_convertible;
148 template <typename From, typename To> struct is_nothrow_convertible; // C++20
149 template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20
151 template <class Fn, class... ArgTypes> struct is_invocable;
152 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
154 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
155 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
157 // Alignment properties and transformations:
158 template <class T> struct alignment_of;
159 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
160 struct aligned_storage;
161 template <size_t Len, class... Types> struct aligned_union;
162 template <class T> struct remove_cvref; // C++20
164 template <class T> struct decay;
165 template <class... T> struct common_type;
166 template <class T> struct underlying_type;
167 template <class> class result_of; // undefined
168 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
169 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
171 // const-volatile modifications:
173 using remove_const_t = typename remove_const<T>::type; // C++14
175 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
177 using remove_cv_t = typename remove_cv<T>::type; // C++14
179 using add_const_t = typename add_const<T>::type; // C++14
181 using add_volatile_t = typename add_volatile<T>::type; // C++14
183 using add_cv_t = typename add_cv<T>::type; // C++14
185 // reference modifications:
187 using remove_reference_t = typename remove_reference<T>::type; // C++14
189 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
191 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
193 // sign modifications:
195 using make_signed_t = typename make_signed<T>::type; // C++14
197 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
199 // array modifications:
201 using remove_extent_t = typename remove_extent<T>::type; // C++14
203 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
206 inline constexpr bool is_bounded_array_v
207 = is_bounded_array<T>::value; // C++20
208 inline constexpr bool is_unbounded_array_v
209 = is_unbounded_array<T>::value; // C++20
211 // pointer modifications:
213 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
215 using add_pointer_t = typename add_pointer<T>::type; // C++14
217 // other transformations:
218 template <size_t Len, std::size_t Align=default-alignment>
219 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
220 template <std::size_t Len, class... Types>
221 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
223 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
225 using decay_t = typename decay<T>::type; // C++14
226 template <bool b, class T=void>
227 using enable_if_t = typename enable_if<b,T>::type; // C++14
228 template <bool b, class T, class F>
229 using conditional_t = typename conditional<b,T,F>::type; // C++14
230 template <class... T>
231 using common_type_t = typename common_type<T...>::type; // C++14
233 using underlying_type_t = typename underlying_type<T>::type; // C++14
235 using result_of_t = typename result_of<T>::type; // C++14
236 template <class Fn, class... ArgTypes>
237 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
240 using void_t = void; // C++17
242 // See C++14 20.10.4.1, primary type categories
243 template <class T> inline constexpr bool is_void_v
244 = is_void<T>::value; // C++17
245 template <class T> inline constexpr bool is_null_pointer_v
246 = is_null_pointer<T>::value; // C++17
247 template <class T> inline constexpr bool is_integral_v
248 = is_integral<T>::value; // C++17
249 template <class T> inline constexpr bool is_floating_point_v
250 = is_floating_point<T>::value; // C++17
251 template <class T> inline constexpr bool is_array_v
252 = is_array<T>::value; // C++17
253 template <class T> inline constexpr bool is_pointer_v
254 = is_pointer<T>::value; // C++17
255 template <class T> inline constexpr bool is_lvalue_reference_v
256 = is_lvalue_reference<T>::value; // C++17
257 template <class T> inline constexpr bool is_rvalue_reference_v
258 = is_rvalue_reference<T>::value; // C++17
259 template <class T> inline constexpr bool is_member_object_pointer_v
260 = is_member_object_pointer<T>::value; // C++17
261 template <class T> inline constexpr bool is_member_function_pointer_v
262 = is_member_function_pointer<T>::value; // C++17
263 template <class T> inline constexpr bool is_enum_v
264 = is_enum<T>::value; // C++17
265 template <class T> inline constexpr bool is_union_v
266 = is_union<T>::value; // C++17
267 template <class T> inline constexpr bool is_class_v
268 = is_class<T>::value; // C++17
269 template <class T> inline constexpr bool is_function_v
270 = is_function<T>::value; // C++17
272 // See C++14 20.10.4.2, composite type categories
273 template <class T> inline constexpr bool is_reference_v
274 = is_reference<T>::value; // C++17
275 template <class T> inline constexpr bool is_arithmetic_v
276 = is_arithmetic<T>::value; // C++17
277 template <class T> inline constexpr bool is_fundamental_v
278 = is_fundamental<T>::value; // C++17
279 template <class T> inline constexpr bool is_object_v
280 = is_object<T>::value; // C++17
281 template <class T> inline constexpr bool is_scalar_v
282 = is_scalar<T>::value; // C++17
283 template <class T> inline constexpr bool is_compound_v
284 = is_compound<T>::value; // C++17
285 template <class T> inline constexpr bool is_member_pointer_v
286 = is_member_pointer<T>::value; // C++17
288 // See C++14 20.10.4.3, type properties
289 template <class T> inline constexpr bool is_const_v
290 = is_const<T>::value; // C++17
291 template <class T> inline constexpr bool is_volatile_v
292 = is_volatile<T>::value; // C++17
293 template <class T> inline constexpr bool is_trivial_v
294 = is_trivial<T>::value; // C++17
295 template <class T> inline constexpr bool is_trivially_copyable_v
296 = is_trivially_copyable<T>::value; // C++17
297 template <class T> inline constexpr bool is_standard_layout_v
298 = is_standard_layout<T>::value; // C++17
299 template <class T> inline constexpr bool is_pod_v
300 = is_pod<T>::value; // C++17
301 template <class T> inline constexpr bool is_literal_type_v
302 = is_literal_type<T>::value; // C++17
303 template <class T> inline constexpr bool is_empty_v
304 = is_empty<T>::value; // C++17
305 template <class T> inline constexpr bool is_polymorphic_v
306 = is_polymorphic<T>::value; // C++17
307 template <class T> inline constexpr bool is_abstract_v
308 = is_abstract<T>::value; // C++17
309 template <class T> inline constexpr bool is_final_v
310 = is_final<T>::value; // C++17
311 template <class T> inline constexpr bool is_aggregate_v
312 = is_aggregate<T>::value; // C++17
313 template <class T> inline constexpr bool is_signed_v
314 = is_signed<T>::value; // C++17
315 template <class T> inline constexpr bool is_unsigned_v
316 = is_unsigned<T>::value; // C++17
317 template <class T, class... Args> inline constexpr bool is_constructible_v
318 = is_constructible<T, Args...>::value; // C++17
319 template <class T> inline constexpr bool is_default_constructible_v
320 = is_default_constructible<T>::value; // C++17
321 template <class T> inline constexpr bool is_copy_constructible_v
322 = is_copy_constructible<T>::value; // C++17
323 template <class T> inline constexpr bool is_move_constructible_v
324 = is_move_constructible<T>::value; // C++17
325 template <class T, class U> inline constexpr bool is_assignable_v
326 = is_assignable<T, U>::value; // C++17
327 template <class T> inline constexpr bool is_copy_assignable_v
328 = is_copy_assignable<T>::value; // C++17
329 template <class T> inline constexpr bool is_move_assignable_v
330 = is_move_assignable<T>::value; // C++17
331 template <class T, class U> inline constexpr bool is_swappable_with_v
332 = is_swappable_with<T, U>::value; // C++17
333 template <class T> inline constexpr bool is_swappable_v
334 = is_swappable<T>::value; // C++17
335 template <class T> inline constexpr bool is_destructible_v
336 = is_destructible<T>::value; // C++17
337 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
338 = is_trivially_constructible<T, Args...>::value; // C++17
339 template <class T> inline constexpr bool is_trivially_default_constructible_v
340 = is_trivially_default_constructible<T>::value; // C++17
341 template <class T> inline constexpr bool is_trivially_copy_constructible_v
342 = is_trivially_copy_constructible<T>::value; // C++17
343 template <class T> inline constexpr bool is_trivially_move_constructible_v
344 = is_trivially_move_constructible<T>::value; // C++17
345 template <class T, class U> inline constexpr bool is_trivially_assignable_v
346 = is_trivially_assignable<T, U>::value; // C++17
347 template <class T> inline constexpr bool is_trivially_copy_assignable_v
348 = is_trivially_copy_assignable<T>::value; // C++17
349 template <class T> inline constexpr bool is_trivially_move_assignable_v
350 = is_trivially_move_assignable<T>::value; // C++17
351 template <class T> inline constexpr bool is_trivially_destructible_v
352 = is_trivially_destructible<T>::value; // C++17
353 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
354 = is_nothrow_constructible<T, Args...>::value; // C++17
355 template <class T> inline constexpr bool is_nothrow_default_constructible_v
356 = is_nothrow_default_constructible<T>::value; // C++17
357 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
358 = is_nothrow_copy_constructible<T>::value; // C++17
359 template <class T> inline constexpr bool is_nothrow_move_constructible_v
360 = is_nothrow_move_constructible<T>::value; // C++17
361 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
362 = is_nothrow_assignable<T, U>::value; // C++17
363 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
364 = is_nothrow_copy_assignable<T>::value; // C++17
365 template <class T> inline constexpr bool is_nothrow_move_assignable_v
366 = is_nothrow_move_assignable<T>::value; // C++17
367 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
368 = is_nothrow_swappable_with<T, U>::value; // C++17
369 template <class T> inline constexpr bool is_nothrow_swappable_v
370 = is_nothrow_swappable<T>::value; // C++17
371 template <class T> inline constexpr bool is_nothrow_destructible_v
372 = is_nothrow_destructible<T>::value; // C++17
373 template <class T> inline constexpr bool has_virtual_destructor_v
374 = has_virtual_destructor<T>::value; // C++17
375 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
376 = has_unique_object_representations<T>::value;
378 // See C++14 20.10.5, type property queries
379 template <class T> inline constexpr size_t alignment_of_v
380 = alignment_of<T>::value; // C++17
381 template <class T> inline constexpr size_t rank_v
382 = rank<T>::value; // C++17
383 template <class T, unsigned I = 0> inline constexpr size_t extent_v
384 = extent<T, I>::value; // C++17
386 // See C++14 20.10.6, type relations
387 template <class T, class U> inline constexpr bool is_same_v
388 = is_same<T, U>::value; // C++17
389 template <class Base, class Derived> inline constexpr bool is_base_of_v
390 = is_base_of<Base, Derived>::value; // C++17
391 template <class From, class To> inline constexpr bool is_convertible_v
392 = is_convertible<From, To>::value; // C++17
393 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
394 = is_invocable<Fn, ArgTypes...>::value; // C++17
395 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
396 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
397 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
398 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
399 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
400 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
402 // [meta.logical], logical operator traits:
403 template<class... B> struct conjunction; // C++17
405 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
406 template<class... B> struct disjunction; // C++17
408 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
409 template<class B> struct negation; // C++17
411 inline constexpr bool negation_v = negation<B>::value; // C++17
420 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
421 #pragma GCC system_header
424 _LIBCPP_BEGIN_NAMESPACE_STD
426 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
427 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
428 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
430 template <class _Tp, _Tp __v>
431 struct _LIBCPP_TEMPLATE_VIS integral_constant
433 static _LIBCPP_CONSTEXPR const _Tp value = __v;
434 typedef _Tp value_type;
435 typedef integral_constant type;
436 _LIBCPP_INLINE_VISIBILITY
437 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
438 #if _LIBCPP_STD_VER > 11
439 _LIBCPP_INLINE_VISIBILITY
440 constexpr value_type operator ()() const _NOEXCEPT {return value;}
444 template <class _Tp, _Tp __v>
445 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
447 #if _LIBCPP_STD_VER > 14
449 using bool_constant = integral_constant<bool, __b>;
450 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
452 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
455 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
456 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
459 using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
461 template <bool> struct _MetaBase;
463 struct _MetaBase<true> {
464 template <class _Tp, class _Up>
465 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Tp;
466 template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
467 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _FirstFn<_Args...>;
468 template <class _First, class...>
469 using _FirstImpl _LIBCPP_NODEBUG_TYPE = _First;
470 template <class, class _Second, class...>
471 using _SecondImpl _LIBCPP_NODEBUG_TYPE = _Second;
472 template <class _Tp = void>
473 using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp;
474 template <class _Result, class _First, class ..._Rest>
475 using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
476 template <class _Result, class _First, class ..._Rest>
477 using _AndImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>;
481 struct _MetaBase<false> {
482 template <class _Tp, class _Up>
483 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Up;
484 template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
485 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>;
486 template <class _Result, class ...>
487 using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result;
488 template <class _Result, class ...>
489 using _AndImpl _LIBCPP_NODEBUG_TYPE = _Result;
491 template <bool _Cond, class _Ret = void>
492 using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>;
493 template <bool _Cond, class _IfRes, class _ElseRes>
494 using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
495 template <class ..._Rest>
496 using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
497 template <class ..._Rest>
498 using _And _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _AndImpl<true_type, _Rest...>;
499 template <class _Pred>
500 struct _Not : _BoolConstant<!_Pred::value> {};
501 template <class ..._Args>
502 using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
503 template <class ..._Args>
504 using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
506 template <template <class...> class _Func, class ..._Args>
507 struct _Lazy : _Func<_Args...> {};
509 // Member detector base
511 template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
512 true_type __sfinae_test_impl(int);
513 template <template <class...> class, class ...>
514 false_type __sfinae_test_impl(...);
516 template <template <class ...> class _Templ, class ..._Args>
517 using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
520 struct __void_t { typedef void type; };
523 struct __identity { typedef _Tp type; };
525 template <class _Tp, bool>
526 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
529 template <bool _Bp, class _If, class _Then>
530 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
531 template <class _If, class _Then>
532 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
534 #if _LIBCPP_STD_VER > 11
535 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
538 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
539 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
541 #if _LIBCPP_STD_VER > 11
542 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
547 #if __has_keyword(__is_same)
549 template <class _Tp, class _Up>
550 struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
552 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
553 template <class _Tp, class _Up>
554 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v = __is_same(_Tp, _Up);
559 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
560 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
562 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
563 template <class _Tp, class _Up>
564 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
565 = is_same<_Tp, _Up>::value;
570 template <class _Tp, class _Up>
571 using _IsSame = _BoolConstant<
575 _VSTD::is_same<_Tp, _Up>::value
579 template <class _Tp, class _Up>
580 using _IsNotSame = _BoolConstant<
584 !_VSTD::is_same<_Tp, _Up>::value
590 using __test_for_primary_template = _EnableIf<
591 _IsSame<_Tp, typename _Tp::__primary_template>::value
594 using __is_primary_template = _IsValidExpansion<
595 __test_for_primary_template, _Tp
599 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
602 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
603 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
605 addressof(_Tp& __x) _NOEXCEPT
607 return __builtin_addressof(__x);
613 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
615 addressof(_Tp& __x) _NOEXCEPT
617 return reinterpret_cast<_Tp *>(
618 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
621 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
623 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
624 // Objective-C++ Automatic Reference Counting uses qualified pointers
625 // that require special addressof() signatures. When
626 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
627 // itself is providing these definitions. Otherwise, we provide them.
629 inline _LIBCPP_INLINE_VISIBILITY
631 addressof(__strong _Tp& __x) _NOEXCEPT
636 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
638 inline _LIBCPP_INLINE_VISIBILITY
640 addressof(__weak _Tp& __x) _NOEXCEPT
647 inline _LIBCPP_INLINE_VISIBILITY
649 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
655 inline _LIBCPP_INLINE_VISIBILITY
656 __unsafe_unretained _Tp*
657 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
663 #if !defined(_LIBCPP_CXX03_LANG)
664 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
667 struct __two {char __lx[2];};
673 #if __has_keyword(__is_const)
676 struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
678 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
680 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v = __is_const(_Tp);
685 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
686 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
688 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
690 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
691 = is_const<_Tp>::value;
694 #endif // __has_keyword(__is_const)
698 #if __has_keyword(__is_volatile)
701 struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
703 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
705 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v = __is_volatile(_Tp);
710 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
711 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
713 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
715 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
716 = is_volatile<_Tp>::value;
719 #endif // __has_keyword(__is_volatile)
723 #if __has_keyword(__remove_const)
726 struct _LIBCPP_TEMPLATE_VIS remove_const {typedef __remove_const(_Tp) type;};
728 #if _LIBCPP_STD_VER > 11
729 template <class _Tp> using remove_const_t = __remove_const(_Tp);
734 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
735 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
736 #if _LIBCPP_STD_VER > 11
737 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
740 #endif // __has_keyword(__remove_const)
744 #if __has_keyword(__remove_volatile)
747 struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef __remove_volatile(_Tp) type;};
749 #if _LIBCPP_STD_VER > 11
750 template <class _Tp> using remove_volatile_t = __remove_volatile(_Tp);
755 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
756 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
757 #if _LIBCPP_STD_VER > 11
758 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
761 #endif // __has_keyword(__remove_volatile)
765 #if __has_keyword(__remove_cv)
768 struct _LIBCPP_TEMPLATE_VIS remove_cv {typedef __remove_cv(_Tp) type;};
770 #if _LIBCPP_STD_VER > 11
771 template <class _Tp> using remove_cv_t = __remove_cv(_Tp);
776 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
777 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
778 #if _LIBCPP_STD_VER > 11
779 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
782 #endif // __has_keyword(__remove_cv)
786 #if __has_keyword(__is_void)
789 struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
791 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
793 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v = __is_void(_Tp);
798 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
799 : public is_same<typename remove_cv<_Tp>::type, void> {};
801 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
803 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
804 = is_void<_Tp>::value;
807 #endif // __has_keyword(__is_void)
811 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
812 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
814 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
815 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
817 #if _LIBCPP_STD_VER > 11
818 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
819 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
821 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
823 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
824 = is_null_pointer<_Tp>::value;
826 #endif // _LIBCPP_STD_VER > 11
830 #if __has_keyword(__is_integral)
833 struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
835 #if _LIBCPP_STD_VER > 14
837 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v = __is_integral(_Tp);
842 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
843 : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
845 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
847 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
848 = is_integral<_Tp>::value;
851 #endif // __has_keyword(__is_integral)
855 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
856 template <> struct __libcpp_is_floating_point<float> : public true_type {};
857 template <> struct __libcpp_is_floating_point<double> : public true_type {};
858 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
860 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
861 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
863 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
865 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
866 = is_floating_point<_Tp>::value;
871 #if __has_keyword(__is_array)
874 struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
876 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
878 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v = __is_array(_Tp);
883 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
884 : public false_type {};
885 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
886 : public true_type {};
887 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
888 : public true_type {};
890 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
892 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
893 = is_array<_Tp>::value;
896 #endif // __has_keyword(__is_array)
900 // In clang 10.0.0 and earlier __is_pointer didn't work with Objective-C types.
901 #if __has_keyword(__is_pointer) && _LIBCPP_CLANG_VER > 1000
904 struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
906 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
908 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v = __is_pointer(_Tp);
911 #else // __has_keyword(__is_pointer)
913 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
914 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
916 template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
917 #if defined(_LIBCPP_HAS_OBJC_ARC)
918 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
919 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
920 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
921 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
924 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
925 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
927 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
929 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
930 = is_pointer<_Tp>::value;
933 #endif // __has_keyword(__is_pointer)
937 #if __has_keyword(__is_lvalue_reference) && \
938 __has_keyword(__is_rvalue_reference) && \
939 __has_keyword(__is_reference)
942 struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
945 struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
948 struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
950 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
952 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v = __is_reference(_Tp);
955 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
958 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
961 #else // __has_keyword(__is_lvalue_reference) && etc...
963 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
964 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
966 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
967 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
969 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
970 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
971 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
973 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
975 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
976 = is_reference<_Tp>::value;
979 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
980 = is_lvalue_reference<_Tp>::value;
983 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
984 = is_rvalue_reference<_Tp>::value;
987 #endif // __has_keyword(__is_lvalue_reference) && etc...
991 #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
994 : public integral_constant<bool, __is_union(_Tp)> {};
998 template <class _Tp> struct __libcpp_union : public false_type {};
999 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
1000 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
1004 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1005 template <class _Tp>
1006 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
1007 = is_union<_Tp>::value;
1012 #if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
1014 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
1015 : public integral_constant<bool, __is_class(_Tp)> {};
1019 namespace __is_class_imp
1021 template <class _Tp> char __test(int _Tp::*);
1022 template <class _Tp> __two __test(...);
1025 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
1026 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
1030 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1031 template <class _Tp>
1032 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
1033 = is_class<_Tp>::value;
1038 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
1039 : public _BoolConstant<
1043 !(is_reference<_Tp>::value || is_const<const _Tp>::value)
1048 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1049 template <class _Tp>
1050 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
1051 = is_function<_Tp>::value;
1054 template <class _Tp> struct __libcpp_is_member_pointer {
1056 __is_member = false,
1061 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
1064 __is_func = is_function<_Tp>::value,
1065 __is_obj = !__is_func,
1069 #if __has_keyword(__is_member_function_pointer)
1072 struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
1073 : _BoolConstant<__is_member_function_pointer(_Tp)> { };
1075 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1076 template <class _Tp>
1077 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
1078 = __is_member_function_pointer(_Tp);
1081 #else // __has_keyword(__is_member_function_pointer)
1083 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
1084 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
1086 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1087 template <class _Tp>
1088 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
1089 = is_member_function_pointer<_Tp>::value;
1092 #endif // __has_keyword(__is_member_function_pointer)
1094 // is_member_pointer
1096 #if __has_keyword(__is_member_pointer)
1099 struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
1101 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1102 template <class _Tp>
1103 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v = __is_member_pointer(_Tp);
1106 #else // __has_keyword(__is_member_pointer)
1108 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
1109 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
1111 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1112 template <class _Tp>
1113 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
1114 = is_member_pointer<_Tp>::value;
1117 #endif // __has_keyword(__is_member_pointer)
1119 // is_member_object_pointer
1121 #if __has_keyword(__is_member_object_pointer)
1124 struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
1125 : _BoolConstant<__is_member_object_pointer(_Tp)> { };
1127 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1128 template <class _Tp>
1129 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
1130 = __is_member_object_pointer(_Tp);
1133 #else // __has_keyword(__is_member_object_pointer)
1135 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
1136 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
1138 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1139 template <class _Tp>
1140 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
1141 = is_member_object_pointer<_Tp>::value;
1144 #endif // __has_keyword(__is_member_object_pointer)
1148 #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
1150 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
1151 : public integral_constant<bool, __is_enum(_Tp)> {};
1153 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1154 template <class _Tp>
1155 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v = __is_enum(_Tp);
1160 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
1161 : public integral_constant<bool, !is_void<_Tp>::value &&
1162 !is_integral<_Tp>::value &&
1163 !is_floating_point<_Tp>::value &&
1164 !is_array<_Tp>::value &&
1165 !is_pointer<_Tp>::value &&
1166 !is_reference<_Tp>::value &&
1167 !is_member_pointer<_Tp>::value &&
1168 !is_union<_Tp>::value &&
1169 !is_class<_Tp>::value &&
1170 !is_function<_Tp>::value > {};
1172 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1173 template <class _Tp>
1174 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
1175 = is_enum<_Tp>::value;
1178 #endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
1183 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
1184 : public integral_constant<bool, is_integral<_Tp>::value ||
1185 is_floating_point<_Tp>::value> {};
1187 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1188 template <class _Tp>
1189 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
1190 = is_arithmetic<_Tp>::value;
1195 // In clang 9 and lower, this builtin did not work for nullptr_t. Additionally, in C++03 mode,
1196 // nullptr isn't defined by the compiler so, this builtin won't work.
1197 #if __has_keyword(__is_fundamental) && _LIBCPP_CLANG_VER > 900 && !defined(_LIBCPP_CXX03_LANG)
1200 struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
1202 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1203 template <class _Tp>
1204 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v = __is_fundamental(_Tp);
1207 #else // __has_keyword(__is_fundamental)
1209 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
1210 : public integral_constant<bool, is_void<_Tp>::value ||
1211 __is_nullptr_t<_Tp>::value ||
1212 is_arithmetic<_Tp>::value> {};
1214 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1215 template <class _Tp>
1216 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1217 = is_fundamental<_Tp>::value;
1220 #endif // __has_keyword(__is_fundamental)
1224 // >= 11 because in C++03 nullptr isn't actually nullptr
1225 #if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG)
1228 struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
1230 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1231 template <class _Tp>
1232 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v = __is_scalar(_Tp);
1235 #else // __has_keyword(__is_scalar)
1237 template <class _Tp> struct __is_block : false_type {};
1238 #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
1239 template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
1242 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1243 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1244 is_member_pointer<_Tp>::value ||
1245 is_pointer<_Tp>::value ||
1246 __is_nullptr_t<_Tp>::value ||
1247 __is_block<_Tp>::value ||
1248 is_enum<_Tp>::value > {};
1250 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1252 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1253 template <class _Tp>
1254 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1255 = is_scalar<_Tp>::value;
1258 #endif // __has_keyword(__is_scalar)
1262 #if __has_keyword(__is_object)
1265 struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
1267 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1268 template <class _Tp>
1269 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v = __is_object(_Tp);
1272 #else // __has_keyword(__is_object)
1274 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1275 : public integral_constant<bool, is_scalar<_Tp>::value ||
1276 is_array<_Tp>::value ||
1277 is_union<_Tp>::value ||
1278 is_class<_Tp>::value > {};
1280 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1281 template <class _Tp>
1282 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
1283 = is_object<_Tp>::value;
1286 #endif // __has_keyword(__is_object)
1290 // >= 11 because in C++03 nullptr isn't actually nullptr
1291 #if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG)
1294 struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
1296 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1297 template <class _Tp>
1298 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v = __is_compound(_Tp);
1301 #else // __has_keyword(__is_compound)
1303 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1304 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1306 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1307 template <class _Tp>
1308 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1309 = is_compound<_Tp>::value;
1312 #endif // __has_keyword(__is_compound)
1314 // __is_referenceable [defns.referenceable]
1316 struct __is_referenceable_impl {
1317 template <class _Tp> static _Tp& __test(int);
1318 template <class _Tp> static __two __test(...);
1321 template <class _Tp>
1322 struct __is_referenceable : integral_constant<bool,
1323 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1328 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
1329 typedef _LIBCPP_NODEBUG_TYPE const _Tp type;
1332 #if _LIBCPP_STD_VER > 11
1333 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1338 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
1339 typedef _LIBCPP_NODEBUG_TYPE volatile _Tp type;
1342 #if _LIBCPP_STD_VER > 11
1343 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1347 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
1348 typedef _LIBCPP_NODEBUG_TYPE const volatile _Tp type;
1351 #if _LIBCPP_STD_VER > 11
1352 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1357 #if __has_keyword(__remove_reference)
1360 struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) type; };
1362 #else // __has_keyword(__remove_reference)
1364 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1365 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1366 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1368 #if _LIBCPP_STD_VER > 11
1369 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1372 #endif // __has_keyword(__remove_reference)
1374 // add_lvalue_reference
1376 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1377 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; };
1379 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1380 {typedef _LIBCPP_NODEBUG_TYPE typename __add_lvalue_reference_impl<_Tp>::type type;};
1382 #if _LIBCPP_STD_VER > 11
1383 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1386 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1387 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; };
1389 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1390 {typedef _LIBCPP_NODEBUG_TYPE typename __add_rvalue_reference_impl<_Tp>::type type;};
1392 #if _LIBCPP_STD_VER > 11
1393 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1396 // Suppress deprecation notice for volatile-qualified return type resulting
1397 // from volatile-qualified types _Tp.
1398 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1399 template <class _Tp> _Tp&& __declval(int);
1400 template <class _Tp> _Tp __declval(long);
1401 _LIBCPP_SUPPRESS_DEPRECATED_POP
1403 template <class _Tp>
1404 decltype(_VSTD::__declval<_Tp>(0))
1405 declval() _NOEXCEPT;
1409 template <class _Tp>
1411 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1414 template <class _Tp>
1415 struct __unconstref {
1416 typedef _LIBCPP_NODEBUG_TYPE typename remove_const<typename remove_reference<_Tp>::type>::type type;
1419 #ifndef _LIBCPP_CXX03_LANG
1420 template <class _Tp>
1421 using __uncvref_t _LIBCPP_NODEBUG_TYPE = typename __uncvref<_Tp>::type;
1424 // __is_same_uncvref
1426 template <class _Tp, class _Up>
1427 struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
1428 typename __uncvref<_Up>::type> {};
1430 #if _LIBCPP_STD_VER > 17
1431 // remove_cvref - same as __uncvref
1432 template <class _Tp>
1433 struct remove_cvref : public __uncvref<_Tp> {};
1435 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1446 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1447 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1448 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1449 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1450 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1452 #if _LIBCPP_STD_VER > 11
1453 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1458 template <class _Tp,
1459 bool = __is_referenceable<_Tp>::value ||
1460 _IsSame<typename remove_cv<_Tp>::type, void>::value>
1461 struct __add_pointer_impl
1462 {typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type* type;};
1463 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1464 {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1466 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1467 {typedef _LIBCPP_NODEBUG_TYPE typename __add_pointer_impl<_Tp>::type type;};
1469 #if _LIBCPP_STD_VER > 11
1470 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1474 #if _LIBCPP_STD_VER > 17
1475 template<class _Tp> struct type_identity { typedef _Tp type; };
1476 template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
1481 // In clang 9 and earlier, this builtin did not work for floating points or enums
1482 #if __has_keyword(__is_signed) && _LIBCPP_CLANG_VER > 900
1485 struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
1487 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1488 template <class _Tp>
1489 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v = __is_signed(_Tp);
1492 #else // __has_keyword(__is_signed)
1494 template <class _Tp, bool = is_integral<_Tp>::value>
1495 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1497 template <class _Tp>
1498 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1500 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1501 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1503 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1505 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1507 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1508 template <class _Tp>
1509 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1510 = is_signed<_Tp>::value;
1513 #endif // __has_keyword(__is_signed)
1517 #if __has_keyword(__is_unsigned)
1520 struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
1522 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1523 template <class _Tp>
1524 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v = __is_unsigned(_Tp);
1527 #else // __has_keyword(__is_unsigned)
1529 template <class _Tp, bool = is_integral<_Tp>::value>
1530 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1532 template <class _Tp>
1533 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1535 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1536 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1538 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1540 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1542 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1543 template <class _Tp>
1544 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1545 = is_unsigned<_Tp>::value;
1548 #endif // __has_keyword(__is_unsigned)
1552 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1553 : public integral_constant<size_t, 0> {};
1554 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1555 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1556 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1557 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1559 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1560 template <class _Tp>
1561 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1567 #if __has_keyword(__array_extent)
1569 template<class _Tp, size_t _Dim = 0>
1570 struct _LIBCPP_TEMPLATE_VIS extent
1571 : integral_constant<size_t, __array_extent(_Tp, _Dim)> { };
1573 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1574 template <class _Tp, unsigned _Ip = 0>
1575 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v = __array_extent(_Tp, _Ip);
1578 #else // __has_keyword(__array_extent)
1580 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1581 : public integral_constant<size_t, 0> {};
1582 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1583 : public integral_constant<size_t, 0> {};
1584 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1585 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1586 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1587 : public integral_constant<size_t, _Np> {};
1588 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1589 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1591 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1592 template <class _Tp, unsigned _Ip = 0>
1593 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1594 = extent<_Tp, _Ip>::value;
1597 #endif // __has_keyword(__array_extent)
1601 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1602 {typedef _Tp type;};
1603 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1604 {typedef _Tp type;};
1605 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1606 {typedef _Tp type;};
1608 #if _LIBCPP_STD_VER > 11
1609 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1612 // remove_all_extents
1614 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1615 {typedef _Tp type;};
1616 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1617 {typedef typename remove_all_extents<_Tp>::type type;};
1618 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1619 {typedef typename remove_all_extents<_Tp>::type type;};
1621 #if _LIBCPP_STD_VER > 11
1622 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1625 #if _LIBCPP_STD_VER > 17
1628 template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
1629 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
1631 template <class _Tp>
1632 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1633 bool is_bounded_array_v = is_bounded_array<_Tp>::value;
1635 // is_unbounded_array
1637 template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
1638 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
1640 template <class _Tp>
1641 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1642 bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
1647 template <class _Up, bool>
1649 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<_Up>::type type;
1652 template <class _Up>
1653 struct __decay<_Up, true> {
1655 typedef _LIBCPP_NODEBUG_TYPE typename conditional
1657 is_array<_Up>::value,
1658 typename remove_extent<_Up>::type*,
1659 typename conditional
1661 is_function<_Up>::value,
1662 typename add_pointer<_Up>::type,
1663 typename remove_cv<_Up>::type
1668 template <class _Tp>
1669 struct _LIBCPP_TEMPLATE_VIS decay
1672 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
1674 typedef _LIBCPP_NODEBUG_TYPE typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1677 #if _LIBCPP_STD_VER > 11
1678 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1683 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1684 : public integral_constant<bool, __is_abstract(_Tp)> {};
1686 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1687 template <class _Tp>
1688 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1689 = is_abstract<_Tp>::value;
1694 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1695 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1697 #if _LIBCPP_STD_VER > 11
1698 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1699 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1702 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1703 template <class _Tp>
1704 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1705 = is_final<_Tp>::value;
1709 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1711 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1712 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1714 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1715 template <class _Tp>
1716 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1717 = is_aggregate<_Tp>::value;
1720 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1724 template <class _Bp, class _Dp>
1725 struct _LIBCPP_TEMPLATE_VIS is_base_of
1726 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1728 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1729 template <class _Bp, class _Dp>
1730 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1731 = is_base_of<_Bp, _Dp>::value;
1736 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1738 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1739 : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
1741 #else // __has_feature(is_convertible_to)
1743 namespace __is_convertible_imp
1745 template <class _Tp> void __test_convert(_Tp);
1747 template <class _From, class _To, class = void>
1748 struct __is_convertible_test : public false_type {};
1750 template <class _From, class _To>
1751 struct __is_convertible_test<_From, _To,
1752 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1755 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1756 bool _IsFunction = is_function<_Tp>::value,
1757 bool _IsVoid = is_void<_Tp>::value>
1758 struct __is_array_function_or_void {enum {value = 0};};
1759 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1760 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1761 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1764 template <class _Tp,
1765 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1766 struct __is_convertible_check
1768 static const size_t __v = 0;
1771 template <class _Tp>
1772 struct __is_convertible_check<_Tp, 0>
1774 static const size_t __v = sizeof(_Tp);
1777 template <class _T1, class _T2,
1778 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1779 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1780 struct __is_convertible
1781 : public integral_constant<bool,
1782 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1786 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1787 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1788 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1789 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1791 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1792 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1793 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1794 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1796 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1797 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1798 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1799 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1801 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1802 : public __is_convertible<_T1, _T2>
1804 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1805 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1808 #endif // __has_feature(is_convertible_to)
1810 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1811 template <class _From, class _To>
1812 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1813 = is_convertible<_From, _To>::value;
1816 // is_nothrow_convertible
1818 #if _LIBCPP_STD_VER > 17
1820 template <typename _Tp>
1821 static void __test_noexcept(_Tp) noexcept;
1823 template<typename _Fm, typename _To>
1824 static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))>
1825 __is_nothrow_convertible_test();
1827 template <typename _Fm, typename _To>
1828 struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
1831 template <typename _Fm, typename _To>
1832 struct is_nothrow_convertible : _Or<
1833 _And<is_void<_To>, is_void<_Fm>>,
1834 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
1837 template <typename _Fm, typename _To>
1838 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
1840 #endif // _LIBCPP_STD_VER > 17
1844 #if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
1846 template <class _Tp>
1847 struct _LIBCPP_TEMPLATE_VIS is_empty
1848 : public integral_constant<bool, __is_empty(_Tp)> {};
1850 #else // __has_feature(is_empty)
1852 template <class _Tp>
1864 template <class _Tp, bool = is_class<_Tp>::value>
1865 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1867 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1869 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1871 #endif // __has_feature(is_empty)
1873 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1874 template <class _Tp>
1875 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1876 = is_empty<_Tp>::value;
1881 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1883 template <class _Tp>
1884 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1885 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1889 template<typename _Tp> char &__is_polymorphic_impl(
1890 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1892 template<typename _Tp> __two &__is_polymorphic_impl(...);
1894 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1895 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1897 #endif // __has_feature(is_polymorphic)
1899 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1900 template <class _Tp>
1901 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1902 = is_polymorphic<_Tp>::value;
1905 // has_virtual_destructor
1907 #if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
1909 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1910 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1914 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1915 : public false_type {};
1919 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1920 template <class _Tp>
1921 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1922 = has_virtual_destructor<_Tp>::value;
1925 // has_unique_object_representations
1927 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1929 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1930 : public integral_constant<bool,
1931 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1933 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1934 template <class _Tp>
1935 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1936 = has_unique_object_representations<_Tp>::value;
1943 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1944 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
1946 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1947 template <class _Tp>
1948 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1949 = alignment_of<_Tp>::value;
1954 template <class _Hp, class _Tp>
1963 #ifndef _LIBCPP_CXX03_LANG
1965 __nat(const __nat&) = delete;
1966 __nat& operator=(const __nat&) = delete;
1971 template <class _Tp>
1974 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
1978 struct __struct_double {long double __lx;};
1979 struct __struct_double4 {double __lx[4];};
1982 __type_list<__align_type<unsigned char>,
1983 __type_list<__align_type<unsigned short>,
1984 __type_list<__align_type<unsigned int>,
1985 __type_list<__align_type<unsigned long>,
1986 __type_list<__align_type<unsigned long long>,
1987 __type_list<__align_type<double>,
1988 __type_list<__align_type<long double>,
1989 __type_list<__align_type<__struct_double>,
1990 __type_list<__align_type<__struct_double4>,
1991 __type_list<__align_type<int*>,
1993 > > > > > > > > > > __all_types;
1995 template <size_t _Align>
1996 struct _ALIGNAS(_Align) __fallback_overaligned {};
1998 template <class _TL, size_t _Align> struct __find_pod;
2000 template <class _Hp, size_t _Align>
2001 struct __find_pod<__type_list<_Hp, __nat>, _Align>
2003 typedef typename conditional<
2004 _Align == _Hp::value,
2006 __fallback_overaligned<_Align>
2010 template <class _Hp, class _Tp, size_t _Align>
2011 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
2013 typedef typename conditional<
2014 _Align == _Hp::value,
2016 typename __find_pod<_Tp, _Align>::type
2020 template <class _TL, size_t _Len> struct __find_max_align;
2022 template <class _Hp, size_t _Len>
2023 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
2025 template <size_t _Len, size_t _A1, size_t _A2>
2026 struct __select_align
2029 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
2030 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
2032 static const size_t value = _Len < __max ? __min : __max;
2035 template <class _Hp, class _Tp, size_t _Len>
2036 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
2037 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
2039 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
2040 struct _LIBCPP_TEMPLATE_VIS aligned_storage
2042 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
2046 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
2050 #if _LIBCPP_STD_VER > 11
2051 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
2052 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
2055 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
2056 template <size_t _Len>\
2057 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
2059 struct _ALIGNAS(n) type\
2061 unsigned char __lx[(_Len + n - 1)/n * n];\
2065 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
2066 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
2067 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
2068 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
2069 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
2070 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
2071 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
2072 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
2073 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
2074 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
2075 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
2076 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
2077 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
2078 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
2079 // PE/COFF does not support alignment beyond 8192 (=0x2000)
2080 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
2081 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
2082 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
2084 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
2089 template <size_t _I0, size_t ..._In>
2090 struct __static_max;
2092 template <size_t _I0>
2093 struct __static_max<_I0>
2095 static const size_t value = _I0;
2098 template <size_t _I0, size_t _I1, size_t ..._In>
2099 struct __static_max<_I0, _I1, _In...>
2101 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
2102 __static_max<_I1, _In...>::value;
2105 template <size_t _Len, class _Type0, class ..._Types>
2106 struct aligned_union
2108 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
2109 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
2110 static const size_t __len = __static_max<_Len, sizeof(_Type0),
2111 sizeof(_Types)...>::value;
2112 typedef typename aligned_storage<__len, alignment_value>::type type;
2115 #if _LIBCPP_STD_VER > 11
2116 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2119 template <class _Tp>
2120 struct __numeric_type
2122 static void __test(...);
2123 static float __test(float);
2124 static double __test(char);
2125 static double __test(int);
2126 static double __test(unsigned);
2127 static double __test(long);
2128 static double __test(unsigned long);
2129 static double __test(long long);
2130 static double __test(unsigned long long);
2131 static double __test(double);
2132 static long double __test(long double);
2134 typedef decltype(__test(declval<_Tp>())) type;
2135 static const bool value = _IsNotSame<type, void>::value;
2139 struct __numeric_type<void>
2141 static const bool value = true;
2146 template <class _A1, class _A2 = void, class _A3 = void,
2147 bool = __numeric_type<_A1>::value &&
2148 __numeric_type<_A2>::value &&
2149 __numeric_type<_A3>::value>
2153 static const bool value = false;
2156 template <class _A1, class _A2, class _A3>
2157 class __promote_imp<_A1, _A2, _A3, true>
2160 typedef typename __promote_imp<_A1>::type __type1;
2161 typedef typename __promote_imp<_A2>::type __type2;
2162 typedef typename __promote_imp<_A3>::type __type3;
2164 typedef decltype(__type1() + __type2() + __type3()) type;
2165 static const bool value = true;
2168 template <class _A1, class _A2>
2169 class __promote_imp<_A1, _A2, void, true>
2172 typedef typename __promote_imp<_A1>::type __type1;
2173 typedef typename __promote_imp<_A2>::type __type2;
2175 typedef decltype(__type1() + __type2()) type;
2176 static const bool value = true;
2179 template <class _A1>
2180 class __promote_imp<_A1, void, void, true>
2183 typedef typename __numeric_type<_A1>::type type;
2184 static const bool value = true;
2187 template <class _A1, class _A2 = void, class _A3 = void>
2188 class __promote : public __promote_imp<_A1, _A2, _A3> {};
2190 // make_signed / make_unsigned
2193 __type_list<signed char,
2194 __type_list<signed short,
2195 __type_list<signed int,
2196 __type_list<signed long,
2197 __type_list<signed long long,
2198 #ifndef _LIBCPP_HAS_NO_INT128
2199 __type_list<__int128_t,
2202 #ifndef _LIBCPP_HAS_NO_INT128
2205 > > > > > __signed_types;
2208 __type_list<unsigned char,
2209 __type_list<unsigned short,
2210 __type_list<unsigned int,
2211 __type_list<unsigned long,
2212 __type_list<unsigned long long,
2213 #ifndef _LIBCPP_HAS_NO_INT128
2214 __type_list<__uint128_t,
2217 #ifndef _LIBCPP_HAS_NO_INT128
2220 > > > > > __unsigned_types;
2222 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
2224 template <class _Hp, class _Tp, size_t _Size>
2225 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
2227 typedef _LIBCPP_NODEBUG_TYPE _Hp type;
2230 template <class _Hp, class _Tp, size_t _Size>
2231 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
2233 typedef _LIBCPP_NODEBUG_TYPE typename __find_first<_Tp, _Size>::type type;
2236 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
2237 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
2240 typedef _LIBCPP_NODEBUG_TYPE _Up type;
2243 template <class _Tp, class _Up>
2244 struct __apply_cv<_Tp, _Up, true, false>
2246 typedef _LIBCPP_NODEBUG_TYPE const _Up type;
2249 template <class _Tp, class _Up>
2250 struct __apply_cv<_Tp, _Up, false, true>
2252 typedef volatile _Up type;
2255 template <class _Tp, class _Up>
2256 struct __apply_cv<_Tp, _Up, true, true>
2258 typedef const volatile _Up type;
2261 template <class _Tp, class _Up>
2262 struct __apply_cv<_Tp&, _Up, false, false>
2267 template <class _Tp, class _Up>
2268 struct __apply_cv<_Tp&, _Up, true, false>
2270 typedef const _Up& type;
2273 template <class _Tp, class _Up>
2274 struct __apply_cv<_Tp&, _Up, false, true>
2276 typedef volatile _Up& type;
2279 template <class _Tp, class _Up>
2280 struct __apply_cv<_Tp&, _Up, true, true>
2282 typedef const volatile _Up& type;
2285 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2286 struct __make_signed {};
2288 template <class _Tp>
2289 struct __make_signed<_Tp, true>
2291 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
2294 template <> struct __make_signed<bool, true> {};
2295 template <> struct __make_signed< signed short, true> {typedef short type;};
2296 template <> struct __make_signed<unsigned short, true> {typedef short type;};
2297 template <> struct __make_signed< signed int, true> {typedef int type;};
2298 template <> struct __make_signed<unsigned int, true> {typedef int type;};
2299 template <> struct __make_signed< signed long, true> {typedef long type;};
2300 template <> struct __make_signed<unsigned long, true> {typedef long type;};
2301 template <> struct __make_signed< signed long long, true> {typedef long long type;};
2302 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2303 #ifndef _LIBCPP_HAS_NO_INT128
2304 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2305 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2308 template <class _Tp>
2309 struct _LIBCPP_TEMPLATE_VIS make_signed
2311 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2314 #if _LIBCPP_STD_VER > 11
2315 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2318 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2319 struct __make_unsigned {};
2321 template <class _Tp>
2322 struct __make_unsigned<_Tp, true>
2324 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2327 template <> struct __make_unsigned<bool, true> {};
2328 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2329 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2330 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2331 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2332 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2333 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2334 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2335 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2336 #ifndef _LIBCPP_HAS_NO_INT128
2337 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2338 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2341 template <class _Tp>
2342 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2344 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2347 #if _LIBCPP_STD_VER > 11
2348 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2351 #if _LIBCPP_STD_VER > 14
2352 template <class...> using void_t = void;
2355 #if _LIBCPP_STD_VER > 17
2356 // Let COND_RES(X, Y) be:
2357 template <class _Tp, class _Up>
2358 using __cond_type = decltype(false ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>());
2360 template <class _Tp, class _Up, class = void>
2361 struct __common_type3 {};
2363 // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
2364 template <class _Tp, class _Up>
2365 struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
2367 using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
2370 template <class _Tp, class _Up, class = void>
2371 struct __common_type2_imp : __common_type3<_Tp, _Up> {};
2373 template <class _Tp, class _Up, class = void>
2374 struct __common_type2_imp {};
2377 // sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
2378 template <class _Tp, class _Up>
2379 struct __common_type2_imp<_Tp, _Up,
2380 typename __void_t<decltype(
2381 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2384 typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype(
2385 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2389 template <class, class = void>
2390 struct __common_type_impl {};
2392 // Clang provides variadic templates in C++03 as an extension.
2393 #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
2394 # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
2395 template <class... Tp>
2396 struct __common_types;
2397 template <class... _Tp>
2398 struct _LIBCPP_TEMPLATE_VIS common_type;
2400 # define _LIBCPP_OPTIONAL_PACK(...)
2402 template <class _Tp, class _Up, class = __no_arg>
2403 struct __common_types;
2404 template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
2405 class _Unused = __no_arg>
2406 struct common_type {
2407 static_assert(sizeof(_Unused) == 0,
2408 "common_type accepts at most 3 arguments in C++03");
2410 #endif // _LIBCPP_CXX03_LANG
2412 template <class _Tp, class _Up>
2413 struct __common_type_impl<
2414 __common_types<_Tp, _Up>,
2415 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2417 typedef typename common_type<_Tp, _Up>::type type;
2420 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2421 struct __common_type_impl<
2422 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
2423 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2424 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
2425 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
2428 // bullet 1 - sizeof...(Tp) == 0
2431 struct _LIBCPP_TEMPLATE_VIS common_type<> {};
2433 // bullet 2 - sizeof...(Tp) == 1
2435 template <class _Tp>
2436 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2437 : public common_type<_Tp, _Tp> {};
2439 // bullet 3 - sizeof...(Tp) == 2
2441 // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
2442 template <class _Tp, class _Up>
2443 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2445 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
2446 __common_type2_imp<_Tp, _Up>,
2447 common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
2451 // bullet 4 - sizeof...(Tp) > 2
2453 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2454 struct _LIBCPP_TEMPLATE_VIS
2455 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
2456 : __common_type_impl<
2457 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
2459 #undef _LIBCPP_OPTIONAL_PACK
2461 #if _LIBCPP_STD_VER > 11
2462 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2467 template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
2469 #if __has_keyword(__is_assignable)
2471 template<class _Tp, class _Up>
2472 struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
2474 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2475 template <class _Tp, class _Arg>
2476 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v = __is_assignable(_Tp, _Arg);
2479 #else // __has_keyword(__is_assignable)
2481 template <class _Tp, class _Arg>
2482 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2483 __is_assignable_test(int);
2485 template <class, class>
2486 false_type __is_assignable_test(...);
2489 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2490 struct __is_assignable_imp
2491 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2493 template <class _Tp, class _Arg>
2494 struct __is_assignable_imp<_Tp, _Arg, true>
2499 template <class _Tp, class _Arg>
2500 struct is_assignable
2501 : public __is_assignable_imp<_Tp, _Arg> {};
2503 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2504 template <class _Tp, class _Arg>
2505 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2506 = is_assignable<_Tp, _Arg>::value;
2509 #endif // __has_keyword(__is_assignable)
2511 // is_copy_assignable
2513 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2514 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2515 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2517 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2518 template <class _Tp>
2519 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2520 = is_copy_assignable<_Tp>::value;
2523 // is_move_assignable
2525 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2526 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2527 typename add_rvalue_reference<_Tp>::type> {};
2529 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2530 template <class _Tp>
2531 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2532 = is_move_assignable<_Tp>::value;
2537 #if __has_keyword(__is_destructible)
2540 struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
2542 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2543 template <class _Tp>
2544 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v = __is_destructible(_Tp);
2547 #else // __has_keyword(__is_destructible)
2549 // if it's a reference, return true
2550 // if it's a function, return false
2551 // if it's void, return false
2552 // if it's an array of unknown bound, return false
2553 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2554 // where _Up is remove_all_extents<_Tp>::type
2557 struct __is_destructible_apply { typedef int type; };
2559 template <typename _Tp>
2560 struct __is_destructor_wellformed {
2561 template <typename _Tp1>
2562 static char __test (
2563 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2566 template <typename _Tp1>
2567 static __two __test (...);
2569 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2572 template <class _Tp, bool>
2573 struct __destructible_imp;
2575 template <class _Tp>
2576 struct __destructible_imp<_Tp, false>
2577 : public _VSTD::integral_constant<bool,
2578 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2580 template <class _Tp>
2581 struct __destructible_imp<_Tp, true>
2582 : public _VSTD::true_type {};
2584 template <class _Tp, bool>
2585 struct __destructible_false;
2587 template <class _Tp>
2588 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2590 template <class _Tp>
2591 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2593 template <class _Tp>
2594 struct is_destructible
2595 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2597 template <class _Tp>
2598 struct is_destructible<_Tp[]>
2599 : public _VSTD::false_type {};
2602 struct is_destructible<void>
2603 : public _VSTD::false_type {};
2605 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2606 template <class _Tp>
2607 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2608 = is_destructible<_Tp>::value;
2611 #endif // __has_keyword(__is_destructible)
2615 template <class _Tp>
2616 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2617 typename remove_reference<_Tp>::type&&
2618 move(_Tp&& __t) _NOEXCEPT
2620 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
2621 return static_cast<_Up&&>(__t);
2624 template <class _Tp>
2625 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2627 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2629 return static_cast<_Tp&&>(__t);
2632 template <class _Tp>
2633 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2635 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2637 static_assert(!is_lvalue_reference<_Tp>::value,
2638 "can not forward an rvalue as an lvalue");
2639 return static_cast<_Tp&&>(__t);
2642 template <class _Tp>
2643 inline _LIBCPP_INLINE_VISIBILITY
2644 typename decay<_Tp>::type
2645 __decay_copy(_Tp&& __t)
2647 return _VSTD::forward<_Tp>(__t);
2650 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
2651 struct __member_pointer_traits_imp
2655 template <class _Rp, class _Class, class ..._Param>
2656 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2658 typedef _Class _ClassType;
2659 typedef _Rp _ReturnType;
2660 typedef _Rp (_FnType) (_Param...);
2663 template <class _Rp, class _Class, class ..._Param>
2664 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2666 typedef _Class _ClassType;
2667 typedef _Rp _ReturnType;
2668 typedef _Rp (_FnType) (_Param..., ...);
2671 template <class _Rp, class _Class, class ..._Param>
2672 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2674 typedef _Class const _ClassType;
2675 typedef _Rp _ReturnType;
2676 typedef _Rp (_FnType) (_Param...);
2679 template <class _Rp, class _Class, class ..._Param>
2680 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2682 typedef _Class const _ClassType;
2683 typedef _Rp _ReturnType;
2684 typedef _Rp (_FnType) (_Param..., ...);
2687 template <class _Rp, class _Class, class ..._Param>
2688 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2690 typedef _Class volatile _ClassType;
2691 typedef _Rp _ReturnType;
2692 typedef _Rp (_FnType) (_Param...);
2695 template <class _Rp, class _Class, class ..._Param>
2696 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2698 typedef _Class volatile _ClassType;
2699 typedef _Rp _ReturnType;
2700 typedef _Rp (_FnType) (_Param..., ...);
2703 template <class _Rp, class _Class, class ..._Param>
2704 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2706 typedef _Class const volatile _ClassType;
2707 typedef _Rp _ReturnType;
2708 typedef _Rp (_FnType) (_Param...);
2711 template <class _Rp, class _Class, class ..._Param>
2712 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2714 typedef _Class const volatile _ClassType;
2715 typedef _Rp _ReturnType;
2716 typedef _Rp (_FnType) (_Param..., ...);
2719 #if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2721 template <class _Rp, class _Class, class ..._Param>
2722 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2724 typedef _Class& _ClassType;
2725 typedef _Rp _ReturnType;
2726 typedef _Rp (_FnType) (_Param...);
2729 template <class _Rp, class _Class, class ..._Param>
2730 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2732 typedef _Class& _ClassType;
2733 typedef _Rp _ReturnType;
2734 typedef _Rp (_FnType) (_Param..., ...);
2737 template <class _Rp, class _Class, class ..._Param>
2738 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2740 typedef _Class const& _ClassType;
2741 typedef _Rp _ReturnType;
2742 typedef _Rp (_FnType) (_Param...);
2745 template <class _Rp, class _Class, class ..._Param>
2746 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2748 typedef _Class const& _ClassType;
2749 typedef _Rp _ReturnType;
2750 typedef _Rp (_FnType) (_Param..., ...);
2753 template <class _Rp, class _Class, class ..._Param>
2754 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2756 typedef _Class volatile& _ClassType;
2757 typedef _Rp _ReturnType;
2758 typedef _Rp (_FnType) (_Param...);
2761 template <class _Rp, class _Class, class ..._Param>
2762 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2764 typedef _Class volatile& _ClassType;
2765 typedef _Rp _ReturnType;
2766 typedef _Rp (_FnType) (_Param..., ...);
2769 template <class _Rp, class _Class, class ..._Param>
2770 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2772 typedef _Class const volatile& _ClassType;
2773 typedef _Rp _ReturnType;
2774 typedef _Rp (_FnType) (_Param...);
2777 template <class _Rp, class _Class, class ..._Param>
2778 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2780 typedef _Class const volatile& _ClassType;
2781 typedef _Rp _ReturnType;
2782 typedef _Rp (_FnType) (_Param..., ...);
2785 template <class _Rp, class _Class, class ..._Param>
2786 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2788 typedef _Class&& _ClassType;
2789 typedef _Rp _ReturnType;
2790 typedef _Rp (_FnType) (_Param...);
2793 template <class _Rp, class _Class, class ..._Param>
2794 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2796 typedef _Class&& _ClassType;
2797 typedef _Rp _ReturnType;
2798 typedef _Rp (_FnType) (_Param..., ...);
2801 template <class _Rp, class _Class, class ..._Param>
2802 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2804 typedef _Class const&& _ClassType;
2805 typedef _Rp _ReturnType;
2806 typedef _Rp (_FnType) (_Param...);
2809 template <class _Rp, class _Class, class ..._Param>
2810 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2812 typedef _Class const&& _ClassType;
2813 typedef _Rp _ReturnType;
2814 typedef _Rp (_FnType) (_Param..., ...);
2817 template <class _Rp, class _Class, class ..._Param>
2818 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2820 typedef _Class volatile&& _ClassType;
2821 typedef _Rp _ReturnType;
2822 typedef _Rp (_FnType) (_Param...);
2825 template <class _Rp, class _Class, class ..._Param>
2826 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2828 typedef _Class volatile&& _ClassType;
2829 typedef _Rp _ReturnType;
2830 typedef _Rp (_FnType) (_Param..., ...);
2833 template <class _Rp, class _Class, class ..._Param>
2834 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2836 typedef _Class const volatile&& _ClassType;
2837 typedef _Rp _ReturnType;
2838 typedef _Rp (_FnType) (_Param...);
2841 template <class _Rp, class _Class, class ..._Param>
2842 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2844 typedef _Class const volatile&& _ClassType;
2845 typedef _Rp _ReturnType;
2846 typedef _Rp (_FnType) (_Param..., ...);
2849 #endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2852 template <class _Rp, class _Class>
2853 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2855 typedef _Class _ClassType;
2856 typedef _Rp _ReturnType;
2859 template <class _MP>
2860 struct __member_pointer_traits
2861 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2862 is_member_function_pointer<_MP>::value,
2863 is_member_object_pointer<_MP>::value>
2865 // typedef ... _ClassType;
2866 // typedef ... _ReturnType;
2867 // typedef ... _FnType;
2871 template <class _DecayedFp>
2872 struct __member_pointer_class_type {};
2874 template <class _Ret, class _ClassType>
2875 struct __member_pointer_class_type<_Ret _ClassType::*> {
2876 typedef _ClassType type;
2881 template <class _Callable> class result_of;
2883 #ifdef _LIBCPP_HAS_NO_VARIADICS
2885 template <class _Fn, bool, bool>
2890 template <class _Fn>
2891 class __result_of<_Fn(), true, false>
2894 typedef decltype(declval<_Fn>()()) type;
2897 template <class _Fn, class _A0>
2898 class __result_of<_Fn(_A0), true, false>
2901 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2904 template <class _Fn, class _A0, class _A1>
2905 class __result_of<_Fn(_A0, _A1), true, false>
2908 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2911 template <class _Fn, class _A0, class _A1, class _A2>
2912 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2915 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2918 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2919 struct __result_of_mp;
2921 // member function pointer
2923 template <class _MP, class _Tp>
2924 struct __result_of_mp<_MP, _Tp, true>
2925 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2929 // member data pointer
2931 template <class _MP, class _Tp, bool>
2932 struct __result_of_mdp;
2934 template <class _Rp, class _Class, class _Tp>
2935 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2937 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2940 template <class _Rp, class _Class, class _Tp>
2941 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2943 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2946 template <class _Rp, class _Class, class _Tp>
2947 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2948 : public __result_of_mdp<_Rp _Class::*, _Tp,
2949 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2955 template <class _Fn, class _Tp>
2956 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2957 : public __result_of_mp<typename remove_reference<_Fn>::type,
2959 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2963 template <class _Fn, class _Tp, class _A0>
2964 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2965 : public __result_of_mp<typename remove_reference<_Fn>::type,
2967 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2971 template <class _Fn, class _Tp, class _A0, class _A1>
2972 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2973 : public __result_of_mp<typename remove_reference<_Fn>::type,
2975 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2979 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2980 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2981 : public __result_of_mp<typename remove_reference<_Fn>::type,
2983 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2989 template <class _Fn>
2990 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2991 : public __result_of<_Fn(),
2992 is_class<typename remove_reference<_Fn>::type>::value ||
2993 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2994 is_member_pointer<typename remove_reference<_Fn>::type>::value
2999 template <class _Fn, class _A0>
3000 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
3001 : public __result_of<_Fn(_A0),
3002 is_class<typename remove_reference<_Fn>::type>::value ||
3003 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3004 is_member_pointer<typename remove_reference<_Fn>::type>::value
3009 template <class _Fn, class _A0, class _A1>
3010 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
3011 : public __result_of<_Fn(_A0, _A1),
3012 is_class<typename remove_reference<_Fn>::type>::value ||
3013 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3014 is_member_pointer<typename remove_reference<_Fn>::type>::value
3019 template <class _Fn, class _A0, class _A1, class _A2>
3020 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
3021 : public __result_of<_Fn(_A0, _A1, _A2),
3022 is_class<typename remove_reference<_Fn>::type>::value ||
3023 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
3024 is_member_pointer<typename remove_reference<_Fn>::type>::value
3029 #endif // _LIBCPP_HAS_NO_VARIADICS
3031 // template <class T, class... Args> struct is_constructible;
3033 namespace __is_construct
3038 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
3039 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
3041 template <class _Tp, class... _Args>
3042 struct __libcpp_is_constructible;
3044 template <class _To, class _From>
3045 struct __is_invalid_base_to_derived_cast {
3046 static_assert(is_reference<_To>::value, "Wrong specialization");
3047 using _RawFrom = __uncvref_t<_From>;
3048 using _RawTo = __uncvref_t<_To>;
3049 static const bool value = _And<
3050 _IsNotSame<_RawFrom, _RawTo>,
3051 is_base_of<_RawFrom, _RawTo>,
3052 _Not<__libcpp_is_constructible<_RawTo, _From>>
3056 template <class _To, class _From>
3057 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
3058 static_assert(is_reference<_To>::value, "Wrong specialization");
3061 template <class _ToRef, class _FromRef>
3062 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
3063 using _RawFrom = __uncvref_t<_FromRef>;
3064 using _RawTo = __uncvref_t<_ToRef>;
3065 static const bool value = _And<
3066 _Not<is_function<_RawTo>>,
3068 _IsSame<_RawFrom, _RawTo>,
3069 is_base_of<_RawTo, _RawFrom>>
3073 struct __is_constructible_helper
3075 template <class _To>
3076 static void __eat(_To);
3078 // This overload is needed to work around a Clang bug that disallows
3079 // static_cast<T&&>(e) for non-reference-compatible types.
3080 // Example: static_cast<int&&>(declval<double>());
3081 // NOTE: The static_cast implementation below is required to support
3082 // classes with explicit conversion operators.
3083 template <class _To, class _From,
3084 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
3085 static true_type __test_cast(int);
3087 template <class _To, class _From,
3088 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
3089 static integral_constant<bool,
3090 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
3091 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
3092 > __test_cast(long);
3094 template <class, class>
3095 static false_type __test_cast(...);
3097 template <class _Tp, class ..._Args,
3098 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
3099 static true_type __test_nary(int);
3100 template <class _Tp, class...>
3101 static false_type __test_nary(...);
3103 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
3104 static is_destructible<_Tp> __test_unary(int);
3105 template <class, class>
3106 static false_type __test_unary(...);
3109 template <class _Tp, bool = is_void<_Tp>::value>
3110 struct __is_default_constructible
3111 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
3114 template <class _Tp>
3115 struct __is_default_constructible<_Tp, true> : false_type {};
3117 template <class _Tp>
3118 struct __is_default_constructible<_Tp[], false> : false_type {};
3120 template <class _Tp, size_t _Nx>
3121 struct __is_default_constructible<_Tp[_Nx], false>
3122 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3124 template <class _Tp, class... _Args>
3125 struct __libcpp_is_constructible
3127 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3128 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3132 template <class _Tp>
3133 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3135 template <class _Tp, class _A0>
3136 struct __libcpp_is_constructible<_Tp, _A0>
3137 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3140 template <class _Tp, class _A0>
3141 struct __libcpp_is_constructible<_Tp&, _A0>
3142 : public decltype(__is_constructible_helper::
3143 __test_cast<_Tp&, _A0>(0))
3146 template <class _Tp, class _A0>
3147 struct __libcpp_is_constructible<_Tp&&, _A0>
3148 : public decltype(__is_constructible_helper::
3149 __test_cast<_Tp&&, _A0>(0))
3154 #if __has_feature(is_constructible)
3155 template <class _Tp, class ..._Args>
3156 struct _LIBCPP_TEMPLATE_VIS is_constructible
3157 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3160 template <class _Tp, class... _Args>
3161 struct _LIBCPP_TEMPLATE_VIS is_constructible
3162 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3165 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3166 template <class _Tp, class ..._Args>
3167 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
3168 = is_constructible<_Tp, _Args...>::value;
3171 // is_default_constructible
3173 template <class _Tp>
3174 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3175 : public is_constructible<_Tp>
3178 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3179 template <class _Tp>
3180 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
3181 = is_default_constructible<_Tp>::value;
3184 #ifndef _LIBCPP_CXX03_LANG
3185 // First of all, we can't implement this check in C++03 mode because the {}
3186 // default initialization syntax isn't valid.
3187 // Second, we implement the trait in a funny manner with two defaulted template
3188 // arguments to workaround Clang's PR43454.
3189 template <class _Tp>
3190 void __test_implicit_default_constructible(_Tp);
3192 template <class _Tp, class = void, bool = is_default_constructible<_Tp>::value>
3193 struct __is_implicitly_default_constructible
3197 template <class _Tp>
3198 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true>
3202 template <class _Tp>
3203 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false>
3208 // is_copy_constructible
3210 template <class _Tp>
3211 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3212 : public is_constructible<_Tp,
3213 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3215 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3216 template <class _Tp>
3217 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3218 = is_copy_constructible<_Tp>::value;
3221 // is_move_constructible
3223 template <class _Tp>
3224 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3225 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3228 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3229 template <class _Tp>
3230 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
3231 = is_move_constructible<_Tp>::value;
3234 // is_trivially_constructible
3236 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3238 template <class _Tp, class... _Args>
3239 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3240 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3244 #else // !__has_feature(is_trivially_constructible)
3246 template <class _Tp, class... _Args>
3247 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3252 template <class _Tp>
3253 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3254 #if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC)
3255 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3257 : integral_constant<bool, is_scalar<_Tp>::value>
3262 template <class _Tp>
3263 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3264 : integral_constant<bool, is_scalar<_Tp>::value>
3268 template <class _Tp>
3269 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3270 : integral_constant<bool, is_scalar<_Tp>::value>
3274 template <class _Tp>
3275 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3276 : integral_constant<bool, is_scalar<_Tp>::value>
3280 #endif // !__has_feature(is_trivially_constructible)
3283 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3284 template <class _Tp, class... _Args>
3285 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3286 = is_trivially_constructible<_Tp, _Args...>::value;
3289 // is_trivially_default_constructible
3291 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3292 : public is_trivially_constructible<_Tp>
3295 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3296 template <class _Tp>
3297 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3298 = is_trivially_default_constructible<_Tp>::value;
3301 // is_trivially_copy_constructible
3303 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3304 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3307 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3308 template <class _Tp>
3309 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3310 = is_trivially_copy_constructible<_Tp>::value;
3313 // is_trivially_move_constructible
3315 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3316 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3319 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3320 template <class _Tp>
3321 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3322 = is_trivially_move_constructible<_Tp>::value;
3325 // is_trivially_assignable
3327 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3329 template <class _Tp, class _Arg>
3330 struct is_trivially_assignable
3331 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3335 #else // !__has_feature(is_trivially_assignable)
3337 template <class _Tp, class _Arg>
3338 struct is_trivially_assignable
3339 : public false_type {};
3341 template <class _Tp>
3342 struct is_trivially_assignable<_Tp&, _Tp>
3343 : integral_constant<bool, is_scalar<_Tp>::value> {};
3345 template <class _Tp>
3346 struct is_trivially_assignable<_Tp&, _Tp&>
3347 : integral_constant<bool, is_scalar<_Tp>::value> {};
3349 template <class _Tp>
3350 struct is_trivially_assignable<_Tp&, const _Tp&>
3351 : integral_constant<bool, is_scalar<_Tp>::value> {};
3353 template <class _Tp>
3354 struct is_trivially_assignable<_Tp&, _Tp&&>
3355 : integral_constant<bool, is_scalar<_Tp>::value> {};
3357 #endif // !__has_feature(is_trivially_assignable)
3359 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3360 template <class _Tp, class _Arg>
3361 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3362 = is_trivially_assignable<_Tp, _Arg>::value;
3365 // is_trivially_copy_assignable
3367 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3368 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3369 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3371 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3372 template <class _Tp>
3373 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3374 = is_trivially_copy_assignable<_Tp>::value;
3377 // is_trivially_move_assignable
3379 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3380 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3381 typename add_rvalue_reference<_Tp>::type>
3384 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3385 template <class _Tp>
3386 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3387 = is_trivially_move_assignable<_Tp>::value;
3390 // is_trivially_destructible
3392 #if __has_keyword(__is_trivially_destructible)
3394 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3395 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
3397 #elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
3399 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3400 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3404 template <class _Tp> struct __libcpp_trivial_destructor
3405 : public integral_constant<bool, is_scalar<_Tp>::value ||
3406 is_reference<_Tp>::value> {};
3408 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3409 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3411 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3412 : public false_type {};
3416 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3417 template <class _Tp>
3418 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3419 = is_trivially_destructible<_Tp>::value;
3422 // is_nothrow_constructible
3424 #if __has_keyword(__is_nothrow_constructible)
3426 template <class _Tp, class... _Args>
3427 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3428 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
3432 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3434 template <class _Tp, class... _Args>
3435 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3436 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3440 template <class _Tp>
3441 void __implicit_conversion_to(_Tp) noexcept { }
3443 template <class _Tp, class _Arg>
3444 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3445 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3449 template <class _Tp, bool _IsReference, class... _Args>
3450 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3455 template <class _Tp, class... _Args>
3456 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3457 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3461 template <class _Tp, size_t _Ns>
3462 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3463 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3467 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3470 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3471 template <class _Tp, class ..._Args>
3472 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3473 = is_nothrow_constructible<_Tp, _Args...>::value;
3476 // is_nothrow_default_constructible
3478 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3479 : public is_nothrow_constructible<_Tp>
3482 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3483 template <class _Tp>
3484 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3485 = is_nothrow_default_constructible<_Tp>::value;
3488 // is_nothrow_copy_constructible
3490 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3491 : public is_nothrow_constructible<_Tp,
3492 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3494 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3495 template <class _Tp>
3496 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3497 = is_nothrow_copy_constructible<_Tp>::value;
3500 // is_nothrow_move_constructible
3502 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3503 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3506 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3507 template <class _Tp>
3508 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3509 = is_nothrow_move_constructible<_Tp>::value;
3512 // is_nothrow_assignable
3514 #if __has_keyword(__is_nothrow_assignable)
3516 template <class _Tp, class _Arg>
3517 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3518 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
3522 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3524 template <class _Tp, class _Arg>
3525 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3530 template <class _Tp, class _Arg>
3531 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3532 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3536 template <class _Tp, class _Arg>
3537 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3538 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3542 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3544 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3545 template <class _Tp, class _Arg>
3546 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3547 = is_nothrow_assignable<_Tp, _Arg>::value;
3550 // is_nothrow_copy_assignable
3552 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3553 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3554 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3556 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3557 template <class _Tp>
3558 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3559 = is_nothrow_copy_assignable<_Tp>::value;
3562 // is_nothrow_move_assignable
3564 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3565 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3566 typename add_rvalue_reference<_Tp>::type>
3569 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3570 template <class _Tp>
3571 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3572 = is_nothrow_move_assignable<_Tp>::value;
3575 // is_nothrow_destructible
3577 #if !defined(_LIBCPP_CXX03_LANG)
3579 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3581 template <class _Tp>
3582 struct __libcpp_is_nothrow_destructible<false, _Tp>
3587 template <class _Tp>
3588 struct __libcpp_is_nothrow_destructible<true, _Tp>
3589 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3593 template <class _Tp>
3594 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3595 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3599 template <class _Tp, size_t _Ns>
3600 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3601 : public is_nothrow_destructible<_Tp>
3605 template <class _Tp>
3606 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3611 template <class _Tp>
3612 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3619 template <class _Tp> struct __libcpp_nothrow_destructor
3620 : public integral_constant<bool, is_scalar<_Tp>::value ||
3621 is_reference<_Tp>::value> {};
3623 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3624 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3626 template <class _Tp>
3627 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3628 : public false_type {};
3632 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3633 template <class _Tp>
3634 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3635 = is_nothrow_destructible<_Tp>::value;
3640 #if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
3642 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3643 : public integral_constant<bool, __is_pod(_Tp)> {};
3647 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3648 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3649 is_trivially_copy_constructible<_Tp>::value &&
3650 is_trivially_copy_assignable<_Tp>::value &&
3651 is_trivially_destructible<_Tp>::value> {};
3655 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3656 template <class _Tp>
3657 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
3658 = is_pod<_Tp>::value;
3663 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
3664 : public integral_constant<bool, __is_literal_type(_Tp)>
3667 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3668 template <class _Tp>
3669 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
3670 = is_literal_type<_Tp>::value;
3673 // is_standard_layout;
3675 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3676 #if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
3677 : public integral_constant<bool, __is_standard_layout(_Tp)>
3679 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3683 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3684 template <class _Tp>
3685 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
3686 = is_standard_layout<_Tp>::value;
3689 // is_trivially_copyable;
3691 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3692 #if __has_feature(is_trivially_copyable)
3693 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3694 #elif _GNUC_VER >= 501
3695 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3697 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3701 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3702 template <class _Tp>
3703 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3704 = is_trivially_copyable<_Tp>::value;
3709 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3710 #if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
3711 : public integral_constant<bool, __is_trivial(_Tp)>
3713 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3714 is_trivially_default_constructible<_Tp>::value>
3718 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3719 template <class _Tp>
3720 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
3721 = is_trivial<_Tp>::value;
3724 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3725 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3726 template <class _Tp> struct __is_reference_wrapper
3727 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3729 #ifndef _LIBCPP_CXX03_LANG
3731 template <class _Fp, class _A0,
3732 class _DecayFp = typename decay<_Fp>::type,
3733 class _DecayA0 = typename decay<_A0>::type,
3734 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3735 using __enable_if_bullet1 = typename enable_if
3737 is_member_function_pointer<_DecayFp>::value
3738 && is_base_of<_ClassT, _DecayA0>::value
3741 template <class _Fp, class _A0,
3742 class _DecayFp = typename decay<_Fp>::type,
3743 class _DecayA0 = typename decay<_A0>::type>
3744 using __enable_if_bullet2 = typename enable_if
3746 is_member_function_pointer<_DecayFp>::value
3747 && __is_reference_wrapper<_DecayA0>::value
3750 template <class _Fp, class _A0,
3751 class _DecayFp = typename decay<_Fp>::type,
3752 class _DecayA0 = typename decay<_A0>::type,
3753 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3754 using __enable_if_bullet3 = typename enable_if
3756 is_member_function_pointer<_DecayFp>::value
3757 && !is_base_of<_ClassT, _DecayA0>::value
3758 && !__is_reference_wrapper<_DecayA0>::value
3761 template <class _Fp, class _A0,
3762 class _DecayFp = typename decay<_Fp>::type,
3763 class _DecayA0 = typename decay<_A0>::type,
3764 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3765 using __enable_if_bullet4 = typename enable_if
3767 is_member_object_pointer<_DecayFp>::value
3768 && is_base_of<_ClassT, _DecayA0>::value
3771 template <class _Fp, class _A0,
3772 class _DecayFp = typename decay<_Fp>::type,
3773 class _DecayA0 = typename decay<_A0>::type>
3774 using __enable_if_bullet5 = typename enable_if
3776 is_member_object_pointer<_DecayFp>::value
3777 && __is_reference_wrapper<_DecayA0>::value
3780 template <class _Fp, class _A0,
3781 class _DecayFp = typename decay<_Fp>::type,
3782 class _DecayA0 = typename decay<_A0>::type,
3783 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3784 using __enable_if_bullet6 = typename enable_if
3786 is_member_object_pointer<_DecayFp>::value
3787 && !is_base_of<_ClassT, _DecayA0>::value
3788 && !__is_reference_wrapper<_DecayA0>::value
3791 // __invoke forward declarations
3793 // fall back - none of the bullets
3795 #define _LIBCPP_INVOKE_RETURN(...) \
3796 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
3797 { return __VA_ARGS__; }
3799 template <class ..._Args>
3800 auto __invoke(__any, _Args&& ...__args) -> __nat;
3802 template <class ..._Args>
3803 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
3805 // bullets 1, 2 and 3
3807 template <class _Fp, class _A0, class ..._Args,
3808 class = __enable_if_bullet1<_Fp, _A0>>
3809 inline _LIBCPP_INLINE_VISIBILITY
3811 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3812 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3814 template <class _Fp, class _A0, class ..._Args,
3815 class = __enable_if_bullet1<_Fp, _A0>>
3816 inline _LIBCPP_INLINE_VISIBILITY
3817 _LIBCPP_CONSTEXPR auto
3818 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3819 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3821 template <class _Fp, class _A0, class ..._Args,
3822 class = __enable_if_bullet2<_Fp, _A0>>
3823 inline _LIBCPP_INLINE_VISIBILITY
3825 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3826 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3828 template <class _Fp, class _A0, class ..._Args,
3829 class = __enable_if_bullet2<_Fp, _A0>>
3830 inline _LIBCPP_INLINE_VISIBILITY
3831 _LIBCPP_CONSTEXPR auto
3832 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3833 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3835 template <class _Fp, class _A0, class ..._Args,
3836 class = __enable_if_bullet3<_Fp, _A0>>
3837 inline _LIBCPP_INLINE_VISIBILITY
3839 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3840 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3842 template <class _Fp, class _A0, class ..._Args,
3843 class = __enable_if_bullet3<_Fp, _A0>>
3844 inline _LIBCPP_INLINE_VISIBILITY
3845 _LIBCPP_CONSTEXPR auto
3846 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3847 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3849 // bullets 4, 5 and 6
3851 template <class _Fp, class _A0,
3852 class = __enable_if_bullet4<_Fp, _A0>>
3853 inline _LIBCPP_INLINE_VISIBILITY
3855 __invoke(_Fp&& __f, _A0&& __a0)
3856 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3858 template <class _Fp, class _A0,
3859 class = __enable_if_bullet4<_Fp, _A0>>
3860 inline _LIBCPP_INLINE_VISIBILITY
3861 _LIBCPP_CONSTEXPR auto
3862 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3863 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3865 template <class _Fp, class _A0,
3866 class = __enable_if_bullet5<_Fp, _A0>>
3867 inline _LIBCPP_INLINE_VISIBILITY
3869 __invoke(_Fp&& __f, _A0&& __a0)
3870 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3872 template <class _Fp, class _A0,
3873 class = __enable_if_bullet5<_Fp, _A0>>
3874 inline _LIBCPP_INLINE_VISIBILITY
3875 _LIBCPP_CONSTEXPR auto
3876 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3877 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3879 template <class _Fp, class _A0,
3880 class = __enable_if_bullet6<_Fp, _A0>>
3881 inline _LIBCPP_INLINE_VISIBILITY
3883 __invoke(_Fp&& __f, _A0&& __a0)
3884 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3886 template <class _Fp, class _A0,
3887 class = __enable_if_bullet6<_Fp, _A0>>
3888 inline _LIBCPP_INLINE_VISIBILITY
3889 _LIBCPP_CONSTEXPR auto
3890 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3891 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3895 template <class _Fp, class ..._Args>
3896 inline _LIBCPP_INLINE_VISIBILITY
3898 __invoke(_Fp&& __f, _Args&& ...__args)
3899 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3901 template <class _Fp, class ..._Args>
3902 inline _LIBCPP_INLINE_VISIBILITY
3903 _LIBCPP_CONSTEXPR auto
3904 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
3905 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3907 #undef _LIBCPP_INVOKE_RETURN
3910 template <class _Ret, class _Fp, class ..._Args>
3911 struct __invokable_r
3913 template <class _XFp, class ..._XArgs>
3914 static auto __try_call(int) -> decltype(
3915 _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...));
3916 template <class _XFp, class ..._XArgs>
3917 static __nat __try_call(...);
3919 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
3920 // or incomplete array types as required by the standard.
3921 using _Result = decltype(__try_call<_Fp, _Args...>(0));
3924 typename conditional<
3925 _IsNotSame<_Result, __nat>::value,
3926 typename conditional<
3927 is_void<_Ret>::value,
3929 is_convertible<_Result, _Ret>
3933 static const bool value = type::value;
3935 template <class _Fp, class ..._Args>
3936 using __invokable = __invokable_r<void, _Fp, _Args...>;
3938 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
3939 struct __nothrow_invokable_r_imp {
3940 static const bool value = false;
3943 template <class _Ret, class _Fp, class ..._Args>
3944 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
3946 typedef __nothrow_invokable_r_imp _ThisT;
3948 template <class _Tp>
3949 static void __test_noexcept(_Tp) noexcept;
3951 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
3952 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
3955 template <class _Ret, class _Fp, class ..._Args>
3956 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
3958 static const bool value = noexcept(
3959 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
3962 template <class _Ret, class _Fp, class ..._Args>
3963 using __nothrow_invokable_r =
3964 __nothrow_invokable_r_imp<
3965 __invokable_r<_Ret, _Fp, _Args...>::value,
3966 is_void<_Ret>::value,
3970 template <class _Fp, class ..._Args>
3971 using __nothrow_invokable =
3972 __nothrow_invokable_r_imp<
3973 __invokable<_Fp, _Args...>::value,
3974 true, void, _Fp, _Args...
3977 template <class _Fp, class ..._Args>
3980 __invokable<_Fp, _Args...>::value,
3981 typename __invokable_r<void, _Fp, _Args...>::_Result>
3987 template <class _Fp, class ..._Args>
3988 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
3989 : public __invoke_of<_Fp, _Args...>
3993 #if _LIBCPP_STD_VER > 11
3994 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3997 #if _LIBCPP_STD_VER > 14
4001 template <class _Fn, class... _Args>
4002 struct _LIBCPP_TEMPLATE_VIS invoke_result
4003 : __invoke_of<_Fn, _Args...>
4007 template <class _Fn, class... _Args>
4008 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
4012 template <class _Fn, class ..._Args>
4013 struct _LIBCPP_TEMPLATE_VIS is_invocable
4014 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
4016 template <class _Ret, class _Fn, class ..._Args>
4017 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
4018 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4020 template <class _Fn, class ..._Args>
4021 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
4022 = is_invocable<_Fn, _Args...>::value;
4024 template <class _Ret, class _Fn, class ..._Args>
4025 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
4026 = is_invocable_r<_Ret, _Fn, _Args...>::value;
4028 // is_nothrow_invocable
4030 template <class _Fn, class ..._Args>
4031 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
4032 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
4034 template <class _Ret, class _Fn, class ..._Args>
4035 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
4036 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
4038 template <class _Fn, class ..._Args>
4039 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
4040 = is_nothrow_invocable<_Fn, _Args...>::value;
4042 template <class _Ret, class _Fn, class ..._Args>
4043 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
4044 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
4046 #endif // _LIBCPP_STD_VER > 14
4048 #endif // !defined(_LIBCPP_CXX03_LANG)
4050 template <class _Tp> struct __is_swappable;
4051 template <class _Tp> struct __is_nothrow_swappable;
4053 // swap, swap_ranges
4055 template <class _ForwardIterator1, class _ForwardIterator2>
4056 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4058 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2);
4060 template <class _Tp>
4061 inline _LIBCPP_INLINE_VISIBILITY
4062 #ifndef _LIBCPP_CXX03_LANG
4065 is_move_constructible<_Tp>::value &&
4066 is_move_assignable<_Tp>::value
4071 _LIBCPP_CONSTEXPR_AFTER_CXX17
4072 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4073 is_nothrow_move_assignable<_Tp>::value)
4075 _Tp __t(_VSTD::move(__x));
4076 __x = _VSTD::move(__y);
4077 __y = _VSTD::move(__t);
4080 template<class _Tp, size_t _Np>
4081 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4083 __is_swappable<_Tp>::value
4085 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
4087 _VSTD::swap_ranges(__a, __a + _Np, __b);
4090 template <class _ForwardIterator1, class _ForwardIterator2>
4091 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4093 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
4095 for(; __first1 != __last1; ++__first1, (void) ++__first2)
4096 swap(*__first1, *__first2);
4102 template <class _ForwardIterator1, class _ForwardIterator2>
4103 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4105 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4106 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4107 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4108 *_VSTD::declval<_ForwardIterator2>())))
4117 // ALL generic swap overloads MUST already have a declaration available at this point.
4119 template <class _Tp, class _Up = _Tp,
4120 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4121 struct __swappable_with
4123 template <class _LHS, class _RHS>
4124 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4126 template <class, class>
4127 static __nat __test_swap(long);
4129 // Extra parens are needed for the C++03 definition of decltype.
4130 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4131 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4133 static const bool value = _IsNotSame<__swap1, __nat>::value
4134 && _IsNotSame<__swap2, __nat>::value;
4137 template <class _Tp, class _Up>
4138 struct __swappable_with<_Tp, _Up, false> : false_type {};
4140 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4141 struct __nothrow_swappable_with {
4142 static const bool value =
4143 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4144 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4145 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4151 template <class _Tp, class _Up>
4152 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4156 template <class _Tp>
4157 struct __is_swappable
4158 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4162 template <class _Tp>
4163 struct __is_nothrow_swappable
4164 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4168 #if _LIBCPP_STD_VER > 14
4170 template <class _Tp, class _Up>
4171 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4172 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4176 template <class _Tp>
4177 struct _LIBCPP_TEMPLATE_VIS is_swappable
4178 : public conditional<
4179 __is_referenceable<_Tp>::value,
4181 typename add_lvalue_reference<_Tp>::type,
4182 typename add_lvalue_reference<_Tp>::type>,
4188 template <class _Tp, class _Up>
4189 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4190 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4194 template <class _Tp>
4195 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4196 : public conditional<
4197 __is_referenceable<_Tp>::value,
4198 is_nothrow_swappable_with<
4199 typename add_lvalue_reference<_Tp>::type,
4200 typename add_lvalue_reference<_Tp>::type>,
4206 template <class _Tp, class _Up>
4207 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
4208 = is_swappable_with<_Tp, _Up>::value;
4210 template <class _Tp>
4211 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
4212 = is_swappable<_Tp>::value;
4214 template <class _Tp, class _Up>
4215 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
4216 = is_nothrow_swappable_with<_Tp, _Up>::value;
4218 template <class _Tp>
4219 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
4220 = is_nothrow_swappable<_Tp>::value;
4222 #endif // _LIBCPP_STD_VER > 14
4224 template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
4226 template <class _Tp>
4227 struct __underlying_type_impl<_Tp, false> {};
4229 template <class _Tp>
4230 struct __underlying_type_impl<_Tp, true>
4232 typedef __underlying_type(_Tp) type;
4235 template <class _Tp>
4236 struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
4238 #if _LIBCPP_STD_VER > 11
4239 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4242 template <class _Tp, bool = is_enum<_Tp>::value>
4243 struct __sfinae_underlying_type
4245 typedef typename underlying_type<_Tp>::type type;
4246 typedef decltype(((type)1) + 0) __promoted_type;
4249 template <class _Tp>
4250 struct __sfinae_underlying_type<_Tp, false> {};
4252 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4253 int __convert_to_integral(int __val) { return __val; }
4255 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4256 unsigned __convert_to_integral(unsigned __val) { return __val; }
4258 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4259 long __convert_to_integral(long __val) { return __val; }
4261 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4262 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4264 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4265 long long __convert_to_integral(long long __val) { return __val; }
4267 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4268 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4270 template<typename _Fp>
4271 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4272 typename enable_if<is_floating_point<_Fp>::value, long long>::type
4273 __convert_to_integral(_Fp __val) { return __val; }
4275 #ifndef _LIBCPP_HAS_NO_INT128
4276 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4277 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4279 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4280 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4283 template <class _Tp>
4284 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4285 typename __sfinae_underlying_type<_Tp>::__promoted_type
4286 __convert_to_integral(_Tp __val) { return __val; }
4288 #ifndef _LIBCPP_CXX03_LANG
4290 template <class _Tp>
4291 struct __has_operator_addressof_member_imp
4293 template <class _Up>
4294 static auto __test(int)
4295 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4297 static auto __test(long) -> false_type;
4299 static const bool value = decltype(__test<_Tp>(0))::value;
4302 template <class _Tp>
4303 struct __has_operator_addressof_free_imp
4305 template <class _Up>
4306 static auto __test(int)
4307 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4309 static auto __test(long) -> false_type;
4311 static const bool value = decltype(__test<_Tp>(0))::value;
4314 template <class _Tp>
4315 struct __has_operator_addressof
4316 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4317 || __has_operator_addressof_free_imp<_Tp>::value>
4320 #endif // _LIBCPP_CXX03_LANG
4322 #if _LIBCPP_STD_VER > 14
4324 template <class... _Args>
4325 struct conjunction : _And<_Args...> {};
4326 template<class... _Args>
4327 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
4328 = conjunction<_Args...>::value;
4330 template <class... _Args>
4331 struct disjunction : _Or<_Args...> {};
4332 template<class... _Args>
4333 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
4334 = disjunction<_Args...>::value;
4336 template <class _Tp>
4337 struct negation : _Not<_Tp> {};
4339 _LIBCPP_INLINE_VAR constexpr bool negation_v
4340 = negation<_Tp>::value;
4341 #endif // _LIBCPP_STD_VER > 14
4343 // These traits are used in __tree and __hash_table
4344 #ifndef _LIBCPP_CXX03_LANG
4345 struct __extract_key_fail_tag {};
4346 struct __extract_key_self_tag {};
4347 struct __extract_key_first_tag {};
4349 template <class _ValTy, class _Key,
4350 class _RawValTy = typename __unconstref<_ValTy>::type>
4351 struct __can_extract_key
4352 : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
4353 __extract_key_fail_tag>::type {};
4355 template <class _Pair, class _Key, class _First, class _Second>
4356 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4357 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
4358 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4360 // __can_extract_map_key uses true_type/false_type instead of the tags.
4361 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4362 // and _ValTy == _Key.
4363 template <class _ValTy, class _Key, class _ContainerValueTy,
4364 class _RawValTy = typename __unconstref<_ValTy>::type>
4365 struct __can_extract_map_key
4366 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
4368 // This specialization returns __extract_key_fail_tag for non-map containers
4369 // because _Key == _ContainerValueTy
4370 template <class _ValTy, class _Key, class _RawValTy>
4371 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4376 #ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
4377 #if _LIBCPP_STD_VER > 17
4378 _LIBCPP_INLINE_VISIBILITY
4379 inline constexpr bool is_constant_evaluated() noexcept {
4380 return __builtin_is_constant_evaluated();
4384 inline _LIBCPP_CONSTEXPR
4385 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
4387 inline _LIBCPP_CONSTEXPR
4388 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; }
4391 template <class _CharT>
4392 using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
4394 _LIBCPP_END_NAMESPACE_STD
4396 #if _LIBCPP_STD_VER > 14
4398 namespace std // purposefully not versioned
4405 #endif // _LIBCPP_TYPE_TRAITS