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