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
101 template <class T, class... Args> struct is_constructible;
102 template <class T> struct is_default_constructible;
103 template <class T> struct is_copy_constructible;
104 template <class T> struct is_move_constructible;
105 template <class T, class U> struct is_assignable;
106 template <class T> struct is_copy_assignable;
107 template <class T> struct is_move_assignable;
108 template <class T, class U> struct is_swappable_with; // C++17
109 template <class T> struct is_swappable; // C++17
110 template <class T> struct is_destructible;
112 template <class T, class... Args> struct is_trivially_constructible;
113 template <class T> struct is_trivially_default_constructible;
114 template <class T> struct is_trivially_copy_constructible;
115 template <class T> struct is_trivially_move_constructible;
116 template <class T, class U> struct is_trivially_assignable;
117 template <class T> struct is_trivially_copy_assignable;
118 template <class T> struct is_trivially_move_assignable;
119 template <class T> struct is_trivially_destructible;
121 template <class T, class... Args> struct is_nothrow_constructible;
122 template <class T> struct is_nothrow_default_constructible;
123 template <class T> struct is_nothrow_copy_constructible;
124 template <class T> struct is_nothrow_move_constructible;
125 template <class T, class U> struct is_nothrow_assignable;
126 template <class T> struct is_nothrow_copy_assignable;
127 template <class T> struct is_nothrow_move_assignable;
128 template <class T, class U> struct is_nothrow_swappable_with; // C++17
129 template <class T> struct is_nothrow_swappable; // C++17
130 template <class T> struct is_nothrow_destructible;
132 template <class T> struct has_virtual_destructor;
134 // Relationships between types:
135 template <class T, class U> struct is_same;
136 template <class Base, class Derived> struct is_base_of;
137 template <class From, class To> struct is_convertible;
139 template <class, class R = void> struct is_callable; // not defined
140 template <class Fn, class... ArgTypes, class R>
141 struct is_callable<Fn(ArgTypes...), R>;
143 template <class, class R = void> struct is_nothrow_callable; // not defined
144 template <class Fn, class... ArgTypes, class R>
145 struct is_nothrow_callable<Fn(ArgTypes...), R>;
147 // Alignment properties and transformations:
148 template <class T> struct alignment_of;
149 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
150 struct aligned_storage;
151 template <size_t Len, class... Types> struct aligned_union;
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...)>;
159 // const-volatile modifications:
161 using remove_const_t = typename remove_const<T>::type; // C++14
163 using remove_volatile_t = typename remove_volatile<T>::type; // C++14
165 using remove_cv_t = typename remove_cv<T>::type; // C++14
167 using add_const_t = typename add_const<T>::type; // C++14
169 using add_volatile_t = typename add_volatile<T>::type; // C++14
171 using add_cv_t = typename add_cv<T>::type; // C++14
173 // reference modifications:
175 using remove_reference_t = typename remove_reference<T>::type; // C++14
177 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
179 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
181 // sign modifications:
183 using make_signed_t = typename make_signed<T>::type; // C++14
185 using make_unsigned_t = typename make_unsigned<T>::type; // C++14
187 // array modifications:
189 using remove_extent_t = typename remove_extent<T>::type; // C++14
191 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
193 // pointer modifications:
195 using remove_pointer_t = typename remove_pointer<T>::type; // C++14
197 using add_pointer_t = typename add_pointer<T>::type; // C++14
199 // other transformations:
200 template <size_t Len, std::size_t Align=default-alignment>
201 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
202 template <std::size_t Len, class... Types>
203 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
205 using decay_t = typename decay<T>::type; // C++14
206 template <bool b, class T=void>
207 using enable_if_t = typename enable_if<b,T>::type; // C++14
208 template <bool b, class T, class F>
209 using conditional_t = typename conditional<b,T,F>::type; // C++14
210 template <class... T>
211 using common_type_t = typename common_type<T...>::type; // C++14
213 using underlying_type_t = typename underlying_type<T>::type; // C++14
214 template <class F, class... ArgTypes>
215 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
218 using void_t = void; // C++17
220 // See C++14 20.10.4.1, primary type categories
221 template <class T> constexpr bool is_void_v
222 = is_void<T>::value; // C++17
223 template <class T> constexpr bool is_null_pointer_v
224 = is_null_pointer<T>::value; // C++17
225 template <class T> constexpr bool is_integral_v
226 = is_integral<T>::value; // C++17
227 template <class T> constexpr bool is_floating_point_v
228 = is_floating_point<T>::value; // C++17
229 template <class T> constexpr bool is_array_v
230 = is_array<T>::value; // C++17
231 template <class T> constexpr bool is_pointer_v
232 = is_pointer<T>::value; // C++17
233 template <class T> constexpr bool is_lvalue_reference_v
234 = is_lvalue_reference<T>::value; // C++17
235 template <class T> constexpr bool is_rvalue_reference_v
236 = is_rvalue_reference<T>::value; // C++17
237 template <class T> constexpr bool is_member_object_pointer_v
238 = is_member_object_pointer<T>::value; // C++17
239 template <class T> constexpr bool is_member_function_pointer_v
240 = is_member_function_pointer<T>::value; // C++17
241 template <class T> constexpr bool is_enum_v
242 = is_enum<T>::value; // C++17
243 template <class T> constexpr bool is_union_v
244 = is_union<T>::value; // C++17
245 template <class T> constexpr bool is_class_v
246 = is_class<T>::value; // C++17
247 template <class T> constexpr bool is_function_v
248 = is_function<T>::value; // C++17
250 // See C++14 20.10.4.2, composite type categories
251 template <class T> constexpr bool is_reference_v
252 = is_reference<T>::value; // C++17
253 template <class T> constexpr bool is_arithmetic_v
254 = is_arithmetic<T>::value; // C++17
255 template <class T> constexpr bool is_fundamental_v
256 = is_fundamental<T>::value; // C++17
257 template <class T> constexpr bool is_object_v
258 = is_object<T>::value; // C++17
259 template <class T> constexpr bool is_scalar_v
260 = is_scalar<T>::value; // C++17
261 template <class T> constexpr bool is_compound_v
262 = is_compound<T>::value; // C++17
263 template <class T> constexpr bool is_member_pointer_v
264 = is_member_pointer<T>::value; // C++17
266 // See C++14 20.10.4.3, type properties
267 template <class T> constexpr bool is_const_v
268 = is_const<T>::value; // C++17
269 template <class T> constexpr bool is_volatile_v
270 = is_volatile<T>::value; // C++17
271 template <class T> constexpr bool is_trivial_v
272 = is_trivial<T>::value; // C++17
273 template <class T> constexpr bool is_trivially_copyable_v
274 = is_trivially_copyable<T>::value; // C++17
275 template <class T> constexpr bool is_standard_layout_v
276 = is_standard_layout<T>::value; // C++17
277 template <class T> constexpr bool is_pod_v
278 = is_pod<T>::value; // C++17
279 template <class T> constexpr bool is_literal_type_v
280 = is_literal_type<T>::value; // C++17
281 template <class T> constexpr bool is_empty_v
282 = is_empty<T>::value; // C++17
283 template <class T> constexpr bool is_polymorphic_v
284 = is_polymorphic<T>::value; // C++17
285 template <class T> constexpr bool is_abstract_v
286 = is_abstract<T>::value; // C++17
287 template <class T> constexpr bool is_final_v
288 = is_final<T>::value; // C++17
289 template <class T> constexpr bool is_signed_v
290 = is_signed<T>::value; // C++17
291 template <class T> constexpr bool is_unsigned_v
292 = is_unsigned<T>::value; // C++17
293 template <class T, class... Args> constexpr bool is_constructible_v
294 = is_constructible<T, Args...>::value; // C++17
295 template <class T> constexpr bool is_default_constructible_v
296 = is_default_constructible<T>::value; // C++17
297 template <class T> constexpr bool is_copy_constructible_v
298 = is_copy_constructible<T>::value; // C++17
299 template <class T> constexpr bool is_move_constructible_v
300 = is_move_constructible<T>::value; // C++17
301 template <class T, class U> constexpr bool is_assignable_v
302 = is_assignable<T, U>::value; // C++17
303 template <class T> constexpr bool is_copy_assignable_v
304 = is_copy_assignable<T>::value; // C++17
305 template <class T> constexpr bool is_move_assignable_v
306 = is_move_assignable<T>::value; // C++17
307 template <class T, class U> constexpr bool is_swappable_with_v
308 = is_swappable_with<T, U>::value; // C++17
309 template <class T> constexpr bool is_swappable_v
310 = is_swappable<T>::value; // C++17
311 template <class T> constexpr bool is_destructible_v
312 = is_destructible<T>::value; // C++17
313 template <class T, class... Args> constexpr bool is_trivially_constructible_v
314 = is_trivially_constructible<T, Args...>::value; // C++17
315 template <class T> constexpr bool is_trivially_default_constructible_v
316 = is_trivially_default_constructible<T>::value; // C++17
317 template <class T> constexpr bool is_trivially_copy_constructible_v
318 = is_trivially_copy_constructible<T>::value; // C++17
319 template <class T> constexpr bool is_trivially_move_constructible_v
320 = is_trivially_move_constructible<T>::value; // C++17
321 template <class T, class U> constexpr bool is_trivially_assignable_v
322 = is_trivially_assignable<T, U>::value; // C++17
323 template <class T> constexpr bool is_trivially_copy_assignable_v
324 = is_trivially_copy_assignable<T>::value; // C++17
325 template <class T> constexpr bool is_trivially_move_assignable_v
326 = is_trivially_move_assignable<T>::value; // C++17
327 template <class T> constexpr bool is_trivially_destructible_v
328 = is_trivially_destructible<T>::value; // C++17
329 template <class T, class... Args> constexpr bool is_nothrow_constructible_v
330 = is_nothrow_constructible<T, Args...>::value; // C++17
331 template <class T> constexpr bool is_nothrow_default_constructible_v
332 = is_nothrow_default_constructible<T>::value; // C++17
333 template <class T> constexpr bool is_nothrow_copy_constructible_v
334 = is_nothrow_copy_constructible<T>::value; // C++17
335 template <class T> constexpr bool is_nothrow_move_constructible_v
336 = is_nothrow_move_constructible<T>::value; // C++17
337 template <class T, class U> constexpr bool is_nothrow_assignable_v
338 = is_nothrow_assignable<T, U>::value; // C++17
339 template <class T> constexpr bool is_nothrow_copy_assignable_v
340 = is_nothrow_copy_assignable<T>::value; // C++17
341 template <class T> constexpr bool is_nothrow_move_assignable_v
342 = is_nothrow_move_assignable<T>::value; // C++17
343 template <class T, class U> constexpr bool is_nothrow_swappable_with_v
344 = is_nothrow_swappable_with<T, U>::value; // C++17
345 template <class T> constexpr bool is_nothrow_swappable_v
346 = is_nothrow_swappable<T>::value; // C++17
347 template <class T> constexpr bool is_nothrow_destructible_v
348 = is_nothrow_destructible<T>::value; // C++17
349 template <class T> constexpr bool has_virtual_destructor_v
350 = has_virtual_destructor<T>::value; // C++17
352 // See C++14 20.10.5, type property queries
353 template <class T> constexpr size_t alignment_of_v
354 = alignment_of<T>::value; // C++17
355 template <class T> constexpr size_t rank_v
356 = rank<T>::value; // C++17
357 template <class T, unsigned I = 0> constexpr size_t extent_v
358 = extent<T, I>::value; // C++17
360 // See C++14 20.10.6, type relations
361 template <class T, class U> constexpr bool is_same_v
362 = is_same<T, U>::value; // C++17
363 template <class Base, class Derived> constexpr bool is_base_of_v
364 = is_base_of<Base, Derived>::value; // C++17
365 template <class From, class To> constexpr bool is_convertible_v
366 = is_convertible<From, To>::value; // C++17
367 template <class T, class R = void> constexpr bool is_callable_v
368 = is_callable<T, R>::value; // C++17
369 template <class T, class R = void> constexpr bool is_nothrow_callable_v
370 = is_nothrow_callable<T, R>::value; // C++17
372 // [meta.logical], logical operator traits:
373 template<class... B> struct conjunction; // C++17
375 constexpr bool conjunction_v = conjunction<B...>::value; // C++17
376 template<class... B> struct disjunction; // C++17
378 constexpr bool disjunction_v = disjunction<B...>::value; // C++17
379 template<class B> struct negation; // C++17
381 constexpr bool negation_v = negation<B>::value; // C++17
389 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
390 #pragma GCC system_header
393 _LIBCPP_BEGIN_NAMESPACE_STD
395 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
396 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
397 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
400 struct __void_t { typedef void type; };
403 struct __identity { typedef _Tp type; };
405 template <class _Tp, bool>
406 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
408 template <bool _Bp, class _If, class _Then>
409 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
410 template <class _If, class _Then>
411 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
413 #if _LIBCPP_STD_VER > 11
414 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
417 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {};
418 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
420 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
421 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
423 #if _LIBCPP_STD_VER > 11
424 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
428 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
431 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
432 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
434 addressof(_Tp& __x) _NOEXCEPT
436 return __builtin_addressof(__x);
442 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
444 addressof(_Tp& __x) _NOEXCEPT
446 return reinterpret_cast<_Tp *>(
447 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
450 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
452 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
453 // Objective-C++ Automatic Reference Counting uses qualified pointers
454 // that require special addressof() signatures. When
455 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
456 // itself is providing these definitions. Otherwise, we provide them.
458 inline _LIBCPP_INLINE_VISIBILITY
460 addressof(__strong _Tp& __x) _NOEXCEPT
465 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
467 inline _LIBCPP_INLINE_VISIBILITY
469 addressof(__weak _Tp& __x) _NOEXCEPT
476 inline _LIBCPP_INLINE_VISIBILITY
478 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
484 inline _LIBCPP_INLINE_VISIBILITY
485 __unsafe_unretained _Tp*
486 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
492 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_DELETED_FUNCTIONS)
493 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
496 struct __two {char __lx[2];};
500 template <class _Tp, _Tp __v>
501 struct _LIBCPP_TEMPLATE_VIS integral_constant
503 static _LIBCPP_CONSTEXPR const _Tp value = __v;
504 typedef _Tp value_type;
505 typedef integral_constant type;
506 _LIBCPP_INLINE_VISIBILITY
507 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
508 #if _LIBCPP_STD_VER > 11
509 _LIBCPP_INLINE_VISIBILITY
510 constexpr value_type operator ()() const _NOEXCEPT {return value;}
514 template <class _Tp, _Tp __v>
515 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
517 #if _LIBCPP_STD_VER > 14
519 using bool_constant = integral_constant<bool, __b>;
520 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
522 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
525 typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
526 typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
528 #if !defined(_LIBCPP_CXX03_LANG)
532 template <bool _Last, class ..._Preds>
533 struct __lazy_and_impl;
535 template <class ..._Preds>
536 struct __lazy_and_impl<false, _Preds...> : false_type {};
539 struct __lazy_and_impl<true> : true_type {};
541 template <class _Pred>
542 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
544 template <class _Hp, class ..._Tp>
545 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
547 template <class _P1, class ..._Pr>
548 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
552 template <bool _List, class ..._Preds>
553 struct __lazy_or_impl;
555 template <class ..._Preds>
556 struct __lazy_or_impl<true, _Preds...> : true_type {};
559 struct __lazy_or_impl<false> : false_type {};
561 template <class _Hp, class ..._Tp>
562 struct __lazy_or_impl<false, _Hp, _Tp...>
563 : __lazy_or_impl<_Hp::type::value, _Tp...> {};
565 template <class _P1, class ..._Pr>
566 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
570 template <class _Pred>
571 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
574 template<class...> struct __and_;
575 template<> struct __and_<> : true_type {};
577 template<class _B0> struct __and_<_B0> : _B0 {};
579 template<class _B0, class _B1>
580 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
582 template<class _B0, class _B1, class _B2, class... _Bn>
583 struct __and_<_B0, _B1, _B2, _Bn...>
584 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
587 template<class...> struct __or_;
588 template<> struct __or_<> : false_type {};
590 template<class _B0> struct __or_<_B0> : _B0 {};
592 template<class _B0, class _B1>
593 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
595 template<class _B0, class _B1, class _B2, class... _Bn>
596 struct __or_<_B0, _B1, _B2, _Bn...>
597 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
601 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
603 #endif // !defined(_LIBCPP_CXX03_LANG)
607 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
608 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
610 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
611 template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
612 = is_const<_Tp>::value;
617 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
618 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
620 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
621 template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
622 = is_volatile<_Tp>::value;
627 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
628 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
629 #if _LIBCPP_STD_VER > 11
630 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
635 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
636 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
637 #if _LIBCPP_STD_VER > 11
638 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
643 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
644 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
645 #if _LIBCPP_STD_VER > 11
646 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
651 template <class _Tp> struct __libcpp_is_void : public false_type {};
652 template <> struct __libcpp_is_void<void> : public true_type {};
654 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
655 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
657 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
658 template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
659 = is_void<_Tp>::value;
664 template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
665 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
667 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
668 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
670 #if _LIBCPP_STD_VER > 11
671 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
672 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
674 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
675 template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
676 = is_null_pointer<_Tp>::value;
682 template <class _Tp> struct __libcpp_is_integral : public false_type {};
683 template <> struct __libcpp_is_integral<bool> : public true_type {};
684 template <> struct __libcpp_is_integral<char> : public true_type {};
685 template <> struct __libcpp_is_integral<signed char> : public true_type {};
686 template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
687 template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
688 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
689 template <> struct __libcpp_is_integral<char16_t> : public true_type {};
690 template <> struct __libcpp_is_integral<char32_t> : public true_type {};
691 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
692 template <> struct __libcpp_is_integral<short> : public true_type {};
693 template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
694 template <> struct __libcpp_is_integral<int> : public true_type {};
695 template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
696 template <> struct __libcpp_is_integral<long> : public true_type {};
697 template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
698 template <> struct __libcpp_is_integral<long long> : public true_type {};
699 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
700 #ifndef _LIBCPP_HAS_NO_INT128
701 template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
702 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
705 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
706 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
708 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
709 template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
710 = is_integral<_Tp>::value;
715 template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
716 template <> struct __libcpp_is_floating_point<float> : public true_type {};
717 template <> struct __libcpp_is_floating_point<double> : public true_type {};
718 template <> struct __libcpp_is_floating_point<long double> : public true_type {};
720 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
721 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
723 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
724 template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
725 = is_floating_point<_Tp>::value;
730 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
731 : public false_type {};
732 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
733 : public true_type {};
734 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
735 : public true_type {};
737 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
738 template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
739 = is_array<_Tp>::value;
744 template <class _Tp> struct __libcpp_is_pointer : public false_type {};
745 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
747 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
748 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
750 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
751 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
752 = is_pointer<_Tp>::value;
757 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
758 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
760 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
761 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
762 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
765 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
766 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
767 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
768 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
771 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
772 template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
773 = is_reference<_Tp>::value;
775 template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
776 = is_lvalue_reference<_Tp>::value;
778 template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
779 = is_rvalue_reference<_Tp>::value;
783 #if __has_feature(is_union) || (_GNUC_VER >= 403)
785 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
786 : public integral_constant<bool, __is_union(_Tp)> {};
790 template <class _Tp> struct __libcpp_union : public false_type {};
791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
792 : public __libcpp_union<typename remove_cv<_Tp>::type> {};
796 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
797 template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
798 = is_union<_Tp>::value;
803 #if __has_feature(is_class) || (_GNUC_VER >= 403)
805 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
806 : public integral_constant<bool, __is_class(_Tp)> {};
810 namespace __is_class_imp
812 template <class _Tp> char __test(int _Tp::*);
813 template <class _Tp> __two __test(...);
816 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
817 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
821 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
822 template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
823 = is_class<_Tp>::value;
828 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
829 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
831 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
832 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
833 = is_same<_Tp, _Up>::value;
838 namespace __libcpp_is_function_imp
840 struct __dummy_type {};
841 template <class _Tp> char __test(_Tp*);
842 template <class _Tp> char __test(__dummy_type);
843 template <class _Tp> __two __test(...);
844 template <class _Tp> _Tp& __source(int);
845 template <class _Tp> __dummy_type __source(...);
848 template <class _Tp, bool = is_class<_Tp>::value ||
849 is_union<_Tp>::value ||
850 is_void<_Tp>::value ||
851 is_reference<_Tp>::value ||
852 __is_nullptr_t<_Tp>::value >
853 struct __libcpp_is_function
854 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
856 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
858 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
859 : public __libcpp_is_function<_Tp> {};
861 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
862 template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
863 = is_function<_Tp>::value;
866 // is_member_function_pointer
868 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
869 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
872 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
873 struct __member_pointer_traits_imp
874 { // forward declaration; specializations later
878 template <class _Tp> struct __libcpp_is_member_function_pointer
879 : public false_type {};
881 template <class _Ret, class _Class>
882 struct __libcpp_is_member_function_pointer<_Ret _Class::*>
883 : public is_function<_Ret> {};
885 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
886 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
888 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
889 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
890 = is_member_function_pointer<_Tp>::value;
895 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
896 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
898 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
899 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
901 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
902 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
903 = is_member_pointer<_Tp>::value;
906 // is_member_object_pointer
908 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
909 : public integral_constant<bool, is_member_pointer<_Tp>::value &&
910 !is_member_function_pointer<_Tp>::value> {};
912 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
913 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
914 = is_member_object_pointer<_Tp>::value;
919 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
921 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
922 : public integral_constant<bool, __is_enum(_Tp)> {};
926 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
927 : public integral_constant<bool, !is_void<_Tp>::value &&
928 !is_integral<_Tp>::value &&
929 !is_floating_point<_Tp>::value &&
930 !is_array<_Tp>::value &&
931 !is_pointer<_Tp>::value &&
932 !is_reference<_Tp>::value &&
933 !is_member_pointer<_Tp>::value &&
934 !is_union<_Tp>::value &&
935 !is_class<_Tp>::value &&
936 !is_function<_Tp>::value > {};
940 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
941 template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
942 = is_enum<_Tp>::value;
947 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
948 : public integral_constant<bool, is_integral<_Tp>::value ||
949 is_floating_point<_Tp>::value> {};
951 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
952 template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
953 = is_arithmetic<_Tp>::value;
958 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
959 : public integral_constant<bool, is_void<_Tp>::value ||
960 __is_nullptr_t<_Tp>::value ||
961 is_arithmetic<_Tp>::value> {};
963 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
964 template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
965 = is_fundamental<_Tp>::value;
970 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
971 : public integral_constant<bool, is_arithmetic<_Tp>::value ||
972 is_member_pointer<_Tp>::value ||
973 is_pointer<_Tp>::value ||
974 __is_nullptr_t<_Tp>::value ||
975 is_enum<_Tp>::value > {};
977 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
979 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
980 template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
981 = is_scalar<_Tp>::value;
986 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
987 : public integral_constant<bool, is_scalar<_Tp>::value ||
988 is_array<_Tp>::value ||
989 is_union<_Tp>::value ||
990 is_class<_Tp>::value > {};
992 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
993 template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
994 = is_object<_Tp>::value;
999 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
1000 : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
1002 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1003 template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
1004 = is_compound<_Tp>::value;
1008 // __is_referenceable [defns.referenceable]
1010 struct __is_referenceable_impl {
1011 template <class _Tp> static _Tp& __test(int);
1012 template <class _Tp> static __two __test(...);
1015 template <class _Tp>
1016 struct __is_referenceable : integral_constant<bool,
1017 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
1022 template <class _Tp, bool = is_reference<_Tp>::value ||
1023 is_function<_Tp>::value ||
1024 is_const<_Tp>::value >
1025 struct __add_const {typedef _Tp type;};
1027 template <class _Tp>
1028 struct __add_const<_Tp, false> {typedef const _Tp type;};
1030 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
1031 {typedef typename __add_const<_Tp>::type type;};
1033 #if _LIBCPP_STD_VER > 11
1034 template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
1039 template <class _Tp, bool = is_reference<_Tp>::value ||
1040 is_function<_Tp>::value ||
1041 is_volatile<_Tp>::value >
1042 struct __add_volatile {typedef _Tp type;};
1044 template <class _Tp>
1045 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
1047 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile
1048 {typedef typename __add_volatile<_Tp>::type type;};
1050 #if _LIBCPP_STD_VER > 11
1051 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
1056 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv
1057 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
1059 #if _LIBCPP_STD_VER > 11
1060 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
1065 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;};
1066 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;};
1067 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1068 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
1071 #if _LIBCPP_STD_VER > 11
1072 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
1075 // add_lvalue_reference
1077 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
1078 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
1080 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
1081 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
1083 #if _LIBCPP_STD_VER > 11
1084 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1087 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1089 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
1090 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
1092 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
1093 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
1095 #if _LIBCPP_STD_VER > 11
1096 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1099 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1101 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1103 template <class _Tp> _Tp&& __declval(int);
1104 template <class _Tp> _Tp __declval(long);
1106 template <class _Tp>
1107 decltype(_VSTD::__declval<_Tp>(0))
1108 declval() _NOEXCEPT;
1110 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1112 template <class _Tp>
1113 typename add_lvalue_reference<_Tp>::type
1116 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1120 template <class _Tp>
1122 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
1125 template <class _Tp>
1126 struct __unconstref {
1127 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
1130 #ifndef _LIBCPP_CXX03_LANG
1131 template <class _Tp>
1132 using __uncvref_t = typename __uncvref<_Tp>::type;
1135 // __is_same_uncvref
1137 template <class _Tp, class _Up>
1138 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
1139 typename __uncvref<_Up>::type> {};
1148 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;};
1149 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;};
1150 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;};
1151 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
1152 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
1154 #if _LIBCPP_STD_VER > 11
1155 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
1160 template <class _Tp,
1161 bool = __is_referenceable<_Tp>::value ||
1162 is_same<typename remove_cv<_Tp>::type, void>::value>
1163 struct __add_pointer_impl
1164 {typedef typename remove_reference<_Tp>::type* type;};
1165 template <class _Tp> struct __add_pointer_impl<_Tp, false>
1166 {typedef _Tp type;};
1168 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
1169 {typedef typename __add_pointer_impl<_Tp>::type type;};
1171 #if _LIBCPP_STD_VER > 11
1172 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
1177 template <class _Tp, bool = is_integral<_Tp>::value>
1178 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
1180 template <class _Tp>
1181 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
1183 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1184 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
1186 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
1188 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
1190 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1191 template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
1192 = is_signed<_Tp>::value;
1197 template <class _Tp, bool = is_integral<_Tp>::value>
1198 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
1200 template <class _Tp>
1201 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
1203 template <class _Tp, bool = is_arithmetic<_Tp>::value>
1204 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
1206 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
1208 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
1210 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1211 template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
1212 = is_unsigned<_Tp>::value;
1217 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
1218 : public integral_constant<size_t, 0> {};
1219 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
1220 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1221 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
1222 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
1224 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1225 template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
1231 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
1232 : public integral_constant<size_t, 0> {};
1233 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
1234 : public integral_constant<size_t, 0> {};
1235 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
1236 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1237 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
1238 : public integral_constant<size_t, _Np> {};
1239 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
1240 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
1242 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1243 template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
1244 = extent<_Tp, _Ip>::value;
1249 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
1250 {typedef _Tp type;};
1251 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
1252 {typedef _Tp type;};
1253 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
1254 {typedef _Tp type;};
1256 #if _LIBCPP_STD_VER > 11
1257 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
1260 // remove_all_extents
1262 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
1263 {typedef _Tp type;};
1264 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
1265 {typedef typename remove_all_extents<_Tp>::type type;};
1266 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
1267 {typedef typename remove_all_extents<_Tp>::type type;};
1269 #if _LIBCPP_STD_VER > 11
1270 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1275 template <class _Tp>
1276 struct _LIBCPP_TEMPLATE_VIS decay
1279 typedef typename remove_reference<_Tp>::type _Up;
1281 typedef typename conditional
1283 is_array<_Up>::value,
1284 typename remove_extent<_Up>::type*,
1285 typename conditional
1287 is_function<_Up>::value,
1288 typename add_pointer<_Up>::type,
1289 typename remove_cv<_Up>::type
1294 #if _LIBCPP_STD_VER > 11
1295 template <class _Tp> using decay_t = typename decay<_Tp>::type;
1300 namespace __is_abstract_imp
1302 template <class _Tp> char __test(_Tp (*)[1]);
1303 template <class _Tp> __two __test(...);
1306 template <class _Tp, bool = is_class<_Tp>::value>
1307 struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
1309 template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
1311 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract : public __libcpp_abstract<_Tp> {};
1313 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1314 template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
1315 = is_abstract<_Tp>::value;
1320 #if defined(_LIBCPP_HAS_IS_FINAL)
1321 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1322 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
1324 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1325 __libcpp_is_final : public false_type {};
1328 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
1329 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
1330 is_final : public integral_constant<bool, __is_final(_Tp)> {};
1333 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1334 template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
1335 = is_final<_Tp>::value;
1340 #ifdef _LIBCPP_HAS_IS_BASE_OF
1342 template <class _Bp, class _Dp>
1343 struct _LIBCPP_TEMPLATE_VIS is_base_of
1344 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
1346 #else // _LIBCPP_HAS_IS_BASE_OF
1348 namespace __is_base_of_imp
1350 template <class _Tp>
1353 _Dst(const volatile _Tp &);
1355 template <class _Tp>
1358 operator const volatile _Tp &();
1359 template <class _Up> operator const _Dst<_Up> &();
1361 template <size_t> struct __one { typedef char type; };
1362 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
1363 template <class _Bp, class _Dp> __two __test(...);
1366 template <class _Bp, class _Dp>
1367 struct _LIBCPP_TEMPLATE_VIS is_base_of
1368 : public integral_constant<bool, is_class<_Bp>::value &&
1369 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
1371 #endif // _LIBCPP_HAS_IS_BASE_OF
1373 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1374 template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
1375 = is_base_of<_Bp, _Dp>::value;
1380 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
1382 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1383 : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
1384 !is_abstract<_T2>::value> {};
1386 #else // __has_feature(is_convertible_to)
1388 namespace __is_convertible_imp
1390 template <class _Tp> void __test_convert(_Tp);
1392 template <class _From, class _To, class = void>
1393 struct __is_convertible_test : public false_type {};
1395 template <class _From, class _To>
1396 struct __is_convertible_test<_From, _To,
1397 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
1400 template <class _Tp, bool _IsArray = is_array<_Tp>::value,
1401 bool _IsFunction = is_function<_Tp>::value,
1402 bool _IsVoid = is_void<_Tp>::value>
1403 struct __is_array_function_or_void {enum {value = 0};};
1404 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
1405 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
1406 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
1409 template <class _Tp,
1410 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
1411 struct __is_convertible_check
1413 static const size_t __v = 0;
1416 template <class _Tp>
1417 struct __is_convertible_check<_Tp, 0>
1419 static const size_t __v = sizeof(_Tp);
1422 template <class _T1, class _T2,
1423 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
1424 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
1425 struct __is_convertible
1426 : public integral_constant<bool,
1427 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
1428 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1429 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
1430 && (!is_const<typename remove_reference<_T2>::type>::value
1431 || is_volatile<typename remove_reference<_T2>::type>::value)
1432 && (is_same<typename remove_cv<_T1>::type,
1433 typename remove_cv<typename remove_reference<_T2>::type>::type>::value
1434 || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
1439 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
1440 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
1441 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
1442 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
1444 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
1445 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
1446 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
1447 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
1449 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
1450 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
1451 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
1452 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
1454 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
1455 : public __is_convertible<_T1, _T2>
1457 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
1458 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
1461 #endif // __has_feature(is_convertible_to)
1463 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1464 template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
1465 = is_convertible<_From, _To>::value;
1470 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
1472 template <class _Tp>
1473 struct _LIBCPP_TEMPLATE_VIS is_empty
1474 : public integral_constant<bool, __is_empty(_Tp)> {};
1476 #else // __has_feature(is_empty)
1478 template <class _Tp>
1490 template <class _Tp, bool = is_class<_Tp>::value>
1491 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
1493 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
1495 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
1497 #endif // __has_feature(is_empty)
1499 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1500 template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
1501 = is_empty<_Tp>::value;
1506 #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
1508 template <class _Tp>
1509 struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1510 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
1514 template<typename _Tp> char &__is_polymorphic_impl(
1515 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
1517 template<typename _Tp> __two &__is_polymorphic_impl(...);
1519 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
1520 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
1522 #endif // __has_feature(is_polymorphic)
1524 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1525 template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
1526 = is_polymorphic<_Tp>::value;
1529 // has_virtual_destructor
1531 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
1533 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1534 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
1538 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
1539 : public false_type {};
1543 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1544 template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
1545 = has_virtual_destructor<_Tp>::value;
1550 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
1551 : public integral_constant<size_t, __alignof__(_Tp)> {};
1553 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
1554 template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
1555 = alignment_of<_Tp>::value;
1560 template <class _Hp, class _Tp>
1569 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1571 __nat(const __nat&) = delete;
1572 __nat& operator=(const __nat&) = delete;
1577 template <class _Tp>
1580 static const size_t value = alignment_of<_Tp>::value;
1584 struct __struct_double {long double __lx;};
1585 struct __struct_double4 {double __lx[4];};
1588 __type_list<__align_type<unsigned char>,
1589 __type_list<__align_type<unsigned short>,
1590 __type_list<__align_type<unsigned int>,
1591 __type_list<__align_type<unsigned long>,
1592 __type_list<__align_type<unsigned long long>,
1593 __type_list<__align_type<double>,
1594 __type_list<__align_type<long double>,
1595 __type_list<__align_type<__struct_double>,
1596 __type_list<__align_type<__struct_double4>,
1597 __type_list<__align_type<int*>,
1599 > > > > > > > > > > __all_types;
1601 template <class _TL, size_t _Align> struct __find_pod;
1603 template <class _Hp, size_t _Align>
1604 struct __find_pod<__type_list<_Hp, __nat>, _Align>
1606 typedef typename conditional<
1607 _Align == _Hp::value,
1613 template <class _Hp, class _Tp, size_t _Align>
1614 struct __find_pod<__type_list<_Hp, _Tp>, _Align>
1616 typedef typename conditional<
1617 _Align == _Hp::value,
1619 typename __find_pod<_Tp, _Align>::type
1623 template <class _TL, size_t _Len> struct __find_max_align;
1625 template <class _Hp, size_t _Len>
1626 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
1628 template <size_t _Len, size_t _A1, size_t _A2>
1629 struct __select_align
1632 static const size_t __min = _A2 < _A1 ? _A2 : _A1;
1633 static const size_t __max = _A1 < _A2 ? _A2 : _A1;
1635 static const size_t value = _Len < __max ? __min : __max;
1638 template <class _Hp, class _Tp, size_t _Len>
1639 struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
1640 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
1642 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1643 struct _LIBCPP_TEMPLATE_VIS aligned_storage
1645 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
1646 static_assert(!is_void<_Aligner>::value, "");
1650 unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
1654 #if _LIBCPP_STD_VER > 11
1655 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
1656 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
1659 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
1660 template <size_t _Len>\
1661 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
1663 struct _ALIGNAS(n) type\
1665 unsigned char __lx[(_Len + n - 1)/n * n];\
1669 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
1670 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
1671 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
1672 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
1673 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
1674 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
1675 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
1676 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
1677 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
1678 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
1679 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
1680 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
1681 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
1682 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
1683 // PE/COFF does not support alignment beyond 8192 (=0x2000)
1684 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1685 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
1686 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1688 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
1690 #ifndef _LIBCPP_HAS_NO_VARIADICS
1694 template <size_t _I0, size_t ..._In>
1695 struct __static_max;
1697 template <size_t _I0>
1698 struct __static_max<_I0>
1700 static const size_t value = _I0;
1703 template <size_t _I0, size_t _I1, size_t ..._In>
1704 struct __static_max<_I0, _I1, _In...>
1706 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
1707 __static_max<_I1, _In...>::value;
1710 template <size_t _Len, class _Type0, class ..._Types>
1711 struct aligned_union
1713 static const size_t alignment_value = __static_max<__alignof__(_Type0),
1714 __alignof__(_Types)...>::value;
1715 static const size_t __len = __static_max<_Len, sizeof(_Type0),
1716 sizeof(_Types)...>::value;
1717 typedef typename aligned_storage<__len, alignment_value>::type type;
1720 #if _LIBCPP_STD_VER > 11
1721 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
1724 #endif // _LIBCPP_HAS_NO_VARIADICS
1726 template <class _Tp>
1727 struct __numeric_type
1729 static void __test(...);
1730 static float __test(float);
1731 static double __test(char);
1732 static double __test(int);
1733 static double __test(unsigned);
1734 static double __test(long);
1735 static double __test(unsigned long);
1736 static double __test(long long);
1737 static double __test(unsigned long long);
1738 static double __test(double);
1739 static long double __test(long double);
1741 typedef decltype(__test(declval<_Tp>())) type;
1742 static const bool value = !is_same<type, void>::value;
1746 struct __numeric_type<void>
1748 static const bool value = true;
1753 template <class _A1, class _A2 = void, class _A3 = void,
1754 bool = __numeric_type<_A1>::value &&
1755 __numeric_type<_A2>::value &&
1756 __numeric_type<_A3>::value>
1760 static const bool value = false;
1763 template <class _A1, class _A2, class _A3>
1764 class __promote_imp<_A1, _A2, _A3, true>
1767 typedef typename __promote_imp<_A1>::type __type1;
1768 typedef typename __promote_imp<_A2>::type __type2;
1769 typedef typename __promote_imp<_A3>::type __type3;
1771 typedef decltype(__type1() + __type2() + __type3()) type;
1772 static const bool value = true;
1775 template <class _A1, class _A2>
1776 class __promote_imp<_A1, _A2, void, true>
1779 typedef typename __promote_imp<_A1>::type __type1;
1780 typedef typename __promote_imp<_A2>::type __type2;
1782 typedef decltype(__type1() + __type2()) type;
1783 static const bool value = true;
1786 template <class _A1>
1787 class __promote_imp<_A1, void, void, true>
1790 typedef typename __numeric_type<_A1>::type type;
1791 static const bool value = true;
1794 template <class _A1, class _A2 = void, class _A3 = void>
1795 class __promote : public __promote_imp<_A1, _A2, _A3> {};
1797 // make_signed / make_unsigned
1800 __type_list<signed char,
1801 __type_list<signed short,
1802 __type_list<signed int,
1803 __type_list<signed long,
1804 __type_list<signed long long,
1805 #ifndef _LIBCPP_HAS_NO_INT128
1806 __type_list<__int128_t,
1809 #ifndef _LIBCPP_HAS_NO_INT128
1812 > > > > > __signed_types;
1815 __type_list<unsigned char,
1816 __type_list<unsigned short,
1817 __type_list<unsigned int,
1818 __type_list<unsigned long,
1819 __type_list<unsigned long long,
1820 #ifndef _LIBCPP_HAS_NO_INT128
1821 __type_list<__uint128_t,
1824 #ifndef _LIBCPP_HAS_NO_INT128
1827 > > > > > __unsigned_types;
1829 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
1831 template <class _Hp, class _Tp, size_t _Size>
1832 struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1837 template <class _Hp, class _Tp, size_t _Size>
1838 struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1840 typedef typename __find_first<_Tp, _Size>::type type;
1843 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1844 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1850 template <class _Tp, class _Up>
1851 struct __apply_cv<_Tp, _Up, true, false>
1853 typedef const _Up type;
1856 template <class _Tp, class _Up>
1857 struct __apply_cv<_Tp, _Up, false, true>
1859 typedef volatile _Up type;
1862 template <class _Tp, class _Up>
1863 struct __apply_cv<_Tp, _Up, true, true>
1865 typedef const volatile _Up type;
1868 template <class _Tp, class _Up>
1869 struct __apply_cv<_Tp&, _Up, false, false>
1874 template <class _Tp, class _Up>
1875 struct __apply_cv<_Tp&, _Up, true, false>
1877 typedef const _Up& type;
1880 template <class _Tp, class _Up>
1881 struct __apply_cv<_Tp&, _Up, false, true>
1883 typedef volatile _Up& type;
1886 template <class _Tp, class _Up>
1887 struct __apply_cv<_Tp&, _Up, true, true>
1889 typedef const volatile _Up& type;
1892 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1893 struct __make_signed {};
1895 template <class _Tp>
1896 struct __make_signed<_Tp, true>
1898 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1901 template <> struct __make_signed<bool, true> {};
1902 template <> struct __make_signed< signed short, true> {typedef short type;};
1903 template <> struct __make_signed<unsigned short, true> {typedef short type;};
1904 template <> struct __make_signed< signed int, true> {typedef int type;};
1905 template <> struct __make_signed<unsigned int, true> {typedef int type;};
1906 template <> struct __make_signed< signed long, true> {typedef long type;};
1907 template <> struct __make_signed<unsigned long, true> {typedef long type;};
1908 template <> struct __make_signed< signed long long, true> {typedef long long type;};
1909 template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1910 #ifndef _LIBCPP_HAS_NO_INT128
1911 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
1912 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
1915 template <class _Tp>
1916 struct _LIBCPP_TEMPLATE_VIS make_signed
1918 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1921 #if _LIBCPP_STD_VER > 11
1922 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1925 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1926 struct __make_unsigned {};
1928 template <class _Tp>
1929 struct __make_unsigned<_Tp, true>
1931 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1934 template <> struct __make_unsigned<bool, true> {};
1935 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
1936 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
1937 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
1938 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
1939 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
1940 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
1941 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
1942 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1943 #ifndef _LIBCPP_HAS_NO_INT128
1944 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
1945 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
1948 template <class _Tp>
1949 struct _LIBCPP_TEMPLATE_VIS make_unsigned
1951 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1954 #if _LIBCPP_STD_VER > 11
1955 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1958 #ifdef _LIBCPP_HAS_NO_VARIADICS
1960 template <class _Tp, class _Up = void, class _Vp = void>
1961 struct _LIBCPP_TEMPLATE_VIS common_type
1964 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
1967 template <class _Tp>
1968 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
1971 typedef typename decay<_Tp>::type type;
1974 template <class _Tp, class _Up>
1975 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void>
1977 typedef typename decay<decltype(
1978 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
1982 #else // _LIBCPP_HAS_NO_VARIADICS
1984 // bullet 1 - sizeof...(Tp) == 0
1986 template <class ..._Tp>
1987 struct _LIBCPP_TEMPLATE_VIS common_type {};
1989 // bullet 2 - sizeof...(Tp) == 1
1991 template <class _Tp>
1992 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
1994 typedef typename decay<_Tp>::type type;
1997 // bullet 3 - sizeof...(Tp) == 2
1999 template <class _Tp, class _Up, class = void>
2000 struct __common_type2_imp {};
2002 template <class _Tp, class _Up>
2003 struct __common_type2_imp<_Tp, _Up,
2004 typename __void_t<decltype(
2005 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2008 typedef typename decay<decltype(
2009 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
2013 template <class _Tp, class _Up,
2014 class _DTp = typename decay<_Tp>::type,
2015 class _DUp = typename decay<_Up>::type>
2016 using __common_type2 =
2017 typename conditional<
2018 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
2019 __common_type2_imp<_Tp, _Up>,
2020 common_type<_DTp, _DUp>
2023 template <class _Tp, class _Up>
2024 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
2025 : __common_type2<_Tp, _Up> {};
2027 // bullet 4 - sizeof...(Tp) > 2
2029 template <class ...Tp> struct __common_types;
2031 template <class, class = void>
2032 struct __common_type_impl {};
2034 template <class _Tp, class _Up>
2035 struct __common_type_impl<
2036 __common_types<_Tp, _Up>,
2037 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2039 typedef typename common_type<_Tp, _Up>::type type;
2042 template <class _Tp, class _Up, class ..._Vp>
2043 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
2044 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
2045 : __common_type_impl<
2046 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
2051 template <class _Tp, class _Up, class ..._Vp>
2052 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...>
2053 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
2055 #if _LIBCPP_STD_VER > 11
2056 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
2059 #endif // _LIBCPP_HAS_NO_VARIADICS
2063 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
2065 template <class _Tp, class _Arg>
2066 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
2067 __is_assignable_test(int);
2069 template <class, class>
2070 false_type __is_assignable_test(...);
2073 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
2074 struct __is_assignable_imp
2075 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
2077 template <class _Tp, class _Arg>
2078 struct __is_assignable_imp<_Tp, _Arg, true>
2083 template <class _Tp, class _Arg>
2084 struct is_assignable
2085 : public __is_assignable_imp<_Tp, _Arg> {};
2087 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2088 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
2089 = is_assignable<_Tp, _Arg>::value;
2092 // is_copy_assignable
2094 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
2095 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2096 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2098 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2099 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
2100 = is_copy_assignable<_Tp>::value;
2103 // is_move_assignable
2105 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
2106 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2107 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
2108 typename add_rvalue_reference<_Tp>::type> {};
2110 : public is_copy_assignable<_Tp> {};
2113 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2114 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
2115 = is_move_assignable<_Tp>::value;
2120 // if it's a reference, return true
2121 // if it's a function, return false
2122 // if it's void, return false
2123 // if it's an array of unknown bound, return false
2124 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
2125 // where _Up is remove_all_extents<_Tp>::type
2128 struct __is_destructible_apply { typedef int type; };
2130 template <typename _Tp>
2131 struct __is_destructor_wellformed {
2132 template <typename _Tp1>
2133 static char __test (
2134 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
2137 template <typename _Tp1>
2138 static __two __test (...);
2140 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
2143 template <class _Tp, bool>
2144 struct __destructible_imp;
2146 template <class _Tp>
2147 struct __destructible_imp<_Tp, false>
2148 : public _VSTD::integral_constant<bool,
2149 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
2151 template <class _Tp>
2152 struct __destructible_imp<_Tp, true>
2153 : public _VSTD::true_type {};
2155 template <class _Tp, bool>
2156 struct __destructible_false;
2158 template <class _Tp>
2159 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
2161 template <class _Tp>
2162 struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
2164 template <class _Tp>
2165 struct is_destructible
2166 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
2168 template <class _Tp>
2169 struct is_destructible<_Tp[]>
2170 : public _VSTD::false_type {};
2173 struct is_destructible<void>
2174 : public _VSTD::false_type {};
2176 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
2177 template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
2178 = is_destructible<_Tp>::value;
2183 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2185 template <class _Tp>
2186 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2187 typename remove_reference<_Tp>::type&&
2188 move(_Tp&& __t) _NOEXCEPT
2190 typedef typename remove_reference<_Tp>::type _Up;
2191 return static_cast<_Up&&>(__t);
2194 template <class _Tp>
2195 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2197 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2199 return static_cast<_Tp&&>(__t);
2202 template <class _Tp>
2203 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2205 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
2207 static_assert(!is_lvalue_reference<_Tp>::value,
2208 "can not forward an rvalue as an lvalue");
2209 return static_cast<_Tp&&>(__t);
2212 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2214 template <class _Tp>
2215 inline _LIBCPP_INLINE_VISIBILITY
2222 template <class _Tp>
2223 inline _LIBCPP_INLINE_VISIBILITY
2225 move(const _Tp& __t)
2230 template <class _Tp>
2231 inline _LIBCPP_INLINE_VISIBILITY
2233 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
2239 template <class _Tp>
2242 typedef typename remove_reference<_Tp>::type _Trr;
2245 _LIBCPP_INLINE_VISIBILITY
2246 _Trr* operator->() {return &t_;}
2247 _LIBCPP_INLINE_VISIBILITY
2248 explicit __rv(_Trr& __t) : t_(__t) {}
2251 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2253 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2255 template <class _Tp>
2256 inline _LIBCPP_INLINE_VISIBILITY
2257 typename decay<_Tp>::type
2258 __decay_copy(_Tp&& __t)
2260 return _VSTD::forward<_Tp>(__t);
2265 template <class _Tp>
2266 inline _LIBCPP_INLINE_VISIBILITY
2267 typename decay<_Tp>::type
2268 __decay_copy(const _Tp& __t)
2270 return _VSTD::forward<_Tp>(__t);
2275 #ifndef _LIBCPP_HAS_NO_VARIADICS
2277 template <class _Rp, class _Class, class ..._Param>
2278 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
2280 typedef _Class _ClassType;
2281 typedef _Rp _ReturnType;
2282 typedef _Rp (_FnType) (_Param...);
2285 template <class _Rp, class _Class, class ..._Param>
2286 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
2288 typedef _Class _ClassType;
2289 typedef _Rp _ReturnType;
2290 typedef _Rp (_FnType) (_Param..., ...);
2293 template <class _Rp, class _Class, class ..._Param>
2294 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
2296 typedef _Class const _ClassType;
2297 typedef _Rp _ReturnType;
2298 typedef _Rp (_FnType) (_Param...);
2301 template <class _Rp, class _Class, class ..._Param>
2302 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
2304 typedef _Class const _ClassType;
2305 typedef _Rp _ReturnType;
2306 typedef _Rp (_FnType) (_Param..., ...);
2309 template <class _Rp, class _Class, class ..._Param>
2310 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
2312 typedef _Class volatile _ClassType;
2313 typedef _Rp _ReturnType;
2314 typedef _Rp (_FnType) (_Param...);
2317 template <class _Rp, class _Class, class ..._Param>
2318 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
2320 typedef _Class volatile _ClassType;
2321 typedef _Rp _ReturnType;
2322 typedef _Rp (_FnType) (_Param..., ...);
2325 template <class _Rp, class _Class, class ..._Param>
2326 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
2328 typedef _Class const volatile _ClassType;
2329 typedef _Rp _ReturnType;
2330 typedef _Rp (_FnType) (_Param...);
2333 template <class _Rp, class _Class, class ..._Param>
2334 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
2336 typedef _Class const volatile _ClassType;
2337 typedef _Rp _ReturnType;
2338 typedef _Rp (_FnType) (_Param..., ...);
2341 #if __has_feature(cxx_reference_qualified_functions) || \
2342 (defined(_GNUC_VER) && _GNUC_VER >= 409)
2344 template <class _Rp, class _Class, class ..._Param>
2345 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
2347 typedef _Class& _ClassType;
2348 typedef _Rp _ReturnType;
2349 typedef _Rp (_FnType) (_Param...);
2352 template <class _Rp, class _Class, class ..._Param>
2353 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
2355 typedef _Class& _ClassType;
2356 typedef _Rp _ReturnType;
2357 typedef _Rp (_FnType) (_Param..., ...);
2360 template <class _Rp, class _Class, class ..._Param>
2361 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
2363 typedef _Class const& _ClassType;
2364 typedef _Rp _ReturnType;
2365 typedef _Rp (_FnType) (_Param...);
2368 template <class _Rp, class _Class, class ..._Param>
2369 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
2371 typedef _Class const& _ClassType;
2372 typedef _Rp _ReturnType;
2373 typedef _Rp (_FnType) (_Param..., ...);
2376 template <class _Rp, class _Class, class ..._Param>
2377 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
2379 typedef _Class volatile& _ClassType;
2380 typedef _Rp _ReturnType;
2381 typedef _Rp (_FnType) (_Param...);
2384 template <class _Rp, class _Class, class ..._Param>
2385 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
2387 typedef _Class volatile& _ClassType;
2388 typedef _Rp _ReturnType;
2389 typedef _Rp (_FnType) (_Param..., ...);
2392 template <class _Rp, class _Class, class ..._Param>
2393 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
2395 typedef _Class const volatile& _ClassType;
2396 typedef _Rp _ReturnType;
2397 typedef _Rp (_FnType) (_Param...);
2400 template <class _Rp, class _Class, class ..._Param>
2401 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
2403 typedef _Class const volatile& _ClassType;
2404 typedef _Rp _ReturnType;
2405 typedef _Rp (_FnType) (_Param..., ...);
2408 template <class _Rp, class _Class, class ..._Param>
2409 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
2411 typedef _Class&& _ClassType;
2412 typedef _Rp _ReturnType;
2413 typedef _Rp (_FnType) (_Param...);
2416 template <class _Rp, class _Class, class ..._Param>
2417 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
2419 typedef _Class&& _ClassType;
2420 typedef _Rp _ReturnType;
2421 typedef _Rp (_FnType) (_Param..., ...);
2424 template <class _Rp, class _Class, class ..._Param>
2425 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
2427 typedef _Class const&& _ClassType;
2428 typedef _Rp _ReturnType;
2429 typedef _Rp (_FnType) (_Param...);
2432 template <class _Rp, class _Class, class ..._Param>
2433 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
2435 typedef _Class const&& _ClassType;
2436 typedef _Rp _ReturnType;
2437 typedef _Rp (_FnType) (_Param..., ...);
2440 template <class _Rp, class _Class, class ..._Param>
2441 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
2443 typedef _Class volatile&& _ClassType;
2444 typedef _Rp _ReturnType;
2445 typedef _Rp (_FnType) (_Param...);
2448 template <class _Rp, class _Class, class ..._Param>
2449 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
2451 typedef _Class volatile&& _ClassType;
2452 typedef _Rp _ReturnType;
2453 typedef _Rp (_FnType) (_Param..., ...);
2456 template <class _Rp, class _Class, class ..._Param>
2457 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
2459 typedef _Class const volatile&& _ClassType;
2460 typedef _Rp _ReturnType;
2461 typedef _Rp (_FnType) (_Param...);
2464 template <class _Rp, class _Class, class ..._Param>
2465 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
2467 typedef _Class const volatile&& _ClassType;
2468 typedef _Rp _ReturnType;
2469 typedef _Rp (_FnType) (_Param..., ...);
2472 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
2474 #else // _LIBCPP_HAS_NO_VARIADICS
2476 template <class _Rp, class _Class>
2477 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
2479 typedef _Class _ClassType;
2480 typedef _Rp _ReturnType;
2481 typedef _Rp (_FnType) ();
2484 template <class _Rp, class _Class>
2485 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
2487 typedef _Class _ClassType;
2488 typedef _Rp _ReturnType;
2489 typedef _Rp (_FnType) (...);
2492 template <class _Rp, class _Class, class _P0>
2493 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
2495 typedef _Class _ClassType;
2496 typedef _Rp _ReturnType;
2497 typedef _Rp (_FnType) (_P0);
2500 template <class _Rp, class _Class, class _P0>
2501 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
2503 typedef _Class _ClassType;
2504 typedef _Rp _ReturnType;
2505 typedef _Rp (_FnType) (_P0, ...);
2508 template <class _Rp, class _Class, class _P0, class _P1>
2509 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
2511 typedef _Class _ClassType;
2512 typedef _Rp _ReturnType;
2513 typedef _Rp (_FnType) (_P0, _P1);
2516 template <class _Rp, class _Class, class _P0, class _P1>
2517 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
2519 typedef _Class _ClassType;
2520 typedef _Rp _ReturnType;
2521 typedef _Rp (_FnType) (_P0, _P1, ...);
2524 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2525 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
2527 typedef _Class _ClassType;
2528 typedef _Rp _ReturnType;
2529 typedef _Rp (_FnType) (_P0, _P1, _P2);
2532 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2533 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
2535 typedef _Class _ClassType;
2536 typedef _Rp _ReturnType;
2537 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2540 template <class _Rp, class _Class>
2541 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
2543 typedef _Class const _ClassType;
2544 typedef _Rp _ReturnType;
2545 typedef _Rp (_FnType) ();
2548 template <class _Rp, class _Class>
2549 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
2551 typedef _Class const _ClassType;
2552 typedef _Rp _ReturnType;
2553 typedef _Rp (_FnType) (...);
2556 template <class _Rp, class _Class, class _P0>
2557 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
2559 typedef _Class const _ClassType;
2560 typedef _Rp _ReturnType;
2561 typedef _Rp (_FnType) (_P0);
2564 template <class _Rp, class _Class, class _P0>
2565 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
2567 typedef _Class const _ClassType;
2568 typedef _Rp _ReturnType;
2569 typedef _Rp (_FnType) (_P0, ...);
2572 template <class _Rp, class _Class, class _P0, class _P1>
2573 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
2575 typedef _Class const _ClassType;
2576 typedef _Rp _ReturnType;
2577 typedef _Rp (_FnType) (_P0, _P1);
2580 template <class _Rp, class _Class, class _P0, class _P1>
2581 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
2583 typedef _Class const _ClassType;
2584 typedef _Rp _ReturnType;
2585 typedef _Rp (_FnType) (_P0, _P1, ...);
2588 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2589 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
2591 typedef _Class const _ClassType;
2592 typedef _Rp _ReturnType;
2593 typedef _Rp (_FnType) (_P0, _P1, _P2);
2596 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2597 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
2599 typedef _Class const _ClassType;
2600 typedef _Rp _ReturnType;
2601 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2604 template <class _Rp, class _Class>
2605 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
2607 typedef _Class volatile _ClassType;
2608 typedef _Rp _ReturnType;
2609 typedef _Rp (_FnType) ();
2612 template <class _Rp, class _Class>
2613 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
2615 typedef _Class volatile _ClassType;
2616 typedef _Rp _ReturnType;
2617 typedef _Rp (_FnType) (...);
2620 template <class _Rp, class _Class, class _P0>
2621 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
2623 typedef _Class volatile _ClassType;
2624 typedef _Rp _ReturnType;
2625 typedef _Rp (_FnType) (_P0);
2628 template <class _Rp, class _Class, class _P0>
2629 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
2631 typedef _Class volatile _ClassType;
2632 typedef _Rp _ReturnType;
2633 typedef _Rp (_FnType) (_P0, ...);
2636 template <class _Rp, class _Class, class _P0, class _P1>
2637 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
2639 typedef _Class volatile _ClassType;
2640 typedef _Rp _ReturnType;
2641 typedef _Rp (_FnType) (_P0, _P1);
2644 template <class _Rp, class _Class, class _P0, class _P1>
2645 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
2647 typedef _Class volatile _ClassType;
2648 typedef _Rp _ReturnType;
2649 typedef _Rp (_FnType) (_P0, _P1, ...);
2652 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2653 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
2655 typedef _Class volatile _ClassType;
2656 typedef _Rp _ReturnType;
2657 typedef _Rp (_FnType) (_P0, _P1, _P2);
2660 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2661 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
2663 typedef _Class volatile _ClassType;
2664 typedef _Rp _ReturnType;
2665 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2668 template <class _Rp, class _Class>
2669 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
2671 typedef _Class const volatile _ClassType;
2672 typedef _Rp _ReturnType;
2673 typedef _Rp (_FnType) ();
2676 template <class _Rp, class _Class>
2677 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
2679 typedef _Class const volatile _ClassType;
2680 typedef _Rp _ReturnType;
2681 typedef _Rp (_FnType) (...);
2684 template <class _Rp, class _Class, class _P0>
2685 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
2687 typedef _Class const volatile _ClassType;
2688 typedef _Rp _ReturnType;
2689 typedef _Rp (_FnType) (_P0);
2692 template <class _Rp, class _Class, class _P0>
2693 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
2695 typedef _Class const volatile _ClassType;
2696 typedef _Rp _ReturnType;
2697 typedef _Rp (_FnType) (_P0, ...);
2700 template <class _Rp, class _Class, class _P0, class _P1>
2701 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
2703 typedef _Class const volatile _ClassType;
2704 typedef _Rp _ReturnType;
2705 typedef _Rp (_FnType) (_P0, _P1);
2708 template <class _Rp, class _Class, class _P0, class _P1>
2709 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
2711 typedef _Class const volatile _ClassType;
2712 typedef _Rp _ReturnType;
2713 typedef _Rp (_FnType) (_P0, _P1, ...);
2716 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2717 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
2719 typedef _Class const volatile _ClassType;
2720 typedef _Rp _ReturnType;
2721 typedef _Rp (_FnType) (_P0, _P1, _P2);
2724 template <class _Rp, class _Class, class _P0, class _P1, class _P2>
2725 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
2727 typedef _Class const volatile _ClassType;
2728 typedef _Rp _ReturnType;
2729 typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
2732 #endif // _LIBCPP_HAS_NO_VARIADICS
2734 template <class _Rp, class _Class>
2735 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
2737 typedef _Class _ClassType;
2738 typedef _Rp _ReturnType;
2741 template <class _MP>
2742 struct __member_pointer_traits
2743 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
2744 is_member_function_pointer<_MP>::value,
2745 is_member_object_pointer<_MP>::value>
2747 // typedef ... _ClassType;
2748 // typedef ... _ReturnType;
2749 // typedef ... _FnType;
2753 template <class _DecayedFp>
2754 struct __member_pointer_class_type {};
2756 template <class _Ret, class _ClassType>
2757 struct __member_pointer_class_type<_Ret _ClassType::*> {
2758 typedef _ClassType type;
2763 template <class _Callable> class result_of;
2765 #ifdef _LIBCPP_HAS_NO_VARIADICS
2767 template <class _Fn, bool, bool>
2772 template <class _Fn>
2773 class __result_of<_Fn(), true, false>
2776 typedef decltype(declval<_Fn>()()) type;
2779 template <class _Fn, class _A0>
2780 class __result_of<_Fn(_A0), true, false>
2783 typedef decltype(declval<_Fn>()(declval<_A0>())) type;
2786 template <class _Fn, class _A0, class _A1>
2787 class __result_of<_Fn(_A0, _A1), true, false>
2790 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
2793 template <class _Fn, class _A0, class _A1, class _A2>
2794 class __result_of<_Fn(_A0, _A1, _A2), true, false>
2797 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
2800 template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2801 struct __result_of_mp;
2803 // member function pointer
2805 template <class _MP, class _Tp>
2806 struct __result_of_mp<_MP, _Tp, true>
2807 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
2811 // member data pointer
2813 template <class _MP, class _Tp, bool>
2814 struct __result_of_mdp;
2816 template <class _Rp, class _Class, class _Tp>
2817 struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2819 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
2822 template <class _Rp, class _Class, class _Tp>
2823 struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2825 typedef typename __apply_cv<_Tp, _Rp>::type& type;
2828 template <class _Rp, class _Class, class _Tp>
2829 struct __result_of_mp<_Rp _Class::*, _Tp, false>
2830 : public __result_of_mdp<_Rp _Class::*, _Tp,
2831 is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2837 template <class _Fn, class _Tp>
2838 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
2839 : public __result_of_mp<typename remove_reference<_Fn>::type,
2841 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2845 template <class _Fn, class _Tp, class _A0>
2846 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
2847 : public __result_of_mp<typename remove_reference<_Fn>::type,
2849 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2853 template <class _Fn, class _Tp, class _A0, class _A1>
2854 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
2855 : public __result_of_mp<typename remove_reference<_Fn>::type,
2857 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2861 template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
2862 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
2863 : public __result_of_mp<typename remove_reference<_Fn>::type,
2865 is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2871 template <class _Fn>
2872 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()>
2873 : public __result_of<_Fn(),
2874 is_class<typename remove_reference<_Fn>::type>::value ||
2875 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2876 is_member_pointer<typename remove_reference<_Fn>::type>::value
2881 template <class _Fn, class _A0>
2882 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)>
2883 : public __result_of<_Fn(_A0),
2884 is_class<typename remove_reference<_Fn>::type>::value ||
2885 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2886 is_member_pointer<typename remove_reference<_Fn>::type>::value
2891 template <class _Fn, class _A0, class _A1>
2892 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)>
2893 : public __result_of<_Fn(_A0, _A1),
2894 is_class<typename remove_reference<_Fn>::type>::value ||
2895 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2896 is_member_pointer<typename remove_reference<_Fn>::type>::value
2901 template <class _Fn, class _A0, class _A1, class _A2>
2902 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)>
2903 : public __result_of<_Fn(_A0, _A1, _A2),
2904 is_class<typename remove_reference<_Fn>::type>::value ||
2905 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2906 is_member_pointer<typename remove_reference<_Fn>::type>::value
2911 #endif // _LIBCPP_HAS_NO_VARIADICS
2913 // template <class T, class... Args> struct is_constructible;
2915 namespace __is_construct
2920 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \
2921 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE))
2923 template <class _Tp, class... _Args>
2924 struct __libcpp_is_constructible;
2926 template <class _To, class _From>
2927 struct __is_invalid_base_to_derived_cast {
2928 static_assert(is_reference<_To>::value, "Wrong specialization");
2929 using _RawFrom = __uncvref_t<_From>;
2930 using _RawTo = __uncvref_t<_To>;
2931 static const bool value = __lazy_and<
2932 __lazy_not<is_same<_RawFrom, _RawTo>>,
2933 is_base_of<_RawFrom, _RawTo>,
2934 __lazy_not<__libcpp_is_constructible<_RawTo, _From>>
2938 template <class _To, class _From>
2939 struct __is_invalid_lvalue_to_rvalue_cast : false_type {
2940 static_assert(is_reference<_To>::value, "Wrong specialization");
2943 template <class _ToRef, class _FromRef>
2944 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
2945 using _RawFrom = __uncvref_t<_FromRef>;
2946 using _RawTo = __uncvref_t<_ToRef>;
2947 static const bool value = __lazy_and<
2948 __lazy_not<is_function<_RawTo>>,
2950 is_same<_RawFrom, _RawTo>,
2951 is_base_of<_RawTo, _RawFrom>>
2955 struct __is_constructible_helper
2957 template <class _To>
2958 static void __eat(_To);
2960 // This overload is needed to work around a Clang bug that disallows
2961 // static_cast<T&&>(e) for non-reference-compatible types.
2962 // Example: static_cast<int&&>(declval<double>());
2963 // NOTE: The static_cast implementation below is required to support
2964 // classes with explicit conversion operators.
2965 template <class _To, class _From,
2966 class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
2967 static true_type __test_cast(int);
2969 template <class _To, class _From,
2970 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
2971 static integral_constant<bool,
2972 !__is_invalid_base_to_derived_cast<_To, _From>::value &&
2973 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
2974 > __test_cast(long);
2976 template <class, class>
2977 static false_type __test_cast(...);
2979 template <class _Tp, class ..._Args,
2980 class = decltype(_Tp(_VSTD::declval<_Args>()...))>
2981 static true_type __test_nary(int);
2982 template <class _Tp, class...>
2983 static false_type __test_nary(...);
2985 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
2986 static is_destructible<_Tp> __test_unary(int);
2987 template <class, class>
2988 static false_type __test_unary(...);
2991 template <class _Tp, bool = is_void<_Tp>::value>
2992 struct __is_default_constructible
2993 : decltype(__is_constructible_helper::__test_nary<_Tp>(0))
2996 template <class _Tp>
2997 struct __is_default_constructible<_Tp, true> : false_type {};
2999 template <class _Tp>
3000 struct __is_default_constructible<_Tp[], false> : false_type {};
3002 template <class _Tp, size_t _Nx>
3003 struct __is_default_constructible<_Tp[_Nx], false>
3004 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
3006 template <class _Tp, class... _Args>
3007 struct __libcpp_is_constructible
3009 static_assert(sizeof...(_Args) > 1, "Wrong specialization");
3010 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
3014 template <class _Tp>
3015 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
3017 template <class _Tp, class _A0>
3018 struct __libcpp_is_constructible<_Tp, _A0>
3019 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
3022 template <class _Tp, class _A0>
3023 struct __libcpp_is_constructible<_Tp&, _A0>
3024 : public decltype(__is_constructible_helper::
3025 __test_cast<_Tp&, _A0>(0))
3028 template <class _Tp, class _A0>
3029 struct __libcpp_is_constructible<_Tp&&, _A0>
3030 : public decltype(__is_constructible_helper::
3031 __test_cast<_Tp&&, _A0>(0))
3036 #if __has_feature(is_constructible)
3037 template <class _Tp, class ..._Args>
3038 struct _LIBCPP_TEMPLATE_VIS is_constructible
3039 : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
3041 #elif !defined(_LIBCPP_CXX03_LANG)
3042 template <class _Tp, class... _Args>
3043 struct _LIBCPP_TEMPLATE_VIS is_constructible
3044 : public __libcpp_is_constructible<_Tp, _Args...>::type {};
3046 // template <class T> struct is_constructible0;
3048 // main is_constructible0 test
3050 template <class _Tp>
3051 decltype((_Tp(), true_type()))
3052 __is_constructible0_test(_Tp&);
3055 __is_constructible0_test(__any);
3057 template <class _Tp, class _A0>
3058 decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
3059 __is_constructible1_test(_Tp&, _A0&);
3061 template <class _A0>
3063 __is_constructible1_test(__any, _A0&);
3065 template <class _Tp, class _A0, class _A1>
3066 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
3067 __is_constructible2_test(_Tp&, _A0&, _A1&);
3069 template <class _A0, class _A1>
3071 __is_constructible2_test(__any, _A0&, _A1&);
3073 template <bool, class _Tp>
3074 struct __is_constructible0_imp // false, _Tp is not a scalar
3075 : public common_type
3077 decltype(__is_constructible0_test(declval<_Tp&>()))
3081 template <bool, class _Tp, class _A0>
3082 struct __is_constructible1_imp // false, _Tp is not a scalar
3083 : public common_type
3085 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
3089 template <bool, class _Tp, class _A0, class _A1>
3090 struct __is_constructible2_imp // false, _Tp is not a scalar
3091 : public common_type
3093 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
3097 // handle scalars and reference types
3099 // Scalars are default constructible, references are not
3101 template <class _Tp>
3102 struct __is_constructible0_imp<true, _Tp>
3103 : public is_scalar<_Tp>
3106 template <class _Tp, class _A0>
3107 struct __is_constructible1_imp<true, _Tp, _A0>
3108 : public is_convertible<_A0, _Tp>
3111 template <class _Tp, class _A0, class _A1>
3112 struct __is_constructible2_imp<true, _Tp, _A0, _A1>
3116 // Treat scalars and reference types separately
3118 template <bool, class _Tp>
3119 struct __is_constructible0_void_check
3120 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3124 template <bool, class _Tp, class _A0>
3125 struct __is_constructible1_void_check
3126 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3130 template <bool, class _Tp, class _A0, class _A1>
3131 struct __is_constructible2_void_check
3132 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
3136 // If any of T or Args is void, is_constructible should be false
3138 template <class _Tp>
3139 struct __is_constructible0_void_check<true, _Tp>
3143 template <class _Tp, class _A0>
3144 struct __is_constructible1_void_check<true, _Tp, _A0>
3148 template <class _Tp, class _A0, class _A1>
3149 struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
3153 // is_constructible entry point
3155 template <class _Tp, class _A0 = __is_construct::__nat,
3156 class _A1 = __is_construct::__nat>
3157 struct _LIBCPP_TEMPLATE_VIS is_constructible
3158 : public __is_constructible2_void_check<is_void<_Tp>::value
3159 || is_abstract<_Tp>::value
3160 || is_function<_Tp>::value
3161 || is_void<_A0>::value
3162 || is_void<_A1>::value,
3166 template <class _Tp>
3167 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
3168 : public __is_constructible0_void_check<is_void<_Tp>::value
3169 || is_abstract<_Tp>::value
3170 || is_function<_Tp>::value,
3174 template <class _Tp, class _A0>
3175 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat>
3176 : public __is_constructible1_void_check<is_void<_Tp>::value
3177 || is_abstract<_Tp>::value
3178 || is_function<_Tp>::value
3179 || is_void<_A0>::value,
3183 // Array types are default constructible if their element type
3184 // is default constructible
3186 template <class _Ap, size_t _Np>
3187 struct __is_constructible0_imp<false, _Ap[_Np]>
3188 : public is_constructible<typename remove_all_extents<_Ap>::type>
3191 template <class _Ap, size_t _Np, class _A0>
3192 struct __is_constructible1_imp<false, _Ap[_Np], _A0>
3196 template <class _Ap, size_t _Np, class _A0, class _A1>
3197 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
3201 // Incomplete array types are not constructible
3203 template <class _Ap>
3204 struct __is_constructible0_imp<false, _Ap[]>
3208 template <class _Ap, class _A0>
3209 struct __is_constructible1_imp<false, _Ap[], _A0>
3213 template <class _Ap, class _A0, class _A1>
3214 struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
3218 #endif // __has_feature(is_constructible)
3221 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3222 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
3223 = is_constructible<_Tp, _Args...>::value;
3226 // is_default_constructible
3228 template <class _Tp>
3229 struct _LIBCPP_TEMPLATE_VIS is_default_constructible
3230 : public is_constructible<_Tp>
3233 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3234 template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
3235 = is_default_constructible<_Tp>::value;
3238 // is_copy_constructible
3240 template <class _Tp>
3241 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
3242 : public is_constructible<_Tp,
3243 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3245 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3246 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
3247 = is_copy_constructible<_Tp>::value;
3250 // is_move_constructible
3252 template <class _Tp>
3253 struct _LIBCPP_TEMPLATE_VIS is_move_constructible
3254 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3255 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3257 : public is_copy_constructible<_Tp>
3261 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3262 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
3263 = is_move_constructible<_Tp>::value;
3266 // is_trivially_constructible
3268 #ifndef _LIBCPP_HAS_NO_VARIADICS
3270 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3272 template <class _Tp, class... _Args>
3273 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3274 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
3278 #else // !__has_feature(is_trivially_constructible)
3280 template <class _Tp, class... _Args>
3281 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3286 template <class _Tp>
3287 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp>
3288 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
3289 : integral_constant<bool, __has_trivial_constructor(_Tp)>
3291 : integral_constant<bool, is_scalar<_Tp>::value>
3296 template <class _Tp>
3297 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3298 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&>
3300 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp>
3302 : integral_constant<bool, is_scalar<_Tp>::value>
3306 template <class _Tp>
3307 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&>
3308 : integral_constant<bool, is_scalar<_Tp>::value>
3312 template <class _Tp>
3313 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
3314 : integral_constant<bool, is_scalar<_Tp>::value>
3318 #endif // !__has_feature(is_trivially_constructible)
3320 #else // _LIBCPP_HAS_NO_VARIADICS
3322 template <class _Tp, class _A0 = __is_construct::__nat,
3323 class _A1 = __is_construct::__nat>
3324 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
3329 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
3331 template <class _Tp>
3332 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3333 __is_construct::__nat>
3334 : integral_constant<bool, __is_trivially_constructible(_Tp)>
3338 template <class _Tp>
3339 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3340 __is_construct::__nat>
3341 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
3345 template <class _Tp>
3346 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3347 __is_construct::__nat>
3348 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
3352 template <class _Tp>
3353 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3354 __is_construct::__nat>
3355 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
3359 #else // !__has_feature(is_trivially_constructible)
3361 template <class _Tp>
3362 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat,
3363 __is_construct::__nat>
3364 : integral_constant<bool, is_scalar<_Tp>::value>
3368 template <class _Tp>
3369 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp,
3370 __is_construct::__nat>
3371 : integral_constant<bool, is_scalar<_Tp>::value>
3375 template <class _Tp>
3376 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&,
3377 __is_construct::__nat>
3378 : integral_constant<bool, is_scalar<_Tp>::value>
3382 template <class _Tp>
3383 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&,
3384 __is_construct::__nat>
3385 : integral_constant<bool, is_scalar<_Tp>::value>
3389 #endif // !__has_feature(is_trivially_constructible)
3391 #endif // _LIBCPP_HAS_NO_VARIADICS
3393 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3394 template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
3395 = is_trivially_constructible<_Tp, _Args...>::value;
3398 // is_trivially_default_constructible
3400 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
3401 : public is_trivially_constructible<_Tp>
3404 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3405 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
3406 = is_trivially_default_constructible<_Tp>::value;
3409 // is_trivially_copy_constructible
3411 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
3412 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
3415 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3416 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
3417 = is_trivially_copy_constructible<_Tp>::value;
3420 // is_trivially_move_constructible
3422 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
3423 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3424 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3426 : public is_trivially_copy_constructible<_Tp>
3430 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3431 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
3432 = is_trivially_move_constructible<_Tp>::value;
3435 // is_trivially_assignable
3437 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
3439 template <class _Tp, class _Arg>
3440 struct is_trivially_assignable
3441 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
3445 #else // !__has_feature(is_trivially_assignable)
3447 template <class _Tp, class _Arg>
3448 struct is_trivially_assignable
3449 : public false_type {};
3451 template <class _Tp>
3452 struct is_trivially_assignable<_Tp&, _Tp>
3453 : integral_constant<bool, is_scalar<_Tp>::value> {};
3455 template <class _Tp>
3456 struct is_trivially_assignable<_Tp&, _Tp&>
3457 : integral_constant<bool, is_scalar<_Tp>::value> {};
3459 template <class _Tp>
3460 struct is_trivially_assignable<_Tp&, const _Tp&>
3461 : integral_constant<bool, is_scalar<_Tp>::value> {};
3463 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3465 template <class _Tp>
3466 struct is_trivially_assignable<_Tp&, _Tp&&>
3467 : integral_constant<bool, is_scalar<_Tp>::value> {};
3469 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3471 #endif // !__has_feature(is_trivially_assignable)
3473 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3474 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
3475 = is_trivially_assignable<_Tp, _Arg>::value;
3478 // is_trivially_copy_assignable
3480 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
3481 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3482 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3484 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3485 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
3486 = is_trivially_copy_assignable<_Tp>::value;
3489 // is_trivially_move_assignable
3491 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
3492 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
3493 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3494 typename add_rvalue_reference<_Tp>::type>
3496 typename add_lvalue_reference<_Tp>::type>
3500 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3501 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
3502 = is_trivially_move_assignable<_Tp>::value;
3505 // is_trivially_destructible
3507 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
3509 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3510 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
3514 template <class _Tp> struct __libcpp_trivial_destructor
3515 : public integral_constant<bool, is_scalar<_Tp>::value ||
3516 is_reference<_Tp>::value> {};
3518 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3519 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
3521 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
3522 : public false_type {};
3526 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3527 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
3528 = is_trivially_destructible<_Tp>::value;
3531 // is_nothrow_constructible
3534 template <class _Tp, class... _Args>
3535 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3536 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
3542 #ifndef _LIBCPP_HAS_NO_VARIADICS
3544 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3546 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3548 template <class _Tp, class... _Args>
3549 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
3550 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
3554 template <class _Tp>
3555 void __implicit_conversion_to(_Tp) noexcept { }
3557 template <class _Tp, class _Arg>
3558 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
3559 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
3563 template <class _Tp, bool _IsReference, class... _Args>
3564 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
3569 template <class _Tp, class... _Args>
3570 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3571 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
3575 template <class _Tp, size_t _Ns>
3576 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
3577 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
3581 #else // __has_feature(cxx_noexcept)
3583 template <class _Tp, class... _Args>
3584 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3589 template <class _Tp>
3590 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp>
3591 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3592 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3594 : integral_constant<bool, is_scalar<_Tp>::value>
3599 template <class _Tp>
3600 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3601 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&>
3603 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp>
3605 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3606 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3608 : integral_constant<bool, is_scalar<_Tp>::value>
3613 template <class _Tp>
3614 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&>
3615 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3616 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3618 : integral_constant<bool, is_scalar<_Tp>::value>
3623 template <class _Tp>
3624 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&>
3625 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3626 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3628 : integral_constant<bool, is_scalar<_Tp>::value>
3633 #endif // __has_feature(cxx_noexcept)
3635 #else // _LIBCPP_HAS_NO_VARIADICS
3637 template <class _Tp, class _A0 = __is_construct::__nat,
3638 class _A1 = __is_construct::__nat>
3639 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3644 template <class _Tp>
3645 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat,
3646 __is_construct::__nat>
3647 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
3648 : integral_constant<bool, __has_nothrow_constructor(_Tp)>
3650 : integral_constant<bool, is_scalar<_Tp>::value>
3655 template <class _Tp>
3656 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp,
3657 __is_construct::__nat>
3658 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3659 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3661 : integral_constant<bool, is_scalar<_Tp>::value>
3666 template <class _Tp>
3667 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&,
3668 __is_construct::__nat>
3669 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3670 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3672 : integral_constant<bool, is_scalar<_Tp>::value>
3677 template <class _Tp>
3678 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&,
3679 __is_construct::__nat>
3680 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
3681 : integral_constant<bool, __has_nothrow_copy(_Tp)>
3683 : integral_constant<bool, is_scalar<_Tp>::value>
3688 #endif // _LIBCPP_HAS_NO_VARIADICS
3689 #endif // __has_feature(is_nothrow_constructible)
3691 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
3692 template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
3693 = is_nothrow_constructible<_Tp, _Args...>::value;
3696 // is_nothrow_default_constructible
3698 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
3699 : public is_nothrow_constructible<_Tp>
3702 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3703 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
3704 = is_nothrow_default_constructible<_Tp>::value;
3707 // is_nothrow_copy_constructible
3709 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
3710 : public is_nothrow_constructible<_Tp,
3711 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3713 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3714 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
3715 = is_nothrow_copy_constructible<_Tp>::value;
3718 // is_nothrow_move_constructible
3720 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
3721 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3722 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
3724 : public is_nothrow_copy_constructible<_Tp>
3728 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3729 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
3730 = is_nothrow_move_constructible<_Tp>::value;
3733 // is_nothrow_assignable
3735 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3737 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
3739 template <class _Tp, class _Arg>
3740 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
3745 template <class _Tp, class _Arg>
3746 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
3747 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
3751 template <class _Tp, class _Arg>
3752 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3753 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
3757 #else // __has_feature(cxx_noexcept)
3759 template <class _Tp, class _Arg>
3760 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
3761 : public false_type {};
3763 template <class _Tp>
3764 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp>
3765 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3766 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3768 : integral_constant<bool, is_scalar<_Tp>::value> {};
3771 template <class _Tp>
3772 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&>
3773 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3774 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3776 : integral_constant<bool, is_scalar<_Tp>::value> {};
3779 template <class _Tp>
3780 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&>
3781 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3782 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3784 : integral_constant<bool, is_scalar<_Tp>::value> {};
3787 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3789 template <class _Tp>
3790 struct is_nothrow_assignable<_Tp&, _Tp&&>
3791 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
3792 : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
3794 : integral_constant<bool, is_scalar<_Tp>::value> {};
3797 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3799 #endif // __has_feature(cxx_noexcept)
3801 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3802 template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
3803 = is_nothrow_assignable<_Tp, _Arg>::value;
3806 // is_nothrow_copy_assignable
3808 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
3809 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3810 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
3812 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3813 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
3814 = is_nothrow_copy_assignable<_Tp>::value;
3817 // is_nothrow_move_assignable
3819 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
3820 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
3821 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3822 typename add_rvalue_reference<_Tp>::type>
3824 typename add_lvalue_reference<_Tp>::type>
3828 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3829 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
3830 = is_nothrow_move_assignable<_Tp>::value;
3833 // is_nothrow_destructible
3835 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
3837 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
3839 template <class _Tp>
3840 struct __libcpp_is_nothrow_destructible<false, _Tp>
3845 template <class _Tp>
3846 struct __libcpp_is_nothrow_destructible<true, _Tp>
3847 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
3851 template <class _Tp>
3852 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3853 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
3857 template <class _Tp, size_t _Ns>
3858 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
3859 : public is_nothrow_destructible<_Tp>
3863 template <class _Tp>
3864 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
3869 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3871 template <class _Tp>
3872 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
3881 template <class _Tp> struct __libcpp_nothrow_destructor
3882 : public integral_constant<bool, is_scalar<_Tp>::value ||
3883 is_reference<_Tp>::value> {};
3885 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
3886 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
3888 template <class _Tp>
3889 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
3890 : public false_type {};
3894 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3895 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
3896 = is_nothrow_destructible<_Tp>::value;
3901 #if __has_feature(is_pod) || (_GNUC_VER >= 403)
3903 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3904 : public integral_constant<bool, __is_pod(_Tp)> {};
3908 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
3909 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
3910 is_trivially_copy_constructible<_Tp>::value &&
3911 is_trivially_copy_assignable<_Tp>::value &&
3912 is_trivially_destructible<_Tp>::value> {};
3916 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3917 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
3918 = is_pod<_Tp>::value;
3923 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
3924 #ifdef _LIBCPP_IS_LITERAL
3925 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
3927 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
3928 is_reference<typename remove_all_extents<_Tp>::type>::value>
3932 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3933 template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
3934 = is_literal_type<_Tp>::value;
3937 // is_standard_layout;
3939 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
3940 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
3941 : public integral_constant<bool, __is_standard_layout(_Tp)>
3943 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3947 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3948 template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
3949 = is_standard_layout<_Tp>::value;
3952 // is_trivially_copyable;
3954 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
3955 #if __has_feature(is_trivially_copyable)
3956 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
3957 #elif _GNUC_VER >= 501
3958 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
3960 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
3964 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3965 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
3966 = is_trivially_copyable<_Tp>::value;
3971 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
3972 #if __has_feature(is_trivial) || _GNUC_VER >= 407
3973 : public integral_constant<bool, __is_trivial(_Tp)>
3975 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
3976 is_trivially_default_constructible<_Tp>::value>
3980 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
3981 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
3982 = is_trivial<_Tp>::value;
3985 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
3986 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
3987 template <class _Tp> struct __is_reference_wrapper
3988 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
3990 #ifndef _LIBCPP_CXX03_LANG
3992 // Check for complete types
3994 template <class ..._Tp> struct __check_complete;
3997 struct __check_complete<>
4001 template <class _Hp, class _T0, class ..._Tp>
4002 struct __check_complete<_Hp, _T0, _Tp...>
4003 : private __check_complete<_Hp>,
4004 private __check_complete<_T0, _Tp...>
4008 template <class _Hp>
4009 struct __check_complete<_Hp, _Hp>
4010 : private __check_complete<_Hp>
4014 template <class _Tp>
4015 struct __check_complete<_Tp>
4017 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
4020 template <class _Tp>
4021 struct __check_complete<_Tp&>
4022 : private __check_complete<_Tp>
4026 template <class _Tp>
4027 struct __check_complete<_Tp&&>
4028 : private __check_complete<_Tp>
4032 template <class _Rp, class ..._Param>
4033 struct __check_complete<_Rp (*)(_Param...)>
4034 : private __check_complete<_Rp>
4038 template <class ..._Param>
4039 struct __check_complete<void (*)(_Param...)>
4043 template <class _Rp, class ..._Param>
4044 struct __check_complete<_Rp (_Param...)>
4045 : private __check_complete<_Rp>
4049 template <class ..._Param>
4050 struct __check_complete<void (_Param...)>
4054 template <class _Rp, class _Class, class ..._Param>
4055 struct __check_complete<_Rp (_Class::*)(_Param...)>
4056 : private __check_complete<_Class>
4060 template <class _Rp, class _Class, class ..._Param>
4061 struct __check_complete<_Rp (_Class::*)(_Param...) const>
4062 : private __check_complete<_Class>
4066 template <class _Rp, class _Class, class ..._Param>
4067 struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
4068 : private __check_complete<_Class>
4072 template <class _Rp, class _Class, class ..._Param>
4073 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
4074 : private __check_complete<_Class>
4078 template <class _Rp, class _Class, class ..._Param>
4079 struct __check_complete<_Rp (_Class::*)(_Param...) &>
4080 : private __check_complete<_Class>
4084 template <class _Rp, class _Class, class ..._Param>
4085 struct __check_complete<_Rp (_Class::*)(_Param...) const&>
4086 : private __check_complete<_Class>
4090 template <class _Rp, class _Class, class ..._Param>
4091 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
4092 : private __check_complete<_Class>
4096 template <class _Rp, class _Class, class ..._Param>
4097 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
4098 : private __check_complete<_Class>
4102 template <class _Rp, class _Class, class ..._Param>
4103 struct __check_complete<_Rp (_Class::*)(_Param...) &&>
4104 : private __check_complete<_Class>
4108 template <class _Rp, class _Class, class ..._Param>
4109 struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
4110 : private __check_complete<_Class>
4114 template <class _Rp, class _Class, class ..._Param>
4115 struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
4116 : private __check_complete<_Class>
4120 template <class _Rp, class _Class, class ..._Param>
4121 struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
4122 : private __check_complete<_Class>
4126 template <class _Rp, class _Class>
4127 struct __check_complete<_Rp _Class::*>
4128 : private __check_complete<_Class>
4133 template <class _Fp, class _A0,
4134 class _DecayFp = typename decay<_Fp>::type,
4135 class _DecayA0 = typename decay<_A0>::type,
4136 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4137 using __enable_if_bullet1 = typename enable_if
4139 is_member_function_pointer<_DecayFp>::value
4140 && is_base_of<_ClassT, _DecayA0>::value
4143 template <class _Fp, class _A0,
4144 class _DecayFp = typename decay<_Fp>::type,
4145 class _DecayA0 = typename decay<_A0>::type>
4146 using __enable_if_bullet2 = typename enable_if
4148 is_member_function_pointer<_DecayFp>::value
4149 && __is_reference_wrapper<_DecayA0>::value
4152 template <class _Fp, class _A0,
4153 class _DecayFp = typename decay<_Fp>::type,
4154 class _DecayA0 = typename decay<_A0>::type,
4155 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4156 using __enable_if_bullet3 = typename enable_if
4158 is_member_function_pointer<_DecayFp>::value
4159 && !is_base_of<_ClassT, _DecayA0>::value
4160 && !__is_reference_wrapper<_DecayA0>::value
4163 template <class _Fp, class _A0,
4164 class _DecayFp = typename decay<_Fp>::type,
4165 class _DecayA0 = typename decay<_A0>::type,
4166 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4167 using __enable_if_bullet4 = typename enable_if
4169 is_member_object_pointer<_DecayFp>::value
4170 && is_base_of<_ClassT, _DecayA0>::value
4173 template <class _Fp, class _A0,
4174 class _DecayFp = typename decay<_Fp>::type,
4175 class _DecayA0 = typename decay<_A0>::type>
4176 using __enable_if_bullet5 = typename enable_if
4178 is_member_object_pointer<_DecayFp>::value
4179 && __is_reference_wrapper<_DecayA0>::value
4182 template <class _Fp, class _A0,
4183 class _DecayFp = typename decay<_Fp>::type,
4184 class _DecayA0 = typename decay<_A0>::type,
4185 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
4186 using __enable_if_bullet6 = typename enable_if
4188 is_member_object_pointer<_DecayFp>::value
4189 && !is_base_of<_ClassT, _DecayA0>::value
4190 && !__is_reference_wrapper<_DecayA0>::value
4193 // __invoke forward declarations
4195 // fall back - none of the bullets
4197 #define _LIBCPP_INVOKE_RETURN(...) \
4198 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
4199 { return __VA_ARGS__; }
4201 template <class ..._Args>
4202 auto __invoke(__any, _Args&& ...__args) -> __nat;
4204 template <class ..._Args>
4205 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
4207 // bullets 1, 2 and 3
4209 template <class _Fp, class _A0, class ..._Args,
4210 class = __enable_if_bullet1<_Fp, _A0>>
4211 inline _LIBCPP_INLINE_VISIBILITY
4213 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4214 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4216 template <class _Fp, class _A0, class ..._Args,
4217 class = __enable_if_bullet1<_Fp, _A0>>
4218 inline _LIBCPP_INLINE_VISIBILITY
4219 _LIBCPP_CONSTEXPR auto
4220 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4221 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
4223 template <class _Fp, class _A0, class ..._Args,
4224 class = __enable_if_bullet2<_Fp, _A0>>
4225 inline _LIBCPP_INLINE_VISIBILITY
4227 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4228 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4230 template <class _Fp, class _A0, class ..._Args,
4231 class = __enable_if_bullet2<_Fp, _A0>>
4232 inline _LIBCPP_INLINE_VISIBILITY
4233 _LIBCPP_CONSTEXPR auto
4234 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4235 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
4237 template <class _Fp, class _A0, class ..._Args,
4238 class = __enable_if_bullet3<_Fp, _A0>>
4239 inline _LIBCPP_INLINE_VISIBILITY
4241 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4242 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4244 template <class _Fp, class _A0, class ..._Args,
4245 class = __enable_if_bullet3<_Fp, _A0>>
4246 inline _LIBCPP_INLINE_VISIBILITY
4247 _LIBCPP_CONSTEXPR auto
4248 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
4249 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
4251 // bullets 4, 5 and 6
4253 template <class _Fp, class _A0,
4254 class = __enable_if_bullet4<_Fp, _A0>>
4255 inline _LIBCPP_INLINE_VISIBILITY
4257 __invoke(_Fp&& __f, _A0&& __a0)
4258 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4260 template <class _Fp, class _A0,
4261 class = __enable_if_bullet4<_Fp, _A0>>
4262 inline _LIBCPP_INLINE_VISIBILITY
4263 _LIBCPP_CONSTEXPR auto
4264 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4265 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
4267 template <class _Fp, class _A0,
4268 class = __enable_if_bullet5<_Fp, _A0>>
4269 inline _LIBCPP_INLINE_VISIBILITY
4271 __invoke(_Fp&& __f, _A0&& __a0)
4272 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4274 template <class _Fp, class _A0,
4275 class = __enable_if_bullet5<_Fp, _A0>>
4276 inline _LIBCPP_INLINE_VISIBILITY
4277 _LIBCPP_CONSTEXPR auto
4278 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4279 _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
4281 template <class _Fp, class _A0,
4282 class = __enable_if_bullet6<_Fp, _A0>>
4283 inline _LIBCPP_INLINE_VISIBILITY
4285 __invoke(_Fp&& __f, _A0&& __a0)
4286 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4288 template <class _Fp, class _A0,
4289 class = __enable_if_bullet6<_Fp, _A0>>
4290 inline _LIBCPP_INLINE_VISIBILITY
4291 _LIBCPP_CONSTEXPR auto
4292 __invoke_constexpr(_Fp&& __f, _A0&& __a0)
4293 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
4297 template <class _Fp, class ..._Args>
4298 inline _LIBCPP_INLINE_VISIBILITY
4300 __invoke(_Fp&& __f, _Args&& ...__args)
4301 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4303 template <class _Fp, class ..._Args>
4304 inline _LIBCPP_INLINE_VISIBILITY
4305 _LIBCPP_CONSTEXPR auto
4306 __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
4307 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
4309 #undef _LIBCPP_INVOKE_RETURN
4313 template <class _Ret, class _Fp, class ..._Args>
4314 struct __invokable_r
4315 : private __check_complete<_Fp>
4317 using _Result = decltype(
4318 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4320 static const bool value =
4322 !is_same<_Result, __nat>::value,
4323 typename conditional<
4324 is_void<_Ret>::value,
4326 is_convertible<_Result, _Ret>
4332 template <class _Fp, class ..._Args>
4333 using __invokable = __invokable_r<void, _Fp, _Args...>;
4335 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
4336 struct __nothrow_invokable_r_imp {
4337 static const bool value = false;
4340 template <class _Ret, class _Fp, class ..._Args>
4341 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
4343 typedef __nothrow_invokable_r_imp _ThisT;
4345 template <class _Tp>
4346 static void __test_noexcept(_Tp) noexcept;
4348 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
4349 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
4352 template <class _Ret, class _Fp, class ..._Args>
4353 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
4355 static const bool value = noexcept(
4356 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
4359 template <class _Ret, class _Fp, class ..._Args>
4360 using __nothrow_invokable_r =
4361 __nothrow_invokable_r_imp<
4362 __invokable_r<_Ret, _Fp, _Args...>::value,
4363 is_void<_Ret>::value,
4367 template <class _Fp, class ..._Args>
4370 __invokable<_Fp, _Args...>::value,
4371 typename __invokable_r<void, _Fp, _Args...>::_Result>
4377 template <class _Fp, class ..._Args>
4378 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
4379 : public __invoke_of<_Fp, _Args...>
4383 #if _LIBCPP_STD_VER > 11
4384 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
4387 #if _LIBCPP_STD_VER > 14
4391 template <class _Fn, class _Ret = void>
4392 struct _LIBCPP_TEMPLATE_VIS is_callable;
4394 template <class _Fn, class ..._Args, class _Ret>
4395 struct _LIBCPP_TEMPLATE_VIS is_callable<_Fn(_Args...), _Ret>
4396 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
4398 template <class _Fn, class _Ret = void>
4399 constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
4401 // is_nothrow_callable
4403 template <class _Fn, class _Ret = void>
4404 struct _LIBCPP_TEMPLATE_VIS is_nothrow_callable;
4406 template <class _Fn, class ..._Args, class _Ret>
4407 struct _LIBCPP_TEMPLATE_VIS is_nothrow_callable<_Fn(_Args...), _Ret>
4408 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
4411 template <class _Fn, class _Ret = void>
4412 constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
4414 #endif // _LIBCPP_STD_VER > 14
4416 #endif // !defined(_LIBCPP_CXX03_LANG)
4418 template <class _Tp> struct __is_swappable;
4419 template <class _Tp> struct __is_nothrow_swappable;
4421 template <class _Tp>
4422 inline _LIBCPP_INLINE_VISIBILITY
4423 #ifndef _LIBCPP_CXX03_LANG
4426 is_move_constructible<_Tp>::value &&
4427 is_move_assignable<_Tp>::value
4432 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
4433 is_nothrow_move_assignable<_Tp>::value)
4435 _Tp __t(_VSTD::move(__x));
4436 __x = _VSTD::move(__y);
4437 __y = _VSTD::move(__t);
4440 template<class _Tp, size_t _Np>
4441 inline _LIBCPP_INLINE_VISIBILITY
4443 __is_swappable<_Tp>::value
4445 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
4447 template <class _ForwardIterator1, class _ForwardIterator2>
4448 inline _LIBCPP_INLINE_VISIBILITY
4450 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
4451 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
4452 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
4453 *_VSTD::declval<_ForwardIterator2>())))
4462 // ALL generic swap overloads MUST already have a declaration available at this point.
4464 template <class _Tp, class _Up = _Tp,
4465 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
4466 struct __swappable_with
4468 template <class _LHS, class _RHS>
4469 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
4471 template <class, class>
4472 static __nat __test_swap(long);
4474 // Extra parens are needed for the C++03 definition of decltype.
4475 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
4476 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
4478 static const bool value = !is_same<__swap1, __nat>::value
4479 && !is_same<__swap2, __nat>::value;
4482 template <class _Tp, class _Up>
4483 struct __swappable_with<_Tp, _Up, false> : false_type {};
4485 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
4486 struct __nothrow_swappable_with {
4487 static const bool value =
4488 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
4489 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
4490 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
4496 template <class _Tp, class _Up>
4497 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
4501 template <class _Tp>
4502 struct __is_swappable
4503 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
4507 template <class _Tp>
4508 struct __is_nothrow_swappable
4509 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
4513 #if _LIBCPP_STD_VER > 14
4515 template <class _Tp, class _Up>
4516 struct _LIBCPP_TEMPLATE_VIS is_swappable_with
4517 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
4521 template <class _Tp>
4522 struct _LIBCPP_TEMPLATE_VIS is_swappable
4523 : public conditional<
4524 __is_referenceable<_Tp>::value,
4526 typename add_lvalue_reference<_Tp>::type,
4527 typename add_lvalue_reference<_Tp>::type>,
4533 template <class _Tp, class _Up>
4534 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
4535 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
4539 template <class _Tp>
4540 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
4541 : public conditional<
4542 __is_referenceable<_Tp>::value,
4543 is_nothrow_swappable_with<
4544 typename add_lvalue_reference<_Tp>::type,
4545 typename add_lvalue_reference<_Tp>::type>,
4551 template <class _Tp, class _Up>
4552 constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
4554 template <class _Tp>
4555 constexpr bool is_swappable_v = is_swappable<_Tp>::value;
4557 template <class _Tp, class _Up>
4558 constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
4560 template <class _Tp>
4561 constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
4563 #endif // _LIBCPP_STD_VER > 14
4565 #ifdef _LIBCPP_UNDERLYING_TYPE
4567 template <class _Tp>
4568 struct underlying_type
4570 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
4573 #if _LIBCPP_STD_VER > 11
4574 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
4577 #else // _LIBCPP_UNDERLYING_TYPE
4579 template <class _Tp, bool _Support = false>
4580 struct underlying_type
4582 static_assert(_Support, "The underyling_type trait requires compiler "
4583 "support. Either no such support exists or "
4584 "libc++ does not know how to use it.");
4587 #endif // _LIBCPP_UNDERLYING_TYPE
4590 template <class _Tp, bool = is_enum<_Tp>::value>
4591 struct __sfinae_underlying_type
4593 typedef typename underlying_type<_Tp>::type type;
4594 typedef decltype(((type)1) + 0) __promoted_type;
4597 template <class _Tp>
4598 struct __sfinae_underlying_type<_Tp, false> {};
4600 inline _LIBCPP_INLINE_VISIBILITY
4601 int __convert_to_integral(int __val) { return __val; }
4603 inline _LIBCPP_INLINE_VISIBILITY
4604 unsigned __convert_to_integral(unsigned __val) { return __val; }
4606 inline _LIBCPP_INLINE_VISIBILITY
4607 long __convert_to_integral(long __val) { return __val; }
4609 inline _LIBCPP_INLINE_VISIBILITY
4610 unsigned long __convert_to_integral(unsigned long __val) { return __val; }
4612 inline _LIBCPP_INLINE_VISIBILITY
4613 long long __convert_to_integral(long long __val) { return __val; }
4615 inline _LIBCPP_INLINE_VISIBILITY
4616 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
4618 #ifndef _LIBCPP_HAS_NO_INT128
4619 inline _LIBCPP_INLINE_VISIBILITY
4620 __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4622 inline _LIBCPP_INLINE_VISIBILITY
4623 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
4626 template <class _Tp>
4627 inline _LIBCPP_INLINE_VISIBILITY
4628 typename __sfinae_underlying_type<_Tp>::__promoted_type
4629 __convert_to_integral(_Tp __val) { return __val; }
4631 #ifndef _LIBCPP_CXX03_LANG
4633 template <class _Tp>
4634 struct __has_operator_addressof_member_imp
4636 template <class _Up>
4637 static auto __test(int)
4638 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
4640 static auto __test(long) -> false_type;
4642 static const bool value = decltype(__test<_Tp>(0))::value;
4645 template <class _Tp>
4646 struct __has_operator_addressof_free_imp
4648 template <class _Up>
4649 static auto __test(int)
4650 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
4652 static auto __test(long) -> false_type;
4654 static const bool value = decltype(__test<_Tp>(0))::value;
4657 template <class _Tp>
4658 struct __has_operator_addressof
4659 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
4660 || __has_operator_addressof_free_imp<_Tp>::value>
4663 #endif // _LIBCPP_CXX03_LANG
4665 #if _LIBCPP_STD_VER > 14
4667 #define __cpp_lib_void_t 201411
4668 template <class...> using void_t = void;
4670 # ifndef _LIBCPP_HAS_NO_VARIADICS
4671 template <class... _Args>
4672 struct conjunction : __and_<_Args...> {};
4673 template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
4675 template <class... _Args>
4676 struct disjunction : __or_<_Args...> {};
4677 template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
4679 template <class _Tp>
4680 struct negation : __not_<_Tp> {};
4681 template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
4682 # endif // _LIBCPP_HAS_NO_VARIADICS
4683 #endif // _LIBCPP_STD_VER > 14
4685 // These traits are used in __tree and __hash_table
4686 #ifndef _LIBCPP_CXX03_LANG
4687 struct __extract_key_fail_tag {};
4688 struct __extract_key_self_tag {};
4689 struct __extract_key_first_tag {};
4691 template <class _ValTy, class _Key,
4692 class _RawValTy = typename __unconstref<_ValTy>::type>
4693 struct __can_extract_key
4694 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
4695 __extract_key_fail_tag>::type {};
4697 template <class _Pair, class _Key, class _First, class _Second>
4698 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
4699 : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
4700 __extract_key_first_tag, __extract_key_fail_tag>::type {};
4702 // __can_extract_map_key uses true_type/false_type instead of the tags.
4703 // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
4704 // and _ValTy == _Key.
4705 template <class _ValTy, class _Key, class _ContainerValueTy,
4706 class _RawValTy = typename __unconstref<_ValTy>::type>
4707 struct __can_extract_map_key
4708 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
4710 // This specialization returns __extract_key_fail_tag for non-map containers
4711 // because _Key == _ContainerValueTy
4712 template <class _ValTy, class _Key, class _RawValTy>
4713 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
4718 _LIBCPP_END_NAMESPACE_STD
4720 #endif // _LIBCPP_TYPE_TRAITS