1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_TYPE_TRAITS
11#define _LIBCPP_TYPE_TRAITS
12
13/*
14    type_traits synopsis
15
16namespace std
17{
18
19    // helper class:
20    template <class T, T v> struct integral_constant;
21    typedef integral_constant<bool, true>  true_type;   // C++11
22    typedef integral_constant<bool, false> false_type;  // C++11
23
24    template <bool B>                                   // C++14
25    using bool_constant = integral_constant<bool, B>;   // C++14
26    typedef bool_constant<true> true_type;              // C++14
27    typedef bool_constant<false> false_type;            // C++14
28
29    // helper traits
30    template <bool, class T = void> struct enable_if;
31    template <bool, class T, class F> struct conditional;
32
33    // Primary classification traits:
34    template <class T> struct is_void;
35    template <class T> struct is_null_pointer;  // C++14
36    template <class T> struct is_integral;
37    template <class T> struct is_floating_point;
38    template <class T> struct is_array;
39    template <class T> struct is_pointer;
40    template <class T> struct is_lvalue_reference;
41    template <class T> struct is_rvalue_reference;
42    template <class T> struct is_member_object_pointer;
43    template <class T> struct is_member_function_pointer;
44    template <class T> struct is_enum;
45    template <class T> struct is_union;
46    template <class T> struct is_class;
47    template <class T> struct is_function;
48
49    // Secondary classification traits:
50    template <class T> struct is_reference;
51    template <class T> struct is_arithmetic;
52    template <class T> struct is_fundamental;
53    template <class T> struct is_member_pointer;
54    template <class T> struct is_scoped_enum; // C++2b
55    template <class T> struct is_scalar;
56    template <class T> struct is_object;
57    template <class T> struct is_compound;
58
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;
68
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;
73
74    // Pointer transformations:
75    template <class T> struct remove_pointer;
76    template <class T> struct add_pointer;
77
78    template<class T> struct type_identity;                     // C++20
79    template<class T>
80      using type_identity_t = typename type_identity<T>::type;  // C++20
81
82    // Integral properties:
83    template <class T> struct is_signed;
84    template <class T> struct is_unsigned;
85    template <class T> struct make_signed;
86    template <class T> struct make_unsigned;
87
88    // Array properties and transformations:
89    template <class T> struct rank;
90    template <class T, unsigned I = 0> struct extent;
91    template <class T> struct remove_extent;
92    template <class T> struct remove_all_extents;
93
94    template <class T> struct is_bounded_array;                 // C++20
95    template <class T> struct is_unbounded_array;               // C++20
96
97    // Member introspection:
98    template <class T> struct is_pod;
99    template <class T> struct is_trivial;
100    template <class T> struct is_trivially_copyable;
101    template <class T> struct is_standard_layout;
102    template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20
103    template <class T> struct is_empty;
104    template <class T> struct is_polymorphic;
105    template <class T> struct is_abstract;
106    template <class T> struct is_final; // C++14
107    template <class T> struct is_aggregate; // C++17
108
109    template <class T, class... Args> struct is_constructible;
110    template <class T>                struct is_default_constructible;
111    template <class T>                struct is_copy_constructible;
112    template <class T>                struct is_move_constructible;
113    template <class T, class U>       struct is_assignable;
114    template <class T>                struct is_copy_assignable;
115    template <class T>                struct is_move_assignable;
116    template <class T, class U>       struct is_swappable_with;       // C++17
117    template <class T>                struct is_swappable;            // C++17
118    template <class T>                struct is_destructible;
119
120    template <class T, class... Args> struct is_trivially_constructible;
121    template <class T>                struct is_trivially_default_constructible;
122    template <class T>                struct is_trivially_copy_constructible;
123    template <class T>                struct is_trivially_move_constructible;
124    template <class T, class U>       struct is_trivially_assignable;
125    template <class T>                struct is_trivially_copy_assignable;
126    template <class T>                struct is_trivially_move_assignable;
127    template <class T>                struct is_trivially_destructible;
128
129    template <class T, class... Args> struct is_nothrow_constructible;
130    template <class T>                struct is_nothrow_default_constructible;
131    template <class T>                struct is_nothrow_copy_constructible;
132    template <class T>                struct is_nothrow_move_constructible;
133    template <class T, class U>       struct is_nothrow_assignable;
134    template <class T>                struct is_nothrow_copy_assignable;
135    template <class T>                struct is_nothrow_move_assignable;
136    template <class T, class U>       struct is_nothrow_swappable_with; // C++17
137    template <class T>                struct is_nothrow_swappable;      // C++17
138    template <class T>                struct is_nothrow_destructible;
139
140    template <class T> struct has_virtual_destructor;
141
142    template<class T> struct has_unique_object_representations;         // C++17
143
144    // Relationships between types:
145    template <class T, class U> struct is_same;
146    template <class Base, class Derived> struct is_base_of;
147
148    template <class From, class To> struct is_convertible;
149    template <typename From, typename To> struct is_nothrow_convertible;                  // C++20
150    template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20
151
152    template <class Fn, class... ArgTypes> struct is_invocable;
153    template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
154
155    template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
156    template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
157
158    // Alignment properties and transformations:
159    template <class T> struct alignment_of;
160    template <size_t Len, size_t Align = most_stringent_alignment_requirement>
161        struct aligned_storage;
162    template <size_t Len, class... Types> struct aligned_union;
163    template <class T> struct remove_cvref; // C++20
164
165    template <class T> struct decay;
166    template <class... T> struct common_type;
167    template <class T> struct underlying_type;
168    template <class> class result_of; // undefined; deprecated in C++17; removed in C++20
169    template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20
170    template <class Fn, class... ArgTypes> struct invoke_result;  // C++17
171
172    // const-volatile modifications:
173    template <class T>
174      using remove_const_t    = typename remove_const<T>::type;  // C++14
175    template <class T>
176      using remove_volatile_t = typename remove_volatile<T>::type;  // C++14
177    template <class T>
178      using remove_cv_t       = typename remove_cv<T>::type;  // C++14
179    template <class T>
180      using add_const_t       = typename add_const<T>::type;  // C++14
181    template <class T>
182      using add_volatile_t    = typename add_volatile<T>::type;  // C++14
183    template <class T>
184      using add_cv_t          = typename add_cv<T>::type;  // C++14
185
186    // reference modifications:
187    template <class T>
188      using remove_reference_t     = typename remove_reference<T>::type;  // C++14
189    template <class T>
190      using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;  // C++14
191    template <class T>
192      using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;  // C++14
193
194    // sign modifications:
195    template <class T>
196      using make_signed_t   = typename make_signed<T>::type;  // C++14
197    template <class T>
198      using make_unsigned_t = typename make_unsigned<T>::type;  // C++14
199
200    // array modifications:
201    template <class T>
202      using remove_extent_t      = typename remove_extent<T>::type;  // C++14
203    template <class T>
204      using remove_all_extents_t = typename remove_all_extents<T>::type;  // C++14
205
206    template <class T>
207      inline constexpr bool is_bounded_array_v
208        = is_bounded_array<T>::value;                                     // C++20
209      inline constexpr bool is_unbounded_array_v
210        = is_unbounded_array<T>::value;                                   // C++20
211
212    // pointer modifications:
213    template <class T>
214      using remove_pointer_t = typename remove_pointer<T>::type;  // C++14
215    template <class T>
216      using add_pointer_t    = typename add_pointer<T>::type;  // C++14
217
218    // other transformations:
219    template <size_t Len, size_t Align=default-alignment>
220      using aligned_storage_t = typename aligned_storage<Len,Align>::type;  // C++14
221    template <size_t Len, class... Types>
222      using aligned_union_t   = typename aligned_union<Len,Types...>::type;  // C++14
223    template <class T>
224      using remove_cvref_t    = typename remove_cvref<T>::type;  // C++20
225    template <class T>
226      using decay_t           = typename decay<T>::type;  // C++14
227    template <bool b, class T=void>
228      using enable_if_t       = typename enable_if<b,T>::type;  // C++14
229    template <bool b, class T, class F>
230      using conditional_t     = typename conditional<b,T,F>::type;  // C++14
231    template <class... T>
232      using common_type_t     = typename common_type<T...>::type;  // C++14
233    template <class T>
234      using underlying_type_t = typename underlying_type<T>::type;  // C++14
235    template <class T>
236      using result_of_t       = typename result_of<T>::type;  // C++14; deprecated in C++17; removed in C++20
237    template <class Fn, class... ArgTypes>
238      using invoke_result_t   = typename invoke_result<Fn, ArgTypes...>::type;  // C++17
239
240    template <class...>
241      using void_t = void;   // C++17
242
243      // See C++14 20.10.4.1, primary type categories
244      template <class T> inline constexpr bool is_void_v
245        = is_void<T>::value;                                             // C++17
246      template <class T> inline constexpr bool is_null_pointer_v
247        = is_null_pointer<T>::value;                                     // C++17
248      template <class T> inline constexpr bool is_integral_v
249        = is_integral<T>::value;                                         // C++17
250      template <class T> inline constexpr bool is_floating_point_v
251        = is_floating_point<T>::value;                                   // C++17
252      template <class T> inline constexpr bool is_array_v
253        = is_array<T>::value;                                            // C++17
254      template <class T> inline constexpr bool is_pointer_v
255        = is_pointer<T>::value;                                          // C++17
256      template <class T> inline constexpr bool is_lvalue_reference_v
257        = is_lvalue_reference<T>::value;                                 // C++17
258      template <class T> inline constexpr bool is_rvalue_reference_v
259        = is_rvalue_reference<T>::value;                                 // C++17
260      template <class T> inline constexpr bool is_member_object_pointer_v
261        = is_member_object_pointer<T>::value;                            // C++17
262      template <class T> inline constexpr bool is_member_function_pointer_v
263        = is_member_function_pointer<T>::value;                          // C++17
264      template <class T> inline constexpr bool is_enum_v
265        = is_enum<T>::value;                                             // C++17
266      template <class T> inline constexpr bool is_union_v
267        = is_union<T>::value;                                            // C++17
268      template <class T> inline constexpr bool is_class_v
269        = is_class<T>::value;                                            // C++17
270      template <class T> inline constexpr bool is_function_v
271        = is_function<T>::value;                                         // C++17
272
273      // See C++14 20.10.4.2, composite type categories
274      template <class T> inline constexpr bool is_reference_v
275        = is_reference<T>::value;                                        // C++17
276      template <class T> inline constexpr bool is_arithmetic_v
277        = is_arithmetic<T>::value;                                       // C++17
278      template <class T> inline constexpr bool is_fundamental_v
279        = is_fundamental<T>::value;                                      // C++17
280      template <class T> inline constexpr bool is_object_v
281        = is_object<T>::value;                                           // C++17
282      template <class T> inline constexpr bool is_scalar_v
283        = is_scalar<T>::value;                                           // C++17
284      template <class T> inline constexpr bool is_compound_v
285        = is_compound<T>::value;                                         // C++17
286      template <class T> inline constexpr bool is_member_pointer_v
287        = is_member_pointer<T>::value;                                   // C++17
288      template <class T> inline constexpr bool is_scoped_enum_v
289        = is_scoped_enum<T>::value;                                      // C++2b
290
291      // See C++14 20.10.4.3, type properties
292      template <class T> inline constexpr bool is_const_v
293        = is_const<T>::value;                                            // C++17
294      template <class T> inline constexpr bool is_volatile_v
295        = is_volatile<T>::value;                                         // C++17
296      template <class T> inline constexpr bool is_trivial_v
297        = is_trivial<T>::value;                                          // C++17
298      template <class T> inline constexpr bool is_trivially_copyable_v
299        = is_trivially_copyable<T>::value;                               // C++17
300      template <class T> inline constexpr bool is_standard_layout_v
301        = is_standard_layout<T>::value;                                  // C++17
302      template <class T> inline constexpr bool is_pod_v
303        = is_pod<T>::value;                                              // C++17
304      template <class T> inline constexpr bool is_literal_type_v
305        = is_literal_type<T>::value;                                     // C++17; deprecated in C++17; removed in C++20
306      template <class T> inline constexpr bool is_empty_v
307        = is_empty<T>::value;                                            // C++17
308      template <class T> inline constexpr bool is_polymorphic_v
309        = is_polymorphic<T>::value;                                      // C++17
310      template <class T> inline constexpr bool is_abstract_v
311        = is_abstract<T>::value;                                         // C++17
312      template <class T> inline constexpr bool is_final_v
313        = is_final<T>::value;                                            // C++17
314      template <class T> inline constexpr bool is_aggregate_v
315        = is_aggregate<T>::value;                                        // C++17
316      template <class T> inline constexpr bool is_signed_v
317        = is_signed<T>::value;                                           // C++17
318      template <class T> inline constexpr bool is_unsigned_v
319        = is_unsigned<T>::value;                                         // C++17
320      template <class T, class... Args> inline constexpr bool is_constructible_v
321        = is_constructible<T, Args...>::value;                           // C++17
322      template <class T> inline constexpr bool is_default_constructible_v
323        = is_default_constructible<T>::value;                            // C++17
324      template <class T> inline constexpr bool is_copy_constructible_v
325        = is_copy_constructible<T>::value;                               // C++17
326      template <class T> inline constexpr bool is_move_constructible_v
327        = is_move_constructible<T>::value;                               // C++17
328      template <class T, class U> inline constexpr bool is_assignable_v
329        = is_assignable<T, U>::value;                                    // C++17
330      template <class T> inline constexpr bool is_copy_assignable_v
331        = is_copy_assignable<T>::value;                                  // C++17
332      template <class T> inline constexpr bool is_move_assignable_v
333        = is_move_assignable<T>::value;                                  // C++17
334      template <class T, class U> inline constexpr bool is_swappable_with_v
335        = is_swappable_with<T, U>::value;                                // C++17
336      template <class T> inline constexpr bool is_swappable_v
337        = is_swappable<T>::value;                                        // C++17
338      template <class T> inline constexpr bool is_destructible_v
339        = is_destructible<T>::value;                                     // C++17
340      template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
341        = is_trivially_constructible<T, Args...>::value;                 // C++17
342      template <class T> inline constexpr bool is_trivially_default_constructible_v
343        = is_trivially_default_constructible<T>::value;                  // C++17
344      template <class T> inline constexpr bool is_trivially_copy_constructible_v
345        = is_trivially_copy_constructible<T>::value;                     // C++17
346      template <class T> inline constexpr bool is_trivially_move_constructible_v
347        = is_trivially_move_constructible<T>::value;                     // C++17
348      template <class T, class U> inline constexpr bool is_trivially_assignable_v
349        = is_trivially_assignable<T, U>::value;                          // C++17
350      template <class T> inline constexpr bool is_trivially_copy_assignable_v
351        = is_trivially_copy_assignable<T>::value;                        // C++17
352      template <class T> inline constexpr bool is_trivially_move_assignable_v
353        = is_trivially_move_assignable<T>::value;                        // C++17
354      template <class T> inline constexpr bool is_trivially_destructible_v
355        = is_trivially_destructible<T>::value;                           // C++17
356      template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
357        = is_nothrow_constructible<T, Args...>::value;                   // C++17
358      template <class T> inline constexpr bool is_nothrow_default_constructible_v
359        = is_nothrow_default_constructible<T>::value;                    // C++17
360      template <class T> inline constexpr bool is_nothrow_copy_constructible_v
361        = is_nothrow_copy_constructible<T>::value;                       // C++17
362      template <class T> inline constexpr bool is_nothrow_move_constructible_v
363        = is_nothrow_move_constructible<T>::value;                       // C++17
364      template <class T, class U> inline constexpr bool is_nothrow_assignable_v
365        = is_nothrow_assignable<T, U>::value;                            // C++17
366      template <class T> inline constexpr bool is_nothrow_copy_assignable_v
367        = is_nothrow_copy_assignable<T>::value;                          // C++17
368      template <class T> inline constexpr bool is_nothrow_move_assignable_v
369        = is_nothrow_move_assignable<T>::value;                          // C++17
370      template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
371        = is_nothrow_swappable_with<T, U>::value;                       // C++17
372      template <class T> inline constexpr bool is_nothrow_swappable_v
373        = is_nothrow_swappable<T>::value;                               // C++17
374      template <class T> inline constexpr bool is_nothrow_destructible_v
375        = is_nothrow_destructible<T>::value;                             // C++17
376      template <class T> inline constexpr bool has_virtual_destructor_v
377        = has_virtual_destructor<T>::value;                              // C++17
378      template<class T> inline constexpr bool has_unique_object_representations_v // C++17
379        = has_unique_object_representations<T>::value;
380
381      // See C++14 20.10.5, type property queries
382      template <class T> inline constexpr size_t alignment_of_v
383        = alignment_of<T>::value;                                        // C++17
384      template <class T> inline constexpr size_t rank_v
385        = rank<T>::value;                                                // C++17
386      template <class T, unsigned I = 0> inline constexpr size_t extent_v
387        = extent<T, I>::value;                                           // C++17
388
389      // See C++14 20.10.6, type relations
390      template <class T, class U> inline constexpr bool is_same_v
391        = is_same<T, U>::value;                                          // C++17
392      template <class Base, class Derived> inline constexpr bool is_base_of_v
393        = is_base_of<Base, Derived>::value;                              // C++17
394      template <class From, class To> inline constexpr bool is_convertible_v
395        = is_convertible<From, To>::value;                               // C++17
396      template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
397        = is_invocable<Fn, ArgTypes...>::value;                          // C++17
398      template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
399        = is_invocable_r<R, Fn, ArgTypes...>::value;                     // C++17
400      template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
401        = is_nothrow_invocable<Fn, ArgTypes...>::value;                  // C++17
402      template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
403        = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value;             // C++17
404
405      // [meta.logical], logical operator traits:
406      template<class... B> struct conjunction;                           // C++17
407      template<class... B>
408        inline constexpr bool conjunction_v = conjunction<B...>::value;  // C++17
409      template<class... B> struct disjunction;                           // C++17
410      template<class... B>
411        inline constexpr bool disjunction_v = disjunction<B...>::value;  // C++17
412      template<class B> struct negation;                                 // C++17
413      template<class B>
414        inline constexpr bool negation_v = negation<B>::value;           // C++17
415
416}
417
418*/
419#include <__assert> // all public C++ headers provide the assertion handler
420#include <__config>
421#include <__type_traits/add_const.h>
422#include <__type_traits/add_cv.h>
423#include <__type_traits/add_lvalue_reference.h>
424#include <__type_traits/add_pointer.h>
425#include <__type_traits/add_rvalue_reference.h>
426#include <__type_traits/add_volatile.h>
427#include <__type_traits/conditional.h>
428#include <__type_traits/conjunction.h>
429#include <__type_traits/decay.h>
430#include <__type_traits/disjunction.h>
431#include <__type_traits/enable_if.h>
432#include <__type_traits/extent.h>
433#include <__type_traits/integral_constant.h>
434#include <__type_traits/is_abstract.h>
435#include <__type_traits/is_aggregate.h>
436#include <__type_traits/is_arithmetic.h>
437#include <__type_traits/is_array.h>
438#include <__type_traits/is_base_of.h>
439#include <__type_traits/is_bounded_array.h>
440#include <__type_traits/is_callable.h>
441#include <__type_traits/is_class.h>
442#include <__type_traits/is_compound.h>
443#include <__type_traits/is_const.h>
444#include <__type_traits/is_convertible.h>
445#include <__type_traits/is_empty.h>
446#include <__type_traits/is_enum.h>
447#include <__type_traits/is_final.h>
448#include <__type_traits/is_floating_point.h>
449#include <__type_traits/is_function.h>
450#include <__type_traits/is_fundamental.h>
451#include <__type_traits/is_integral.h>
452#include <__type_traits/is_member_function_pointer.h>
453#include <__type_traits/is_member_object_pointer.h>
454#include <__type_traits/is_member_pointer.h>
455#include <__type_traits/is_null_pointer.h>
456#include <__type_traits/is_object.h>
457#include <__type_traits/is_pointer.h>
458#include <__type_traits/is_reference.h>
459#include <__type_traits/is_reference_wrapper.h>
460#include <__type_traits/is_referenceable.h>
461#include <__type_traits/is_same.h>
462#include <__type_traits/is_scalar.h>
463#include <__type_traits/is_signed.h>
464#include <__type_traits/is_unbounded_array.h>
465#include <__type_traits/is_union.h>
466#include <__type_traits/is_unsigned.h>
467#include <__type_traits/is_void.h>
468#include <__type_traits/is_volatile.h>
469#include <__type_traits/rank.h>
470#include <__type_traits/remove_all_extents.h>
471#include <__type_traits/remove_const.h>
472#include <__type_traits/remove_cv.h>
473#include <__type_traits/remove_extent.h>
474#include <__type_traits/remove_pointer.h>
475#include <__type_traits/remove_reference.h>
476#include <__type_traits/remove_volatile.h>
477#include <__type_traits/type_identity.h>
478#include <__utility/declval.h>
479#include <cstddef>
480#include <version>
481
482#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
483#  pragma GCC system_header
484#endif
485
486_LIBCPP_BEGIN_NAMESPACE_STD
487
488template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
489template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
490
491template <bool> struct _MetaBase;
492template <>
493struct _MetaBase<true> {
494  template <class _Tp, class _Up>
495  using _SelectImpl _LIBCPP_NODEBUG = _Tp;
496  template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
497  using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>;
498  template <class _First, class...>
499  using _FirstImpl _LIBCPP_NODEBUG = _First;
500  template <class, class _Second, class...>
501  using _SecondImpl _LIBCPP_NODEBUG = _Second;
502  template <class _Result, class _First, class ..._Rest>
503  using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
504};
505
506template <>
507struct _MetaBase<false> {
508  template <class _Tp, class _Up>
509  using _SelectImpl _LIBCPP_NODEBUG = _Up;
510  template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
511  using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>;
512  template <class _Result, class ...>
513  using _OrImpl _LIBCPP_NODEBUG = _Result;
514};
515template <bool _Cond, class _IfRes, class _ElseRes>
516using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
517template <class ..._Rest>
518using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
519template <class _Pred>
520struct _Not : _BoolConstant<!_Pred::value> {};
521template <class ..._Args>
522using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
523template <class ..._Args>
524using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
525
526template <class ...> using __expand_to_true = true_type;
527template <class ..._Pred>
528__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
529template <class ...>
530false_type __and_helper(...);
531template <class ..._Pred>
532using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
533
534template <template <class...> class _Func, class ..._Args>
535struct _Lazy : _Func<_Args...> {};
536
537// Member detector base
538
539template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
540true_type __sfinae_test_impl(int);
541template <template <class...> class, class ...>
542false_type __sfinae_test_impl(...);
543
544template <template <class ...> class _Templ, class ..._Args>
545using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
546
547template <class>
548struct __void_t { typedef void type; };
549
550template <class _Tp, bool>
551struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
552
553// is_same
554
555template <class _Tp>
556using __test_for_primary_template = __enable_if_t<
557    _IsSame<_Tp, typename _Tp::__primary_template>::value
558  >;
559template <class _Tp>
560using __is_primary_template = _IsValidExpansion<
561    __test_for_primary_template, _Tp
562  >;
563
564// is_integral
565
566// [basic.fundamental] defines five standard signed integer types;
567// __int128_t is an extended signed integer type.
568// The signed and unsigned integer types, plus bool and the
569// five types with "char" in their name, compose the "integral" types.
570
571template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
572template <> struct __libcpp_is_signed_integer<signed char>      : public true_type {};
573template <> struct __libcpp_is_signed_integer<signed short>     : public true_type {};
574template <> struct __libcpp_is_signed_integer<signed int>       : public true_type {};
575template <> struct __libcpp_is_signed_integer<signed long>      : public true_type {};
576template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
577#ifndef _LIBCPP_HAS_NO_INT128
578template <> struct __libcpp_is_signed_integer<__int128_t>       : public true_type {};
579#endif
580
581template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
582template <> struct __libcpp_is_unsigned_integer<unsigned char>      : public true_type {};
583template <> struct __libcpp_is_unsigned_integer<unsigned short>     : public true_type {};
584template <> struct __libcpp_is_unsigned_integer<unsigned int>       : public true_type {};
585template <> struct __libcpp_is_unsigned_integer<unsigned long>      : public true_type {};
586template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
587#ifndef _LIBCPP_HAS_NO_INT128
588template <> struct __libcpp_is_unsigned_integer<__uint128_t>        : public true_type {};
589#endif
590
591template <class _Tp>
592struct __unconstref {
593    typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
594};
595
596template <class _Tp>
597using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
598
599// __is_same_uncvref
600
601template <class _Tp, class _Up>
602struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
603
604#if _LIBCPP_STD_VER > 17
605// remove_cvref - same as __uncvref
606template <class _Tp>
607struct remove_cvref {
608    using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
609};
610
611template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
612#endif
613
614
615struct __any
616{
617    __any(...);
618};
619
620// __is_core_convertible
621
622// [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
623// We can't test for that, but we can test implicit convertibility by passing it
624// to a function. Notice that __is_core_convertible<void,void> is false,
625// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
626
627template <class _Tp, class _Up, class = void>
628struct __is_core_convertible : public false_type {};
629
630template <class _Tp, class _Up>
631struct __is_core_convertible<_Tp, _Up, decltype(
632    static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
633)> : public true_type {};
634
635// is_nothrow_convertible
636
637#if _LIBCPP_STD_VER > 17
638
639template <typename _Tp>
640static void __test_noexcept(_Tp) noexcept;
641
642template<typename _Fm, typename _To>
643static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
644__is_nothrow_convertible_test();
645
646template <typename _Fm, typename _To>
647struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
648{ };
649
650template <typename _Fm, typename _To>
651struct is_nothrow_convertible : _Or<
652    _And<is_void<_To>, is_void<_Fm>>,
653    _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
654>::type { };
655
656template <typename _Fm, typename _To>
657inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
658
659#endif // _LIBCPP_STD_VER > 17
660
661// is_polymorphic
662
663#if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
664
665template <class _Tp>
666struct _LIBCPP_TEMPLATE_VIS is_polymorphic
667    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
668
669#else
670
671template<typename _Tp> char &__is_polymorphic_impl(
672    typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
673                       int>::type);
674template<typename _Tp> __two &__is_polymorphic_impl(...);
675
676template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
677    : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
678
679#endif // __has_feature(is_polymorphic)
680
681#if _LIBCPP_STD_VER > 14
682template <class _Tp>
683inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
684#endif
685
686// has_virtual_destructor
687
688#if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
689
690template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
691    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
692
693#else
694
695template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
696    : public false_type {};
697
698#endif
699
700#if _LIBCPP_STD_VER > 14
701template <class _Tp>
702inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
703#endif
704
705// has_unique_object_representations
706
707#if _LIBCPP_STD_VER > 14
708
709template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
710    : public integral_constant<bool,
711       __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
712
713template <class _Tp>
714inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
715
716#endif
717
718// alignment_of
719
720template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
721    : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
722
723#if _LIBCPP_STD_VER > 14
724template <class _Tp>
725inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
726#endif
727
728// aligned_storage
729
730template <class _Hp, class _Tp>
731struct __type_list
732{
733    typedef _Hp _Head;
734    typedef _Tp _Tail;
735};
736
737struct __nat
738{
739#ifndef _LIBCPP_CXX03_LANG
740    __nat() = delete;
741    __nat(const __nat&) = delete;
742    __nat& operator=(const __nat&) = delete;
743    ~__nat() = delete;
744#endif
745};
746
747template <class _Tp>
748struct __align_type
749{
750    static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
751    typedef _Tp type;
752};
753
754struct __struct_double {long double __lx;};
755struct __struct_double4 {double __lx[4];};
756
757typedef
758    __type_list<__align_type<unsigned char>,
759    __type_list<__align_type<unsigned short>,
760    __type_list<__align_type<unsigned int>,
761    __type_list<__align_type<unsigned long>,
762    __type_list<__align_type<unsigned long long>,
763    __type_list<__align_type<double>,
764    __type_list<__align_type<long double>,
765    __type_list<__align_type<__struct_double>,
766    __type_list<__align_type<__struct_double4>,
767    __type_list<__align_type<int*>,
768    __nat
769    > > > > > > > > > > __all_types;
770
771template <size_t _Align>
772struct _ALIGNAS(_Align) __fallback_overaligned {};
773
774template <class _TL, size_t _Align> struct __find_pod;
775
776template <class _Hp, size_t _Align>
777struct __find_pod<__type_list<_Hp, __nat>, _Align>
778{
779    typedef typename conditional<
780                             _Align == _Hp::value,
781                             typename _Hp::type,
782                             __fallback_overaligned<_Align>
783                         >::type type;
784};
785
786template <class _Hp, class _Tp, size_t _Align>
787struct __find_pod<__type_list<_Hp, _Tp>, _Align>
788{
789    typedef typename conditional<
790                             _Align == _Hp::value,
791                             typename _Hp::type,
792                             typename __find_pod<_Tp, _Align>::type
793                         >::type type;
794};
795
796template <class _TL, size_t _Len> struct __find_max_align;
797
798template <class _Hp, size_t _Len>
799struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
800
801template <size_t _Len, size_t _A1, size_t _A2>
802struct __select_align
803{
804private:
805    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
806    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
807public:
808    static const size_t value = _Len < __max ? __min : __max;
809};
810
811template <class _Hp, class _Tp, size_t _Len>
812struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
813    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
814
815template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
816struct _LIBCPP_TEMPLATE_VIS aligned_storage
817{
818    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
819    union type
820    {
821        _Aligner __align;
822        unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
823    };
824};
825
826#if _LIBCPP_STD_VER > 11
827template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
828    using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
829#endif
830
831#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
832template <size_t _Len>\
833struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
834{\
835    struct _ALIGNAS(n) type\
836    {\
837        unsigned char __lx[(_Len + n - 1)/n * n];\
838    };\
839}
840
841_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
842_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
843_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
844_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
845_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
846_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
847_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
848_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
849_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
850_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
851_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
852_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
853_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
854_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
855// PE/COFF does not support alignment beyond 8192 (=0x2000)
856#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
857_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
858#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
859
860#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
861
862
863// aligned_union
864
865template <size_t _I0, size_t ..._In>
866struct __static_max;
867
868template <size_t _I0>
869struct __static_max<_I0>
870{
871    static const size_t value = _I0;
872};
873
874template <size_t _I0, size_t _I1, size_t ..._In>
875struct __static_max<_I0, _I1, _In...>
876{
877    static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
878                                             __static_max<_I1, _In...>::value;
879};
880
881template <size_t _Len, class _Type0, class ..._Types>
882struct aligned_union
883{
884    static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
885                                                       _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
886    static const size_t __len = __static_max<_Len, sizeof(_Type0),
887                                             sizeof(_Types)...>::value;
888    typedef typename aligned_storage<__len, alignment_value>::type type;
889};
890
891#if _LIBCPP_STD_VER > 11
892template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
893#endif
894
895template <class _Tp>
896struct __numeric_type
897{
898   static void __test(...);
899   static float __test(float);
900   static double __test(char);
901   static double __test(int);
902   static double __test(unsigned);
903   static double __test(long);
904   static double __test(unsigned long);
905   static double __test(long long);
906   static double __test(unsigned long long);
907   static double __test(double);
908   static long double __test(long double);
909
910   typedef decltype(__test(declval<_Tp>())) type;
911   static const bool value = _IsNotSame<type, void>::value;
912};
913
914template <>
915struct __numeric_type<void>
916{
917   static const bool value = true;
918};
919
920// __promote
921
922template <class _A1, class _A2 = void, class _A3 = void,
923          bool = __numeric_type<_A1>::value &&
924                 __numeric_type<_A2>::value &&
925                 __numeric_type<_A3>::value>
926class __promote_imp
927{
928public:
929    static const bool value = false;
930};
931
932template <class _A1, class _A2, class _A3>
933class __promote_imp<_A1, _A2, _A3, true>
934{
935private:
936    typedef typename __promote_imp<_A1>::type __type1;
937    typedef typename __promote_imp<_A2>::type __type2;
938    typedef typename __promote_imp<_A3>::type __type3;
939public:
940    typedef decltype(__type1() + __type2() + __type3()) type;
941    static const bool value = true;
942};
943
944template <class _A1, class _A2>
945class __promote_imp<_A1, _A2, void, true>
946{
947private:
948    typedef typename __promote_imp<_A1>::type __type1;
949    typedef typename __promote_imp<_A2>::type __type2;
950public:
951    typedef decltype(__type1() + __type2()) type;
952    static const bool value = true;
953};
954
955template <class _A1>
956class __promote_imp<_A1, void, void, true>
957{
958public:
959    typedef typename __numeric_type<_A1>::type type;
960    static const bool value = true;
961};
962
963template <class _A1, class _A2 = void, class _A3 = void>
964class __promote : public __promote_imp<_A1, _A2, _A3> {};
965
966// make_signed / make_unsigned
967
968typedef
969    __type_list<signed char,
970    __type_list<signed short,
971    __type_list<signed int,
972    __type_list<signed long,
973    __type_list<signed long long,
974#ifndef _LIBCPP_HAS_NO_INT128
975    __type_list<__int128_t,
976#endif
977    __nat
978#ifndef _LIBCPP_HAS_NO_INT128
979    >
980#endif
981    > > > > > __signed_types;
982
983typedef
984    __type_list<unsigned char,
985    __type_list<unsigned short,
986    __type_list<unsigned int,
987    __type_list<unsigned long,
988    __type_list<unsigned long long,
989#ifndef _LIBCPP_HAS_NO_INT128
990    __type_list<__uint128_t,
991#endif
992    __nat
993#ifndef _LIBCPP_HAS_NO_INT128
994    >
995#endif
996    > > > > > __unsigned_types;
997
998template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
999
1000template <class _Hp, class _Tp, size_t _Size>
1001struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
1002{
1003    typedef _LIBCPP_NODEBUG _Hp type;
1004};
1005
1006template <class _Hp, class _Tp, size_t _Size>
1007struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
1008{
1009    typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
1010};
1011
1012template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
1013                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
1014struct __apply_cv
1015{
1016    typedef _LIBCPP_NODEBUG _Up type;
1017};
1018
1019template <class _Tp, class _Up>
1020struct __apply_cv<_Tp, _Up, true, false>
1021{
1022    typedef _LIBCPP_NODEBUG const _Up type;
1023};
1024
1025template <class _Tp, class _Up>
1026struct __apply_cv<_Tp, _Up, false, true>
1027{
1028    typedef volatile _Up type;
1029};
1030
1031template <class _Tp, class _Up>
1032struct __apply_cv<_Tp, _Up, true, true>
1033{
1034    typedef const volatile _Up type;
1035};
1036
1037template <class _Tp, class _Up>
1038struct __apply_cv<_Tp&, _Up, false, false>
1039{
1040    typedef _Up& type;
1041};
1042
1043template <class _Tp, class _Up>
1044struct __apply_cv<_Tp&, _Up, true, false>
1045{
1046    typedef const _Up& type;
1047};
1048
1049template <class _Tp, class _Up>
1050struct __apply_cv<_Tp&, _Up, false, true>
1051{
1052    typedef volatile _Up& type;
1053};
1054
1055template <class _Tp, class _Up>
1056struct __apply_cv<_Tp&, _Up, true, true>
1057{
1058    typedef const volatile _Up& type;
1059};
1060
1061template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1062struct __make_signed {};
1063
1064template <class _Tp>
1065struct __make_signed<_Tp, true>
1066{
1067    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
1068};
1069
1070template <> struct __make_signed<bool,               true> {};
1071template <> struct __make_signed<  signed short,     true> {typedef short     type;};
1072template <> struct __make_signed<unsigned short,     true> {typedef short     type;};
1073template <> struct __make_signed<  signed int,       true> {typedef int       type;};
1074template <> struct __make_signed<unsigned int,       true> {typedef int       type;};
1075template <> struct __make_signed<  signed long,      true> {typedef long      type;};
1076template <> struct __make_signed<unsigned long,      true> {typedef long      type;};
1077template <> struct __make_signed<  signed long long, true> {typedef long long type;};
1078template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
1079#ifndef _LIBCPP_HAS_NO_INT128
1080template <> struct __make_signed<__int128_t,         true> {typedef __int128_t type;};
1081template <> struct __make_signed<__uint128_t,        true> {typedef __int128_t type;};
1082#endif
1083
1084template <class _Tp>
1085struct _LIBCPP_TEMPLATE_VIS make_signed
1086{
1087    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
1088};
1089
1090#if _LIBCPP_STD_VER > 11
1091template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
1092#endif
1093
1094template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
1095struct __make_unsigned {};
1096
1097template <class _Tp>
1098struct __make_unsigned<_Tp, true>
1099{
1100    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
1101};
1102
1103template <> struct __make_unsigned<bool,               true> {};
1104template <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
1105template <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
1106template <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
1107template <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
1108template <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
1109template <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
1110template <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
1111template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1112#ifndef _LIBCPP_HAS_NO_INT128
1113template <> struct __make_unsigned<__int128_t,         true> {typedef __uint128_t        type;};
1114template <> struct __make_unsigned<__uint128_t,        true> {typedef __uint128_t        type;};
1115#endif
1116
1117template <class _Tp>
1118struct _LIBCPP_TEMPLATE_VIS make_unsigned
1119{
1120    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1121};
1122
1123#if _LIBCPP_STD_VER > 11
1124template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1125#endif
1126
1127#ifndef _LIBCPP_CXX03_LANG
1128template <class _Tp>
1129_LIBCPP_HIDE_FROM_ABI constexpr
1130typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
1131    return static_cast<typename make_unsigned<_Tp>::type>(__x);
1132}
1133#endif
1134
1135#if _LIBCPP_STD_VER > 14
1136template <class...> using void_t = void;
1137#endif
1138
1139#if _LIBCPP_STD_VER > 17
1140// Let COND_RES(X, Y) be:
1141template <class _Tp, class _Up>
1142using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
1143
1144template <class _Tp, class _Up, class = void>
1145struct __common_type3 {};
1146
1147// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
1148template <class _Tp, class _Up>
1149struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
1150{
1151    using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
1152};
1153
1154template <class _Tp, class _Up, class = void>
1155struct __common_type2_imp : __common_type3<_Tp, _Up> {};
1156#else
1157template <class _Tp, class _Up, class = void>
1158struct __common_type2_imp {};
1159#endif
1160
1161// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
1162template <class _Tp, class _Up>
1163struct __common_type2_imp<_Tp, _Up,
1164                          typename __void_t<decltype(
1165                                            true ? declval<_Tp>() : declval<_Up>()
1166                                            )>::type>
1167{
1168  typedef _LIBCPP_NODEBUG typename decay<decltype(
1169                         true ? declval<_Tp>() : declval<_Up>()
1170                         )>::type type;
1171};
1172
1173template <class, class = void>
1174struct __common_type_impl {};
1175
1176// Clang provides variadic templates in C++03 as an extension.
1177#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
1178# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
1179template <class... _Tp>
1180struct __common_types;
1181template <class... _Tp>
1182struct _LIBCPP_TEMPLATE_VIS common_type;
1183#else
1184# define _LIBCPP_OPTIONAL_PACK(...)
1185struct __no_arg;
1186template <class _Tp, class _Up, class = __no_arg>
1187struct __common_types;
1188template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
1189          class _Unused = __no_arg>
1190struct common_type {
1191  static_assert(sizeof(_Unused) == 0,
1192                "common_type accepts at most 3 arguments in C++03");
1193};
1194#endif // _LIBCPP_CXX03_LANG
1195
1196template <class _Tp, class _Up>
1197struct __common_type_impl<
1198    __common_types<_Tp, _Up>,
1199    typename __void_t<typename common_type<_Tp, _Up>::type>::type>
1200{
1201  typedef typename common_type<_Tp, _Up>::type type;
1202};
1203
1204template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
1205struct __common_type_impl<
1206    __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
1207    typename __void_t<typename common_type<_Tp, _Up>::type>::type>
1208    : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
1209                                        _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
1210};
1211
1212// bullet 1 - sizeof...(Tp) == 0
1213
1214template <>
1215struct _LIBCPP_TEMPLATE_VIS common_type<> {};
1216
1217// bullet 2 - sizeof...(Tp) == 1
1218
1219template <class _Tp>
1220struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
1221    : public common_type<_Tp, _Tp> {};
1222
1223// bullet 3 - sizeof...(Tp) == 2
1224
1225// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
1226template <class _Tp, class _Up>
1227struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
1228    : conditional<
1229        _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
1230        __common_type2_imp<_Tp, _Up>,
1231        common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
1232    >::type
1233{};
1234
1235// bullet 4 - sizeof...(Tp) > 2
1236
1237template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
1238struct _LIBCPP_TEMPLATE_VIS
1239    common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
1240    : __common_type_impl<
1241          __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
1242
1243#undef _LIBCPP_OPTIONAL_PACK
1244
1245#if _LIBCPP_STD_VER > 11
1246template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1247#endif
1248
1249#if _LIBCPP_STD_VER > 11
1250// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
1251// top-level cv-qualifiers.
1252template <class _From, class _To>
1253struct __copy_cv
1254{
1255    using type = _To;
1256};
1257
1258template <class _From, class _To>
1259struct __copy_cv<const _From, _To>
1260{
1261    using type = add_const_t<_To>;
1262};
1263
1264template <class _From, class _To>
1265struct __copy_cv<volatile _From, _To>
1266{
1267    using type = add_volatile_t<_To>;
1268};
1269
1270template <class _From, class _To>
1271struct __copy_cv<const volatile _From, _To>
1272{
1273    using type = add_cv_t<_To>;
1274};
1275
1276template <class _From, class _To>
1277using __copy_cv_t = typename __copy_cv<_From, _To>::type;
1278
1279template <class _From, class _To>
1280struct __copy_cvref
1281{
1282    using type = __copy_cv_t<_From, _To>;
1283};
1284
1285template <class _From, class _To>
1286struct __copy_cvref<_From&, _To>
1287{
1288    using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>;
1289};
1290
1291template <class _From, class _To>
1292struct __copy_cvref<_From&&, _To>
1293{
1294    using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>;
1295};
1296
1297template <class _From, class _To>
1298using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
1299
1300#endif // _LIBCPP_STD_VER > 11
1301
1302// common_reference
1303#if _LIBCPP_STD_VER > 17
1304// Let COND_RES(X, Y) be:
1305template <class _Xp, class _Yp>
1306using __cond_res =
1307    decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
1308
1309// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
1310// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
1311// `U`.
1312// [Note: `XREF(A)` is `__xref<A>::template __apply`]
1313template <class _Tp>
1314struct __xref {
1315  template<class _Up>
1316  using __apply = __copy_cvref_t<_Tp, _Up>;
1317};
1318
1319// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
1320// and let COMMON-REF(A, B) be:
1321template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
1322struct __common_ref;
1323
1324template<class _Xp, class _Yp>
1325using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
1326
1327template<class _Xp, class _Yp>
1328using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
1329
1330
1331//    If A and B are both lvalue reference types, COMMON-REF(A, B) is
1332//    COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
1333template<class _Ap, class _Bp, class _Xp, class _Yp>
1334requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
1335struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
1336{
1337    using __type = __cv_cond_res<_Xp, _Yp>;
1338};
1339
1340//    Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
1341template <class _Xp, class _Yp>
1342using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
1343
1344
1345//    .... If A and B are both rvalue reference types, C is well-formed, and
1346//    is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
1347template<class _Ap, class _Bp, class _Xp, class _Yp>
1348requires
1349  requires { typename __common_ref_C<_Xp, _Yp>; } &&
1350  is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
1351  is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
1352struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
1353{
1354    using __type = __common_ref_C<_Xp, _Yp>;
1355};
1356
1357//    Otherwise, let D be COMMON-REF(const X&, Y&). ...
1358template <class _Tp, class _Up>
1359using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
1360
1361//    ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
1362//    is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
1363template<class _Ap, class _Bp, class _Xp, class _Yp>
1364requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
1365         is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
1366struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
1367{
1368    using __type = __common_ref_D<_Xp, _Yp>;
1369};
1370
1371//    Otherwise, if A is an lvalue reference and B is an rvalue reference, then
1372//    COMMON-REF(A, B) is COMMON-REF(B, A).
1373template<class _Ap, class _Bp, class _Xp, class _Yp>
1374struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
1375
1376//    Otherwise, COMMON-REF(A, B) is ill-formed.
1377template<class _Ap, class _Bp, class _Xp, class _Yp>
1378struct __common_ref {};
1379
1380// Note C: For the common_reference trait applied to a parameter pack [...]
1381
1382template <class...>
1383struct common_reference;
1384
1385template <class... _Types>
1386using common_reference_t = typename common_reference<_Types...>::type;
1387
1388// bullet 1 - sizeof...(T) == 0
1389template<>
1390struct common_reference<> {};
1391
1392// bullet 2 - sizeof...(T) == 1
1393template <class _Tp>
1394struct common_reference<_Tp>
1395{
1396    using type = _Tp;
1397};
1398
1399// bullet 3 - sizeof...(T) == 2
1400template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
1401template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
1402template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
1403
1404// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
1405// the member typedef `type` denotes that type.
1406template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
1407
1408template <class _Tp, class _Up>
1409requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
1410struct __common_reference_sub_bullet1<_Tp, _Up>
1411{
1412    using type = __common_ref_t<_Tp, _Up>;
1413};
1414
1415// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
1416// is well-formed, then the member typedef `type` denotes that type.
1417template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
1418
1419template <class _Tp, class _Up>
1420using __basic_common_reference_t = typename basic_common_reference<
1421    remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
1422    __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
1423
1424template <class _Tp, class _Up>
1425requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
1426struct __common_reference_sub_bullet2<_Tp, _Up>
1427{
1428    using type = __basic_common_reference_t<_Tp, _Up>;
1429};
1430
1431// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
1432// then the member typedef `type` denotes that type.
1433template <class _Tp, class _Up>
1434requires requires { typename __cond_res<_Tp, _Up>; }
1435struct __common_reference_sub_bullet3<_Tp, _Up>
1436{
1437    using type = __cond_res<_Tp, _Up>;
1438};
1439
1440
1441// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
1442//                    then the member typedef `type` denotes that type.
1443//                  - Otherwise, there shall be no member `type`.
1444template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
1445
1446// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
1447//            any, as `common_reference_t<C, Rest...>`.
1448template <class _Tp, class _Up, class _Vp, class... _Rest>
1449requires requires { typename common_reference_t<_Tp, _Up>; }
1450struct common_reference<_Tp, _Up, _Vp, _Rest...>
1451    : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
1452{};
1453
1454// bullet 5 - Otherwise, there shall be no member `type`.
1455template <class...> struct common_reference {};
1456
1457#endif // _LIBCPP_STD_VER > 17
1458
1459// is_assignable
1460
1461template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
1462
1463#if __has_keyword(__is_assignable)
1464
1465template<class _Tp, class _Up>
1466struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
1467
1468#if _LIBCPP_STD_VER > 14
1469template <class _Tp, class _Arg>
1470inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
1471#endif
1472
1473#else // __has_keyword(__is_assignable)
1474
1475template <class _Tp, class _Arg>
1476typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
1477__is_assignable_test(int);
1478
1479template <class, class>
1480false_type __is_assignable_test(...);
1481
1482
1483template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
1484struct __is_assignable_imp
1485    : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
1486
1487template <class _Tp, class _Arg>
1488struct __is_assignable_imp<_Tp, _Arg, true>
1489    : public false_type
1490{
1491};
1492
1493template <class _Tp, class _Arg>
1494struct is_assignable
1495    : public __is_assignable_imp<_Tp, _Arg> {};
1496
1497#if _LIBCPP_STD_VER > 14
1498template <class _Tp, class _Arg>
1499inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
1500#endif
1501
1502#endif // __has_keyword(__is_assignable)
1503
1504// is_copy_assignable
1505
1506template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
1507    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1508                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
1509
1510#if _LIBCPP_STD_VER > 14
1511template <class _Tp>
1512inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
1513#endif
1514
1515// is_move_assignable
1516
1517template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
1518    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
1519                           typename add_rvalue_reference<_Tp>::type> {};
1520
1521#if _LIBCPP_STD_VER > 14
1522template <class _Tp>
1523inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
1524#endif
1525
1526// is_destructible
1527
1528#if __has_keyword(__is_destructible)
1529
1530template<class _Tp>
1531struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
1532
1533#if _LIBCPP_STD_VER > 14
1534template <class _Tp>
1535inline constexpr bool is_destructible_v = __is_destructible(_Tp);
1536#endif
1537
1538#else // __has_keyword(__is_destructible)
1539
1540//  if it's a reference, return true
1541//  if it's a function, return false
1542//  if it's   void,     return false
1543//  if it's an array of unknown bound, return false
1544//  Otherwise, return "declval<_Up&>().~_Up()" is well-formed
1545//    where _Up is remove_all_extents<_Tp>::type
1546
1547template <class>
1548struct __is_destructible_apply { typedef int type; };
1549
1550template <typename _Tp>
1551struct __is_destructor_wellformed {
1552    template <typename _Tp1>
1553    static char  __test (
1554        typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
1555    );
1556
1557    template <typename _Tp1>
1558    static __two __test (...);
1559
1560    static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
1561};
1562
1563template <class _Tp, bool>
1564struct __destructible_imp;
1565
1566template <class _Tp>
1567struct __destructible_imp<_Tp, false>
1568   : public integral_constant<bool,
1569        __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
1570
1571template <class _Tp>
1572struct __destructible_imp<_Tp, true>
1573    : public true_type {};
1574
1575template <class _Tp, bool>
1576struct __destructible_false;
1577
1578template <class _Tp>
1579struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
1580
1581template <class _Tp>
1582struct __destructible_false<_Tp, true> : public false_type {};
1583
1584template <class _Tp>
1585struct is_destructible
1586    : public __destructible_false<_Tp, is_function<_Tp>::value> {};
1587
1588template <class _Tp>
1589struct is_destructible<_Tp[]>
1590    : public false_type {};
1591
1592template <>
1593struct is_destructible<void>
1594    : public false_type {};
1595
1596#if _LIBCPP_STD_VER > 14
1597template <class _Tp>
1598inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
1599#endif
1600
1601#endif // __has_keyword(__is_destructible)
1602
1603template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
1604struct __member_pointer_traits_imp
1605{
1606};
1607
1608template <class _Rp, class _Class, class ..._Param>
1609struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
1610{
1611    typedef _Class _ClassType;
1612    typedef _Rp _ReturnType;
1613    typedef _Rp (_FnType) (_Param...);
1614};
1615
1616template <class _Rp, class _Class, class ..._Param>
1617struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
1618{
1619    typedef _Class _ClassType;
1620    typedef _Rp _ReturnType;
1621    typedef _Rp (_FnType) (_Param..., ...);
1622};
1623
1624template <class _Rp, class _Class, class ..._Param>
1625struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
1626{
1627    typedef _Class const _ClassType;
1628    typedef _Rp _ReturnType;
1629    typedef _Rp (_FnType) (_Param...);
1630};
1631
1632template <class _Rp, class _Class, class ..._Param>
1633struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
1634{
1635    typedef _Class const _ClassType;
1636    typedef _Rp _ReturnType;
1637    typedef _Rp (_FnType) (_Param..., ...);
1638};
1639
1640template <class _Rp, class _Class, class ..._Param>
1641struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
1642{
1643    typedef _Class volatile _ClassType;
1644    typedef _Rp _ReturnType;
1645    typedef _Rp (_FnType) (_Param...);
1646};
1647
1648template <class _Rp, class _Class, class ..._Param>
1649struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
1650{
1651    typedef _Class volatile _ClassType;
1652    typedef _Rp _ReturnType;
1653    typedef _Rp (_FnType) (_Param..., ...);
1654};
1655
1656template <class _Rp, class _Class, class ..._Param>
1657struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
1658{
1659    typedef _Class const volatile _ClassType;
1660    typedef _Rp _ReturnType;
1661    typedef _Rp (_FnType) (_Param...);
1662};
1663
1664template <class _Rp, class _Class, class ..._Param>
1665struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
1666{
1667    typedef _Class const volatile _ClassType;
1668    typedef _Rp _ReturnType;
1669    typedef _Rp (_FnType) (_Param..., ...);
1670};
1671
1672#if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
1673
1674template <class _Rp, class _Class, class ..._Param>
1675struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
1676{
1677    typedef _Class& _ClassType;
1678    typedef _Rp _ReturnType;
1679    typedef _Rp (_FnType) (_Param...);
1680};
1681
1682template <class _Rp, class _Class, class ..._Param>
1683struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
1684{
1685    typedef _Class& _ClassType;
1686    typedef _Rp _ReturnType;
1687    typedef _Rp (_FnType) (_Param..., ...);
1688};
1689
1690template <class _Rp, class _Class, class ..._Param>
1691struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
1692{
1693    typedef _Class const& _ClassType;
1694    typedef _Rp _ReturnType;
1695    typedef _Rp (_FnType) (_Param...);
1696};
1697
1698template <class _Rp, class _Class, class ..._Param>
1699struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
1700{
1701    typedef _Class const& _ClassType;
1702    typedef _Rp _ReturnType;
1703    typedef _Rp (_FnType) (_Param..., ...);
1704};
1705
1706template <class _Rp, class _Class, class ..._Param>
1707struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
1708{
1709    typedef _Class volatile& _ClassType;
1710    typedef _Rp _ReturnType;
1711    typedef _Rp (_FnType) (_Param...);
1712};
1713
1714template <class _Rp, class _Class, class ..._Param>
1715struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
1716{
1717    typedef _Class volatile& _ClassType;
1718    typedef _Rp _ReturnType;
1719    typedef _Rp (_FnType) (_Param..., ...);
1720};
1721
1722template <class _Rp, class _Class, class ..._Param>
1723struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
1724{
1725    typedef _Class const volatile& _ClassType;
1726    typedef _Rp _ReturnType;
1727    typedef _Rp (_FnType) (_Param...);
1728};
1729
1730template <class _Rp, class _Class, class ..._Param>
1731struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
1732{
1733    typedef _Class const volatile& _ClassType;
1734    typedef _Rp _ReturnType;
1735    typedef _Rp (_FnType) (_Param..., ...);
1736};
1737
1738template <class _Rp, class _Class, class ..._Param>
1739struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
1740{
1741    typedef _Class&& _ClassType;
1742    typedef _Rp _ReturnType;
1743    typedef _Rp (_FnType) (_Param...);
1744};
1745
1746template <class _Rp, class _Class, class ..._Param>
1747struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
1748{
1749    typedef _Class&& _ClassType;
1750    typedef _Rp _ReturnType;
1751    typedef _Rp (_FnType) (_Param..., ...);
1752};
1753
1754template <class _Rp, class _Class, class ..._Param>
1755struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
1756{
1757    typedef _Class const&& _ClassType;
1758    typedef _Rp _ReturnType;
1759    typedef _Rp (_FnType) (_Param...);
1760};
1761
1762template <class _Rp, class _Class, class ..._Param>
1763struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
1764{
1765    typedef _Class const&& _ClassType;
1766    typedef _Rp _ReturnType;
1767    typedef _Rp (_FnType) (_Param..., ...);
1768};
1769
1770template <class _Rp, class _Class, class ..._Param>
1771struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
1772{
1773    typedef _Class volatile&& _ClassType;
1774    typedef _Rp _ReturnType;
1775    typedef _Rp (_FnType) (_Param...);
1776};
1777
1778template <class _Rp, class _Class, class ..._Param>
1779struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
1780{
1781    typedef _Class volatile&& _ClassType;
1782    typedef _Rp _ReturnType;
1783    typedef _Rp (_FnType) (_Param..., ...);
1784};
1785
1786template <class _Rp, class _Class, class ..._Param>
1787struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
1788{
1789    typedef _Class const volatile&& _ClassType;
1790    typedef _Rp _ReturnType;
1791    typedef _Rp (_FnType) (_Param...);
1792};
1793
1794template <class _Rp, class _Class, class ..._Param>
1795struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
1796{
1797    typedef _Class const volatile&& _ClassType;
1798    typedef _Rp _ReturnType;
1799    typedef _Rp (_FnType) (_Param..., ...);
1800};
1801
1802#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
1803
1804
1805template <class _Rp, class _Class>
1806struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
1807{
1808    typedef _Class _ClassType;
1809    typedef _Rp _ReturnType;
1810};
1811
1812template <class _MP>
1813struct __member_pointer_traits
1814    : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
1815                    is_member_function_pointer<_MP>::value,
1816                    is_member_object_pointer<_MP>::value>
1817{
1818//     typedef ... _ClassType;
1819//     typedef ... _ReturnType;
1820//     typedef ... _FnType;
1821};
1822
1823
1824template <class _DecayedFp>
1825struct __member_pointer_class_type {};
1826
1827template <class _Ret, class _ClassType>
1828struct __member_pointer_class_type<_Ret _ClassType::*> {
1829  typedef _ClassType type;
1830};
1831
1832// template <class T, class... Args> struct is_constructible;
1833
1834template <class _Tp, class ..._Args>
1835struct _LIBCPP_TEMPLATE_VIS is_constructible
1836    : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
1837{ };
1838
1839#if _LIBCPP_STD_VER > 14
1840template <class _Tp, class ..._Args>
1841inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
1842#endif
1843
1844// is_default_constructible
1845
1846template <class _Tp>
1847struct _LIBCPP_TEMPLATE_VIS is_default_constructible
1848    : public is_constructible<_Tp>
1849    {};
1850
1851#if _LIBCPP_STD_VER > 14
1852template <class _Tp>
1853inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
1854#endif
1855
1856#ifndef _LIBCPP_CXX03_LANG
1857// First of all, we can't implement this check in C++03 mode because the {}
1858// default initialization syntax isn't valid.
1859// Second, we implement the trait in a funny manner with two defaulted template
1860// arguments to workaround Clang's PR43454.
1861template <class _Tp>
1862void __test_implicit_default_constructible(_Tp);
1863
1864template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
1865struct __is_implicitly_default_constructible
1866    : false_type
1867{ };
1868
1869template <class _Tp>
1870struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
1871    : true_type
1872{ };
1873
1874template <class _Tp>
1875struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
1876    : false_type
1877{ };
1878#endif // !C++03
1879
1880// is_copy_constructible
1881
1882template <class _Tp>
1883struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
1884    : public is_constructible<_Tp,
1885                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
1886
1887#if _LIBCPP_STD_VER > 14
1888template <class _Tp>
1889inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
1890#endif
1891
1892// is_move_constructible
1893
1894template <class _Tp>
1895struct _LIBCPP_TEMPLATE_VIS is_move_constructible
1896    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
1897    {};
1898
1899#if _LIBCPP_STD_VER > 14
1900template <class _Tp>
1901inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
1902#endif
1903
1904// is_trivially_constructible
1905
1906template <class _Tp, class... _Args>
1907struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
1908    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
1909{
1910};
1911
1912#if _LIBCPP_STD_VER > 14
1913template <class _Tp, class... _Args>
1914inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
1915#endif
1916
1917// is_trivially_default_constructible
1918
1919template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
1920    : public is_trivially_constructible<_Tp>
1921    {};
1922
1923#if _LIBCPP_STD_VER > 14
1924template <class _Tp>
1925inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
1926#endif
1927
1928// is_trivially_copy_constructible
1929
1930template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
1931    : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
1932    {};
1933
1934#if _LIBCPP_STD_VER > 14
1935template <class _Tp>
1936inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
1937#endif
1938
1939// is_trivially_move_constructible
1940
1941template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
1942    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
1943    {};
1944
1945#if _LIBCPP_STD_VER > 14
1946template <class _Tp>
1947inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
1948#endif
1949
1950// is_trivially_assignable
1951
1952template <class _Tp, class _Arg>
1953struct is_trivially_assignable
1954    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
1955{ };
1956
1957#if _LIBCPP_STD_VER > 14
1958template <class _Tp, class _Arg>
1959inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
1960#endif
1961
1962// is_trivially_copy_assignable
1963
1964template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
1965    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
1966                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
1967
1968#if _LIBCPP_STD_VER > 14
1969template <class _Tp>
1970inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
1971#endif
1972
1973// is_trivially_move_assignable
1974
1975template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
1976    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
1977                                     typename add_rvalue_reference<_Tp>::type>
1978    {};
1979
1980#if _LIBCPP_STD_VER > 14
1981template <class _Tp>
1982inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
1983#endif
1984
1985// is_trivially_destructible
1986
1987#if __has_keyword(__is_trivially_destructible)
1988
1989template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
1990    : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
1991
1992#elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
1993
1994template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
1995    : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
1996
1997#else
1998
1999template <class _Tp> struct __libcpp_trivial_destructor
2000    : public integral_constant<bool, is_scalar<_Tp>::value ||
2001                                     is_reference<_Tp>::value> {};
2002
2003template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
2004    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
2005
2006template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
2007    : public false_type {};
2008
2009#endif
2010
2011#if _LIBCPP_STD_VER > 14
2012template <class _Tp>
2013inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
2014#endif
2015
2016// is_nothrow_constructible
2017
2018#if __has_keyword(__is_nothrow_constructible)
2019
2020template <class _Tp, class... _Args>
2021struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
2022    : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
2023
2024#else
2025
2026template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
2027
2028template <class _Tp, class... _Args>
2029struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
2030    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
2031{
2032};
2033
2034template <class _Tp>
2035void __implicit_conversion_to(_Tp) noexcept { }
2036
2037template <class _Tp, class _Arg>
2038struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
2039    : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
2040{
2041};
2042
2043template <class _Tp, bool _IsReference, class... _Args>
2044struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
2045    : public false_type
2046{
2047};
2048
2049template <class _Tp, class... _Args>
2050struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
2051    : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
2052{
2053};
2054
2055template <class _Tp, size_t _Ns>
2056struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
2057    : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
2058{
2059};
2060
2061#endif // _LIBCPP_HAS_NO_NOEXCEPT
2062
2063
2064#if _LIBCPP_STD_VER > 14
2065template <class _Tp, class ..._Args>
2066inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
2067#endif
2068
2069// is_nothrow_default_constructible
2070
2071template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
2072    : public is_nothrow_constructible<_Tp>
2073    {};
2074
2075#if _LIBCPP_STD_VER > 14
2076template <class _Tp>
2077inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
2078#endif
2079
2080// is_nothrow_copy_constructible
2081
2082template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
2083    : public is_nothrow_constructible<_Tp,
2084                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2085
2086#if _LIBCPP_STD_VER > 14
2087template <class _Tp>
2088inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
2089#endif
2090
2091// is_nothrow_move_constructible
2092
2093template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
2094    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
2095    {};
2096
2097#if _LIBCPP_STD_VER > 14
2098template <class _Tp>
2099inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
2100#endif
2101
2102// is_nothrow_assignable
2103
2104#if __has_keyword(__is_nothrow_assignable)
2105
2106template <class _Tp, class _Arg>
2107struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
2108    : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
2109
2110#else
2111
2112template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
2113
2114template <class _Tp, class _Arg>
2115struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
2116    : public false_type
2117{
2118};
2119
2120template <class _Tp, class _Arg>
2121struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
2122    : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
2123{
2124};
2125
2126template <class _Tp, class _Arg>
2127struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
2128    : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
2129{
2130};
2131
2132#endif // _LIBCPP_HAS_NO_NOEXCEPT
2133
2134#if _LIBCPP_STD_VER > 14
2135template <class _Tp, class _Arg>
2136inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
2137#endif
2138
2139// is_nothrow_copy_assignable
2140
2141template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
2142    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2143                  typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
2144
2145#if _LIBCPP_STD_VER > 14
2146template <class _Tp>
2147inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
2148#endif
2149
2150// is_nothrow_move_assignable
2151
2152template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
2153    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
2154                                     typename add_rvalue_reference<_Tp>::type>
2155    {};
2156
2157#if _LIBCPP_STD_VER > 14
2158template <class _Tp>
2159inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
2160#endif
2161
2162// is_nothrow_destructible
2163
2164#if !defined(_LIBCPP_CXX03_LANG)
2165
2166template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
2167
2168template <class _Tp>
2169struct __libcpp_is_nothrow_destructible<false, _Tp>
2170    : public false_type
2171{
2172};
2173
2174template <class _Tp>
2175struct __libcpp_is_nothrow_destructible<true, _Tp>
2176    : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
2177{
2178};
2179
2180template <class _Tp>
2181struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
2182    : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
2183{
2184};
2185
2186template <class _Tp, size_t _Ns>
2187struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
2188    : public is_nothrow_destructible<_Tp>
2189{
2190};
2191
2192template <class _Tp>
2193struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
2194    : public true_type
2195{
2196};
2197
2198template <class _Tp>
2199struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
2200    : public true_type
2201{
2202};
2203
2204#else
2205
2206template <class _Tp> struct __libcpp_nothrow_destructor
2207    : public integral_constant<bool, is_scalar<_Tp>::value ||
2208                                     is_reference<_Tp>::value> {};
2209
2210template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
2211    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
2212
2213template <class _Tp>
2214struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
2215    : public false_type {};
2216
2217#endif
2218
2219#if _LIBCPP_STD_VER > 14
2220template <class _Tp>
2221inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
2222#endif
2223
2224// is_pod
2225
2226#if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
2227
2228template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
2229    : public integral_constant<bool, __is_pod(_Tp)> {};
2230
2231#else
2232
2233template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
2234    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
2235                                     is_trivially_copy_constructible<_Tp>::value      &&
2236                                     is_trivially_copy_assignable<_Tp>::value    &&
2237                                     is_trivially_destructible<_Tp>::value> {};
2238
2239#endif
2240
2241#if _LIBCPP_STD_VER > 14
2242template <class _Tp>
2243inline constexpr bool is_pod_v = is_pod<_Tp>::value;
2244#endif
2245
2246// is_literal_type;
2247
2248#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2249template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
2250    : public integral_constant<bool, __is_literal_type(_Tp)>
2251    {};
2252
2253#if _LIBCPP_STD_VER > 14
2254template <class _Tp>
2255_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
2256#endif // _LIBCPP_STD_VER > 14
2257#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2258
2259// is_standard_layout;
2260
2261template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
2262#if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
2263    : public integral_constant<bool, __is_standard_layout(_Tp)>
2264#else
2265    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
2266#endif
2267    {};
2268
2269#if _LIBCPP_STD_VER > 14
2270template <class _Tp>
2271inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
2272#endif
2273
2274// is_trivially_copyable;
2275
2276template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
2277    : public integral_constant<bool, __is_trivially_copyable(_Tp)>
2278    {};
2279
2280#if _LIBCPP_STD_VER > 14
2281template <class _Tp>
2282inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
2283#endif
2284
2285// is_trivial;
2286
2287template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
2288#if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
2289    : public integral_constant<bool, __is_trivial(_Tp)>
2290#else
2291    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
2292                                 is_trivially_default_constructible<_Tp>::value>
2293#endif
2294    {};
2295
2296#if _LIBCPP_STD_VER > 14
2297template <class _Tp>
2298inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
2299#endif
2300
2301
2302#ifndef _LIBCPP_CXX03_LANG
2303
2304template <class _Fp, class _A0,
2305         class _DecayFp = typename decay<_Fp>::type,
2306         class _DecayA0 = typename decay<_A0>::type,
2307         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
2308using __enable_if_bullet1 = typename enable_if
2309    <
2310        is_member_function_pointer<_DecayFp>::value
2311        && is_base_of<_ClassT, _DecayA0>::value
2312    >::type;
2313
2314template <class _Fp, class _A0,
2315         class _DecayFp = typename decay<_Fp>::type,
2316         class _DecayA0 = typename decay<_A0>::type>
2317using __enable_if_bullet2 = typename enable_if
2318    <
2319        is_member_function_pointer<_DecayFp>::value
2320        && __is_reference_wrapper<_DecayA0>::value
2321    >::type;
2322
2323template <class _Fp, class _A0,
2324         class _DecayFp = typename decay<_Fp>::type,
2325         class _DecayA0 = typename decay<_A0>::type,
2326         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
2327using __enable_if_bullet3 = typename enable_if
2328    <
2329        is_member_function_pointer<_DecayFp>::value
2330        && !is_base_of<_ClassT, _DecayA0>::value
2331        && !__is_reference_wrapper<_DecayA0>::value
2332    >::type;
2333
2334template <class _Fp, class _A0,
2335         class _DecayFp = typename decay<_Fp>::type,
2336         class _DecayA0 = typename decay<_A0>::type,
2337         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
2338using __enable_if_bullet4 = typename enable_if
2339    <
2340        is_member_object_pointer<_DecayFp>::value
2341        && is_base_of<_ClassT, _DecayA0>::value
2342    >::type;
2343
2344template <class _Fp, class _A0,
2345         class _DecayFp = typename decay<_Fp>::type,
2346         class _DecayA0 = typename decay<_A0>::type>
2347using __enable_if_bullet5 = typename enable_if
2348    <
2349        is_member_object_pointer<_DecayFp>::value
2350        && __is_reference_wrapper<_DecayA0>::value
2351    >::type;
2352
2353template <class _Fp, class _A0,
2354         class _DecayFp = typename decay<_Fp>::type,
2355         class _DecayA0 = typename decay<_A0>::type,
2356         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
2357using __enable_if_bullet6 = typename enable_if
2358    <
2359        is_member_object_pointer<_DecayFp>::value
2360        && !is_base_of<_ClassT, _DecayA0>::value
2361        && !__is_reference_wrapper<_DecayA0>::value
2362    >::type;
2363
2364// __invoke forward declarations
2365
2366// fall back - none of the bullets
2367
2368template <class ..._Args>
2369auto __invoke(__any, _Args&& ...__args) -> __nat;
2370
2371// bullets 1, 2 and 3
2372
2373template <class _Fp, class _A0, class ..._Args,
2374          class = __enable_if_bullet1<_Fp, _A0>>
2375inline _LIBCPP_INLINE_VISIBILITY
2376constexpr auto
2377__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2378    noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
2379    -> decltype(      (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
2380    { return          (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
2381
2382template <class _Fp, class _A0, class ..._Args,
2383          class = __enable_if_bullet2<_Fp, _A0>>
2384inline _LIBCPP_INLINE_VISIBILITY
2385constexpr auto
2386__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2387    noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
2388    -> decltype(      (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
2389    { return          (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
2390
2391template <class _Fp, class _A0, class ..._Args,
2392          class = __enable_if_bullet3<_Fp, _A0>>
2393inline _LIBCPP_INLINE_VISIBILITY
2394constexpr auto
2395__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
2396    noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
2397    -> decltype(      ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
2398    { return          ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
2399
2400// bullets 4, 5 and 6
2401
2402template <class _Fp, class _A0,
2403          class = __enable_if_bullet4<_Fp, _A0>>
2404inline _LIBCPP_INLINE_VISIBILITY
2405constexpr auto
2406__invoke(_Fp&& __f, _A0&& __a0)
2407    noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
2408    -> decltype(      static_cast<_A0&&>(__a0).*__f)
2409    { return          static_cast<_A0&&>(__a0).*__f; }
2410
2411template <class _Fp, class _A0,
2412          class = __enable_if_bullet5<_Fp, _A0>>
2413inline _LIBCPP_INLINE_VISIBILITY
2414constexpr auto
2415__invoke(_Fp&& __f, _A0&& __a0)
2416    noexcept(noexcept(__a0.get().*__f))
2417    -> decltype(      __a0.get().*__f)
2418    { return          __a0.get().*__f; }
2419
2420template <class _Fp, class _A0,
2421          class = __enable_if_bullet6<_Fp, _A0>>
2422inline _LIBCPP_INLINE_VISIBILITY
2423constexpr auto
2424__invoke(_Fp&& __f, _A0&& __a0)
2425    noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
2426    -> decltype(      (*static_cast<_A0&&>(__a0)).*__f)
2427    { return          (*static_cast<_A0&&>(__a0)).*__f; }
2428
2429// bullet 7
2430
2431template <class _Fp, class ..._Args>
2432inline _LIBCPP_INLINE_VISIBILITY
2433constexpr auto
2434__invoke(_Fp&& __f, _Args&& ...__args)
2435    noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
2436    -> decltype(      static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
2437    { return          static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
2438
2439// __invokable
2440template <class _Ret, class _Fp, class ..._Args>
2441struct __invokable_r
2442{
2443  template <class _XFp, class ..._XArgs>
2444  static auto __try_call(int) -> decltype(
2445    _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...));
2446  template <class _XFp, class ..._XArgs>
2447  static __nat __try_call(...);
2448
2449  // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
2450  // or incomplete array types as required by the standard.
2451  using _Result = decltype(__try_call<_Fp, _Args...>(0));
2452
2453  using type = typename conditional<
2454      _IsNotSame<_Result, __nat>::value,
2455      typename conditional< is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >::type,
2456      false_type >::type;
2457  static const bool value = type::value;
2458};
2459template <class _Fp, class ..._Args>
2460using __invokable = __invokable_r<void, _Fp, _Args...>;
2461
2462template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
2463struct __nothrow_invokable_r_imp {
2464  static const bool value = false;
2465};
2466
2467template <class _Ret, class _Fp, class ..._Args>
2468struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
2469{
2470    typedef __nothrow_invokable_r_imp _ThisT;
2471
2472    template <class _Tp>
2473    static void __test_noexcept(_Tp) noexcept;
2474
2475    static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
2476        _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
2477};
2478
2479template <class _Ret, class _Fp, class ..._Args>
2480struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
2481{
2482    static const bool value = noexcept(
2483        _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
2484};
2485
2486template <class _Ret, class _Fp, class ..._Args>
2487using __nothrow_invokable_r =
2488    __nothrow_invokable_r_imp<
2489            __invokable_r<_Ret, _Fp, _Args...>::value,
2490            is_void<_Ret>::value,
2491            _Ret, _Fp, _Args...
2492    >;
2493
2494template <class _Fp, class ..._Args>
2495using __nothrow_invokable =
2496    __nothrow_invokable_r_imp<
2497            __invokable<_Fp, _Args...>::value,
2498            true, void, _Fp, _Args...
2499    >;
2500
2501template <class _Fp, class ..._Args>
2502struct __invoke_of
2503    : public enable_if<
2504        __invokable<_Fp, _Args...>::value,
2505        typename __invokable_r<void, _Fp, _Args...>::_Result>
2506{
2507};
2508
2509#else
2510
2511// Assume that it's a functor in C++03
2512template <class _Func, class... _Args>
2513_LIBCPP_HIDE_FROM_ABI
2514decltype(std::declval<_Func>()(std::declval<_Args>()...)) __invoke(_Func&& __func, _Args&&... __args) {
2515    return static_cast<_Func&&>(__func)(static_cast<_Args&&>(__args)...);
2516}
2517
2518#endif // _LIBCPP_CXX03_LANG
2519
2520// result_of
2521
2522#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2523template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
2524
2525#ifndef _LIBCPP_CXX03_LANG
2526
2527template <class _Fp, class ..._Args>
2528class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
2529    : public __invoke_of<_Fp, _Args...>
2530{
2531};
2532
2533#else // C++03
2534
2535template <class _Fn, bool, bool>
2536class __result_of
2537{
2538};
2539
2540template <class _Fn, class ..._Args>
2541class __result_of<_Fn(_Args...), true, false>
2542{
2543public:
2544    typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
2545};
2546
2547template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
2548struct __result_of_mp;
2549
2550// member function pointer
2551
2552template <class _MP, class _Tp>
2553struct __result_of_mp<_MP, _Tp, true>
2554{
2555    using type = typename __member_pointer_traits<_MP>::_ReturnType;
2556};
2557
2558// member data pointer
2559
2560template <class _MP, class _Tp, bool>
2561struct __result_of_mdp;
2562
2563template <class _Rp, class _Class, class _Tp>
2564struct __result_of_mdp<_Rp _Class::*, _Tp, false>
2565{
2566    using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&;
2567};
2568
2569template <class _Rp, class _Class, class _Tp>
2570struct __result_of_mdp<_Rp _Class::*, _Tp, true>
2571{
2572    using type = typename __apply_cv<_Tp, _Rp>::type&;
2573};
2574
2575template <class _Rp, class _Class, class _Tp>
2576struct __result_of_mp<_Rp _Class::*, _Tp, false>
2577    : public __result_of_mdp<_Rp _Class::*, _Tp,
2578            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
2579{
2580};
2581
2582template <class _Fn, class _Tp>
2583class __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
2584    : public __result_of_mp<typename remove_reference<_Fn>::type,
2585                            _Tp,
2586                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2587{
2588};
2589
2590template <class _Fn, class _Tp, class ..._Args>
2591class __result_of<_Fn(_Tp, _Args...), false, true>  // _Fn must be member pointer
2592    : public __result_of_mp<typename remove_reference<_Fn>::type,
2593                            _Tp,
2594                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
2595{
2596};
2597
2598template <class _Fn, class ..._Args>
2599class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
2600    : public __result_of<_Fn(_Args...),
2601                         is_class<typename remove_reference<_Fn>::type>::value ||
2602                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
2603                         is_member_pointer<typename remove_reference<_Fn>::type>::value
2604                        >
2605{
2606};
2607
2608#endif // C++03
2609
2610#if _LIBCPP_STD_VER > 11
2611template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
2612#endif // _LIBCPP_STD_VER > 11
2613#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2614
2615#if _LIBCPP_STD_VER > 14
2616
2617// invoke_result
2618
2619template <class _Fn, class... _Args>
2620struct _LIBCPP_TEMPLATE_VIS invoke_result
2621    : __invoke_of<_Fn, _Args...>
2622{
2623};
2624
2625template <class _Fn, class... _Args>
2626using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
2627
2628// is_invocable
2629
2630template <class _Fn, class ..._Args>
2631struct _LIBCPP_TEMPLATE_VIS is_invocable
2632    : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
2633
2634template <class _Ret, class _Fn, class ..._Args>
2635struct _LIBCPP_TEMPLATE_VIS is_invocable_r
2636    : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
2637
2638template <class _Fn, class ..._Args>
2639inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
2640
2641template <class _Ret, class _Fn, class ..._Args>
2642inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
2643
2644// is_nothrow_invocable
2645
2646template <class _Fn, class ..._Args>
2647struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
2648    : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
2649
2650template <class _Ret, class _Fn, class ..._Args>
2651struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
2652    : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
2653
2654template <class _Fn, class ..._Args>
2655inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
2656
2657template <class _Ret, class _Fn, class ..._Args>
2658inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
2659
2660#endif // _LIBCPP_STD_VER > 14
2661
2662// __swappable
2663
2664template <class _Tp> struct __is_swappable;
2665template <class _Tp> struct __is_nothrow_swappable;
2666
2667
2668#ifndef _LIBCPP_CXX03_LANG
2669template <class _Tp>
2670using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
2671#else
2672template <class>
2673using __swap_result_t = void;
2674#endif
2675
2676template <class _Tp>
2677inline _LIBCPP_INLINE_VISIBILITY
2678_LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp>
2679swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
2680                                    is_nothrow_move_assignable<_Tp>::value);
2681
2682template<class _Tp, size_t _Np>
2683inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2684typename enable_if<
2685    __is_swappable<_Tp>::value
2686>::type
2687swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
2688
2689namespace __detail
2690{
2691// ALL generic swap overloads MUST already have a declaration available at this point.
2692
2693template <class _Tp, class _Up = _Tp,
2694          bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
2695struct __swappable_with
2696{
2697    template <class _LHS, class _RHS>
2698    static decltype(swap(declval<_LHS>(), declval<_RHS>()))
2699    __test_swap(int);
2700    template <class, class>
2701    static __nat __test_swap(long);
2702
2703    // Extra parens are needed for the C++03 definition of decltype.
2704    typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
2705    typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
2706
2707    static const bool value = _IsNotSame<__swap1, __nat>::value
2708                           && _IsNotSame<__swap2, __nat>::value;
2709};
2710
2711template <class _Tp, class _Up>
2712struct __swappable_with<_Tp, _Up,  false> : false_type {};
2713
2714template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
2715struct __nothrow_swappable_with {
2716  static const bool value =
2717#ifndef _LIBCPP_HAS_NO_NOEXCEPT
2718      noexcept(swap(declval<_Tp>(), declval<_Up>()))
2719  &&  noexcept(swap(declval<_Up>(), declval<_Tp>()));
2720#else
2721      false;
2722#endif
2723};
2724
2725template <class _Tp, class _Up>
2726struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
2727
2728} // namespace __detail
2729
2730template <class _Tp>
2731struct __is_swappable
2732    : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
2733{
2734};
2735
2736template <class _Tp>
2737struct __is_nothrow_swappable
2738    : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
2739{
2740};
2741
2742#if _LIBCPP_STD_VER > 14
2743
2744template <class _Tp, class _Up>
2745struct _LIBCPP_TEMPLATE_VIS is_swappable_with
2746    : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
2747{
2748};
2749
2750template <class _Tp>
2751struct _LIBCPP_TEMPLATE_VIS is_swappable
2752    : public conditional<
2753        __is_referenceable<_Tp>::value,
2754        is_swappable_with<
2755            typename add_lvalue_reference<_Tp>::type,
2756            typename add_lvalue_reference<_Tp>::type>,
2757        false_type
2758    >::type
2759{
2760};
2761
2762template <class _Tp, class _Up>
2763struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
2764    : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
2765{
2766};
2767
2768template <class _Tp>
2769struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
2770    : public conditional<
2771        __is_referenceable<_Tp>::value,
2772        is_nothrow_swappable_with<
2773            typename add_lvalue_reference<_Tp>::type,
2774            typename add_lvalue_reference<_Tp>::type>,
2775        false_type
2776    >::type
2777{
2778};
2779
2780template <class _Tp, class _Up>
2781inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
2782
2783template <class _Tp>
2784inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
2785
2786template <class _Tp, class _Up>
2787inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
2788
2789template <class _Tp>
2790inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
2791
2792#endif // _LIBCPP_STD_VER > 14
2793
2794template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
2795
2796template <class _Tp>
2797struct __underlying_type_impl<_Tp, false> {};
2798
2799template <class _Tp>
2800struct __underlying_type_impl<_Tp, true>
2801{
2802    typedef __underlying_type(_Tp) type;
2803};
2804
2805template <class _Tp>
2806struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
2807
2808#if _LIBCPP_STD_VER > 11
2809template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
2810#endif
2811
2812template <class _Tp, bool = is_enum<_Tp>::value>
2813struct __sfinae_underlying_type
2814{
2815    typedef typename underlying_type<_Tp>::type type;
2816    typedef decltype(((type)1) + 0) __promoted_type;
2817};
2818
2819template <class _Tp>
2820struct __sfinae_underlying_type<_Tp, false> {};
2821
2822inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2823int __convert_to_integral(int __val) { return __val; }
2824
2825inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2826unsigned __convert_to_integral(unsigned __val) { return __val; }
2827
2828inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2829long __convert_to_integral(long __val) { return __val; }
2830
2831inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2832unsigned long __convert_to_integral(unsigned long __val) { return __val; }
2833
2834inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2835long long __convert_to_integral(long long __val) { return __val; }
2836
2837inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2838unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
2839
2840template<typename _Fp>
2841inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2842typename enable_if<is_floating_point<_Fp>::value, long long>::type
2843 __convert_to_integral(_Fp __val) { return __val; }
2844
2845#ifndef _LIBCPP_HAS_NO_INT128
2846inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2847__int128_t __convert_to_integral(__int128_t __val) { return __val; }
2848
2849inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2850__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
2851#endif
2852
2853template <class _Tp>
2854inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
2855typename __sfinae_underlying_type<_Tp>::__promoted_type
2856__convert_to_integral(_Tp __val) { return __val; }
2857
2858// is_scoped_enum [meta.unary.prop]
2859
2860#if _LIBCPP_STD_VER > 20
2861template <class _Tp, bool = is_enum_v<_Tp> >
2862struct __is_scoped_enum_helper : false_type {};
2863
2864template <class _Tp>
2865struct __is_scoped_enum_helper<_Tp, true>
2866    : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
2867
2868template <class _Tp>
2869struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
2870    : public __is_scoped_enum_helper<_Tp> {};
2871
2872template <class _Tp>
2873inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
2874#endif
2875
2876#if _LIBCPP_STD_VER > 14
2877template <class _Tp>
2878struct negation : _Not<_Tp> {};
2879template<class _Tp>
2880inline constexpr bool negation_v = negation<_Tp>::value;
2881#endif // _LIBCPP_STD_VER > 14
2882
2883// These traits are used in __tree and __hash_table
2884struct __extract_key_fail_tag {};
2885struct __extract_key_self_tag {};
2886struct __extract_key_first_tag {};
2887
2888template <class _ValTy, class _Key,
2889          class _RawValTy = typename __unconstref<_ValTy>::type>
2890struct __can_extract_key
2891    : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
2892                  __extract_key_fail_tag>::type {};
2893
2894template <class _Pair, class _Key, class _First, class _Second>
2895struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
2896    : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
2897                  __extract_key_first_tag, __extract_key_fail_tag>::type {};
2898
2899// __can_extract_map_key uses true_type/false_type instead of the tags.
2900// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
2901// and _ValTy == _Key.
2902template <class _ValTy, class _Key, class _ContainerValueTy,
2903          class _RawValTy = typename __unconstref<_ValTy>::type>
2904struct __can_extract_map_key
2905    : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
2906
2907// This specialization returns __extract_key_fail_tag for non-map containers
2908// because _Key == _ContainerValueTy
2909template <class _ValTy, class _Key, class _RawValTy>
2910struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
2911    : false_type {};
2912
2913#if _LIBCPP_STD_VER > 17
2914_LIBCPP_INLINE_VISIBILITY
2915inline constexpr bool is_constant_evaluated() noexcept {
2916  return __builtin_is_constant_evaluated();
2917}
2918#endif
2919
2920inline _LIBCPP_CONSTEXPR
2921bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
2922
2923template <class _CharT>
2924using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
2925
2926template<class _Tp>
2927using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;
2928
2929#if _LIBCPP_STD_VER > 17
2930template<bool _Const, class _Tp>
2931using __maybe_const = conditional_t<_Const, const _Tp, _Tp>;
2932#endif // _LIBCPP_STD_VER > 17
2933
2934_LIBCPP_END_NAMESPACE_STD
2935
2936#endif // _LIBCPP_TYPE_TRAITS
2937