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;
431 template <class _Tp, _Tp __v>
432 struct _LIBCPP_TEMPLATE_VIS integral_constant
434 static _LIBCPP_CONSTEXPR const _Tp value = __v;
435 typedef _Tp value_type;
436 typedef integral_constant type;
437 _LIBCPP_INLINE_VISIBILITY
438 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
439 #if _LIBCPP_STD_VER > 11
440 _LIBCPP_INLINE_VISIBILITY
441 constexpr value_type operator ()() const _NOEXCEPT {return value;}
445 template <class _Tp, _Tp __v>
446 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
448 #if _LIBCPP_STD_VER > 14
450 using bool_constant = integral_constant<bool, __b>;
451 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
453 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
456 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
457 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
460 using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
462 template <bool> struct _MetaBase;
464 struct _MetaBase<true> {
465 template <class _Tp, class _Up>
466 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Tp;
467 template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
468 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _FirstFn<_Args...>;
469 template <class _First, class...>
470 using _FirstImpl _LIBCPP_NODEBUG_TYPE = _First;
471 template <class, class _Second, class...>
472 using _SecondImpl _LIBCPP_NODEBUG_TYPE = _Second;
473 template <class _Tp = void>
474 using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp;
475 template <class _Result, class _First, class ..._Rest>
476 using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
477 template <class _Result, class _First, class ..._Rest>
478 using _AndImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>;
482 struct _MetaBase<false> {
483 template <class _Tp, class _Up>
484 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Up;
485 template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
486 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>;
487 template <class _Result, class ...>
488 using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result;
489 template <class _Result, class ...>
490 using _AndImpl _LIBCPP_NODEBUG_TYPE = _Result;
492 template <bool _Cond, class _Ret = void>
493 using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>;
494 template <bool _Cond, class _IfRes, class _ElseRes>
495 using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
496 template <class ..._Rest>
497 using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
498 template <class ..._Rest>
499 using _And _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _AndImpl<true_type, _Rest...>;
500 template <class _Pred>
501 struct _Not : _BoolConstant<!_Pred::value> {};
502 template <class ..._Args>
503 using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
504 template <class ..._Args>
505 using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
507 template <template <class...> class _Func, class ..._Args>
508 struct _Lazy : _Func<_Args...> {};
510 // Member detector base
512 template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
513 true_type __sfinae_test_impl(int);
514 template <template <class...> class, class ...>
515 false_type __sfinae_test_impl(...);
517 template <template <class ...> class _Templ, class ..._Args>
518 using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
521 struct __void_t { typedef void type; };
524 struct __identity { typedef _Tp type; };
526 template <class _Tp, bool>
527 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 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
548 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
550 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
551 template <class _Tp, class _Up>
552 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
553 = is_same<_Tp, _Up>::value;
556 template <class _Tp, class _Up>
557 using _IsSame = _BoolConstant<
561 _VSTD::is_same<_Tp, _Up>::value
565 template <class _Tp, class _Up>
566 using _IsNotSame = _BoolConstant<
570 !_VSTD::is_same<_Tp, _Up>::value
574 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
577 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
578 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
580 addressof(_Tp& __x) _NOEXCEPT
582 return __builtin_addressof(__x);
588 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
590 addressof(_Tp& __x) _NOEXCEPT
592 return reinterpret_cast<_Tp *>(
593 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
596 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
598 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
599 // Objective-C++ Automatic Reference Counting uses qualified pointers
600 // that require special addressof() signatures. When
601 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
602 // itself is providing these definitions. Otherwise, we provide them.
604 inline _LIBCPP_INLINE_VISIBILITY
606 addressof(__strong _Tp& __x) _NOEXCEPT
611 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
613 inline _LIBCPP_INLINE_VISIBILITY
615 addressof(__weak _Tp& __x) _NOEXCEPT
622 inline _LIBCPP_INLINE_VISIBILITY
624 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
630 inline _LIBCPP_INLINE_VISIBILITY
631 __unsafe_unretained _Tp*
632 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
638 #if !defined(_LIBCPP_CXX03_LANG)
639 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
642 struct __two {char __lx[2];};
648 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
649 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
651 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
653 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
654 = is_const<_Tp>::value;
659 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
660 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
662 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
664 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
665 = is_volatile<_Tp>::value;
670 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
671 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
672 #if _LIBCPP_STD_VER > 11
673 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
678 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
679 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
680 #if _LIBCPP_STD_VER > 11
681 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
686 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
687 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
688 #if _LIBCPP_STD_VER > 11
689 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
694 template <class _Tp> struct __libcpp_is_void : public false_type {};
695 template <> struct __libcpp_is_void<void> : public true_type {};
697 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
698 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
700 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
702 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
703 = is_void<_Tp>::value;
708 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
709 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
711 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
712 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
714 #if _LIBCPP_STD_VER > 11
715 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
716 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
718 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
720 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
721 = is_null_pointer<_Tp>::value;
727 template <class _Tp> struct __libcpp_is_integral : public false_type {};
728 template <> struct __libcpp_is_integral<bool> : public true_type {};
729 template <> struct __libcpp_is_integral<char> : public true_type {};
730 template <> struct __libcpp_is_integral<signed char> : public true_type {};
731 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
732 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
733 #ifndef _LIBCPP_NO_HAS_CHAR8_T
734 template <> struct __libcpp_is_integral<char8_t> : public true_type {};
736 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
737 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
738 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
739 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
740 template <> struct __libcpp_is_integral<short> : public true_type {};
741 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
742 template <> struct __libcpp_is_integral<int> : public true_type {};
743 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
744 template <> struct __libcpp_is_integral<long> : public true_type {};
745 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
746 template <> struct __libcpp_is_integral<long long> : public true_type {};
747 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
748 #ifndef _LIBCPP_HAS_NO_INT128
749 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
750 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
753 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
754 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
756 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
758 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
759 = is_integral<_Tp>::value;
764 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
765 template <> struct __libcpp_is_floating_point<float> : public true_type {};
766 template <> struct __libcpp_is_floating_point<double> : public true_type {};
767 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
769 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
770 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
772 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
774 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
775 = is_floating_point<_Tp>::value;
780 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
781 : public false_type {};
782 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
783 : public true_type {};
784 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
785 : public true_type {};
787 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
789 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
790 = is_array<_Tp>::value;
795 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
796 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
798 template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
799 #if defined(_LIBCPP_HAS_OBJC_ARC)
800 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
801 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
802 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
803 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
806 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
807 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
809 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
811 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
812 = is_pointer<_Tp>::value;
817 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
818 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
820 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
821 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
823 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
824 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
825 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
827 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
829 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
830 = is_reference<_Tp>::value;
833 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
834 = is_lvalue_reference<_Tp>::value;
837 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
838 = is_rvalue_reference<_Tp>::value;
842 #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
844 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
845 : public integral_constant<bool, __is_union(_Tp)> {};
849 template <class _Tp> struct __libcpp_union : public false_type {};
850 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
851 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
855 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
857 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
858 = is_union<_Tp>::value;
863 #if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
865 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
866 : public integral_constant<bool, __is_class(_Tp)> {};
870 namespace __is_class_imp
872 template <class _Tp> char __test(int _Tp::*);
873 template <class _Tp> __two __test(...);
876 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
877 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
881 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
883 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
884 = is_class<_Tp>::value;
889 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
890 : public _BoolConstant<
894 !(is_reference<_Tp>::value || is_const<const _Tp>::value)
899 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
901 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
902 = is_function<_Tp>::value;
905 template <class _Tp> struct __libcpp_is_member_pointer {
912 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
915 __is_func = is_function<_Tp>::value,
916 __is_obj = !__is_func,
921 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
922 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
924 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
926 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
927 = is_member_function_pointer<_Tp>::value;
932 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
933 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
935 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
937 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
938 = is_member_pointer<_Tp>::value;
941 // is_member_object_pointer
943 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
944 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
946 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
948 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
949 = is_member_object_pointer<_Tp>::value;
954 #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
956 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
957 : public integral_constant<bool, __is_enum(_Tp)> {};
961 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
962 : public integral_constant<bool, !is_void<_Tp>::value &&
963 !is_integral<_Tp>::value &&
964 !is_floating_point<_Tp>::value &&
965 !is_array<_Tp>::value &&
966 !is_pointer<_Tp>::value &&
967 !is_reference<_Tp>::value &&
968 !is_member_pointer<_Tp>::value &&
969 !is_union<_Tp>::value &&
970 !is_class<_Tp>::value &&
971 !is_function<_Tp>::value > {};
975 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
977 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
978 = is_enum<_Tp>::value;
983 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
984 : public integral_constant<bool, is_integral<_Tp>::value ||
985 is_floating_point<_Tp>::value> {};
987 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
989 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
990 = is_arithmetic<_Tp>::value;
995 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
996 : public integral_constant<bool, is_void<_Tp>::value ||
997 __is_nullptr_t<_Tp>::value ||
998 is_arithmetic<_Tp>::value> {};
1000 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1001 template <class _Tp>
1002 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1003 = is_fundamental<_Tp>::value;
1008 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1009 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1010 is_member_pointer<_Tp>::value ||
1011 is_pointer<_Tp>::value ||
1012 __is_nullptr_t<_Tp>::value ||
1013 is_enum<_Tp>::value > {};
1015 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1017 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1018 template <class _Tp>
1019 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1020 = is_scalar<_Tp>::value;
1025 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1026 : public integral_constant<bool, is_scalar<_Tp>::value ||
1027 is_array<_Tp>::value ||
1028 is_union<_Tp>::value ||
1029 is_class<_Tp>::value > {};
1031 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1032 template <class _Tp>
1033 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
1034 = is_object<_Tp>::value;
1039 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1040 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1042 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1043 template <class _Tp>
1044 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1045 = is_compound<_Tp>::value;
1049 // __is_referenceable [defns.referenceable]
1051 struct __is_referenceable_impl {
1052 template <class _Tp> static _Tp& __test(int);
1053 template <class _Tp> static __two __test(...);
1056 template <class _Tp>
1057 struct __is_referenceable : integral_constant<bool,
1058 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1063 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
1064 typedef _LIBCPP_NODEBUG_TYPE const _Tp type;
1067 #if _LIBCPP_STD_VER > 11
1068 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1073 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
1074 typedef _LIBCPP_NODEBUG_TYPE volatile _Tp type;
1077 #if _LIBCPP_STD_VER > 11
1078 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1082 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
1083 typedef _LIBCPP_NODEBUG_TYPE const volatile _Tp type;
1086 #if _LIBCPP_STD_VER > 11
1087 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1092 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1093 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1094 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1096 #if _LIBCPP_STD_VER > 11
1097 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1100 // add_lvalue_reference
1102 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1103 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; };
1105 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1106 {typedef _LIBCPP_NODEBUG_TYPE typename __add_lvalue_reference_impl<_Tp>::type type;};
1108 #if _LIBCPP_STD_VER > 11
1109 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1112 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1113 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; };
1115 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1116 {typedef _LIBCPP_NODEBUG_TYPE typename __add_rvalue_reference_impl<_Tp>::type type;};
1118 #if _LIBCPP_STD_VER > 11
1119 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1122 // Suppress deprecation notice for volatile-qualified return type resulting
1123 // from volatile-qualified types _Tp.
1124 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1125 template <class _Tp> _Tp&& __declval(int);
1126 template <class _Tp> _Tp __declval(long);
1127 _LIBCPP_SUPPRESS_DEPRECATED_POP
1129 template <class _Tp>
1130 decltype(_VSTD::__declval<_Tp>(0))
1131 declval() _NOEXCEPT;
1135 template <class _Tp>
1137 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1140 template <class _Tp>
1141 struct __unconstref {
1142 typedef _LIBCPP_NODEBUG_TYPE typename remove_const<typename remove_reference<_Tp>::type>::type type;
1145 #ifndef _LIBCPP_CXX03_LANG
1146 template <class _Tp>
1147 using __uncvref_t _LIBCPP_NODEBUG_TYPE = typename __uncvref<_Tp>::type;
1150 // __is_same_uncvref
1152 template <class _Tp, class _Up>
1153 struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
1154 typename __uncvref<_Up>::type> {};
1156 #if _LIBCPP_STD_VER > 17
1157 // remove_cvref - same as __uncvref
1158 template <class _Tp>
1159 struct remove_cvref : public __uncvref<_Tp> {};
1161 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1172 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1173 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1174 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1175 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1176 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1178 #if _LIBCPP_STD_VER > 11
1179 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1184 template <class _Tp,
1185 bool = __is_referenceable<_Tp>::value ||
1186 _IsSame<typename remove_cv<_Tp>::type, void>::value>
1187 struct __add_pointer_impl
1188 {typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type* type;};
1189 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1190 {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1192 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1193 {typedef _LIBCPP_NODEBUG_TYPE typename __add_pointer_impl<_Tp>::type type;};
1195 #if _LIBCPP_STD_VER > 11
1196 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1200 #if _LIBCPP_STD_VER > 17
1201 template<class _Tp> struct type_identity { typedef _Tp type; };
1202 template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
1207 template <class _Tp, bool = is_integral<_Tp>::value>
1208 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1210 template <class _Tp>
1211 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1213 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1214 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1216 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1218 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1220 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1221 template <class _Tp>
1222 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1223 = is_signed<_Tp>::value;
1228 template <class _Tp, bool = is_integral<_Tp>::value>
1229 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1231 template <class _Tp>
1232 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1234 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1235 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1237 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1239 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1241 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1242 template <class _Tp>
1243 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1244 = is_unsigned<_Tp>::value;
1249 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1250 : public integral_constant<size_t, 0> {};
1251 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1252 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1253 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1254 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1256 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1257 template <class _Tp>
1258 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1264 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1265 : public integral_constant<size_t, 0> {};
1266 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1267 : public integral_constant<size_t, 0> {};
1268 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1269 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1270 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1271 : public integral_constant<size_t, _Np> {};
1272 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1273 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1275 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1276 template <class _Tp, unsigned _Ip = 0>
1277 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1278 = extent<_Tp, _Ip>::value;
1283 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1284 {typedef _Tp type;};
1285 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1286 {typedef _Tp type;};
1287 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1288 {typedef _Tp type;};
1290 #if _LIBCPP_STD_VER > 11
1291 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1294 // remove_all_extents
1296 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1297 {typedef _Tp type;};
1298 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1299 {typedef typename remove_all_extents<_Tp>::type type;};
1300 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1301 {typedef typename remove_all_extents<_Tp>::type type;};
1303 #if _LIBCPP_STD_VER > 11
1304 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1307 #if _LIBCPP_STD_VER > 17
1310 template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
1311 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
1313 template <class _Tp>
1314 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1315 bool is_bounded_array_v = is_bounded_array<_Tp>::value;
1317 // is_unbounded_array
1319 template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
1320 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
1322 template <class _Tp>
1323 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1324 bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
1329 template <class _Up, bool>
1331 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<_Up>::type type;
1334 template <class _Up>
1335 struct __decay<_Up, true> {
1337 typedef _LIBCPP_NODEBUG_TYPE typename conditional
1339 is_array<_Up>::value,
1340 typename remove_extent<_Up>::type*,
1341 typename conditional
1343 is_function<_Up>::value,
1344 typename add_pointer<_Up>::type,
1345 typename remove_cv<_Up>::type
1350 template <class _Tp>
1351 struct _LIBCPP_TEMPLATE_VIS decay
1354 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
1356 typedef _LIBCPP_NODEBUG_TYPE typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1359 #if _LIBCPP_STD_VER > 11
1360 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1365 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1366 : public integral_constant<bool, __is_abstract(_Tp)> {};
1368 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1369 template <class _Tp>
1370 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1371 = is_abstract<_Tp>::value;
1376 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1377 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1379 #if _LIBCPP_STD_VER > 11
1380 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1381 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1384 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1385 template <class _Tp>
1386 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1387 = is_final<_Tp>::value;
1391 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1393 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1394 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1396 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1397 template <class _Tp>
1398 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1399 = is_aggregate<_Tp>::value;
1402 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1406 template <class _Bp, class _Dp>
1407 struct _LIBCPP_TEMPLATE_VIS is_base_of
1408 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1410 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1411 template <class _Bp, class _Dp>
1412 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1413 = is_base_of<_Bp, _Dp>::value;
1418 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1420 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1421 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1422 !is_abstract<_T2>::value> {};
1424 #else // __has_feature(is_convertible_to)
1426 namespace __is_convertible_imp
1428 template <class _Tp> void __test_convert(_Tp);
1430 template <class _From, class _To, class = void>
1431 struct __is_convertible_test : public false_type {};
1433 template <class _From, class _To>
1434 struct __is_convertible_test<_From, _To,
1435 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1438 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1439 bool _IsFunction = is_function<_Tp>::value,
1440 bool _IsVoid = is_void<_Tp>::value>
1441 struct __is_array_function_or_void {enum {value = 0};};
1442 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1443 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1444 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1447 template <class _Tp,
1448 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1449 struct __is_convertible_check
1451 static const size_t __v = 0;
1454 template <class _Tp>
1455 struct __is_convertible_check<_Tp, 0>
1457 static const size_t __v = sizeof(_Tp);
1460 template <class _T1, class _T2,
1461 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1462 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1463 struct __is_convertible
1464 : public integral_constant<bool,
1465 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1469 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1470 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1471 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1472 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1474 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1475 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1476 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1477 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1479 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1480 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1481 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1482 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1484 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1485 : public __is_convertible<_T1, _T2>
1487 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1488 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1491 #endif // __has_feature(is_convertible_to)
1493 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1494 template <class _From, class _To>
1495 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1496 = is_convertible<_From, _To>::value;
1499 // is_nothrow_convertible
1501 #if _LIBCPP_STD_VER > 17
1503 template <typename _Tp>
1504 static void __test_noexcept(_Tp) noexcept;
1506 template<typename _Fm, typename _To>
1507 static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))>
1508 __is_nothrow_convertible_test();
1510 template <typename _Fm, typename _To>
1511 struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
1514 template <typename _Fm, typename _To>
1515 struct is_nothrow_convertible : _Or<
1516 _And<is_void<_To>, is_void<_Fm>>,
1517 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
1520 template <typename _Fm, typename _To>
1521 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
1523 #endif // _LIBCPP_STD_VER > 17
1527 #if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
1529 template <class _Tp>
1530 struct _LIBCPP_TEMPLATE_VIS is_empty
1531 : public integral_constant<bool, __is_empty(_Tp)> {};
1533 #else // __has_feature(is_empty)
1535 template <class _Tp>
1547 template <class _Tp, bool = is_class<_Tp>::value>
1548 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1550 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1552 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1554 #endif // __has_feature(is_empty)
1556 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1557 template <class _Tp>
1558 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1559 = is_empty<_Tp>::value;
1564 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1566 template <class _Tp>
1567 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1568 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1572 template<typename _Tp> char &__is_polymorphic_impl(
1573 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1575 template<typename _Tp> __two &__is_polymorphic_impl(...);
1577 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1578 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1580 #endif // __has_feature(is_polymorphic)
1582 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1583 template <class _Tp>
1584 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1585 = is_polymorphic<_Tp>::value;
1588 // has_virtual_destructor
1590 #if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
1592 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1593 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1597 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1598 : public false_type {};
1602 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1603 template <class _Tp>
1604 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1605 = has_virtual_destructor<_Tp>::value;
1608 // has_unique_object_representations
1610 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1612 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1613 : public integral_constant<bool,
1614 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1616 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1617 template <class _Tp>
1618 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1619 = has_unique_object_representations<_Tp>::value;
1626 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1627 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
1629 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1630 template <class _Tp>
1631 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1632 = alignment_of<_Tp>::value;
1637 template <class _Hp, class _Tp>
1646 #ifndef _LIBCPP_CXX03_LANG
1648 __nat(const __nat&) = delete;
1649 __nat& operator=(const __nat&) = delete;
1654 template <class _Tp>
1657 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
1661 struct __struct_double {long double __lx;};
1662 struct __struct_double4 {double __lx[4];};
1665 __type_list<__align_type<unsigned char>,
1666 __type_list<__align_type<unsigned short>,
1667 __type_list<__align_type<unsigned int>,
1668 __type_list<__align_type<unsigned long>,
1669 __type_list<__align_type<unsigned long long>,
1670 __type_list<__align_type<double>,
1671 __type_list<__align_type<long double>,
1672 __type_list<__align_type<__struct_double>,
1673 __type_list<__align_type<__struct_double4>,
1674 __type_list<__align_type<int*>,
1676 > > > > > > > > > > __all_types;
1678 template <size_t _Align>
1679 struct _ALIGNAS(_Align) __fallback_overaligned {};
1681 template <class _TL, size_t _Align> struct __find_pod;
1683 template <class _Hp, size_t _Align>
1684 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1686 typedef typename conditional<
1687 _Align == _Hp::value,
1689 __fallback_overaligned<_Align>
1693 template <class _Hp, class _Tp, size_t _Align>
1694 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1696 typedef typename conditional<
1697 _Align == _Hp::value,
1699 typename __find_pod<_Tp, _Align>::type
1703 template <class _TL, size_t _Len> struct __find_max_align;
1705 template <class _Hp, size_t _Len>
1706 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1708 template <size_t _Len, size_t _A1, size_t _A2>
1709 struct __select_align
1712 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1713 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1715 static const size_t value = _Len < __max ? __min : __max;
1718 template <class _Hp, class _Tp, size_t _Len>
1719 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1720 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1722 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1723 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1725 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1729 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1733 #if _LIBCPP_STD_VER > 11
1734 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1735 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1738 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1739 template <size_t _Len>\
1740 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1742 struct _ALIGNAS(n) type\
1744 unsigned char __lx[(_Len + n - 1)/n * n];\
1748 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1749 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1750 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1751 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1752 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1753 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1754 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1755 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1756 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1757 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1758 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1759 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1760 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1761 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1762 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1763 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1764 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1765 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1767 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1772 template <size_t _I0, size_t ..._In>
1773 struct __static_max;
1775 template <size_t _I0>
1776 struct __static_max<_I0>
1778 static const size_t value = _I0;
1781 template <size_t _I0, size_t _I1, size_t ..._In>
1782 struct __static_max<_I0, _I1, _In...>
1784 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1785 __static_max<_I1, _In...>::value;
1788 template <size_t _Len, class _Type0, class ..._Types>
1789 struct aligned_union
1791 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
1792 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
1793 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1794 sizeof(_Types)...>::value;
1795 typedef typename aligned_storage<__len, alignment_value>::type type;
1798 #if _LIBCPP_STD_VER > 11
1799 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1802 template <class _Tp>
1803 struct __numeric_type
1805 static void __test(...);
1806 static float __test(float);
1807 static double __test(char);
1808 static double __test(int);
1809 static double __test(unsigned);
1810 static double __test(long);
1811 static double __test(unsigned long);
1812 static double __test(long long);
1813 static double __test(unsigned long long);
1814 static double __test(double);
1815 static long double __test(long double);
1817 typedef decltype(__test(declval<_Tp>())) type;
1818 static const bool value = _IsNotSame<type, void>::value;
1822 struct __numeric_type<void>
1824 static const bool value = true;
1829 template <class _A1, class _A2 = void, class _A3 = void,
1830 bool = __numeric_type<_A1>::value &&
1831 __numeric_type<_A2>::value &&
1832 __numeric_type<_A3>::value>
1836 static const bool value = false;
1839 template <class _A1, class _A2, class _A3>
1840 class __promote_imp<_A1, _A2, _A3, true>
1843 typedef typename __promote_imp<_A1>::type __type1;
1844 typedef typename __promote_imp<_A2>::type __type2;
1845 typedef typename __promote_imp<_A3>::type __type3;
1847 typedef decltype(__type1() + __type2() + __type3()) type;
1848 static const bool value = true;
1851 template <class _A1, class _A2>
1852 class __promote_imp<_A1, _A2, void, true>
1855 typedef typename __promote_imp<_A1>::type __type1;
1856 typedef typename __promote_imp<_A2>::type __type2;
1858 typedef decltype(__type1() + __type2()) type;
1859 static const bool value = true;
1862 template <class _A1>
1863 class __promote_imp<_A1, void, void, true>
1866 typedef typename __numeric_type<_A1>::type type;
1867 static const bool value = true;
1870 template <class _A1, class _A2 = void, class _A3 = void>
1871 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1873 // make_signed / make_unsigned
1876 __type_list<signed char,
1877 __type_list<signed short,
1878 __type_list<signed int,
1879 __type_list<signed long,
1880 __type_list<signed long long,
1881 #ifndef _LIBCPP_HAS_NO_INT128
1882 __type_list<__int128_t,
1885 #ifndef _LIBCPP_HAS_NO_INT128
1888 > > > > > __signed_types;
1891 __type_list<unsigned char,
1892 __type_list<unsigned short,
1893 __type_list<unsigned int,
1894 __type_list<unsigned long,
1895 __type_list<unsigned long long,
1896 #ifndef _LIBCPP_HAS_NO_INT128
1897 __type_list<__uint128_t,
1900 #ifndef _LIBCPP_HAS_NO_INT128
1903 > > > > > __unsigned_types;
1905 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1907 template <class _Hp, class _Tp, size_t _Size>
1908 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1910 typedef _LIBCPP_NODEBUG_TYPE _Hp type;
1913 template <class _Hp, class _Tp, size_t _Size>
1914 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1916 typedef _LIBCPP_NODEBUG_TYPE typename __find_first<_Tp, _Size>::type type;
1919 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1920 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1923 typedef _LIBCPP_NODEBUG_TYPE _Up type;
1926 template <class _Tp, class _Up>
1927 struct __apply_cv<_Tp, _Up, true, false>
1929 typedef _LIBCPP_NODEBUG_TYPE const _Up type;
1932 template <class _Tp, class _Up>
1933 struct __apply_cv<_Tp, _Up, false, true>
1935 typedef volatile _Up type;
1938 template <class _Tp, class _Up>
1939 struct __apply_cv<_Tp, _Up, true, true>
1941 typedef const volatile _Up type;
1944 template <class _Tp, class _Up>
1945 struct __apply_cv<_Tp&, _Up, false, false>
1950 template <class _Tp, class _Up>
1951 struct __apply_cv<_Tp&, _Up, true, false>
1953 typedef const _Up& type;
1956 template <class _Tp, class _Up>
1957 struct __apply_cv<_Tp&, _Up, false, true>
1959 typedef volatile _Up& type;
1962 template <class _Tp, class _Up>
1963 struct __apply_cv<_Tp&, _Up, true, true>
1965 typedef const volatile _Up& type;
1968 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1969 struct __make_signed {};
1971 template <class _Tp>
1972 struct __make_signed<_Tp, true>
1974 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1977 template <> struct __make_signed<bool, true> {};
1978 template <> struct __make_signed< signed short, true> {typedef short type;};
1979 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1980 template <> struct __make_signed< signed int, true> {typedef int type;};
1981 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1982 template <> struct __make_signed< signed long, true> {typedef long type;};
1983 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1984 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1985 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1986 #ifndef _LIBCPP_HAS_NO_INT128
1987 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1988 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1991 template <class _Tp>
1992 struct _LIBCPP_TEMPLATE_VIS make_signed
1994 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1997 #if _LIBCPP_STD_VER > 11
1998 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2001 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2002 struct __make_unsigned {};
2004 template <class _Tp>
2005 struct __make_unsigned<_Tp, true>
2007 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2010 template <> struct __make_unsigned<bool, true> {};
2011 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2012 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2013 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2014 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2015 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2016 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2017 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2018 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2019 #ifndef _LIBCPP_HAS_NO_INT128
2020 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2021 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2024 template <class _Tp>
2025 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2027 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2030 #if _LIBCPP_STD_VER > 11
2031 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2034 template <class _Tp, class _Up, class = void>
2035 struct __common_type2_imp {};
2037 template <class _Tp, class _Up>
2038 struct __common_type2_imp<_Tp, _Up,
2039 typename __void_t<decltype(
2040 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2043 typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype(
2044 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2048 template <class, class = void>
2049 struct __common_type_impl {};
2051 // Clang provides variadic templates in C++03 as an extension.
2052 #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
2053 # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
2054 template <class... Tp>
2055 struct __common_types;
2056 template <class... _Tp>
2057 struct _LIBCPP_TEMPLATE_VIS common_type;
2059 # define _LIBCPP_OPTIONAL_PACK(...)
2061 template <class _Tp, class _Up, class = __no_arg>
2062 struct __common_types;
2063 template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
2064 class _Unused = __no_arg>
2065 struct common_type {
2066 static_assert(sizeof(_Unused) == 0,
2067 "common_type accepts at most 3 arguments in C++03");
2069 #endif // _LIBCPP_CXX03_LANG
2071 template <class _Tp, class _Up>
2072 struct __common_type_impl<
2073 __common_types<_Tp, _Up>,
2074 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2076 typedef typename common_type<_Tp, _Up>::type type;
2079 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2080 struct __common_type_impl<
2081 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
2082 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2083 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
2084 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
2087 // bullet 1 - sizeof...(Tp) == 0
2090 struct _LIBCPP_TEMPLATE_VIS common_type<> {};
2092 // bullet 2 - sizeof...(Tp) == 1
2094 template <class _Tp>
2095 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2096 : public common_type<_Tp, _Tp> {};
2098 // bullet 3 - sizeof...(Tp) == 2
2100 template <class _Tp, class _Up>
2101 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2103 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
2104 __common_type2_imp<_Tp, _Up>,
2105 common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
2109 // bullet 4 - sizeof...(Tp) > 2
2111 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2112 struct _LIBCPP_TEMPLATE_VIS
2113 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
2114 : __common_type_impl<
2115 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
2117 #undef _LIBCPP_OPTIONAL_PACK
2119 #if _LIBCPP_STD_VER > 11
2120 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2125 template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
2127 template <class _Tp, class _Arg>
2128 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2129 __is_assignable_test(int);
2131 template <class, class>
2132 false_type __is_assignable_test(...);
2135 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2136 struct __is_assignable_imp
2137 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2139 template <class _Tp, class _Arg>
2140 struct __is_assignable_imp<_Tp, _Arg, true>
2145 template <class _Tp, class _Arg>
2146 struct is_assignable
2147 : public __is_assignable_imp<_Tp, _Arg> {};
2149 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2150 template <class _Tp, class _Arg>
2151 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2152 = is_assignable<_Tp, _Arg>::value;
2155 // is_copy_assignable
2157 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2158 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2159 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2161 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2162 template <class _Tp>
2163 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2164 = is_copy_assignable<_Tp>::value;
2167 // is_move_assignable
2169 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2170 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2171 typename add_rvalue_reference<_Tp>::type> {};
2173 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2174 template <class _Tp>
2175 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2176 = is_move_assignable<_Tp>::value;
2181 // if it's a reference, return true
2182 // if it's a function, return false
2183 // if it's void, return false
2184 // if it's an array of unknown bound, return false
2185 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2186 // where _Up is remove_all_extents<_Tp>::type
2189 struct __is_destructible_apply { typedef int type; };
2191 template <typename _Tp>
2192 struct __is_destructor_wellformed {
2193 template <typename _Tp1>
2194 static char __test (
2195 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2198 template <typename _Tp1>
2199 static __two __test (...);
2201 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2204 template <class _Tp, bool>
2205 struct __destructible_imp;
2207 template <class _Tp>
2208 struct __destructible_imp<_Tp, false>
2209 : public _VSTD::integral_constant<bool,
2210 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2212 template <class _Tp>
2213 struct __destructible_imp<_Tp, true>
2214 : public _VSTD::true_type {};
2216 template <class _Tp, bool>
2217 struct __destructible_false;
2219 template <class _Tp>
2220 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2222 template <class _Tp>
2223 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2225 template <class _Tp>
2226 struct is_destructible
2227 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2229 template <class _Tp>
2230 struct is_destructible<_Tp[]>
2231 : public _VSTD::false_type {};
2234 struct is_destructible<void>
2235 : public _VSTD::false_type {};
2237 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2238 template <class _Tp>
2239 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2240 = is_destructible<_Tp>::value;
2245 template <class _Tp>
2246 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2247 typename remove_reference<_Tp>::type&&
2248 move(_Tp&& __t) _NOEXCEPT
2250 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
2251 return static_cast<_Up&&>(__t);
2254 template <class _Tp>
2255 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2257 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2259 return static_cast<_Tp&&>(__t);
2262 template <class _Tp>
2263 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2265 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2267 static_assert(!is_lvalue_reference<_Tp>::value,
2268 "can not forward an rvalue as an lvalue");
2269 return static_cast<_Tp&&>(__t);
2272 template <class _Tp>
2273 inline _LIBCPP_INLINE_VISIBILITY
2274 typename decay<_Tp>::type
2275 __decay_copy(_Tp&& __t)
2277 return _VSTD::forward<_Tp>(__t);
2280 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
2281 struct __member_pointer_traits_imp
2285 template <class _Rp, class _Class, class ..._Param>
2286 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2288 typedef _Class _ClassType;
2289 typedef _Rp _ReturnType;
2290 typedef _Rp (_FnType) (_Param...);
2293 template <class _Rp, class _Class, class ..._Param>
2294 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2296 typedef _Class _ClassType;
2297 typedef _Rp _ReturnType;
2298 typedef _Rp (_FnType) (_Param..., ...);
2301 template <class _Rp, class _Class, class ..._Param>
2302 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2304 typedef _Class const _ClassType;
2305 typedef _Rp _ReturnType;
2306 typedef _Rp (_FnType) (_Param...);
2309 template <class _Rp, class _Class, class ..._Param>
2310 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2312 typedef _Class const _ClassType;
2313 typedef _Rp _ReturnType;
2314 typedef _Rp (_FnType) (_Param..., ...);
2317 template <class _Rp, class _Class, class ..._Param>
2318 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2320 typedef _Class volatile _ClassType;
2321 typedef _Rp _ReturnType;
2322 typedef _Rp (_FnType) (_Param...);
2325 template <class _Rp, class _Class, class ..._Param>
2326 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2328 typedef _Class volatile _ClassType;
2329 typedef _Rp _ReturnType;
2330 typedef _Rp (_FnType) (_Param..., ...);
2333 template <class _Rp, class _Class, class ..._Param>
2334 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2336 typedef _Class const volatile _ClassType;
2337 typedef _Rp _ReturnType;
2338 typedef _Rp (_FnType) (_Param...);
2341 template <class _Rp, class _Class, class ..._Param>
2342 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2344 typedef _Class const volatile _ClassType;
2345 typedef _Rp _ReturnType;
2346 typedef _Rp (_FnType) (_Param..., ...);
2349 #if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2351 template <class _Rp, class _Class, class ..._Param>
2352 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2354 typedef _Class& _ClassType;
2355 typedef _Rp _ReturnType;
2356 typedef _Rp (_FnType) (_Param...);
2359 template <class _Rp, class _Class, class ..._Param>
2360 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2362 typedef _Class& _ClassType;
2363 typedef _Rp _ReturnType;
2364 typedef _Rp (_FnType) (_Param..., ...);
2367 template <class _Rp, class _Class, class ..._Param>
2368 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2370 typedef _Class const& _ClassType;
2371 typedef _Rp _ReturnType;
2372 typedef _Rp (_FnType) (_Param...);
2375 template <class _Rp, class _Class, class ..._Param>
2376 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2378 typedef _Class const& _ClassType;
2379 typedef _Rp _ReturnType;
2380 typedef _Rp (_FnType) (_Param..., ...);
2383 template <class _Rp, class _Class, class ..._Param>
2384 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2386 typedef _Class volatile& _ClassType;
2387 typedef _Rp _ReturnType;
2388 typedef _Rp (_FnType) (_Param...);
2391 template <class _Rp, class _Class, class ..._Param>
2392 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2394 typedef _Class volatile& _ClassType;
2395 typedef _Rp _ReturnType;
2396 typedef _Rp (_FnType) (_Param..., ...);
2399 template <class _Rp, class _Class, class ..._Param>
2400 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2402 typedef _Class const volatile& _ClassType;
2403 typedef _Rp _ReturnType;
2404 typedef _Rp (_FnType) (_Param...);
2407 template <class _Rp, class _Class, class ..._Param>
2408 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2410 typedef _Class const volatile& _ClassType;
2411 typedef _Rp _ReturnType;
2412 typedef _Rp (_FnType) (_Param..., ...);
2415 template <class _Rp, class _Class, class ..._Param>
2416 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2418 typedef _Class&& _ClassType;
2419 typedef _Rp _ReturnType;
2420 typedef _Rp (_FnType) (_Param...);
2423 template <class _Rp, class _Class, class ..._Param>
2424 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2426 typedef _Class&& _ClassType;
2427 typedef _Rp _ReturnType;
2428 typedef _Rp (_FnType) (_Param..., ...);
2431 template <class _Rp, class _Class, class ..._Param>
2432 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2434 typedef _Class const&& _ClassType;
2435 typedef _Rp _ReturnType;
2436 typedef _Rp (_FnType) (_Param...);
2439 template <class _Rp, class _Class, class ..._Param>
2440 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2442 typedef _Class const&& _ClassType;
2443 typedef _Rp _ReturnType;
2444 typedef _Rp (_FnType) (_Param..., ...);
2447 template <class _Rp, class _Class, class ..._Param>
2448 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2450 typedef _Class volatile&& _ClassType;
2451 typedef _Rp _ReturnType;
2452 typedef _Rp (_FnType) (_Param...);
2455 template <class _Rp, class _Class, class ..._Param>
2456 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2458 typedef _Class volatile&& _ClassType;
2459 typedef _Rp _ReturnType;
2460 typedef _Rp (_FnType) (_Param..., ...);
2463 template <class _Rp, class _Class, class ..._Param>
2464 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2466 typedef _Class const volatile&& _ClassType;
2467 typedef _Rp _ReturnType;
2468 typedef _Rp (_FnType) (_Param...);
2471 template <class _Rp, class _Class, class ..._Param>
2472 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2474 typedef _Class const volatile&& _ClassType;
2475 typedef _Rp _ReturnType;
2476 typedef _Rp (_FnType) (_Param..., ...);
2479 #endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2482 template <class _Rp, class _Class>
2483 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2485 typedef _Class _ClassType;
2486 typedef _Rp _ReturnType;
2489 template <class _MP>
2490 struct __member_pointer_traits
2491 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2492 is_member_function_pointer<_MP>::value,
2493 is_member_object_pointer<_MP>::value>
2495 // typedef ... _ClassType;
2496 // typedef ... _ReturnType;
2497 // typedef ... _FnType;
2501 template <class _DecayedFp>
2502 struct __member_pointer_class_type {};
2504 template <class _Ret, class _ClassType>
2505 struct __member_pointer_class_type<_Ret _ClassType::*> {
2506 typedef _ClassType type;
2511 template <class _Callable> class result_of;
2513 #ifdef _LIBCPP_HAS_NO_VARIADICS
2515 template <class _Fn, bool, bool>
2520 template <class _Fn>
2521 class __result_of<_Fn(), true, false>
2524 typedef decltype(declval<_Fn>()()) type;
2527 template <class _Fn, class _A0>
2528 class __result_of<_Fn(_A0), true, false>
2531 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2534 template <class _Fn, class _A0, class _A1>
2535 class __result_of<_Fn(_A0, _A1), true, false>
2538 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2541 template <class _Fn, class _A0, class _A1, class _A2>
2542 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2545 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2548 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2549 struct __result_of_mp;
2551 // member function pointer
2553 template <class _MP, class _Tp>
2554 struct __result_of_mp<_MP, _Tp, true>
2555 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2559 // member data pointer
2561 template <class _MP, class _Tp, bool>
2562 struct __result_of_mdp;
2564 template <class _Rp, class _Class, class _Tp>
2565 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2567 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2570 template <class _Rp, class _Class, class _Tp>
2571 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2573 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2576 template <class _Rp, class _Class, class _Tp>
2577 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2578 : public __result_of_mdp<_Rp _Class::*, _Tp,
2579 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2585 template <class _Fn, class _Tp>
2586 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2587 : public __result_of_mp<typename remove_reference<_Fn>::type,
2589 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2593 template <class _Fn, class _Tp, class _A0>
2594 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2595 : public __result_of_mp<typename remove_reference<_Fn>::type,
2597 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2601 template <class _Fn, class _Tp, class _A0, class _A1>
2602 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2603 : public __result_of_mp<typename remove_reference<_Fn>::type,
2605 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2609 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2610 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2611 : public __result_of_mp<typename remove_reference<_Fn>::type,
2613 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2619 template <class _Fn>
2620 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2621 : public __result_of<_Fn(),
2622 is_class<typename remove_reference<_Fn>::type>::value ||
2623 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2624 is_member_pointer<typename remove_reference<_Fn>::type>::value
2629 template <class _Fn, class _A0>
2630 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2631 : public __result_of<_Fn(_A0),
2632 is_class<typename remove_reference<_Fn>::type>::value ||
2633 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2634 is_member_pointer<typename remove_reference<_Fn>::type>::value
2639 template <class _Fn, class _A0, class _A1>
2640 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2641 : public __result_of<_Fn(_A0, _A1),
2642 is_class<typename remove_reference<_Fn>::type>::value ||
2643 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2644 is_member_pointer<typename remove_reference<_Fn>::type>::value
2649 template <class _Fn, class _A0, class _A1, class _A2>
2650 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
2651 : public __result_of<_Fn(_A0, _A1, _A2),
2652 is_class<typename remove_reference<_Fn>::type>::value ||
2653 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2654 is_member_pointer<typename remove_reference<_Fn>::type>::value
2659 #endif // _LIBCPP_HAS_NO_VARIADICS
2661 // template <class T, class... Args> struct is_constructible;
2663 namespace __is_construct
2668 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
2669 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
2671 template <class _Tp, class... _Args>
2672 struct __libcpp_is_constructible;
2674 template <class _To, class _From>
2675 struct __is_invalid_base_to_derived_cast {
2676 static_assert(is_reference<_To>::value, "Wrong specialization");
2677 using _RawFrom = __uncvref_t<_From>;
2678 using _RawTo = __uncvref_t<_To>;
2679 static const bool value = _And<
2680 _IsNotSame<_RawFrom, _RawTo>,
2681 is_base_of<_RawFrom, _RawTo>,
2682 _Not<__libcpp_is_constructible<_RawTo, _From>>
2686 template <class _To, class _From>
2687 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
2688 static_assert(is_reference<_To>::value, "Wrong specialization");
2691 template <class _ToRef, class _FromRef>
2692 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
2693 using _RawFrom = __uncvref_t<_FromRef>;
2694 using _RawTo = __uncvref_t<_ToRef>;
2695 static const bool value = _And<
2696 _Not<is_function<_RawTo>>,
2698 _IsSame<_RawFrom, _RawTo>,
2699 is_base_of<_RawTo, _RawFrom>>
2703 struct __is_constructible_helper
2705 template <class _To>
2706 static void __eat(_To);
2708 // This overload is needed to work around a Clang bug that disallows
2709 // static_cast<T&&>(e) for non-reference-compatible types.
2710 // Example: static_cast<int&&>(declval<double>());
2711 // NOTE: The static_cast implementation below is required to support
2712 // classes with explicit conversion operators.
2713 template <class _To, class _From,
2714 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
2715 static true_type __test_cast(int);
2717 template <class _To, class _From,
2718 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
2719 static integral_constant<bool,
2720 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
2721 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
2722 > __test_cast(long);
2724 template <class, class>
2725 static false_type __test_cast(...);
2727 template <class _Tp, class ..._Args,
2728 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
2729 static true_type __test_nary(int);
2730 template <class _Tp, class...>
2731 static false_type __test_nary(...);
2733 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
2734 static is_destructible<_Tp> __test_unary(int);
2735 template <class, class>
2736 static false_type __test_unary(...);
2739 template <class _Tp, bool = is_void<_Tp>::value>
2740 struct __is_default_constructible
2741 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
2744 template <class _Tp>
2745 struct __is_default_constructible<_Tp, true> : false_type {};
2747 template <class _Tp>
2748 struct __is_default_constructible<_Tp[], false> : false_type {};
2750 template <class _Tp, size_t _Nx>
2751 struct __is_default_constructible<_Tp[_Nx], false>
2752 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
2754 template <class _Tp, class... _Args>
2755 struct __libcpp_is_constructible
2757 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
2758 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
2762 template <class _Tp>
2763 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
2765 template <class _Tp, class _A0>
2766 struct __libcpp_is_constructible<_Tp, _A0>
2767 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
2770 template <class _Tp, class _A0>
2771 struct __libcpp_is_constructible<_Tp&, _A0>
2772 : public decltype(__is_constructible_helper::
2773 __test_cast<_Tp&, _A0>(0))
2776 template <class _Tp, class _A0>
2777 struct __libcpp_is_constructible<_Tp&&, _A0>
2778 : public decltype(__is_constructible_helper::
2779 __test_cast<_Tp&&, _A0>(0))
2784 #if __has_feature(is_constructible)
2785 template <class _Tp, class ..._Args>
2786 struct _LIBCPP_TEMPLATE_VIS is_constructible
2787 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2790 template <class _Tp, class... _Args>
2791 struct _LIBCPP_TEMPLATE_VIS is_constructible
2792 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
2795 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2796 template <class _Tp, class ..._Args>
2797 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
2798 = is_constructible<_Tp, _Args...>::value;
2801 // is_default_constructible
2803 template <class _Tp>
2804 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
2805 : public is_constructible<_Tp>
2808 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2809 template <class _Tp>
2810 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
2811 = is_default_constructible<_Tp>::value;
2814 #ifndef _LIBCPP_CXX03_LANG
2815 // First of all, we can't implement this check in C++03 mode because the {}
2816 // default initialization syntax isn't valid.
2817 // Second, we implement the trait in a funny manner with two defaulted template
2818 // arguments to workaround Clang's PR43454.
2819 template <class _Tp>
2820 void __test_implicit_default_constructible(_Tp);
2822 template <class _Tp, class = void, bool = is_default_constructible<_Tp>::value>
2823 struct __is_implicitly_default_constructible
2827 template <class _Tp>
2828 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true>
2832 template <class _Tp>
2833 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false>
2838 // is_copy_constructible
2840 template <class _Tp>
2841 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
2842 : public is_constructible<_Tp,
2843 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2845 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2846 template <class _Tp>
2847 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
2848 = is_copy_constructible<_Tp>::value;
2851 // is_move_constructible
2853 template <class _Tp>
2854 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
2855 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2858 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2859 template <class _Tp>
2860 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
2861 = is_move_constructible<_Tp>::value;
2864 // is_trivially_constructible
2866 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
2868 template <class _Tp, class... _Args>
2869 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2870 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2874 #else // !__has_feature(is_trivially_constructible)
2876 template <class _Tp, class... _Args>
2877 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2882 template <class _Tp>
2883 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
2884 #if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC)
2885 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2887 : integral_constant<bool, is_scalar<_Tp>::value>
2892 template <class _Tp>
2893 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
2894 : integral_constant<bool, is_scalar<_Tp>::value>
2898 template <class _Tp>
2899 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
2900 : integral_constant<bool, is_scalar<_Tp>::value>
2904 template <class _Tp>
2905 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
2906 : integral_constant<bool, is_scalar<_Tp>::value>
2910 #endif // !__has_feature(is_trivially_constructible)
2913 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2914 template <class _Tp, class... _Args>
2915 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
2916 = is_trivially_constructible<_Tp, _Args...>::value;
2919 // is_trivially_default_constructible
2921 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
2922 : public is_trivially_constructible<_Tp>
2925 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2926 template <class _Tp>
2927 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
2928 = is_trivially_default_constructible<_Tp>::value;
2931 // is_trivially_copy_constructible
2933 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
2934 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2937 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2938 template <class _Tp>
2939 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
2940 = is_trivially_copy_constructible<_Tp>::value;
2943 // is_trivially_move_constructible
2945 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
2946 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2949 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2950 template <class _Tp>
2951 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
2952 = is_trivially_move_constructible<_Tp>::value;
2955 // is_trivially_assignable
2957 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
2959 template <class _Tp, class _Arg>
2960 struct is_trivially_assignable
2961 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2965 #else // !__has_feature(is_trivially_assignable)
2967 template <class _Tp, class _Arg>
2968 struct is_trivially_assignable
2969 : public false_type {};
2971 template <class _Tp>
2972 struct is_trivially_assignable<_Tp&, _Tp>
2973 : integral_constant<bool, is_scalar<_Tp>::value> {};
2975 template <class _Tp>
2976 struct is_trivially_assignable<_Tp&, _Tp&>
2977 : integral_constant<bool, is_scalar<_Tp>::value> {};
2979 template <class _Tp>
2980 struct is_trivially_assignable<_Tp&, const _Tp&>
2981 : integral_constant<bool, is_scalar<_Tp>::value> {};
2983 template <class _Tp>
2984 struct is_trivially_assignable<_Tp&, _Tp&&>
2985 : integral_constant<bool, is_scalar<_Tp>::value> {};
2987 #endif // !__has_feature(is_trivially_assignable)
2989 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2990 template <class _Tp, class _Arg>
2991 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
2992 = is_trivially_assignable<_Tp, _Arg>::value;
2995 // is_trivially_copy_assignable
2997 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
2998 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
2999 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3001 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3002 template <class _Tp>
3003 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3004 = is_trivially_copy_assignable<_Tp>::value;
3007 // is_trivially_move_assignable
3009 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3010 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3011 typename add_rvalue_reference<_Tp>::type>
3014 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3015 template <class _Tp>
3016 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3017 = is_trivially_move_assignable<_Tp>::value;
3020 // is_trivially_destructible
3022 #if __has_keyword(__is_trivially_destructible)
3024 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3025 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
3027 #elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
3029 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3030 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3034 template <class _Tp> struct __libcpp_trivial_destructor
3035 : public integral_constant<bool, is_scalar<_Tp>::value ||
3036 is_reference<_Tp>::value> {};
3038 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3039 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3041 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3042 : public false_type {};
3046 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3047 template <class _Tp>
3048 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3049 = is_trivially_destructible<_Tp>::value;
3052 // is_nothrow_constructible
3054 #if __has_keyword(__is_nothrow_constructible)
3056 template <class _Tp, class... _Args>
3057 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3058 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
3062 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3064 template <class _Tp, class... _Args>
3065 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3066 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3070 template <class _Tp>
3071 void __implicit_conversion_to(_Tp) noexcept { }
3073 template <class _Tp, class _Arg>
3074 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3075 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3079 template <class _Tp, bool _IsReference, class... _Args>
3080 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3085 template <class _Tp, class... _Args>
3086 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3087 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3091 template <class _Tp, size_t _Ns>
3092 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3093 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3097 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3100 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3101 template <class _Tp, class ..._Args>
3102 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3103 = is_nothrow_constructible<_Tp, _Args...>::value;
3106 // is_nothrow_default_constructible
3108 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3109 : public is_nothrow_constructible<_Tp>
3112 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3113 template <class _Tp>
3114 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3115 = is_nothrow_default_constructible<_Tp>::value;
3118 // is_nothrow_copy_constructible
3120 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3121 : public is_nothrow_constructible<_Tp,
3122 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3124 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3125 template <class _Tp>
3126 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3127 = is_nothrow_copy_constructible<_Tp>::value;
3130 // is_nothrow_move_constructible
3132 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3133 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3136 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3137 template <class _Tp>
3138 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3139 = is_nothrow_move_constructible<_Tp>::value;
3142 // is_nothrow_assignable
3144 #if __has_keyword(__is_nothrow_assignable)
3146 template <class _Tp, class _Arg>
3147 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3148 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
3152 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3154 template <class _Tp, class _Arg>
3155 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3160 template <class _Tp, class _Arg>
3161 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3162 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3166 template <class _Tp, class _Arg>
3167 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3168 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3172 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3174 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3175 template <class _Tp, class _Arg>
3176 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3177 = is_nothrow_assignable<_Tp, _Arg>::value;
3180 // is_nothrow_copy_assignable
3182 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3183 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3184 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3186 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3187 template <class _Tp>
3188 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3189 = is_nothrow_copy_assignable<_Tp>::value;
3192 // is_nothrow_move_assignable
3194 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3195 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3196 typename add_rvalue_reference<_Tp>::type>
3199 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3200 template <class _Tp>
3201 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3202 = is_nothrow_move_assignable<_Tp>::value;
3205 // is_nothrow_destructible
3207 #if !defined(_LIBCPP_CXX03_LANG)
3209 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3211 template <class _Tp>
3212 struct __libcpp_is_nothrow_destructible<false, _Tp>
3217 template <class _Tp>
3218 struct __libcpp_is_nothrow_destructible<true, _Tp>
3219 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3223 template <class _Tp>
3224 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3225 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3229 template <class _Tp, size_t _Ns>
3230 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3231 : public is_nothrow_destructible<_Tp>
3235 template <class _Tp>
3236 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3241 template <class _Tp>
3242 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3249 template <class _Tp> struct __libcpp_nothrow_destructor
3250 : public integral_constant<bool, is_scalar<_Tp>::value ||
3251 is_reference<_Tp>::value> {};
3253 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3254 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3256 template <class _Tp>
3257 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3258 : public false_type {};
3262 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3263 template <class _Tp>
3264 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3265 = is_nothrow_destructible<_Tp>::value;
3270 #if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
3272 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3273 : public integral_constant<bool, __is_pod(_Tp)> {};
3277 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3278 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3279 is_trivially_copy_constructible<_Tp>::value &&
3280 is_trivially_copy_assignable<_Tp>::value &&
3281 is_trivially_destructible<_Tp>::value> {};
3285 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3286 template <class _Tp>
3287 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
3288 = is_pod<_Tp>::value;
3293 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
3294 : public integral_constant<bool, __is_literal_type(_Tp)>
3297 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3298 template <class _Tp>
3299 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
3300 = is_literal_type<_Tp>::value;
3303 // is_standard_layout;
3305 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3306 #if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
3307 : public integral_constant<bool, __is_standard_layout(_Tp)>
3309 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3313 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3314 template <class _Tp>
3315 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
3316 = is_standard_layout<_Tp>::value;
3319 // is_trivially_copyable;
3321 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3322 #if __has_feature(is_trivially_copyable)
3323 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3324 #elif _GNUC_VER >= 501
3325 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3327 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3331 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3332 template <class _Tp>
3333 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3334 = is_trivially_copyable<_Tp>::value;
3339 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3340 #if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
3341 : public integral_constant<bool, __is_trivial(_Tp)>
3343 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3344 is_trivially_default_constructible<_Tp>::value>
3348 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3349 template <class _Tp>
3350 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
3351 = is_trivial<_Tp>::value;
3354 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3355 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3356 template <class _Tp> struct __is_reference_wrapper
3357 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3359 #ifndef _LIBCPP_CXX03_LANG
3361 template <class _Fp, class _A0,
3362 class _DecayFp = typename decay<_Fp>::type,
3363 class _DecayA0 = typename decay<_A0>::type,
3364 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3365 using __enable_if_bullet1 = typename enable_if
3367 is_member_function_pointer<_DecayFp>::value
3368 && is_base_of<_ClassT, _DecayA0>::value
3371 template <class _Fp, class _A0,
3372 class _DecayFp = typename decay<_Fp>::type,
3373 class _DecayA0 = typename decay<_A0>::type>
3374 using __enable_if_bullet2 = typename enable_if
3376 is_member_function_pointer<_DecayFp>::value
3377 && __is_reference_wrapper<_DecayA0>::value
3380 template <class _Fp, class _A0,
3381 class _DecayFp = typename decay<_Fp>::type,
3382 class _DecayA0 = typename decay<_A0>::type,
3383 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3384 using __enable_if_bullet3 = typename enable_if
3386 is_member_function_pointer<_DecayFp>::value
3387 && !is_base_of<_ClassT, _DecayA0>::value
3388 && !__is_reference_wrapper<_DecayA0>::value
3391 template <class _Fp, class _A0,
3392 class _DecayFp = typename decay<_Fp>::type,
3393 class _DecayA0 = typename decay<_A0>::type,
3394 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3395 using __enable_if_bullet4 = typename enable_if
3397 is_member_object_pointer<_DecayFp>::value
3398 && is_base_of<_ClassT, _DecayA0>::value
3401 template <class _Fp, class _A0,
3402 class _DecayFp = typename decay<_Fp>::type,
3403 class _DecayA0 = typename decay<_A0>::type>
3404 using __enable_if_bullet5 = typename enable_if
3406 is_member_object_pointer<_DecayFp>::value
3407 && __is_reference_wrapper<_DecayA0>::value
3410 template <class _Fp, class _A0,
3411 class _DecayFp = typename decay<_Fp>::type,
3412 class _DecayA0 = typename decay<_A0>::type,
3413 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3414 using __enable_if_bullet6 = typename enable_if
3416 is_member_object_pointer<_DecayFp>::value
3417 && !is_base_of<_ClassT, _DecayA0>::value
3418 && !__is_reference_wrapper<_DecayA0>::value
3421 // __invoke forward declarations
3423 // fall back - none of the bullets
3425 #define _LIBCPP_INVOKE_RETURN(...) \
3426 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
3427 { return __VA_ARGS__; }
3429 template <class ..._Args>
3430 auto __invoke(__any, _Args&& ...__args) -> __nat;
3432 template <class ..._Args>
3433 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
3435 // bullets 1, 2 and 3
3437 template <class _Fp, class _A0, class ..._Args,
3438 class = __enable_if_bullet1<_Fp, _A0>>
3439 inline _LIBCPP_INLINE_VISIBILITY
3441 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3442 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3444 template <class _Fp, class _A0, class ..._Args,
3445 class = __enable_if_bullet1<_Fp, _A0>>
3446 inline _LIBCPP_INLINE_VISIBILITY
3447 _LIBCPP_CONSTEXPR auto
3448 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3449 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3451 template <class _Fp, class _A0, class ..._Args,
3452 class = __enable_if_bullet2<_Fp, _A0>>
3453 inline _LIBCPP_INLINE_VISIBILITY
3455 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3456 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3458 template <class _Fp, class _A0, class ..._Args,
3459 class = __enable_if_bullet2<_Fp, _A0>>
3460 inline _LIBCPP_INLINE_VISIBILITY
3461 _LIBCPP_CONSTEXPR auto
3462 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3463 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3465 template <class _Fp, class _A0, class ..._Args,
3466 class = __enable_if_bullet3<_Fp, _A0>>
3467 inline _LIBCPP_INLINE_VISIBILITY
3469 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3470 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3472 template <class _Fp, class _A0, class ..._Args,
3473 class = __enable_if_bullet3<_Fp, _A0>>
3474 inline _LIBCPP_INLINE_VISIBILITY
3475 _LIBCPP_CONSTEXPR auto
3476 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3477 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3479 // bullets 4, 5 and 6
3481 template <class _Fp, class _A0,
3482 class = __enable_if_bullet4<_Fp, _A0>>
3483 inline _LIBCPP_INLINE_VISIBILITY
3485 __invoke(_Fp&& __f, _A0&& __a0)
3486 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3488 template <class _Fp, class _A0,
3489 class = __enable_if_bullet4<_Fp, _A0>>
3490 inline _LIBCPP_INLINE_VISIBILITY
3491 _LIBCPP_CONSTEXPR auto
3492 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3493 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3495 template <class _Fp, class _A0,
3496 class = __enable_if_bullet5<_Fp, _A0>>
3497 inline _LIBCPP_INLINE_VISIBILITY
3499 __invoke(_Fp&& __f, _A0&& __a0)
3500 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3502 template <class _Fp, class _A0,
3503 class = __enable_if_bullet5<_Fp, _A0>>
3504 inline _LIBCPP_INLINE_VISIBILITY
3505 _LIBCPP_CONSTEXPR auto
3506 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3507 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3509 template <class _Fp, class _A0,
3510 class = __enable_if_bullet6<_Fp, _A0>>
3511 inline _LIBCPP_INLINE_VISIBILITY
3513 __invoke(_Fp&& __f, _A0&& __a0)
3514 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3516 template <class _Fp, class _A0,
3517 class = __enable_if_bullet6<_Fp, _A0>>
3518 inline _LIBCPP_INLINE_VISIBILITY
3519 _LIBCPP_CONSTEXPR auto
3520 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3521 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3525 template <class _Fp, class ..._Args>
3526 inline _LIBCPP_INLINE_VISIBILITY
3528 __invoke(_Fp&& __f, _Args&& ...__args)
3529 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3531 template <class _Fp, class ..._Args>
3532 inline _LIBCPP_INLINE_VISIBILITY
3533 _LIBCPP_CONSTEXPR auto
3534 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
3535 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3537 #undef _LIBCPP_INVOKE_RETURN
3540 template <class _Ret, class _Fp, class ..._Args>
3541 struct __invokable_r
3543 template <class _XFp, class ..._XArgs>
3544 static auto __try_call(int) -> decltype(
3545 _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...));
3546 template <class _XFp, class ..._XArgs>
3547 static __nat __try_call(...);
3549 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
3550 // or incomplete array types as required by the standard.
3551 using _Result = decltype(__try_call<_Fp, _Args...>(0));
3554 typename conditional<
3555 _IsNotSame<_Result, __nat>::value,
3556 typename conditional<
3557 is_void<_Ret>::value,
3559 is_convertible<_Result, _Ret>
3563 static const bool value = type::value;
3565 template <class _Fp, class ..._Args>
3566 using __invokable = __invokable_r<void, _Fp, _Args...>;
3568 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
3569 struct __nothrow_invokable_r_imp {
3570 static const bool value = false;
3573 template <class _Ret, class _Fp, class ..._Args>
3574 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
3576 typedef __nothrow_invokable_r_imp _ThisT;
3578 template <class _Tp>
3579 static void __test_noexcept(_Tp) noexcept;
3581 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
3582 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
3585 template <class _Ret, class _Fp, class ..._Args>
3586 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
3588 static const bool value = noexcept(
3589 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
3592 template <class _Ret, class _Fp, class ..._Args>
3593 using __nothrow_invokable_r =
3594 __nothrow_invokable_r_imp<
3595 __invokable_r<_Ret, _Fp, _Args...>::value,
3596 is_void<_Ret>::value,
3600 template <class _Fp, class ..._Args>
3601 using __nothrow_invokable =
3602 __nothrow_invokable_r_imp<
3603 __invokable<_Fp, _Args...>::value,
3604 true, void, _Fp, _Args...
3607 template <class _Fp, class ..._Args>
3610 __invokable<_Fp, _Args...>::value,
3611 typename __invokable_r<void, _Fp, _Args...>::_Result>
3617 template <class _Fp, class ..._Args>
3618 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
3619 : public __invoke_of<_Fp, _Args...>
3623 #if _LIBCPP_STD_VER > 11
3624 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3627 #if _LIBCPP_STD_VER > 14
3631 template <class _Fn, class... _Args>
3632 struct _LIBCPP_TEMPLATE_VIS invoke_result
3633 : __invoke_of<_Fn, _Args...>
3637 template <class _Fn, class... _Args>
3638 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
3642 template <class _Fn, class ..._Args>
3643 struct _LIBCPP_TEMPLATE_VIS is_invocable
3644 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
3646 template <class _Ret, class _Fn, class ..._Args>
3647 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
3648 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
3650 template <class _Fn, class ..._Args>
3651 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
3652 = is_invocable<_Fn, _Args...>::value;
3654 template <class _Ret, class _Fn, class ..._Args>
3655 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
3656 = is_invocable_r<_Ret, _Fn, _Args...>::value;
3658 // is_nothrow_invocable
3660 template <class _Fn, class ..._Args>
3661 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
3662 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
3664 template <class _Ret, class _Fn, class ..._Args>
3665 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
3666 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
3668 template <class _Fn, class ..._Args>
3669 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
3670 = is_nothrow_invocable<_Fn, _Args...>::value;
3672 template <class _Ret, class _Fn, class ..._Args>
3673 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
3674 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
3676 #endif // _LIBCPP_STD_VER > 14
3678 #endif // !defined(_LIBCPP_CXX03_LANG)
3680 template <class _Tp> struct __is_swappable;
3681 template <class _Tp> struct __is_nothrow_swappable;
3683 // swap, swap_ranges
3685 template <class _ForwardIterator1, class _ForwardIterator2>
3686 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3688 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2);
3690 template <class _Tp>
3691 inline _LIBCPP_INLINE_VISIBILITY
3692 #ifndef _LIBCPP_CXX03_LANG
3695 is_move_constructible<_Tp>::value &&
3696 is_move_assignable<_Tp>::value
3701 _LIBCPP_CONSTEXPR_AFTER_CXX17
3702 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3703 is_nothrow_move_assignable<_Tp>::value)
3705 _Tp __t(_VSTD::move(__x));
3706 __x = _VSTD::move(__y);
3707 __y = _VSTD::move(__t);
3710 template<class _Tp, size_t _Np>
3711 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3713 __is_swappable<_Tp>::value
3715 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
3717 _VSTD::swap_ranges(__a, __a + _Np, __b);
3720 template <class _ForwardIterator1, class _ForwardIterator2>
3721 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3723 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
3725 for(; __first1 != __last1; ++__first1, (void) ++__first2)
3726 swap(*__first1, *__first2);
3732 template <class _ForwardIterator1, class _ForwardIterator2>
3733 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3735 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3736 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3737 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3738 *_VSTD::declval<_ForwardIterator2>())))
3747 // ALL generic swap overloads MUST already have a declaration available at this point.
3749 template <class _Tp, class _Up = _Tp,
3750 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
3751 struct __swappable_with
3753 template <class _LHS, class _RHS>
3754 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
3756 template <class, class>
3757 static __nat __test_swap(long);
3759 // Extra parens are needed for the C++03 definition of decltype.
3760 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
3761 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
3763 static const bool value = _IsNotSame<__swap1, __nat>::value
3764 && _IsNotSame<__swap2, __nat>::value;
3767 template <class _Tp, class _Up>
3768 struct __swappable_with<_Tp, _Up, false> : false_type {};
3770 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
3771 struct __nothrow_swappable_with {
3772 static const bool value =
3773 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
3774 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
3775 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
3781 template <class _Tp, class _Up>
3782 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
3786 template <class _Tp>
3787 struct __is_swappable
3788 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
3792 template <class _Tp>
3793 struct __is_nothrow_swappable
3794 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
3798 #if _LIBCPP_STD_VER > 14
3800 template <class _Tp, class _Up>
3801 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
3802 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
3806 template <class _Tp>
3807 struct _LIBCPP_TEMPLATE_VIS is_swappable
3808 : public conditional<
3809 __is_referenceable<_Tp>::value,
3811 typename add_lvalue_reference<_Tp>::type,
3812 typename add_lvalue_reference<_Tp>::type>,
3818 template <class _Tp, class _Up>
3819 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
3820 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
3824 template <class _Tp>
3825 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
3826 : public conditional<
3827 __is_referenceable<_Tp>::value,
3828 is_nothrow_swappable_with<
3829 typename add_lvalue_reference<_Tp>::type,
3830 typename add_lvalue_reference<_Tp>::type>,
3836 template <class _Tp, class _Up>
3837 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
3838 = is_swappable_with<_Tp, _Up>::value;
3840 template <class _Tp>
3841 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
3842 = is_swappable<_Tp>::value;
3844 template <class _Tp, class _Up>
3845 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
3846 = is_nothrow_swappable_with<_Tp, _Up>::value;
3848 template <class _Tp>
3849 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
3850 = is_nothrow_swappable<_Tp>::value;
3852 #endif // _LIBCPP_STD_VER > 14
3854 template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
3856 template <class _Tp>
3857 struct __underlying_type_impl<_Tp, false> {};
3859 template <class _Tp>
3860 struct __underlying_type_impl<_Tp, true>
3862 typedef __underlying_type(_Tp) type;
3865 template <class _Tp>
3866 struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
3868 #if _LIBCPP_STD_VER > 11
3869 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3873 template <class _Tp, bool = is_enum<_Tp>::value>
3874 struct __sfinae_underlying_type
3876 typedef typename underlying_type<_Tp>::type type;
3877 typedef decltype(((type)1) + 0) __promoted_type;
3880 template <class _Tp>
3881 struct __sfinae_underlying_type<_Tp, false> {};
3883 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3884 int __convert_to_integral(int __val) { return __val; }
3886 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3887 unsigned __convert_to_integral(unsigned __val) { return __val; }
3889 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3890 long __convert_to_integral(long __val) { return __val; }
3892 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3893 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
3895 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3896 long long __convert_to_integral(long long __val) { return __val; }
3898 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3899 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
3901 template<typename _Fp>
3902 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3903 typename enable_if<is_floating_point<_Fp>::value, long long>::type
3904 __convert_to_integral(_Fp __val) { return __val; }
3906 #ifndef _LIBCPP_HAS_NO_INT128
3907 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3908 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
3910 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3911 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
3914 template <class _Tp>
3915 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3916 typename __sfinae_underlying_type<_Tp>::__promoted_type
3917 __convert_to_integral(_Tp __val) { return __val; }
3919 #ifndef _LIBCPP_CXX03_LANG
3921 template <class _Tp>
3922 struct __has_operator_addressof_member_imp
3924 template <class _Up>
3925 static auto __test(int)
3926 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
3928 static auto __test(long) -> false_type;
3930 static const bool value = decltype(__test<_Tp>(0))::value;
3933 template <class _Tp>
3934 struct __has_operator_addressof_free_imp
3936 template <class _Up>
3937 static auto __test(int)
3938 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
3940 static auto __test(long) -> false_type;
3942 static const bool value = decltype(__test<_Tp>(0))::value;
3945 template <class _Tp>
3946 struct __has_operator_addressof
3947 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
3948 || __has_operator_addressof_free_imp<_Tp>::value>
3951 #endif // _LIBCPP_CXX03_LANG
3953 #if _LIBCPP_STD_VER > 14
3955 template <class...> using void_t = void;
3957 template <class... _Args>
3958 struct conjunction : _And<_Args...> {};
3959 template<class... _Args>
3960 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
3961 = conjunction<_Args...>::value;
3963 template <class... _Args>
3964 struct disjunction : _Or<_Args...> {};
3965 template<class... _Args>
3966 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
3967 = disjunction<_Args...>::value;
3969 template <class _Tp>
3970 struct negation : _Not<_Tp> {};
3972 _LIBCPP_INLINE_VAR constexpr bool negation_v
3973 = negation<_Tp>::value;
3974 #endif // _LIBCPP_STD_VER > 14
3976 // These traits are used in __tree and __hash_table
3977 #ifndef _LIBCPP_CXX03_LANG
3978 struct __extract_key_fail_tag {};
3979 struct __extract_key_self_tag {};
3980 struct __extract_key_first_tag {};
3982 template <class _ValTy, class _Key,
3983 class _RawValTy = typename __unconstref<_ValTy>::type>
3984 struct __can_extract_key
3985 : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
3986 __extract_key_fail_tag>::type {};
3988 template <class _Pair, class _Key, class _First, class _Second>
3989 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
3990 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
3991 __extract_key_first_tag, __extract_key_fail_tag>::type {};
3993 // __can_extract_map_key uses true_type/false_type instead of the tags.
3994 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
3995 // and _ValTy == _Key.
3996 template <class _ValTy, class _Key, class _ContainerValueTy,
3997 class _RawValTy = typename __unconstref<_ValTy>::type>
3998 struct __can_extract_map_key
3999 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
4001 // This specialization returns __extract_key_fail_tag for non-map containers
4002 // because _Key == _ContainerValueTy
4003 template <class _ValTy, class _Key, class _RawValTy>
4004 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4009 #ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
4010 #if _LIBCPP_STD_VER > 17
4011 _LIBCPP_INLINE_VISIBILITY
4012 inline constexpr bool is_constant_evaluated() noexcept {
4013 return __builtin_is_constant_evaluated();
4017 inline _LIBCPP_CONSTEXPR
4018 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
4020 inline _LIBCPP_CONSTEXPR
4021 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; }
4024 template <class _CharT>
4025 using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
4027 _LIBCPP_END_NAMESPACE_STD
4029 #if _LIBCPP_STD_VER > 14
4031 namespace std // purposefully not versioned
4033 template <class _Integer>
4034 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4035 operator<<=(byte& __lhs, _Integer __shift) noexcept
4036 { return __lhs = __lhs << __shift; }
4038 template <class _Integer>
4039 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4040 operator<< (byte __lhs, _Integer __shift) noexcept
4041 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
4043 template <class _Integer>
4044 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4045 operator>>=(byte& __lhs, _Integer __shift) noexcept
4046 { return __lhs = __lhs >> __shift; }
4048 template <class _Integer>
4049 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4050 operator>> (byte __lhs, _Integer __shift) noexcept
4051 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4053 template <class _Integer>
4054 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4055 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4060 #endif // _LIBCPP_TYPE_TRAITS