2 //===------------------------ type_traits ---------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_TYPE_TRAITS
11 #define _LIBCPP_TYPE_TRAITS
20 template <class T, T v> struct integral_constant;
21 typedef integral_constant<bool, true> true_type; // C++11
22 typedef integral_constant<bool, false> false_type; // C++11
24 template <bool B> // C++14
25 using bool_constant = integral_constant<bool, B>; // C++14
26 typedef bool_constant<true> true_type; // C++14
27 typedef bool_constant<false> false_type; // C++14
30 template <bool, class T = void> struct enable_if;
31 template <bool, class T, class F> struct conditional;
33 // Primary classification traits:
34 template <class T> struct is_void;
35 template <class T> struct is_null_pointer; // C++14
36 template <class T> struct is_integral;
37 template <class T> struct is_floating_point;
38 template <class T> struct is_array;
39 template <class T> struct is_pointer;
40 template <class T> struct is_lvalue_reference;
41 template <class T> struct is_rvalue_reference;
42 template <class T> struct is_member_object_pointer;
43 template <class T> struct is_member_function_pointer;
44 template <class T> struct is_enum;
45 template <class T> struct is_union;
46 template <class T> struct is_class;
47 template <class T> struct is_function;
49 // Secondary classification traits:
50 template <class T> struct is_reference;
51 template <class T> struct is_arithmetic;
52 template <class T> struct is_fundamental;
53 template <class T> struct is_member_pointer;
54 template <class T> struct is_scalar;
55 template <class T> struct is_object;
56 template <class T> struct is_compound;
58 // Const-volatile properties and transformations:
59 template <class T> struct is_const;
60 template <class T> struct is_volatile;
61 template <class T> struct remove_const;
62 template <class T> struct remove_volatile;
63 template <class T> struct remove_cv;
64 template <class T> struct add_const;
65 template <class T> struct add_volatile;
66 template <class T> struct add_cv;
68 // Reference transformations:
69 template <class T> struct remove_reference;
70 template <class T> struct add_lvalue_reference;
71 template <class T> struct add_rvalue_reference;
73 // Pointer transformations:
74 template <class T> struct remove_pointer;
75 template <class T> struct add_pointer;
77 template<class T> struct type_identity; // C++20
79 using type_identity_t = typename type_identity<T>::type; // C++20
81 // Integral properties:
82 template <class T> struct is_signed;
83 template <class T> struct is_unsigned;
84 template <class T> struct make_signed;
85 template <class T> struct make_unsigned;
87 // Array properties and transformations:
88 template <class T> struct rank;
89 template <class T, unsigned I = 0> struct extent;
90 template <class T> struct remove_extent;
91 template <class T> struct remove_all_extents;
93 template <class T> struct is_bounded_array; // C++20
94 template <class T> struct is_unbounded_array; // C++20
96 // Member introspection:
97 template <class T> struct is_pod;
98 template <class T> struct is_trivial;
99 template <class T> struct is_trivially_copyable;
100 template <class T> struct is_standard_layout;
101 template <class T> struct is_literal_type;
102 template <class T> struct is_empty;
103 template <class T> struct is_polymorphic;
104 template <class T> struct is_abstract;
105 template <class T> struct is_final; // C++14
106 template <class T> struct is_aggregate; // C++17
108 template <class T, class... Args> struct is_constructible;
109 template <class T> struct is_default_constructible;
110 template <class T> struct is_copy_constructible;
111 template <class T> struct is_move_constructible;
112 template <class T, class U> struct is_assignable;
113 template <class T> struct is_copy_assignable;
114 template <class T> struct is_move_assignable;
115 template <class T, class U> struct is_swappable_with; // C++17
116 template <class T> struct is_swappable; // C++17
117 template <class T> struct is_destructible;
119 template <class T, class... Args> struct is_trivially_constructible;
120 template <class T> struct is_trivially_default_constructible;
121 template <class T> struct is_trivially_copy_constructible;
122 template <class T> struct is_trivially_move_constructible;
123 template <class T, class U> struct is_trivially_assignable;
124 template <class T> struct is_trivially_copy_assignable;
125 template <class T> struct is_trivially_move_assignable;
126 template <class T> struct is_trivially_destructible;
128 template <class T, class... Args> struct is_nothrow_constructible;
129 template <class T> struct is_nothrow_default_constructible;
130 template <class T> struct is_nothrow_copy_constructible;
131 template <class T> struct is_nothrow_move_constructible;
132 template <class T, class U> struct is_nothrow_assignable;
133 template <class T> struct is_nothrow_copy_assignable;
134 template <class T> struct is_nothrow_move_assignable;
135 template <class T, class U> struct is_nothrow_swappable_with; // C++17
136 template <class T> struct is_nothrow_swappable; // C++17
137 template <class T> struct is_nothrow_destructible;
139 template <class T> struct has_virtual_destructor;
141 template<class T> struct has_unique_object_representations; // C++17
143 // Relationships between types:
144 template <class T, class U> struct is_same;
145 template <class Base, class Derived> struct is_base_of;
147 template <class From, class To> struct is_convertible;
148 template <typename From, typename To> struct is_nothrow_convertible; // C++20
149 template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20
151 template <class Fn, class... ArgTypes> struct is_invocable;
152 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
154 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
155 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
157 // Alignment properties and transformations:
158 template <class T> struct alignment_of;
159 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
160 struct aligned_storage;
161 template <size_t Len, class... Types> struct aligned_union;
162 template <class T> struct remove_cvref; // C++20
164 template <class T> struct decay;
165 template <class... T> struct common_type;
166 template <class T> struct underlying_type;
167 template <class> class result_of; // undefined
168 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
169 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
171 // const-volatile modifications:
173 using remove_const_t = typename remove_const<T>::type; // C++14
175 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
177 using remove_cv_t = typename remove_cv<T>::type; // C++14
179 using add_const_t = typename add_const<T>::type; // C++14
181 using add_volatile_t = typename add_volatile<T>::type; // C++14
183 using add_cv_t = typename add_cv<T>::type; // C++14
185 // reference modifications:
187 using remove_reference_t = typename remove_reference<T>::type; // C++14
189 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
191 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
193 // sign modifications:
195 using make_signed_t = typename make_signed<T>::type; // C++14
197 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
199 // array modifications:
201 using remove_extent_t = typename remove_extent<T>::type; // C++14
203 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
206 inline constexpr bool is_bounded_array_v
207 = is_bounded_array<T>::value; // C++20
208 inline constexpr bool is_unbounded_array_v
209 = is_unbounded_array<T>::value; // C++20
211 // pointer modifications:
213 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
215 using add_pointer_t = typename add_pointer<T>::type; // C++14
217 // other transformations:
218 template <size_t Len, std::size_t Align=default-alignment>
219 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
220 template <std::size_t Len, class... Types>
221 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
223 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
225 using decay_t = typename decay<T>::type; // C++14
226 template <bool b, class T=void>
227 using enable_if_t = typename enable_if<b,T>::type; // C++14
228 template <bool b, class T, class F>
229 using conditional_t = typename conditional<b,T,F>::type; // C++14
230 template <class... T>
231 using common_type_t = typename common_type<T...>::type; // C++14
233 using underlying_type_t = typename underlying_type<T>::type; // C++14
235 using result_of_t = typename result_of<T>::type; // C++14
236 template <class Fn, class... ArgTypes>
237 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
240 using void_t = void; // C++17
242 // See C++14 20.10.4.1, primary type categories
243 template <class T> inline constexpr bool is_void_v
244 = is_void<T>::value; // C++17
245 template <class T> inline constexpr bool is_null_pointer_v
246 = is_null_pointer<T>::value; // C++17
247 template <class T> inline constexpr bool is_integral_v
248 = is_integral<T>::value; // C++17
249 template <class T> inline constexpr bool is_floating_point_v
250 = is_floating_point<T>::value; // C++17
251 template <class T> inline constexpr bool is_array_v
252 = is_array<T>::value; // C++17
253 template <class T> inline constexpr bool is_pointer_v
254 = is_pointer<T>::value; // C++17
255 template <class T> inline constexpr bool is_lvalue_reference_v
256 = is_lvalue_reference<T>::value; // C++17
257 template <class T> inline constexpr bool is_rvalue_reference_v
258 = is_rvalue_reference<T>::value; // C++17
259 template <class T> inline constexpr bool is_member_object_pointer_v
260 = is_member_object_pointer<T>::value; // C++17
261 template <class T> inline constexpr bool is_member_function_pointer_v
262 = is_member_function_pointer<T>::value; // C++17
263 template <class T> inline constexpr bool is_enum_v
264 = is_enum<T>::value; // C++17
265 template <class T> inline constexpr bool is_union_v
266 = is_union<T>::value; // C++17
267 template <class T> inline constexpr bool is_class_v
268 = is_class<T>::value; // C++17
269 template <class T> inline constexpr bool is_function_v
270 = is_function<T>::value; // C++17
272 // See C++14 20.10.4.2, composite type categories
273 template <class T> inline constexpr bool is_reference_v
274 = is_reference<T>::value; // C++17
275 template <class T> inline constexpr bool is_arithmetic_v
276 = is_arithmetic<T>::value; // C++17
277 template <class T> inline constexpr bool is_fundamental_v
278 = is_fundamental<T>::value; // C++17
279 template <class T> inline constexpr bool is_object_v
280 = is_object<T>::value; // C++17
281 template <class T> inline constexpr bool is_scalar_v
282 = is_scalar<T>::value; // C++17
283 template <class T> inline constexpr bool is_compound_v
284 = is_compound<T>::value; // C++17
285 template <class T> inline constexpr bool is_member_pointer_v
286 = is_member_pointer<T>::value; // C++17
288 // See C++14 20.10.4.3, type properties
289 template <class T> inline constexpr bool is_const_v
290 = is_const<T>::value; // C++17
291 template <class T> inline constexpr bool is_volatile_v
292 = is_volatile<T>::value; // C++17
293 template <class T> inline constexpr bool is_trivial_v
294 = is_trivial<T>::value; // C++17
295 template <class T> inline constexpr bool is_trivially_copyable_v
296 = is_trivially_copyable<T>::value; // C++17
297 template <class T> inline constexpr bool is_standard_layout_v
298 = is_standard_layout<T>::value; // C++17
299 template <class T> inline constexpr bool is_pod_v
300 = is_pod<T>::value; // C++17
301 template <class T> inline constexpr bool is_literal_type_v
302 = is_literal_type<T>::value; // C++17
303 template <class T> inline constexpr bool is_empty_v
304 = is_empty<T>::value; // C++17
305 template <class T> inline constexpr bool is_polymorphic_v
306 = is_polymorphic<T>::value; // C++17
307 template <class T> inline constexpr bool is_abstract_v
308 = is_abstract<T>::value; // C++17
309 template <class T> inline constexpr bool is_final_v
310 = is_final<T>::value; // C++17
311 template <class T> inline constexpr bool is_aggregate_v
312 = is_aggregate<T>::value; // C++17
313 template <class T> inline constexpr bool is_signed_v
314 = is_signed<T>::value; // C++17
315 template <class T> inline constexpr bool is_unsigned_v
316 = is_unsigned<T>::value; // C++17
317 template <class T, class... Args> inline constexpr bool is_constructible_v
318 = is_constructible<T, Args...>::value; // C++17
319 template <class T> inline constexpr bool is_default_constructible_v
320 = is_default_constructible<T>::value; // C++17
321 template <class T> inline constexpr bool is_copy_constructible_v
322 = is_copy_constructible<T>::value; // C++17
323 template <class T> inline constexpr bool is_move_constructible_v
324 = is_move_constructible<T>::value; // C++17
325 template <class T, class U> inline constexpr bool is_assignable_v
326 = is_assignable<T, U>::value; // C++17
327 template <class T> inline constexpr bool is_copy_assignable_v
328 = is_copy_assignable<T>::value; // C++17
329 template <class T> inline constexpr bool is_move_assignable_v
330 = is_move_assignable<T>::value; // C++17
331 template <class T, class U> inline constexpr bool is_swappable_with_v
332 = is_swappable_with<T, U>::value; // C++17
333 template <class T> inline constexpr bool is_swappable_v
334 = is_swappable<T>::value; // C++17
335 template <class T> inline constexpr bool is_destructible_v
336 = is_destructible<T>::value; // C++17
337 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
338 = is_trivially_constructible<T, Args...>::value; // C++17
339 template <class T> inline constexpr bool is_trivially_default_constructible_v
340 = is_trivially_default_constructible<T>::value; // C++17
341 template <class T> inline constexpr bool is_trivially_copy_constructible_v
342 = is_trivially_copy_constructible<T>::value; // C++17
343 template <class T> inline constexpr bool is_trivially_move_constructible_v
344 = is_trivially_move_constructible<T>::value; // C++17
345 template <class T, class U> inline constexpr bool is_trivially_assignable_v
346 = is_trivially_assignable<T, U>::value; // C++17
347 template <class T> inline constexpr bool is_trivially_copy_assignable_v
348 = is_trivially_copy_assignable<T>::value; // C++17
349 template <class T> inline constexpr bool is_trivially_move_assignable_v
350 = is_trivially_move_assignable<T>::value; // C++17
351 template <class T> inline constexpr bool is_trivially_destructible_v
352 = is_trivially_destructible<T>::value; // C++17
353 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
354 = is_nothrow_constructible<T, Args...>::value; // C++17
355 template <class T> inline constexpr bool is_nothrow_default_constructible_v
356 = is_nothrow_default_constructible<T>::value; // C++17
357 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
358 = is_nothrow_copy_constructible<T>::value; // C++17
359 template <class T> inline constexpr bool is_nothrow_move_constructible_v
360 = is_nothrow_move_constructible<T>::value; // C++17
361 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
362 = is_nothrow_assignable<T, U>::value; // C++17
363 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
364 = is_nothrow_copy_assignable<T>::value; // C++17
365 template <class T> inline constexpr bool is_nothrow_move_assignable_v
366 = is_nothrow_move_assignable<T>::value; // C++17
367 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
368 = is_nothrow_swappable_with<T, U>::value; // C++17
369 template <class T> inline constexpr bool is_nothrow_swappable_v
370 = is_nothrow_swappable<T>::value; // C++17
371 template <class T> inline constexpr bool is_nothrow_destructible_v
372 = is_nothrow_destructible<T>::value; // C++17
373 template <class T> inline constexpr bool has_virtual_destructor_v
374 = has_virtual_destructor<T>::value; // C++17
375 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
376 = has_unique_object_representations<T>::value;
378 // See C++14 20.10.5, type property queries
379 template <class T> inline constexpr size_t alignment_of_v
380 = alignment_of<T>::value; // C++17
381 template <class T> inline constexpr size_t rank_v
382 = rank<T>::value; // C++17
383 template <class T, unsigned I = 0> inline constexpr size_t extent_v
384 = extent<T, I>::value; // C++17
386 // See C++14 20.10.6, type relations
387 template <class T, class U> inline constexpr bool is_same_v
388 = is_same<T, U>::value; // C++17
389 template <class Base, class Derived> inline constexpr bool is_base_of_v
390 = is_base_of<Base, Derived>::value; // C++17
391 template <class From, class To> inline constexpr bool is_convertible_v
392 = is_convertible<From, To>::value; // C++17
393 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
394 = is_invocable<Fn, ArgTypes...>::value; // C++17
395 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
396 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
397 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
398 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
399 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
400 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
402 // [meta.logical], logical operator traits:
403 template<class... B> struct conjunction; // C++17
405 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
406 template<class... B> struct disjunction; // C++17
408 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
409 template<class B> struct negation; // C++17
411 inline constexpr bool negation_v = negation<B>::value; // C++17
420 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
421 #pragma GCC system_header
424 _LIBCPP_BEGIN_NAMESPACE_STD
426 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
427 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
428 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
431 template <class _Tp, _Tp __v>
432 struct _LIBCPP_TEMPLATE_VIS integral_constant
434 static _LIBCPP_CONSTEXPR const _Tp value = __v;
435 typedef _Tp value_type;
436 typedef integral_constant type;
437 _LIBCPP_INLINE_VISIBILITY
438 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
439 #if _LIBCPP_STD_VER > 11
440 _LIBCPP_INLINE_VISIBILITY
441 constexpr value_type operator ()() const _NOEXCEPT {return value;}
445 template <class _Tp, _Tp __v>
446 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
448 #if _LIBCPP_STD_VER > 14
450 using bool_constant = integral_constant<bool, __b>;
451 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
453 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
456 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
457 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
460 using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
462 template <bool> struct _MetaBase;
464 struct _MetaBase<true> {
465 template <class _Tp, class _Up>
466 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Tp;
467 template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
468 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _FirstFn<_Args...>;
469 template <class _First, class...>
470 using _FirstImpl _LIBCPP_NODEBUG_TYPE = _First;
471 template <class, class _Second, class...>
472 using _SecondImpl _LIBCPP_NODEBUG_TYPE = _Second;
473 template <class _Tp = void>
474 using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp;
475 template <class _Result, class _First, class ..._Rest>
476 using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
477 template <class _Result, class _First, class ..._Rest>
478 using _AndImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>;
482 struct _MetaBase<false> {
483 template <class _Tp, class _Up>
484 using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Up;
485 template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
486 using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>;
487 template <class _Result, class ...>
488 using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result;
489 template <class _Result, class ...>
490 using _AndImpl _LIBCPP_NODEBUG_TYPE = _Result;
492 template <bool _Cond, class _Ret = void>
493 using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>;
494 template <bool _Cond, class _IfRes, class _ElseRes>
495 using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
496 template <class ..._Rest>
497 using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
498 template <class ..._Rest>
499 using _And _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _AndImpl<true_type, _Rest...>;
500 template <class _Pred>
501 struct _Not : _BoolConstant<!_Pred::value> {};
502 template <class ..._Args>
503 using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
504 template <class ..._Args>
505 using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
507 template <template <class...> class _Func, class ..._Args>
508 struct _Lazy : _Func<_Args...> {};
510 // Member detector base
512 template <template <class...> class _Templ, class ..._Args>
513 true_type __sfinae_test_impl(_FirstType<int, _Templ<_Args...> >);
514 template <template <class...> class, class ...>
515 false_type __sfinae_test_impl(...);
517 template <template <class ...> class _Templ, class ..._Args>
518 using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
521 struct __void_t { typedef void type; };
524 struct __identity { typedef _Tp type; };
526 template <class _Tp, bool>
527 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
529 template <bool _Bp, class _If, class _Then>
530 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
531 template <class _If, class _Then>
532 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
534 #if _LIBCPP_STD_VER > 11
535 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
538 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
539 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
541 #if _LIBCPP_STD_VER > 11
542 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
547 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
548 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
550 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
551 template <class _Tp, class _Up>
552 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
553 = is_same<_Tp, _Up>::value;
556 template <class _Tp, class _Up>
557 using _IsSame = _BoolConstant<
561 _VSTD::is_same<_Tp, _Up>::value
565 template <class _Tp, class _Up>
566 using _IsNotSame = _BoolConstant<
570 !_VSTD::is_same<_Tp, _Up>::value
574 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
577 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
578 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
580 addressof(_Tp& __x) _NOEXCEPT
582 return __builtin_addressof(__x);
588 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
590 addressof(_Tp& __x) _NOEXCEPT
592 return reinterpret_cast<_Tp *>(
593 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
596 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
598 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
599 // Objective-C++ Automatic Reference Counting uses qualified pointers
600 // that require special addressof() signatures. When
601 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
602 // itself is providing these definitions. Otherwise, we provide them.
604 inline _LIBCPP_INLINE_VISIBILITY
606 addressof(__strong _Tp& __x) _NOEXCEPT
611 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
613 inline _LIBCPP_INLINE_VISIBILITY
615 addressof(__weak _Tp& __x) _NOEXCEPT
622 inline _LIBCPP_INLINE_VISIBILITY
624 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
630 inline _LIBCPP_INLINE_VISIBILITY
631 __unsafe_unretained _Tp*
632 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
638 #if !defined(_LIBCPP_CXX03_LANG)
639 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
642 struct __two {char __lx[2];};
648 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
649 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
651 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
653 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v
654 = is_const<_Tp>::value;
659 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
660 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
662 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
664 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v
665 = is_volatile<_Tp>::value;
670 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
671 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
672 #if _LIBCPP_STD_VER > 11
673 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
678 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
679 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
680 #if _LIBCPP_STD_VER > 11
681 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
686 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
687 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
688 #if _LIBCPP_STD_VER > 11
689 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
694 template <class _Tp> struct __libcpp_is_void : public false_type {};
695 template <> struct __libcpp_is_void<void> : public true_type {};
697 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
698 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
700 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
702 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v
703 = is_void<_Tp>::value;
708 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
709 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
711 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
712 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
714 #if _LIBCPP_STD_VER > 11
715 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
716 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
718 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
720 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v
721 = is_null_pointer<_Tp>::value;
727 template <class _Tp> struct __libcpp_is_integral : public false_type {};
728 template <> struct __libcpp_is_integral<bool> : public true_type {};
729 template <> struct __libcpp_is_integral<char> : public true_type {};
730 template <> struct __libcpp_is_integral<signed char> : public true_type {};
731 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
732 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
733 #ifndef _LIBCPP_NO_HAS_CHAR8_T
734 template <> struct __libcpp_is_integral<char8_t> : public true_type {};
736 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
737 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
738 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
739 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
740 template <> struct __libcpp_is_integral<short> : public true_type {};
741 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
742 template <> struct __libcpp_is_integral<int> : public true_type {};
743 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
744 template <> struct __libcpp_is_integral<long> : public true_type {};
745 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
746 template <> struct __libcpp_is_integral<long long> : public true_type {};
747 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
748 #ifndef _LIBCPP_HAS_NO_INT128
749 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
750 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
753 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
754 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
756 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
758 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
759 = is_integral<_Tp>::value;
764 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
765 template <> struct __libcpp_is_floating_point<float> : public true_type {};
766 template <> struct __libcpp_is_floating_point<double> : public true_type {};
767 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
769 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
770 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
772 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
774 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v
775 = is_floating_point<_Tp>::value;
780 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
781 : public false_type {};
782 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
783 : public true_type {};
784 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
785 : public true_type {};
787 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
789 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
790 = is_array<_Tp>::value;
795 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
796 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
798 template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
799 #if defined(_LIBCPP_HAS_OBJC_ARC)
800 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
801 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
802 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
803 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
806 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
807 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
809 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
811 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
812 = is_pointer<_Tp>::value;
817 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
818 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
820 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
821 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
823 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
824 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
825 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
827 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
829 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v
830 = is_reference<_Tp>::value;
833 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
834 = is_lvalue_reference<_Tp>::value;
837 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
838 = is_rvalue_reference<_Tp>::value;
842 #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
844 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
845 : public integral_constant<bool, __is_union(_Tp)> {};
849 template <class _Tp> struct __libcpp_union : public false_type {};
850 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
851 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
855 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
857 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v
858 = is_union<_Tp>::value;
863 #if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
865 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
866 : public integral_constant<bool, __is_class(_Tp)> {};
870 namespace __is_class_imp
872 template <class _Tp> char __test(int _Tp::*);
873 template <class _Tp> __two __test(...);
876 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
877 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
881 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
883 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
884 = is_class<_Tp>::value;
889 namespace __libcpp_is_function_imp
891 struct __dummy_type {};
892 template <class _Tp> char __test(_Tp*);
893 template <class _Tp> char __test(__dummy_type);
894 template <class _Tp> __two __test(...);
895 template <class _Tp> _Tp& __source(int);
896 template <class _Tp> __dummy_type __source(...);
899 template <class _Tp, bool = is_class<_Tp>::value ||
900 is_union<_Tp>::value ||
901 is_void<_Tp>::value ||
902 is_reference<_Tp>::value ||
903 __is_nullptr_t<_Tp>::value >
904 struct __libcpp_is_function
905 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
907 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
909 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
910 : public __libcpp_is_function<_Tp> {};
912 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
914 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
915 = is_function<_Tp>::value;
918 // is_member_function_pointer
920 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
921 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
924 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
925 struct __member_pointer_traits_imp
926 { // forward declaration; specializations later
930 template <class _Tp> struct __libcpp_is_member_function_pointer
931 : public false_type {};
933 template <class _Ret, class _Class>
934 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
935 : public is_function<_Ret> {};
937 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
938 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
940 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
942 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
943 = is_member_function_pointer<_Tp>::value;
948 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
949 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
951 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
952 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
954 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
956 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v
957 = is_member_pointer<_Tp>::value;
960 // is_member_object_pointer
962 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
963 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
964 !is_member_function_pointer<_Tp>::value> {};
966 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
968 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
969 = is_member_object_pointer<_Tp>::value;
974 #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
976 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
977 : public integral_constant<bool, __is_enum(_Tp)> {};
981 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
982 : public integral_constant<bool, !is_void<_Tp>::value &&
983 !is_integral<_Tp>::value &&
984 !is_floating_point<_Tp>::value &&
985 !is_array<_Tp>::value &&
986 !is_pointer<_Tp>::value &&
987 !is_reference<_Tp>::value &&
988 !is_member_pointer<_Tp>::value &&
989 !is_union<_Tp>::value &&
990 !is_class<_Tp>::value &&
991 !is_function<_Tp>::value > {};
995 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
997 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v
998 = is_enum<_Tp>::value;
1003 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
1004 : public integral_constant<bool, is_integral<_Tp>::value ||
1005 is_floating_point<_Tp>::value> {};
1007 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1008 template <class _Tp>
1009 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
1010 = is_arithmetic<_Tp>::value;
1015 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
1016 : public integral_constant<bool, is_void<_Tp>::value ||
1017 __is_nullptr_t<_Tp>::value ||
1018 is_arithmetic<_Tp>::value> {};
1020 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1021 template <class _Tp>
1022 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
1023 = is_fundamental<_Tp>::value;
1028 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
1029 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
1030 is_member_pointer<_Tp>::value ||
1031 is_pointer<_Tp>::value ||
1032 __is_nullptr_t<_Tp>::value ||
1033 is_enum<_Tp>::value > {};
1035 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
1037 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1038 template <class _Tp>
1039 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v
1040 = is_scalar<_Tp>::value;
1045 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
1046 : public integral_constant<bool, is_scalar<_Tp>::value ||
1047 is_array<_Tp>::value ||
1048 is_union<_Tp>::value ||
1049 is_class<_Tp>::value > {};
1051 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1052 template <class _Tp>
1053 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v
1054 = is_object<_Tp>::value;
1059 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1060 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1062 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1063 template <class _Tp>
1064 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v
1065 = is_compound<_Tp>::value;
1069 // __is_referenceable [defns.referenceable]
1071 struct __is_referenceable_impl {
1072 template <class _Tp> static _Tp& __test(int);
1073 template <class _Tp> static __two __test(...);
1076 template <class _Tp>
1077 struct __is_referenceable : integral_constant<bool,
1078 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1083 template <class _Tp, bool = is_reference<_Tp>::value ||
1084 is_function<_Tp>::value ||
1085 is_const<_Tp>::value >
1086 struct __add_const {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1088 template <class _Tp>
1089 struct __add_const<_Tp, false> {typedef _LIBCPP_NODEBUG_TYPE const _Tp type;};
1091 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1092 {typedef _LIBCPP_NODEBUG_TYPE typename __add_const<_Tp>::type type;};
1094 #if _LIBCPP_STD_VER > 11
1095 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1100 template <class _Tp, bool = is_reference<_Tp>::value ||
1101 is_function<_Tp>::value ||
1102 is_volatile<_Tp>::value >
1103 struct __add_volatile {typedef _Tp type;};
1105 template <class _Tp>
1106 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1108 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1109 {typedef _LIBCPP_NODEBUG_TYPE typename __add_volatile<_Tp>::type type;};
1111 #if _LIBCPP_STD_VER > 11
1112 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1117 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1118 {typedef _LIBCPP_NODEBUG_TYPE typename add_const<typename add_volatile<_Tp>::type>::type type;};
1120 #if _LIBCPP_STD_VER > 11
1121 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1126 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1127 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1128 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1130 #if _LIBCPP_STD_VER > 11
1131 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1134 // add_lvalue_reference
1136 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1137 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; };
1139 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1140 {typedef _LIBCPP_NODEBUG_TYPE typename __add_lvalue_reference_impl<_Tp>::type type;};
1142 #if _LIBCPP_STD_VER > 11
1143 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1146 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
1147 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; };
1149 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1150 {typedef _LIBCPP_NODEBUG_TYPE typename __add_rvalue_reference_impl<_Tp>::type type;};
1152 #if _LIBCPP_STD_VER > 11
1153 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1156 template <class _Tp> _Tp&& __declval(int);
1157 template <class _Tp> _Tp __declval(long);
1159 template <class _Tp>
1160 decltype(_VSTD::__declval<_Tp>(0))
1161 declval() _NOEXCEPT;
1165 template <class _Tp>
1167 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1170 template <class _Tp>
1171 struct __unconstref {
1172 typedef _LIBCPP_NODEBUG_TYPE typename remove_const<typename remove_reference<_Tp>::type>::type type;
1175 #ifndef _LIBCPP_CXX03_LANG
1176 template <class _Tp>
1177 using __uncvref_t _LIBCPP_NODEBUG_TYPE = typename __uncvref<_Tp>::type;
1180 // __is_same_uncvref
1182 template <class _Tp, class _Up>
1183 struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
1184 typename __uncvref<_Up>::type> {};
1186 #if _LIBCPP_STD_VER > 17
1187 // remove_cvref - same as __uncvref
1188 template <class _Tp>
1189 struct remove_cvref : public __uncvref<_Tp> {};
1191 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1202 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1203 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1204 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1205 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1206 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1208 #if _LIBCPP_STD_VER > 11
1209 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1214 template <class _Tp,
1215 bool = __is_referenceable<_Tp>::value ||
1216 _IsSame<typename remove_cv<_Tp>::type, void>::value>
1217 struct __add_pointer_impl
1218 {typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type* type;};
1219 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1220 {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
1222 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1223 {typedef _LIBCPP_NODEBUG_TYPE typename __add_pointer_impl<_Tp>::type type;};
1225 #if _LIBCPP_STD_VER > 11
1226 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1230 #if _LIBCPP_STD_VER > 17
1231 template<class _Tp> struct type_identity { typedef _Tp type; };
1232 template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
1237 template <class _Tp, bool = is_integral<_Tp>::value>
1238 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1240 template <class _Tp>
1241 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1243 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1244 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1246 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1248 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1250 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1251 template <class _Tp>
1252 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
1253 = is_signed<_Tp>::value;
1258 template <class _Tp, bool = is_integral<_Tp>::value>
1259 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1261 template <class _Tp>
1262 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1264 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1265 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1267 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1269 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1271 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1272 template <class _Tp>
1273 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v
1274 = is_unsigned<_Tp>::value;
1279 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1280 : public integral_constant<size_t, 0> {};
1281 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1282 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1283 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1284 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1286 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1287 template <class _Tp>
1288 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v
1294 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1295 : public integral_constant<size_t, 0> {};
1296 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1297 : public integral_constant<size_t, 0> {};
1298 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1299 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1300 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1301 : public integral_constant<size_t, _Np> {};
1302 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1303 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1305 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1306 template <class _Tp, unsigned _Ip = 0>
1307 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v
1308 = extent<_Tp, _Ip>::value;
1313 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1314 {typedef _Tp type;};
1315 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1316 {typedef _Tp type;};
1317 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1318 {typedef _Tp type;};
1320 #if _LIBCPP_STD_VER > 11
1321 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1324 // remove_all_extents
1326 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1327 {typedef _Tp type;};
1328 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1329 {typedef typename remove_all_extents<_Tp>::type type;};
1330 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1331 {typedef typename remove_all_extents<_Tp>::type type;};
1333 #if _LIBCPP_STD_VER > 11
1334 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1337 #if _LIBCPP_STD_VER > 17
1340 template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
1341 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
1343 template <class _Tp>
1344 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1345 bool is_bounded_array_v = is_bounded_array<_Tp>::value;
1347 // is_unbounded_array
1349 template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
1350 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
1352 template <class _Tp>
1353 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR
1354 bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
1359 template <class _Up, bool>
1361 typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<_Up>::type type;
1364 template <class _Up>
1365 struct __decay<_Up, true> {
1367 typedef _LIBCPP_NODEBUG_TYPE typename conditional
1369 is_array<_Up>::value,
1370 typename remove_extent<_Up>::type*,
1371 typename conditional
1373 is_function<_Up>::value,
1374 typename add_pointer<_Up>::type,
1375 typename remove_cv<_Up>::type
1380 template <class _Tp>
1381 struct _LIBCPP_TEMPLATE_VIS decay
1384 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
1386 typedef _LIBCPP_NODEBUG_TYPE typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1389 #if _LIBCPP_STD_VER > 11
1390 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1395 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1396 : public integral_constant<bool, __is_abstract(_Tp)> {};
1398 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1399 template <class _Tp>
1400 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v
1401 = is_abstract<_Tp>::value;
1406 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1407 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1409 #if _LIBCPP_STD_VER > 11
1410 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1411 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1414 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1415 template <class _Tp>
1416 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v
1417 = is_final<_Tp>::value;
1421 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1423 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1424 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1426 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1427 template <class _Tp>
1428 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v
1429 = is_aggregate<_Tp>::value;
1432 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1436 template <class _Bp, class _Dp>
1437 struct _LIBCPP_TEMPLATE_VIS is_base_of
1438 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1440 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1441 template <class _Bp, class _Dp>
1442 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
1443 = is_base_of<_Bp, _Dp>::value;
1448 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1450 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1451 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1452 !is_abstract<_T2>::value> {};
1454 #else // __has_feature(is_convertible_to)
1456 namespace __is_convertible_imp
1458 template <class _Tp> void __test_convert(_Tp);
1460 template <class _From, class _To, class = void>
1461 struct __is_convertible_test : public false_type {};
1463 template <class _From, class _To>
1464 struct __is_convertible_test<_From, _To,
1465 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1468 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1469 bool _IsFunction = is_function<_Tp>::value,
1470 bool _IsVoid = is_void<_Tp>::value>
1471 struct __is_array_function_or_void {enum {value = 0};};
1472 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1473 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1474 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1477 template <class _Tp,
1478 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1479 struct __is_convertible_check
1481 static const size_t __v = 0;
1484 template <class _Tp>
1485 struct __is_convertible_check<_Tp, 0>
1487 static const size_t __v = sizeof(_Tp);
1490 template <class _T1, class _T2,
1491 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1492 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1493 struct __is_convertible
1494 : public integral_constant<bool,
1495 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1499 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1500 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1501 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1502 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1504 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1505 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1506 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1507 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1509 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1510 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1511 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1512 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1514 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1515 : public __is_convertible<_T1, _T2>
1517 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1518 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1521 #endif // __has_feature(is_convertible_to)
1523 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1524 template <class _From, class _To>
1525 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v
1526 = is_convertible<_From, _To>::value;
1529 // is_nothrow_convertible
1531 #if _LIBCPP_STD_VER > 17
1533 template <typename _Tp>
1534 static void __test_noexcept(_Tp) noexcept;
1536 template<typename _Fm, typename _To>
1537 static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))>
1538 __is_nothrow_convertible_test();
1540 template <typename _Fm, typename _To>
1541 struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
1544 template <typename _Fm, typename _To>
1545 struct is_nothrow_convertible : _Or<
1546 _And<is_void<_To>, is_void<_Fm>>,
1547 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
1550 template <typename _Fm, typename _To>
1551 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
1553 #endif // _LIBCPP_STD_VER > 17
1557 #if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
1559 template <class _Tp>
1560 struct _LIBCPP_TEMPLATE_VIS is_empty
1561 : public integral_constant<bool, __is_empty(_Tp)> {};
1563 #else // __has_feature(is_empty)
1565 template <class _Tp>
1577 template <class _Tp, bool = is_class<_Tp>::value>
1578 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1580 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1582 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1584 #endif // __has_feature(is_empty)
1586 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1587 template <class _Tp>
1588 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v
1589 = is_empty<_Tp>::value;
1594 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1596 template <class _Tp>
1597 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1598 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1602 template<typename _Tp> char &__is_polymorphic_impl(
1603 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1605 template<typename _Tp> __two &__is_polymorphic_impl(...);
1607 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1608 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1610 #endif // __has_feature(is_polymorphic)
1612 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1613 template <class _Tp>
1614 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v
1615 = is_polymorphic<_Tp>::value;
1618 // has_virtual_destructor
1620 #if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
1622 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1623 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1627 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1628 : public false_type {};
1632 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1633 template <class _Tp>
1634 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1635 = has_virtual_destructor<_Tp>::value;
1638 // has_unique_object_representations
1640 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
1642 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
1643 : public integral_constant<bool,
1644 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
1646 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1647 template <class _Tp>
1648 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v
1649 = has_unique_object_representations<_Tp>::value;
1656 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1657 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
1659 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1660 template <class _Tp>
1661 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v
1662 = alignment_of<_Tp>::value;
1667 template <class _Hp, class _Tp>
1676 #ifndef _LIBCPP_CXX03_LANG
1678 __nat(const __nat&) = delete;
1679 __nat& operator=(const __nat&) = delete;
1684 template <class _Tp>
1687 static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
1691 struct __struct_double {long double __lx;};
1692 struct __struct_double4 {double __lx[4];};
1695 __type_list<__align_type<unsigned char>,
1696 __type_list<__align_type<unsigned short>,
1697 __type_list<__align_type<unsigned int>,
1698 __type_list<__align_type<unsigned long>,
1699 __type_list<__align_type<unsigned long long>,
1700 __type_list<__align_type<double>,
1701 __type_list<__align_type<long double>,
1702 __type_list<__align_type<__struct_double>,
1703 __type_list<__align_type<__struct_double4>,
1704 __type_list<__align_type<int*>,
1706 > > > > > > > > > > __all_types;
1708 template <size_t _Align>
1709 struct _ALIGNAS(_Align) __fallback_overaligned {};
1711 template <class _TL, size_t _Align> struct __find_pod;
1713 template <class _Hp, size_t _Align>
1714 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1716 typedef typename conditional<
1717 _Align == _Hp::value,
1719 __fallback_overaligned<_Align>
1723 template <class _Hp, class _Tp, size_t _Align>
1724 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1726 typedef typename conditional<
1727 _Align == _Hp::value,
1729 typename __find_pod<_Tp, _Align>::type
1733 template <class _TL, size_t _Len> struct __find_max_align;
1735 template <class _Hp, size_t _Len>
1736 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1738 template <size_t _Len, size_t _A1, size_t _A2>
1739 struct __select_align
1742 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1743 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1745 static const size_t value = _Len < __max ? __min : __max;
1748 template <class _Hp, class _Tp, size_t _Len>
1749 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1750 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1752 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1753 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1755 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1759 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1763 #if _LIBCPP_STD_VER > 11
1764 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1765 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1768 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1769 template <size_t _Len>\
1770 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1772 struct _ALIGNAS(n) type\
1774 unsigned char __lx[(_Len + n - 1)/n * n];\
1778 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1779 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1780 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1781 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1782 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1783 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1784 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1785 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1786 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1787 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1788 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1789 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1790 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1791 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1792 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1793 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1794 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1795 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1797 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1802 template <size_t _I0, size_t ..._In>
1803 struct __static_max;
1805 template <size_t _I0>
1806 struct __static_max<_I0>
1808 static const size_t value = _I0;
1811 template <size_t _I0, size_t _I1, size_t ..._In>
1812 struct __static_max<_I0, _I1, _In...>
1814 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1815 __static_max<_I1, _In...>::value;
1818 template <size_t _Len, class _Type0, class ..._Types>
1819 struct aligned_union
1821 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
1822 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
1823 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1824 sizeof(_Types)...>::value;
1825 typedef typename aligned_storage<__len, alignment_value>::type type;
1828 #if _LIBCPP_STD_VER > 11
1829 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1832 template <class _Tp>
1833 struct __numeric_type
1835 static void __test(...);
1836 static float __test(float);
1837 static double __test(char);
1838 static double __test(int);
1839 static double __test(unsigned);
1840 static double __test(long);
1841 static double __test(unsigned long);
1842 static double __test(long long);
1843 static double __test(unsigned long long);
1844 static double __test(double);
1845 static long double __test(long double);
1847 typedef decltype(__test(declval<_Tp>())) type;
1848 static const bool value = _IsNotSame<type, void>::value;
1852 struct __numeric_type<void>
1854 static const bool value = true;
1859 template <class _A1, class _A2 = void, class _A3 = void,
1860 bool = __numeric_type<_A1>::value &&
1861 __numeric_type<_A2>::value &&
1862 __numeric_type<_A3>::value>
1866 static const bool value = false;
1869 template <class _A1, class _A2, class _A3>
1870 class __promote_imp<_A1, _A2, _A3, true>
1873 typedef typename __promote_imp<_A1>::type __type1;
1874 typedef typename __promote_imp<_A2>::type __type2;
1875 typedef typename __promote_imp<_A3>::type __type3;
1877 typedef decltype(__type1() + __type2() + __type3()) type;
1878 static const bool value = true;
1881 template <class _A1, class _A2>
1882 class __promote_imp<_A1, _A2, void, true>
1885 typedef typename __promote_imp<_A1>::type __type1;
1886 typedef typename __promote_imp<_A2>::type __type2;
1888 typedef decltype(__type1() + __type2()) type;
1889 static const bool value = true;
1892 template <class _A1>
1893 class __promote_imp<_A1, void, void, true>
1896 typedef typename __numeric_type<_A1>::type type;
1897 static const bool value = true;
1900 template <class _A1, class _A2 = void, class _A3 = void>
1901 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1903 // make_signed / make_unsigned
1906 __type_list<signed char,
1907 __type_list<signed short,
1908 __type_list<signed int,
1909 __type_list<signed long,
1910 __type_list<signed long long,
1911 #ifndef _LIBCPP_HAS_NO_INT128
1912 __type_list<__int128_t,
1915 #ifndef _LIBCPP_HAS_NO_INT128
1918 > > > > > __signed_types;
1921 __type_list<unsigned char,
1922 __type_list<unsigned short,
1923 __type_list<unsigned int,
1924 __type_list<unsigned long,
1925 __type_list<unsigned long long,
1926 #ifndef _LIBCPP_HAS_NO_INT128
1927 __type_list<__uint128_t,
1930 #ifndef _LIBCPP_HAS_NO_INT128
1933 > > > > > __unsigned_types;
1935 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1937 template <class _Hp, class _Tp, size_t _Size>
1938 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1940 typedef _LIBCPP_NODEBUG_TYPE _Hp type;
1943 template <class _Hp, class _Tp, size_t _Size>
1944 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1946 typedef _LIBCPP_NODEBUG_TYPE typename __find_first<_Tp, _Size>::type type;
1949 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1950 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1953 typedef _LIBCPP_NODEBUG_TYPE _Up type;
1956 template <class _Tp, class _Up>
1957 struct __apply_cv<_Tp, _Up, true, false>
1959 typedef _LIBCPP_NODEBUG_TYPE const _Up type;
1962 template <class _Tp, class _Up>
1963 struct __apply_cv<_Tp, _Up, false, true>
1965 typedef volatile _Up type;
1968 template <class _Tp, class _Up>
1969 struct __apply_cv<_Tp, _Up, true, true>
1971 typedef const volatile _Up type;
1974 template <class _Tp, class _Up>
1975 struct __apply_cv<_Tp&, _Up, false, false>
1980 template <class _Tp, class _Up>
1981 struct __apply_cv<_Tp&, _Up, true, false>
1983 typedef const _Up& type;
1986 template <class _Tp, class _Up>
1987 struct __apply_cv<_Tp&, _Up, false, true>
1989 typedef volatile _Up& type;
1992 template <class _Tp, class _Up>
1993 struct __apply_cv<_Tp&, _Up, true, true>
1995 typedef const volatile _Up& type;
1998 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1999 struct __make_signed {};
2001 template <class _Tp>
2002 struct __make_signed<_Tp, true>
2004 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
2007 template <> struct __make_signed<bool, true> {};
2008 template <> struct __make_signed< signed short, true> {typedef short type;};
2009 template <> struct __make_signed<unsigned short, true> {typedef short type;};
2010 template <> struct __make_signed< signed int, true> {typedef int type;};
2011 template <> struct __make_signed<unsigned int, true> {typedef int type;};
2012 template <> struct __make_signed< signed long, true> {typedef long type;};
2013 template <> struct __make_signed<unsigned long, true> {typedef long type;};
2014 template <> struct __make_signed< signed long long, true> {typedef long long type;};
2015 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
2016 #ifndef _LIBCPP_HAS_NO_INT128
2017 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
2018 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
2021 template <class _Tp>
2022 struct _LIBCPP_TEMPLATE_VIS make_signed
2024 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
2027 #if _LIBCPP_STD_VER > 11
2028 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
2031 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
2032 struct __make_unsigned {};
2034 template <class _Tp>
2035 struct __make_unsigned<_Tp, true>
2037 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
2040 template <> struct __make_unsigned<bool, true> {};
2041 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
2042 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
2043 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
2044 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
2045 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
2046 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
2047 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
2048 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
2049 #ifndef _LIBCPP_HAS_NO_INT128
2050 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
2051 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
2054 template <class _Tp>
2055 struct _LIBCPP_TEMPLATE_VIS make_unsigned
2057 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
2060 #if _LIBCPP_STD_VER > 11
2061 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
2064 template <class _Tp, class _Up, class = void>
2065 struct __common_type2_imp {};
2067 template <class _Tp, class _Up>
2068 struct __common_type2_imp<_Tp, _Up,
2069 typename __void_t<decltype(
2070 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2073 typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype(
2074 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2078 template <class, class = void>
2079 struct __common_type_impl {};
2081 // Clang provides variadic templates in C++03 as an extension.
2082 #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
2083 # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
2084 template <class... Tp>
2085 struct __common_types;
2086 template <class... _Tp>
2087 struct _LIBCPP_TEMPLATE_VIS common_type;
2089 # define _LIBCPP_OPTIONAL_PACK(...)
2091 template <class _Tp, class _Up, class = __no_arg>
2092 struct __common_types;
2093 template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
2094 class _Unused = __no_arg>
2095 struct common_type {
2096 static_assert(sizeof(_Unused) == 0,
2097 "common_type accepts at most 3 arguments in C++03");
2099 #endif // _LIBCPP_CXX03_LANG
2101 template <class _Tp, class _Up>
2102 struct __common_type_impl<
2103 __common_types<_Tp, _Up>,
2104 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2106 typedef typename common_type<_Tp, _Up>::type type;
2109 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2110 struct __common_type_impl<
2111 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
2112 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2113 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
2114 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
2117 // bullet 1 - sizeof...(Tp) == 0
2120 struct _LIBCPP_TEMPLATE_VIS common_type<> {};
2122 // bullet 2 - sizeof...(Tp) == 1
2124 template <class _Tp>
2125 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2126 : public common_type<_Tp, _Tp> {};
2128 // bullet 3 - sizeof...(Tp) == 2
2130 template <class _Tp, class _Up>
2131 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2133 _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
2134 __common_type2_imp<_Tp, _Up>,
2135 common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
2139 // bullet 4 - sizeof...(Tp) > 2
2141 template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
2142 struct _LIBCPP_TEMPLATE_VIS
2143 common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
2144 : __common_type_impl<
2145 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
2147 #undef _LIBCPP_OPTIONAL_PACK
2149 #if _LIBCPP_STD_VER > 11
2150 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2155 template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
2157 template <class _Tp, class _Arg>
2158 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2159 __is_assignable_test(int);
2161 template <class, class>
2162 false_type __is_assignable_test(...);
2165 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2166 struct __is_assignable_imp
2167 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2169 template <class _Tp, class _Arg>
2170 struct __is_assignable_imp<_Tp, _Arg, true>
2175 template <class _Tp, class _Arg>
2176 struct is_assignable
2177 : public __is_assignable_imp<_Tp, _Arg> {};
2179 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2180 template <class _Tp, class _Arg>
2181 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
2182 = is_assignable<_Tp, _Arg>::value;
2185 // is_copy_assignable
2187 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2188 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2189 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2191 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2192 template <class _Tp>
2193 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2194 = is_copy_assignable<_Tp>::value;
2197 // is_move_assignable
2199 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2200 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2201 typename add_rvalue_reference<_Tp>::type> {};
2203 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2204 template <class _Tp>
2205 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v
2206 = is_move_assignable<_Tp>::value;
2211 // if it's a reference, return true
2212 // if it's a function, return false
2213 // if it's void, return false
2214 // if it's an array of unknown bound, return false
2215 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2216 // where _Up is remove_all_extents<_Tp>::type
2219 struct __is_destructible_apply { typedef int type; };
2221 template <typename _Tp>
2222 struct __is_destructor_wellformed {
2223 template <typename _Tp1>
2224 static char __test (
2225 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2228 template <typename _Tp1>
2229 static __two __test (...);
2231 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2234 template <class _Tp, bool>
2235 struct __destructible_imp;
2237 template <class _Tp>
2238 struct __destructible_imp<_Tp, false>
2239 : public _VSTD::integral_constant<bool,
2240 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2242 template <class _Tp>
2243 struct __destructible_imp<_Tp, true>
2244 : public _VSTD::true_type {};
2246 template <class _Tp, bool>
2247 struct __destructible_false;
2249 template <class _Tp>
2250 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2252 template <class _Tp>
2253 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2255 template <class _Tp>
2256 struct is_destructible
2257 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2259 template <class _Tp>
2260 struct is_destructible<_Tp[]>
2261 : public _VSTD::false_type {};
2264 struct is_destructible<void>
2265 : public _VSTD::false_type {};
2267 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2268 template <class _Tp>
2269 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
2270 = is_destructible<_Tp>::value;
2275 template <class _Tp>
2276 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2277 typename remove_reference<_Tp>::type&&
2278 move(_Tp&& __t) _NOEXCEPT
2280 typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
2281 return static_cast<_Up&&>(__t);
2284 template <class _Tp>
2285 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2287 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2289 return static_cast<_Tp&&>(__t);
2292 template <class _Tp>
2293 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2295 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2297 static_assert(!is_lvalue_reference<_Tp>::value,
2298 "can not forward an rvalue as an lvalue");
2299 return static_cast<_Tp&&>(__t);
2302 template <class _Tp>
2303 inline _LIBCPP_INLINE_VISIBILITY
2304 typename decay<_Tp>::type
2305 __decay_copy(_Tp&& __t)
2307 return _VSTD::forward<_Tp>(__t);
2310 template <class _Rp, class _Class, class ..._Param>
2311 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2313 typedef _Class _ClassType;
2314 typedef _Rp _ReturnType;
2315 typedef _Rp (_FnType) (_Param...);
2318 template <class _Rp, class _Class, class ..._Param>
2319 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2321 typedef _Class _ClassType;
2322 typedef _Rp _ReturnType;
2323 typedef _Rp (_FnType) (_Param..., ...);
2326 template <class _Rp, class _Class, class ..._Param>
2327 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2329 typedef _Class const _ClassType;
2330 typedef _Rp _ReturnType;
2331 typedef _Rp (_FnType) (_Param...);
2334 template <class _Rp, class _Class, class ..._Param>
2335 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2337 typedef _Class const _ClassType;
2338 typedef _Rp _ReturnType;
2339 typedef _Rp (_FnType) (_Param..., ...);
2342 template <class _Rp, class _Class, class ..._Param>
2343 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2345 typedef _Class volatile _ClassType;
2346 typedef _Rp _ReturnType;
2347 typedef _Rp (_FnType) (_Param...);
2350 template <class _Rp, class _Class, class ..._Param>
2351 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2353 typedef _Class volatile _ClassType;
2354 typedef _Rp _ReturnType;
2355 typedef _Rp (_FnType) (_Param..., ...);
2358 template <class _Rp, class _Class, class ..._Param>
2359 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2361 typedef _Class const volatile _ClassType;
2362 typedef _Rp _ReturnType;
2363 typedef _Rp (_FnType) (_Param...);
2366 template <class _Rp, class _Class, class ..._Param>
2367 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2369 typedef _Class const volatile _ClassType;
2370 typedef _Rp _ReturnType;
2371 typedef _Rp (_FnType) (_Param..., ...);
2374 #if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2376 template <class _Rp, class _Class, class ..._Param>
2377 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2379 typedef _Class& _ClassType;
2380 typedef _Rp _ReturnType;
2381 typedef _Rp (_FnType) (_Param...);
2384 template <class _Rp, class _Class, class ..._Param>
2385 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2387 typedef _Class& _ClassType;
2388 typedef _Rp _ReturnType;
2389 typedef _Rp (_FnType) (_Param..., ...);
2392 template <class _Rp, class _Class, class ..._Param>
2393 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2395 typedef _Class const& _ClassType;
2396 typedef _Rp _ReturnType;
2397 typedef _Rp (_FnType) (_Param...);
2400 template <class _Rp, class _Class, class ..._Param>
2401 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2403 typedef _Class const& _ClassType;
2404 typedef _Rp _ReturnType;
2405 typedef _Rp (_FnType) (_Param..., ...);
2408 template <class _Rp, class _Class, class ..._Param>
2409 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2411 typedef _Class volatile& _ClassType;
2412 typedef _Rp _ReturnType;
2413 typedef _Rp (_FnType) (_Param...);
2416 template <class _Rp, class _Class, class ..._Param>
2417 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2419 typedef _Class volatile& _ClassType;
2420 typedef _Rp _ReturnType;
2421 typedef _Rp (_FnType) (_Param..., ...);
2424 template <class _Rp, class _Class, class ..._Param>
2425 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2427 typedef _Class const volatile& _ClassType;
2428 typedef _Rp _ReturnType;
2429 typedef _Rp (_FnType) (_Param...);
2432 template <class _Rp, class _Class, class ..._Param>
2433 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2435 typedef _Class const volatile& _ClassType;
2436 typedef _Rp _ReturnType;
2437 typedef _Rp (_FnType) (_Param..., ...);
2440 template <class _Rp, class _Class, class ..._Param>
2441 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2443 typedef _Class&& _ClassType;
2444 typedef _Rp _ReturnType;
2445 typedef _Rp (_FnType) (_Param...);
2448 template <class _Rp, class _Class, class ..._Param>
2449 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2451 typedef _Class&& _ClassType;
2452 typedef _Rp _ReturnType;
2453 typedef _Rp (_FnType) (_Param..., ...);
2456 template <class _Rp, class _Class, class ..._Param>
2457 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2459 typedef _Class const&& _ClassType;
2460 typedef _Rp _ReturnType;
2461 typedef _Rp (_FnType) (_Param...);
2464 template <class _Rp, class _Class, class ..._Param>
2465 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2467 typedef _Class const&& _ClassType;
2468 typedef _Rp _ReturnType;
2469 typedef _Rp (_FnType) (_Param..., ...);
2472 template <class _Rp, class _Class, class ..._Param>
2473 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2475 typedef _Class volatile&& _ClassType;
2476 typedef _Rp _ReturnType;
2477 typedef _Rp (_FnType) (_Param...);
2480 template <class _Rp, class _Class, class ..._Param>
2481 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2483 typedef _Class volatile&& _ClassType;
2484 typedef _Rp _ReturnType;
2485 typedef _Rp (_FnType) (_Param..., ...);
2488 template <class _Rp, class _Class, class ..._Param>
2489 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2491 typedef _Class const volatile&& _ClassType;
2492 typedef _Rp _ReturnType;
2493 typedef _Rp (_FnType) (_Param...);
2496 template <class _Rp, class _Class, class ..._Param>
2497 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2499 typedef _Class const volatile&& _ClassType;
2500 typedef _Rp _ReturnType;
2501 typedef _Rp (_FnType) (_Param..., ...);
2504 #endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
2507 template <class _Rp, class _Class>
2508 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2510 typedef _Class _ClassType;
2511 typedef _Rp _ReturnType;
2514 template <class _MP>
2515 struct __member_pointer_traits
2516 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2517 is_member_function_pointer<_MP>::value,
2518 is_member_object_pointer<_MP>::value>
2520 // typedef ... _ClassType;
2521 // typedef ... _ReturnType;
2522 // typedef ... _FnType;
2526 template <class _DecayedFp>
2527 struct __member_pointer_class_type {};
2529 template <class _Ret, class _ClassType>
2530 struct __member_pointer_class_type<_Ret _ClassType::*> {
2531 typedef _ClassType type;
2536 template <class _Callable> class result_of;
2538 #ifdef _LIBCPP_HAS_NO_VARIADICS
2540 template <class _Fn, bool, bool>
2545 template <class _Fn>
2546 class __result_of<_Fn(), true, false>
2549 typedef decltype(declval<_Fn>()()) type;
2552 template <class _Fn, class _A0>
2553 class __result_of<_Fn(_A0), true, false>
2556 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2559 template <class _Fn, class _A0, class _A1>
2560 class __result_of<_Fn(_A0, _A1), true, false>
2563 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2566 template <class _Fn, class _A0, class _A1, class _A2>
2567 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2570 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2573 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2574 struct __result_of_mp;
2576 // member function pointer
2578 template <class _MP, class _Tp>
2579 struct __result_of_mp<_MP, _Tp, true>
2580 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2584 // member data pointer
2586 template <class _MP, class _Tp, bool>
2587 struct __result_of_mdp;
2589 template <class _Rp, class _Class, class _Tp>
2590 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2592 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2595 template <class _Rp, class _Class, class _Tp>
2596 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2598 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2601 template <class _Rp, class _Class, class _Tp>
2602 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2603 : public __result_of_mdp<_Rp _Class::*, _Tp,
2604 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2610 template <class _Fn, class _Tp>
2611 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2612 : public __result_of_mp<typename remove_reference<_Fn>::type,
2614 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2618 template <class _Fn, class _Tp, class _A0>
2619 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2620 : public __result_of_mp<typename remove_reference<_Fn>::type,
2622 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2626 template <class _Fn, class _Tp, class _A0, class _A1>
2627 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2628 : public __result_of_mp<typename remove_reference<_Fn>::type,
2630 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2634 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2635 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2636 : public __result_of_mp<typename remove_reference<_Fn>::type,
2638 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2644 template <class _Fn>
2645 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2646 : public __result_of<_Fn(),
2647 is_class<typename remove_reference<_Fn>::type>::value ||
2648 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2649 is_member_pointer<typename remove_reference<_Fn>::type>::value
2654 template <class _Fn, class _A0>
2655 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2656 : public __result_of<_Fn(_A0),
2657 is_class<typename remove_reference<_Fn>::type>::value ||
2658 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2659 is_member_pointer<typename remove_reference<_Fn>::type>::value
2664 template <class _Fn, class _A0, class _A1>
2665 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2666 : public __result_of<_Fn(_A0, _A1),
2667 is_class<typename remove_reference<_Fn>::type>::value ||
2668 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2669 is_member_pointer<typename remove_reference<_Fn>::type>::value
2674 template <class _Fn, class _A0, class _A1, class _A2>
2675 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
2676 : public __result_of<_Fn(_A0, _A1, _A2),
2677 is_class<typename remove_reference<_Fn>::type>::value ||
2678 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2679 is_member_pointer<typename remove_reference<_Fn>::type>::value
2684 #endif // _LIBCPP_HAS_NO_VARIADICS
2686 // template <class T, class... Args> struct is_constructible;
2688 namespace __is_construct
2693 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
2694 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
2696 template <class _Tp, class... _Args>
2697 struct __libcpp_is_constructible;
2699 template <class _To, class _From>
2700 struct __is_invalid_base_to_derived_cast {
2701 static_assert(is_reference<_To>::value, "Wrong specialization");
2702 using _RawFrom = __uncvref_t<_From>;
2703 using _RawTo = __uncvref_t<_To>;
2704 static const bool value = _And<
2705 _IsNotSame<_RawFrom, _RawTo>,
2706 is_base_of<_RawFrom, _RawTo>,
2707 _Not<__libcpp_is_constructible<_RawTo, _From>>
2711 template <class _To, class _From>
2712 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
2713 static_assert(is_reference<_To>::value, "Wrong specialization");
2716 template <class _ToRef, class _FromRef>
2717 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
2718 using _RawFrom = __uncvref_t<_FromRef>;
2719 using _RawTo = __uncvref_t<_ToRef>;
2720 static const bool value = _And<
2721 _Not<is_function<_RawTo>>,
2723 _IsSame<_RawFrom, _RawTo>,
2724 is_base_of<_RawTo, _RawFrom>>
2728 struct __is_constructible_helper
2730 template <class _To>
2731 static void __eat(_To);
2733 // This overload is needed to work around a Clang bug that disallows
2734 // static_cast<T&&>(e) for non-reference-compatible types.
2735 // Example: static_cast<int&&>(declval<double>());
2736 // NOTE: The static_cast implementation below is required to support
2737 // classes with explicit conversion operators.
2738 template <class _To, class _From,
2739 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
2740 static true_type __test_cast(int);
2742 template <class _To, class _From,
2743 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
2744 static integral_constant<bool,
2745 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
2746 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
2747 > __test_cast(long);
2749 template <class, class>
2750 static false_type __test_cast(...);
2752 template <class _Tp, class ..._Args,
2753 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
2754 static true_type __test_nary(int);
2755 template <class _Tp, class...>
2756 static false_type __test_nary(...);
2758 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
2759 static is_destructible<_Tp> __test_unary(int);
2760 template <class, class>
2761 static false_type __test_unary(...);
2764 template <class _Tp, bool = is_void<_Tp>::value>
2765 struct __is_default_constructible
2766 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
2769 template <class _Tp>
2770 struct __is_default_constructible<_Tp, true> : false_type {};
2772 template <class _Tp>
2773 struct __is_default_constructible<_Tp[], false> : false_type {};
2775 template <class _Tp, size_t _Nx>
2776 struct __is_default_constructible<_Tp[_Nx], false>
2777 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
2779 template <class _Tp, class... _Args>
2780 struct __libcpp_is_constructible
2782 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
2783 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
2787 template <class _Tp>
2788 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
2790 template <class _Tp, class _A0>
2791 struct __libcpp_is_constructible<_Tp, _A0>
2792 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
2795 template <class _Tp, class _A0>
2796 struct __libcpp_is_constructible<_Tp&, _A0>
2797 : public decltype(__is_constructible_helper::
2798 __test_cast<_Tp&, _A0>(0))
2801 template <class _Tp, class _A0>
2802 struct __libcpp_is_constructible<_Tp&&, _A0>
2803 : public decltype(__is_constructible_helper::
2804 __test_cast<_Tp&&, _A0>(0))
2809 #if __has_feature(is_constructible)
2810 template <class _Tp, class ..._Args>
2811 struct _LIBCPP_TEMPLATE_VIS is_constructible
2812 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
2815 template <class _Tp, class... _Args>
2816 struct _LIBCPP_TEMPLATE_VIS is_constructible
2817 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
2820 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2821 template <class _Tp, class ..._Args>
2822 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v
2823 = is_constructible<_Tp, _Args...>::value;
2826 // is_default_constructible
2828 template <class _Tp>
2829 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
2830 : public is_constructible<_Tp>
2833 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2834 template <class _Tp>
2835 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
2836 = is_default_constructible<_Tp>::value;
2839 // is_copy_constructible
2841 template <class _Tp>
2842 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
2843 : public is_constructible<_Tp,
2844 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2846 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2847 template <class _Tp>
2848 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v
2849 = is_copy_constructible<_Tp>::value;
2852 // is_move_constructible
2854 template <class _Tp>
2855 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
2856 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2859 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2860 template <class _Tp>
2861 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v
2862 = is_move_constructible<_Tp>::value;
2865 // is_trivially_constructible
2867 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
2869 template <class _Tp, class... _Args>
2870 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2871 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
2875 #else // !__has_feature(is_trivially_constructible)
2877 template <class _Tp, class... _Args>
2878 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2883 template <class _Tp>
2884 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
2885 #if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC)
2886 : integral_constant<bool, __has_trivial_constructor(_Tp)>
2888 : integral_constant<bool, is_scalar<_Tp>::value>
2893 template <class _Tp>
2894 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
2895 : integral_constant<bool, is_scalar<_Tp>::value>
2899 template <class _Tp>
2900 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
2901 : integral_constant<bool, is_scalar<_Tp>::value>
2905 template <class _Tp>
2906 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
2907 : integral_constant<bool, is_scalar<_Tp>::value>
2911 #endif // !__has_feature(is_trivially_constructible)
2914 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2915 template <class _Tp, class... _Args>
2916 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
2917 = is_trivially_constructible<_Tp, _Args...>::value;
2920 // is_trivially_default_constructible
2922 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
2923 : public is_trivially_constructible<_Tp>
2926 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2927 template <class _Tp>
2928 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
2929 = is_trivially_default_constructible<_Tp>::value;
2932 // is_trivially_copy_constructible
2934 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
2935 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
2938 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2939 template <class _Tp>
2940 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
2941 = is_trivially_copy_constructible<_Tp>::value;
2944 // is_trivially_move_constructible
2946 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
2947 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2950 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2951 template <class _Tp>
2952 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
2953 = is_trivially_move_constructible<_Tp>::value;
2956 // is_trivially_assignable
2958 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
2960 template <class _Tp, class _Arg>
2961 struct is_trivially_assignable
2962 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
2966 #else // !__has_feature(is_trivially_assignable)
2968 template <class _Tp, class _Arg>
2969 struct is_trivially_assignable
2970 : public false_type {};
2972 template <class _Tp>
2973 struct is_trivially_assignable<_Tp&, _Tp>
2974 : integral_constant<bool, is_scalar<_Tp>::value> {};
2976 template <class _Tp>
2977 struct is_trivially_assignable<_Tp&, _Tp&>
2978 : integral_constant<bool, is_scalar<_Tp>::value> {};
2980 template <class _Tp>
2981 struct is_trivially_assignable<_Tp&, const _Tp&>
2982 : integral_constant<bool, is_scalar<_Tp>::value> {};
2984 template <class _Tp>
2985 struct is_trivially_assignable<_Tp&, _Tp&&>
2986 : integral_constant<bool, is_scalar<_Tp>::value> {};
2988 #endif // !__has_feature(is_trivially_assignable)
2990 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2991 template <class _Tp, class _Arg>
2992 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
2993 = is_trivially_assignable<_Tp, _Arg>::value;
2996 // is_trivially_copy_assignable
2998 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
2999 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3000 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3002 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3003 template <class _Tp>
3004 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3005 = is_trivially_copy_assignable<_Tp>::value;
3008 // is_trivially_move_assignable
3010 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3011 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3012 typename add_rvalue_reference<_Tp>::type>
3015 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3016 template <class _Tp>
3017 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3018 = is_trivially_move_assignable<_Tp>::value;
3021 // is_trivially_destructible
3023 #if __has_keyword(__is_trivially_destructible)
3025 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3026 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
3028 #elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
3030 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3031 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3035 template <class _Tp> struct __libcpp_trivial_destructor
3036 : public integral_constant<bool, is_scalar<_Tp>::value ||
3037 is_reference<_Tp>::value> {};
3039 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3040 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3042 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3043 : public false_type {};
3047 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3048 template <class _Tp>
3049 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3050 = is_trivially_destructible<_Tp>::value;
3053 // is_nothrow_constructible
3055 #if __has_keyword(__is_nothrow_constructible)
3057 template <class _Tp, class... _Args>
3058 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3059 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
3063 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3065 template <class _Tp, class... _Args>
3066 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3067 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3071 template <class _Tp>
3072 void __implicit_conversion_to(_Tp) noexcept { }
3074 template <class _Tp, class _Arg>
3075 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3076 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3080 template <class _Tp, bool _IsReference, class... _Args>
3081 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3086 template <class _Tp, class... _Args>
3087 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3088 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3092 template <class _Tp, size_t _Ns>
3093 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3094 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3098 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3101 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3102 template <class _Tp, class ..._Args>
3103 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3104 = is_nothrow_constructible<_Tp, _Args...>::value;
3107 // is_nothrow_default_constructible
3109 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3110 : public is_nothrow_constructible<_Tp>
3113 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3114 template <class _Tp>
3115 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3116 = is_nothrow_default_constructible<_Tp>::value;
3119 // is_nothrow_copy_constructible
3121 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3122 : public is_nothrow_constructible<_Tp,
3123 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3125 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3126 template <class _Tp>
3127 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3128 = is_nothrow_copy_constructible<_Tp>::value;
3131 // is_nothrow_move_constructible
3133 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3134 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3137 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3138 template <class _Tp>
3139 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3140 = is_nothrow_move_constructible<_Tp>::value;
3143 // is_nothrow_assignable
3145 #if __has_keyword(__is_nothrow_assignable)
3147 template <class _Tp, class _Arg>
3148 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3149 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
3153 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3155 template <class _Tp, class _Arg>
3156 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3161 template <class _Tp, class _Arg>
3162 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3163 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3167 template <class _Tp, class _Arg>
3168 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3169 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3173 #endif // _LIBCPP_HAS_NO_NOEXCEPT
3175 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3176 template <class _Tp, class _Arg>
3177 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3178 = is_nothrow_assignable<_Tp, _Arg>::value;
3181 // is_nothrow_copy_assignable
3183 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3184 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3185 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3187 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3188 template <class _Tp>
3189 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3190 = is_nothrow_copy_assignable<_Tp>::value;
3193 // is_nothrow_move_assignable
3195 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3196 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3197 typename add_rvalue_reference<_Tp>::type>
3200 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3201 template <class _Tp>
3202 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3203 = is_nothrow_move_assignable<_Tp>::value;
3206 // is_nothrow_destructible
3208 #if !defined(_LIBCPP_CXX03_LANG)
3210 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3212 template <class _Tp>
3213 struct __libcpp_is_nothrow_destructible<false, _Tp>
3218 template <class _Tp>
3219 struct __libcpp_is_nothrow_destructible<true, _Tp>
3220 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3224 template <class _Tp>
3225 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3226 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3230 template <class _Tp, size_t _Ns>
3231 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3232 : public is_nothrow_destructible<_Tp>
3236 template <class _Tp>
3237 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3242 template <class _Tp>
3243 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3250 template <class _Tp> struct __libcpp_nothrow_destructor
3251 : public integral_constant<bool, is_scalar<_Tp>::value ||
3252 is_reference<_Tp>::value> {};
3254 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3255 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3257 template <class _Tp>
3258 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3259 : public false_type {};
3263 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3264 template <class _Tp>
3265 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3266 = is_nothrow_destructible<_Tp>::value;
3271 #if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
3273 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3274 : public integral_constant<bool, __is_pod(_Tp)> {};
3278 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3279 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3280 is_trivially_copy_constructible<_Tp>::value &&
3281 is_trivially_copy_assignable<_Tp>::value &&
3282 is_trivially_destructible<_Tp>::value> {};
3286 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3287 template <class _Tp>
3288 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
3289 = is_pod<_Tp>::value;
3294 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
3295 : public integral_constant<bool, __is_literal_type(_Tp)>
3298 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3299 template <class _Tp>
3300 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
3301 = is_literal_type<_Tp>::value;
3304 // is_standard_layout;
3306 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3307 #if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
3308 : public integral_constant<bool, __is_standard_layout(_Tp)>
3310 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3314 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3315 template <class _Tp>
3316 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
3317 = is_standard_layout<_Tp>::value;
3320 // is_trivially_copyable;
3322 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3323 #if __has_feature(is_trivially_copyable)
3324 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3325 #elif _GNUC_VER >= 501
3326 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3328 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3332 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3333 template <class _Tp>
3334 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3335 = is_trivially_copyable<_Tp>::value;
3340 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3341 #if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
3342 : public integral_constant<bool, __is_trivial(_Tp)>
3344 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3345 is_trivially_default_constructible<_Tp>::value>
3349 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3350 template <class _Tp>
3351 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v
3352 = is_trivial<_Tp>::value;
3355 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3356 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3357 template <class _Tp> struct __is_reference_wrapper
3358 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3360 #ifndef _LIBCPP_CXX03_LANG
3362 template <class _Fp, class _A0,
3363 class _DecayFp = typename decay<_Fp>::type,
3364 class _DecayA0 = typename decay<_A0>::type,
3365 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3366 using __enable_if_bullet1 = typename enable_if
3368 is_member_function_pointer<_DecayFp>::value
3369 && is_base_of<_ClassT, _DecayA0>::value
3372 template <class _Fp, class _A0,
3373 class _DecayFp = typename decay<_Fp>::type,
3374 class _DecayA0 = typename decay<_A0>::type>
3375 using __enable_if_bullet2 = typename enable_if
3377 is_member_function_pointer<_DecayFp>::value
3378 && __is_reference_wrapper<_DecayA0>::value
3381 template <class _Fp, class _A0,
3382 class _DecayFp = typename decay<_Fp>::type,
3383 class _DecayA0 = typename decay<_A0>::type,
3384 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3385 using __enable_if_bullet3 = typename enable_if
3387 is_member_function_pointer<_DecayFp>::value
3388 && !is_base_of<_ClassT, _DecayA0>::value
3389 && !__is_reference_wrapper<_DecayA0>::value
3392 template <class _Fp, class _A0,
3393 class _DecayFp = typename decay<_Fp>::type,
3394 class _DecayA0 = typename decay<_A0>::type,
3395 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3396 using __enable_if_bullet4 = typename enable_if
3398 is_member_object_pointer<_DecayFp>::value
3399 && is_base_of<_ClassT, _DecayA0>::value
3402 template <class _Fp, class _A0,
3403 class _DecayFp = typename decay<_Fp>::type,
3404 class _DecayA0 = typename decay<_A0>::type>
3405 using __enable_if_bullet5 = typename enable_if
3407 is_member_object_pointer<_DecayFp>::value
3408 && __is_reference_wrapper<_DecayA0>::value
3411 template <class _Fp, class _A0,
3412 class _DecayFp = typename decay<_Fp>::type,
3413 class _DecayA0 = typename decay<_A0>::type,
3414 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
3415 using __enable_if_bullet6 = typename enable_if
3417 is_member_object_pointer<_DecayFp>::value
3418 && !is_base_of<_ClassT, _DecayA0>::value
3419 && !__is_reference_wrapper<_DecayA0>::value
3422 // __invoke forward declarations
3424 // fall back - none of the bullets
3426 #define _LIBCPP_INVOKE_RETURN(...) \
3427 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
3428 { return __VA_ARGS__; }
3430 template <class ..._Args>
3431 auto __invoke(__any, _Args&& ...__args) -> __nat;
3433 template <class ..._Args>
3434 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
3436 // bullets 1, 2 and 3
3438 template <class _Fp, class _A0, class ..._Args,
3439 class = __enable_if_bullet1<_Fp, _A0>>
3440 inline _LIBCPP_INLINE_VISIBILITY
3442 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3443 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3445 template <class _Fp, class _A0, class ..._Args,
3446 class = __enable_if_bullet1<_Fp, _A0>>
3447 inline _LIBCPP_INLINE_VISIBILITY
3448 _LIBCPP_CONSTEXPR auto
3449 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3450 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
3452 template <class _Fp, class _A0, class ..._Args,
3453 class = __enable_if_bullet2<_Fp, _A0>>
3454 inline _LIBCPP_INLINE_VISIBILITY
3456 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3457 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3459 template <class _Fp, class _A0, class ..._Args,
3460 class = __enable_if_bullet2<_Fp, _A0>>
3461 inline _LIBCPP_INLINE_VISIBILITY
3462 _LIBCPP_CONSTEXPR auto
3463 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3464 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
3466 template <class _Fp, class _A0, class ..._Args,
3467 class = __enable_if_bullet3<_Fp, _A0>>
3468 inline _LIBCPP_INLINE_VISIBILITY
3470 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3471 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3473 template <class _Fp, class _A0, class ..._Args,
3474 class = __enable_if_bullet3<_Fp, _A0>>
3475 inline _LIBCPP_INLINE_VISIBILITY
3476 _LIBCPP_CONSTEXPR auto
3477 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
3478 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
3480 // bullets 4, 5 and 6
3482 template <class _Fp, class _A0,
3483 class = __enable_if_bullet4<_Fp, _A0>>
3484 inline _LIBCPP_INLINE_VISIBILITY
3486 __invoke(_Fp&& __f, _A0&& __a0)
3487 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3489 template <class _Fp, class _A0,
3490 class = __enable_if_bullet4<_Fp, _A0>>
3491 inline _LIBCPP_INLINE_VISIBILITY
3492 _LIBCPP_CONSTEXPR auto
3493 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3494 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
3496 template <class _Fp, class _A0,
3497 class = __enable_if_bullet5<_Fp, _A0>>
3498 inline _LIBCPP_INLINE_VISIBILITY
3500 __invoke(_Fp&& __f, _A0&& __a0)
3501 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3503 template <class _Fp, class _A0,
3504 class = __enable_if_bullet5<_Fp, _A0>>
3505 inline _LIBCPP_INLINE_VISIBILITY
3506 _LIBCPP_CONSTEXPR auto
3507 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3508 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
3510 template <class _Fp, class _A0,
3511 class = __enable_if_bullet6<_Fp, _A0>>
3512 inline _LIBCPP_INLINE_VISIBILITY
3514 __invoke(_Fp&& __f, _A0&& __a0)
3515 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3517 template <class _Fp, class _A0,
3518 class = __enable_if_bullet6<_Fp, _A0>>
3519 inline _LIBCPP_INLINE_VISIBILITY
3520 _LIBCPP_CONSTEXPR auto
3521 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
3522 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
3526 template <class _Fp, class ..._Args>
3527 inline _LIBCPP_INLINE_VISIBILITY
3529 __invoke(_Fp&& __f, _Args&& ...__args)
3530 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3532 template <class _Fp, class ..._Args>
3533 inline _LIBCPP_INLINE_VISIBILITY
3534 _LIBCPP_CONSTEXPR auto
3535 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
3536 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
3538 #undef _LIBCPP_INVOKE_RETURN
3541 template <class _Ret, class _Fp, class ..._Args>
3542 struct __invokable_r
3544 template <class _XFp, class ..._XArgs>
3545 static auto __try_call(int) -> decltype(
3546 _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...));
3547 template <class _XFp, class ..._XArgs>
3548 static __nat __try_call(...);
3550 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
3551 // or incomplete array types as required by the standard.
3552 using _Result = decltype(__try_call<_Fp, _Args...>(0));
3555 typename conditional<
3556 _IsNotSame<_Result, __nat>::value,
3557 typename conditional<
3558 is_void<_Ret>::value,
3560 is_convertible<_Result, _Ret>
3564 static const bool value = type::value;
3566 template <class _Fp, class ..._Args>
3567 using __invokable = __invokable_r<void, _Fp, _Args...>;
3569 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
3570 struct __nothrow_invokable_r_imp {
3571 static const bool value = false;
3574 template <class _Ret, class _Fp, class ..._Args>
3575 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
3577 typedef __nothrow_invokable_r_imp _ThisT;
3579 template <class _Tp>
3580 static void __test_noexcept(_Tp) noexcept;
3582 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
3583 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
3586 template <class _Ret, class _Fp, class ..._Args>
3587 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
3589 static const bool value = noexcept(
3590 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
3593 template <class _Ret, class _Fp, class ..._Args>
3594 using __nothrow_invokable_r =
3595 __nothrow_invokable_r_imp<
3596 __invokable_r<_Ret, _Fp, _Args...>::value,
3597 is_void<_Ret>::value,
3601 template <class _Fp, class ..._Args>
3602 using __nothrow_invokable =
3603 __nothrow_invokable_r_imp<
3604 __invokable<_Fp, _Args...>::value,
3605 true, void, _Fp, _Args...
3608 template <class _Fp, class ..._Args>
3611 __invokable<_Fp, _Args...>::value,
3612 typename __invokable_r<void, _Fp, _Args...>::_Result>
3618 template <class _Fp, class ..._Args>
3619 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
3620 : public __invoke_of<_Fp, _Args...>
3624 #if _LIBCPP_STD_VER > 11
3625 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
3628 #if _LIBCPP_STD_VER > 14
3632 template <class _Fn, class... _Args>
3633 struct _LIBCPP_TEMPLATE_VIS invoke_result
3634 : __invoke_of<_Fn, _Args...>
3638 template <class _Fn, class... _Args>
3639 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
3643 template <class _Fn, class ..._Args>
3644 struct _LIBCPP_TEMPLATE_VIS is_invocable
3645 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
3647 template <class _Ret, class _Fn, class ..._Args>
3648 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
3649 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
3651 template <class _Fn, class ..._Args>
3652 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v
3653 = is_invocable<_Fn, _Args...>::value;
3655 template <class _Ret, class _Fn, class ..._Args>
3656 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v
3657 = is_invocable_r<_Ret, _Fn, _Args...>::value;
3659 // is_nothrow_invocable
3661 template <class _Fn, class ..._Args>
3662 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
3663 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
3665 template <class _Ret, class _Fn, class ..._Args>
3666 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
3667 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
3669 template <class _Fn, class ..._Args>
3670 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v
3671 = is_nothrow_invocable<_Fn, _Args...>::value;
3673 template <class _Ret, class _Fn, class ..._Args>
3674 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
3675 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
3677 #endif // _LIBCPP_STD_VER > 14
3679 #endif // !defined(_LIBCPP_CXX03_LANG)
3681 template <class _Tp> struct __is_swappable;
3682 template <class _Tp> struct __is_nothrow_swappable;
3684 template <class _Tp>
3685 inline _LIBCPP_INLINE_VISIBILITY
3686 #ifndef _LIBCPP_CXX03_LANG
3689 is_move_constructible<_Tp>::value &&
3690 is_move_assignable<_Tp>::value
3695 _LIBCPP_CONSTEXPR_AFTER_CXX17
3696 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
3697 is_nothrow_move_assignable<_Tp>::value)
3699 _Tp __t(_VSTD::move(__x));
3700 __x = _VSTD::move(__y);
3701 __y = _VSTD::move(__t);
3704 template<class _Tp, size_t _Np>
3705 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3707 __is_swappable<_Tp>::value
3709 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
3711 template <class _ForwardIterator1, class _ForwardIterator2>
3712 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3714 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
3715 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
3716 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
3717 *_VSTD::declval<_ForwardIterator2>())))
3726 // ALL generic swap overloads MUST already have a declaration available at this point.
3728 template <class _Tp, class _Up = _Tp,
3729 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
3730 struct __swappable_with
3732 template <class _LHS, class _RHS>
3733 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
3735 template <class, class>
3736 static __nat __test_swap(long);
3738 // Extra parens are needed for the C++03 definition of decltype.
3739 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
3740 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
3742 static const bool value = _IsNotSame<__swap1, __nat>::value
3743 && _IsNotSame<__swap2, __nat>::value;
3746 template <class _Tp, class _Up>
3747 struct __swappable_with<_Tp, _Up, false> : false_type {};
3749 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
3750 struct __nothrow_swappable_with {
3751 static const bool value =
3752 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
3753 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
3754 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
3760 template <class _Tp, class _Up>
3761 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
3765 template <class _Tp>
3766 struct __is_swappable
3767 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
3771 template <class _Tp>
3772 struct __is_nothrow_swappable
3773 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
3777 #if _LIBCPP_STD_VER > 14
3779 template <class _Tp, class _Up>
3780 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
3781 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
3785 template <class _Tp>
3786 struct _LIBCPP_TEMPLATE_VIS is_swappable
3787 : public conditional<
3788 __is_referenceable<_Tp>::value,
3790 typename add_lvalue_reference<_Tp>::type,
3791 typename add_lvalue_reference<_Tp>::type>,
3797 template <class _Tp, class _Up>
3798 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
3799 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
3803 template <class _Tp>
3804 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
3805 : public conditional<
3806 __is_referenceable<_Tp>::value,
3807 is_nothrow_swappable_with<
3808 typename add_lvalue_reference<_Tp>::type,
3809 typename add_lvalue_reference<_Tp>::type>,
3815 template <class _Tp, class _Up>
3816 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v
3817 = is_swappable_with<_Tp, _Up>::value;
3819 template <class _Tp>
3820 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v
3821 = is_swappable<_Tp>::value;
3823 template <class _Tp, class _Up>
3824 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v
3825 = is_nothrow_swappable_with<_Tp, _Up>::value;
3827 template <class _Tp>
3828 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v
3829 = is_nothrow_swappable<_Tp>::value;
3831 #endif // _LIBCPP_STD_VER > 14
3833 template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
3835 template <class _Tp>
3836 struct __underlying_type_impl<_Tp, false> {};
3838 template <class _Tp>
3839 struct __underlying_type_impl<_Tp, true>
3841 typedef __underlying_type(_Tp) type;
3844 template <class _Tp>
3845 struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
3847 #if _LIBCPP_STD_VER > 11
3848 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
3852 template <class _Tp, bool = is_enum<_Tp>::value>
3853 struct __sfinae_underlying_type
3855 typedef typename underlying_type<_Tp>::type type;
3856 typedef decltype(((type)1) + 0) __promoted_type;
3859 template <class _Tp>
3860 struct __sfinae_underlying_type<_Tp, false> {};
3862 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3863 int __convert_to_integral(int __val) { return __val; }
3865 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3866 unsigned __convert_to_integral(unsigned __val) { return __val; }
3868 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3869 long __convert_to_integral(long __val) { return __val; }
3871 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3872 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
3874 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3875 long long __convert_to_integral(long long __val) { return __val; }
3877 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3878 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
3880 template<typename _Fp>
3881 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3882 typename enable_if<is_floating_point<_Fp>::value, long long>::type
3883 __convert_to_integral(_Fp __val) { return __val; }
3885 #ifndef _LIBCPP_HAS_NO_INT128
3886 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3887 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
3889 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3890 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
3893 template <class _Tp>
3894 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3895 typename __sfinae_underlying_type<_Tp>::__promoted_type
3896 __convert_to_integral(_Tp __val) { return __val; }
3898 #ifndef _LIBCPP_CXX03_LANG
3900 template <class _Tp>
3901 struct __has_operator_addressof_member_imp
3903 template <class _Up>
3904 static auto __test(int)
3905 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
3907 static auto __test(long) -> false_type;
3909 static const bool value = decltype(__test<_Tp>(0))::value;
3912 template <class _Tp>
3913 struct __has_operator_addressof_free_imp
3915 template <class _Up>
3916 static auto __test(int)
3917 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
3919 static auto __test(long) -> false_type;
3921 static const bool value = decltype(__test<_Tp>(0))::value;
3924 template <class _Tp>
3925 struct __has_operator_addressof
3926 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
3927 || __has_operator_addressof_free_imp<_Tp>::value>
3930 #endif // _LIBCPP_CXX03_LANG
3932 #if _LIBCPP_STD_VER > 14
3934 template <class...> using void_t = void;
3936 template <class... _Args>
3937 struct conjunction : _And<_Args...> {};
3938 template<class... _Args>
3939 _LIBCPP_INLINE_VAR constexpr bool conjunction_v
3940 = conjunction<_Args...>::value;
3942 template <class... _Args>
3943 struct disjunction : _Or<_Args...> {};
3944 template<class... _Args>
3945 _LIBCPP_INLINE_VAR constexpr bool disjunction_v
3946 = disjunction<_Args...>::value;
3948 template <class _Tp>
3949 struct negation : _Not<_Tp> {};
3951 _LIBCPP_INLINE_VAR constexpr bool negation_v
3952 = negation<_Tp>::value;
3953 #endif // _LIBCPP_STD_VER > 14
3955 // These traits are used in __tree and __hash_table
3956 #ifndef _LIBCPP_CXX03_LANG
3957 struct __extract_key_fail_tag {};
3958 struct __extract_key_self_tag {};
3959 struct __extract_key_first_tag {};
3961 template <class _ValTy, class _Key,
3962 class _RawValTy = typename __unconstref<_ValTy>::type>
3963 struct __can_extract_key
3964 : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
3965 __extract_key_fail_tag>::type {};
3967 template <class _Pair, class _Key, class _First, class _Second>
3968 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
3969 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
3970 __extract_key_first_tag, __extract_key_fail_tag>::type {};
3972 // __can_extract_map_key uses true_type/false_type instead of the tags.
3973 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
3974 // and _ValTy == _Key.
3975 template <class _ValTy, class _Key, class _ContainerValueTy,
3976 class _RawValTy = typename __unconstref<_ValTy>::type>
3977 struct __can_extract_map_key
3978 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
3980 // This specialization returns __extract_key_fail_tag for non-map containers
3981 // because _Key == _ContainerValueTy
3982 template <class _ValTy, class _Key, class _RawValTy>
3983 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
3988 #if _LIBCPP_STD_VER > 17
3993 #if defined(_LIBCPP_LITTLE_ENDIAN)
3995 #elif defined(_LIBCPP_BIG_ENDIAN)
4003 #ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
4004 #if _LIBCPP_STD_VER > 17
4005 _LIBCPP_INLINE_VISIBILITY
4006 inline constexpr bool is_constant_evaluated() noexcept {
4007 return __builtin_is_constant_evaluated();
4011 inline _LIBCPP_CONSTEXPR
4012 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
4014 inline _LIBCPP_CONSTEXPR
4015 bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; }
4018 template <class _CharT>
4019 using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
4021 _LIBCPP_END_NAMESPACE_STD
4023 #if _LIBCPP_STD_VER > 14
4025 namespace std // purposefully not versioned
4027 template <class _Integer>
4028 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4029 operator<<=(byte& __lhs, _Integer __shift) noexcept
4030 { return __lhs = __lhs << __shift; }
4032 template <class _Integer>
4033 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4034 operator<< (byte __lhs, _Integer __shift) noexcept
4035 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
4037 template <class _Integer>
4038 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4039 operator>>=(byte& __lhs, _Integer __shift) noexcept
4040 { return __lhs = __lhs >> __shift; }
4042 template <class _Integer>
4043 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4044 operator>> (byte __lhs, _Integer __shift) noexcept
4045 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4047 template <class _Integer>
4048 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4049 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4054 #endif // _LIBCPP_TYPE_TRAITS