2 //===------------------------ type_traits ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_TYPE_TRAITS
12 #define _LIBCPP_TYPE_TRAITS
21 template <class T, T v> struct integral_constant;
22 typedef integral_constant<bool, true> true_type; // C++11
23 typedef integral_constant<bool, false> false_type; // C++11
25 template <bool B> // C++14
26 using bool_constant = integral_constant<bool, B>; // C++14
27 typedef bool_constant<true> true_type; // C++14
28 typedef bool_constant<false> false_type; // C++14
31 template <bool, class T = void> struct enable_if;
32 template <bool, class T, class F> struct conditional;
34 // Primary classification traits:
35 template <class T> struct is_void;
36 template <class T> struct is_null_pointer; // C++14
37 template <class T> struct is_integral;
38 template <class T> struct is_floating_point;
39 template <class T> struct is_array;
40 template <class T> struct is_pointer;
41 template <class T> struct is_lvalue_reference;
42 template <class T> struct is_rvalue_reference;
43 template <class T> struct is_member_object_pointer;
44 template <class T> struct is_member_function_pointer;
45 template <class T> struct is_enum;
46 template <class T> struct is_union;
47 template <class T> struct is_class;
48 template <class T> struct is_function;
50 // Secondary classification traits:
51 template <class T> struct is_reference;
52 template <class T> struct is_arithmetic;
53 template <class T> struct is_fundamental;
54 template <class T> struct is_member_pointer;
55 template <class T> struct is_scalar;
56 template <class T> struct is_object;
57 template <class T> struct is_compound;
59 // Const-volatile properties and transformations:
60 template <class T> struct is_const;
61 template <class T> struct is_volatile;
62 template <class T> struct remove_const;
63 template <class T> struct remove_volatile;
64 template <class T> struct remove_cv;
65 template <class T> struct add_const;
66 template <class T> struct add_volatile;
67 template <class T> struct add_cv;
69 // Reference transformations:
70 template <class T> struct remove_reference;
71 template <class T> struct add_lvalue_reference;
72 template <class T> struct add_rvalue_reference;
74 // Pointer transformations:
75 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;
78 // Integral properties:
79 template <class T> struct is_signed;
80 template <class T> struct is_unsigned;
81 template <class T> struct make_signed;
82 template <class T> struct make_unsigned;
84 // Array properties and transformations:
85 template <class T> struct rank;
86 template <class T, unsigned I = 0> struct extent;
87 template <class T> struct remove_extent;
88 template <class T> struct remove_all_extents;
90 // Member introspection:
91 template <class T> struct is_pod;
92 template <class T> struct is_trivial;
93 template <class T> struct is_trivially_copyable;
94 template <class T> struct is_standard_layout;
95 template <class T> struct is_literal_type;
96 template <class T> struct is_empty;
97 template <class T> struct is_polymorphic;
98 template <class T> struct is_abstract;
99 template <class T> struct is_final; // C++14
100 template <class T> struct is_aggregate; // C++17
102 template <class T, class... Args> struct is_constructible;
103 template <class T> struct is_default_constructible;
104 template <class T> struct is_copy_constructible;
105 template <class T> struct is_move_constructible;
106 template <class T, class U> struct is_assignable;
107 template <class T> struct is_copy_assignable;
108 template <class T> struct is_move_assignable;
109 template <class T, class U> struct is_swappable_with; // C++17
110 template <class T> struct is_swappable; // C++17
111 template <class T> struct is_destructible;
113 template <class T, class... Args> struct is_trivially_constructible;
114 template <class T> struct is_trivially_default_constructible;
115 template <class T> struct is_trivially_copy_constructible;
116 template <class T> struct is_trivially_move_constructible;
117 template <class T, class U> struct is_trivially_assignable;
118 template <class T> struct is_trivially_copy_assignable;
119 template <class T> struct is_trivially_move_assignable;
120 template <class T> struct is_trivially_destructible;
122 template <class T, class... Args> struct is_nothrow_constructible;
123 template <class T> struct is_nothrow_default_constructible;
124 template <class T> struct is_nothrow_copy_constructible;
125 template <class T> struct is_nothrow_move_constructible;
126 template <class T, class U> struct is_nothrow_assignable;
127 template <class T> struct is_nothrow_copy_assignable;
128 template <class T> struct is_nothrow_move_assignable;
129 template <class T, class U> struct is_nothrow_swappable_with; // C++17
130 template <class T> struct is_nothrow_swappable; // C++17
131 template <class T> struct is_nothrow_destructible;
133 template <class T> struct has_virtual_destructor;
135 // Relationships between types:
136 template <class T, class U> struct is_same;
137 template <class Base, class Derived> struct is_base_of;
138 template <class From, class To> struct is_convertible;
140 template <class Fn, class... ArgTypes> struct is_invocable;
141 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
143 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
144 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
146 // Alignment properties and transformations:
147 template <class T> struct alignment_of;
148 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
149 struct aligned_storage;
150 template <size_t Len, class... Types> struct aligned_union;
151 template <class T> struct remove_cvref; // C++20
153 template <class T> struct decay;
154 template <class... T> struct common_type;
155 template <class T> struct underlying_type;
156 template <class> class result_of; // undefined
157 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
158 template <class Fn, class... ArgTypes> struct invoke_result; // C++17
160 // const-volatile modifications:
162 using remove_const_t = typename remove_const<T>::type; // C++14
164 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
166 using remove_cv_t = typename remove_cv<T>::type; // C++14
168 using add_const_t = typename add_const<T>::type; // C++14
170 using add_volatile_t = typename add_volatile<T>::type; // C++14
172 using add_cv_t = typename add_cv<T>::type; // C++14
174 // reference modifications:
176 using remove_reference_t = typename remove_reference<T>::type; // C++14
178 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
180 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
182 // sign modifications:
184 using make_signed_t = typename make_signed<T>::type; // C++14
186 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
188 // array modifications:
190 using remove_extent_t = typename remove_extent<T>::type; // C++14
192 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
194 // pointer modifications:
196 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
198 using add_pointer_t = typename add_pointer<T>::type; // C++14
200 // other transformations:
201 template <size_t Len, std::size_t Align=default-alignment>
202 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
203 template <std::size_t Len, class... Types>
204 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
206 using remove_cvref_t = typename remove_cvref<T>::type; // C++20
208 using decay_t = typename decay<T>::type; // C++14
209 template <bool b, class T=void>
210 using enable_if_t = typename enable_if<b,T>::type; // C++14
211 template <bool b, class T, class F>
212 using conditional_t = typename conditional<b,T,F>::type; // C++14
213 template <class... T>
214 using common_type_t = typename common_type<T...>::type; // C++14
216 using underlying_type_t = typename underlying_type<T>::type; // C++14
218 using result_of_t = typename result_of<T>::type; // C++14
219 template <class Fn, class... ArgTypes>
220 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
223 using void_t = void; // C++17
225 // See C++14 20.10.4.1, primary type categories
226 template <class T> constexpr bool is_void_v
227 = is_void<T>::value; // C++17
228 template <class T> constexpr bool is_null_pointer_v
229 = is_null_pointer<T>::value; // C++17
230 template <class T> constexpr bool is_integral_v
231 = is_integral<T>::value; // C++17
232 template <class T> constexpr bool is_floating_point_v
233 = is_floating_point<T>::value; // C++17
234 template <class T> constexpr bool is_array_v
235 = is_array<T>::value; // C++17
236 template <class T> constexpr bool is_pointer_v
237 = is_pointer<T>::value; // C++17
238 template <class T> constexpr bool is_lvalue_reference_v
239 = is_lvalue_reference<T>::value; // C++17
240 template <class T> constexpr bool is_rvalue_reference_v
241 = is_rvalue_reference<T>::value; // C++17
242 template <class T> constexpr bool is_member_object_pointer_v
243 = is_member_object_pointer<T>::value; // C++17
244 template <class T> constexpr bool is_member_function_pointer_v
245 = is_member_function_pointer<T>::value; // C++17
246 template <class T> constexpr bool is_enum_v
247 = is_enum<T>::value; // C++17
248 template <class T> constexpr bool is_union_v
249 = is_union<T>::value; // C++17
250 template <class T> constexpr bool is_class_v
251 = is_class<T>::value; // C++17
252 template <class T> constexpr bool is_function_v
253 = is_function<T>::value; // C++17
255 // See C++14 20.10.4.2, composite type categories
256 template <class T> constexpr bool is_reference_v
257 = is_reference<T>::value; // C++17
258 template <class T> constexpr bool is_arithmetic_v
259 = is_arithmetic<T>::value; // C++17
260 template <class T> constexpr bool is_fundamental_v
261 = is_fundamental<T>::value; // C++17
262 template <class T> constexpr bool is_object_v
263 = is_object<T>::value; // C++17
264 template <class T> constexpr bool is_scalar_v
265 = is_scalar<T>::value; // C++17
266 template <class T> constexpr bool is_compound_v
267 = is_compound<T>::value; // C++17
268 template <class T> constexpr bool is_member_pointer_v
269 = is_member_pointer<T>::value; // C++17
271 // See C++14 20.10.4.3, type properties
272 template <class T> constexpr bool is_const_v
273 = is_const<T>::value; // C++17
274 template <class T> constexpr bool is_volatile_v
275 = is_volatile<T>::value; // C++17
276 template <class T> constexpr bool is_trivial_v
277 = is_trivial<T>::value; // C++17
278 template <class T> constexpr bool is_trivially_copyable_v
279 = is_trivially_copyable<T>::value; // C++17
280 template <class T> constexpr bool is_standard_layout_v
281 = is_standard_layout<T>::value; // C++17
282 template <class T> constexpr bool is_pod_v
283 = is_pod<T>::value; // C++17
284 template <class T> constexpr bool is_literal_type_v
285 = is_literal_type<T>::value; // C++17
286 template <class T> constexpr bool is_empty_v
287 = is_empty<T>::value; // C++17
288 template <class T> constexpr bool is_polymorphic_v
289 = is_polymorphic<T>::value; // C++17
290 template <class T> constexpr bool is_abstract_v
291 = is_abstract<T>::value; // C++17
292 template <class T> constexpr bool is_final_v
293 = is_final<T>::value; // C++17
294 template <class T> constexpr bool is_aggregate_v
295 = is_aggregate<T>::value; // C++17
296 template <class T> constexpr bool is_signed_v
297 = is_signed<T>::value; // C++17
298 template <class T> constexpr bool is_unsigned_v
299 = is_unsigned<T>::value; // C++17
300 template <class T, class... Args> constexpr bool is_constructible_v
301 = is_constructible<T, Args...>::value; // C++17
302 template <class T> constexpr bool is_default_constructible_v
303 = is_default_constructible<T>::value; // C++17
304 template <class T> constexpr bool is_copy_constructible_v
305 = is_copy_constructible<T>::value; // C++17
306 template <class T> constexpr bool is_move_constructible_v
307 = is_move_constructible<T>::value; // C++17
308 template <class T, class U> constexpr bool is_assignable_v
309 = is_assignable<T, U>::value; // C++17
310 template <class T> constexpr bool is_copy_assignable_v
311 = is_copy_assignable<T>::value; // C++17
312 template <class T> constexpr bool is_move_assignable_v
313 = is_move_assignable<T>::value; // C++17
314 template <class T, class U> constexpr bool is_swappable_with_v
315 = is_swappable_with<T, U>::value; // C++17
316 template <class T> constexpr bool is_swappable_v
317 = is_swappable<T>::value; // C++17
318 template <class T> constexpr bool is_destructible_v
319 = is_destructible<T>::value; // C++17
320 template <class T, class... Args> constexpr bool is_trivially_constructible_v
321 = is_trivially_constructible<T, Args...>::value; // C++17
322 template <class T> constexpr bool is_trivially_default_constructible_v
323 = is_trivially_default_constructible<T>::value; // C++17
324 template <class T> constexpr bool is_trivially_copy_constructible_v
325 = is_trivially_copy_constructible<T>::value; // C++17
326 template <class T> constexpr bool is_trivially_move_constructible_v
327 = is_trivially_move_constructible<T>::value; // C++17
328 template <class T, class U> constexpr bool is_trivially_assignable_v
329 = is_trivially_assignable<T, U>::value; // C++17
330 template <class T> constexpr bool is_trivially_copy_assignable_v
331 = is_trivially_copy_assignable<T>::value; // C++17
332 template <class T> constexpr bool is_trivially_move_assignable_v
333 = is_trivially_move_assignable<T>::value; // C++17
334 template <class T> constexpr bool is_trivially_destructible_v
335 = is_trivially_destructible<T>::value; // C++17
336 template <class T, class... Args> constexpr bool is_nothrow_constructible_v
337 = is_nothrow_constructible<T, Args...>::value; // C++17
338 template <class T> constexpr bool is_nothrow_default_constructible_v
339 = is_nothrow_default_constructible<T>::value; // C++17
340 template <class T> constexpr bool is_nothrow_copy_constructible_v
341 = is_nothrow_copy_constructible<T>::value; // C++17
342 template <class T> constexpr bool is_nothrow_move_constructible_v
343 = is_nothrow_move_constructible<T>::value; // C++17
344 template <class T, class U> constexpr bool is_nothrow_assignable_v
345 = is_nothrow_assignable<T, U>::value; // C++17
346 template <class T> constexpr bool is_nothrow_copy_assignable_v
347 = is_nothrow_copy_assignable<T>::value; // C++17
348 template <class T> constexpr bool is_nothrow_move_assignable_v
349 = is_nothrow_move_assignable<T>::value; // C++17
350 template <class T, class U> constexpr bool is_nothrow_swappable_with_v
351 = is_nothrow_swappable_with<T, U>::value; // C++17
352 template <class T> constexpr bool is_nothrow_swappable_v
353 = is_nothrow_swappable<T>::value; // C++17
354 template <class T> constexpr bool is_nothrow_destructible_v
355 = is_nothrow_destructible<T>::value; // C++17
356 template <class T> constexpr bool has_virtual_destructor_v
357 = has_virtual_destructor<T>::value; // C++17
359 // See C++14 20.10.5, type property queries
360 template <class T> constexpr size_t alignment_of_v
361 = alignment_of<T>::value; // C++17
362 template <class T> constexpr size_t rank_v
363 = rank<T>::value; // C++17
364 template <class T, unsigned I = 0> constexpr size_t extent_v
365 = extent<T, I>::value; // C++17
367 // See C++14 20.10.6, type relations
368 template <class T, class U> constexpr bool is_same_v
369 = is_same<T, U>::value; // C++17
370 template <class Base, class Derived> constexpr bool is_base_of_v
371 = is_base_of<Base, Derived>::value; // C++17
372 template <class From, class To> constexpr bool is_convertible_v
373 = is_convertible<From, To>::value; // C++17
374 template <class Fn, class... ArgTypes> constexpr bool is_invocable_v
375 = is_invocable<Fn, ArgTypes...>::value; // C++17
376 template <class R, class Fn, class... ArgTypes> constexpr bool is_invocable_r_v
377 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
378 template <class Fn, class... ArgTypes> constexpr bool is_nothrow_invocable_v
379 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
380 template <class R, class Fn, class... ArgTypes> constexpr bool is_nothrow_invocable_r_v
381 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
383 // [meta.logical], logical operator traits:
384 template<class... B> struct conjunction; // C++17
386 constexpr bool conjunction_v = conjunction<B...>::value; // C++17
387 template<class... B> struct disjunction; // C++17
389 constexpr bool disjunction_v = disjunction<B...>::value; // C++17
390 template<class B> struct negation; // C++17
392 constexpr bool negation_v = negation<B>::value; // C++17
400 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
401 #pragma GCC system_header
404 _LIBCPP_BEGIN_NAMESPACE_STD
406 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
407 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
408 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
411 struct __void_t { typedef void type; };
414 struct __identity { typedef _Tp type; };
416 template <class _Tp, bool>
417 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
419 template <bool _Bp, class _If, class _Then>
420 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
421 template <class _If, class _Then>
422 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
424 #if _LIBCPP_STD_VER > 11
425 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
428 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {};
429 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
431 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
432 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
434 #if _LIBCPP_STD_VER > 11
435 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
439 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
442 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
443 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
445 addressof(_Tp& __x) _NOEXCEPT
447 return __builtin_addressof(__x);
453 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
455 addressof(_Tp& __x) _NOEXCEPT
457 return reinterpret_cast<_Tp *>(
458 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
461 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
463 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
464 // Objective-C++ Automatic Reference Counting uses qualified pointers
465 // that require special addressof() signatures. When
466 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
467 // itself is providing these definitions. Otherwise, we provide them.
469 inline _LIBCPP_INLINE_VISIBILITY
471 addressof(__strong _Tp& __x) _NOEXCEPT
476 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
478 inline _LIBCPP_INLINE_VISIBILITY
480 addressof(__weak _Tp& __x) _NOEXCEPT
487 inline _LIBCPP_INLINE_VISIBILITY
489 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
495 inline _LIBCPP_INLINE_VISIBILITY
496 __unsafe_unretained _Tp*
497 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
503 #if !defined(_LIBCPP_CXX03_LANG)
504 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
507 struct __two {char __lx[2];};
511 template <class _Tp, _Tp __v>
512 struct _LIBCPP_TEMPLATE_VIS integral_constant
514 static _LIBCPP_CONSTEXPR const _Tp value = __v;
515 typedef _Tp value_type;
516 typedef integral_constant type;
517 _LIBCPP_INLINE_VISIBILITY
518 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
519 #if _LIBCPP_STD_VER > 11
520 _LIBCPP_INLINE_VISIBILITY
521 constexpr value_type operator ()() const _NOEXCEPT {return value;}
525 template <class _Tp, _Tp __v>
526 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
528 #if _LIBCPP_STD_VER > 14
530 using bool_constant = integral_constant<bool, __b>;
531 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
533 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
536 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
537 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
539 #if !defined(_LIBCPP_CXX03_LANG)
543 template <bool _Last, class ..._Preds>
544 struct __lazy_and_impl;
546 template <class ..._Preds>
547 struct __lazy_and_impl<false, _Preds...> : false_type {};
550 struct __lazy_and_impl<true> : true_type {};
552 template <class _Pred>
553 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
555 template <class _Hp, class ..._Tp>
556 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
558 template <class _P1, class ..._Pr>
559 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
563 template <bool _List, class ..._Preds>
564 struct __lazy_or_impl;
566 template <class ..._Preds>
567 struct __lazy_or_impl<true, _Preds...> : true_type {};
570 struct __lazy_or_impl<false> : false_type {};
572 template <class _Hp, class ..._Tp>
573 struct __lazy_or_impl<false, _Hp, _Tp...>
574 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
576 template <class _P1, class ..._Pr>
577 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
581 template <class _Pred>
582 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
585 template<class...> struct __and_;
586 template<> struct __and_<> : true_type {};
588 template<class _B0> struct __and_<_B0> : _B0 {};
590 template<class _B0, class _B1>
591 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
593 template<class _B0, class _B1, class _B2, class... _Bn>
594 struct __and_<_B0, _B1, _B2, _Bn...>
595 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
598 template<class...> struct __or_;
599 template<> struct __or_<> : false_type {};
601 template<class _B0> struct __or_<_B0> : _B0 {};
603 template<class _B0, class _B1>
604 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
606 template<class _B0, class _B1, class _B2, class... _Bn>
607 struct __or_<_B0, _B1, _B2, _Bn...>
608 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
612 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
614 #endif // !defined(_LIBCPP_CXX03_LANG)
618 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
619 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
621 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
622 template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
623 = is_const<_Tp>::value;
628 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
629 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
631 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
632 template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
633 = is_volatile<_Tp>::value;
638 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
639 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
640 #if _LIBCPP_STD_VER > 11
641 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
646 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
647 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
648 #if _LIBCPP_STD_VER > 11
649 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
654 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
655 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
656 #if _LIBCPP_STD_VER > 11
657 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
662 template <class _Tp> struct __libcpp_is_void : public false_type {};
663 template <> struct __libcpp_is_void<void> : public true_type {};
665 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
666 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
668 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
669 template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
670 = is_void<_Tp>::value;
675 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
676 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
678 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
679 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
681 #if _LIBCPP_STD_VER > 11
682 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
683 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
685 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
686 template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
687 = is_null_pointer<_Tp>::value;
693 template <class _Tp> struct __libcpp_is_integral : public false_type {};
694 template <> struct __libcpp_is_integral<bool> : public true_type {};
695 template <> struct __libcpp_is_integral<char> : public true_type {};
696 template <> struct __libcpp_is_integral<signed char> : public true_type {};
697 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
698 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
699 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
700 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
701 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
702 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
703 template <> struct __libcpp_is_integral<short> : public true_type {};
704 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
705 template <> struct __libcpp_is_integral<int> : public true_type {};
706 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
707 template <> struct __libcpp_is_integral<long> : public true_type {};
708 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
709 template <> struct __libcpp_is_integral<long long> : public true_type {};
710 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
711 #ifndef _LIBCPP_HAS_NO_INT128
712 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
713 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
716 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
717 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
719 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
720 template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
721 = is_integral<_Tp>::value;
726 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
727 template <> struct __libcpp_is_floating_point<float> : public true_type {};
728 template <> struct __libcpp_is_floating_point<double> : public true_type {};
729 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
731 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
732 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
734 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
735 template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
736 = is_floating_point<_Tp>::value;
741 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
742 : public false_type {};
743 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
744 : public true_type {};
745 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
746 : public true_type {};
748 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
749 template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
750 = is_array<_Tp>::value;
755 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
756 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
758 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
759 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
761 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
762 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
763 = is_pointer<_Tp>::value;
768 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
769 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
771 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
772 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
773 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
776 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
777 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
778 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
779 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
782 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
783 template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
784 = is_reference<_Tp>::value;
786 template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
787 = is_lvalue_reference<_Tp>::value;
789 template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
790 = is_rvalue_reference<_Tp>::value;
794 #if __has_feature(is_union) || (_GNUC_VER >= 403)
796 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
797 : public integral_constant<bool, __is_union(_Tp)> {};
801 template <class _Tp> struct __libcpp_union : public false_type {};
802 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
803 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
807 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
808 template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
809 = is_union<_Tp>::value;
814 #if __has_feature(is_class) || (_GNUC_VER >= 403)
816 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
817 : public integral_constant<bool, __is_class(_Tp)> {};
821 namespace __is_class_imp
823 template <class _Tp> char __test(int _Tp::*);
824 template <class _Tp> __two __test(...);
827 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
828 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
832 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
833 template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
834 = is_class<_Tp>::value;
839 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
840 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
842 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
843 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
844 = is_same<_Tp, _Up>::value;
849 namespace __libcpp_is_function_imp
851 struct __dummy_type {};
852 template <class _Tp> char __test(_Tp*);
853 template <class _Tp> char __test(__dummy_type);
854 template <class _Tp> __two __test(...);
855 template <class _Tp> _Tp& __source(int);
856 template <class _Tp> __dummy_type __source(...);
859 template <class _Tp, bool = is_class<_Tp>::value ||
860 is_union<_Tp>::value ||
861 is_void<_Tp>::value ||
862 is_reference<_Tp>::value ||
863 __is_nullptr_t<_Tp>::value >
864 struct __libcpp_is_function
865 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
867 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
869 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
870 : public __libcpp_is_function<_Tp> {};
872 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
873 template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
874 = is_function<_Tp>::value;
877 // is_member_function_pointer
879 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
880 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
883 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
884 struct __member_pointer_traits_imp
885 { // forward declaration; specializations later
889 template <class _Tp> struct __libcpp_is_member_function_pointer
890 : public false_type {};
892 template <class _Ret, class _Class>
893 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
894 : public is_function<_Ret> {};
896 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
897 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
899 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
900 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
901 = is_member_function_pointer<_Tp>::value;
906 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
907 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
909 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
910 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
912 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
913 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
914 = is_member_pointer<_Tp>::value;
917 // is_member_object_pointer
919 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
920 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
921 !is_member_function_pointer<_Tp>::value> {};
923 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
924 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
925 = is_member_object_pointer<_Tp>::value;
930 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
932 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
933 : public integral_constant<bool, __is_enum(_Tp)> {};
937 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
938 : public integral_constant<bool, !is_void<_Tp>::value &&
939 !is_integral<_Tp>::value &&
940 !is_floating_point<_Tp>::value &&
941 !is_array<_Tp>::value &&
942 !is_pointer<_Tp>::value &&
943 !is_reference<_Tp>::value &&
944 !is_member_pointer<_Tp>::value &&
945 !is_union<_Tp>::value &&
946 !is_class<_Tp>::value &&
947 !is_function<_Tp>::value > {};
951 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
952 template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
953 = is_enum<_Tp>::value;
958 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
959 : public integral_constant<bool, is_integral<_Tp>::value ||
960 is_floating_point<_Tp>::value> {};
962 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
963 template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
964 = is_arithmetic<_Tp>::value;
969 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
970 : public integral_constant<bool, is_void<_Tp>::value ||
971 __is_nullptr_t<_Tp>::value ||
972 is_arithmetic<_Tp>::value> {};
974 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
975 template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
976 = is_fundamental<_Tp>::value;
981 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
982 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
983 is_member_pointer<_Tp>::value ||
984 is_pointer<_Tp>::value ||
985 __is_nullptr_t<_Tp>::value ||
986 is_enum<_Tp>::value > {};
988 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
990 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
991 template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
992 = is_scalar<_Tp>::value;
997 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
998 : public integral_constant<bool, is_scalar<_Tp>::value ||
999 is_array<_Tp>::value ||
1000 is_union<_Tp>::value ||
1001 is_class<_Tp>::value > {};
1003 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1004 template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
1005 = is_object<_Tp>::value;
1010 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1011 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1013 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1014 template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
1015 = is_compound<_Tp>::value;
1019 // __is_referenceable [defns.referenceable]
1021 struct __is_referenceable_impl {
1022 template <class _Tp> static _Tp& __test(int);
1023 template <class _Tp> static __two __test(...);
1026 template <class _Tp>
1027 struct __is_referenceable : integral_constant<bool,
1028 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1033 template <class _Tp, bool = is_reference<_Tp>::value ||
1034 is_function<_Tp>::value ||
1035 is_const<_Tp>::value >
1036 struct __add_const {typedef _Tp type;};
1038 template <class _Tp>
1039 struct __add_const<_Tp, false> {typedef const _Tp type;};
1041 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1042 {typedef typename __add_const<_Tp>::type type;};
1044 #if _LIBCPP_STD_VER > 11
1045 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1050 template <class _Tp, bool = is_reference<_Tp>::value ||
1051 is_function<_Tp>::value ||
1052 is_volatile<_Tp>::value >
1053 struct __add_volatile {typedef _Tp type;};
1055 template <class _Tp>
1056 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1058 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1059 {typedef typename __add_volatile<_Tp>::type type;};
1061 #if _LIBCPP_STD_VER > 11
1062 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1067 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1068 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1070 #if _LIBCPP_STD_VER > 11
1071 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1076 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;};
1077 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;};
1078 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1079 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
1082 #if _LIBCPP_STD_VER > 11
1083 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1086 // add_lvalue_reference
1088 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1089 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1091 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1092 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1094 #if _LIBCPP_STD_VER > 11
1095 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1098 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1100 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1101 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1103 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1104 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1106 #if _LIBCPP_STD_VER > 11
1107 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1110 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1112 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1114 template <class _Tp> _Tp&& __declval(int);
1115 template <class _Tp> _Tp __declval(long);
1117 template <class _Tp>
1118 decltype(_VSTD::__declval<_Tp>(0))
1119 declval() _NOEXCEPT;
1121 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1123 template <class _Tp>
1124 typename add_lvalue_reference<_Tp>::type
1127 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1131 template <class _Tp>
1133 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1136 template <class _Tp>
1137 struct __unconstref {
1138 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1141 #ifndef _LIBCPP_CXX03_LANG
1142 template <class _Tp>
1143 using __uncvref_t = typename __uncvref<_Tp>::type;
1146 // __is_same_uncvref
1148 template <class _Tp, class _Up>
1149 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1150 typename __uncvref<_Up>::type> {};
1152 #if _LIBCPP_STD_VER > 17
1153 // aligned_union - same as __uncvref
1154 template <class _Tp>
1155 struct remove_cvref {
1156 using type = remove_cv_t<remove_reference_t<_Tp>>;
1159 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
1170 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;};
1171 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
1172 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
1173 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
1174 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1176 #if _LIBCPP_STD_VER > 11
1177 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1182 template <class _Tp,
1183 bool = __is_referenceable<_Tp>::value ||
1184 is_same<typename remove_cv<_Tp>::type, void>::value>
1185 struct __add_pointer_impl
1186 {typedef typename remove_reference<_Tp>::type* type;};
1187 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1188 {typedef _Tp type;};
1190 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1191 {typedef typename __add_pointer_impl<_Tp>::type type;};
1193 #if _LIBCPP_STD_VER > 11
1194 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1199 template <class _Tp, bool = is_integral<_Tp>::value>
1200 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1202 template <class _Tp>
1203 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1205 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1206 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1208 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1210 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1212 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1213 template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
1214 = is_signed<_Tp>::value;
1219 template <class _Tp, bool = is_integral<_Tp>::value>
1220 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1222 template <class _Tp>
1223 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1225 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1226 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1228 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1230 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1232 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1233 template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
1234 = is_unsigned<_Tp>::value;
1239 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1240 : public integral_constant<size_t, 0> {};
1241 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1242 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1243 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1244 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1246 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1247 template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
1253 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1254 : public integral_constant<size_t, 0> {};
1255 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1256 : public integral_constant<size_t, 0> {};
1257 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1258 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1259 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1260 : public integral_constant<size_t, _Np> {};
1261 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1262 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1264 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1265 template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
1266 = extent<_Tp, _Ip>::value;
1271 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1272 {typedef _Tp type;};
1273 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1274 {typedef _Tp type;};
1275 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1276 {typedef _Tp type;};
1278 #if _LIBCPP_STD_VER > 11
1279 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1282 // remove_all_extents
1284 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1285 {typedef _Tp type;};
1286 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1287 {typedef typename remove_all_extents<_Tp>::type type;};
1288 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1289 {typedef typename remove_all_extents<_Tp>::type type;};
1291 #if _LIBCPP_STD_VER > 11
1292 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1297 template <class _Up, bool>
1299 typedef typename remove_cv<_Up>::type type;
1302 template <class _Up>
1303 struct __decay<_Up, true> {
1305 typedef typename conditional
1307 is_array<_Up>::value,
1308 typename remove_extent<_Up>::type*,
1309 typename conditional
1311 is_function<_Up>::value,
1312 typename add_pointer<_Up>::type,
1313 typename remove_cv<_Up>::type
1318 template <class _Tp>
1319 struct _LIBCPP_TEMPLATE_VIS decay
1322 typedef typename remove_reference<_Tp>::type _Up;
1324 typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
1327 #if _LIBCPP_STD_VER > 11
1328 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1333 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
1334 : public integral_constant<bool, __is_abstract(_Tp)> {};
1336 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1337 template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
1338 = is_abstract<_Tp>::value;
1343 #if defined(_LIBCPP_HAS_IS_FINAL)
1344 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1345 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1347 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1348 __libcpp_is_final : public false_type {};
1351 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1352 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1353 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1356 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1357 template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
1358 = is_final<_Tp>::value;
1362 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1364 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1365 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
1367 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1368 template <class _Tp>
1369 constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
1372 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
1376 #ifdef _LIBCPP_HAS_IS_BASE_OF
1378 template <class _Bp, class _Dp>
1379 struct _LIBCPP_TEMPLATE_VIS is_base_of
1380 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1382 #else // _LIBCPP_HAS_IS_BASE_OF
1384 namespace __is_base_of_imp
1386 template <class _Tp>
1389 _Dst(const volatile _Tp &);
1391 template <class _Tp>
1394 operator const volatile _Tp &();
1395 template <class _Up> operator const _Dst<_Up> &();
1397 template <size_t> struct __one { typedef char type; };
1398 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1399 template <class _Bp, class _Dp> __two __test(...);
1402 template <class _Bp, class _Dp>
1403 struct _LIBCPP_TEMPLATE_VIS is_base_of
1404 : public integral_constant<bool, is_class<_Bp>::value &&
1405 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1407 #endif // _LIBCPP_HAS_IS_BASE_OF
1409 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1410 template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
1411 = is_base_of<_Bp, _Dp>::value;
1416 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1418 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1419 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1420 !is_abstract<_T2>::value> {};
1422 #else // __has_feature(is_convertible_to)
1424 namespace __is_convertible_imp
1426 template <class _Tp> void __test_convert(_Tp);
1428 template <class _From, class _To, class = void>
1429 struct __is_convertible_test : public false_type {};
1431 template <class _From, class _To>
1432 struct __is_convertible_test<_From, _To,
1433 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1436 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1437 bool _IsFunction = is_function<_Tp>::value,
1438 bool _IsVoid = is_void<_Tp>::value>
1439 struct __is_array_function_or_void {enum {value = 0};};
1440 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1441 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1442 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1445 template <class _Tp,
1446 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1447 struct __is_convertible_check
1449 static const size_t __v = 0;
1452 template <class _Tp>
1453 struct __is_convertible_check<_Tp, 0>
1455 static const size_t __v = sizeof(_Tp);
1458 template <class _T1, class _T2,
1459 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1460 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1461 struct __is_convertible
1462 : public integral_constant<bool,
1463 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1464 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1465 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1466 && (!is_const<typename remove_reference<_T2>::type>::value
1467 || is_volatile<typename remove_reference<_T2>::type>::value)
1468 && (is_same<typename remove_cv<_T1>::type,
1469 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1470 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1475 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1476 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1477 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1478 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1480 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1481 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1482 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1483 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1485 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1486 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1487 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1488 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1490 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1491 : public __is_convertible<_T1, _T2>
1493 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1494 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1497 #endif // __has_feature(is_convertible_to)
1499 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1500 template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
1501 = is_convertible<_From, _To>::value;
1506 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1508 template <class _Tp>
1509 struct _LIBCPP_TEMPLATE_VIS is_empty
1510 : public integral_constant<bool, __is_empty(_Tp)> {};
1512 #else // __has_feature(is_empty)
1514 template <class _Tp>
1526 template <class _Tp, bool = is_class<_Tp>::value>
1527 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1529 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1531 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1533 #endif // __has_feature(is_empty)
1535 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1536 template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
1537 = is_empty<_Tp>::value;
1542 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
1544 template <class _Tp>
1545 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1546 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1550 template<typename _Tp> char &__is_polymorphic_impl(
1551 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1553 template<typename _Tp> __two &__is_polymorphic_impl(...);
1555 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1556 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1558 #endif // __has_feature(is_polymorphic)
1560 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1561 template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
1562 = is_polymorphic<_Tp>::value;
1565 // has_virtual_destructor
1567 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1569 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1570 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1574 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1575 : public false_type {};
1579 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1580 template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1581 = has_virtual_destructor<_Tp>::value;
1586 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1587 : public integral_constant<size_t, __alignof__(_Tp)> {};
1589 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1590 template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
1591 = alignment_of<_Tp>::value;
1596 template <class _Hp, class _Tp>
1605 #ifndef _LIBCPP_CXX03_LANG
1607 __nat(const __nat&) = delete;
1608 __nat& operator=(const __nat&) = delete;
1613 template <class _Tp>
1616 static const size_t value = alignment_of<_Tp>::value;
1620 struct __struct_double {long double __lx;};
1621 struct __struct_double4 {double __lx[4];};
1624 __type_list<__align_type<unsigned char>,
1625 __type_list<__align_type<unsigned short>,
1626 __type_list<__align_type<unsigned int>,
1627 __type_list<__align_type<unsigned long>,
1628 __type_list<__align_type<unsigned long long>,
1629 __type_list<__align_type<double>,
1630 __type_list<__align_type<long double>,
1631 __type_list<__align_type<__struct_double>,
1632 __type_list<__align_type<__struct_double4>,
1633 __type_list<__align_type<int*>,
1635 > > > > > > > > > > __all_types;
1637 template <class _TL, size_t _Align> struct __find_pod;
1639 template <class _Hp, size_t _Align>
1640 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1642 typedef typename conditional<
1643 _Align == _Hp::value,
1649 template <class _Hp, class _Tp, size_t _Align>
1650 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1652 typedef typename conditional<
1653 _Align == _Hp::value,
1655 typename __find_pod<_Tp, _Align>::type
1659 template <class _TL, size_t _Len> struct __find_max_align;
1661 template <class _Hp, size_t _Len>
1662 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1664 template <size_t _Len, size_t _A1, size_t _A2>
1665 struct __select_align
1668 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1669 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1671 static const size_t value = _Len < __max ? __min : __max;
1674 template <class _Hp, class _Tp, size_t _Len>
1675 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1676 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1678 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1679 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1681 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1682 static_assert(!is_void<_Aligner>::value, "");
1686 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1690 #if _LIBCPP_STD_VER > 11
1691 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1692 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1695 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1696 template <size_t _Len>\
1697 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1699 struct _ALIGNAS(n) type\
1701 unsigned char __lx[(_Len + n - 1)/n * n];\
1705 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1706 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1707 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1708 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1709 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1710 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1711 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1712 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1713 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1714 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1715 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1716 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1717 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1718 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1719 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1720 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1721 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1722 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1724 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1726 #ifndef _LIBCPP_HAS_NO_VARIADICS
1730 template <size_t _I0, size_t ..._In>
1731 struct __static_max;
1733 template <size_t _I0>
1734 struct __static_max<_I0>
1736 static const size_t value = _I0;
1739 template <size_t _I0, size_t _I1, size_t ..._In>
1740 struct __static_max<_I0, _I1, _In...>
1742 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1743 __static_max<_I1, _In...>::value;
1746 template <size_t _Len, class _Type0, class ..._Types>
1747 struct aligned_union
1749 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1750 __alignof__(_Types)...>::value;
1751 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1752 sizeof(_Types)...>::value;
1753 typedef typename aligned_storage<__len, alignment_value>::type type;
1756 #if _LIBCPP_STD_VER > 11
1757 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1760 #endif // _LIBCPP_HAS_NO_VARIADICS
1762 template <class _Tp>
1763 struct __numeric_type
1765 static void __test(...);
1766 static float __test(float);
1767 static double __test(char);
1768 static double __test(int);
1769 static double __test(unsigned);
1770 static double __test(long);
1771 static double __test(unsigned long);
1772 static double __test(long long);
1773 static double __test(unsigned long long);
1774 static double __test(double);
1775 static long double __test(long double);
1777 typedef decltype(__test(declval<_Tp>())) type;
1778 static const bool value = !is_same<type, void>::value;
1782 struct __numeric_type<void>
1784 static const bool value = true;
1789 template <class _A1, class _A2 = void, class _A3 = void,
1790 bool = __numeric_type<_A1>::value &&
1791 __numeric_type<_A2>::value &&
1792 __numeric_type<_A3>::value>
1796 static const bool value = false;
1799 template <class _A1, class _A2, class _A3>
1800 class __promote_imp<_A1, _A2, _A3, true>
1803 typedef typename __promote_imp<_A1>::type __type1;
1804 typedef typename __promote_imp<_A2>::type __type2;
1805 typedef typename __promote_imp<_A3>::type __type3;
1807 typedef decltype(__type1() + __type2() + __type3()) type;
1808 static const bool value = true;
1811 template <class _A1, class _A2>
1812 class __promote_imp<_A1, _A2, void, true>
1815 typedef typename __promote_imp<_A1>::type __type1;
1816 typedef typename __promote_imp<_A2>::type __type2;
1818 typedef decltype(__type1() + __type2()) type;
1819 static const bool value = true;
1822 template <class _A1>
1823 class __promote_imp<_A1, void, void, true>
1826 typedef typename __numeric_type<_A1>::type type;
1827 static const bool value = true;
1830 template <class _A1, class _A2 = void, class _A3 = void>
1831 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1833 // make_signed / make_unsigned
1836 __type_list<signed char,
1837 __type_list<signed short,
1838 __type_list<signed int,
1839 __type_list<signed long,
1840 __type_list<signed long long,
1841 #ifndef _LIBCPP_HAS_NO_INT128
1842 __type_list<__int128_t,
1845 #ifndef _LIBCPP_HAS_NO_INT128
1848 > > > > > __signed_types;
1851 __type_list<unsigned char,
1852 __type_list<unsigned short,
1853 __type_list<unsigned int,
1854 __type_list<unsigned long,
1855 __type_list<unsigned long long,
1856 #ifndef _LIBCPP_HAS_NO_INT128
1857 __type_list<__uint128_t,
1860 #ifndef _LIBCPP_HAS_NO_INT128
1863 > > > > > __unsigned_types;
1865 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1867 template <class _Hp, class _Tp, size_t _Size>
1868 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1873 template <class _Hp, class _Tp, size_t _Size>
1874 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1876 typedef typename __find_first<_Tp, _Size>::type type;
1879 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1880 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1886 template <class _Tp, class _Up>
1887 struct __apply_cv<_Tp, _Up, true, false>
1889 typedef const _Up type;
1892 template <class _Tp, class _Up>
1893 struct __apply_cv<_Tp, _Up, false, true>
1895 typedef volatile _Up type;
1898 template <class _Tp, class _Up>
1899 struct __apply_cv<_Tp, _Up, true, true>
1901 typedef const volatile _Up type;
1904 template <class _Tp, class _Up>
1905 struct __apply_cv<_Tp&, _Up, false, false>
1910 template <class _Tp, class _Up>
1911 struct __apply_cv<_Tp&, _Up, true, false>
1913 typedef const _Up& type;
1916 template <class _Tp, class _Up>
1917 struct __apply_cv<_Tp&, _Up, false, true>
1919 typedef volatile _Up& type;
1922 template <class _Tp, class _Up>
1923 struct __apply_cv<_Tp&, _Up, true, true>
1925 typedef const volatile _Up& type;
1928 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1929 struct __make_signed {};
1931 template <class _Tp>
1932 struct __make_signed<_Tp, true>
1934 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1937 template <> struct __make_signed<bool, true> {};
1938 template <> struct __make_signed< signed short, true> {typedef short type;};
1939 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1940 template <> struct __make_signed< signed int, true> {typedef int type;};
1941 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1942 template <> struct __make_signed< signed long, true> {typedef long type;};
1943 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1944 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1945 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1946 #ifndef _LIBCPP_HAS_NO_INT128
1947 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1948 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1951 template <class _Tp>
1952 struct _LIBCPP_TEMPLATE_VIS make_signed
1954 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1957 #if _LIBCPP_STD_VER > 11
1958 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1961 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1962 struct __make_unsigned {};
1964 template <class _Tp>
1965 struct __make_unsigned<_Tp, true>
1967 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1970 template <> struct __make_unsigned<bool, true> {};
1971 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1972 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1973 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1974 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1975 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1976 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1977 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1978 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1979 #ifndef _LIBCPP_HAS_NO_INT128
1980 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1981 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1984 template <class _Tp>
1985 struct _LIBCPP_TEMPLATE_VIS make_unsigned
1987 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1990 #if _LIBCPP_STD_VER > 11
1991 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1994 #ifdef _LIBCPP_HAS_NO_VARIADICS
1996 template <class _Tp, class _Up = void, class _Vp = void>
1997 struct _LIBCPP_TEMPLATE_VIS common_type
2000 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
2004 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void>
2010 template <class _Tp>
2011 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
2014 typedef typename common_type<_Tp, _Tp>::type type;
2017 template <class _Tp, class _Up>
2018 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
2020 typedef typename decay<decltype(
2021 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2025 #else // _LIBCPP_HAS_NO_VARIADICS
2027 // bullet 1 - sizeof...(Tp) == 0
2029 template <class ..._Tp>
2030 struct _LIBCPP_TEMPLATE_VIS common_type {};
2032 // bullet 2 - sizeof...(Tp) == 1
2034 template <class _Tp>
2035 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
2036 : public common_type<_Tp, _Tp> {};
2038 // bullet 3 - sizeof...(Tp) == 2
2040 template <class _Tp, class _Up, class = void>
2041 struct __common_type2_imp {};
2043 template <class _Tp, class _Up>
2044 struct __common_type2_imp<_Tp, _Up,
2045 typename __void_t<decltype(
2046 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2049 typedef typename decay<decltype(
2050 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2054 template <class _Tp, class _Up,
2055 class _DTp = typename decay<_Tp>::type,
2056 class _DUp = typename decay<_Up>::type>
2057 using __common_type2 =
2058 typename conditional<
2059 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
2060 __common_type2_imp<_Tp, _Up>,
2061 common_type<_DTp, _DUp>
2064 template <class _Tp, class _Up>
2065 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2066 : __common_type2<_Tp, _Up> {};
2068 // bullet 4 - sizeof...(Tp) > 2
2070 template <class ...Tp> struct __common_types;
2072 template <class, class = void>
2073 struct __common_type_impl {};
2075 template <class _Tp, class _Up>
2076 struct __common_type_impl<
2077 __common_types<_Tp, _Up>,
2078 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2080 typedef typename common_type<_Tp, _Up>::type type;
2083 template <class _Tp, class _Up, class ..._Vp>
2084 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2085 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2086 : __common_type_impl<
2087 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
2092 template <class _Tp, class _Up, class ..._Vp>
2093 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
2094 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2096 #if _LIBCPP_STD_VER > 11
2097 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2100 #endif // _LIBCPP_HAS_NO_VARIADICS
2104 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2106 template <class _Tp, class _Arg>
2107 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2108 __is_assignable_test(int);
2110 template <class, class>
2111 false_type __is_assignable_test(...);
2114 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2115 struct __is_assignable_imp
2116 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2118 template <class _Tp, class _Arg>
2119 struct __is_assignable_imp<_Tp, _Arg, true>
2124 template <class _Tp, class _Arg>
2125 struct is_assignable
2126 : public __is_assignable_imp<_Tp, _Arg> {};
2128 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2129 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
2130 = is_assignable<_Tp, _Arg>::value;
2133 // is_copy_assignable
2135 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2136 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2137 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2139 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2140 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2141 = is_copy_assignable<_Tp>::value;
2144 // is_move_assignable
2146 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2147 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2148 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2149 typename add_rvalue_reference<_Tp>::type> {};
2151 : public is_copy_assignable<_Tp> {};
2154 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2155 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
2156 = is_move_assignable<_Tp>::value;
2161 // if it's a reference, return true
2162 // if it's a function, return false
2163 // if it's void, return false
2164 // if it's an array of unknown bound, return false
2165 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2166 // where _Up is remove_all_extents<_Tp>::type
2169 struct __is_destructible_apply { typedef int type; };
2171 template <typename _Tp>
2172 struct __is_destructor_wellformed {
2173 template <typename _Tp1>
2174 static char __test (
2175 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2178 template <typename _Tp1>
2179 static __two __test (...);
2181 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2184 template <class _Tp, bool>
2185 struct __destructible_imp;
2187 template <class _Tp>
2188 struct __destructible_imp<_Tp, false>
2189 : public _VSTD::integral_constant<bool,
2190 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2192 template <class _Tp>
2193 struct __destructible_imp<_Tp, true>
2194 : public _VSTD::true_type {};
2196 template <class _Tp, bool>
2197 struct __destructible_false;
2199 template <class _Tp>
2200 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2202 template <class _Tp>
2203 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2205 template <class _Tp>
2206 struct is_destructible
2207 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2209 template <class _Tp>
2210 struct is_destructible<_Tp[]>
2211 : public _VSTD::false_type {};
2214 struct is_destructible<void>
2215 : public _VSTD::false_type {};
2217 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2218 template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
2219 = is_destructible<_Tp>::value;
2224 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2226 template <class _Tp>
2227 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2228 typename remove_reference<_Tp>::type&&
2229 move(_Tp&& __t) _NOEXCEPT
2231 typedef typename remove_reference<_Tp>::type _Up;
2232 return static_cast<_Up&&>(__t);
2235 template <class _Tp>
2236 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2238 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2240 return static_cast<_Tp&&>(__t);
2243 template <class _Tp>
2244 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2246 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2248 static_assert(!is_lvalue_reference<_Tp>::value,
2249 "can not forward an rvalue as an lvalue");
2250 return static_cast<_Tp&&>(__t);
2253 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2255 template <class _Tp>
2256 inline _LIBCPP_INLINE_VISIBILITY
2263 template <class _Tp>
2264 inline _LIBCPP_INLINE_VISIBILITY
2266 move(const _Tp& __t)
2271 template <class _Tp>
2272 inline _LIBCPP_INLINE_VISIBILITY
2274 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2280 template <class _Tp>
2283 typedef typename remove_reference<_Tp>::type _Trr;
2286 _LIBCPP_INLINE_VISIBILITY
2287 _Trr* operator->() {return &t_;}
2288 _LIBCPP_INLINE_VISIBILITY
2289 explicit __rv(_Trr& __t) : t_(__t) {}
2292 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2294 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2296 template <class _Tp>
2297 inline _LIBCPP_INLINE_VISIBILITY
2298 typename decay<_Tp>::type
2299 __decay_copy(_Tp&& __t)
2301 return _VSTD::forward<_Tp>(__t);
2306 template <class _Tp>
2307 inline _LIBCPP_INLINE_VISIBILITY
2308 typename decay<_Tp>::type
2309 __decay_copy(const _Tp& __t)
2311 return _VSTD::forward<_Tp>(__t);
2316 #ifndef _LIBCPP_HAS_NO_VARIADICS
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..., ...), true, false>
2329 typedef _Class _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..., ...) const, true, false>
2345 typedef _Class const _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..., ...) volatile, true, false>
2361 typedef _Class 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 template <class _Rp, class _Class, class ..._Param>
2375 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2377 typedef _Class const volatile _ClassType;
2378 typedef _Rp _ReturnType;
2379 typedef _Rp (_FnType) (_Param..., ...);
2382 #if __has_feature(cxx_reference_qualified_functions) || \
2383 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2385 template <class _Rp, class _Class, class ..._Param>
2386 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2388 typedef _Class& _ClassType;
2389 typedef _Rp _ReturnType;
2390 typedef _Rp (_FnType) (_Param...);
2393 template <class _Rp, class _Class, class ..._Param>
2394 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2396 typedef _Class& _ClassType;
2397 typedef _Rp _ReturnType;
2398 typedef _Rp (_FnType) (_Param..., ...);
2401 template <class _Rp, class _Class, class ..._Param>
2402 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2404 typedef _Class const& _ClassType;
2405 typedef _Rp _ReturnType;
2406 typedef _Rp (_FnType) (_Param...);
2409 template <class _Rp, class _Class, class ..._Param>
2410 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2412 typedef _Class const& _ClassType;
2413 typedef _Rp _ReturnType;
2414 typedef _Rp (_FnType) (_Param..., ...);
2417 template <class _Rp, class _Class, class ..._Param>
2418 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2420 typedef _Class volatile& _ClassType;
2421 typedef _Rp _ReturnType;
2422 typedef _Rp (_FnType) (_Param...);
2425 template <class _Rp, class _Class, class ..._Param>
2426 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2428 typedef _Class volatile& _ClassType;
2429 typedef _Rp _ReturnType;
2430 typedef _Rp (_FnType) (_Param..., ...);
2433 template <class _Rp, class _Class, class ..._Param>
2434 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2436 typedef _Class const volatile& _ClassType;
2437 typedef _Rp _ReturnType;
2438 typedef _Rp (_FnType) (_Param...);
2441 template <class _Rp, class _Class, class ..._Param>
2442 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2444 typedef _Class const volatile& _ClassType;
2445 typedef _Rp _ReturnType;
2446 typedef _Rp (_FnType) (_Param..., ...);
2449 template <class _Rp, class _Class, class ..._Param>
2450 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2452 typedef _Class&& _ClassType;
2453 typedef _Rp _ReturnType;
2454 typedef _Rp (_FnType) (_Param...);
2457 template <class _Rp, class _Class, class ..._Param>
2458 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2460 typedef _Class&& _ClassType;
2461 typedef _Rp _ReturnType;
2462 typedef _Rp (_FnType) (_Param..., ...);
2465 template <class _Rp, class _Class, class ..._Param>
2466 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2468 typedef _Class const&& _ClassType;
2469 typedef _Rp _ReturnType;
2470 typedef _Rp (_FnType) (_Param...);
2473 template <class _Rp, class _Class, class ..._Param>
2474 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2476 typedef _Class const&& _ClassType;
2477 typedef _Rp _ReturnType;
2478 typedef _Rp (_FnType) (_Param..., ...);
2481 template <class _Rp, class _Class, class ..._Param>
2482 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2484 typedef _Class volatile&& _ClassType;
2485 typedef _Rp _ReturnType;
2486 typedef _Rp (_FnType) (_Param...);
2489 template <class _Rp, class _Class, class ..._Param>
2490 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2492 typedef _Class volatile&& _ClassType;
2493 typedef _Rp _ReturnType;
2494 typedef _Rp (_FnType) (_Param..., ...);
2497 template <class _Rp, class _Class, class ..._Param>
2498 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2500 typedef _Class const volatile&& _ClassType;
2501 typedef _Rp _ReturnType;
2502 typedef _Rp (_FnType) (_Param...);
2505 template <class _Rp, class _Class, class ..._Param>
2506 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2508 typedef _Class const volatile&& _ClassType;
2509 typedef _Rp _ReturnType;
2510 typedef _Rp (_FnType) (_Param..., ...);
2513 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2515 #else // _LIBCPP_HAS_NO_VARIADICS
2517 template <class _Rp, class _Class>
2518 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2520 typedef _Class _ClassType;
2521 typedef _Rp _ReturnType;
2522 typedef _Rp (_FnType) ();
2525 template <class _Rp, class _Class>
2526 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2528 typedef _Class _ClassType;
2529 typedef _Rp _ReturnType;
2530 typedef _Rp (_FnType) (...);
2533 template <class _Rp, class _Class, class _P0>
2534 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2536 typedef _Class _ClassType;
2537 typedef _Rp _ReturnType;
2538 typedef _Rp (_FnType) (_P0);
2541 template <class _Rp, class _Class, class _P0>
2542 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2544 typedef _Class _ClassType;
2545 typedef _Rp _ReturnType;
2546 typedef _Rp (_FnType) (_P0, ...);
2549 template <class _Rp, class _Class, class _P0, class _P1>
2550 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2552 typedef _Class _ClassType;
2553 typedef _Rp _ReturnType;
2554 typedef _Rp (_FnType) (_P0, _P1);
2557 template <class _Rp, class _Class, class _P0, class _P1>
2558 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2560 typedef _Class _ClassType;
2561 typedef _Rp _ReturnType;
2562 typedef _Rp (_FnType) (_P0, _P1, ...);
2565 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2566 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2568 typedef _Class _ClassType;
2569 typedef _Rp _ReturnType;
2570 typedef _Rp (_FnType) (_P0, _P1, _P2);
2573 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2574 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2576 typedef _Class _ClassType;
2577 typedef _Rp _ReturnType;
2578 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2581 template <class _Rp, class _Class>
2582 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2584 typedef _Class const _ClassType;
2585 typedef _Rp _ReturnType;
2586 typedef _Rp (_FnType) ();
2589 template <class _Rp, class _Class>
2590 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2592 typedef _Class const _ClassType;
2593 typedef _Rp _ReturnType;
2594 typedef _Rp (_FnType) (...);
2597 template <class _Rp, class _Class, class _P0>
2598 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2600 typedef _Class const _ClassType;
2601 typedef _Rp _ReturnType;
2602 typedef _Rp (_FnType) (_P0);
2605 template <class _Rp, class _Class, class _P0>
2606 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2608 typedef _Class const _ClassType;
2609 typedef _Rp _ReturnType;
2610 typedef _Rp (_FnType) (_P0, ...);
2613 template <class _Rp, class _Class, class _P0, class _P1>
2614 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2616 typedef _Class const _ClassType;
2617 typedef _Rp _ReturnType;
2618 typedef _Rp (_FnType) (_P0, _P1);
2621 template <class _Rp, class _Class, class _P0, class _P1>
2622 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2624 typedef _Class const _ClassType;
2625 typedef _Rp _ReturnType;
2626 typedef _Rp (_FnType) (_P0, _P1, ...);
2629 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2630 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2632 typedef _Class const _ClassType;
2633 typedef _Rp _ReturnType;
2634 typedef _Rp (_FnType) (_P0, _P1, _P2);
2637 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2638 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2640 typedef _Class const _ClassType;
2641 typedef _Rp _ReturnType;
2642 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2645 template <class _Rp, class _Class>
2646 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2648 typedef _Class volatile _ClassType;
2649 typedef _Rp _ReturnType;
2650 typedef _Rp (_FnType) ();
2653 template <class _Rp, class _Class>
2654 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2656 typedef _Class volatile _ClassType;
2657 typedef _Rp _ReturnType;
2658 typedef _Rp (_FnType) (...);
2661 template <class _Rp, class _Class, class _P0>
2662 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2664 typedef _Class volatile _ClassType;
2665 typedef _Rp _ReturnType;
2666 typedef _Rp (_FnType) (_P0);
2669 template <class _Rp, class _Class, class _P0>
2670 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2672 typedef _Class volatile _ClassType;
2673 typedef _Rp _ReturnType;
2674 typedef _Rp (_FnType) (_P0, ...);
2677 template <class _Rp, class _Class, class _P0, class _P1>
2678 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2680 typedef _Class volatile _ClassType;
2681 typedef _Rp _ReturnType;
2682 typedef _Rp (_FnType) (_P0, _P1);
2685 template <class _Rp, class _Class, class _P0, class _P1>
2686 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2688 typedef _Class volatile _ClassType;
2689 typedef _Rp _ReturnType;
2690 typedef _Rp (_FnType) (_P0, _P1, ...);
2693 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2694 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2696 typedef _Class volatile _ClassType;
2697 typedef _Rp _ReturnType;
2698 typedef _Rp (_FnType) (_P0, _P1, _P2);
2701 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2702 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2704 typedef _Class volatile _ClassType;
2705 typedef _Rp _ReturnType;
2706 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2709 template <class _Rp, class _Class>
2710 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2712 typedef _Class const volatile _ClassType;
2713 typedef _Rp _ReturnType;
2714 typedef _Rp (_FnType) ();
2717 template <class _Rp, class _Class>
2718 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2720 typedef _Class const volatile _ClassType;
2721 typedef _Rp _ReturnType;
2722 typedef _Rp (_FnType) (...);
2725 template <class _Rp, class _Class, class _P0>
2726 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2728 typedef _Class const volatile _ClassType;
2729 typedef _Rp _ReturnType;
2730 typedef _Rp (_FnType) (_P0);
2733 template <class _Rp, class _Class, class _P0>
2734 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2736 typedef _Class const volatile _ClassType;
2737 typedef _Rp _ReturnType;
2738 typedef _Rp (_FnType) (_P0, ...);
2741 template <class _Rp, class _Class, class _P0, class _P1>
2742 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2744 typedef _Class const volatile _ClassType;
2745 typedef _Rp _ReturnType;
2746 typedef _Rp (_FnType) (_P0, _P1);
2749 template <class _Rp, class _Class, class _P0, class _P1>
2750 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2752 typedef _Class const volatile _ClassType;
2753 typedef _Rp _ReturnType;
2754 typedef _Rp (_FnType) (_P0, _P1, ...);
2757 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2758 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2760 typedef _Class const volatile _ClassType;
2761 typedef _Rp _ReturnType;
2762 typedef _Rp (_FnType) (_P0, _P1, _P2);
2765 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2766 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2768 typedef _Class const volatile _ClassType;
2769 typedef _Rp _ReturnType;
2770 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2773 #endif // _LIBCPP_HAS_NO_VARIADICS
2775 template <class _Rp, class _Class>
2776 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2778 typedef _Class _ClassType;
2779 typedef _Rp _ReturnType;
2782 template <class _MP>
2783 struct __member_pointer_traits
2784 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2785 is_member_function_pointer<_MP>::value,
2786 is_member_object_pointer<_MP>::value>
2788 // typedef ... _ClassType;
2789 // typedef ... _ReturnType;
2790 // typedef ... _FnType;
2794 template <class _DecayedFp>
2795 struct __member_pointer_class_type {};
2797 template <class _Ret, class _ClassType>
2798 struct __member_pointer_class_type<_Ret _ClassType::*> {
2799 typedef _ClassType type;
2804 template <class _Callable> class result_of;
2806 #ifdef _LIBCPP_HAS_NO_VARIADICS
2808 template <class _Fn, bool, bool>
2813 template <class _Fn>
2814 class __result_of<_Fn(), true, false>
2817 typedef decltype(declval<_Fn>()()) type;
2820 template <class _Fn, class _A0>
2821 class __result_of<_Fn(_A0), true, false>
2824 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2827 template <class _Fn, class _A0, class _A1>
2828 class __result_of<_Fn(_A0, _A1), true, false>
2831 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2834 template <class _Fn, class _A0, class _A1, class _A2>
2835 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2838 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2841 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2842 struct __result_of_mp;
2844 // member function pointer
2846 template <class _MP, class _Tp>
2847 struct __result_of_mp<_MP, _Tp, true>
2848 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2852 // member data pointer
2854 template <class _MP, class _Tp, bool>
2855 struct __result_of_mdp;
2857 template <class _Rp, class _Class, class _Tp>
2858 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2860 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2863 template <class _Rp, class _Class, class _Tp>
2864 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2866 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2869 template <class _Rp, class _Class, class _Tp>
2870 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2871 : public __result_of_mdp<_Rp _Class::*, _Tp,
2872 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2878 template <class _Fn, class _Tp>
2879 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2880 : public __result_of_mp<typename remove_reference<_Fn>::type,
2882 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2886 template <class _Fn, class _Tp, class _A0>
2887 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2888 : public __result_of_mp<typename remove_reference<_Fn>::type,
2890 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2894 template <class _Fn, class _Tp, class _A0, class _A1>
2895 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2896 : public __result_of_mp<typename remove_reference<_Fn>::type,
2898 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2902 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2903 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2904 : public __result_of_mp<typename remove_reference<_Fn>::type,
2906 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2912 template <class _Fn>
2913 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2914 : public __result_of<_Fn(),
2915 is_class<typename remove_reference<_Fn>::type>::value ||
2916 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2917 is_member_pointer<typename remove_reference<_Fn>::type>::value
2922 template <class _Fn, class _A0>
2923 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2924 : public __result_of<_Fn(_A0),
2925 is_class<typename remove_reference<_Fn>::type>::value ||
2926 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2927 is_member_pointer<typename remove_reference<_Fn>::type>::value
2932 template <class _Fn, class _A0, class _A1>
2933 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2934 : public __result_of<_Fn(_A0, _A1),
2935 is_class<typename remove_reference<_Fn>::type>::value ||
2936 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2937 is_member_pointer<typename remove_reference<_Fn>::type>::value
2942 template <class _Fn, class _A0, class _A1, class _A2>
2943 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
2944 : public __result_of<_Fn(_A0, _A1, _A2),
2945 is_class<typename remove_reference<_Fn>::type>::value ||
2946 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2947 is_member_pointer<typename remove_reference<_Fn>::type>::value
2952 #endif // _LIBCPP_HAS_NO_VARIADICS
2954 // template <class T, class... Args> struct is_constructible;
2956 namespace __is_construct
2961 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
2962 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
2964 template <class _Tp, class... _Args>
2965 struct __libcpp_is_constructible;
2967 template <class _To, class _From>
2968 struct __is_invalid_base_to_derived_cast {
2969 static_assert(is_reference<_To>::value, "Wrong specialization");
2970 using _RawFrom = __uncvref_t<_From>;
2971 using _RawTo = __uncvref_t<_To>;
2972 static const bool value = __lazy_and<
2973 __lazy_not<is_same<_RawFrom, _RawTo>>,
2974 is_base_of<_RawFrom, _RawTo>,
2975 __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
2979 template <class _To, class _From>
2980 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
2981 static_assert(is_reference<_To>::value, "Wrong specialization");
2984 template <class _ToRef, class _FromRef>
2985 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
2986 using _RawFrom = __uncvref_t<_FromRef>;
2987 using _RawTo = __uncvref_t<_ToRef>;
2988 static const bool value = __lazy_and<
2989 __lazy_not<is_function<_RawTo>>,
2991 is_same<_RawFrom, _RawTo>,
2992 is_base_of<_RawTo, _RawFrom>>
2996 struct __is_constructible_helper
2998 template <class _To>
2999 static void __eat(_To);
3001 // This overload is needed to work around a Clang bug that disallows
3002 // static_cast<T&&>(e) for non-reference-compatible types.
3003 // Example: static_cast<int&&>(declval<double>());
3004 // NOTE: The static_cast implementation below is required to support
3005 // classes with explicit conversion operators.
3006 template <class _To, class _From,
3007 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
3008 static true_type __test_cast(int);
3010 template <class _To, class _From,
3011 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
3012 static integral_constant<bool,
3013 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
3014 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
3015 > __test_cast(long);
3017 template <class, class>
3018 static false_type __test_cast(...);
3020 template <class _Tp, class ..._Args,
3021 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
3022 static true_type __test_nary(int);
3023 template <class _Tp, class...>
3024 static false_type __test_nary(...);
3026 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
3027 static is_destructible<_Tp> __test_unary(int);
3028 template <class, class>
3029 static false_type __test_unary(...);
3032 template <class _Tp, bool = is_void<_Tp>::value>
3033 struct __is_default_constructible
3034 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
3037 template <class _Tp>
3038 struct __is_default_constructible<_Tp, true> : false_type {};
3040 template <class _Tp>
3041 struct __is_default_constructible<_Tp[], false> : false_type {};
3043 template <class _Tp, size_t _Nx>
3044 struct __is_default_constructible<_Tp[_Nx], false>
3045 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3047 template <class _Tp, class... _Args>
3048 struct __libcpp_is_constructible
3050 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3051 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3055 template <class _Tp>
3056 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3058 template <class _Tp, class _A0>
3059 struct __libcpp_is_constructible<_Tp, _A0>
3060 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3063 template <class _Tp, class _A0>
3064 struct __libcpp_is_constructible<_Tp&, _A0>
3065 : public decltype(__is_constructible_helper::
3066 __test_cast<_Tp&, _A0>(0))
3069 template <class _Tp, class _A0>
3070 struct __libcpp_is_constructible<_Tp&&, _A0>
3071 : public decltype(__is_constructible_helper::
3072 __test_cast<_Tp&&, _A0>(0))
3077 #if __has_feature(is_constructible)
3078 template <class _Tp, class ..._Args>
3079 struct _LIBCPP_TEMPLATE_VIS is_constructible
3080 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3082 #elif !defined(_LIBCPP_CXX03_LANG)
3083 template <class _Tp, class... _Args>
3084 struct _LIBCPP_TEMPLATE_VIS is_constructible
3085 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3087 // template <class T> struct is_constructible0;
3089 // main is_constructible0 test
3091 template <class _Tp>
3092 decltype((_Tp(), true_type()))
3093 __is_constructible0_test(_Tp&);
3096 __is_constructible0_test(__any);
3098 template <class _Tp, class _A0>
3099 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3100 __is_constructible1_test(_Tp&, _A0&);
3102 template <class _A0>
3104 __is_constructible1_test(__any, _A0&);
3106 template <class _Tp, class _A0, class _A1>
3107 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3108 __is_constructible2_test(_Tp&, _A0&, _A1&);
3110 template <class _A0, class _A1>
3112 __is_constructible2_test(__any, _A0&, _A1&);
3114 template <bool, class _Tp>
3115 struct __is_constructible0_imp // false, _Tp is not a scalar
3116 : public common_type
3118 decltype(__is_constructible0_test(declval<_Tp&>()))
3122 template <bool, class _Tp, class _A0>
3123 struct __is_constructible1_imp // false, _Tp is not a scalar
3124 : public common_type
3126 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3130 template <bool, class _Tp, class _A0, class _A1>
3131 struct __is_constructible2_imp // false, _Tp is not a scalar
3132 : public common_type
3134 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3138 // handle scalars and reference types
3140 // Scalars are default constructible, references are not
3142 template <class _Tp>
3143 struct __is_constructible0_imp<true, _Tp>
3144 : public is_scalar<_Tp>
3147 template <class _Tp, class _A0>
3148 struct __is_constructible1_imp<true, _Tp, _A0>
3149 : public is_convertible<_A0, _Tp>
3152 template <class _Tp, class _A0, class _A1>
3153 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3157 // Treat scalars and reference types separately
3159 template <bool, class _Tp>
3160 struct __is_constructible0_void_check
3161 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3165 template <bool, class _Tp, class _A0>
3166 struct __is_constructible1_void_check
3167 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3171 template <bool, class _Tp, class _A0, class _A1>
3172 struct __is_constructible2_void_check
3173 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3177 // If any of T or Args is void, is_constructible should be false
3179 template <class _Tp>
3180 struct __is_constructible0_void_check<true, _Tp>
3184 template <class _Tp, class _A0>
3185 struct __is_constructible1_void_check<true, _Tp, _A0>
3189 template <class _Tp, class _A0, class _A1>
3190 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3194 // is_constructible entry point
3196 template <class _Tp, class _A0 = __is_construct::__nat,
3197 class _A1 = __is_construct::__nat>
3198 struct _LIBCPP_TEMPLATE_VIS is_constructible
3199 : public __is_constructible2_void_check<is_void<_Tp>::value
3200 || is_abstract<_Tp>::value
3201 || is_function<_Tp>::value
3202 || is_void<_A0>::value
3203 || is_void<_A1>::value,
3207 template <class _Tp>
3208 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3209 : public __is_constructible0_void_check<is_void<_Tp>::value
3210 || is_abstract<_Tp>::value
3211 || is_function<_Tp>::value,
3215 template <class _Tp, class _A0>
3216 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
3217 : public __is_constructible1_void_check<is_void<_Tp>::value
3218 || is_abstract<_Tp>::value
3219 || is_function<_Tp>::value
3220 || is_void<_A0>::value,
3224 // Array types are default constructible if their element type
3225 // is default constructible
3227 template <class _Ap, size_t _Np>
3228 struct __is_constructible0_imp<false, _Ap[_Np]>
3229 : public is_constructible<typename remove_all_extents<_Ap>::type>
3232 template <class _Ap, size_t _Np, class _A0>
3233 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3237 template <class _Ap, size_t _Np, class _A0, class _A1>
3238 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3242 // Incomplete array types are not constructible
3244 template <class _Ap>
3245 struct __is_constructible0_imp<false, _Ap[]>
3249 template <class _Ap, class _A0>
3250 struct __is_constructible1_imp<false, _Ap[], _A0>
3254 template <class _Ap, class _A0, class _A1>
3255 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3259 #endif // __has_feature(is_constructible)
3262 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3263 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
3264 = is_constructible<_Tp, _Args...>::value;
3267 // is_default_constructible
3269 template <class _Tp>
3270 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3271 : public is_constructible<_Tp>
3274 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3275 template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
3276 = is_default_constructible<_Tp>::value;
3279 // is_copy_constructible
3281 template <class _Tp>
3282 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3283 : public is_constructible<_Tp,
3284 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3286 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3287 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3288 = is_copy_constructible<_Tp>::value;
3291 // is_move_constructible
3293 template <class _Tp>
3294 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3295 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3296 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3298 : public is_copy_constructible<_Tp>
3302 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3303 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
3304 = is_move_constructible<_Tp>::value;
3307 // is_trivially_constructible
3309 #ifndef _LIBCPP_HAS_NO_VARIADICS
3311 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3313 template <class _Tp, class... _Args>
3314 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3315 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3319 #else // !__has_feature(is_trivially_constructible)
3321 template <class _Tp, class... _Args>
3322 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3327 template <class _Tp>
3328 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3329 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3330 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3332 : integral_constant<bool, is_scalar<_Tp>::value>
3337 template <class _Tp>
3338 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3339 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3341 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
3343 : integral_constant<bool, is_scalar<_Tp>::value>
3347 template <class _Tp>
3348 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3349 : integral_constant<bool, is_scalar<_Tp>::value>
3353 template <class _Tp>
3354 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3355 : integral_constant<bool, is_scalar<_Tp>::value>
3359 #endif // !__has_feature(is_trivially_constructible)
3361 #else // _LIBCPP_HAS_NO_VARIADICS
3363 template <class _Tp, class _A0 = __is_construct::__nat,
3364 class _A1 = __is_construct::__nat>
3365 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3370 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3372 template <class _Tp>
3373 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3374 __is_construct::__nat>
3375 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3379 template <class _Tp>
3380 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3381 __is_construct::__nat>
3382 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3386 template <class _Tp>
3387 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3388 __is_construct::__nat>
3389 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3393 template <class _Tp>
3394 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3395 __is_construct::__nat>
3396 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3400 #else // !__has_feature(is_trivially_constructible)
3402 template <class _Tp>
3403 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3404 __is_construct::__nat>
3405 : integral_constant<bool, is_scalar<_Tp>::value>
3409 template <class _Tp>
3410 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3411 __is_construct::__nat>
3412 : integral_constant<bool, is_scalar<_Tp>::value>
3416 template <class _Tp>
3417 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3418 __is_construct::__nat>
3419 : integral_constant<bool, is_scalar<_Tp>::value>
3423 template <class _Tp>
3424 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3425 __is_construct::__nat>
3426 : integral_constant<bool, is_scalar<_Tp>::value>
3430 #endif // !__has_feature(is_trivially_constructible)
3432 #endif // _LIBCPP_HAS_NO_VARIADICS
3434 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3435 template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3436 = is_trivially_constructible<_Tp, _Args...>::value;
3439 // is_trivially_default_constructible
3441 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3442 : public is_trivially_constructible<_Tp>
3445 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3446 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3447 = is_trivially_default_constructible<_Tp>::value;
3450 // is_trivially_copy_constructible
3452 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3453 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3456 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3457 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3458 = is_trivially_copy_constructible<_Tp>::value;
3461 // is_trivially_move_constructible
3463 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3464 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3465 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3467 : public is_trivially_copy_constructible<_Tp>
3471 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3472 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3473 = is_trivially_move_constructible<_Tp>::value;
3476 // is_trivially_assignable
3478 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3480 template <class _Tp, class _Arg>
3481 struct is_trivially_assignable
3482 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3486 #else // !__has_feature(is_trivially_assignable)
3488 template <class _Tp, class _Arg>
3489 struct is_trivially_assignable
3490 : public false_type {};
3492 template <class _Tp>
3493 struct is_trivially_assignable<_Tp&, _Tp>
3494 : integral_constant<bool, is_scalar<_Tp>::value> {};
3496 template <class _Tp>
3497 struct is_trivially_assignable<_Tp&, _Tp&>
3498 : integral_constant<bool, is_scalar<_Tp>::value> {};
3500 template <class _Tp>
3501 struct is_trivially_assignable<_Tp&, const _Tp&>
3502 : integral_constant<bool, is_scalar<_Tp>::value> {};
3504 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3506 template <class _Tp>
3507 struct is_trivially_assignable<_Tp&, _Tp&&>
3508 : integral_constant<bool, is_scalar<_Tp>::value> {};
3510 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3512 #endif // !__has_feature(is_trivially_assignable)
3514 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3515 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3516 = is_trivially_assignable<_Tp, _Arg>::value;
3519 // is_trivially_copy_assignable
3521 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3522 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3523 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3525 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3526 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3527 = is_trivially_copy_assignable<_Tp>::value;
3530 // is_trivially_move_assignable
3532 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3533 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3534 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3535 typename add_rvalue_reference<_Tp>::type>
3537 typename add_lvalue_reference<_Tp>::type>
3541 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3542 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3543 = is_trivially_move_assignable<_Tp>::value;
3546 // is_trivially_destructible
3548 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3550 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3551 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3555 template <class _Tp> struct __libcpp_trivial_destructor
3556 : public integral_constant<bool, is_scalar<_Tp>::value ||
3557 is_reference<_Tp>::value> {};
3559 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3560 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3562 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3563 : public false_type {};
3567 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3568 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3569 = is_trivially_destructible<_Tp>::value;
3572 // is_nothrow_constructible
3575 template <class _Tp, class... _Args>
3576 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3577 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3583 #ifndef _LIBCPP_HAS_NO_VARIADICS
3585 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3587 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3589 template <class _Tp, class... _Args>
3590 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3591 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3595 template <class _Tp>
3596 void __implicit_conversion_to(_Tp) noexcept { }
3598 template <class _Tp, class _Arg>
3599 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3600 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3604 template <class _Tp, bool _IsReference, class... _Args>
3605 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3610 template <class _Tp, class... _Args>
3611 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3612 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3616 template <class _Tp, size_t _Ns>
3617 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3618 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3622 #else // __has_feature(cxx_noexcept)
3624 template <class _Tp, class... _Args>
3625 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3630 template <class _Tp>
3631 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
3632 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3633 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3635 : integral_constant<bool, is_scalar<_Tp>::value>
3640 template <class _Tp>
3641 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3642 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
3644 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
3646 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3647 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3649 : integral_constant<bool, is_scalar<_Tp>::value>
3654 template <class _Tp>
3655 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
3656 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3657 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3659 : integral_constant<bool, is_scalar<_Tp>::value>
3664 template <class _Tp>
3665 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
3666 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3667 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3669 : integral_constant<bool, is_scalar<_Tp>::value>
3674 #endif // __has_feature(cxx_noexcept)
3676 #else // _LIBCPP_HAS_NO_VARIADICS
3678 template <class _Tp, class _A0 = __is_construct::__nat,
3679 class _A1 = __is_construct::__nat>
3680 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3685 template <class _Tp>
3686 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
3687 __is_construct::__nat>
3688 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3689 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3691 : integral_constant<bool, is_scalar<_Tp>::value>
3696 template <class _Tp>
3697 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
3698 __is_construct::__nat>
3699 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3700 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3702 : integral_constant<bool, is_scalar<_Tp>::value>
3707 template <class _Tp>
3708 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
3709 __is_construct::__nat>
3710 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3711 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3713 : integral_constant<bool, is_scalar<_Tp>::value>
3718 template <class _Tp>
3719 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
3720 __is_construct::__nat>
3721 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3722 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3724 : integral_constant<bool, is_scalar<_Tp>::value>
3729 #endif // _LIBCPP_HAS_NO_VARIADICS
3730 #endif // __has_feature(is_nothrow_constructible)
3732 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3733 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3734 = is_nothrow_constructible<_Tp, _Args...>::value;
3737 // is_nothrow_default_constructible
3739 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3740 : public is_nothrow_constructible<_Tp>
3743 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3744 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3745 = is_nothrow_default_constructible<_Tp>::value;
3748 // is_nothrow_copy_constructible
3750 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3751 : public is_nothrow_constructible<_Tp,
3752 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3754 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3755 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3756 = is_nothrow_copy_constructible<_Tp>::value;
3759 // is_nothrow_move_constructible
3761 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3762 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3763 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3765 : public is_nothrow_copy_constructible<_Tp>
3769 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3770 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3771 = is_nothrow_move_constructible<_Tp>::value;
3774 // is_nothrow_assignable
3776 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3778 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3780 template <class _Tp, class _Arg>
3781 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3786 template <class _Tp, class _Arg>
3787 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3788 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3792 template <class _Tp, class _Arg>
3793 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3794 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3798 #else // __has_feature(cxx_noexcept)
3800 template <class _Tp, class _Arg>
3801 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3802 : public false_type {};
3804 template <class _Tp>
3805 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
3806 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3807 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3809 : integral_constant<bool, is_scalar<_Tp>::value> {};
3812 template <class _Tp>
3813 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
3814 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3815 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3817 : integral_constant<bool, is_scalar<_Tp>::value> {};
3820 template <class _Tp>
3821 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
3822 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3823 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3825 : integral_constant<bool, is_scalar<_Tp>::value> {};
3828 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3830 template <class _Tp>
3831 struct is_nothrow_assignable<_Tp&, _Tp&&>
3832 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3833 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3835 : integral_constant<bool, is_scalar<_Tp>::value> {};
3838 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3840 #endif // __has_feature(cxx_noexcept)
3842 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3843 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3844 = is_nothrow_assignable<_Tp, _Arg>::value;
3847 // is_nothrow_copy_assignable
3849 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3850 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3851 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3853 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3854 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3855 = is_nothrow_copy_assignable<_Tp>::value;
3858 // is_nothrow_move_assignable
3860 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3861 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3862 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3863 typename add_rvalue_reference<_Tp>::type>
3865 typename add_lvalue_reference<_Tp>::type>
3869 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3870 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3871 = is_nothrow_move_assignable<_Tp>::value;
3874 // is_nothrow_destructible
3876 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3878 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3880 template <class _Tp>
3881 struct __libcpp_is_nothrow_destructible<false, _Tp>
3886 template <class _Tp>
3887 struct __libcpp_is_nothrow_destructible<true, _Tp>
3888 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3892 template <class _Tp>
3893 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3894 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3898 template <class _Tp, size_t _Ns>
3899 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3900 : public is_nothrow_destructible<_Tp>
3904 template <class _Tp>
3905 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3910 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3912 template <class _Tp>
3913 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3922 template <class _Tp> struct __libcpp_nothrow_destructor
3923 : public integral_constant<bool, is_scalar<_Tp>::value ||
3924 is_reference<_Tp>::value> {};
3926 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3927 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3929 template <class _Tp>
3930 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3931 : public false_type {};
3935 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3936 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3937 = is_nothrow_destructible<_Tp>::value;
3942 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
3944 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3945 : public integral_constant<bool, __is_pod(_Tp)> {};
3949 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3950 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3951 is_trivially_copy_constructible<_Tp>::value &&
3952 is_trivially_copy_assignable<_Tp>::value &&
3953 is_trivially_destructible<_Tp>::value> {};
3957 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3958 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
3959 = is_pod<_Tp>::value;
3964 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
3965 #ifdef _LIBCPP_IS_LITERAL
3966 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3968 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3969 is_reference<typename remove_all_extents<_Tp>::type>::value>
3973 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3974 template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
3975 = is_literal_type<_Tp>::value;
3978 // is_standard_layout;
3980 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3981 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3982 : public integral_constant<bool, __is_standard_layout(_Tp)>
3984 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3988 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3989 template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
3990 = is_standard_layout<_Tp>::value;
3993 // is_trivially_copyable;
3995 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3996 #if __has_feature(is_trivially_copyable)
3997 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3998 #elif _GNUC_VER >= 501
3999 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
4001 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
4005 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4006 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
4007 = is_trivially_copyable<_Tp>::value;
4012 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
4013 #if __has_feature(is_trivial) || _GNUC_VER >= 407
4014 : public integral_constant<bool, __is_trivial(_Tp)>
4016 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
4017 is_trivially_default_constructible<_Tp>::value>
4021 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
4022 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
4023 = is_trivial<_Tp>::value;
4026 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
4027 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
4028 template <class _Tp> struct __is_reference_wrapper
4029 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
4031 #ifndef _LIBCPP_CXX03_LANG
4033 // Check for complete types
4035 template <class ..._Tp> struct __check_complete;
4038 struct __check_complete<>
4042 template <class _Hp, class _T0, class ..._Tp>
4043 struct __check_complete<_Hp, _T0, _Tp...>
4044 : private __check_complete<_Hp>,
4045 private __check_complete<_T0, _Tp...>
4049 template <class _Hp>
4050 struct __check_complete<_Hp, _Hp>
4051 : private __check_complete<_Hp>
4055 template <class _Tp>
4056 struct __check_complete<_Tp>
4058 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
4061 template <class _Tp>
4062 struct __check_complete<_Tp&>
4063 : private __check_complete<_Tp>
4067 template <class _Tp>
4068 struct __check_complete<_Tp&&>
4069 : private __check_complete<_Tp>
4073 template <class _Rp, class ..._Param>
4074 struct __check_complete<_Rp (*)(_Param...)>
4075 : private __check_complete<_Rp>
4079 template <class ..._Param>
4080 struct __check_complete<void (*)(_Param...)>
4084 template <class _Rp, class ..._Param>
4085 struct __check_complete<_Rp (_Param...)>
4086 : private __check_complete<_Rp>
4090 template <class ..._Param>
4091 struct __check_complete<void (_Param...)>
4095 template <class _Rp, class _Class, class ..._Param>
4096 struct __check_complete<_Rp (_Class::*)(_Param...)>
4097 : private __check_complete<_Class>
4101 template <class _Rp, class _Class, class ..._Param>
4102 struct __check_complete<_Rp (_Class::*)(_Param...) const>
4103 : private __check_complete<_Class>
4107 template <class _Rp, class _Class, class ..._Param>
4108 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
4109 : private __check_complete<_Class>
4113 template <class _Rp, class _Class, class ..._Param>
4114 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
4115 : private __check_complete<_Class>
4119 template <class _Rp, class _Class, class ..._Param>
4120 struct __check_complete<_Rp (_Class::*)(_Param...) &>
4121 : private __check_complete<_Class>
4125 template <class _Rp, class _Class, class ..._Param>
4126 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
4127 : private __check_complete<_Class>
4131 template <class _Rp, class _Class, class ..._Param>
4132 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
4133 : private __check_complete<_Class>
4137 template <class _Rp, class _Class, class ..._Param>
4138 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
4139 : private __check_complete<_Class>
4143 template <class _Rp, class _Class, class ..._Param>
4144 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
4145 : private __check_complete<_Class>
4149 template <class _Rp, class _Class, class ..._Param>
4150 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
4151 : private __check_complete<_Class>
4155 template <class _Rp, class _Class, class ..._Param>
4156 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
4157 : private __check_complete<_Class>
4161 template <class _Rp, class _Class, class ..._Param>
4162 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
4163 : private __check_complete<_Class>
4167 template <class _Rp, class _Class>
4168 struct __check_complete<_Rp _Class::*>
4169 : private __check_complete<_Class>
4174 template <class _Fp, class _A0,
4175 class _DecayFp = typename decay<_Fp>::type,
4176 class _DecayA0 = typename decay<_A0>::type,
4177 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4178 using __enable_if_bullet1 = typename enable_if
4180 is_member_function_pointer<_DecayFp>::value
4181 && is_base_of<_ClassT, _DecayA0>::value
4184 template <class _Fp, class _A0,
4185 class _DecayFp = typename decay<_Fp>::type,
4186 class _DecayA0 = typename decay<_A0>::type>
4187 using __enable_if_bullet2 = typename enable_if
4189 is_member_function_pointer<_DecayFp>::value
4190 && __is_reference_wrapper<_DecayA0>::value
4193 template <class _Fp, class _A0,
4194 class _DecayFp = typename decay<_Fp>::type,
4195 class _DecayA0 = typename decay<_A0>::type,
4196 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4197 using __enable_if_bullet3 = typename enable_if
4199 is_member_function_pointer<_DecayFp>::value
4200 && !is_base_of<_ClassT, _DecayA0>::value
4201 && !__is_reference_wrapper<_DecayA0>::value
4204 template <class _Fp, class _A0,
4205 class _DecayFp = typename decay<_Fp>::type,
4206 class _DecayA0 = typename decay<_A0>::type,
4207 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4208 using __enable_if_bullet4 = typename enable_if
4210 is_member_object_pointer<_DecayFp>::value
4211 && is_base_of<_ClassT, _DecayA0>::value
4214 template <class _Fp, class _A0,
4215 class _DecayFp = typename decay<_Fp>::type,
4216 class _DecayA0 = typename decay<_A0>::type>
4217 using __enable_if_bullet5 = typename enable_if
4219 is_member_object_pointer<_DecayFp>::value
4220 && __is_reference_wrapper<_DecayA0>::value
4223 template <class _Fp, class _A0,
4224 class _DecayFp = typename decay<_Fp>::type,
4225 class _DecayA0 = typename decay<_A0>::type,
4226 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4227 using __enable_if_bullet6 = typename enable_if
4229 is_member_object_pointer<_DecayFp>::value
4230 && !is_base_of<_ClassT, _DecayA0>::value
4231 && !__is_reference_wrapper<_DecayA0>::value
4234 // __invoke forward declarations
4236 // fall back - none of the bullets
4238 #define _LIBCPP_INVOKE_RETURN(...) \
4239 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4240 { return __VA_ARGS__; }
4242 template <class ..._Args>
4243 auto __invoke(__any, _Args&& ...__args) -> __nat;
4245 template <class ..._Args>
4246 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4248 // bullets 1, 2 and 3
4250 template <class _Fp, class _A0, class ..._Args,
4251 class = __enable_if_bullet1<_Fp, _A0>>
4252 inline _LIBCPP_INLINE_VISIBILITY
4254 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4255 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4257 template <class _Fp, class _A0, class ..._Args,
4258 class = __enable_if_bullet1<_Fp, _A0>>
4259 inline _LIBCPP_INLINE_VISIBILITY
4260 _LIBCPP_CONSTEXPR auto
4261 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4262 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4264 template <class _Fp, class _A0, class ..._Args,
4265 class = __enable_if_bullet2<_Fp, _A0>>
4266 inline _LIBCPP_INLINE_VISIBILITY
4268 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4269 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4271 template <class _Fp, class _A0, class ..._Args,
4272 class = __enable_if_bullet2<_Fp, _A0>>
4273 inline _LIBCPP_INLINE_VISIBILITY
4274 _LIBCPP_CONSTEXPR auto
4275 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4276 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4278 template <class _Fp, class _A0, class ..._Args,
4279 class = __enable_if_bullet3<_Fp, _A0>>
4280 inline _LIBCPP_INLINE_VISIBILITY
4282 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4283 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4285 template <class _Fp, class _A0, class ..._Args,
4286 class = __enable_if_bullet3<_Fp, _A0>>
4287 inline _LIBCPP_INLINE_VISIBILITY
4288 _LIBCPP_CONSTEXPR auto
4289 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4290 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4292 // bullets 4, 5 and 6
4294 template <class _Fp, class _A0,
4295 class = __enable_if_bullet4<_Fp, _A0>>
4296 inline _LIBCPP_INLINE_VISIBILITY
4298 __invoke(_Fp&& __f, _A0&& __a0)
4299 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4301 template <class _Fp, class _A0,
4302 class = __enable_if_bullet4<_Fp, _A0>>
4303 inline _LIBCPP_INLINE_VISIBILITY
4304 _LIBCPP_CONSTEXPR auto
4305 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4306 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4308 template <class _Fp, class _A0,
4309 class = __enable_if_bullet5<_Fp, _A0>>
4310 inline _LIBCPP_INLINE_VISIBILITY
4312 __invoke(_Fp&& __f, _A0&& __a0)
4313 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4315 template <class _Fp, class _A0,
4316 class = __enable_if_bullet5<_Fp, _A0>>
4317 inline _LIBCPP_INLINE_VISIBILITY
4318 _LIBCPP_CONSTEXPR auto
4319 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4320 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4322 template <class _Fp, class _A0,
4323 class = __enable_if_bullet6<_Fp, _A0>>
4324 inline _LIBCPP_INLINE_VISIBILITY
4326 __invoke(_Fp&& __f, _A0&& __a0)
4327 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4329 template <class _Fp, class _A0,
4330 class = __enable_if_bullet6<_Fp, _A0>>
4331 inline _LIBCPP_INLINE_VISIBILITY
4332 _LIBCPP_CONSTEXPR auto
4333 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4334 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4338 template <class _Fp, class ..._Args>
4339 inline _LIBCPP_INLINE_VISIBILITY
4341 __invoke(_Fp&& __f, _Args&& ...__args)
4342 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4344 template <class _Fp, class ..._Args>
4345 inline _LIBCPP_INLINE_VISIBILITY
4346 _LIBCPP_CONSTEXPR auto
4347 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4348 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4350 #undef _LIBCPP_INVOKE_RETURN
4354 template <class _Ret, class _Fp, class ..._Args>
4355 struct __invokable_r
4356 : private __check_complete<_Fp>
4358 using _Result = decltype(
4359 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4362 typename conditional<
4363 !is_same<_Result, __nat>::value,
4364 typename conditional<
4365 is_void<_Ret>::value,
4367 is_convertible<_Result, _Ret>
4371 static const bool value = type::value;
4374 template <class _Fp, class ..._Args>
4375 using __invokable = __invokable_r<void, _Fp, _Args...>;
4377 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4378 struct __nothrow_invokable_r_imp {
4379 static const bool value = false;
4382 template <class _Ret, class _Fp, class ..._Args>
4383 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4385 typedef __nothrow_invokable_r_imp _ThisT;
4387 template <class _Tp>
4388 static void __test_noexcept(_Tp) noexcept;
4390 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4391 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4394 template <class _Ret, class _Fp, class ..._Args>
4395 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4397 static const bool value = noexcept(
4398 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4401 template <class _Ret, class _Fp, class ..._Args>
4402 using __nothrow_invokable_r =
4403 __nothrow_invokable_r_imp<
4404 __invokable_r<_Ret, _Fp, _Args...>::value,
4405 is_void<_Ret>::value,
4409 template <class _Fp, class ..._Args>
4410 using __nothrow_invokable =
4411 __nothrow_invokable_r_imp<
4412 __invokable<_Fp, _Args...>::value,
4413 true, void, _Fp, _Args...
4416 template <class _Fp, class ..._Args>
4419 __invokable<_Fp, _Args...>::value,
4420 typename __invokable_r<void, _Fp, _Args...>::_Result>
4426 template <class _Fp, class ..._Args>
4427 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
4428 : public __invoke_of<_Fp, _Args...>
4432 #if _LIBCPP_STD_VER > 11
4433 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4436 #if _LIBCPP_STD_VER > 14
4440 template <class _Fn, class... _Args>
4441 struct _LIBCPP_TEMPLATE_VIS invoke_result
4442 : __invoke_of<_Fn, _Args...>
4446 template <class _Fn, class... _Args>
4447 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
4451 template <class _Fn, class ..._Args>
4452 struct _LIBCPP_TEMPLATE_VIS is_invocable
4453 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
4455 template <class _Ret, class _Fn, class ..._Args>
4456 struct _LIBCPP_TEMPLATE_VIS is_invocable_r
4457 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4459 template <class _Fn, class ..._Args>
4460 constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
4462 template <class _Ret, class _Fn, class ..._Args>
4463 constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
4465 // is_nothrow_callable
4467 template <class _Fn, class ..._Args>
4468 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
4469 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
4471 template <class _Ret, class _Fn, class ..._Args>
4472 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
4473 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
4475 template <class _Fn, class ..._Args>
4476 constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
4478 template <class _Ret, class _Fn, class ..._Args>
4479 constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
4481 #endif // _LIBCPP_STD_VER > 14
4483 #endif // !defined(_LIBCPP_CXX03_LANG)
4485 template <class _Tp> struct __is_swappable;
4486 template <class _Tp> struct __is_nothrow_swappable;
4488 template <class _Tp>
4489 inline _LIBCPP_INLINE_VISIBILITY
4490 #ifndef _LIBCPP_CXX03_LANG
4493 is_move_constructible<_Tp>::value &&
4494 is_move_assignable<_Tp>::value
4499 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4500 is_nothrow_move_assignable<_Tp>::value)
4502 _Tp __t(_VSTD::move(__x));
4503 __x = _VSTD::move(__y);
4504 __y = _VSTD::move(__t);
4507 template<class _Tp, size_t _Np>
4508 inline _LIBCPP_INLINE_VISIBILITY
4510 __is_swappable<_Tp>::value
4512 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4514 template <class _ForwardIterator1, class _ForwardIterator2>
4515 inline _LIBCPP_INLINE_VISIBILITY
4517 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4518 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4519 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4520 *_VSTD::declval<_ForwardIterator2>())))
4529 // ALL generic swap overloads MUST already have a declaration available at this point.
4531 template <class _Tp, class _Up = _Tp,
4532 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4533 struct __swappable_with
4535 template <class _LHS, class _RHS>
4536 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4538 template <class, class>
4539 static __nat __test_swap(long);
4541 // Extra parens are needed for the C++03 definition of decltype.
4542 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4543 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4545 static const bool value = !is_same<__swap1, __nat>::value
4546 && !is_same<__swap2, __nat>::value;
4549 template <class _Tp, class _Up>
4550 struct __swappable_with<_Tp, _Up, false> : false_type {};
4552 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4553 struct __nothrow_swappable_with {
4554 static const bool value =
4555 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4556 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4557 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4563 template <class _Tp, class _Up>
4564 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4568 template <class _Tp>
4569 struct __is_swappable
4570 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4574 template <class _Tp>
4575 struct __is_nothrow_swappable
4576 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4580 #if _LIBCPP_STD_VER > 14
4582 template <class _Tp, class _Up>
4583 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4584 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4588 template <class _Tp>
4589 struct _LIBCPP_TEMPLATE_VIS is_swappable
4590 : public conditional<
4591 __is_referenceable<_Tp>::value,
4593 typename add_lvalue_reference<_Tp>::type,
4594 typename add_lvalue_reference<_Tp>::type>,
4600 template <class _Tp, class _Up>
4601 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4602 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4606 template <class _Tp>
4607 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4608 : public conditional<
4609 __is_referenceable<_Tp>::value,
4610 is_nothrow_swappable_with<
4611 typename add_lvalue_reference<_Tp>::type,
4612 typename add_lvalue_reference<_Tp>::type>,
4618 template <class _Tp, class _Up>
4619 constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
4621 template <class _Tp>
4622 constexpr bool is_swappable_v = is_swappable<_Tp>::value;
4624 template <class _Tp, class _Up>
4625 constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
4627 template <class _Tp>
4628 constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
4630 #endif // _LIBCPP_STD_VER > 14
4632 #ifdef _LIBCPP_UNDERLYING_TYPE
4634 template <class _Tp>
4635 struct underlying_type
4637 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4640 #if _LIBCPP_STD_VER > 11
4641 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4644 #else // _LIBCPP_UNDERLYING_TYPE
4646 template <class _Tp, bool _Support = false>
4647 struct underlying_type
4649 static_assert(_Support, "The underyling_type trait requires compiler "
4650 "support. Either no such support exists or "
4651 "libc++ does not know how to use it.");
4654 #endif // _LIBCPP_UNDERLYING_TYPE
4657 template <class _Tp, bool = is_enum<_Tp>::value>
4658 struct __sfinae_underlying_type
4660 typedef typename underlying_type<_Tp>::type type;
4661 typedef decltype(((type)1) + 0) __promoted_type;
4664 template <class _Tp>
4665 struct __sfinae_underlying_type<_Tp, false> {};
4667 inline _LIBCPP_INLINE_VISIBILITY
4668 int __convert_to_integral(int __val) { return __val; }
4670 inline _LIBCPP_INLINE_VISIBILITY
4671 unsigned __convert_to_integral(unsigned __val) { return __val; }
4673 inline _LIBCPP_INLINE_VISIBILITY
4674 long __convert_to_integral(long __val) { return __val; }
4676 inline _LIBCPP_INLINE_VISIBILITY
4677 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4679 inline _LIBCPP_INLINE_VISIBILITY
4680 long long __convert_to_integral(long long __val) { return __val; }
4682 inline _LIBCPP_INLINE_VISIBILITY
4683 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4685 template<typename _Fp>
4686 inline _LIBCPP_INLINE_VISIBILITY
4687 typename enable_if<is_floating_point<_Fp>::value, long long>::type
4688 __convert_to_integral(_Fp __val) { return __val; }
4690 #ifndef _LIBCPP_HAS_NO_INT128
4691 inline _LIBCPP_INLINE_VISIBILITY
4692 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4694 inline _LIBCPP_INLINE_VISIBILITY
4695 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4698 template <class _Tp>
4699 inline _LIBCPP_INLINE_VISIBILITY
4700 typename __sfinae_underlying_type<_Tp>::__promoted_type
4701 __convert_to_integral(_Tp __val) { return __val; }
4703 #ifndef _LIBCPP_CXX03_LANG
4705 template <class _Tp>
4706 struct __has_operator_addressof_member_imp
4708 template <class _Up>
4709 static auto __test(int)
4710 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4712 static auto __test(long) -> false_type;
4714 static const bool value = decltype(__test<_Tp>(0))::value;
4717 template <class _Tp>
4718 struct __has_operator_addressof_free_imp
4720 template <class _Up>
4721 static auto __test(int)
4722 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4724 static auto __test(long) -> false_type;
4726 static const bool value = decltype(__test<_Tp>(0))::value;
4729 template <class _Tp>
4730 struct __has_operator_addressof
4731 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4732 || __has_operator_addressof_free_imp<_Tp>::value>
4735 #endif // _LIBCPP_CXX03_LANG
4737 #if _LIBCPP_STD_VER > 14
4739 #define __cpp_lib_void_t 201411
4740 template <class...> using void_t = void;
4742 # ifndef _LIBCPP_HAS_NO_VARIADICS
4743 template <class... _Args>
4744 struct conjunction : __and_<_Args...> {};
4745 template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
4747 template <class... _Args>
4748 struct disjunction : __or_<_Args...> {};
4749 template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
4751 template <class _Tp>
4752 struct negation : __not_<_Tp> {};
4753 template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
4754 # endif // _LIBCPP_HAS_NO_VARIADICS
4755 #endif // _LIBCPP_STD_VER > 14
4757 // These traits are used in __tree and __hash_table
4758 #ifndef _LIBCPP_CXX03_LANG
4759 struct __extract_key_fail_tag {};
4760 struct __extract_key_self_tag {};
4761 struct __extract_key_first_tag {};
4763 template <class _ValTy, class _Key,
4764 class _RawValTy = typename __unconstref<_ValTy>::type>
4765 struct __can_extract_key
4766 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4767 __extract_key_fail_tag>::type {};
4769 template <class _Pair, class _Key, class _First, class _Second>
4770 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4771 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4772 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4774 // __can_extract_map_key uses true_type/false_type instead of the tags.
4775 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4776 // and _ValTy == _Key.
4777 template <class _ValTy, class _Key, class _ContainerValueTy,
4778 class _RawValTy = typename __unconstref<_ValTy>::type>
4779 struct __can_extract_map_key
4780 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4782 // This specialization returns __extract_key_fail_tag for non-map containers
4783 // because _Key == _ContainerValueTy
4784 template <class _ValTy, class _Key, class _RawValTy>
4785 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4790 _LIBCPP_END_NAMESPACE_STD
4792 #if _LIBCPP_STD_VER > 14
4794 namespace std // purposefully not versioned
4796 template <class _Integer>
4797 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4798 operator<<=(byte& __lhs, _Integer __shift) noexcept
4799 { return __lhs = __lhs << __shift; }
4801 template <class _Integer>
4802 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4803 operator<< (byte __lhs, _Integer __shift) noexcept
4804 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
4806 template <class _Integer>
4807 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
4808 operator>>=(byte& __lhs, _Integer __shift) noexcept
4809 { return __lhs = __lhs >> __shift; }
4811 template <class _Integer>
4812 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
4813 operator>> (byte __lhs, _Integer __shift) noexcept
4814 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
4816 template <class _Integer>
4817 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
4818 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
4823 #endif // _LIBCPP_TYPE_TRAITS