2 //===------------------------ type_traits ---------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_TYPE_TRAITS
11 #define _LIBCPP_TYPE_TRAITS
20 template <class T, T v> struct integral_constant;
21 typedef integral_constant<bool, true> true_type; // C++11
22 typedef integral_constant<bool, false> false_type; // C++11
24 template <bool B> // C++14
25 using bool_constant = integral_constant<bool, B>; // C++14
26 typedef bool_constant<true> true_type; // C++14
27 typedef bool_constant<false> false_type; // C++14
30 template <bool, class T = void> struct enable_if;
31 template <bool, class T, class F> struct conditional;
33 // Primary classification traits:
34 template <class T> struct is_void;
35 template <class T> struct is_null_pointer; // C++14
36 template <class T> struct is_integral;
37 template <class T> struct is_floating_point;
38 template <class T> struct is_array;
39 template <class T> struct is_pointer;
40 template <class T> struct is_lvalue_reference;
41 template <class T> struct is_rvalue_reference;
42 template <class T> struct is_member_object_pointer;
43 template <class T> struct is_member_function_pointer;
44 template <class T> struct is_enum;
45 template <class T> struct is_union;
46 template <class T> struct is_class;
47 template <class T> struct is_function;
49 // Secondary classification traits:
50 template <class T> struct is_reference;
51 template <class T> struct is_arithmetic;
52 template <class T> struct is_fundamental;
53 template <class T> struct is_member_pointer;
54 template <class T> struct is_scalar;
55 template <class T> struct is_object;
56 template <class T> struct is_compound;
58 // Const-volatile properties and transformations:
59 template <class T> struct is_const;
60 template <class T> struct is_volatile;
61 template <class T> struct remove_const;
62 template <class T> struct remove_volatile;
63 template <class T> struct remove_cv;
64 template <class T> struct add_const;
65 template <class T> struct add_volatile;
66 template <class T> struct add_cv;
68 // Reference transformations:
69 template <class T> struct remove_reference;
70 template <class T> struct add_lvalue_reference;
71 template <class T> struct add_rvalue_reference;
73 // Pointer transformations:
74 template <class T> struct remove_pointer;
75 template <class T> struct add_pointer;
77 template<class T> struct type_identity; // C++20
79 using type_identity_t = typename type_identity<T>::type; // C++20
81 // Integral properties:
82 template <class T> struct is_signed;
83 template <class T> struct is_unsigned;
84 template <class T> struct make_signed;
85 template <class T> struct make_unsigned;
87 // Array properties and transformations:
88 template <class T> struct rank;
89 template <class T, unsigned I = 0> struct extent;
90 template <class T> struct remove_extent;
91 template <class T> struct remove_all_extents;
93 template <class T> struct is_bounded_array; // C++20
94 template <class T> struct is_unbounded_array; // C++20
96 // Member introspection:
97 template <class T> struct is_pod;
98 template <class T> struct is_trivial;
99 template <class T> struct is_trivially_copyable;
100 template <class T> struct is_standard_layout;
101 template <class T> struct is_literal_type;
102 template <class T> struct is_empty;
103 template <class T> struct is_polymorphic;
104 template <class T> struct is_abstract;
105 template <class T> struct is_final; // C++14
106 template <class T> struct is_aggregate; // C++17
108 template <class T, class... Args> struct is_constructible;
109 template <class T> struct is_default_constructible;
110 template <class T> struct is_copy_constructible;
111 template <class T> struct is_move_constructible;
112 template <class T, class U> struct is_assignable;
113 template <class T> struct is_copy_assignable;
114 template <class T> struct is_move_assignable;
115 template <class T, class U> struct is_swappable_with; // C++17
116 template <class T> struct is_swappable; // C++17
117 template <class T> struct is_destructible;
119 template <class T, class... Args> struct is_trivially_constructible;
120 template <class T> struct is_trivially_default_constructible;
121 template <class T> struct is_trivially_copy_constructible;
122 template <class T> struct is_trivially_move_constructible;
123 template <class T, class U> struct is_trivially_assignable;
124 template <class T> struct is_trivially_copy_assignable;
125 template <class T> struct is_trivially_move_assignable;
126 template <class T> struct is_trivially_destructible;
128 template <class T, class... Args> struct is_nothrow_constructible;
129 template <class T> struct is_nothrow_default_constructible;
130 template <class T> struct is_nothrow_copy_constructible;
131 template <class T> struct is_nothrow_move_constructible;
132 template <class T, class U> struct is_nothrow_assignable;
133 template <class T> struct is_nothrow_copy_assignable;
134 template <class T> struct is_nothrow_move_assignable;
135 template <class T, class U> struct is_nothrow_swappable_with; // C++17
136 template <class T> struct is_nothrow_swappable; // C++17
137 template <class T> struct is_nothrow_destructible;
139 template <class T> struct has_virtual_destructor;
141 template<class T> struct has_unique_object_representations; // C++17
143 // Relationships between types:
144 template <class T, class U> struct is_same;
145 template <class Base, class Derived> struct is_base_of;
147 template <class From, class To> struct is_convertible;
148 template <typename From, typename To> struct is_nothrow_convertible; // C++20
149 template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20
151 template <class Fn, class... ArgTypes> struct is_invocable;
152 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
154 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
155 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
157 // Alignment properties and transformations:
158 template <class T> struct alignment_of;
159 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
160 struct aligned_storage;
161 template <size_t Len, class... Types> struct aligned_union;
162 template <class T> struct remove_cvref; // C++20
164 template <class T> struct decay;
165 template <class... T> struct common_type;
166 template <class T> struct underlying_type;
167 template <class> class result_of; // undefined
168 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
169 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
171 // const-volatile modifications:
173 using remove_const_t = typename remove_const<T>::type; // C++14
175 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
177 using remove_cv_t = typename remove_cv<T>::type; // C++14
179 using add_const_t = typename add_const<T>::type; // C++14
181 using add_volatile_t = typename add_volatile<T>::type; // C++14
183 using add_cv_t = typename add_cv<T>::type; // C++14
185 // reference modifications:
187 using remove_reference_t = typename remove_reference<T>::type; // C++14
189 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
191 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
193 // sign modifications:
195 using make_signed_t = typename make_signed<T>::type; // C++14
197 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
199 // array modifications:
201 using remove_extent_t = typename remove_extent<T>::type; // C++14
203 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
206 inline constexpr bool is_bounded_array_v
207 = is_bounded_array<T>::value; // C++20
208 inline constexpr bool is_unbounded_array_v
209 = is_unbounded_array<T>::value; // C++20
211 // pointer modifications:
213 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
215 using add_pointer_t = typename add_pointer<T>::type; // C++14
217 // other transformations:
218 template <size_t Len, std::size_t Align=default-alignment>
219 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
220 template <std::size_t Len, class... Types>
221 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
223 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
225 using decay_t = typename decay<T>::type; // C++14
226 template <bool b, class T=void>
227 using enable_if_t = typename enable_if<b,T>::type; // C++14
228 template <bool b, class T, class F>
229 using conditional_t = typename conditional<b,T,F>::type; // C++14
230 template <class... T>
231 using common_type_t = typename common_type<T...>::type; // C++14
233 using underlying_type_t = typename underlying_type<T>::type; // C++14
235 using result_of_t = typename result_of<T>::type; // C++14
236 template <class Fn, class... ArgTypes>
237 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
240 using void_t = void; // C++17
242 // See C++14 20.10.4.1, primary type categories
243 template <class T> inline constexpr bool is_void_v
244 = is_void<T>::value; // C++17
245 template <class T> inline constexpr bool is_null_pointer_v
246 = is_null_pointer<T>::value; // C++17
247 template <class T> inline constexpr bool is_integral_v
248 = is_integral<T>::value; // C++17
249 template <class T> inline constexpr bool is_floating_point_v
250 = is_floating_point<T>::value; // C++17
251 template <class T> inline constexpr bool is_array_v
252 = is_array<T>::value; // C++17
253 template <class T> inline constexpr bool is_pointer_v
254 = is_pointer<T>::value; // C++17
255 template <class T> inline constexpr bool is_lvalue_reference_v
256 = is_lvalue_reference<T>::value; // C++17
257 template <class T> inline constexpr bool is_rvalue_reference_v
258 = is_rvalue_reference<T>::value; // C++17
259 template <class T> inline constexpr bool is_member_object_pointer_v
260 = is_member_object_pointer<T>::value; // C++17
261 template <class T> inline constexpr bool is_member_function_pointer_v
262 = is_member_function_pointer<T>::value; // C++17
263 template <class T> inline constexpr bool is_enum_v
264 = is_enum<T>::value; // C++17
265 template <class T> inline constexpr bool is_union_v
266 = is_union<T>::value; // C++17
267 template <class T> inline constexpr bool is_class_v
268 = is_class<T>::value; // C++17
269 template <class T> inline constexpr bool is_function_v
270 = is_function<T>::value; // C++17
272 // See C++14 20.10.4.2, composite type categories
273 template <class T> inline constexpr bool is_reference_v
274 = is_reference<T>::value; // C++17
275 template <class T> inline constexpr bool is_arithmetic_v
276 = is_arithmetic<T>::value; // C++17
277 template <class T> inline constexpr bool is_fundamental_v
278 = is_fundamental<T>::value; // C++17
279 template <class T> inline constexpr bool is_object_v
280 = is_object<T>::value; // C++17
281 template <class T> inline constexpr bool is_scalar_v
282 = is_scalar<T>::value; // C++17
283 template <class T> inline constexpr bool is_compound_v
284 = is_compound<T>::value; // C++17
285 template <class T> inline constexpr bool is_member_pointer_v
286 = is_member_pointer<T>::value; // C++17
288 // See C++14 20.10.4.3, type properties
289 template <class T> inline constexpr bool is_const_v
290 = is_const<T>::value; // C++17
291 template <class T> inline constexpr bool is_volatile_v
292 = is_volatile<T>::value; // C++17
293 template <class T> inline constexpr bool is_trivial_v
294 = is_trivial<T>::value; // C++17
295 template <class T> inline constexpr bool is_trivially_copyable_v
296 = is_trivially_copyable<T>::value; // C++17
297 template <class T> inline constexpr bool is_standard_layout_v
298 = is_standard_layout<T>::value; // C++17
299 template <class T> inline constexpr bool is_pod_v
300 = is_pod<T>::value; // C++17
301 template <class T> inline constexpr bool is_literal_type_v
302 = is_literal_type<T>::value; // C++17
303 template <class T> inline constexpr bool is_empty_v
304 = is_empty<T>::value; // C++17
305 template <class T> inline constexpr bool is_polymorphic_v
306 = is_polymorphic<T>::value; // C++17
307 template <class T> inline constexpr bool is_abstract_v
308 = is_abstract<T>::value; // C++17
309 template <class T> inline constexpr bool is_final_v
310 = is_final<T>::value; // C++17
311 template <class T> inline constexpr bool is_aggregate_v
312 = is_aggregate<T>::value; // C++17
313 template <class T> inline constexpr bool is_signed_v
314 = is_signed<T>::value; // C++17
315 template <class T> inline constexpr bool is_unsigned_v
316 = is_unsigned<T>::value; // C++17
317 template <class T, class... Args> inline constexpr bool is_constructible_v
318 = is_constructible<T, Args...>::value; // C++17
319 template <class T> inline constexpr bool is_default_constructible_v
320 = is_default_constructible<T>::value; // C++17
321 template <class T> inline constexpr bool is_copy_constructible_v
322 = is_copy_constructible<T>::value; // C++17
323 template <class T> inline constexpr bool is_move_constructible_v
324 = is_move_constructible<T>::value; // C++17
325 template <class T, class U> inline constexpr bool is_assignable_v
326 = is_assignable<T, U>::value; // C++17
327 template <class T> inline constexpr bool is_copy_assignable_v
328 = is_copy_assignable<T>::value; // C++17
329 template <class T> inline constexpr bool is_move_assignable_v
330 = is_move_assignable<T>::value; // C++17
331 template <class T, class U> inline constexpr bool is_swappable_with_v
332 = is_swappable_with<T, U>::value; // C++17
333 template <class T> inline constexpr bool is_swappable_v
334 = is_swappable<T>::value; // C++17
335 template <class T> inline constexpr bool is_destructible_v
336 = is_destructible<T>::value; // C++17
337 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
338 = is_trivially_constructible<T, Args...>::value; // C++17
339 template <class T> inline constexpr bool is_trivially_default_constructible_v
340 = is_trivially_default_constructible<T>::value; // C++17
341 template <class T> inline constexpr bool is_trivially_copy_constructible_v
342 = is_trivially_copy_constructible<T>::value; // C++17
343 template <class T> inline constexpr bool is_trivially_move_constructible_v
344 = is_trivially_move_constructible<T>::value; // C++17
345 template <class T, class U> inline constexpr bool is_trivially_assignable_v
346 = is_trivially_assignable<T, U>::value; // C++17
347 template <class T> inline constexpr bool is_trivially_copy_assignable_v
348 = is_trivially_copy_assignable<T>::value; // C++17
349 template <class T> inline constexpr bool is_trivially_move_assignable_v
350 = is_trivially_move_assignable<T>::value; // C++17
351 template <class T> inline constexpr bool is_trivially_destructible_v
352 = is_trivially_destructible<T>::value; // C++17
353 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
354 = is_nothrow_constructible<T, Args...>::value; // C++17
355 template <class T> inline constexpr bool is_nothrow_default_constructible_v
356 = is_nothrow_default_constructible<T>::value; // C++17
357 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
358 = is_nothrow_copy_constructible<T>::value; // C++17
359 template <class T> inline constexpr bool is_nothrow_move_constructible_v
360 = is_nothrow_move_constructible<T>::value; // C++17
361 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
362 = is_nothrow_assignable<T, U>::value; // C++17
363 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
364 = is_nothrow_copy_assignable<T>::value; // C++17
365 template <class T> inline constexpr bool is_nothrow_move_assignable_v
366 = is_nothrow_move_assignable<T>::value; // C++17
367 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
368 = is_nothrow_swappable_with<T, U>::value; // C++17
369 template <class T> inline constexpr bool is_nothrow_swappable_v
370 = is_nothrow_swappable<T>::value; // C++17
371 template <class T> inline constexpr bool is_nothrow_destructible_v
372 = is_nothrow_destructible<T>::value; // C++17
373 template <class T> inline constexpr bool has_virtual_destructor_v
374 = has_virtual_destructor<T>::value; // C++17
375 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
376 = has_unique_object_representations<T>::value;
378 // See C++14 20.10.5, type property queries
379 template <class T> inline constexpr size_t alignment_of_v
380 = alignment_of<T>::value; // C++17
381 template <class T> inline constexpr size_t rank_v
382 = rank<T>::value; // C++17
383 template <class T, unsigned I = 0> inline constexpr size_t extent_v
384 = extent<T, I>::value; // C++17
386 // See C++14 20.10.6, type relations
387 template <class T, class U> inline constexpr bool is_same_v
388 = is_same<T, U>::value; // C++17
389 template <class Base, class Derived> inline constexpr bool is_base_of_v
390 = is_base_of<Base, Derived>::value; // C++17
391 template <class From, class To> inline constexpr bool is_convertible_v
392 = is_convertible<From, To>::value; // C++17
393 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
394 = is_invocable<Fn, ArgTypes...>::value; // C++17
395 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
396 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
397 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
398 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
399 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
400 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
402 // [meta.logical], logical operator traits:
403 template<class... B> struct conjunction; // C++17
405 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
406 template<class... B> struct disjunction; // C++17
408 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
409 template<class B> struct negation; // C++17
411 inline constexpr bool negation_v = negation<B>::value; // C++17
420 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
421 #pragma GCC system_header
424 _LIBCPP_BEGIN_NAMESPACE_STD
426 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
427 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
428 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
430 template <class _Tp, _Tp __v>
431 struct _LIBCPP_TEMPLATE_VIS integral_constant
433 static _LIBCPP_CONSTEXPR const _Tp value = __v;
434 typedef _Tp value_type;
435 typedef integral_constant type;
436 _LIBCPP_INLINE_VISIBILITY
437 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
438 #if _LIBCPP_STD_VER > 11
439 _LIBCPP_INLINE_VISIBILITY
440 constexpr value_type operator ()() const _NOEXCEPT {return value;}
444 template <class _Tp, _Tp __v>
445 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
447 #if _LIBCPP_STD_VER > 14
449 using bool_constant = integral_constant<bool, __b>;
450 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
452 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
455 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
456 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
459 using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
461 template <bool> struct _MetaBase;
463 struct _MetaBase<true> {
464 template <class _Tp, class _Up>
465 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Tp;
466 template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
467 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _FirstFn<_Args...>;
468 template <class _First, class...>
469 using _FirstImpl _LIBCPP_NODEBUG_TYPE = _First;
470 template <class, class _Second, class...>
471 using _SecondImpl _LIBCPP_NODEBUG_TYPE = _Second;
472 template <class _Tp = void>
473 using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp;
474 template <class _Result, class _First, class ..._Rest>
475 using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
476 template <class _Result, class _First, class ..._Rest>
477 using _AndImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>;
481 struct _MetaBase<false> {
482 template <class _Tp, class _Up>
483 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Up;
484 template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
485 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>;
486 template <class _Result, class ...>
487 using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result;
488 template <class _Result, class ...>
489 using _AndImpl _LIBCPP_NODEBUG_TYPE = _Result;
491 template <bool _Cond, class _Ret = void>
492 using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>;
493 template <bool _Cond, class _IfRes, class _ElseRes>
494 using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
495 template <class ..._Rest>
496 using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
497 template <class ..._Rest>
498 using _And _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _AndImpl<true_type, _Rest...>;
499 template <class _Pred>
500 struct _Not : _BoolConstant<!_Pred::value> {};
501 template <class ..._Args>
502 using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
503 template <class ..._Args>
504 using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
506 template <template <class...> class _Func, class ..._Args>
507 struct _Lazy : _Func<_Args...> {};
509 // Member detector base
511 template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
512 true_type __sfinae_test_impl(int);
513 template <template <class...> class, class ...>
514 false_type __sfinae_test_impl(...);
516 template <template <class ...> class _Templ, class ..._Args>
517 using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
520 struct __void_t { typedef void type; };
523 struct __identity { typedef _Tp type; };
525 template <class _Tp, bool>
526 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
529 template <bool _Bp, class _If, class _Then>
530 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
531 template <class _If, class _Then>
532 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
534 #if _LIBCPP_STD_VER > 11
535 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
538 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
539 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
541 #if _LIBCPP_STD_VER > 11
542 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
547 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
576 using __test_for_primary_template = _EnableIf<
577 _IsSame<_Tp, typename _Tp::__primary_template>::value
580 using __is_primary_template = _IsValidExpansion<
581 __test_for_primary_template, _Tp
585 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
588 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
589 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
591 addressof(_Tp& __x) _NOEXCEPT
593 return __builtin_addressof(__x);
599 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
601 addressof(_Tp& __x) _NOEXCEPT
603 return reinterpret_cast<_Tp *>(
604 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
607 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
609 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
610 // Objective-C++ Automatic Reference Counting uses qualified pointers
611 // that require special addressof() signatures. When
612 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
613 // itself is providing these definitions. Otherwise, we provide them.
615 inline _LIBCPP_INLINE_VISIBILITY
617 addressof(__strong _Tp& __x) _NOEXCEPT
622 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
624 inline _LIBCPP_INLINE_VISIBILITY
626 addressof(__weak _Tp& __x) _NOEXCEPT
633 inline _LIBCPP_INLINE_VISIBILITY
635 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
641 inline _LIBCPP_INLINE_VISIBILITY
642 __unsafe_unretained _Tp*
643 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
649 #if !defined(_LIBCPP_CXX03_LANG)
650 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
653 struct __two {char __lx[2];};
659 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
660 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
662 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
664 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
665 = is_const<_Tp>::value;
670 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
671 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
673 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
675 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
676 = is_volatile<_Tp>::value;
681 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
682 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
683 #if _LIBCPP_STD_VER > 11
684 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
689 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
690 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
691 #if _LIBCPP_STD_VER > 11
692 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
697 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
698 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
699 #if _LIBCPP_STD_VER > 11
700 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
705 template <class _Tp> struct __libcpp_is_void : public false_type {};
706 template <> struct __libcpp_is_void<void> : public true_type {};
708 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
709 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
711 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
713 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
714 = is_void<_Tp>::value;
719 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
720 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
722 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
723 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
725 #if _LIBCPP_STD_VER > 11
726 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
727 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
729 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
731 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
732 = is_null_pointer<_Tp>::value;
734 #endif // _LIBCPP_STD_VER > 11
738 template <class _Tp> struct __libcpp_is_integral : public false_type {};
739 template <> struct __libcpp_is_integral<bool> : public true_type {};
740 template <> struct __libcpp_is_integral<char> : public true_type {};
741 template <> struct __libcpp_is_integral<signed char> : public true_type {};
742 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
743 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
744 #ifndef _LIBCPP_NO_HAS_CHAR8_T
745 template <> struct __libcpp_is_integral<char8_t> : public true_type {};
747 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
748 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
749 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
750 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
751 template <> struct __libcpp_is_integral<short> : public true_type {};
752 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
753 template <> struct __libcpp_is_integral<int> : public true_type {};
754 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
755 template <> struct __libcpp_is_integral<long> : public true_type {};
756 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
757 template <> struct __libcpp_is_integral<long long> : public true_type {};
758 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
759 #ifndef _LIBCPP_HAS_NO_INT128
760 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
761 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
764 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
765 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
767 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
769 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
770 = is_integral<_Tp>::value;
775 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
776 template <> struct __libcpp_is_floating_point<float> : public true_type {};
777 template <> struct __libcpp_is_floating_point<double> : public true_type {};
778 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
780 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
781 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
783 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
785 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
786 = is_floating_point<_Tp>::value;
791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
792 : public false_type {};
793 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
794 : public true_type {};
795 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
796 : public true_type {};
798 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
800 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
801 = is_array<_Tp>::value;
806 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
807 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
809 template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
810 #if defined(_LIBCPP_HAS_OBJC_ARC)
811 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
812 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
813 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
814 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
817 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
818 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
820 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
822 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
823 = is_pointer<_Tp>::value;
828 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
829 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
831 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
832 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
834 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
835 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
836 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
838 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
840 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
841 = is_reference<_Tp>::value;
844 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
845 = is_lvalue_reference<_Tp>::value;
848 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
849 = is_rvalue_reference<_Tp>::value;
853 #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
855 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
856 : public integral_constant<bool, __is_union(_Tp)> {};
860 template <class _Tp> struct __libcpp_union : public false_type {};
861 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
862 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
866 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
868 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
869 = is_union<_Tp>::value;
874 #if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
876 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
877 : public integral_constant<bool, __is_class(_Tp)> {};
881 namespace __is_class_imp
883 template <class _Tp> char __test(int _Tp::*);
884 template <class _Tp> __two __test(...);
887 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
888 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
892 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
894 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
895 = is_class<_Tp>::value;
900 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
901 : public _BoolConstant<
905 !(is_reference<_Tp>::value || is_const<const _Tp>::value)
910 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
912 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
913 = is_function<_Tp>::value;
916 template <class _Tp> struct __libcpp_is_member_pointer {
923 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
926 __is_func = is_function<_Tp>::value,
927 __is_obj = !__is_func,
932 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
933 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
935 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
937 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
938 = is_member_function_pointer<_Tp>::value;
943 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
944 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
946 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
948 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
949 = is_member_pointer<_Tp>::value;
952 // is_member_object_pointer
954 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
955 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
957 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
959 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
960 = is_member_object_pointer<_Tp>::value;
965 #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
967 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
968 : public integral_constant<bool, __is_enum(_Tp)> {};
972 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
973 : public integral_constant<bool, !is_void<_Tp>::value &&
974 !is_integral<_Tp>::value &&
975 !is_floating_point<_Tp>::value &&
976 !is_array<_Tp>::value &&
977 !is_pointer<_Tp>::value &&
978 !is_reference<_Tp>::value &&
979 !is_member_pointer<_Tp>::value &&
980 !is_union<_Tp>::value &&
981 !is_class<_Tp>::value &&
982 !is_function<_Tp>::value > {};
986 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
988 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
989 = is_enum<_Tp>::value;
994 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
995 : public integral_constant<bool, is_integral<_Tp>::value ||
996 is_floating_point<_Tp>::value> {};
998 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1000 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
1001 = is_arithmetic<_Tp>::value;
1006 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
1007 : public integral_constant<bool, is_void<_Tp>::value ||
1008 __is_nullptr_t<_Tp>::value ||
1009 is_arithmetic<_Tp>::value> {};
1011 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1012 template <class _Tp>
1013 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1014 = is_fundamental<_Tp>::value;
1019 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1020 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1021 is_member_pointer<_Tp>::value ||
1022 is_pointer<_Tp>::value ||
1023 __is_nullptr_t<_Tp>::value ||
1024 is_enum<_Tp>::value > {};
1026 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1028 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1029 template <class _Tp>
1030 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1031 = is_scalar<_Tp>::value;
1036 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1037 : public integral_constant<bool, is_scalar<_Tp>::value ||
1038 is_array<_Tp>::value ||
1039 is_union<_Tp>::value ||
1040 is_class<_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_object_v
1045 = is_object<_Tp>::value;
1050 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1051 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1053 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1054 template <class _Tp>
1055 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1056 = is_compound<_Tp>::value;
1060 // __is_referenceable [defns.referenceable]
1062 struct __is_referenceable_impl {
1063 template <class _Tp> static _Tp& __test(int);
1064 template <class _Tp> static __two __test(...);
1067 template <class _Tp>
1068 struct __is_referenceable : integral_constant<bool,
1069 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1074 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
1075 typedef _LIBCPP_NODEBUG_TYPE const _Tp type;
1078 #if _LIBCPP_STD_VER > 11
1079 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1084 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
1085 typedef _LIBCPP_NODEBUG_TYPE volatile _Tp type;
1088 #if _LIBCPP_STD_VER > 11
1089 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1093 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
1094 typedef _LIBCPP_NODEBUG_TYPE const volatile _Tp type;
1097 #if _LIBCPP_STD_VER > 11
1098 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1103 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1104 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1105 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1107 #if _LIBCPP_STD_VER > 11
1108 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1111 // add_lvalue_reference
1113 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1114 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; };
1116 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1117 {typedef _LIBCPP_NODEBUG_TYPE typename __add_lvalue_reference_impl<_Tp>::type type;};
1119 #if _LIBCPP_STD_VER > 11
1120 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1123 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1124 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; };
1126 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1127 {typedef _LIBCPP_NODEBUG_TYPE typename __add_rvalue_reference_impl<_Tp>::type type;};
1129 #if _LIBCPP_STD_VER > 11
1130 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1133 // Suppress deprecation notice for volatile-qualified return type resulting
1134 // from volatile-qualified types _Tp.
1135 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1136 template <class _Tp> _Tp&& __declval(int);
1137 template <class _Tp> _Tp __declval(long);
1138 _LIBCPP_SUPPRESS_DEPRECATED_POP
1140 template <class _Tp>
1141 decltype(_VSTD::__declval<_Tp>(0))
1142 declval() _NOEXCEPT;
1146 template <class _Tp>
1148 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1151 template <class _Tp>
1152 struct __unconstref {
1153 typedef _LIBCPP_NODEBUG_TYPE typename remove_const<typename remove_reference<_Tp>::type>::type type;
1156 #ifndef _LIBCPP_CXX03_LANG
1157 template <class _Tp>
1158 using __uncvref_t _LIBCPP_NODEBUG_TYPE = typename __uncvref<_Tp>::type;
1161 // __is_same_uncvref
1163 template <class _Tp, class _Up>
1164 struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
1165 typename __uncvref<_Up>::type> {};
1167 #if _LIBCPP_STD_VER > 17
1168 // remove_cvref - same as __uncvref
1169 template <class _Tp>
1170 struct remove_cvref : public __uncvref<_Tp> {};
1172 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1183 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1184 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1185 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1186 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1187 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1189 #if _LIBCPP_STD_VER > 11
1190 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1195 template <class _Tp,
1196 bool = __is_referenceable<_Tp>::value ||
1197 _IsSame<typename remove_cv<_Tp>::type, void>::value>
1198 struct __add_pointer_impl
1199 {typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type* type;};
1200 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1201 {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1203 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1204 {typedef _LIBCPP_NODEBUG_TYPE typename __add_pointer_impl<_Tp>::type type;};
1206 #if _LIBCPP_STD_VER > 11
1207 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1211 #if _LIBCPP_STD_VER > 17
1212 template<class _Tp> struct type_identity { typedef _Tp type; };
1213 template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
1218 template <class _Tp, bool = is_integral<_Tp>::value>
1219 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1221 template <class _Tp>
1222 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1224 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1225 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1227 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1229 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1231 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1232 template <class _Tp>
1233 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1234 = is_signed<_Tp>::value;
1239 template <class _Tp, bool = is_integral<_Tp>::value>
1240 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1242 template <class _Tp>
1243 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1245 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1246 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1248 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1250 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1252 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1253 template <class _Tp>
1254 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1255 = is_unsigned<_Tp>::value;
1260 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1261 : public integral_constant<size_t, 0> {};
1262 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1263 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1264 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1265 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1267 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1268 template <class _Tp>
1269 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1275 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1276 : public integral_constant<size_t, 0> {};
1277 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1278 : public integral_constant<size_t, 0> {};
1279 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1280 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1281 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1282 : public integral_constant<size_t, _Np> {};
1283 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1284 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1286 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1287 template <class _Tp, unsigned _Ip = 0>
1288 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1289 = extent<_Tp, _Ip>::value;
1294 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1295 {typedef _Tp type;};
1296 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1297 {typedef _Tp type;};
1298 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1299 {typedef _Tp type;};
1301 #if _LIBCPP_STD_VER > 11
1302 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1305 // remove_all_extents
1307 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1308 {typedef _Tp type;};
1309 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1310 {typedef typename remove_all_extents<_Tp>::type type;};
1311 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1312 {typedef typename remove_all_extents<_Tp>::type type;};
1314 #if _LIBCPP_STD_VER > 11
1315 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1318 #if _LIBCPP_STD_VER > 17
1321 template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
1322 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
1324 template <class _Tp>
1325 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1326 bool is_bounded_array_v = is_bounded_array<_Tp>::value;
1328 // is_unbounded_array
1330 template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
1331 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
1333 template <class _Tp>
1334 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1335 bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
1340 template <class _Up, bool>
1342 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<_Up>::type type;
1345 template <class _Up>
1346 struct __decay<_Up, true> {
1348 typedef _LIBCPP_NODEBUG_TYPE typename conditional
1350 is_array<_Up>::value,
1351 typename remove_extent<_Up>::type*,
1352 typename conditional
1354 is_function<_Up>::value,
1355 typename add_pointer<_Up>::type,
1356 typename remove_cv<_Up>::type
1361 template <class _Tp>
1362 struct _LIBCPP_TEMPLATE_VIS decay
1365 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
1367 typedef _LIBCPP_NODEBUG_TYPE typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1370 #if _LIBCPP_STD_VER > 11
1371 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1376 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1377 : public integral_constant<bool, __is_abstract(_Tp)> {};
1379 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1380 template <class _Tp>
1381 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1382 = is_abstract<_Tp>::value;
1387 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1388 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1390 #if _LIBCPP_STD_VER > 11
1391 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1392 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1395 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1396 template <class _Tp>
1397 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1398 = is_final<_Tp>::value;
1402 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1404 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1405 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1407 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1408 template <class _Tp>
1409 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1410 = is_aggregate<_Tp>::value;
1413 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1417 template <class _Bp, class _Dp>
1418 struct _LIBCPP_TEMPLATE_VIS is_base_of
1419 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1421 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1422 template <class _Bp, class _Dp>
1423 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1424 = is_base_of<_Bp, _Dp>::value;
1429 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1431 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1432 : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
1434 #else // __has_feature(is_convertible_to)
1436 namespace __is_convertible_imp
1438 template <class _Tp> void __test_convert(_Tp);
1440 template <class _From, class _To, class = void>
1441 struct __is_convertible_test : public false_type {};
1443 template <class _From, class _To>
1444 struct __is_convertible_test<_From, _To,
1445 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1448 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1449 bool _IsFunction = is_function<_Tp>::value,
1450 bool _IsVoid = is_void<_Tp>::value>
1451 struct __is_array_function_or_void {enum {value = 0};};
1452 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1453 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1454 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1457 template <class _Tp,
1458 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1459 struct __is_convertible_check
1461 static const size_t __v = 0;
1464 template <class _Tp>
1465 struct __is_convertible_check<_Tp, 0>
1467 static const size_t __v = sizeof(_Tp);
1470 template <class _T1, class _T2,
1471 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1472 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1473 struct __is_convertible
1474 : public integral_constant<bool,
1475 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1479 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1480 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1481 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1482 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1484 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1485 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1486 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1487 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1489 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1490 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1491 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1492 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1494 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1495 : public __is_convertible<_T1, _T2>
1497 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1498 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1501 #endif // __has_feature(is_convertible_to)
1503 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1504 template <class _From, class _To>
1505 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1506 = is_convertible<_From, _To>::value;
1509 // is_nothrow_convertible
1511 #if _LIBCPP_STD_VER > 17
1513 template <typename _Tp>
1514 static void __test_noexcept(_Tp) noexcept;
1516 template<typename _Fm, typename _To>
1517 static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))>
1518 __is_nothrow_convertible_test();
1520 template <typename _Fm, typename _To>
1521 struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
1524 template <typename _Fm, typename _To>
1525 struct is_nothrow_convertible : _Or<
1526 _And<is_void<_To>, is_void<_Fm>>,
1527 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
1530 template <typename _Fm, typename _To>
1531 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
1533 #endif // _LIBCPP_STD_VER > 17
1537 #if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
1539 template <class _Tp>
1540 struct _LIBCPP_TEMPLATE_VIS is_empty
1541 : public integral_constant<bool, __is_empty(_Tp)> {};
1543 #else // __has_feature(is_empty)
1545 template <class _Tp>
1557 template <class _Tp, bool = is_class<_Tp>::value>
1558 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1560 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1562 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1564 #endif // __has_feature(is_empty)
1566 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1567 template <class _Tp>
1568 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1569 = is_empty<_Tp>::value;
1574 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1576 template <class _Tp>
1577 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1578 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1582 template<typename _Tp> char &__is_polymorphic_impl(
1583 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1585 template<typename _Tp> __two &__is_polymorphic_impl(...);
1587 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1588 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1590 #endif // __has_feature(is_polymorphic)
1592 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1593 template <class _Tp>
1594 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1595 = is_polymorphic<_Tp>::value;
1598 // has_virtual_destructor
1600 #if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
1602 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1603 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1607 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1608 : public false_type {};
1612 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1613 template <class _Tp>
1614 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1615 = has_virtual_destructor<_Tp>::value;
1618 // has_unique_object_representations
1620 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1622 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1623 : public integral_constant<bool,
1624 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1626 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1627 template <class _Tp>
1628 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1629 = has_unique_object_representations<_Tp>::value;
1636 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1637 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
1639 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1640 template <class _Tp>
1641 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1642 = alignment_of<_Tp>::value;
1647 template <class _Hp, class _Tp>
1656 #ifndef _LIBCPP_CXX03_LANG
1658 __nat(const __nat&) = delete;
1659 __nat& operator=(const __nat&) = delete;
1664 template <class _Tp>
1667 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
1671 struct __struct_double {long double __lx;};
1672 struct __struct_double4 {double __lx[4];};
1675 __type_list<__align_type<unsigned char>,
1676 __type_list<__align_type<unsigned short>,
1677 __type_list<__align_type<unsigned int>,
1678 __type_list<__align_type<unsigned long>,
1679 __type_list<__align_type<unsigned long long>,
1680 __type_list<__align_type<double>,
1681 __type_list<__align_type<long double>,
1682 __type_list<__align_type<__struct_double>,
1683 __type_list<__align_type<__struct_double4>,
1684 __type_list<__align_type<int*>,
1686 > > > > > > > > > > __all_types;
1688 template <size_t _Align>
1689 struct _ALIGNAS(_Align) __fallback_overaligned {};
1691 template <class _TL, size_t _Align> struct __find_pod;
1693 template <class _Hp, size_t _Align>
1694 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1696 typedef typename conditional<
1697 _Align == _Hp::value,
1699 __fallback_overaligned<_Align>
1703 template <class _Hp, class _Tp, size_t _Align>
1704 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1706 typedef typename conditional<
1707 _Align == _Hp::value,
1709 typename __find_pod<_Tp, _Align>::type
1713 template <class _TL, size_t _Len> struct __find_max_align;
1715 template <class _Hp, size_t _Len>
1716 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1718 template <size_t _Len, size_t _A1, size_t _A2>
1719 struct __select_align
1722 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1723 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1725 static const size_t value = _Len < __max ? __min : __max;
1728 template <class _Hp, class _Tp, size_t _Len>
1729 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1730 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1732 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1733 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1735 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1739 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1743 #if _LIBCPP_STD_VER > 11
1744 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1745 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1748 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1749 template <size_t _Len>\
1750 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1752 struct _ALIGNAS(n) type\
1754 unsigned char __lx[(_Len + n - 1)/n * n];\
1758 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1759 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1760 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1761 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1762 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1763 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1764 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1765 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1766 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1767 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1768 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1769 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1770 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1771 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1772 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1773 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1774 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1775 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1777 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1782 template <size_t _I0, size_t ..._In>
1783 struct __static_max;
1785 template <size_t _I0>
1786 struct __static_max<_I0>
1788 static const size_t value = _I0;
1791 template <size_t _I0, size_t _I1, size_t ..._In>
1792 struct __static_max<_I0, _I1, _In...>
1794 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1795 __static_max<_I1, _In...>::value;
1798 template <size_t _Len, class _Type0, class ..._Types>
1799 struct aligned_union
1801 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
1802 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
1803 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1804 sizeof(_Types)...>::value;
1805 typedef typename aligned_storage<__len, alignment_value>::type type;
1808 #if _LIBCPP_STD_VER > 11
1809 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1812 template <class _Tp>
1813 struct __numeric_type
1815 static void __test(...);
1816 static float __test(float);
1817 static double __test(char);
1818 static double __test(int);
1819 static double __test(unsigned);
1820 static double __test(long);
1821 static double __test(unsigned long);
1822 static double __test(long long);
1823 static double __test(unsigned long long);
1824 static double __test(double);
1825 static long double __test(long double);
1827 typedef decltype(__test(declval<_Tp>())) type;
1828 static const bool value = _IsNotSame<type, void>::value;
1832 struct __numeric_type<void>
1834 static const bool value = true;
1839 template <class _A1, class _A2 = void, class _A3 = void,
1840 bool = __numeric_type<_A1>::value &&
1841 __numeric_type<_A2>::value &&
1842 __numeric_type<_A3>::value>
1846 static const bool value = false;
1849 template <class _A1, class _A2, class _A3>
1850 class __promote_imp<_A1, _A2, _A3, true>
1853 typedef typename __promote_imp<_A1>::type __type1;
1854 typedef typename __promote_imp<_A2>::type __type2;
1855 typedef typename __promote_imp<_A3>::type __type3;
1857 typedef decltype(__type1() + __type2() + __type3()) type;
1858 static const bool value = true;
1861 template <class _A1, class _A2>
1862 class __promote_imp<_A1, _A2, void, true>
1865 typedef typename __promote_imp<_A1>::type __type1;
1866 typedef typename __promote_imp<_A2>::type __type2;
1868 typedef decltype(__type1() + __type2()) type;
1869 static const bool value = true;
1872 template <class _A1>
1873 class __promote_imp<_A1, void, void, true>
1876 typedef typename __numeric_type<_A1>::type type;
1877 static const bool value = true;
1880 template <class _A1, class _A2 = void, class _A3 = void>
1881 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1883 // make_signed / make_unsigned
1886 __type_list<signed char,
1887 __type_list<signed short,
1888 __type_list<signed int,
1889 __type_list<signed long,
1890 __type_list<signed long long,
1891 #ifndef _LIBCPP_HAS_NO_INT128
1892 __type_list<__int128_t,
1895 #ifndef _LIBCPP_HAS_NO_INT128
1898 > > > > > __signed_types;
1901 __type_list<unsigned char,
1902 __type_list<unsigned short,
1903 __type_list<unsigned int,
1904 __type_list<unsigned long,
1905 __type_list<unsigned long long,
1906 #ifndef _LIBCPP_HAS_NO_INT128
1907 __type_list<__uint128_t,
1910 #ifndef _LIBCPP_HAS_NO_INT128
1913 > > > > > __unsigned_types;
1915 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1917 template <class _Hp, class _Tp, size_t _Size>
1918 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1920 typedef _LIBCPP_NODEBUG_TYPE _Hp type;
1923 template <class _Hp, class _Tp, size_t _Size>
1924 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1926 typedef _LIBCPP_NODEBUG_TYPE typename __find_first<_Tp, _Size>::type type;
1929 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1930 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1933 typedef _LIBCPP_NODEBUG_TYPE _Up type;
1936 template <class _Tp, class _Up>
1937 struct __apply_cv<_Tp, _Up, true, false>
1939 typedef _LIBCPP_NODEBUG_TYPE const _Up type;
1942 template <class _Tp, class _Up>
1943 struct __apply_cv<_Tp, _Up, false, true>
1945 typedef volatile _Up type;
1948 template <class _Tp, class _Up>
1949 struct __apply_cv<_Tp, _Up, true, true>
1951 typedef const volatile _Up type;
1954 template <class _Tp, class _Up>
1955 struct __apply_cv<_Tp&, _Up, false, false>
1960 template <class _Tp, class _Up>
1961 struct __apply_cv<_Tp&, _Up, true, false>
1963 typedef const _Up& type;
1966 template <class _Tp, class _Up>
1967 struct __apply_cv<_Tp&, _Up, false, true>
1969 typedef volatile _Up& type;
1972 template <class _Tp, class _Up>
1973 struct __apply_cv<_Tp&, _Up, true, true>
1975 typedef const volatile _Up& type;
1978 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1979 struct __make_signed {};
1981 template <class _Tp>
1982 struct __make_signed<_Tp, true>
1984 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1987 template <> struct __make_signed<bool, true> {};
1988 template <> struct __make_signed< signed short, true> {typedef short type;};
1989 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1990 template <> struct __make_signed< signed int, true> {typedef int type;};
1991 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1992 template <> struct __make_signed< signed long, true> {typedef long type;};
1993 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1994 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1995 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1996 #ifndef _LIBCPP_HAS_NO_INT128
1997 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1998 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2001 template <class _Tp>
2002 struct _LIBCPP_TEMPLATE_VIS make_signed
2004 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2007 #if _LIBCPP_STD_VER > 11
2008 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2011 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2012 struct __make_unsigned {};
2014 template <class _Tp>
2015 struct __make_unsigned<_Tp, true>
2017 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2020 template <> struct __make_unsigned<bool, true> {};
2021 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2022 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2023 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2024 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2025 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2026 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2027 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2028 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2029 #ifndef _LIBCPP_HAS_NO_INT128
2030 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2031 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2034 template <class _Tp>
2035 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2037 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2040 #if _LIBCPP_STD_VER > 11
2041 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2044 template <class _Tp, class _Up, class = void>
2045 struct __common_type2_imp {};
2047 template <class _Tp, class _Up>
2048 struct __common_type2_imp<_Tp, _Up,
2049 typename __void_t<decltype(
2050 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2053 typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype(
2054 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2058 template <class, class = void>
2059 struct __common_type_impl {};
2061 // Clang provides variadic templates in C++03 as an extension.
2062 #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
2063 # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
2064 template <class... Tp>
2065 struct __common_types;
2066 template <class... _Tp>
2067 struct _LIBCPP_TEMPLATE_VIS common_type;
2069 # define _LIBCPP_OPTIONAL_PACK(...)
2071 template <class _Tp, class _Up, class = __no_arg>
2072 struct __common_types;
2073 template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
2074 class _Unused = __no_arg>
2075 struct common_type {
2076 static_assert(sizeof(_Unused) == 0,
2077 "common_type accepts at most 3 arguments in C++03");
2079 #endif // _LIBCPP_CXX03_LANG
2081 template <class _Tp, class _Up>
2082 struct __common_type_impl<
2083 __common_types<_Tp, _Up>,
2084 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2086 typedef typename common_type<_Tp, _Up>::type type;
2089 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2090 struct __common_type_impl<
2091 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
2092 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2093 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
2094 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
2097 // bullet 1 - sizeof...(Tp) == 0
2100 struct _LIBCPP_TEMPLATE_VIS common_type<> {};
2102 // bullet 2 - sizeof...(Tp) == 1
2104 template <class _Tp>
2105 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2106 : public common_type<_Tp, _Tp> {};
2108 // bullet 3 - sizeof...(Tp) == 2
2110 template <class _Tp, class _Up>
2111 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2113 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
2114 __common_type2_imp<_Tp, _Up>,
2115 common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
2119 // bullet 4 - sizeof...(Tp) > 2
2121 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2122 struct _LIBCPP_TEMPLATE_VIS
2123 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
2124 : __common_type_impl<
2125 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
2127 #undef _LIBCPP_OPTIONAL_PACK
2129 #if _LIBCPP_STD_VER > 11
2130 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2135 template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
2137 template <class _Tp, class _Arg>
2138 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2139 __is_assignable_test(int);
2141 template <class, class>
2142 false_type __is_assignable_test(...);
2145 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2146 struct __is_assignable_imp
2147 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2149 template <class _Tp, class _Arg>
2150 struct __is_assignable_imp<_Tp, _Arg, true>
2155 template <class _Tp, class _Arg>
2156 struct is_assignable
2157 : public __is_assignable_imp<_Tp, _Arg> {};
2159 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2160 template <class _Tp, class _Arg>
2161 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2162 = is_assignable<_Tp, _Arg>::value;
2165 // is_copy_assignable
2167 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2168 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2169 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2171 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2172 template <class _Tp>
2173 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2174 = is_copy_assignable<_Tp>::value;
2177 // is_move_assignable
2179 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2180 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2181 typename add_rvalue_reference<_Tp>::type> {};
2183 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2184 template <class _Tp>
2185 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2186 = is_move_assignable<_Tp>::value;
2191 // if it's a reference, return true
2192 // if it's a function, return false
2193 // if it's void, return false
2194 // if it's an array of unknown bound, return false
2195 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2196 // where _Up is remove_all_extents<_Tp>::type
2199 struct __is_destructible_apply { typedef int type; };
2201 template <typename _Tp>
2202 struct __is_destructor_wellformed {
2203 template <typename _Tp1>
2204 static char __test (
2205 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2208 template <typename _Tp1>
2209 static __two __test (...);
2211 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2214 template <class _Tp, bool>
2215 struct __destructible_imp;
2217 template <class _Tp>
2218 struct __destructible_imp<_Tp, false>
2219 : public _VSTD::integral_constant<bool,
2220 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2222 template <class _Tp>
2223 struct __destructible_imp<_Tp, true>
2224 : public _VSTD::true_type {};
2226 template <class _Tp, bool>
2227 struct __destructible_false;
2229 template <class _Tp>
2230 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2232 template <class _Tp>
2233 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2235 template <class _Tp>
2236 struct is_destructible
2237 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2239 template <class _Tp>
2240 struct is_destructible<_Tp[]>
2241 : public _VSTD::false_type {};
2244 struct is_destructible<void>
2245 : public _VSTD::false_type {};
2247 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2248 template <class _Tp>
2249 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2250 = is_destructible<_Tp>::value;
2255 template <class _Tp>
2256 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2257 typename remove_reference<_Tp>::type&&
2258 move(_Tp&& __t) _NOEXCEPT
2260 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
2261 return static_cast<_Up&&>(__t);
2264 template <class _Tp>
2265 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2267 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2269 return static_cast<_Tp&&>(__t);
2272 template <class _Tp>
2273 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2275 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2277 static_assert(!is_lvalue_reference<_Tp>::value,
2278 "can not forward an rvalue as an lvalue");
2279 return static_cast<_Tp&&>(__t);
2282 template <class _Tp>
2283 inline _LIBCPP_INLINE_VISIBILITY
2284 typename decay<_Tp>::type
2285 __decay_copy(_Tp&& __t)
2287 return _VSTD::forward<_Tp>(__t);
2290 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
2291 struct __member_pointer_traits_imp
2295 template <class _Rp, class _Class, class ..._Param>
2296 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2298 typedef _Class _ClassType;
2299 typedef _Rp _ReturnType;
2300 typedef _Rp (_FnType) (_Param...);
2303 template <class _Rp, class _Class, class ..._Param>
2304 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2306 typedef _Class _ClassType;
2307 typedef _Rp _ReturnType;
2308 typedef _Rp (_FnType) (_Param..., ...);
2311 template <class _Rp, class _Class, class ..._Param>
2312 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2314 typedef _Class const _ClassType;
2315 typedef _Rp _ReturnType;
2316 typedef _Rp (_FnType) (_Param...);
2319 template <class _Rp, class _Class, class ..._Param>
2320 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2322 typedef _Class const _ClassType;
2323 typedef _Rp _ReturnType;
2324 typedef _Rp (_FnType) (_Param..., ...);
2327 template <class _Rp, class _Class, class ..._Param>
2328 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2330 typedef _Class volatile _ClassType;
2331 typedef _Rp _ReturnType;
2332 typedef _Rp (_FnType) (_Param...);
2335 template <class _Rp, class _Class, class ..._Param>
2336 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2338 typedef _Class volatile _ClassType;
2339 typedef _Rp _ReturnType;
2340 typedef _Rp (_FnType) (_Param..., ...);
2343 template <class _Rp, class _Class, class ..._Param>
2344 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2346 typedef _Class const volatile _ClassType;
2347 typedef _Rp _ReturnType;
2348 typedef _Rp (_FnType) (_Param...);
2351 template <class _Rp, class _Class, class ..._Param>
2352 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2354 typedef _Class const volatile _ClassType;
2355 typedef _Rp _ReturnType;
2356 typedef _Rp (_FnType) (_Param..., ...);
2359 #if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2361 template <class _Rp, class _Class, class ..._Param>
2362 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2364 typedef _Class& _ClassType;
2365 typedef _Rp _ReturnType;
2366 typedef _Rp (_FnType) (_Param...);
2369 template <class _Rp, class _Class, class ..._Param>
2370 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2372 typedef _Class& _ClassType;
2373 typedef _Rp _ReturnType;
2374 typedef _Rp (_FnType) (_Param..., ...);
2377 template <class _Rp, class _Class, class ..._Param>
2378 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2380 typedef _Class const& _ClassType;
2381 typedef _Rp _ReturnType;
2382 typedef _Rp (_FnType) (_Param...);
2385 template <class _Rp, class _Class, class ..._Param>
2386 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2388 typedef _Class const& _ClassType;
2389 typedef _Rp _ReturnType;
2390 typedef _Rp (_FnType) (_Param..., ...);
2393 template <class _Rp, class _Class, class ..._Param>
2394 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2396 typedef _Class volatile& _ClassType;
2397 typedef _Rp _ReturnType;
2398 typedef _Rp (_FnType) (_Param...);
2401 template <class _Rp, class _Class, class ..._Param>
2402 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2404 typedef _Class volatile& _ClassType;
2405 typedef _Rp _ReturnType;
2406 typedef _Rp (_FnType) (_Param..., ...);
2409 template <class _Rp, class _Class, class ..._Param>
2410 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2412 typedef _Class const volatile& _ClassType;
2413 typedef _Rp _ReturnType;
2414 typedef _Rp (_FnType) (_Param...);
2417 template <class _Rp, class _Class, class ..._Param>
2418 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2420 typedef _Class const volatile& _ClassType;
2421 typedef _Rp _ReturnType;
2422 typedef _Rp (_FnType) (_Param..., ...);
2425 template <class _Rp, class _Class, class ..._Param>
2426 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2428 typedef _Class&& _ClassType;
2429 typedef _Rp _ReturnType;
2430 typedef _Rp (_FnType) (_Param...);
2433 template <class _Rp, class _Class, class ..._Param>
2434 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2436 typedef _Class&& _ClassType;
2437 typedef _Rp _ReturnType;
2438 typedef _Rp (_FnType) (_Param..., ...);
2441 template <class _Rp, class _Class, class ..._Param>
2442 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2444 typedef _Class const&& _ClassType;
2445 typedef _Rp _ReturnType;
2446 typedef _Rp (_FnType) (_Param...);
2449 template <class _Rp, class _Class, class ..._Param>
2450 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2452 typedef _Class const&& _ClassType;
2453 typedef _Rp _ReturnType;
2454 typedef _Rp (_FnType) (_Param..., ...);
2457 template <class _Rp, class _Class, class ..._Param>
2458 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2460 typedef _Class volatile&& _ClassType;
2461 typedef _Rp _ReturnType;
2462 typedef _Rp (_FnType) (_Param...);
2465 template <class _Rp, class _Class, class ..._Param>
2466 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2468 typedef _Class volatile&& _ClassType;
2469 typedef _Rp _ReturnType;
2470 typedef _Rp (_FnType) (_Param..., ...);
2473 template <class _Rp, class _Class, class ..._Param>
2474 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2476 typedef _Class const volatile&& _ClassType;
2477 typedef _Rp _ReturnType;
2478 typedef _Rp (_FnType) (_Param...);
2481 template <class _Rp, class _Class, class ..._Param>
2482 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2484 typedef _Class const volatile&& _ClassType;
2485 typedef _Rp _ReturnType;
2486 typedef _Rp (_FnType) (_Param..., ...);
2489 #endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2492 template <class _Rp, class _Class>
2493 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2495 typedef _Class _ClassType;
2496 typedef _Rp _ReturnType;
2499 template <class _MP>
2500 struct __member_pointer_traits
2501 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2502 is_member_function_pointer<_MP>::value,
2503 is_member_object_pointer<_MP>::value>
2505 // typedef ... _ClassType;
2506 // typedef ... _ReturnType;
2507 // typedef ... _FnType;
2511 template <class _DecayedFp>
2512 struct __member_pointer_class_type {};
2514 template <class _Ret, class _ClassType>
2515 struct __member_pointer_class_type<_Ret _ClassType::*> {
2516 typedef _ClassType type;
2521 template <class _Callable> class result_of;
2523 #ifdef _LIBCPP_HAS_NO_VARIADICS
2525 template <class _Fn, bool, bool>
2530 template <class _Fn>
2531 class __result_of<_Fn(), true, false>
2534 typedef decltype(declval<_Fn>()()) type;
2537 template <class _Fn, class _A0>
2538 class __result_of<_Fn(_A0), true, false>
2541 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2544 template <class _Fn, class _A0, class _A1>
2545 class __result_of<_Fn(_A0, _A1), true, false>
2548 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2551 template <class _Fn, class _A0, class _A1, class _A2>
2552 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2555 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2558 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2559 struct __result_of_mp;
2561 // member function pointer
2563 template <class _MP, class _Tp>
2564 struct __result_of_mp<_MP, _Tp, true>
2565 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2569 // member data pointer
2571 template <class _MP, class _Tp, bool>
2572 struct __result_of_mdp;
2574 template <class _Rp, class _Class, class _Tp>
2575 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2577 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2580 template <class _Rp, class _Class, class _Tp>
2581 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2583 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2586 template <class _Rp, class _Class, class _Tp>
2587 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2588 : public __result_of_mdp<_Rp _Class::*, _Tp,
2589 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2595 template <class _Fn, class _Tp>
2596 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2597 : public __result_of_mp<typename remove_reference<_Fn>::type,
2599 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2603 template <class _Fn, class _Tp, class _A0>
2604 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2605 : public __result_of_mp<typename remove_reference<_Fn>::type,
2607 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2611 template <class _Fn, class _Tp, class _A0, class _A1>
2612 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2613 : public __result_of_mp<typename remove_reference<_Fn>::type,
2615 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2619 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2620 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2621 : public __result_of_mp<typename remove_reference<_Fn>::type,
2623 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2629 template <class _Fn>
2630 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2631 : public __result_of<_Fn(),
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>
2640 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2641 : public __result_of<_Fn(_A0),
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>
2650 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2651 : public __result_of<_Fn(_A0, _A1),
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 template <class _Fn, class _A0, class _A1, class _A2>
2660 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
2661 : public __result_of<_Fn(_A0, _A1, _A2),
2662 is_class<typename remove_reference<_Fn>::type>::value ||
2663 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2664 is_member_pointer<typename remove_reference<_Fn>::type>::value
2669 #endif // _LIBCPP_HAS_NO_VARIADICS
2671 // template <class T, class... Args> struct is_constructible;
2673 namespace __is_construct
2678 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
2679 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
2681 template <class _Tp, class... _Args>
2682 struct __libcpp_is_constructible;
2684 template <class _To, class _From>
2685 struct __is_invalid_base_to_derived_cast {
2686 static_assert(is_reference<_To>::value, "Wrong specialization");
2687 using _RawFrom = __uncvref_t<_From>;
2688 using _RawTo = __uncvref_t<_To>;
2689 static const bool value = _And<
2690 _IsNotSame<_RawFrom, _RawTo>,
2691 is_base_of<_RawFrom, _RawTo>,
2692 _Not<__libcpp_is_constructible<_RawTo, _From>>
2696 template <class _To, class _From>
2697 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
2698 static_assert(is_reference<_To>::value, "Wrong specialization");
2701 template <class _ToRef, class _FromRef>
2702 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
2703 using _RawFrom = __uncvref_t<_FromRef>;
2704 using _RawTo = __uncvref_t<_ToRef>;
2705 static const bool value = _And<
2706 _Not<is_function<_RawTo>>,
2708 _IsSame<_RawFrom, _RawTo>,
2709 is_base_of<_RawTo, _RawFrom>>
2713 struct __is_constructible_helper
2715 template <class _To>
2716 static void __eat(_To);
2718 // This overload is needed to work around a Clang bug that disallows
2719 // static_cast<T&&>(e) for non-reference-compatible types.
2720 // Example: static_cast<int&&>(declval<double>());
2721 // NOTE: The static_cast implementation below is required to support
2722 // classes with explicit conversion operators.
2723 template <class _To, class _From,
2724 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
2725 static true_type __test_cast(int);
2727 template <class _To, class _From,
2728 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
2729 static integral_constant<bool,
2730 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
2731 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
2732 > __test_cast(long);
2734 template <class, class>
2735 static false_type __test_cast(...);
2737 template <class _Tp, class ..._Args,
2738 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
2739 static true_type __test_nary(int);
2740 template <class _Tp, class...>
2741 static false_type __test_nary(...);
2743 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
2744 static is_destructible<_Tp> __test_unary(int);
2745 template <class, class>
2746 static false_type __test_unary(...);
2749 template <class _Tp, bool = is_void<_Tp>::value>
2750 struct __is_default_constructible
2751 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
2754 template <class _Tp>
2755 struct __is_default_constructible<_Tp, true> : false_type {};
2757 template <class _Tp>
2758 struct __is_default_constructible<_Tp[], false> : false_type {};
2760 template <class _Tp, size_t _Nx>
2761 struct __is_default_constructible<_Tp[_Nx], false>
2762 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
2764 template <class _Tp, class... _Args>
2765 struct __libcpp_is_constructible
2767 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
2768 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
2772 template <class _Tp>
2773 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
2775 template <class _Tp, class _A0>
2776 struct __libcpp_is_constructible<_Tp, _A0>
2777 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
2780 template <class _Tp, class _A0>
2781 struct __libcpp_is_constructible<_Tp&, _A0>
2782 : public decltype(__is_constructible_helper::
2783 __test_cast<_Tp&, _A0>(0))
2786 template <class _Tp, class _A0>
2787 struct __libcpp_is_constructible<_Tp&&, _A0>
2788 : public decltype(__is_constructible_helper::
2789 __test_cast<_Tp&&, _A0>(0))
2794 #if __has_feature(is_constructible)
2795 template <class _Tp, class ..._Args>
2796 struct _LIBCPP_TEMPLATE_VIS is_constructible
2797 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2800 template <class _Tp, class... _Args>
2801 struct _LIBCPP_TEMPLATE_VIS is_constructible
2802 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
2805 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2806 template <class _Tp, class ..._Args>
2807 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
2808 = is_constructible<_Tp, _Args...>::value;
2811 // is_default_constructible
2813 template <class _Tp>
2814 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
2815 : public is_constructible<_Tp>
2818 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2819 template <class _Tp>
2820 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
2821 = is_default_constructible<_Tp>::value;
2824 #ifndef _LIBCPP_CXX03_LANG
2825 // First of all, we can't implement this check in C++03 mode because the {}
2826 // default initialization syntax isn't valid.
2827 // Second, we implement the trait in a funny manner with two defaulted template
2828 // arguments to workaround Clang's PR43454.
2829 template <class _Tp>
2830 void __test_implicit_default_constructible(_Tp);
2832 template <class _Tp, class = void, bool = is_default_constructible<_Tp>::value>
2833 struct __is_implicitly_default_constructible
2837 template <class _Tp>
2838 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true>
2842 template <class _Tp>
2843 struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false>
2848 // is_copy_constructible
2850 template <class _Tp>
2851 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
2852 : public is_constructible<_Tp,
2853 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2855 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2856 template <class _Tp>
2857 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
2858 = is_copy_constructible<_Tp>::value;
2861 // is_move_constructible
2863 template <class _Tp>
2864 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
2865 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2868 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2869 template <class _Tp>
2870 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
2871 = is_move_constructible<_Tp>::value;
2874 // is_trivially_constructible
2876 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
2878 template <class _Tp, class... _Args>
2879 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2880 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2884 #else // !__has_feature(is_trivially_constructible)
2886 template <class _Tp, class... _Args>
2887 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2892 template <class _Tp>
2893 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
2894 #if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC)
2895 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2897 : integral_constant<bool, is_scalar<_Tp>::value>
2902 template <class _Tp>
2903 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
2904 : integral_constant<bool, is_scalar<_Tp>::value>
2908 template <class _Tp>
2909 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
2910 : integral_constant<bool, is_scalar<_Tp>::value>
2914 template <class _Tp>
2915 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
2916 : integral_constant<bool, is_scalar<_Tp>::value>
2920 #endif // !__has_feature(is_trivially_constructible)
2923 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2924 template <class _Tp, class... _Args>
2925 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
2926 = is_trivially_constructible<_Tp, _Args...>::value;
2929 // is_trivially_default_constructible
2931 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
2932 : public is_trivially_constructible<_Tp>
2935 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2936 template <class _Tp>
2937 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
2938 = is_trivially_default_constructible<_Tp>::value;
2941 // is_trivially_copy_constructible
2943 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
2944 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2947 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2948 template <class _Tp>
2949 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
2950 = is_trivially_copy_constructible<_Tp>::value;
2953 // is_trivially_move_constructible
2955 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
2956 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2959 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2960 template <class _Tp>
2961 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
2962 = is_trivially_move_constructible<_Tp>::value;
2965 // is_trivially_assignable
2967 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
2969 template <class _Tp, class _Arg>
2970 struct is_trivially_assignable
2971 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2975 #else // !__has_feature(is_trivially_assignable)
2977 template <class _Tp, class _Arg>
2978 struct is_trivially_assignable
2979 : public false_type {};
2981 template <class _Tp>
2982 struct is_trivially_assignable<_Tp&, _Tp>
2983 : integral_constant<bool, is_scalar<_Tp>::value> {};
2985 template <class _Tp>
2986 struct is_trivially_assignable<_Tp&, _Tp&>
2987 : integral_constant<bool, is_scalar<_Tp>::value> {};
2989 template <class _Tp>
2990 struct is_trivially_assignable<_Tp&, const _Tp&>
2991 : integral_constant<bool, is_scalar<_Tp>::value> {};
2993 template <class _Tp>
2994 struct is_trivially_assignable<_Tp&, _Tp&&>
2995 : integral_constant<bool, is_scalar<_Tp>::value> {};
2997 #endif // !__has_feature(is_trivially_assignable)
2999 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3000 template <class _Tp, class _Arg>
3001 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3002 = is_trivially_assignable<_Tp, _Arg>::value;
3005 // is_trivially_copy_assignable
3007 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3008 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3009 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3011 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3012 template <class _Tp>
3013 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3014 = is_trivially_copy_assignable<_Tp>::value;
3017 // is_trivially_move_assignable
3019 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3020 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3021 typename add_rvalue_reference<_Tp>::type>
3024 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3025 template <class _Tp>
3026 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3027 = is_trivially_move_assignable<_Tp>::value;
3030 // is_trivially_destructible
3032 #if __has_keyword(__is_trivially_destructible)
3034 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3035 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
3037 #elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
3039 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3040 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3044 template <class _Tp> struct __libcpp_trivial_destructor
3045 : public integral_constant<bool, is_scalar<_Tp>::value ||
3046 is_reference<_Tp>::value> {};
3048 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3049 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3051 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3052 : public false_type {};
3056 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3057 template <class _Tp>
3058 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3059 = is_trivially_destructible<_Tp>::value;
3062 // is_nothrow_constructible
3064 #if __has_keyword(__is_nothrow_constructible)
3066 template <class _Tp, class... _Args>
3067 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3068 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
3072 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3074 template <class _Tp, class... _Args>
3075 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3076 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3080 template <class _Tp>
3081 void __implicit_conversion_to(_Tp) noexcept { }
3083 template <class _Tp, class _Arg>
3084 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3085 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3089 template <class _Tp, bool _IsReference, class... _Args>
3090 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3095 template <class _Tp, class... _Args>
3096 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3097 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3101 template <class _Tp, size_t _Ns>
3102 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3103 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3107 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3110 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3111 template <class _Tp, class ..._Args>
3112 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3113 = is_nothrow_constructible<_Tp, _Args...>::value;
3116 // is_nothrow_default_constructible
3118 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3119 : public is_nothrow_constructible<_Tp>
3122 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3123 template <class _Tp>
3124 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3125 = is_nothrow_default_constructible<_Tp>::value;
3128 // is_nothrow_copy_constructible
3130 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3131 : public is_nothrow_constructible<_Tp,
3132 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3134 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3135 template <class _Tp>
3136 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3137 = is_nothrow_copy_constructible<_Tp>::value;
3140 // is_nothrow_move_constructible
3142 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3143 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3146 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3147 template <class _Tp>
3148 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3149 = is_nothrow_move_constructible<_Tp>::value;
3152 // is_nothrow_assignable
3154 #if __has_keyword(__is_nothrow_assignable)
3156 template <class _Tp, class _Arg>
3157 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3158 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
3162 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3164 template <class _Tp, class _Arg>
3165 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3170 template <class _Tp, class _Arg>
3171 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3172 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3176 template <class _Tp, class _Arg>
3177 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3178 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3182 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3184 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3185 template <class _Tp, class _Arg>
3186 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3187 = is_nothrow_assignable<_Tp, _Arg>::value;
3190 // is_nothrow_copy_assignable
3192 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3193 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3194 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3196 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3197 template <class _Tp>
3198 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3199 = is_nothrow_copy_assignable<_Tp>::value;
3202 // is_nothrow_move_assignable
3204 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3205 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3206 typename add_rvalue_reference<_Tp>::type>
3209 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3210 template <class _Tp>
3211 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3212 = is_nothrow_move_assignable<_Tp>::value;
3215 // is_nothrow_destructible
3217 #if !defined(_LIBCPP_CXX03_LANG)
3219 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3221 template <class _Tp>
3222 struct __libcpp_is_nothrow_destructible<false, _Tp>
3227 template <class _Tp>
3228 struct __libcpp_is_nothrow_destructible<true, _Tp>
3229 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3233 template <class _Tp>
3234 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3235 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3239 template <class _Tp, size_t _Ns>
3240 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3241 : public is_nothrow_destructible<_Tp>
3245 template <class _Tp>
3246 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3251 template <class _Tp>
3252 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3259 template <class _Tp> struct __libcpp_nothrow_destructor
3260 : public integral_constant<bool, is_scalar<_Tp>::value ||
3261 is_reference<_Tp>::value> {};
3263 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3264 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3266 template <class _Tp>
3267 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3268 : public false_type {};
3272 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3273 template <class _Tp>
3274 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3275 = is_nothrow_destructible<_Tp>::value;
3280 #if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
3282 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3283 : public integral_constant<bool, __is_pod(_Tp)> {};
3287 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3288 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3289 is_trivially_copy_constructible<_Tp>::value &&
3290 is_trivially_copy_assignable<_Tp>::value &&
3291 is_trivially_destructible<_Tp>::value> {};
3295 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3296 template <class _Tp>
3297 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
3298 = is_pod<_Tp>::value;
3303 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
3304 : public integral_constant<bool, __is_literal_type(_Tp)>
3307 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3308 template <class _Tp>
3309 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
3310 = is_literal_type<_Tp>::value;
3313 // is_standard_layout;
3315 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3316 #if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
3317 : public integral_constant<bool, __is_standard_layout(_Tp)>
3319 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3323 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3324 template <class _Tp>
3325 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
3326 = is_standard_layout<_Tp>::value;
3329 // is_trivially_copyable;
3331 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3332 #if __has_feature(is_trivially_copyable)
3333 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3334 #elif _GNUC_VER >= 501
3335 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3337 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3341 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3342 template <class _Tp>
3343 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3344 = is_trivially_copyable<_Tp>::value;
3349 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3350 #if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
3351 : public integral_constant<bool, __is_trivial(_Tp)>
3353 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3354 is_trivially_default_constructible<_Tp>::value>
3358 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3359 template <class _Tp>
3360 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
3361 = is_trivial<_Tp>::value;
3364 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3365 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3366 template <class _Tp> struct __is_reference_wrapper
3367 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3369 #ifndef _LIBCPP_CXX03_LANG
3371 template <class _Fp, class _A0,
3372 class _DecayFp = typename decay<_Fp>::type,
3373 class _DecayA0 = typename decay<_A0>::type,
3374 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3375 using __enable_if_bullet1 = typename enable_if
3377 is_member_function_pointer<_DecayFp>::value
3378 && is_base_of<_ClassT, _DecayA0>::value
3381 template <class _Fp, class _A0,
3382 class _DecayFp = typename decay<_Fp>::type,
3383 class _DecayA0 = typename decay<_A0>::type>
3384 using __enable_if_bullet2 = typename enable_if
3386 is_member_function_pointer<_DecayFp>::value
3387 && __is_reference_wrapper<_DecayA0>::value
3390 template <class _Fp, class _A0,
3391 class _DecayFp = typename decay<_Fp>::type,
3392 class _DecayA0 = typename decay<_A0>::type,
3393 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3394 using __enable_if_bullet3 = typename enable_if
3396 is_member_function_pointer<_DecayFp>::value
3397 && !is_base_of<_ClassT, _DecayA0>::value
3398 && !__is_reference_wrapper<_DecayA0>::value
3401 template <class _Fp, class _A0,
3402 class _DecayFp = typename decay<_Fp>::type,
3403 class _DecayA0 = typename decay<_A0>::type,
3404 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3405 using __enable_if_bullet4 = typename enable_if
3407 is_member_object_pointer<_DecayFp>::value
3408 && is_base_of<_ClassT, _DecayA0>::value
3411 template <class _Fp, class _A0,
3412 class _DecayFp = typename decay<_Fp>::type,
3413 class _DecayA0 = typename decay<_A0>::type>
3414 using __enable_if_bullet5 = typename enable_if
3416 is_member_object_pointer<_DecayFp>::value
3417 && __is_reference_wrapper<_DecayA0>::value
3420 template <class _Fp, class _A0,
3421 class _DecayFp = typename decay<_Fp>::type,
3422 class _DecayA0 = typename decay<_A0>::type,
3423 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3424 using __enable_if_bullet6 = typename enable_if
3426 is_member_object_pointer<_DecayFp>::value
3427 && !is_base_of<_ClassT, _DecayA0>::value
3428 && !__is_reference_wrapper<_DecayA0>::value
3431 // __invoke forward declarations
3433 // fall back - none of the bullets
3435 #define _LIBCPP_INVOKE_RETURN(...) \
3436 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
3437 { return __VA_ARGS__; }
3439 template <class ..._Args>
3440 auto __invoke(__any, _Args&& ...__args) -> __nat;
3442 template <class ..._Args>
3443 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
3445 // bullets 1, 2 and 3
3447 template <class _Fp, class _A0, class ..._Args,
3448 class = __enable_if_bullet1<_Fp, _A0>>
3449 inline _LIBCPP_INLINE_VISIBILITY
3451 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3452 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3454 template <class _Fp, class _A0, class ..._Args,
3455 class = __enable_if_bullet1<_Fp, _A0>>
3456 inline _LIBCPP_INLINE_VISIBILITY
3457 _LIBCPP_CONSTEXPR auto
3458 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3459 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3461 template <class _Fp, class _A0, class ..._Args,
3462 class = __enable_if_bullet2<_Fp, _A0>>
3463 inline _LIBCPP_INLINE_VISIBILITY
3465 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3466 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3468 template <class _Fp, class _A0, class ..._Args,
3469 class = __enable_if_bullet2<_Fp, _A0>>
3470 inline _LIBCPP_INLINE_VISIBILITY
3471 _LIBCPP_CONSTEXPR auto
3472 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3473 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3475 template <class _Fp, class _A0, class ..._Args,
3476 class = __enable_if_bullet3<_Fp, _A0>>
3477 inline _LIBCPP_INLINE_VISIBILITY
3479 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3480 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3482 template <class _Fp, class _A0, class ..._Args,
3483 class = __enable_if_bullet3<_Fp, _A0>>
3484 inline _LIBCPP_INLINE_VISIBILITY
3485 _LIBCPP_CONSTEXPR auto
3486 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3487 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3489 // bullets 4, 5 and 6
3491 template <class _Fp, class _A0,
3492 class = __enable_if_bullet4<_Fp, _A0>>
3493 inline _LIBCPP_INLINE_VISIBILITY
3495 __invoke(_Fp&& __f, _A0&& __a0)
3496 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3498 template <class _Fp, class _A0,
3499 class = __enable_if_bullet4<_Fp, _A0>>
3500 inline _LIBCPP_INLINE_VISIBILITY
3501 _LIBCPP_CONSTEXPR auto
3502 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3503 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3505 template <class _Fp, class _A0,
3506 class = __enable_if_bullet5<_Fp, _A0>>
3507 inline _LIBCPP_INLINE_VISIBILITY
3509 __invoke(_Fp&& __f, _A0&& __a0)
3510 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3512 template <class _Fp, class _A0,
3513 class = __enable_if_bullet5<_Fp, _A0>>
3514 inline _LIBCPP_INLINE_VISIBILITY
3515 _LIBCPP_CONSTEXPR auto
3516 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3517 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3519 template <class _Fp, class _A0,
3520 class = __enable_if_bullet6<_Fp, _A0>>
3521 inline _LIBCPP_INLINE_VISIBILITY
3523 __invoke(_Fp&& __f, _A0&& __a0)
3524 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3526 template <class _Fp, class _A0,
3527 class = __enable_if_bullet6<_Fp, _A0>>
3528 inline _LIBCPP_INLINE_VISIBILITY
3529 _LIBCPP_CONSTEXPR auto
3530 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3531 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3535 template <class _Fp, class ..._Args>
3536 inline _LIBCPP_INLINE_VISIBILITY
3538 __invoke(_Fp&& __f, _Args&& ...__args)
3539 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3541 template <class _Fp, class ..._Args>
3542 inline _LIBCPP_INLINE_VISIBILITY
3543 _LIBCPP_CONSTEXPR auto
3544 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
3545 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3547 #undef _LIBCPP_INVOKE_RETURN
3550 template <class _Ret, class _Fp, class ..._Args>
3551 struct __invokable_r
3553 template <class _XFp, class ..._XArgs>
3554 static auto __try_call(int) -> decltype(
3555 _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...));
3556 template <class _XFp, class ..._XArgs>
3557 static __nat __try_call(...);
3559 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
3560 // or incomplete array types as required by the standard.
3561 using _Result = decltype(__try_call<_Fp, _Args...>(0));
3564 typename conditional<
3565 _IsNotSame<_Result, __nat>::value,
3566 typename conditional<
3567 is_void<_Ret>::value,
3569 is_convertible<_Result, _Ret>
3573 static const bool value = type::value;
3575 template <class _Fp, class ..._Args>
3576 using __invokable = __invokable_r<void, _Fp, _Args...>;
3578 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
3579 struct __nothrow_invokable_r_imp {
3580 static const bool value = false;
3583 template <class _Ret, class _Fp, class ..._Args>
3584 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
3586 typedef __nothrow_invokable_r_imp _ThisT;
3588 template <class _Tp>
3589 static void __test_noexcept(_Tp) noexcept;
3591 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
3592 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
3595 template <class _Ret, class _Fp, class ..._Args>
3596 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
3598 static const bool value = noexcept(
3599 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
3602 template <class _Ret, class _Fp, class ..._Args>
3603 using __nothrow_invokable_r =
3604 __nothrow_invokable_r_imp<
3605 __invokable_r<_Ret, _Fp, _Args...>::value,
3606 is_void<_Ret>::value,
3610 template <class _Fp, class ..._Args>
3611 using __nothrow_invokable =
3612 __nothrow_invokable_r_imp<
3613 __invokable<_Fp, _Args...>::value,
3614 true, void, _Fp, _Args...
3617 template <class _Fp, class ..._Args>
3620 __invokable<_Fp, _Args...>::value,
3621 typename __invokable_r<void, _Fp, _Args...>::_Result>
3627 template <class _Fp, class ..._Args>
3628 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
3629 : public __invoke_of<_Fp, _Args...>
3633 #if _LIBCPP_STD_VER > 11
3634 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3637 #if _LIBCPP_STD_VER > 14
3641 template <class _Fn, class... _Args>
3642 struct _LIBCPP_TEMPLATE_VIS invoke_result
3643 : __invoke_of<_Fn, _Args...>
3647 template <class _Fn, class... _Args>
3648 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
3652 template <class _Fn, class ..._Args>
3653 struct _LIBCPP_TEMPLATE_VIS is_invocable
3654 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
3656 template <class _Ret, class _Fn, class ..._Args>
3657 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
3658 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
3660 template <class _Fn, class ..._Args>
3661 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
3662 = is_invocable<_Fn, _Args...>::value;
3664 template <class _Ret, class _Fn, class ..._Args>
3665 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
3666 = is_invocable_r<_Ret, _Fn, _Args...>::value;
3668 // is_nothrow_invocable
3670 template <class _Fn, class ..._Args>
3671 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
3672 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
3674 template <class _Ret, class _Fn, class ..._Args>
3675 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
3676 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
3678 template <class _Fn, class ..._Args>
3679 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
3680 = is_nothrow_invocable<_Fn, _Args...>::value;
3682 template <class _Ret, class _Fn, class ..._Args>
3683 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
3684 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
3686 #endif // _LIBCPP_STD_VER > 14
3688 #endif // !defined(_LIBCPP_CXX03_LANG)
3690 template <class _Tp> struct __is_swappable;
3691 template <class _Tp> struct __is_nothrow_swappable;
3693 // swap, swap_ranges
3695 template <class _ForwardIterator1, class _ForwardIterator2>
3696 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3698 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2);
3700 template <class _Tp>
3701 inline _LIBCPP_INLINE_VISIBILITY
3702 #ifndef _LIBCPP_CXX03_LANG
3705 is_move_constructible<_Tp>::value &&
3706 is_move_assignable<_Tp>::value
3711 _LIBCPP_CONSTEXPR_AFTER_CXX17
3712 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3713 is_nothrow_move_assignable<_Tp>::value)
3715 _Tp __t(_VSTD::move(__x));
3716 __x = _VSTD::move(__y);
3717 __y = _VSTD::move(__t);
3720 template<class _Tp, size_t _Np>
3721 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3723 __is_swappable<_Tp>::value
3725 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
3727 _VSTD::swap_ranges(__a, __a + _Np, __b);
3730 template <class _ForwardIterator1, class _ForwardIterator2>
3731 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3733 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
3735 for(; __first1 != __last1; ++__first1, (void) ++__first2)
3736 swap(*__first1, *__first2);
3742 template <class _ForwardIterator1, class _ForwardIterator2>
3743 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3745 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3746 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3747 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3748 *_VSTD::declval<_ForwardIterator2>())))
3757 // ALL generic swap overloads MUST already have a declaration available at this point.
3759 template <class _Tp, class _Up = _Tp,
3760 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
3761 struct __swappable_with
3763 template <class _LHS, class _RHS>
3764 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
3766 template <class, class>
3767 static __nat __test_swap(long);
3769 // Extra parens are needed for the C++03 definition of decltype.
3770 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
3771 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
3773 static const bool value = _IsNotSame<__swap1, __nat>::value
3774 && _IsNotSame<__swap2, __nat>::value;
3777 template <class _Tp, class _Up>
3778 struct __swappable_with<_Tp, _Up, false> : false_type {};
3780 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
3781 struct __nothrow_swappable_with {
3782 static const bool value =
3783 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
3784 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
3785 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
3791 template <class _Tp, class _Up>
3792 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
3796 template <class _Tp>
3797 struct __is_swappable
3798 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
3802 template <class _Tp>
3803 struct __is_nothrow_swappable
3804 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
3808 #if _LIBCPP_STD_VER > 14
3810 template <class _Tp, class _Up>
3811 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
3812 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
3816 template <class _Tp>
3817 struct _LIBCPP_TEMPLATE_VIS is_swappable
3818 : public conditional<
3819 __is_referenceable<_Tp>::value,
3821 typename add_lvalue_reference<_Tp>::type,
3822 typename add_lvalue_reference<_Tp>::type>,
3828 template <class _Tp, class _Up>
3829 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
3830 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
3834 template <class _Tp>
3835 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
3836 : public conditional<
3837 __is_referenceable<_Tp>::value,
3838 is_nothrow_swappable_with<
3839 typename add_lvalue_reference<_Tp>::type,
3840 typename add_lvalue_reference<_Tp>::type>,
3846 template <class _Tp, class _Up>
3847 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
3848 = is_swappable_with<_Tp, _Up>::value;
3850 template <class _Tp>
3851 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
3852 = is_swappable<_Tp>::value;
3854 template <class _Tp, class _Up>
3855 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
3856 = is_nothrow_swappable_with<_Tp, _Up>::value;
3858 template <class _Tp>
3859 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
3860 = is_nothrow_swappable<_Tp>::value;
3862 #endif // _LIBCPP_STD_VER > 14
3864 template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
3866 template <class _Tp>
3867 struct __underlying_type_impl<_Tp, false> {};
3869 template <class _Tp>
3870 struct __underlying_type_impl<_Tp, true>
3872 typedef __underlying_type(_Tp) type;
3875 template <class _Tp>
3876 struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
3878 #if _LIBCPP_STD_VER > 11
3879 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3883 template <class _Tp, bool = is_enum<_Tp>::value>
3884 struct __sfinae_underlying_type
3886 typedef typename underlying_type<_Tp>::type type;
3887 typedef decltype(((type)1) + 0) __promoted_type;
3890 template <class _Tp>
3891 struct __sfinae_underlying_type<_Tp, false> {};
3893 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3894 int __convert_to_integral(int __val) { return __val; }
3896 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3897 unsigned __convert_to_integral(unsigned __val) { return __val; }
3899 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3900 long __convert_to_integral(long __val) { return __val; }
3902 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3903 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
3905 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3906 long long __convert_to_integral(long long __val) { return __val; }
3908 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3909 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
3911 template<typename _Fp>
3912 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3913 typename enable_if<is_floating_point<_Fp>::value, long long>::type
3914 __convert_to_integral(_Fp __val) { return __val; }
3916 #ifndef _LIBCPP_HAS_NO_INT128
3917 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3918 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
3920 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3921 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
3924 template <class _Tp>
3925 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3926 typename __sfinae_underlying_type<_Tp>::__promoted_type
3927 __convert_to_integral(_Tp __val) { return __val; }
3929 #ifndef _LIBCPP_CXX03_LANG
3931 template <class _Tp>
3932 struct __has_operator_addressof_member_imp
3934 template <class _Up>
3935 static auto __test(int)
3936 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
3938 static auto __test(long) -> false_type;
3940 static const bool value = decltype(__test<_Tp>(0))::value;
3943 template <class _Tp>
3944 struct __has_operator_addressof_free_imp
3946 template <class _Up>
3947 static auto __test(int)
3948 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
3950 static auto __test(long) -> false_type;
3952 static const bool value = decltype(__test<_Tp>(0))::value;
3955 template <class _Tp>
3956 struct __has_operator_addressof
3957 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
3958 || __has_operator_addressof_free_imp<_Tp>::value>
3961 #endif // _LIBCPP_CXX03_LANG
3963 #if _LIBCPP_STD_VER > 14
3965 template <class...> using void_t = void;
3967 template <class... _Args>
3968 struct conjunction : _And<_Args...> {};
3969 template<class... _Args>
3970 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
3971 = conjunction<_Args...>::value;
3973 template <class... _Args>
3974 struct disjunction : _Or<_Args...> {};
3975 template<class... _Args>
3976 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
3977 = disjunction<_Args...>::value;
3979 template <class _Tp>
3980 struct negation : _Not<_Tp> {};
3982 _LIBCPP_INLINE_VAR constexpr bool negation_v
3983 = negation<_Tp>::value;
3984 #endif // _LIBCPP_STD_VER > 14
3986 // These traits are used in __tree and __hash_table
3987 #ifndef _LIBCPP_CXX03_LANG
3988 struct __extract_key_fail_tag {};
3989 struct __extract_key_self_tag {};
3990 struct __extract_key_first_tag {};
3992 template <class _ValTy, class _Key,
3993 class _RawValTy = typename __unconstref<_ValTy>::type>
3994 struct __can_extract_key
3995 : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
3996 __extract_key_fail_tag>::type {};
3998 template <class _Pair, class _Key, class _First, class _Second>
3999 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4000 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
4001 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4003 // __can_extract_map_key uses true_type/false_type instead of the tags.
4004 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4005 // and _ValTy == _Key.
4006 template <class _ValTy, class _Key, class _ContainerValueTy,
4007 class _RawValTy = typename __unconstref<_ValTy>::type>
4008 struct __can_extract_map_key
4009 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
4011 // This specialization returns __extract_key_fail_tag for non-map containers
4012 // because _Key == _ContainerValueTy
4013 template <class _ValTy, class _Key, class _RawValTy>
4014 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4019 #ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
4020 #if _LIBCPP_STD_VER > 17
4021 _LIBCPP_INLINE_VISIBILITY
4022 inline constexpr bool is_constant_evaluated() noexcept {
4023 return __builtin_is_constant_evaluated();
4027 inline _LIBCPP_CONSTEXPR
4028 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
4030 inline _LIBCPP_CONSTEXPR
4031 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; }
4034 template <class _CharT>
4035 using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
4037 _LIBCPP_END_NAMESPACE_STD
4039 #if _LIBCPP_STD_VER > 14
4041 namespace std // purposefully not versioned
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>, byte>::type &
4055 operator>>=(byte& __lhs, _Integer __shift) noexcept
4056 { return __lhs = __lhs >> __shift; }
4058 template <class _Integer>
4059 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4060 operator>> (byte __lhs, _Integer __shift) noexcept
4061 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4063 template <class _Integer>
4064 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4065 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4070 #endif // _LIBCPP_TYPE_TRAITS