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 <__functional/invoke.h>
422#include <__type_traits/add_const.h>
423#include <__type_traits/add_cv.h>
424#include <__type_traits/add_lvalue_reference.h>
425#include <__type_traits/add_pointer.h>
426#include <__type_traits/add_rvalue_reference.h>
427#include <__type_traits/add_volatile.h>
428#include <__type_traits/alignment_of.h>
429#include <__type_traits/apply_cv.h>
430#include <__type_traits/conditional.h>
431#include <__type_traits/conjunction.h>
432#include <__type_traits/decay.h>
433#include <__type_traits/disjunction.h>
434#include <__type_traits/enable_if.h>
435#include <__type_traits/extent.h>
436#include <__type_traits/has_unique_object_representation.h>
437#include <__type_traits/has_virtual_destructor.h>
438#include <__type_traits/integral_constant.h>
439#include <__type_traits/is_abstract.h>
440#include <__type_traits/is_aggregate.h>
441#include <__type_traits/is_arithmetic.h>
442#include <__type_traits/is_array.h>
443#include <__type_traits/is_assignable.h>
444#include <__type_traits/is_base_of.h>
445#include <__type_traits/is_bounded_array.h>
446#include <__type_traits/is_callable.h>
447#include <__type_traits/is_class.h>
448#include <__type_traits/is_compound.h>
449#include <__type_traits/is_const.h>
450#include <__type_traits/is_constant_evaluated.h>
451#include <__type_traits/is_constructible.h>
452#include <__type_traits/is_convertible.h>
453#include <__type_traits/is_copy_assignable.h>
454#include <__type_traits/is_copy_constructible.h>
455#include <__type_traits/is_default_constructible.h>
456#include <__type_traits/is_destructible.h>
457#include <__type_traits/is_empty.h>
458#include <__type_traits/is_enum.h>
459#include <__type_traits/is_final.h>
460#include <__type_traits/is_floating_point.h>
461#include <__type_traits/is_function.h>
462#include <__type_traits/is_fundamental.h>
463#include <__type_traits/is_integral.h>
464#include <__type_traits/is_literal_type.h>
465#include <__type_traits/is_member_function_pointer.h>
466#include <__type_traits/is_member_object_pointer.h>
467#include <__type_traits/is_member_pointer.h>
468#include <__type_traits/is_move_assignable.h>
469#include <__type_traits/is_move_constructible.h>
470#include <__type_traits/is_nothrow_assignable.h>
471#include <__type_traits/is_nothrow_constructible.h>
472#include <__type_traits/is_nothrow_copy_assignable.h>
473#include <__type_traits/is_nothrow_copy_constructible.h>
474#include <__type_traits/is_nothrow_default_constructible.h>
475#include <__type_traits/is_nothrow_destructible.h>
476#include <__type_traits/is_nothrow_move_assignable.h>
477#include <__type_traits/is_nothrow_move_constructible.h>
478#include <__type_traits/is_null_pointer.h>
479#include <__type_traits/is_object.h>
480#include <__type_traits/is_pod.h>
481#include <__type_traits/is_pointer.h>
482#include <__type_traits/is_polymorphic.h>
483#include <__type_traits/is_reference.h>
484#include <__type_traits/is_reference_wrapper.h>
485#include <__type_traits/is_referenceable.h>
486#include <__type_traits/is_same.h>
487#include <__type_traits/is_scalar.h>
488#include <__type_traits/is_scoped_enum.h>
489#include <__type_traits/is_signed.h>
490#include <__type_traits/is_standard_layout.h>
491#include <__type_traits/is_trivial.h>
492#include <__type_traits/is_trivially_assignable.h>
493#include <__type_traits/is_trivially_constructible.h>
494#include <__type_traits/is_trivially_copy_assignable.h>
495#include <__type_traits/is_trivially_copy_constructible.h>
496#include <__type_traits/is_trivially_copyable.h>
497#include <__type_traits/is_trivially_default_constructible.h>
498#include <__type_traits/is_trivially_destructible.h>
499#include <__type_traits/is_trivially_move_assignable.h>
500#include <__type_traits/is_trivially_move_constructible.h>
501#include <__type_traits/is_unbounded_array.h>
502#include <__type_traits/is_union.h>
503#include <__type_traits/is_unsigned.h>
504#include <__type_traits/is_void.h>
505#include <__type_traits/is_volatile.h>
506#include <__type_traits/negation.h>
507#include <__type_traits/rank.h>
508#include <__type_traits/remove_all_extents.h>
509#include <__type_traits/remove_const.h>
510#include <__type_traits/remove_cv.h>
511#include <__type_traits/remove_extent.h>
512#include <__type_traits/remove_pointer.h>
513#include <__type_traits/remove_reference.h>
514#include <__type_traits/remove_volatile.h>
515#include <__type_traits/type_identity.h>
516#include <__type_traits/underlying_type.h>
517#include <__type_traits/void_t.h>
518#include <__utility/declval.h>
519#include <cstddef>
520#include <version>
521
522#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
523#  pragma GCC system_header
524#endif
525
526_LIBCPP_BEGIN_NAMESPACE_STD
527
528template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
529template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
530
531template <bool> struct _MetaBase;
532template <>
533struct _MetaBase<true> {
534  template <class _Tp, class _Up>
535  using _SelectImpl _LIBCPP_NODEBUG = _Tp;
536  template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
537  using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>;
538  template <class _First, class...>
539  using _FirstImpl _LIBCPP_NODEBUG = _First;
540  template <class, class _Second, class...>
541  using _SecondImpl _LIBCPP_NODEBUG = _Second;
542  template <class _Result, class _First, class ..._Rest>
543  using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
544};
545
546template <>
547struct _MetaBase<false> {
548  template <class _Tp, class _Up>
549  using _SelectImpl _LIBCPP_NODEBUG = _Up;
550  template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
551  using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>;
552  template <class _Result, class ...>
553  using _OrImpl _LIBCPP_NODEBUG = _Result;
554};
555template <bool _Cond, class _IfRes, class _ElseRes>
556using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
557template <class ..._Rest>
558using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
559template <class ..._Args>
560using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
561template <class ..._Args>
562using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
563
564template <class ...> using __expand_to_true = true_type;
565template <class ..._Pred>
566__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
567template <class ...>
568false_type __and_helper(...);
569template <class ..._Pred>
570using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
571
572template <template <class...> class _Func, class ..._Args>
573struct _Lazy : _Func<_Args...> {};
574
575// Member detector base
576
577template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
578true_type __sfinae_test_impl(int);
579template <template <class...> class, class ...>
580false_type __sfinae_test_impl(...);
581
582template <template <class ...> class _Templ, class ..._Args>
583using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
584
585template <class _Tp, bool>
586struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
587
588// is_same
589
590template <class _Tp>
591using __test_for_primary_template = __enable_if_t<
592    _IsSame<_Tp, typename _Tp::__primary_template>::value
593  >;
594template <class _Tp>
595using __is_primary_template = _IsValidExpansion<
596    __test_for_primary_template, _Tp
597  >;
598
599// is_integral
600
601// [basic.fundamental] defines five standard signed integer types;
602// __int128_t is an extended signed integer type.
603// The signed and unsigned integer types, plus bool and the
604// five types with "char" in their name, compose the "integral" types.
605
606template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
607template <> struct __libcpp_is_signed_integer<signed char>      : public true_type {};
608template <> struct __libcpp_is_signed_integer<signed short>     : public true_type {};
609template <> struct __libcpp_is_signed_integer<signed int>       : public true_type {};
610template <> struct __libcpp_is_signed_integer<signed long>      : public true_type {};
611template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
612#ifndef _LIBCPP_HAS_NO_INT128
613template <> struct __libcpp_is_signed_integer<__int128_t>       : public true_type {};
614#endif
615
616template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
617template <> struct __libcpp_is_unsigned_integer<unsigned char>      : public true_type {};
618template <> struct __libcpp_is_unsigned_integer<unsigned short>     : public true_type {};
619template <> struct __libcpp_is_unsigned_integer<unsigned int>       : public true_type {};
620template <> struct __libcpp_is_unsigned_integer<unsigned long>      : public true_type {};
621template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
622#ifndef _LIBCPP_HAS_NO_INT128
623template <> struct __libcpp_is_unsigned_integer<__uint128_t>        : public true_type {};
624#endif
625
626template <class _Tp>
627struct __unconstref {
628    typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
629};
630
631template <class _Tp>
632using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
633
634// __is_same_uncvref
635
636template <class _Tp, class _Up>
637struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
638
639#if _LIBCPP_STD_VER > 17
640// remove_cvref - same as __uncvref
641template <class _Tp>
642struct remove_cvref {
643    using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
644};
645
646template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
647#endif
648
649// is_nothrow_convertible
650
651#if _LIBCPP_STD_VER > 17
652
653template <typename _Tp>
654static void __test_noexcept(_Tp) noexcept;
655
656template<typename _Fm, typename _To>
657static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
658__is_nothrow_convertible_test();
659
660template <typename _Fm, typename _To>
661struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
662{ };
663
664template <typename _Fm, typename _To>
665struct is_nothrow_convertible : _Or<
666    _And<is_void<_To>, is_void<_Fm>>,
667    _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
668>::type { };
669
670template <typename _Fm, typename _To>
671inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
672
673#endif // _LIBCPP_STD_VER > 17
674
675// aligned_storage
676
677template <class _Hp, class _Tp>
678struct __type_list
679{
680    typedef _Hp _Head;
681    typedef _Tp _Tail;
682};
683
684template <class _Tp>
685struct __align_type
686{
687    static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
688    typedef _Tp type;
689};
690
691struct __struct_double {long double __lx;};
692struct __struct_double4 {double __lx[4];};
693
694typedef
695    __type_list<__align_type<unsigned char>,
696    __type_list<__align_type<unsigned short>,
697    __type_list<__align_type<unsigned int>,
698    __type_list<__align_type<unsigned long>,
699    __type_list<__align_type<unsigned long long>,
700    __type_list<__align_type<double>,
701    __type_list<__align_type<long double>,
702    __type_list<__align_type<__struct_double>,
703    __type_list<__align_type<__struct_double4>,
704    __type_list<__align_type<int*>,
705    __nat
706    > > > > > > > > > > __all_types;
707
708template <size_t _Align>
709struct _ALIGNAS(_Align) __fallback_overaligned {};
710
711template <class _TL, size_t _Align> struct __find_pod;
712
713template <class _Hp, size_t _Align>
714struct __find_pod<__type_list<_Hp, __nat>, _Align>
715{
716    typedef typename conditional<
717                             _Align == _Hp::value,
718                             typename _Hp::type,
719                             __fallback_overaligned<_Align>
720                         >::type type;
721};
722
723template <class _Hp, class _Tp, size_t _Align>
724struct __find_pod<__type_list<_Hp, _Tp>, _Align>
725{
726    typedef typename conditional<
727                             _Align == _Hp::value,
728                             typename _Hp::type,
729                             typename __find_pod<_Tp, _Align>::type
730                         >::type type;
731};
732
733template <class _TL, size_t _Len> struct __find_max_align;
734
735template <class _Hp, size_t _Len>
736struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
737
738template <size_t _Len, size_t _A1, size_t _A2>
739struct __select_align
740{
741private:
742    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
743    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
744public:
745    static const size_t value = _Len < __max ? __min : __max;
746};
747
748template <class _Hp, class _Tp, size_t _Len>
749struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
750    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
751
752template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
753struct _LIBCPP_TEMPLATE_VIS aligned_storage
754{
755    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
756    union type
757    {
758        _Aligner __align;
759        unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
760    };
761};
762
763#if _LIBCPP_STD_VER > 11
764template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
765    using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
766#endif
767
768#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
769template <size_t _Len>\
770struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
771{\
772    struct _ALIGNAS(n) type\
773    {\
774        unsigned char __lx[(_Len + n - 1)/n * n];\
775    };\
776}
777
778_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
779_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
780_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
781_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
782_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
783_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
784_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
785_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
786_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
787_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
788_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
789_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
790_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
791_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
792// PE/COFF does not support alignment beyond 8192 (=0x2000)
793#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
794_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
795#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
796
797#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
798
799
800// aligned_union
801
802template <size_t _I0, size_t ..._In>
803struct __static_max;
804
805template <size_t _I0>
806struct __static_max<_I0>
807{
808    static const size_t value = _I0;
809};
810
811template <size_t _I0, size_t _I1, size_t ..._In>
812struct __static_max<_I0, _I1, _In...>
813{
814    static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
815                                             __static_max<_I1, _In...>::value;
816};
817
818template <size_t _Len, class _Type0, class ..._Types>
819struct aligned_union
820{
821    static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
822                                                       _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
823    static const size_t __len = __static_max<_Len, sizeof(_Type0),
824                                             sizeof(_Types)...>::value;
825    typedef typename aligned_storage<__len, alignment_value>::type type;
826};
827
828#if _LIBCPP_STD_VER > 11
829template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
830#endif
831
832template <class _Tp>
833struct __numeric_type
834{
835   static void __test(...);
836   static float __test(float);
837   static double __test(char);
838   static double __test(int);
839   static double __test(unsigned);
840   static double __test(long);
841   static double __test(unsigned long);
842   static double __test(long long);
843   static double __test(unsigned long long);
844   static double __test(double);
845   static long double __test(long double);
846
847   typedef decltype(__test(declval<_Tp>())) type;
848   static const bool value = _IsNotSame<type, void>::value;
849};
850
851template <>
852struct __numeric_type<void>
853{
854   static const bool value = true;
855};
856
857// __promote
858
859template <class _A1, class _A2 = void, class _A3 = void,
860          bool = __numeric_type<_A1>::value &&
861                 __numeric_type<_A2>::value &&
862                 __numeric_type<_A3>::value>
863class __promote_imp
864{
865public:
866    static const bool value = false;
867};
868
869template <class _A1, class _A2, class _A3>
870class __promote_imp<_A1, _A2, _A3, true>
871{
872private:
873    typedef typename __promote_imp<_A1>::type __type1;
874    typedef typename __promote_imp<_A2>::type __type2;
875    typedef typename __promote_imp<_A3>::type __type3;
876public:
877    typedef decltype(__type1() + __type2() + __type3()) type;
878    static const bool value = true;
879};
880
881template <class _A1, class _A2>
882class __promote_imp<_A1, _A2, void, true>
883{
884private:
885    typedef typename __promote_imp<_A1>::type __type1;
886    typedef typename __promote_imp<_A2>::type __type2;
887public:
888    typedef decltype(__type1() + __type2()) type;
889    static const bool value = true;
890};
891
892template <class _A1>
893class __promote_imp<_A1, void, void, true>
894{
895public:
896    typedef typename __numeric_type<_A1>::type type;
897    static const bool value = true;
898};
899
900template <class _A1, class _A2 = void, class _A3 = void>
901class __promote : public __promote_imp<_A1, _A2, _A3> {};
902
903// make_signed / make_unsigned
904
905typedef
906    __type_list<signed char,
907    __type_list<signed short,
908    __type_list<signed int,
909    __type_list<signed long,
910    __type_list<signed long long,
911#ifndef _LIBCPP_HAS_NO_INT128
912    __type_list<__int128_t,
913#endif
914    __nat
915#ifndef _LIBCPP_HAS_NO_INT128
916    >
917#endif
918    > > > > > __signed_types;
919
920typedef
921    __type_list<unsigned char,
922    __type_list<unsigned short,
923    __type_list<unsigned int,
924    __type_list<unsigned long,
925    __type_list<unsigned long long,
926#ifndef _LIBCPP_HAS_NO_INT128
927    __type_list<__uint128_t,
928#endif
929    __nat
930#ifndef _LIBCPP_HAS_NO_INT128
931    >
932#endif
933    > > > > > __unsigned_types;
934
935template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
936
937template <class _Hp, class _Tp, size_t _Size>
938struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
939{
940    typedef _LIBCPP_NODEBUG _Hp type;
941};
942
943template <class _Hp, class _Tp, size_t _Size>
944struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
945{
946    typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
947};
948
949template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
950struct __make_signed {};
951
952template <class _Tp>
953struct __make_signed<_Tp, true>
954{
955    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
956};
957
958template <> struct __make_signed<bool,               true> {};
959template <> struct __make_signed<  signed short,     true> {typedef short     type;};
960template <> struct __make_signed<unsigned short,     true> {typedef short     type;};
961template <> struct __make_signed<  signed int,       true> {typedef int       type;};
962template <> struct __make_signed<unsigned int,       true> {typedef int       type;};
963template <> struct __make_signed<  signed long,      true> {typedef long      type;};
964template <> struct __make_signed<unsigned long,      true> {typedef long      type;};
965template <> struct __make_signed<  signed long long, true> {typedef long long type;};
966template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
967#ifndef _LIBCPP_HAS_NO_INT128
968template <> struct __make_signed<__int128_t,         true> {typedef __int128_t type;};
969template <> struct __make_signed<__uint128_t,        true> {typedef __int128_t type;};
970#endif
971
972template <class _Tp>
973struct _LIBCPP_TEMPLATE_VIS make_signed
974{
975    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
976};
977
978#if _LIBCPP_STD_VER > 11
979template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
980#endif
981
982template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
983struct __make_unsigned {};
984
985template <class _Tp>
986struct __make_unsigned<_Tp, true>
987{
988    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
989};
990
991template <> struct __make_unsigned<bool,               true> {};
992template <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
993template <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
994template <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
995template <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
996template <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
997template <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
998template <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
999template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
1000#ifndef _LIBCPP_HAS_NO_INT128
1001template <> struct __make_unsigned<__int128_t,         true> {typedef __uint128_t        type;};
1002template <> struct __make_unsigned<__uint128_t,        true> {typedef __uint128_t        type;};
1003#endif
1004
1005template <class _Tp>
1006struct _LIBCPP_TEMPLATE_VIS make_unsigned
1007{
1008    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
1009};
1010
1011#if _LIBCPP_STD_VER > 11
1012template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
1013#endif
1014
1015#ifndef _LIBCPP_CXX03_LANG
1016template <class _Tp>
1017_LIBCPP_HIDE_FROM_ABI constexpr
1018typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
1019    return static_cast<typename make_unsigned<_Tp>::type>(__x);
1020}
1021#endif
1022
1023#if _LIBCPP_STD_VER > 17
1024// Let COND_RES(X, Y) be:
1025template <class _Tp, class _Up>
1026using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
1027
1028template <class _Tp, class _Up, class = void>
1029struct __common_type3 {};
1030
1031// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
1032template <class _Tp, class _Up>
1033struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
1034{
1035    using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
1036};
1037
1038template <class _Tp, class _Up, class = void>
1039struct __common_type2_imp : __common_type3<_Tp, _Up> {};
1040#else
1041template <class _Tp, class _Up, class = void>
1042struct __common_type2_imp {};
1043#endif
1044
1045// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
1046template <class _Tp, class _Up>
1047struct __common_type2_imp<_Tp, _Up,
1048                          typename __void_t<decltype(
1049                                            true ? declval<_Tp>() : declval<_Up>()
1050                                            )>::type>
1051{
1052  typedef _LIBCPP_NODEBUG typename decay<decltype(
1053                         true ? declval<_Tp>() : declval<_Up>()
1054                         )>::type type;
1055};
1056
1057template <class, class = void>
1058struct __common_type_impl {};
1059
1060// Clang provides variadic templates in C++03 as an extension.
1061#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
1062# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
1063template <class... _Tp>
1064struct __common_types;
1065template <class... _Tp>
1066struct _LIBCPP_TEMPLATE_VIS common_type;
1067#else
1068# define _LIBCPP_OPTIONAL_PACK(...)
1069struct __no_arg;
1070template <class _Tp, class _Up, class = __no_arg>
1071struct __common_types;
1072template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
1073          class _Unused = __no_arg>
1074struct common_type {
1075  static_assert(sizeof(_Unused) == 0,
1076                "common_type accepts at most 3 arguments in C++03");
1077};
1078#endif // _LIBCPP_CXX03_LANG
1079
1080template <class _Tp, class _Up>
1081struct __common_type_impl<
1082    __common_types<_Tp, _Up>,
1083    typename __void_t<typename common_type<_Tp, _Up>::type>::type>
1084{
1085  typedef typename common_type<_Tp, _Up>::type type;
1086};
1087
1088template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
1089struct __common_type_impl<
1090    __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
1091    typename __void_t<typename common_type<_Tp, _Up>::type>::type>
1092    : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
1093                                        _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
1094};
1095
1096// bullet 1 - sizeof...(Tp) == 0
1097
1098template <>
1099struct _LIBCPP_TEMPLATE_VIS common_type<> {};
1100
1101// bullet 2 - sizeof...(Tp) == 1
1102
1103template <class _Tp>
1104struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
1105    : public common_type<_Tp, _Tp> {};
1106
1107// bullet 3 - sizeof...(Tp) == 2
1108
1109// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
1110template <class _Tp, class _Up>
1111struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
1112    : conditional<
1113        _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
1114        __common_type2_imp<_Tp, _Up>,
1115        common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
1116    >::type
1117{};
1118
1119// bullet 4 - sizeof...(Tp) > 2
1120
1121template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
1122struct _LIBCPP_TEMPLATE_VIS
1123    common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
1124    : __common_type_impl<
1125          __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
1126
1127#undef _LIBCPP_OPTIONAL_PACK
1128
1129#if _LIBCPP_STD_VER > 11
1130template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
1131#endif
1132
1133#if _LIBCPP_STD_VER > 11
1134// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
1135// top-level cv-qualifiers.
1136template <class _From, class _To>
1137struct __copy_cv
1138{
1139    using type = _To;
1140};
1141
1142template <class _From, class _To>
1143struct __copy_cv<const _From, _To>
1144{
1145    using type = add_const_t<_To>;
1146};
1147
1148template <class _From, class _To>
1149struct __copy_cv<volatile _From, _To>
1150{
1151    using type = add_volatile_t<_To>;
1152};
1153
1154template <class _From, class _To>
1155struct __copy_cv<const volatile _From, _To>
1156{
1157    using type = add_cv_t<_To>;
1158};
1159
1160template <class _From, class _To>
1161using __copy_cv_t = typename __copy_cv<_From, _To>::type;
1162
1163template <class _From, class _To>
1164struct __copy_cvref
1165{
1166    using type = __copy_cv_t<_From, _To>;
1167};
1168
1169template <class _From, class _To>
1170struct __copy_cvref<_From&, _To>
1171{
1172    using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>;
1173};
1174
1175template <class _From, class _To>
1176struct __copy_cvref<_From&&, _To>
1177{
1178    using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>;
1179};
1180
1181template <class _From, class _To>
1182using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
1183
1184#endif // _LIBCPP_STD_VER > 11
1185
1186// common_reference
1187#if _LIBCPP_STD_VER > 17
1188// Let COND_RES(X, Y) be:
1189template <class _Xp, class _Yp>
1190using __cond_res =
1191    decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
1192
1193// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
1194// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
1195// `U`.
1196// [Note: `XREF(A)` is `__xref<A>::template __apply`]
1197template <class _Tp>
1198struct __xref {
1199  template<class _Up>
1200  using __apply = __copy_cvref_t<_Tp, _Up>;
1201};
1202
1203// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
1204// and let COMMON-REF(A, B) be:
1205template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
1206struct __common_ref;
1207
1208template<class _Xp, class _Yp>
1209using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
1210
1211template<class _Xp, class _Yp>
1212using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
1213
1214
1215//    If A and B are both lvalue reference types, COMMON-REF(A, B) is
1216//    COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
1217template<class _Ap, class _Bp, class _Xp, class _Yp>
1218requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
1219struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
1220{
1221    using __type = __cv_cond_res<_Xp, _Yp>;
1222};
1223
1224//    Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
1225template <class _Xp, class _Yp>
1226using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
1227
1228
1229//    .... If A and B are both rvalue reference types, C is well-formed, and
1230//    is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
1231template<class _Ap, class _Bp, class _Xp, class _Yp>
1232requires
1233  requires { typename __common_ref_C<_Xp, _Yp>; } &&
1234  is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
1235  is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
1236struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
1237{
1238    using __type = __common_ref_C<_Xp, _Yp>;
1239};
1240
1241//    Otherwise, let D be COMMON-REF(const X&, Y&). ...
1242template <class _Tp, class _Up>
1243using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
1244
1245//    ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
1246//    is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
1247template<class _Ap, class _Bp, class _Xp, class _Yp>
1248requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
1249         is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
1250struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
1251{
1252    using __type = __common_ref_D<_Xp, _Yp>;
1253};
1254
1255//    Otherwise, if A is an lvalue reference and B is an rvalue reference, then
1256//    COMMON-REF(A, B) is COMMON-REF(B, A).
1257template<class _Ap, class _Bp, class _Xp, class _Yp>
1258struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
1259
1260//    Otherwise, COMMON-REF(A, B) is ill-formed.
1261template<class _Ap, class _Bp, class _Xp, class _Yp>
1262struct __common_ref {};
1263
1264// Note C: For the common_reference trait applied to a parameter pack [...]
1265
1266template <class...>
1267struct common_reference;
1268
1269template <class... _Types>
1270using common_reference_t = typename common_reference<_Types...>::type;
1271
1272// bullet 1 - sizeof...(T) == 0
1273template<>
1274struct common_reference<> {};
1275
1276// bullet 2 - sizeof...(T) == 1
1277template <class _Tp>
1278struct common_reference<_Tp>
1279{
1280    using type = _Tp;
1281};
1282
1283// bullet 3 - sizeof...(T) == 2
1284template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
1285template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
1286template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
1287
1288// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
1289// the member typedef `type` denotes that type.
1290template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
1291
1292template <class _Tp, class _Up>
1293requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
1294struct __common_reference_sub_bullet1<_Tp, _Up>
1295{
1296    using type = __common_ref_t<_Tp, _Up>;
1297};
1298
1299// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
1300// is well-formed, then the member typedef `type` denotes that type.
1301template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
1302
1303template <class _Tp, class _Up>
1304using __basic_common_reference_t = typename basic_common_reference<
1305    remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
1306    __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
1307
1308template <class _Tp, class _Up>
1309requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
1310struct __common_reference_sub_bullet2<_Tp, _Up>
1311{
1312    using type = __basic_common_reference_t<_Tp, _Up>;
1313};
1314
1315// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
1316// then the member typedef `type` denotes that type.
1317template <class _Tp, class _Up>
1318requires requires { typename __cond_res<_Tp, _Up>; }
1319struct __common_reference_sub_bullet3<_Tp, _Up>
1320{
1321    using type = __cond_res<_Tp, _Up>;
1322};
1323
1324
1325// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
1326//                    then the member typedef `type` denotes that type.
1327//                  - Otherwise, there shall be no member `type`.
1328template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
1329
1330// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
1331//            any, as `common_reference_t<C, Rest...>`.
1332template <class _Tp, class _Up, class _Vp, class... _Rest>
1333requires requires { typename common_reference_t<_Tp, _Up>; }
1334struct common_reference<_Tp, _Up, _Vp, _Rest...>
1335    : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
1336{};
1337
1338// bullet 5 - Otherwise, there shall be no member `type`.
1339template <class...> struct common_reference {};
1340
1341#endif // _LIBCPP_STD_VER > 17
1342
1343#ifndef _LIBCPP_CXX03_LANG
1344// First of all, we can't implement this check in C++03 mode because the {}
1345// default initialization syntax isn't valid.
1346// Second, we implement the trait in a funny manner with two defaulted template
1347// arguments to workaround Clang's PR43454.
1348template <class _Tp>
1349void __test_implicit_default_constructible(_Tp);
1350
1351template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
1352struct __is_implicitly_default_constructible
1353    : false_type
1354{ };
1355
1356template <class _Tp>
1357struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
1358    : true_type
1359{ };
1360
1361template <class _Tp>
1362struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
1363    : false_type
1364{ };
1365#endif // !C++03
1366
1367// result_of
1368
1369#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
1370template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
1371
1372#ifndef _LIBCPP_CXX03_LANG
1373
1374template <class _Fp, class ..._Args>
1375class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
1376    : public __invoke_of<_Fp, _Args...>
1377{
1378};
1379
1380#else // C++03
1381
1382template <class _Fn, bool, bool>
1383class __result_of
1384{
1385};
1386
1387template <class _Fn, class ..._Args>
1388class __result_of<_Fn(_Args...), true, false>
1389{
1390public:
1391    typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
1392};
1393
1394template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
1395struct __result_of_mp;
1396
1397// member function pointer
1398
1399template <class _MP, class _Tp>
1400struct __result_of_mp<_MP, _Tp, true>
1401{
1402    using type = typename __member_pointer_traits<_MP>::_ReturnType;
1403};
1404
1405// member data pointer
1406
1407template <class _MP, class _Tp, bool>
1408struct __result_of_mdp;
1409
1410template <class _Rp, class _Class, class _Tp>
1411struct __result_of_mdp<_Rp _Class::*, _Tp, false>
1412{
1413    using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&;
1414};
1415
1416template <class _Rp, class _Class, class _Tp>
1417struct __result_of_mdp<_Rp _Class::*, _Tp, true>
1418{
1419    using type = typename __apply_cv<_Tp, _Rp>::type&;
1420};
1421
1422template <class _Rp, class _Class, class _Tp>
1423struct __result_of_mp<_Rp _Class::*, _Tp, false>
1424    : public __result_of_mdp<_Rp _Class::*, _Tp,
1425            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
1426{
1427};
1428
1429template <class _Fn, class _Tp>
1430class __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
1431    : public __result_of_mp<typename remove_reference<_Fn>::type,
1432                            _Tp,
1433                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1434{
1435};
1436
1437template <class _Fn, class _Tp, class ..._Args>
1438class __result_of<_Fn(_Tp, _Args...), false, true>  // _Fn must be member pointer
1439    : public __result_of_mp<typename remove_reference<_Fn>::type,
1440                            _Tp,
1441                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
1442{
1443};
1444
1445template <class _Fn, class ..._Args>
1446class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
1447    : public __result_of<_Fn(_Args...),
1448                         is_class<typename remove_reference<_Fn>::type>::value ||
1449                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
1450                         is_member_pointer<typename remove_reference<_Fn>::type>::value
1451                        >
1452{
1453};
1454
1455#endif // C++03
1456
1457#if _LIBCPP_STD_VER > 11
1458template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
1459#endif // _LIBCPP_STD_VER > 11
1460#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
1461
1462// __swappable
1463
1464template <class _Tp> struct __is_swappable;
1465template <class _Tp> struct __is_nothrow_swappable;
1466
1467
1468#ifndef _LIBCPP_CXX03_LANG
1469template <class _Tp>
1470using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
1471#else
1472template <class>
1473using __swap_result_t = void;
1474#endif
1475
1476template <class _Tp>
1477inline _LIBCPP_INLINE_VISIBILITY
1478_LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp>
1479swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
1480                                    is_nothrow_move_assignable<_Tp>::value);
1481
1482template<class _Tp, size_t _Np>
1483inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1484typename enable_if<
1485    __is_swappable<_Tp>::value
1486>::type
1487swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
1488
1489namespace __detail
1490{
1491// ALL generic swap overloads MUST already have a declaration available at this point.
1492
1493template <class _Tp, class _Up = _Tp,
1494          bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
1495struct __swappable_with
1496{
1497    template <class _LHS, class _RHS>
1498    static decltype(swap(declval<_LHS>(), declval<_RHS>()))
1499    __test_swap(int);
1500    template <class, class>
1501    static __nat __test_swap(long);
1502
1503    // Extra parens are needed for the C++03 definition of decltype.
1504    typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
1505    typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
1506
1507    static const bool value = _IsNotSame<__swap1, __nat>::value
1508                           && _IsNotSame<__swap2, __nat>::value;
1509};
1510
1511template <class _Tp, class _Up>
1512struct __swappable_with<_Tp, _Up,  false> : false_type {};
1513
1514template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
1515struct __nothrow_swappable_with {
1516  static const bool value =
1517#ifndef _LIBCPP_HAS_NO_NOEXCEPT
1518      noexcept(swap(declval<_Tp>(), declval<_Up>()))
1519  &&  noexcept(swap(declval<_Up>(), declval<_Tp>()));
1520#else
1521      false;
1522#endif
1523};
1524
1525template <class _Tp, class _Up>
1526struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
1527
1528} // namespace __detail
1529
1530template <class _Tp>
1531struct __is_swappable
1532    : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
1533{
1534};
1535
1536template <class _Tp>
1537struct __is_nothrow_swappable
1538    : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
1539{
1540};
1541
1542#if _LIBCPP_STD_VER > 14
1543
1544template <class _Tp, class _Up>
1545struct _LIBCPP_TEMPLATE_VIS is_swappable_with
1546    : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
1547{
1548};
1549
1550template <class _Tp>
1551struct _LIBCPP_TEMPLATE_VIS is_swappable
1552    : public conditional<
1553        __is_referenceable<_Tp>::value,
1554        is_swappable_with<
1555            typename add_lvalue_reference<_Tp>::type,
1556            typename add_lvalue_reference<_Tp>::type>,
1557        false_type
1558    >::type
1559{
1560};
1561
1562template <class _Tp, class _Up>
1563struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
1564    : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
1565{
1566};
1567
1568template <class _Tp>
1569struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
1570    : public conditional<
1571        __is_referenceable<_Tp>::value,
1572        is_nothrow_swappable_with<
1573            typename add_lvalue_reference<_Tp>::type,
1574            typename add_lvalue_reference<_Tp>::type>,
1575        false_type
1576    >::type
1577{
1578};
1579
1580template <class _Tp, class _Up>
1581inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
1582
1583template <class _Tp>
1584inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
1585
1586template <class _Tp, class _Up>
1587inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
1588
1589template <class _Tp>
1590inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
1591
1592#endif // _LIBCPP_STD_VER > 14
1593
1594template <class _Tp, bool = is_enum<_Tp>::value>
1595struct __sfinae_underlying_type
1596{
1597    typedef typename underlying_type<_Tp>::type type;
1598    typedef decltype(((type)1) + 0) __promoted_type;
1599};
1600
1601template <class _Tp>
1602struct __sfinae_underlying_type<_Tp, false> {};
1603
1604inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1605int __convert_to_integral(int __val) { return __val; }
1606
1607inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1608unsigned __convert_to_integral(unsigned __val) { return __val; }
1609
1610inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1611long __convert_to_integral(long __val) { return __val; }
1612
1613inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1614unsigned long __convert_to_integral(unsigned long __val) { return __val; }
1615
1616inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1617long long __convert_to_integral(long long __val) { return __val; }
1618
1619inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1620unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
1621
1622template<typename _Fp>
1623inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1624typename enable_if<is_floating_point<_Fp>::value, long long>::type
1625 __convert_to_integral(_Fp __val) { return __val; }
1626
1627#ifndef _LIBCPP_HAS_NO_INT128
1628inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1629__int128_t __convert_to_integral(__int128_t __val) { return __val; }
1630
1631inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1632__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
1633#endif
1634
1635template <class _Tp>
1636inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1637typename __sfinae_underlying_type<_Tp>::__promoted_type
1638__convert_to_integral(_Tp __val) { return __val; }
1639
1640// These traits are used in __tree and __hash_table
1641struct __extract_key_fail_tag {};
1642struct __extract_key_self_tag {};
1643struct __extract_key_first_tag {};
1644
1645template <class _ValTy, class _Key,
1646          class _RawValTy = typename __unconstref<_ValTy>::type>
1647struct __can_extract_key
1648    : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
1649                  __extract_key_fail_tag>::type {};
1650
1651template <class _Pair, class _Key, class _First, class _Second>
1652struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
1653    : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
1654                  __extract_key_first_tag, __extract_key_fail_tag>::type {};
1655
1656// __can_extract_map_key uses true_type/false_type instead of the tags.
1657// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
1658// and _ValTy == _Key.
1659template <class _ValTy, class _Key, class _ContainerValueTy,
1660          class _RawValTy = typename __unconstref<_ValTy>::type>
1661struct __can_extract_map_key
1662    : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
1663
1664// This specialization returns __extract_key_fail_tag for non-map containers
1665// because _Key == _ContainerValueTy
1666template <class _ValTy, class _Key, class _RawValTy>
1667struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
1668    : false_type {};
1669
1670template <class _CharT>
1671using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
1672
1673template<class _Tp>
1674using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;
1675
1676#if _LIBCPP_STD_VER > 17
1677template<bool _Const, class _Tp>
1678using __maybe_const = conditional_t<_Const, const _Tp, _Tp>;
1679#endif // _LIBCPP_STD_VER > 17
1680
1681_LIBCPP_END_NAMESPACE_STD
1682
1683#endif // _LIBCPP_TYPE_TRAITS
1684