1 | // -*- C++ -*- |
2 | //===------------------------ type_traits ---------------------------------===// |
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_scalar; |
55 | template <class T> struct is_object; |
56 | template <class T> struct is_compound; |
57 | |
58 | // Const-volatile properties and transformations: |
59 | template <class T> struct is_const; |
60 | template <class T> struct is_volatile; |
61 | template <class T> struct remove_const; |
62 | template <class T> struct remove_volatile; |
63 | template <class T> struct remove_cv; |
64 | template <class T> struct add_const; |
65 | template <class T> struct add_volatile; |
66 | template <class T> struct add_cv; |
67 | |
68 | // Reference transformations: |
69 | template <class T> struct remove_reference; |
70 | template <class T> struct add_lvalue_reference; |
71 | template <class T> struct add_rvalue_reference; |
72 | |
73 | // Pointer transformations: |
74 | template <class T> struct remove_pointer; |
75 | template <class T> struct add_pointer; |
76 | |
77 | template<class T> struct type_identity; // C++20 |
78 | template<class T> |
79 | using type_identity_t = typename type_identity<T>::type; // C++20 |
80 | |
81 | // Integral properties: |
82 | template <class T> struct is_signed; |
83 | template <class T> struct is_unsigned; |
84 | template <class T> struct make_signed; |
85 | template <class T> struct make_unsigned; |
86 | |
87 | // Array properties and transformations: |
88 | template <class T> struct rank; |
89 | template <class T, unsigned I = 0> struct extent; |
90 | template <class T> struct remove_extent; |
91 | template <class T> struct remove_all_extents; |
92 | |
93 | template <class T> struct is_bounded_array; // C++20 |
94 | template <class T> struct is_unbounded_array; // C++20 |
95 | |
96 | // Member introspection: |
97 | template <class T> struct is_pod; |
98 | template <class T> struct is_trivial; |
99 | template <class T> struct is_trivially_copyable; |
100 | template <class T> struct is_standard_layout; |
101 | template <class T> struct is_literal_type; |
102 | template <class T> struct is_empty; |
103 | template <class T> struct is_polymorphic; |
104 | template <class T> struct is_abstract; |
105 | template <class T> struct is_final; // C++14 |
106 | template <class T> struct is_aggregate; // C++17 |
107 | |
108 | template <class T, class... Args> struct is_constructible; |
109 | template <class T> struct is_default_constructible; |
110 | template <class T> struct is_copy_constructible; |
111 | template <class T> struct is_move_constructible; |
112 | template <class T, class U> struct is_assignable; |
113 | template <class T> struct is_copy_assignable; |
114 | template <class T> struct is_move_assignable; |
115 | template <class T, class U> struct is_swappable_with; // C++17 |
116 | template <class T> struct is_swappable; // C++17 |
117 | template <class T> struct is_destructible; |
118 | |
119 | template <class T, class... Args> struct is_trivially_constructible; |
120 | template <class T> struct is_trivially_default_constructible; |
121 | template <class T> struct is_trivially_copy_constructible; |
122 | template <class T> struct is_trivially_move_constructible; |
123 | template <class T, class U> struct is_trivially_assignable; |
124 | template <class T> struct is_trivially_copy_assignable; |
125 | template <class T> struct is_trivially_move_assignable; |
126 | template <class T> struct is_trivially_destructible; |
127 | |
128 | template <class T, class... Args> struct is_nothrow_constructible; |
129 | template <class T> struct is_nothrow_default_constructible; |
130 | template <class T> struct is_nothrow_copy_constructible; |
131 | template <class T> struct is_nothrow_move_constructible; |
132 | template <class T, class U> struct is_nothrow_assignable; |
133 | template <class T> struct is_nothrow_copy_assignable; |
134 | template <class T> struct is_nothrow_move_assignable; |
135 | template <class T, class U> struct is_nothrow_swappable_with; // C++17 |
136 | template <class T> struct is_nothrow_swappable; // C++17 |
137 | template <class T> struct is_nothrow_destructible; |
138 | |
139 | template <class T> struct has_virtual_destructor; |
140 | |
141 | template<class T> struct has_unique_object_representations; // C++17 |
142 | |
143 | // Relationships between types: |
144 | template <class T, class U> struct is_same; |
145 | template <class Base, class Derived> struct is_base_of; |
146 | |
147 | template <class From, class To> struct is_convertible; |
148 | template <typename From, typename To> struct is_nothrow_convertible; // C++20 |
149 | template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20 |
150 | |
151 | template <class Fn, class... ArgTypes> struct is_invocable; |
152 | template <class R, class Fn, class... ArgTypes> struct is_invocable_r; |
153 | |
154 | template <class Fn, class... ArgTypes> struct is_nothrow_invocable; |
155 | template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r; |
156 | |
157 | // Alignment properties and transformations: |
158 | template <class T> struct alignment_of; |
159 | template <size_t Len, size_t Align = most_stringent_alignment_requirement> |
160 | struct aligned_storage; |
161 | template <size_t Len, class... Types> struct aligned_union; |
162 | template <class T> struct remove_cvref; // C++20 |
163 | |
164 | template <class T> struct decay; |
165 | template <class... T> struct common_type; |
166 | template <class T> struct underlying_type; |
167 | template <class> class result_of; // undefined |
168 | template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; |
169 | template <class Fn, class... ArgTypes> struct invoke_result; // C++17 |
170 | |
171 | // const-volatile modifications: |
172 | template <class T> |
173 | using remove_const_t = typename remove_const<T>::type; // C++14 |
174 | template <class T> |
175 | using remove_volatile_t = typename remove_volatile<T>::type; // C++14 |
176 | template <class T> |
177 | using remove_cv_t = typename remove_cv<T>::type; // C++14 |
178 | template <class T> |
179 | using add_const_t = typename add_const<T>::type; // C++14 |
180 | template <class T> |
181 | using add_volatile_t = typename add_volatile<T>::type; // C++14 |
182 | template <class T> |
183 | using add_cv_t = typename add_cv<T>::type; // C++14 |
184 | |
185 | // reference modifications: |
186 | template <class T> |
187 | using remove_reference_t = typename remove_reference<T>::type; // C++14 |
188 | template <class T> |
189 | using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 |
190 | template <class T> |
191 | using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 |
192 | |
193 | // sign modifications: |
194 | template <class T> |
195 | using make_signed_t = typename make_signed<T>::type; // C++14 |
196 | template <class T> |
197 | using make_unsigned_t = typename make_unsigned<T>::type; // C++14 |
198 | |
199 | // array modifications: |
200 | template <class T> |
201 | using remove_extent_t = typename remove_extent<T>::type; // C++14 |
202 | template <class T> |
203 | using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 |
204 | |
205 | template <class T> |
206 | inline constexpr bool is_bounded_array_v |
207 | = is_bounded_array<T>::value; // C++20 |
208 | inline constexpr bool is_unbounded_array_v |
209 | = is_unbounded_array<T>::value; // C++20 |
210 | |
211 | // pointer modifications: |
212 | template <class T> |
213 | using remove_pointer_t = typename remove_pointer<T>::type; // C++14 |
214 | template <class T> |
215 | using add_pointer_t = typename add_pointer<T>::type; // C++14 |
216 | |
217 | // other transformations: |
218 | template <size_t Len, std::size_t Align=default-alignment> |
219 | using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 |
220 | template <std::size_t Len, class... Types> |
221 | using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 |
222 | template <class T> |
223 | using remove_cvref_t = typename remove_cvref<T>::type; // C++20 |
224 | template <class T> |
225 | using decay_t = typename decay<T>::type; // C++14 |
226 | template <bool b, class T=void> |
227 | using enable_if_t = typename enable_if<b,T>::type; // C++14 |
228 | template <bool b, class T, class F> |
229 | using conditional_t = typename conditional<b,T,F>::type; // C++14 |
230 | template <class... T> |
231 | using common_type_t = typename common_type<T...>::type; // C++14 |
232 | template <class T> |
233 | using underlying_type_t = typename underlying_type<T>::type; // C++14 |
234 | template <class T> |
235 | using result_of_t = typename result_of<T>::type; // C++14 |
236 | template <class Fn, class... ArgTypes> |
237 | using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17 |
238 | |
239 | template <class...> |
240 | using void_t = void; // C++17 |
241 | |
242 | // See C++14 20.10.4.1, primary type categories |
243 | template <class T> inline constexpr bool is_void_v |
244 | = is_void<T>::value; // C++17 |
245 | template <class T> inline constexpr bool is_null_pointer_v |
246 | = is_null_pointer<T>::value; // C++17 |
247 | template <class T> inline constexpr bool is_integral_v |
248 | = is_integral<T>::value; // C++17 |
249 | template <class T> inline constexpr bool is_floating_point_v |
250 | = is_floating_point<T>::value; // C++17 |
251 | template <class T> inline constexpr bool is_array_v |
252 | = is_array<T>::value; // C++17 |
253 | template <class T> inline constexpr bool is_pointer_v |
254 | = is_pointer<T>::value; // C++17 |
255 | template <class T> inline constexpr bool is_lvalue_reference_v |
256 | = is_lvalue_reference<T>::value; // C++17 |
257 | template <class T> inline constexpr bool is_rvalue_reference_v |
258 | = is_rvalue_reference<T>::value; // C++17 |
259 | template <class T> inline constexpr bool is_member_object_pointer_v |
260 | = is_member_object_pointer<T>::value; // C++17 |
261 | template <class T> inline constexpr bool is_member_function_pointer_v |
262 | = is_member_function_pointer<T>::value; // C++17 |
263 | template <class T> inline constexpr bool is_enum_v |
264 | = is_enum<T>::value; // C++17 |
265 | template <class T> inline constexpr bool is_union_v |
266 | = is_union<T>::value; // C++17 |
267 | template <class T> inline constexpr bool is_class_v |
268 | = is_class<T>::value; // C++17 |
269 | template <class T> inline constexpr bool is_function_v |
270 | = is_function<T>::value; // C++17 |
271 | |
272 | // See C++14 20.10.4.2, composite type categories |
273 | template <class T> inline constexpr bool is_reference_v |
274 | = is_reference<T>::value; // C++17 |
275 | template <class T> inline constexpr bool is_arithmetic_v |
276 | = is_arithmetic<T>::value; // C++17 |
277 | template <class T> inline constexpr bool is_fundamental_v |
278 | = is_fundamental<T>::value; // C++17 |
279 | template <class T> inline constexpr bool is_object_v |
280 | = is_object<T>::value; // C++17 |
281 | template <class T> inline constexpr bool is_scalar_v |
282 | = is_scalar<T>::value; // C++17 |
283 | template <class T> inline constexpr bool is_compound_v |
284 | = is_compound<T>::value; // C++17 |
285 | template <class T> inline constexpr bool is_member_pointer_v |
286 | = is_member_pointer<T>::value; // C++17 |
287 | |
288 | // See C++14 20.10.4.3, type properties |
289 | template <class T> inline constexpr bool is_const_v |
290 | = is_const<T>::value; // C++17 |
291 | template <class T> inline constexpr bool is_volatile_v |
292 | = is_volatile<T>::value; // C++17 |
293 | template <class T> inline constexpr bool is_trivial_v |
294 | = is_trivial<T>::value; // C++17 |
295 | template <class T> inline constexpr bool is_trivially_copyable_v |
296 | = is_trivially_copyable<T>::value; // C++17 |
297 | template <class T> inline constexpr bool is_standard_layout_v |
298 | = is_standard_layout<T>::value; // C++17 |
299 | template <class T> inline constexpr bool is_pod_v |
300 | = is_pod<T>::value; // C++17 |
301 | template <class T> inline constexpr bool is_literal_type_v |
302 | = is_literal_type<T>::value; // C++17 |
303 | template <class T> inline constexpr bool is_empty_v |
304 | = is_empty<T>::value; // C++17 |
305 | template <class T> inline constexpr bool is_polymorphic_v |
306 | = is_polymorphic<T>::value; // C++17 |
307 | template <class T> inline constexpr bool is_abstract_v |
308 | = is_abstract<T>::value; // C++17 |
309 | template <class T> inline constexpr bool is_final_v |
310 | = is_final<T>::value; // C++17 |
311 | template <class T> inline constexpr bool is_aggregate_v |
312 | = is_aggregate<T>::value; // C++17 |
313 | template <class T> inline constexpr bool is_signed_v |
314 | = is_signed<T>::value; // C++17 |
315 | template <class T> inline constexpr bool is_unsigned_v |
316 | = is_unsigned<T>::value; // C++17 |
317 | template <class T, class... Args> inline constexpr bool is_constructible_v |
318 | = is_constructible<T, Args...>::value; // C++17 |
319 | template <class T> inline constexpr bool is_default_constructible_v |
320 | = is_default_constructible<T>::value; // C++17 |
321 | template <class T> inline constexpr bool is_copy_constructible_v |
322 | = is_copy_constructible<T>::value; // C++17 |
323 | template <class T> inline constexpr bool is_move_constructible_v |
324 | = is_move_constructible<T>::value; // C++17 |
325 | template <class T, class U> inline constexpr bool is_assignable_v |
326 | = is_assignable<T, U>::value; // C++17 |
327 | template <class T> inline constexpr bool is_copy_assignable_v |
328 | = is_copy_assignable<T>::value; // C++17 |
329 | template <class T> inline constexpr bool is_move_assignable_v |
330 | = is_move_assignable<T>::value; // C++17 |
331 | template <class T, class U> inline constexpr bool is_swappable_with_v |
332 | = is_swappable_with<T, U>::value; // C++17 |
333 | template <class T> inline constexpr bool is_swappable_v |
334 | = is_swappable<T>::value; // C++17 |
335 | template <class T> inline constexpr bool is_destructible_v |
336 | = is_destructible<T>::value; // C++17 |
337 | template <class T, class... Args> inline constexpr bool is_trivially_constructible_v |
338 | = is_trivially_constructible<T, Args...>::value; // C++17 |
339 | template <class T> inline constexpr bool is_trivially_default_constructible_v |
340 | = is_trivially_default_constructible<T>::value; // C++17 |
341 | template <class T> inline constexpr bool is_trivially_copy_constructible_v |
342 | = is_trivially_copy_constructible<T>::value; // C++17 |
343 | template <class T> inline constexpr bool is_trivially_move_constructible_v |
344 | = is_trivially_move_constructible<T>::value; // C++17 |
345 | template <class T, class U> inline constexpr bool is_trivially_assignable_v |
346 | = is_trivially_assignable<T, U>::value; // C++17 |
347 | template <class T> inline constexpr bool is_trivially_copy_assignable_v |
348 | = is_trivially_copy_assignable<T>::value; // C++17 |
349 | template <class T> inline constexpr bool is_trivially_move_assignable_v |
350 | = is_trivially_move_assignable<T>::value; // C++17 |
351 | template <class T> inline constexpr bool is_trivially_destructible_v |
352 | = is_trivially_destructible<T>::value; // C++17 |
353 | template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v |
354 | = is_nothrow_constructible<T, Args...>::value; // C++17 |
355 | template <class T> inline constexpr bool is_nothrow_default_constructible_v |
356 | = is_nothrow_default_constructible<T>::value; // C++17 |
357 | template <class T> inline constexpr bool is_nothrow_copy_constructible_v |
358 | = is_nothrow_copy_constructible<T>::value; // C++17 |
359 | template <class T> inline constexpr bool is_nothrow_move_constructible_v |
360 | = is_nothrow_move_constructible<T>::value; // C++17 |
361 | template <class T, class U> inline constexpr bool is_nothrow_assignable_v |
362 | = is_nothrow_assignable<T, U>::value; // C++17 |
363 | template <class T> inline constexpr bool is_nothrow_copy_assignable_v |
364 | = is_nothrow_copy_assignable<T>::value; // C++17 |
365 | template <class T> inline constexpr bool is_nothrow_move_assignable_v |
366 | = is_nothrow_move_assignable<T>::value; // C++17 |
367 | template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v |
368 | = is_nothrow_swappable_with<T, U>::value; // C++17 |
369 | template <class T> inline constexpr bool is_nothrow_swappable_v |
370 | = is_nothrow_swappable<T>::value; // C++17 |
371 | template <class T> inline constexpr bool is_nothrow_destructible_v |
372 | = is_nothrow_destructible<T>::value; // C++17 |
373 | template <class T> inline constexpr bool has_virtual_destructor_v |
374 | = has_virtual_destructor<T>::value; // C++17 |
375 | template<class T> inline constexpr bool has_unique_object_representations_v // C++17 |
376 | = has_unique_object_representations<T>::value; |
377 | |
378 | // See C++14 20.10.5, type property queries |
379 | template <class T> inline constexpr size_t alignment_of_v |
380 | = alignment_of<T>::value; // C++17 |
381 | template <class T> inline constexpr size_t rank_v |
382 | = rank<T>::value; // C++17 |
383 | template <class T, unsigned I = 0> inline constexpr size_t extent_v |
384 | = extent<T, I>::value; // C++17 |
385 | |
386 | // See C++14 20.10.6, type relations |
387 | template <class T, class U> inline constexpr bool is_same_v |
388 | = is_same<T, U>::value; // C++17 |
389 | template <class Base, class Derived> inline constexpr bool is_base_of_v |
390 | = is_base_of<Base, Derived>::value; // C++17 |
391 | template <class From, class To> inline constexpr bool is_convertible_v |
392 | = is_convertible<From, To>::value; // C++17 |
393 | template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v |
394 | = is_invocable<Fn, ArgTypes...>::value; // C++17 |
395 | template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v |
396 | = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17 |
397 | template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v |
398 | = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17 |
399 | template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v |
400 | = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17 |
401 | |
402 | // [meta.logical], logical operator traits: |
403 | template<class... B> struct conjunction; // C++17 |
404 | template<class... B> |
405 | inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17 |
406 | template<class... B> struct disjunction; // C++17 |
407 | template<class... B> |
408 | inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17 |
409 | template<class B> struct negation; // C++17 |
410 | template<class B> |
411 | inline constexpr bool negation_v = negation<B>::value; // C++17 |
412 | |
413 | } |
414 | |
415 | */ |
416 | #include <__config> |
417 | #include <cstddef> |
418 | #include <version> |
419 | |
420 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
421 | #pragma GCC system_header |
422 | #endif |
423 | |
424 | _LIBCPP_BEGIN_NAMESPACE_STD |
425 | |
426 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair; |
427 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper; |
428 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; |
429 | |
430 | |
431 | template <class _Tp, _Tp __v> |
432 | struct _LIBCPP_TEMPLATE_VIS integral_constant |
433 | { |
434 | static _LIBCPP_CONSTEXPR const _Tp value = __v; |
435 | typedef _Tp value_type; |
436 | typedef integral_constant type; |
437 | _LIBCPP_INLINE_VISIBILITY |
438 | _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} |
439 | #if _LIBCPP_STD_VER > 11 |
440 | _LIBCPP_INLINE_VISIBILITY |
441 | constexpr value_type operator ()() const _NOEXCEPT {return value;} |
442 | #endif |
443 | }; |
444 | |
445 | template <class _Tp, _Tp __v> |
446 | _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; |
447 | |
448 | #if _LIBCPP_STD_VER > 14 |
449 | template <bool __b> |
450 | using bool_constant = integral_constant<bool, __b>; |
451 | #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> |
452 | #else |
453 | #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> |
454 | #endif |
455 | |
456 | typedef _LIBCPP_BOOL_CONSTANT(true) true_type; |
457 | typedef _LIBCPP_BOOL_CONSTANT(false) false_type; |
458 | |
459 | template <bool _Val> |
460 | using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>; |
461 | |
462 | template <bool> struct _MetaBase; |
463 | template <> |
464 | struct _MetaBase<true> { |
465 | template <class _Tp, class _Up> |
466 | using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Tp; |
467 | template <template <class...> class _FirstFn, template <class...> class, class ..._Args> |
468 | using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _FirstFn<_Args...>; |
469 | template <class _First, class...> |
470 | using _FirstImpl _LIBCPP_NODEBUG_TYPE = _First; |
471 | template <class, class _Second, class...> |
472 | using _SecondImpl _LIBCPP_NODEBUG_TYPE = _Second; |
473 | template <class _Tp = void> |
474 | using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp; |
475 | template <class _Result, class _First, class ..._Rest> |
476 | using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>; |
477 | template <class _Result, class _First, class ..._Rest> |
478 | using _AndImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>; |
479 | }; |
480 | |
481 | template <> |
482 | struct _MetaBase<false> { |
483 | template <class _Tp, class _Up> |
484 | using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Up; |
485 | template <template <class...> class, template <class...> class _SecondFn, class ..._Args> |
486 | using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>; |
487 | template <class _Result, class ...> |
488 | using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result; |
489 | template <class _Result, class ...> |
490 | using _AndImpl _LIBCPP_NODEBUG_TYPE = _Result; |
491 | }; |
492 | template <bool _Cond, class _Ret = void> |
493 | using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>; |
494 | template <bool _Cond, class _IfRes, class _ElseRes> |
495 | using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>; |
496 | template <class ..._Rest> |
497 | using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>; |
498 | template <class ..._Rest> |
499 | using _And _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _AndImpl<true_type, _Rest...>; |
500 | template <class _Pred> |
501 | struct _Not : _BoolConstant<!_Pred::value> {}; |
502 | template <class ..._Args> |
503 | using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>; |
504 | template <class ..._Args> |
505 | using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>; |
506 | |
507 | template <template <class...> class _Func, class ..._Args> |
508 | struct _Lazy : _Func<_Args...> {}; |
509 | |
510 | // Member detector base |
511 | |
512 | template <template <class...> class _Templ, class ..._Args> |
513 | true_type __sfinae_test_impl(_FirstType<int, _Templ<_Args...> >); |
514 | template <template <class...> class, class ...> |
515 | false_type __sfinae_test_impl(...); |
516 | |
517 | template <template <class ...> class _Templ, class ..._Args> |
518 | using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0)); |
519 | |
520 | template <class> |
521 | struct __void_t { typedef void type; }; |
522 | |
523 | template <class _Tp> |
524 | struct __identity { typedef _Tp type; }; |
525 | |
526 | template <class _Tp, bool> |
527 | struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; |
528 | |
529 | template <bool _Bp, class _If, class _Then> |
530 | struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; |
531 | template <class _If, class _Then> |
532 | struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;}; |
533 | |
534 | #if _LIBCPP_STD_VER > 11 |
535 | template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; |
536 | #endif |
537 | |
538 | template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {}; |
539 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;}; |
540 | |
541 | #if _LIBCPP_STD_VER > 11 |
542 | template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; |
543 | #endif |
544 | |
545 | // is_same |
546 | |
547 | template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; |
548 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; |
549 | |
550 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
551 | template <class _Tp, class _Up> |
552 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v |
553 | = is_same<_Tp, _Up>::value; |
554 | #endif |
555 | |
556 | template <class _Tp, class _Up> |
557 | using _IsSame = _BoolConstant< |
558 | #ifdef __clang__ |
559 | __is_same(_Tp, _Up) |
560 | #else |
561 | _VSTD::is_same<_Tp, _Up>::value |
562 | #endif |
563 | >; |
564 | |
565 | template <class _Tp, class _Up> |
566 | using _IsNotSame = _BoolConstant< |
567 | #ifdef __clang__ |
568 | !__is_same(_Tp, _Up) |
569 | #else |
570 | !_VSTD::is_same<_Tp, _Up>::value |
571 | #endif |
572 | >; |
573 | // addressof |
574 | #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF |
575 | |
576 | template <class _Tp> |
577 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 |
578 | _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY |
579 | _Tp* |
580 | addressof(_Tp& __x) _NOEXCEPT |
581 | { |
582 | return __builtin_addressof(__x); |
583 | } |
584 | |
585 | #else |
586 | |
587 | template <class _Tp> |
588 | inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY |
589 | _Tp* |
590 | addressof(_Tp& __x) _NOEXCEPT |
591 | { |
592 | return reinterpret_cast<_Tp *>( |
593 | const_cast<char *>(&reinterpret_cast<const volatile char &>(__x))); |
594 | } |
595 | |
596 | #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF |
597 | |
598 | #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) |
599 | // Objective-C++ Automatic Reference Counting uses qualified pointers |
600 | // that require special addressof() signatures. When |
601 | // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler |
602 | // itself is providing these definitions. Otherwise, we provide them. |
603 | template <class _Tp> |
604 | inline _LIBCPP_INLINE_VISIBILITY |
605 | __strong _Tp* |
606 | addressof(__strong _Tp& __x) _NOEXCEPT |
607 | { |
608 | return &__x; |
609 | } |
610 | |
611 | #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK |
612 | template <class _Tp> |
613 | inline _LIBCPP_INLINE_VISIBILITY |
614 | __weak _Tp* |
615 | addressof(__weak _Tp& __x) _NOEXCEPT |
616 | { |
617 | return &__x; |
618 | } |
619 | #endif |
620 | |
621 | template <class _Tp> |
622 | inline _LIBCPP_INLINE_VISIBILITY |
623 | __autoreleasing _Tp* |
624 | addressof(__autoreleasing _Tp& __x) _NOEXCEPT |
625 | { |
626 | return &__x; |
627 | } |
628 | |
629 | template <class _Tp> |
630 | inline _LIBCPP_INLINE_VISIBILITY |
631 | __unsafe_unretained _Tp* |
632 | addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT |
633 | { |
634 | return &__x; |
635 | } |
636 | #endif |
637 | |
638 | #if !defined(_LIBCPP_CXX03_LANG) |
639 | template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete; |
640 | #endif |
641 | |
642 | struct __two {char __lx[2];}; |
643 | |
644 | // helper class: |
645 | |
646 | // is_const |
647 | |
648 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; |
649 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; |
650 | |
651 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
652 | template <class _Tp> |
653 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v |
654 | = is_const<_Tp>::value; |
655 | #endif |
656 | |
657 | // is_volatile |
658 | |
659 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; |
660 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; |
661 | |
662 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
663 | template <class _Tp> |
664 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v |
665 | = is_volatile<_Tp>::value; |
666 | #endif |
667 | |
668 | // remove_const |
669 | |
670 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; |
671 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; |
672 | #if _LIBCPP_STD_VER > 11 |
673 | template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; |
674 | #endif |
675 | |
676 | // remove_volatile |
677 | |
678 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; |
679 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; |
680 | #if _LIBCPP_STD_VER > 11 |
681 | template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; |
682 | #endif |
683 | |
684 | // remove_cv |
685 | |
686 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv |
687 | {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; |
688 | #if _LIBCPP_STD_VER > 11 |
689 | template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; |
690 | #endif |
691 | |
692 | // is_void |
693 | |
694 | template <class _Tp> struct __libcpp_is_void : public false_type {}; |
695 | template <> struct __libcpp_is_void<void> : public true_type {}; |
696 | |
697 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void |
698 | : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; |
699 | |
700 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
701 | template <class _Tp> |
702 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v |
703 | = is_void<_Tp>::value; |
704 | #endif |
705 | |
706 | // __is_nullptr_t |
707 | |
708 | template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; |
709 | template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; |
710 | |
711 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t |
712 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; |
713 | |
714 | #if _LIBCPP_STD_VER > 11 |
715 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer |
716 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; |
717 | |
718 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
719 | template <class _Tp> |
720 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v |
721 | = is_null_pointer<_Tp>::value; |
722 | #endif |
723 | #endif |
724 | |
725 | // is_integral |
726 | |
727 | template <class _Tp> struct __libcpp_is_integral : public false_type {}; |
728 | template <> struct __libcpp_is_integral<bool> : public true_type {}; |
729 | template <> struct __libcpp_is_integral<char> : public true_type {}; |
730 | template <> struct __libcpp_is_integral<signed char> : public true_type {}; |
731 | template <> struct __libcpp_is_integral<unsigned char> : public true_type {}; |
732 | template <> struct __libcpp_is_integral<wchar_t> : public true_type {}; |
733 | #ifndef _LIBCPP_NO_HAS_CHAR8_T |
734 | template <> struct __libcpp_is_integral<char8_t> : public true_type {}; |
735 | #endif |
736 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
737 | template <> struct __libcpp_is_integral<char16_t> : public true_type {}; |
738 | template <> struct __libcpp_is_integral<char32_t> : public true_type {}; |
739 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS |
740 | template <> struct __libcpp_is_integral<short> : public true_type {}; |
741 | template <> struct __libcpp_is_integral<unsigned short> : public true_type {}; |
742 | template <> struct __libcpp_is_integral<int> : public true_type {}; |
743 | template <> struct __libcpp_is_integral<unsigned int> : public true_type {}; |
744 | template <> struct __libcpp_is_integral<long> : public true_type {}; |
745 | template <> struct __libcpp_is_integral<unsigned long> : public true_type {}; |
746 | template <> struct __libcpp_is_integral<long long> : public true_type {}; |
747 | template <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; |
748 | #ifndef _LIBCPP_HAS_NO_INT128 |
749 | template <> struct __libcpp_is_integral<__int128_t> : public true_type {}; |
750 | template <> struct __libcpp_is_integral<__uint128_t> : public true_type {}; |
751 | #endif |
752 | |
753 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral |
754 | : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; |
755 | |
756 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
757 | template <class _Tp> |
758 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v |
759 | = is_integral<_Tp>::value; |
760 | #endif |
761 | |
762 | // is_floating_point |
763 | |
764 | template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; |
765 | template <> struct __libcpp_is_floating_point<float> : public true_type {}; |
766 | template <> struct __libcpp_is_floating_point<double> : public true_type {}; |
767 | template <> struct __libcpp_is_floating_point<long double> : public true_type {}; |
768 | |
769 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point |
770 | : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; |
771 | |
772 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
773 | template <class _Tp> |
774 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v |
775 | = is_floating_point<_Tp>::value; |
776 | #endif |
777 | |
778 | // is_array |
779 | |
780 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array |
781 | : public false_type {}; |
782 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> |
783 | : public true_type {}; |
784 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> |
785 | : public true_type {}; |
786 | |
787 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
788 | template <class _Tp> |
789 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v |
790 | = is_array<_Tp>::value; |
791 | #endif |
792 | |
793 | // is_pointer |
794 | |
795 | template <class _Tp> struct __libcpp_is_pointer : public false_type {}; |
796 | template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; |
797 | |
798 | template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; |
799 | #if defined(_LIBCPP_HAS_OBJC_ARC) |
800 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; |
801 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; |
802 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; |
803 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; |
804 | #endif |
805 | |
806 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer |
807 | : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {}; |
808 | |
809 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
810 | template <class _Tp> |
811 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v |
812 | = is_pointer<_Tp>::value; |
813 | #endif |
814 | |
815 | // is_reference |
816 | |
817 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; |
818 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; |
819 | |
820 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; |
821 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; |
822 | |
823 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; |
824 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; |
825 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; |
826 | |
827 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
828 | template <class _Tp> |
829 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v |
830 | = is_reference<_Tp>::value; |
831 | |
832 | template <class _Tp> |
833 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v |
834 | = is_lvalue_reference<_Tp>::value; |
835 | |
836 | template <class _Tp> |
837 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v |
838 | = is_rvalue_reference<_Tp>::value; |
839 | #endif |
840 | // is_union |
841 | |
842 | #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) |
843 | |
844 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union |
845 | : public integral_constant<bool, __is_union(_Tp)> {}; |
846 | |
847 | #else |
848 | |
849 | template <class _Tp> struct __libcpp_union : public false_type {}; |
850 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union |
851 | : public __libcpp_union<typename remove_cv<_Tp>::type> {}; |
852 | |
853 | #endif |
854 | |
855 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
856 | template <class _Tp> |
857 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v |
858 | = is_union<_Tp>::value; |
859 | #endif |
860 | |
861 | // is_class |
862 | |
863 | #if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC) |
864 | |
865 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class |
866 | : public integral_constant<bool, __is_class(_Tp)> {}; |
867 | |
868 | #else |
869 | |
870 | namespace __is_class_imp |
871 | { |
872 | template <class _Tp> char __test(int _Tp::*); |
873 | template <class _Tp> __two __test(...); |
874 | } |
875 | |
876 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class |
877 | : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; |
878 | |
879 | #endif |
880 | |
881 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
882 | template <class _Tp> |
883 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v |
884 | = is_class<_Tp>::value; |
885 | #endif |
886 | |
887 | // is_function |
888 | |
889 | namespace __libcpp_is_function_imp |
890 | { |
891 | struct __dummy_type {}; |
892 | template <class _Tp> char __test(_Tp*); |
893 | template <class _Tp> char __test(__dummy_type); |
894 | template <class _Tp> __two __test(...); |
895 | template <class _Tp> _Tp& __source(int); |
896 | template <class _Tp> __dummy_type __source(...); |
897 | } |
898 | |
899 | template <class _Tp, bool = is_class<_Tp>::value || |
900 | is_union<_Tp>::value || |
901 | is_void<_Tp>::value || |
902 | is_reference<_Tp>::value || |
903 | __is_nullptr_t<_Tp>::value > |
904 | struct __libcpp_is_function |
905 | : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1> |
906 | {}; |
907 | template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {}; |
908 | |
909 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function |
910 | : public __libcpp_is_function<_Tp> {}; |
911 | |
912 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
913 | template <class _Tp> |
914 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v |
915 | = is_function<_Tp>::value; |
916 | #endif |
917 | |
918 | // is_member_function_pointer |
919 | |
920 | // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {}; |
921 | // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; |
922 | // |
923 | |
924 | template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> |
925 | struct __member_pointer_traits_imp |
926 | { // forward declaration; specializations later |
927 | }; |
928 | |
929 | |
930 | template <class _Tp> struct __libcpp_is_member_function_pointer |
931 | : public false_type {}; |
932 | |
933 | template <class _Ret, class _Class> |
934 | struct __libcpp_is_member_function_pointer<_Ret _Class::*> |
935 | : public is_function<_Ret> {}; |
936 | |
937 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer |
938 | : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {}; |
939 | |
940 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
941 | template <class _Tp> |
942 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v |
943 | = is_member_function_pointer<_Tp>::value; |
944 | #endif |
945 | |
946 | // is_member_pointer |
947 | |
948 | template <class _Tp> struct __libcpp_is_member_pointer : public false_type {}; |
949 | template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; |
950 | |
951 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer |
952 | : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {}; |
953 | |
954 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
955 | template <class _Tp> |
956 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v |
957 | = is_member_pointer<_Tp>::value; |
958 | #endif |
959 | |
960 | // is_member_object_pointer |
961 | |
962 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer |
963 | : public integral_constant<bool, is_member_pointer<_Tp>::value && |
964 | !is_member_function_pointer<_Tp>::value> {}; |
965 | |
966 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
967 | template <class _Tp> |
968 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v |
969 | = is_member_object_pointer<_Tp>::value; |
970 | #endif |
971 | |
972 | // is_enum |
973 | |
974 | #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) |
975 | |
976 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
977 | : public integral_constant<bool, __is_enum(_Tp)> {}; |
978 | |
979 | #else |
980 | |
981 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
982 | : public integral_constant<bool, !is_void<_Tp>::value && |
983 | !is_integral<_Tp>::value && |
984 | !is_floating_point<_Tp>::value && |
985 | !is_array<_Tp>::value && |
986 | !is_pointer<_Tp>::value && |
987 | !is_reference<_Tp>::value && |
988 | !is_member_pointer<_Tp>::value && |
989 | !is_union<_Tp>::value && |
990 | !is_class<_Tp>::value && |
991 | !is_function<_Tp>::value > {}; |
992 | |
993 | #endif |
994 | |
995 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
996 | template <class _Tp> |
997 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v |
998 | = is_enum<_Tp>::value; |
999 | #endif |
1000 | |
1001 | // is_arithmetic |
1002 | |
1003 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic |
1004 | : public integral_constant<bool, is_integral<_Tp>::value || |
1005 | is_floating_point<_Tp>::value> {}; |
1006 | |
1007 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1008 | template <class _Tp> |
1009 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v |
1010 | = is_arithmetic<_Tp>::value; |
1011 | #endif |
1012 | |
1013 | // is_fundamental |
1014 | |
1015 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental |
1016 | : public integral_constant<bool, is_void<_Tp>::value || |
1017 | __is_nullptr_t<_Tp>::value || |
1018 | is_arithmetic<_Tp>::value> {}; |
1019 | |
1020 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1021 | template <class _Tp> |
1022 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v |
1023 | = is_fundamental<_Tp>::value; |
1024 | #endif |
1025 | |
1026 | // is_scalar |
1027 | |
1028 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar |
1029 | : public integral_constant<bool, is_arithmetic<_Tp>::value || |
1030 | is_member_pointer<_Tp>::value || |
1031 | is_pointer<_Tp>::value || |
1032 | __is_nullptr_t<_Tp>::value || |
1033 | is_enum<_Tp>::value > {}; |
1034 | |
1035 | template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; |
1036 | |
1037 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1038 | template <class _Tp> |
1039 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v |
1040 | = is_scalar<_Tp>::value; |
1041 | #endif |
1042 | |
1043 | // is_object |
1044 | |
1045 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object |
1046 | : public integral_constant<bool, is_scalar<_Tp>::value || |
1047 | is_array<_Tp>::value || |
1048 | is_union<_Tp>::value || |
1049 | is_class<_Tp>::value > {}; |
1050 | |
1051 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1052 | template <class _Tp> |
1053 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v |
1054 | = is_object<_Tp>::value; |
1055 | #endif |
1056 | |
1057 | // is_compound |
1058 | |
1059 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound |
1060 | : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; |
1061 | |
1062 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1063 | template <class _Tp> |
1064 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v |
1065 | = is_compound<_Tp>::value; |
1066 | #endif |
1067 | |
1068 | |
1069 | // __is_referenceable [defns.referenceable] |
1070 | |
1071 | struct __is_referenceable_impl { |
1072 | template <class _Tp> static _Tp& __test(int); |
1073 | template <class _Tp> static __two __test(...); |
1074 | }; |
1075 | |
1076 | template <class _Tp> |
1077 | struct __is_referenceable : integral_constant<bool, |
1078 | _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {}; |
1079 | |
1080 | |
1081 | // add_const |
1082 | |
1083 | template <class _Tp, bool = is_reference<_Tp>::value || |
1084 | is_function<_Tp>::value || |
1085 | is_const<_Tp>::value > |
1086 | struct __add_const {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1087 | |
1088 | template <class _Tp> |
1089 | struct __add_const<_Tp, false> {typedef _LIBCPP_NODEBUG_TYPE const _Tp type;}; |
1090 | |
1091 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const |
1092 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_const<_Tp>::type type;}; |
1093 | |
1094 | #if _LIBCPP_STD_VER > 11 |
1095 | template <class _Tp> using add_const_t = typename add_const<_Tp>::type; |
1096 | #endif |
1097 | |
1098 | // add_volatile |
1099 | |
1100 | template <class _Tp, bool = is_reference<_Tp>::value || |
1101 | is_function<_Tp>::value || |
1102 | is_volatile<_Tp>::value > |
1103 | struct __add_volatile {typedef _Tp type;}; |
1104 | |
1105 | template <class _Tp> |
1106 | struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; |
1107 | |
1108 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile |
1109 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_volatile<_Tp>::type type;}; |
1110 | |
1111 | #if _LIBCPP_STD_VER > 11 |
1112 | template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; |
1113 | #endif |
1114 | |
1115 | // add_cv |
1116 | |
1117 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv |
1118 | {typedef _LIBCPP_NODEBUG_TYPE typename add_const<typename add_volatile<_Tp>::type>::type type;}; |
1119 | |
1120 | #if _LIBCPP_STD_VER > 11 |
1121 | template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; |
1122 | #endif |
1123 | |
1124 | // remove_reference |
1125 | |
1126 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1127 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1128 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1129 | |
1130 | #if _LIBCPP_STD_VER > 11 |
1131 | template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; |
1132 | #endif |
1133 | |
1134 | // add_lvalue_reference |
1135 | |
1136 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; |
1137 | template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; |
1138 | |
1139 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference |
1140 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_lvalue_reference_impl<_Tp>::type type;}; |
1141 | |
1142 | #if _LIBCPP_STD_VER > 11 |
1143 | template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; |
1144 | #endif |
1145 | |
1146 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; |
1147 | template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; }; |
1148 | |
1149 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference |
1150 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_rvalue_reference_impl<_Tp>::type type;}; |
1151 | |
1152 | #if _LIBCPP_STD_VER > 11 |
1153 | template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; |
1154 | #endif |
1155 | |
1156 | template <class _Tp> _Tp&& __declval(int); |
1157 | template <class _Tp> _Tp __declval(long); |
1158 | |
1159 | template <class _Tp> |
1160 | decltype(_VSTD::__declval<_Tp>(0)) |
1161 | declval() _NOEXCEPT; |
1162 | |
1163 | // __uncvref |
1164 | |
1165 | template <class _Tp> |
1166 | struct __uncvref { |
1167 | typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<typename remove_reference<_Tp>::type>::type type; |
1168 | }; |
1169 | |
1170 | template <class _Tp> |
1171 | struct __unconstref { |
1172 | typedef _LIBCPP_NODEBUG_TYPE typename remove_const<typename remove_reference<_Tp>::type>::type type; |
1173 | }; |
1174 | |
1175 | #ifndef _LIBCPP_CXX03_LANG |
1176 | template <class _Tp> |
1177 | using __uncvref_t _LIBCPP_NODEBUG_TYPE = typename __uncvref<_Tp>::type; |
1178 | #endif |
1179 | |
1180 | // __is_same_uncvref |
1181 | |
1182 | template <class _Tp, class _Up> |
1183 | struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type, |
1184 | typename __uncvref<_Up>::type> {}; |
1185 | |
1186 | #if _LIBCPP_STD_VER > 17 |
1187 | // remove_cvref - same as __uncvref |
1188 | template <class _Tp> |
1189 | struct remove_cvref : public __uncvref<_Tp> {}; |
1190 | |
1191 | template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; |
1192 | #endif |
1193 | |
1194 | |
1195 | struct __any |
1196 | { |
1197 | __any(...); |
1198 | }; |
1199 | |
1200 | // remove_pointer |
1201 | |
1202 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1203 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1204 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1205 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1206 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1207 | |
1208 | #if _LIBCPP_STD_VER > 11 |
1209 | template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; |
1210 | #endif |
1211 | |
1212 | // add_pointer |
1213 | |
1214 | template <class _Tp, |
1215 | bool = __is_referenceable<_Tp>::value || |
1216 | _IsSame<typename remove_cv<_Tp>::type, void>::value> |
1217 | struct __add_pointer_impl |
1218 | {typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type* type;}; |
1219 | template <class _Tp> struct __add_pointer_impl<_Tp, false> |
1220 | {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; |
1221 | |
1222 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer |
1223 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_pointer_impl<_Tp>::type type;}; |
1224 | |
1225 | #if _LIBCPP_STD_VER > 11 |
1226 | template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; |
1227 | #endif |
1228 | |
1229 | // type_identity |
1230 | #if _LIBCPP_STD_VER > 17 |
1231 | template<class _Tp> struct type_identity { typedef _Tp type; }; |
1232 | template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; |
1233 | #endif |
1234 | |
1235 | // is_signed |
1236 | |
1237 | template <class _Tp, bool = is_integral<_Tp>::value> |
1238 | struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; |
1239 | |
1240 | template <class _Tp> |
1241 | struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point |
1242 | |
1243 | template <class _Tp, bool = is_arithmetic<_Tp>::value> |
1244 | struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; |
1245 | |
1246 | template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; |
1247 | |
1248 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; |
1249 | |
1250 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1251 | template <class _Tp> |
1252 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v |
1253 | = is_signed<_Tp>::value; |
1254 | #endif |
1255 | |
1256 | // is_unsigned |
1257 | |
1258 | template <class _Tp, bool = is_integral<_Tp>::value> |
1259 | struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; |
1260 | |
1261 | template <class _Tp> |
1262 | struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point |
1263 | |
1264 | template <class _Tp, bool = is_arithmetic<_Tp>::value> |
1265 | struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; |
1266 | |
1267 | template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; |
1268 | |
1269 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; |
1270 | |
1271 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1272 | template <class _Tp> |
1273 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v |
1274 | = is_unsigned<_Tp>::value; |
1275 | #endif |
1276 | |
1277 | // rank |
1278 | |
1279 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank |
1280 | : public integral_constant<size_t, 0> {}; |
1281 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> |
1282 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
1283 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> |
1284 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
1285 | |
1286 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1287 | template <class _Tp> |
1288 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v |
1289 | = rank<_Tp>::value; |
1290 | #endif |
1291 | |
1292 | // extent |
1293 | |
1294 | template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent |
1295 | : public integral_constant<size_t, 0> {}; |
1296 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> |
1297 | : public integral_constant<size_t, 0> {}; |
1298 | template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> |
1299 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; |
1300 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> |
1301 | : public integral_constant<size_t, _Np> {}; |
1302 | template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> |
1303 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; |
1304 | |
1305 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1306 | template <class _Tp, unsigned _Ip = 0> |
1307 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v |
1308 | = extent<_Tp, _Ip>::value; |
1309 | #endif |
1310 | |
1311 | // remove_extent |
1312 | |
1313 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent |
1314 | {typedef _Tp type;}; |
1315 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> |
1316 | {typedef _Tp type;}; |
1317 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> |
1318 | {typedef _Tp type;}; |
1319 | |
1320 | #if _LIBCPP_STD_VER > 11 |
1321 | template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; |
1322 | #endif |
1323 | |
1324 | // remove_all_extents |
1325 | |
1326 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents |
1327 | {typedef _Tp type;}; |
1328 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> |
1329 | {typedef typename remove_all_extents<_Tp>::type type;}; |
1330 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> |
1331 | {typedef typename remove_all_extents<_Tp>::type type;}; |
1332 | |
1333 | #if _LIBCPP_STD_VER > 11 |
1334 | template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; |
1335 | #endif |
1336 | |
1337 | #if _LIBCPP_STD_VER > 17 |
1338 | // is_bounded_array |
1339 | |
1340 | template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; |
1341 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; |
1342 | |
1343 | template <class _Tp> |
1344 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR |
1345 | bool is_bounded_array_v = is_bounded_array<_Tp>::value; |
1346 | |
1347 | // is_unbounded_array |
1348 | |
1349 | template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; |
1350 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; |
1351 | |
1352 | template <class _Tp> |
1353 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR |
1354 | bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; |
1355 | #endif |
1356 | |
1357 | // decay |
1358 | |
1359 | template <class _Up, bool> |
1360 | struct __decay { |
1361 | typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<_Up>::type type; |
1362 | }; |
1363 | |
1364 | template <class _Up> |
1365 | struct __decay<_Up, true> { |
1366 | public: |
1367 | typedef _LIBCPP_NODEBUG_TYPE typename conditional |
1368 | < |
1369 | is_array<_Up>::value, |
1370 | typename remove_extent<_Up>::type*, |
1371 | typename conditional |
1372 | < |
1373 | is_function<_Up>::value, |
1374 | typename add_pointer<_Up>::type, |
1375 | typename remove_cv<_Up>::type |
1376 | >::type |
1377 | >::type type; |
1378 | }; |
1379 | |
1380 | template <class _Tp> |
1381 | struct _LIBCPP_TEMPLATE_VIS decay |
1382 | { |
1383 | private: |
1384 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up; |
1385 | public: |
1386 | typedef _LIBCPP_NODEBUG_TYPE typename __decay<_Up, __is_referenceable<_Up>::value>::type type; |
1387 | }; |
1388 | |
1389 | #if _LIBCPP_STD_VER > 11 |
1390 | template <class _Tp> using decay_t = typename decay<_Tp>::type; |
1391 | #endif |
1392 | |
1393 | // is_abstract |
1394 | |
1395 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract |
1396 | : public integral_constant<bool, __is_abstract(_Tp)> {}; |
1397 | |
1398 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1399 | template <class _Tp> |
1400 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v |
1401 | = is_abstract<_Tp>::value; |
1402 | #endif |
1403 | |
1404 | // is_final |
1405 | |
1406 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
1407 | __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {}; |
1408 | |
1409 | #if _LIBCPP_STD_VER > 11 |
1410 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
1411 | is_final : public integral_constant<bool, __is_final(_Tp)> {}; |
1412 | #endif |
1413 | |
1414 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1415 | template <class _Tp> |
1416 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v |
1417 | = is_final<_Tp>::value; |
1418 | #endif |
1419 | |
1420 | // is_aggregate |
1421 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) |
1422 | |
1423 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
1424 | is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; |
1425 | |
1426 | #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1427 | template <class _Tp> |
1428 | _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v |
1429 | = is_aggregate<_Tp>::value; |
1430 | #endif |
1431 | |
1432 | #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) |
1433 | |
1434 | // is_base_of |
1435 | |
1436 | template <class _Bp, class _Dp> |
1437 | struct _LIBCPP_TEMPLATE_VIS is_base_of |
1438 | : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; |
1439 | |
1440 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1441 | template <class _Bp, class _Dp> |
1442 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v |
1443 | = is_base_of<_Bp, _Dp>::value; |
1444 | #endif |
1445 | |
1446 | // is_convertible |
1447 | |
1448 | #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) |
1449 | |
1450 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible |
1451 | : public integral_constant<bool, __is_convertible_to(_T1, _T2) && |
1452 | !is_abstract<_T2>::value> {}; |
1453 | |
1454 | #else // __has_feature(is_convertible_to) |
1455 | |
1456 | namespace __is_convertible_imp |
1457 | { |
1458 | template <class _Tp> void __test_convert(_Tp); |
1459 | |
1460 | template <class _From, class _To, class = void> |
1461 | struct __is_convertible_test : public false_type {}; |
1462 | |
1463 | template <class _From, class _To> |
1464 | struct __is_convertible_test<_From, _To, |
1465 | decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type |
1466 | {}; |
1467 | |
1468 | template <class _Tp, bool _IsArray = is_array<_Tp>::value, |
1469 | bool _IsFunction = is_function<_Tp>::value, |
1470 | bool _IsVoid = is_void<_Tp>::value> |
1471 | struct __is_array_function_or_void {enum {value = 0};}; |
1472 | template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; |
1473 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; |
1474 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; |
1475 | } |
1476 | |
1477 | template <class _Tp, |
1478 | unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> |
1479 | struct __is_convertible_check |
1480 | { |
1481 | static const size_t __v = 0; |
1482 | }; |
1483 | |
1484 | template <class _Tp> |
1485 | struct __is_convertible_check<_Tp, 0> |
1486 | { |
1487 | static const size_t __v = sizeof(_Tp); |
1488 | }; |
1489 | |
1490 | template <class _T1, class _T2, |
1491 | unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, |
1492 | unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> |
1493 | struct __is_convertible |
1494 | : public integral_constant<bool, |
1495 | __is_convertible_imp::__is_convertible_test<_T1, _T2>::value |
1496 | > |
1497 | {}; |
1498 | |
1499 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; |
1500 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; |
1501 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; |
1502 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; |
1503 | |
1504 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; |
1505 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; |
1506 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; |
1507 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; |
1508 | |
1509 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; |
1510 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; |
1511 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; |
1512 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; |
1513 | |
1514 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible |
1515 | : public __is_convertible<_T1, _T2> |
1516 | { |
1517 | static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; |
1518 | static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; |
1519 | }; |
1520 | |
1521 | #endif // __has_feature(is_convertible_to) |
1522 | |
1523 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1524 | template <class _From, class _To> |
1525 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v |
1526 | = is_convertible<_From, _To>::value; |
1527 | #endif |
1528 | |
1529 | // is_nothrow_convertible |
1530 | |
1531 | #if _LIBCPP_STD_VER > 17 |
1532 | |
1533 | template <typename _Tp> |
1534 | static void __test_noexcept(_Tp) noexcept; |
1535 | |
1536 | template<typename _Fm, typename _To> |
1537 | static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))> |
1538 | __is_nothrow_convertible_test(); |
1539 | |
1540 | template <typename _Fm, typename _To> |
1541 | struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) |
1542 | { }; |
1543 | |
1544 | template <typename _Fm, typename _To> |
1545 | struct is_nothrow_convertible : _Or< |
1546 | _And<is_void<_To>, is_void<_Fm>>, |
1547 | _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> |
1548 | >::type { }; |
1549 | |
1550 | template <typename _Fm, typename _To> |
1551 | inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; |
1552 | |
1553 | #endif // _LIBCPP_STD_VER > 17 |
1554 | |
1555 | // is_empty |
1556 | |
1557 | #if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC) |
1558 | |
1559 | template <class _Tp> |
1560 | struct _LIBCPP_TEMPLATE_VIS is_empty |
1561 | : public integral_constant<bool, __is_empty(_Tp)> {}; |
1562 | |
1563 | #else // __has_feature(is_empty) |
1564 | |
1565 | template <class _Tp> |
1566 | struct __is_empty1 |
1567 | : public _Tp |
1568 | { |
1569 | double __lx; |
1570 | }; |
1571 | |
1572 | struct __is_empty2 |
1573 | { |
1574 | double __lx; |
1575 | }; |
1576 | |
1577 | template <class _Tp, bool = is_class<_Tp>::value> |
1578 | struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; |
1579 | |
1580 | template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; |
1581 | |
1582 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {}; |
1583 | |
1584 | #endif // __has_feature(is_empty) |
1585 | |
1586 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1587 | template <class _Tp> |
1588 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v |
1589 | = is_empty<_Tp>::value; |
1590 | #endif |
1591 | |
1592 | // is_polymorphic |
1593 | |
1594 | #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC) |
1595 | |
1596 | template <class _Tp> |
1597 | struct _LIBCPP_TEMPLATE_VIS is_polymorphic |
1598 | : public integral_constant<bool, __is_polymorphic(_Tp)> {}; |
1599 | |
1600 | #else |
1601 | |
1602 | template<typename _Tp> char &__is_polymorphic_impl( |
1603 | typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, |
1604 | int>::type); |
1605 | template<typename _Tp> __two &__is_polymorphic_impl(...); |
1606 | |
1607 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic |
1608 | : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; |
1609 | |
1610 | #endif // __has_feature(is_polymorphic) |
1611 | |
1612 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1613 | template <class _Tp> |
1614 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v |
1615 | = is_polymorphic<_Tp>::value; |
1616 | #endif |
1617 | |
1618 | // has_virtual_destructor |
1619 | |
1620 | #if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC) |
1621 | |
1622 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor |
1623 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; |
1624 | |
1625 | #else |
1626 | |
1627 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor |
1628 | : public false_type {}; |
1629 | |
1630 | #endif |
1631 | |
1632 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1633 | template <class _Tp> |
1634 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v |
1635 | = has_virtual_destructor<_Tp>::value; |
1636 | #endif |
1637 | |
1638 | // has_unique_object_representations |
1639 | |
1640 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) |
1641 | |
1642 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations |
1643 | : public integral_constant<bool, |
1644 | __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; |
1645 | |
1646 | #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1647 | template <class _Tp> |
1648 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v |
1649 | = has_unique_object_representations<_Tp>::value; |
1650 | #endif |
1651 | |
1652 | #endif |
1653 | |
1654 | // alignment_of |
1655 | |
1656 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of |
1657 | : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; |
1658 | |
1659 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1660 | template <class _Tp> |
1661 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v |
1662 | = alignment_of<_Tp>::value; |
1663 | #endif |
1664 | |
1665 | // aligned_storage |
1666 | |
1667 | template <class _Hp, class _Tp> |
1668 | struct __type_list |
1669 | { |
1670 | typedef _Hp _Head; |
1671 | typedef _Tp _Tail; |
1672 | }; |
1673 | |
1674 | struct __nat |
1675 | { |
1676 | #ifndef _LIBCPP_CXX03_LANG |
1677 | __nat() = delete; |
1678 | __nat(const __nat&) = delete; |
1679 | __nat& operator=(const __nat&) = delete; |
1680 | ~__nat() = delete; |
1681 | #endif |
1682 | }; |
1683 | |
1684 | template <class _Tp> |
1685 | struct __align_type |
1686 | { |
1687 | static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); |
1688 | typedef _Tp type; |
1689 | }; |
1690 | |
1691 | struct __struct_double {long double __lx;}; |
1692 | struct __struct_double4 {double __lx[4];}; |
1693 | |
1694 | typedef |
1695 | __type_list<__align_type<unsigned char>, |
1696 | __type_list<__align_type<unsigned short>, |
1697 | __type_list<__align_type<unsigned int>, |
1698 | __type_list<__align_type<unsigned long>, |
1699 | __type_list<__align_type<unsigned long long>, |
1700 | __type_list<__align_type<double>, |
1701 | __type_list<__align_type<long double>, |
1702 | __type_list<__align_type<__struct_double>, |
1703 | __type_list<__align_type<__struct_double4>, |
1704 | __type_list<__align_type<int*>, |
1705 | __nat |
1706 | > > > > > > > > > > __all_types; |
1707 | |
1708 | template <size_t _Align> |
1709 | struct _ALIGNAS(_Align) __fallback_overaligned {}; |
1710 | |
1711 | template <class _TL, size_t _Align> struct __find_pod; |
1712 | |
1713 | template <class _Hp, size_t _Align> |
1714 | struct __find_pod<__type_list<_Hp, __nat>, _Align> |
1715 | { |
1716 | typedef typename conditional< |
1717 | _Align == _Hp::value, |
1718 | typename _Hp::type, |
1719 | __fallback_overaligned<_Align> |
1720 | >::type type; |
1721 | }; |
1722 | |
1723 | template <class _Hp, class _Tp, size_t _Align> |
1724 | struct __find_pod<__type_list<_Hp, _Tp>, _Align> |
1725 | { |
1726 | typedef typename conditional< |
1727 | _Align == _Hp::value, |
1728 | typename _Hp::type, |
1729 | typename __find_pod<_Tp, _Align>::type |
1730 | >::type type; |
1731 | }; |
1732 | |
1733 | template <class _TL, size_t _Len> struct __find_max_align; |
1734 | |
1735 | template <class _Hp, size_t _Len> |
1736 | struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; |
1737 | |
1738 | template <size_t _Len, size_t _A1, size_t _A2> |
1739 | struct __select_align |
1740 | { |
1741 | private: |
1742 | static const size_t __min = _A2 < _A1 ? _A2 : _A1; |
1743 | static const size_t __max = _A1 < _A2 ? _A2 : _A1; |
1744 | public: |
1745 | static const size_t value = _Len < __max ? __min : __max; |
1746 | }; |
1747 | |
1748 | template <class _Hp, class _Tp, size_t _Len> |
1749 | struct __find_max_align<__type_list<_Hp, _Tp>, _Len> |
1750 | : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; |
1751 | |
1752 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
1753 | struct _LIBCPP_TEMPLATE_VIS aligned_storage |
1754 | { |
1755 | typedef typename __find_pod<__all_types, _Align>::type _Aligner; |
1756 | union type |
1757 | { |
1758 | _Aligner __align; |
1759 | unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; |
1760 | }; |
1761 | }; |
1762 | |
1763 | #if _LIBCPP_STD_VER > 11 |
1764 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
1765 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; |
1766 | #endif |
1767 | |
1768 | #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ |
1769 | template <size_t _Len>\ |
1770 | struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ |
1771 | {\ |
1772 | struct _ALIGNAS(n) type\ |
1773 | {\ |
1774 | unsigned char __lx[(_Len + n - 1)/n * n];\ |
1775 | };\ |
1776 | } |
1777 | |
1778 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); |
1779 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); |
1780 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); |
1781 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); |
1782 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); |
1783 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); |
1784 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); |
1785 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); |
1786 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); |
1787 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); |
1788 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); |
1789 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); |
1790 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); |
1791 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); |
1792 | // PE/COFF does not support alignment beyond 8192 (=0x2000) |
1793 | #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
1794 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); |
1795 | #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
1796 | |
1797 | #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION |
1798 | |
1799 | |
1800 | // aligned_union |
1801 | |
1802 | template <size_t _I0, size_t ..._In> |
1803 | struct __static_max; |
1804 | |
1805 | template <size_t _I0> |
1806 | struct __static_max<_I0> |
1807 | { |
1808 | static const size_t value = _I0; |
1809 | }; |
1810 | |
1811 | template <size_t _I0, size_t _I1, size_t ..._In> |
1812 | struct __static_max<_I0, _I1, _In...> |
1813 | { |
1814 | static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : |
1815 | __static_max<_I1, _In...>::value; |
1816 | }; |
1817 | |
1818 | template <size_t _Len, class _Type0, class ..._Types> |
1819 | struct aligned_union |
1820 | { |
1821 | static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), |
1822 | _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; |
1823 | static const size_t __len = __static_max<_Len, sizeof(_Type0), |
1824 | sizeof(_Types)...>::value; |
1825 | typedef typename aligned_storage<__len, alignment_value>::type type; |
1826 | }; |
1827 | |
1828 | #if _LIBCPP_STD_VER > 11 |
1829 | template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; |
1830 | #endif |
1831 | |
1832 | template <class _Tp> |
1833 | struct __numeric_type |
1834 | { |
1835 | static void __test(...); |
1836 | static float __test(float); |
1837 | static double __test(char); |
1838 | static double __test(int); |
1839 | static double __test(unsigned); |
1840 | static double __test(long); |
1841 | static double __test(unsigned long); |
1842 | static double __test(long long); |
1843 | static double __test(unsigned long long); |
1844 | static double __test(double); |
1845 | static long double __test(long double); |
1846 | |
1847 | typedef decltype(__test(declval<_Tp>())) type; |
1848 | static const bool value = _IsNotSame<type, void>::value; |
1849 | }; |
1850 | |
1851 | template <> |
1852 | struct __numeric_type<void> |
1853 | { |
1854 | static const bool value = true; |
1855 | }; |
1856 | |
1857 | // __promote |
1858 | |
1859 | template <class _A1, class _A2 = void, class _A3 = void, |
1860 | bool = __numeric_type<_A1>::value && |
1861 | __numeric_type<_A2>::value && |
1862 | __numeric_type<_A3>::value> |
1863 | class __promote_imp |
1864 | { |
1865 | public: |
1866 | static const bool value = false; |
1867 | }; |
1868 | |
1869 | template <class _A1, class _A2, class _A3> |
1870 | class __promote_imp<_A1, _A2, _A3, true> |
1871 | { |
1872 | private: |
1873 | typedef typename __promote_imp<_A1>::type __type1; |
1874 | typedef typename __promote_imp<_A2>::type __type2; |
1875 | typedef typename __promote_imp<_A3>::type __type3; |
1876 | public: |
1877 | typedef decltype(__type1() + __type2() + __type3()) type; |
1878 | static const bool value = true; |
1879 | }; |
1880 | |
1881 | template <class _A1, class _A2> |
1882 | class __promote_imp<_A1, _A2, void, true> |
1883 | { |
1884 | private: |
1885 | typedef typename __promote_imp<_A1>::type __type1; |
1886 | typedef typename __promote_imp<_A2>::type __type2; |
1887 | public: |
1888 | typedef decltype(__type1() + __type2()) type; |
1889 | static const bool value = true; |
1890 | }; |
1891 | |
1892 | template <class _A1> |
1893 | class __promote_imp<_A1, void, void, true> |
1894 | { |
1895 | public: |
1896 | typedef typename __numeric_type<_A1>::type type; |
1897 | static const bool value = true; |
1898 | }; |
1899 | |
1900 | template <class _A1, class _A2 = void, class _A3 = void> |
1901 | class __promote : public __promote_imp<_A1, _A2, _A3> {}; |
1902 | |
1903 | // make_signed / make_unsigned |
1904 | |
1905 | typedef |
1906 | __type_list<signed char, |
1907 | __type_list<signed short, |
1908 | __type_list<signed int, |
1909 | __type_list<signed long, |
1910 | __type_list<signed long long, |
1911 | #ifndef _LIBCPP_HAS_NO_INT128 |
1912 | __type_list<__int128_t, |
1913 | #endif |
1914 | __nat |
1915 | #ifndef _LIBCPP_HAS_NO_INT128 |
1916 | > |
1917 | #endif |
1918 | > > > > > __signed_types; |
1919 | |
1920 | typedef |
1921 | __type_list<unsigned char, |
1922 | __type_list<unsigned short, |
1923 | __type_list<unsigned int, |
1924 | __type_list<unsigned long, |
1925 | __type_list<unsigned long long, |
1926 | #ifndef _LIBCPP_HAS_NO_INT128 |
1927 | __type_list<__uint128_t, |
1928 | #endif |
1929 | __nat |
1930 | #ifndef _LIBCPP_HAS_NO_INT128 |
1931 | > |
1932 | #endif |
1933 | > > > > > __unsigned_types; |
1934 | |
1935 | template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; |
1936 | |
1937 | template <class _Hp, class _Tp, size_t _Size> |
1938 | struct __find_first<__type_list<_Hp, _Tp>, _Size, true> |
1939 | { |
1940 | typedef _LIBCPP_NODEBUG_TYPE _Hp type; |
1941 | }; |
1942 | |
1943 | template <class _Hp, class _Tp, size_t _Size> |
1944 | struct __find_first<__type_list<_Hp, _Tp>, _Size, false> |
1945 | { |
1946 | typedef _LIBCPP_NODEBUG_TYPE typename __find_first<_Tp, _Size>::type type; |
1947 | }; |
1948 | |
1949 | template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, |
1950 | bool = is_volatile<typename remove_reference<_Tp>::type>::value> |
1951 | struct __apply_cv |
1952 | { |
1953 | typedef _LIBCPP_NODEBUG_TYPE _Up type; |
1954 | }; |
1955 | |
1956 | template <class _Tp, class _Up> |
1957 | struct __apply_cv<_Tp, _Up, true, false> |
1958 | { |
1959 | typedef _LIBCPP_NODEBUG_TYPE const _Up type; |
1960 | }; |
1961 | |
1962 | template <class _Tp, class _Up> |
1963 | struct __apply_cv<_Tp, _Up, false, true> |
1964 | { |
1965 | typedef volatile _Up type; |
1966 | }; |
1967 | |
1968 | template <class _Tp, class _Up> |
1969 | struct __apply_cv<_Tp, _Up, true, true> |
1970 | { |
1971 | typedef const volatile _Up type; |
1972 | }; |
1973 | |
1974 | template <class _Tp, class _Up> |
1975 | struct __apply_cv<_Tp&, _Up, false, false> |
1976 | { |
1977 | typedef _Up& type; |
1978 | }; |
1979 | |
1980 | template <class _Tp, class _Up> |
1981 | struct __apply_cv<_Tp&, _Up, true, false> |
1982 | { |
1983 | typedef const _Up& type; |
1984 | }; |
1985 | |
1986 | template <class _Tp, class _Up> |
1987 | struct __apply_cv<_Tp&, _Up, false, true> |
1988 | { |
1989 | typedef volatile _Up& type; |
1990 | }; |
1991 | |
1992 | template <class _Tp, class _Up> |
1993 | struct __apply_cv<_Tp&, _Up, true, true> |
1994 | { |
1995 | typedef const volatile _Up& type; |
1996 | }; |
1997 | |
1998 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
1999 | struct __make_signed {}; |
2000 | |
2001 | template <class _Tp> |
2002 | struct __make_signed<_Tp, true> |
2003 | { |
2004 | typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; |
2005 | }; |
2006 | |
2007 | template <> struct __make_signed<bool, true> {}; |
2008 | template <> struct __make_signed< signed short, true> {typedef short type;}; |
2009 | template <> struct __make_signed<unsigned short, true> {typedef short type;}; |
2010 | template <> struct __make_signed< signed int, true> {typedef int type;}; |
2011 | template <> struct __make_signed<unsigned int, true> {typedef int type;}; |
2012 | template <> struct __make_signed< signed long, true> {typedef long type;}; |
2013 | template <> struct __make_signed<unsigned long, true> {typedef long type;}; |
2014 | template <> struct __make_signed< signed long long, true> {typedef long long type;}; |
2015 | template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; |
2016 | #ifndef _LIBCPP_HAS_NO_INT128 |
2017 | template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; |
2018 | template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; |
2019 | #endif |
2020 | |
2021 | template <class _Tp> |
2022 | struct _LIBCPP_TEMPLATE_VIS make_signed |
2023 | { |
2024 | typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; |
2025 | }; |
2026 | |
2027 | #if _LIBCPP_STD_VER > 11 |
2028 | template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; |
2029 | #endif |
2030 | |
2031 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
2032 | struct __make_unsigned {}; |
2033 | |
2034 | template <class _Tp> |
2035 | struct __make_unsigned<_Tp, true> |
2036 | { |
2037 | typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; |
2038 | }; |
2039 | |
2040 | template <> struct __make_unsigned<bool, true> {}; |
2041 | template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; |
2042 | template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; |
2043 | template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; |
2044 | template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; |
2045 | template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; |
2046 | template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; |
2047 | template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; |
2048 | template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; |
2049 | #ifndef _LIBCPP_HAS_NO_INT128 |
2050 | template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; |
2051 | template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; |
2052 | #endif |
2053 | |
2054 | template <class _Tp> |
2055 | struct _LIBCPP_TEMPLATE_VIS make_unsigned |
2056 | { |
2057 | typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; |
2058 | }; |
2059 | |
2060 | #if _LIBCPP_STD_VER > 11 |
2061 | template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; |
2062 | #endif |
2063 | |
2064 | template <class _Tp, class _Up, class = void> |
2065 | struct __common_type2_imp {}; |
2066 | |
2067 | template <class _Tp, class _Up> |
2068 | struct __common_type2_imp<_Tp, _Up, |
2069 | typename __void_t<decltype( |
2070 | true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() |
2071 | )>::type> |
2072 | { |
2073 | typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype( |
2074 | true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() |
2075 | )>::type type; |
2076 | }; |
2077 | |
2078 | template <class, class = void> |
2079 | struct __common_type_impl {}; |
2080 | |
2081 | // Clang provides variadic templates in C++03 as an extension. |
2082 | #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) |
2083 | # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ |
2084 | template <class... Tp> |
2085 | struct __common_types; |
2086 | template <class... _Tp> |
2087 | struct _LIBCPP_TEMPLATE_VIS common_type; |
2088 | #else |
2089 | # define _LIBCPP_OPTIONAL_PACK(...) |
2090 | struct __no_arg; |
2091 | template <class _Tp, class _Up, class = __no_arg> |
2092 | struct __common_types; |
2093 | template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, |
2094 | class _Unused = __no_arg> |
2095 | struct common_type { |
2096 | static_assert(sizeof(_Unused) == 0, |
2097 | "common_type accepts at most 3 arguments in C++03" ); |
2098 | }; |
2099 | #endif // _LIBCPP_CXX03_LANG |
2100 | |
2101 | template <class _Tp, class _Up> |
2102 | struct __common_type_impl< |
2103 | __common_types<_Tp, _Up>, |
2104 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> |
2105 | { |
2106 | typedef typename common_type<_Tp, _Up>::type type; |
2107 | }; |
2108 | |
2109 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> |
2110 | struct __common_type_impl< |
2111 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, |
2112 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> |
2113 | : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, |
2114 | _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { |
2115 | }; |
2116 | |
2117 | // bullet 1 - sizeof...(Tp) == 0 |
2118 | |
2119 | template <> |
2120 | struct _LIBCPP_TEMPLATE_VIS common_type<> {}; |
2121 | |
2122 | // bullet 2 - sizeof...(Tp) == 1 |
2123 | |
2124 | template <class _Tp> |
2125 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> |
2126 | : public common_type<_Tp, _Tp> {}; |
2127 | |
2128 | // bullet 3 - sizeof...(Tp) == 2 |
2129 | |
2130 | template <class _Tp, class _Up> |
2131 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> |
2132 | : conditional< |
2133 | _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value, |
2134 | __common_type2_imp<_Tp, _Up>, |
2135 | common_type<typename decay<_Tp>::type, typename decay<_Up>::type> |
2136 | >::type |
2137 | {}; |
2138 | |
2139 | // bullet 4 - sizeof...(Tp) > 2 |
2140 | |
2141 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> |
2142 | struct _LIBCPP_TEMPLATE_VIS |
2143 | common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> |
2144 | : __common_type_impl< |
2145 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; |
2146 | |
2147 | #undef _LIBCPP_OPTIONAL_PACK |
2148 | |
2149 | #if _LIBCPP_STD_VER > 11 |
2150 | template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; |
2151 | #endif |
2152 | |
2153 | // is_assignable |
2154 | |
2155 | template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; |
2156 | |
2157 | template <class _Tp, class _Arg> |
2158 | typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type |
2159 | __is_assignable_test(int); |
2160 | |
2161 | template <class, class> |
2162 | false_type __is_assignable_test(...); |
2163 | |
2164 | |
2165 | template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> |
2166 | struct __is_assignable_imp |
2167 | : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {}; |
2168 | |
2169 | template <class _Tp, class _Arg> |
2170 | struct __is_assignable_imp<_Tp, _Arg, true> |
2171 | : public false_type |
2172 | { |
2173 | }; |
2174 | |
2175 | template <class _Tp, class _Arg> |
2176 | struct is_assignable |
2177 | : public __is_assignable_imp<_Tp, _Arg> {}; |
2178 | |
2179 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2180 | template <class _Tp, class _Arg> |
2181 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v |
2182 | = is_assignable<_Tp, _Arg>::value; |
2183 | #endif |
2184 | |
2185 | // is_copy_assignable |
2186 | |
2187 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable |
2188 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, |
2189 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
2190 | |
2191 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2192 | template <class _Tp> |
2193 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v |
2194 | = is_copy_assignable<_Tp>::value; |
2195 | #endif |
2196 | |
2197 | // is_move_assignable |
2198 | |
2199 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable |
2200 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, |
2201 | typename add_rvalue_reference<_Tp>::type> {}; |
2202 | |
2203 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2204 | template <class _Tp> |
2205 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v |
2206 | = is_move_assignable<_Tp>::value; |
2207 | #endif |
2208 | |
2209 | // is_destructible |
2210 | |
2211 | // if it's a reference, return true |
2212 | // if it's a function, return false |
2213 | // if it's void, return false |
2214 | // if it's an array of unknown bound, return false |
2215 | // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed |
2216 | // where _Up is remove_all_extents<_Tp>::type |
2217 | |
2218 | template <class> |
2219 | struct __is_destructible_apply { typedef int type; }; |
2220 | |
2221 | template <typename _Tp> |
2222 | struct __is_destructor_wellformed { |
2223 | template <typename _Tp1> |
2224 | static char __test ( |
2225 | typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type |
2226 | ); |
2227 | |
2228 | template <typename _Tp1> |
2229 | static __two __test (...); |
2230 | |
2231 | static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); |
2232 | }; |
2233 | |
2234 | template <class _Tp, bool> |
2235 | struct __destructible_imp; |
2236 | |
2237 | template <class _Tp> |
2238 | struct __destructible_imp<_Tp, false> |
2239 | : public _VSTD::integral_constant<bool, |
2240 | __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {}; |
2241 | |
2242 | template <class _Tp> |
2243 | struct __destructible_imp<_Tp, true> |
2244 | : public _VSTD::true_type {}; |
2245 | |
2246 | template <class _Tp, bool> |
2247 | struct __destructible_false; |
2248 | |
2249 | template <class _Tp> |
2250 | struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {}; |
2251 | |
2252 | template <class _Tp> |
2253 | struct __destructible_false<_Tp, true> : public _VSTD::false_type {}; |
2254 | |
2255 | template <class _Tp> |
2256 | struct is_destructible |
2257 | : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {}; |
2258 | |
2259 | template <class _Tp> |
2260 | struct is_destructible<_Tp[]> |
2261 | : public _VSTD::false_type {}; |
2262 | |
2263 | template <> |
2264 | struct is_destructible<void> |
2265 | : public _VSTD::false_type {}; |
2266 | |
2267 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2268 | template <class _Tp> |
2269 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v |
2270 | = is_destructible<_Tp>::value; |
2271 | #endif |
2272 | |
2273 | // move |
2274 | |
2275 | template <class _Tp> |
2276 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
2277 | typename remove_reference<_Tp>::type&& |
2278 | move(_Tp&& __t) _NOEXCEPT |
2279 | { |
2280 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up; |
2281 | return static_cast<_Up&&>(__t); |
2282 | } |
2283 | |
2284 | template <class _Tp> |
2285 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
2286 | _Tp&& |
2287 | forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT |
2288 | { |
2289 | return static_cast<_Tp&&>(__t); |
2290 | } |
2291 | |
2292 | template <class _Tp> |
2293 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
2294 | _Tp&& |
2295 | forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT |
2296 | { |
2297 | static_assert(!is_lvalue_reference<_Tp>::value, |
2298 | "can not forward an rvalue as an lvalue" ); |
2299 | return static_cast<_Tp&&>(__t); |
2300 | } |
2301 | |
2302 | template <class _Tp> |
2303 | inline _LIBCPP_INLINE_VISIBILITY |
2304 | typename decay<_Tp>::type |
2305 | __decay_copy(_Tp&& __t) |
2306 | { |
2307 | return _VSTD::forward<_Tp>(__t); |
2308 | } |
2309 | |
2310 | template <class _Rp, class _Class, class ..._Param> |
2311 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> |
2312 | { |
2313 | typedef _Class _ClassType; |
2314 | typedef _Rp _ReturnType; |
2315 | typedef _Rp (_FnType) (_Param...); |
2316 | }; |
2317 | |
2318 | template <class _Rp, class _Class, class ..._Param> |
2319 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> |
2320 | { |
2321 | typedef _Class _ClassType; |
2322 | typedef _Rp _ReturnType; |
2323 | typedef _Rp (_FnType) (_Param..., ...); |
2324 | }; |
2325 | |
2326 | template <class _Rp, class _Class, class ..._Param> |
2327 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> |
2328 | { |
2329 | typedef _Class const _ClassType; |
2330 | typedef _Rp _ReturnType; |
2331 | typedef _Rp (_FnType) (_Param...); |
2332 | }; |
2333 | |
2334 | template <class _Rp, class _Class, class ..._Param> |
2335 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> |
2336 | { |
2337 | typedef _Class const _ClassType; |
2338 | typedef _Rp _ReturnType; |
2339 | typedef _Rp (_FnType) (_Param..., ...); |
2340 | }; |
2341 | |
2342 | template <class _Rp, class _Class, class ..._Param> |
2343 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> |
2344 | { |
2345 | typedef _Class volatile _ClassType; |
2346 | typedef _Rp _ReturnType; |
2347 | typedef _Rp (_FnType) (_Param...); |
2348 | }; |
2349 | |
2350 | template <class _Rp, class _Class, class ..._Param> |
2351 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> |
2352 | { |
2353 | typedef _Class volatile _ClassType; |
2354 | typedef _Rp _ReturnType; |
2355 | typedef _Rp (_FnType) (_Param..., ...); |
2356 | }; |
2357 | |
2358 | template <class _Rp, class _Class, class ..._Param> |
2359 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> |
2360 | { |
2361 | typedef _Class const volatile _ClassType; |
2362 | typedef _Rp _ReturnType; |
2363 | typedef _Rp (_FnType) (_Param...); |
2364 | }; |
2365 | |
2366 | template <class _Rp, class _Class, class ..._Param> |
2367 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> |
2368 | { |
2369 | typedef _Class const volatile _ClassType; |
2370 | typedef _Rp _ReturnType; |
2371 | typedef _Rp (_FnType) (_Param..., ...); |
2372 | }; |
2373 | |
2374 | #if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC) |
2375 | |
2376 | template <class _Rp, class _Class, class ..._Param> |
2377 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> |
2378 | { |
2379 | typedef _Class& _ClassType; |
2380 | typedef _Rp _ReturnType; |
2381 | typedef _Rp (_FnType) (_Param...); |
2382 | }; |
2383 | |
2384 | template <class _Rp, class _Class, class ..._Param> |
2385 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false> |
2386 | { |
2387 | typedef _Class& _ClassType; |
2388 | typedef _Rp _ReturnType; |
2389 | typedef _Rp (_FnType) (_Param..., ...); |
2390 | }; |
2391 | |
2392 | template <class _Rp, class _Class, class ..._Param> |
2393 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> |
2394 | { |
2395 | typedef _Class const& _ClassType; |
2396 | typedef _Rp _ReturnType; |
2397 | typedef _Rp (_FnType) (_Param...); |
2398 | }; |
2399 | |
2400 | template <class _Rp, class _Class, class ..._Param> |
2401 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> |
2402 | { |
2403 | typedef _Class const& _ClassType; |
2404 | typedef _Rp _ReturnType; |
2405 | typedef _Rp (_FnType) (_Param..., ...); |
2406 | }; |
2407 | |
2408 | template <class _Rp, class _Class, class ..._Param> |
2409 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> |
2410 | { |
2411 | typedef _Class volatile& _ClassType; |
2412 | typedef _Rp _ReturnType; |
2413 | typedef _Rp (_FnType) (_Param...); |
2414 | }; |
2415 | |
2416 | template <class _Rp, class _Class, class ..._Param> |
2417 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> |
2418 | { |
2419 | typedef _Class volatile& _ClassType; |
2420 | typedef _Rp _ReturnType; |
2421 | typedef _Rp (_FnType) (_Param..., ...); |
2422 | }; |
2423 | |
2424 | template <class _Rp, class _Class, class ..._Param> |
2425 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> |
2426 | { |
2427 | typedef _Class const volatile& _ClassType; |
2428 | typedef _Rp _ReturnType; |
2429 | typedef _Rp (_FnType) (_Param...); |
2430 | }; |
2431 | |
2432 | template <class _Rp, class _Class, class ..._Param> |
2433 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> |
2434 | { |
2435 | typedef _Class const volatile& _ClassType; |
2436 | typedef _Rp _ReturnType; |
2437 | typedef _Rp (_FnType) (_Param..., ...); |
2438 | }; |
2439 | |
2440 | template <class _Rp, class _Class, class ..._Param> |
2441 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> |
2442 | { |
2443 | typedef _Class&& _ClassType; |
2444 | typedef _Rp _ReturnType; |
2445 | typedef _Rp (_FnType) (_Param...); |
2446 | }; |
2447 | |
2448 | template <class _Rp, class _Class, class ..._Param> |
2449 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false> |
2450 | { |
2451 | typedef _Class&& _ClassType; |
2452 | typedef _Rp _ReturnType; |
2453 | typedef _Rp (_FnType) (_Param..., ...); |
2454 | }; |
2455 | |
2456 | template <class _Rp, class _Class, class ..._Param> |
2457 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> |
2458 | { |
2459 | typedef _Class const&& _ClassType; |
2460 | typedef _Rp _ReturnType; |
2461 | typedef _Rp (_FnType) (_Param...); |
2462 | }; |
2463 | |
2464 | template <class _Rp, class _Class, class ..._Param> |
2465 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> |
2466 | { |
2467 | typedef _Class const&& _ClassType; |
2468 | typedef _Rp _ReturnType; |
2469 | typedef _Rp (_FnType) (_Param..., ...); |
2470 | }; |
2471 | |
2472 | template <class _Rp, class _Class, class ..._Param> |
2473 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> |
2474 | { |
2475 | typedef _Class volatile&& _ClassType; |
2476 | typedef _Rp _ReturnType; |
2477 | typedef _Rp (_FnType) (_Param...); |
2478 | }; |
2479 | |
2480 | template <class _Rp, class _Class, class ..._Param> |
2481 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> |
2482 | { |
2483 | typedef _Class volatile&& _ClassType; |
2484 | typedef _Rp _ReturnType; |
2485 | typedef _Rp (_FnType) (_Param..., ...); |
2486 | }; |
2487 | |
2488 | template <class _Rp, class _Class, class ..._Param> |
2489 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> |
2490 | { |
2491 | typedef _Class const volatile&& _ClassType; |
2492 | typedef _Rp _ReturnType; |
2493 | typedef _Rp (_FnType) (_Param...); |
2494 | }; |
2495 | |
2496 | template <class _Rp, class _Class, class ..._Param> |
2497 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> |
2498 | { |
2499 | typedef _Class const volatile&& _ClassType; |
2500 | typedef _Rp _ReturnType; |
2501 | typedef _Rp (_FnType) (_Param..., ...); |
2502 | }; |
2503 | |
2504 | #endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC) |
2505 | |
2506 | |
2507 | template <class _Rp, class _Class> |
2508 | struct __member_pointer_traits_imp<_Rp _Class::*, false, true> |
2509 | { |
2510 | typedef _Class _ClassType; |
2511 | typedef _Rp _ReturnType; |
2512 | }; |
2513 | |
2514 | template <class _MP> |
2515 | struct __member_pointer_traits |
2516 | : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, |
2517 | is_member_function_pointer<_MP>::value, |
2518 | is_member_object_pointer<_MP>::value> |
2519 | { |
2520 | // typedef ... _ClassType; |
2521 | // typedef ... _ReturnType; |
2522 | // typedef ... _FnType; |
2523 | }; |
2524 | |
2525 | |
2526 | template <class _DecayedFp> |
2527 | struct __member_pointer_class_type {}; |
2528 | |
2529 | template <class _Ret, class _ClassType> |
2530 | struct __member_pointer_class_type<_Ret _ClassType::*> { |
2531 | typedef _ClassType type; |
2532 | }; |
2533 | |
2534 | // result_of |
2535 | |
2536 | template <class _Callable> class result_of; |
2537 | |
2538 | #ifdef _LIBCPP_HAS_NO_VARIADICS |
2539 | |
2540 | template <class _Fn, bool, bool> |
2541 | class __result_of |
2542 | { |
2543 | }; |
2544 | |
2545 | template <class _Fn> |
2546 | class __result_of<_Fn(), true, false> |
2547 | { |
2548 | public: |
2549 | typedef decltype(declval<_Fn>()()) type; |
2550 | }; |
2551 | |
2552 | template <class _Fn, class _A0> |
2553 | class __result_of<_Fn(_A0), true, false> |
2554 | { |
2555 | public: |
2556 | typedef decltype(declval<_Fn>()(declval<_A0>())) type; |
2557 | }; |
2558 | |
2559 | template <class _Fn, class _A0, class _A1> |
2560 | class __result_of<_Fn(_A0, _A1), true, false> |
2561 | { |
2562 | public: |
2563 | typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; |
2564 | }; |
2565 | |
2566 | template <class _Fn, class _A0, class _A1, class _A2> |
2567 | class __result_of<_Fn(_A0, _A1, _A2), true, false> |
2568 | { |
2569 | public: |
2570 | typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; |
2571 | }; |
2572 | |
2573 | template <class _MP, class _Tp, bool _IsMemberFunctionPtr> |
2574 | struct __result_of_mp; |
2575 | |
2576 | // member function pointer |
2577 | |
2578 | template <class _MP, class _Tp> |
2579 | struct __result_of_mp<_MP, _Tp, true> |
2580 | : public __identity<typename __member_pointer_traits<_MP>::_ReturnType> |
2581 | { |
2582 | }; |
2583 | |
2584 | // member data pointer |
2585 | |
2586 | template <class _MP, class _Tp, bool> |
2587 | struct __result_of_mdp; |
2588 | |
2589 | template <class _Rp, class _Class, class _Tp> |
2590 | struct __result_of_mdp<_Rp _Class::*, _Tp, false> |
2591 | { |
2592 | typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type; |
2593 | }; |
2594 | |
2595 | template <class _Rp, class _Class, class _Tp> |
2596 | struct __result_of_mdp<_Rp _Class::*, _Tp, true> |
2597 | { |
2598 | typedef typename __apply_cv<_Tp, _Rp>::type& type; |
2599 | }; |
2600 | |
2601 | template <class _Rp, class _Class, class _Tp> |
2602 | struct __result_of_mp<_Rp _Class::*, _Tp, false> |
2603 | : public __result_of_mdp<_Rp _Class::*, _Tp, |
2604 | is_base_of<_Class, typename remove_reference<_Tp>::type>::value> |
2605 | { |
2606 | }; |
2607 | |
2608 | |
2609 | |
2610 | template <class _Fn, class _Tp> |
2611 | class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer |
2612 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
2613 | _Tp, |
2614 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
2615 | { |
2616 | }; |
2617 | |
2618 | template <class _Fn, class _Tp, class _A0> |
2619 | class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer |
2620 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
2621 | _Tp, |
2622 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
2623 | { |
2624 | }; |
2625 | |
2626 | template <class _Fn, class _Tp, class _A0, class _A1> |
2627 | class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer |
2628 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
2629 | _Tp, |
2630 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
2631 | { |
2632 | }; |
2633 | |
2634 | template <class _Fn, class _Tp, class _A0, class _A1, class _A2> |
2635 | class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer |
2636 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
2637 | _Tp, |
2638 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
2639 | { |
2640 | }; |
2641 | |
2642 | // result_of |
2643 | |
2644 | template <class _Fn> |
2645 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn()> |
2646 | : public __result_of<_Fn(), |
2647 | is_class<typename remove_reference<_Fn>::type>::value || |
2648 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
2649 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
2650 | > |
2651 | { |
2652 | }; |
2653 | |
2654 | template <class _Fn, class _A0> |
2655 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)> |
2656 | : public __result_of<_Fn(_A0), |
2657 | is_class<typename remove_reference<_Fn>::type>::value || |
2658 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
2659 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
2660 | > |
2661 | { |
2662 | }; |
2663 | |
2664 | template <class _Fn, class _A0, class _A1> |
2665 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)> |
2666 | : public __result_of<_Fn(_A0, _A1), |
2667 | is_class<typename remove_reference<_Fn>::type>::value || |
2668 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
2669 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
2670 | > |
2671 | { |
2672 | }; |
2673 | |
2674 | template <class _Fn, class _A0, class _A1, class _A2> |
2675 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)> |
2676 | : public __result_of<_Fn(_A0, _A1, _A2), |
2677 | is_class<typename remove_reference<_Fn>::type>::value || |
2678 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
2679 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
2680 | > |
2681 | { |
2682 | }; |
2683 | |
2684 | #endif // _LIBCPP_HAS_NO_VARIADICS |
2685 | |
2686 | // template <class T, class... Args> struct is_constructible; |
2687 | |
2688 | namespace __is_construct |
2689 | { |
2690 | struct __nat {}; |
2691 | } |
2692 | |
2693 | #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \ |
2694 | defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE)) |
2695 | |
2696 | template <class _Tp, class... _Args> |
2697 | struct __libcpp_is_constructible; |
2698 | |
2699 | template <class _To, class _From> |
2700 | struct __is_invalid_base_to_derived_cast { |
2701 | static_assert(is_reference<_To>::value, "Wrong specialization" ); |
2702 | using _RawFrom = __uncvref_t<_From>; |
2703 | using _RawTo = __uncvref_t<_To>; |
2704 | static const bool value = _And< |
2705 | _IsNotSame<_RawFrom, _RawTo>, |
2706 | is_base_of<_RawFrom, _RawTo>, |
2707 | _Not<__libcpp_is_constructible<_RawTo, _From>> |
2708 | >::value; |
2709 | }; |
2710 | |
2711 | template <class _To, class _From> |
2712 | struct __is_invalid_lvalue_to_rvalue_cast : false_type { |
2713 | static_assert(is_reference<_To>::value, "Wrong specialization" ); |
2714 | }; |
2715 | |
2716 | template <class _ToRef, class _FromRef> |
2717 | struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> { |
2718 | using _RawFrom = __uncvref_t<_FromRef>; |
2719 | using _RawTo = __uncvref_t<_ToRef>; |
2720 | static const bool value = _And< |
2721 | _Not<is_function<_RawTo>>, |
2722 | _Or< |
2723 | _IsSame<_RawFrom, _RawTo>, |
2724 | is_base_of<_RawTo, _RawFrom>> |
2725 | >::value; |
2726 | }; |
2727 | |
2728 | struct __is_constructible_helper |
2729 | { |
2730 | template <class _To> |
2731 | static void __eat(_To); |
2732 | |
2733 | // This overload is needed to work around a Clang bug that disallows |
2734 | // static_cast<T&&>(e) for non-reference-compatible types. |
2735 | // Example: static_cast<int&&>(declval<double>()); |
2736 | // NOTE: The static_cast implementation below is required to support |
2737 | // classes with explicit conversion operators. |
2738 | template <class _To, class _From, |
2739 | class = decltype(__eat<_To>(_VSTD::declval<_From>()))> |
2740 | static true_type __test_cast(int); |
2741 | |
2742 | template <class _To, class _From, |
2743 | class = decltype(static_cast<_To>(_VSTD::declval<_From>()))> |
2744 | static integral_constant<bool, |
2745 | !__is_invalid_base_to_derived_cast<_To, _From>::value && |
2746 | !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value |
2747 | > __test_cast(long); |
2748 | |
2749 | template <class, class> |
2750 | static false_type __test_cast(...); |
2751 | |
2752 | template <class _Tp, class ..._Args, |
2753 | class = decltype(_Tp(_VSTD::declval<_Args>()...))> |
2754 | static true_type __test_nary(int); |
2755 | template <class _Tp, class...> |
2756 | static false_type __test_nary(...); |
2757 | |
2758 | template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))> |
2759 | static is_destructible<_Tp> __test_unary(int); |
2760 | template <class, class> |
2761 | static false_type __test_unary(...); |
2762 | }; |
2763 | |
2764 | template <class _Tp, bool = is_void<_Tp>::value> |
2765 | struct __is_default_constructible |
2766 | : decltype(__is_constructible_helper::__test_nary<_Tp>(0)) |
2767 | {}; |
2768 | |
2769 | template <class _Tp> |
2770 | struct __is_default_constructible<_Tp, true> : false_type {}; |
2771 | |
2772 | template <class _Tp> |
2773 | struct __is_default_constructible<_Tp[], false> : false_type {}; |
2774 | |
2775 | template <class _Tp, size_t _Nx> |
2776 | struct __is_default_constructible<_Tp[_Nx], false> |
2777 | : __is_default_constructible<typename remove_all_extents<_Tp>::type> {}; |
2778 | |
2779 | template <class _Tp, class... _Args> |
2780 | struct __libcpp_is_constructible |
2781 | { |
2782 | static_assert(sizeof...(_Args) > 1, "Wrong specialization" ); |
2783 | typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0)) |
2784 | type; |
2785 | }; |
2786 | |
2787 | template <class _Tp> |
2788 | struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {}; |
2789 | |
2790 | template <class _Tp, class _A0> |
2791 | struct __libcpp_is_constructible<_Tp, _A0> |
2792 | : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0)) |
2793 | {}; |
2794 | |
2795 | template <class _Tp, class _A0> |
2796 | struct __libcpp_is_constructible<_Tp&, _A0> |
2797 | : public decltype(__is_constructible_helper:: |
2798 | __test_cast<_Tp&, _A0>(0)) |
2799 | {}; |
2800 | |
2801 | template <class _Tp, class _A0> |
2802 | struct __libcpp_is_constructible<_Tp&&, _A0> |
2803 | : public decltype(__is_constructible_helper:: |
2804 | __test_cast<_Tp&&, _A0>(0)) |
2805 | {}; |
2806 | |
2807 | #endif |
2808 | |
2809 | #if __has_feature(is_constructible) |
2810 | template <class _Tp, class ..._Args> |
2811 | struct _LIBCPP_TEMPLATE_VIS is_constructible |
2812 | : public integral_constant<bool, __is_constructible(_Tp, _Args...)> |
2813 | {}; |
2814 | #else |
2815 | template <class _Tp, class... _Args> |
2816 | struct _LIBCPP_TEMPLATE_VIS is_constructible |
2817 | : public __libcpp_is_constructible<_Tp, _Args...>::type {}; |
2818 | #endif |
2819 | |
2820 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2821 | template <class _Tp, class ..._Args> |
2822 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v |
2823 | = is_constructible<_Tp, _Args...>::value; |
2824 | #endif |
2825 | |
2826 | // is_default_constructible |
2827 | |
2828 | template <class _Tp> |
2829 | struct _LIBCPP_TEMPLATE_VIS is_default_constructible |
2830 | : public is_constructible<_Tp> |
2831 | {}; |
2832 | |
2833 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2834 | template <class _Tp> |
2835 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v |
2836 | = is_default_constructible<_Tp>::value; |
2837 | #endif |
2838 | |
2839 | // is_copy_constructible |
2840 | |
2841 | template <class _Tp> |
2842 | struct _LIBCPP_TEMPLATE_VIS is_copy_constructible |
2843 | : public is_constructible<_Tp, |
2844 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
2845 | |
2846 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2847 | template <class _Tp> |
2848 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v |
2849 | = is_copy_constructible<_Tp>::value; |
2850 | #endif |
2851 | |
2852 | // is_move_constructible |
2853 | |
2854 | template <class _Tp> |
2855 | struct _LIBCPP_TEMPLATE_VIS is_move_constructible |
2856 | : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
2857 | {}; |
2858 | |
2859 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2860 | template <class _Tp> |
2861 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v |
2862 | = is_move_constructible<_Tp>::value; |
2863 | #endif |
2864 | |
2865 | // is_trivially_constructible |
2866 | |
2867 | #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 |
2868 | |
2869 | template <class _Tp, class... _Args> |
2870 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible |
2871 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> |
2872 | { |
2873 | }; |
2874 | |
2875 | #else // !__has_feature(is_trivially_constructible) |
2876 | |
2877 | template <class _Tp, class... _Args> |
2878 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible |
2879 | : false_type |
2880 | { |
2881 | }; |
2882 | |
2883 | template <class _Tp> |
2884 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp> |
2885 | #if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC) |
2886 | : integral_constant<bool, __has_trivial_constructor(_Tp)> |
2887 | #else |
2888 | : integral_constant<bool, is_scalar<_Tp>::value> |
2889 | #endif |
2890 | { |
2891 | }; |
2892 | |
2893 | template <class _Tp> |
2894 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&> |
2895 | : integral_constant<bool, is_scalar<_Tp>::value> |
2896 | { |
2897 | }; |
2898 | |
2899 | template <class _Tp> |
2900 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&> |
2901 | : integral_constant<bool, is_scalar<_Tp>::value> |
2902 | { |
2903 | }; |
2904 | |
2905 | template <class _Tp> |
2906 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&> |
2907 | : integral_constant<bool, is_scalar<_Tp>::value> |
2908 | { |
2909 | }; |
2910 | |
2911 | #endif // !__has_feature(is_trivially_constructible) |
2912 | |
2913 | |
2914 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2915 | template <class _Tp, class... _Args> |
2916 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v |
2917 | = is_trivially_constructible<_Tp, _Args...>::value; |
2918 | #endif |
2919 | |
2920 | // is_trivially_default_constructible |
2921 | |
2922 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible |
2923 | : public is_trivially_constructible<_Tp> |
2924 | {}; |
2925 | |
2926 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2927 | template <class _Tp> |
2928 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v |
2929 | = is_trivially_default_constructible<_Tp>::value; |
2930 | #endif |
2931 | |
2932 | // is_trivially_copy_constructible |
2933 | |
2934 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible |
2935 | : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> |
2936 | {}; |
2937 | |
2938 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2939 | template <class _Tp> |
2940 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v |
2941 | = is_trivially_copy_constructible<_Tp>::value; |
2942 | #endif |
2943 | |
2944 | // is_trivially_move_constructible |
2945 | |
2946 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible |
2947 | : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
2948 | {}; |
2949 | |
2950 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2951 | template <class _Tp> |
2952 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v |
2953 | = is_trivially_move_constructible<_Tp>::value; |
2954 | #endif |
2955 | |
2956 | // is_trivially_assignable |
2957 | |
2958 | #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 |
2959 | |
2960 | template <class _Tp, class _Arg> |
2961 | struct is_trivially_assignable |
2962 | : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> |
2963 | { |
2964 | }; |
2965 | |
2966 | #else // !__has_feature(is_trivially_assignable) |
2967 | |
2968 | template <class _Tp, class _Arg> |
2969 | struct is_trivially_assignable |
2970 | : public false_type {}; |
2971 | |
2972 | template <class _Tp> |
2973 | struct is_trivially_assignable<_Tp&, _Tp> |
2974 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
2975 | |
2976 | template <class _Tp> |
2977 | struct is_trivially_assignable<_Tp&, _Tp&> |
2978 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
2979 | |
2980 | template <class _Tp> |
2981 | struct is_trivially_assignable<_Tp&, const _Tp&> |
2982 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
2983 | |
2984 | template <class _Tp> |
2985 | struct is_trivially_assignable<_Tp&, _Tp&&> |
2986 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
2987 | |
2988 | #endif // !__has_feature(is_trivially_assignable) |
2989 | |
2990 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2991 | template <class _Tp, class _Arg> |
2992 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v |
2993 | = is_trivially_assignable<_Tp, _Arg>::value; |
2994 | #endif |
2995 | |
2996 | // is_trivially_copy_assignable |
2997 | |
2998 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable |
2999 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, |
3000 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
3001 | |
3002 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3003 | template <class _Tp> |
3004 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v |
3005 | = is_trivially_copy_assignable<_Tp>::value; |
3006 | #endif |
3007 | |
3008 | // is_trivially_move_assignable |
3009 | |
3010 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable |
3011 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, |
3012 | typename add_rvalue_reference<_Tp>::type> |
3013 | {}; |
3014 | |
3015 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3016 | template <class _Tp> |
3017 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v |
3018 | = is_trivially_move_assignable<_Tp>::value; |
3019 | #endif |
3020 | |
3021 | // is_trivially_destructible |
3022 | |
3023 | #if __has_keyword(__is_trivially_destructible) |
3024 | |
3025 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible |
3026 | : public integral_constant<bool, __is_trivially_destructible(_Tp)> {}; |
3027 | |
3028 | #elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC) |
3029 | |
3030 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible |
3031 | : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {}; |
3032 | |
3033 | #else |
3034 | |
3035 | template <class _Tp> struct __libcpp_trivial_destructor |
3036 | : public integral_constant<bool, is_scalar<_Tp>::value || |
3037 | is_reference<_Tp>::value> {}; |
3038 | |
3039 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible |
3040 | : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; |
3041 | |
3042 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]> |
3043 | : public false_type {}; |
3044 | |
3045 | #endif |
3046 | |
3047 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3048 | template <class _Tp> |
3049 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v |
3050 | = is_trivially_destructible<_Tp>::value; |
3051 | #endif |
3052 | |
3053 | // is_nothrow_constructible |
3054 | |
3055 | #if __has_keyword(__is_nothrow_constructible) |
3056 | |
3057 | template <class _Tp, class... _Args> |
3058 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible |
3059 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; |
3060 | |
3061 | #else |
3062 | |
3063 | template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; |
3064 | |
3065 | template <class _Tp, class... _Args> |
3066 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...> |
3067 | : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> |
3068 | { |
3069 | }; |
3070 | |
3071 | template <class _Tp> |
3072 | void __implicit_conversion_to(_Tp) noexcept { } |
3073 | |
3074 | template <class _Tp, class _Arg> |
3075 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg> |
3076 | : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))> |
3077 | { |
3078 | }; |
3079 | |
3080 | template <class _Tp, bool _IsReference, class... _Args> |
3081 | struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...> |
3082 | : public false_type |
3083 | { |
3084 | }; |
3085 | |
3086 | template <class _Tp, class... _Args> |
3087 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible |
3088 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...> |
3089 | { |
3090 | }; |
3091 | |
3092 | template <class _Tp, size_t _Ns> |
3093 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> |
3094 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> |
3095 | { |
3096 | }; |
3097 | |
3098 | #endif // _LIBCPP_HAS_NO_NOEXCEPT |
3099 | |
3100 | |
3101 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3102 | template <class _Tp, class ..._Args> |
3103 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v |
3104 | = is_nothrow_constructible<_Tp, _Args...>::value; |
3105 | #endif |
3106 | |
3107 | // is_nothrow_default_constructible |
3108 | |
3109 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible |
3110 | : public is_nothrow_constructible<_Tp> |
3111 | {}; |
3112 | |
3113 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3114 | template <class _Tp> |
3115 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v |
3116 | = is_nothrow_default_constructible<_Tp>::value; |
3117 | #endif |
3118 | |
3119 | // is_nothrow_copy_constructible |
3120 | |
3121 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible |
3122 | : public is_nothrow_constructible<_Tp, |
3123 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
3124 | |
3125 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3126 | template <class _Tp> |
3127 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v |
3128 | = is_nothrow_copy_constructible<_Tp>::value; |
3129 | #endif |
3130 | |
3131 | // is_nothrow_move_constructible |
3132 | |
3133 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible |
3134 | : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
3135 | {}; |
3136 | |
3137 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3138 | template <class _Tp> |
3139 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v |
3140 | = is_nothrow_move_constructible<_Tp>::value; |
3141 | #endif |
3142 | |
3143 | // is_nothrow_assignable |
3144 | |
3145 | #if __has_keyword(__is_nothrow_assignable) |
3146 | |
3147 | template <class _Tp, class _Arg> |
3148 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable |
3149 | : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {}; |
3150 | |
3151 | #else |
3152 | |
3153 | template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; |
3154 | |
3155 | template <class _Tp, class _Arg> |
3156 | struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> |
3157 | : public false_type |
3158 | { |
3159 | }; |
3160 | |
3161 | template <class _Tp, class _Arg> |
3162 | struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> |
3163 | : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > |
3164 | { |
3165 | }; |
3166 | |
3167 | template <class _Tp, class _Arg> |
3168 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable |
3169 | : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> |
3170 | { |
3171 | }; |
3172 | |
3173 | #endif // _LIBCPP_HAS_NO_NOEXCEPT |
3174 | |
3175 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3176 | template <class _Tp, class _Arg> |
3177 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v |
3178 | = is_nothrow_assignable<_Tp, _Arg>::value; |
3179 | #endif |
3180 | |
3181 | // is_nothrow_copy_assignable |
3182 | |
3183 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable |
3184 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, |
3185 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
3186 | |
3187 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3188 | template <class _Tp> |
3189 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v |
3190 | = is_nothrow_copy_assignable<_Tp>::value; |
3191 | #endif |
3192 | |
3193 | // is_nothrow_move_assignable |
3194 | |
3195 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable |
3196 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, |
3197 | typename add_rvalue_reference<_Tp>::type> |
3198 | {}; |
3199 | |
3200 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3201 | template <class _Tp> |
3202 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v |
3203 | = is_nothrow_move_assignable<_Tp>::value; |
3204 | #endif |
3205 | |
3206 | // is_nothrow_destructible |
3207 | |
3208 | #if !defined(_LIBCPP_CXX03_LANG) |
3209 | |
3210 | template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; |
3211 | |
3212 | template <class _Tp> |
3213 | struct __libcpp_is_nothrow_destructible<false, _Tp> |
3214 | : public false_type |
3215 | { |
3216 | }; |
3217 | |
3218 | template <class _Tp> |
3219 | struct __libcpp_is_nothrow_destructible<true, _Tp> |
3220 | : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > |
3221 | { |
3222 | }; |
3223 | |
3224 | template <class _Tp> |
3225 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible |
3226 | : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> |
3227 | { |
3228 | }; |
3229 | |
3230 | template <class _Tp, size_t _Ns> |
3231 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> |
3232 | : public is_nothrow_destructible<_Tp> |
3233 | { |
3234 | }; |
3235 | |
3236 | template <class _Tp> |
3237 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> |
3238 | : public true_type |
3239 | { |
3240 | }; |
3241 | |
3242 | template <class _Tp> |
3243 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> |
3244 | : public true_type |
3245 | { |
3246 | }; |
3247 | |
3248 | #else |
3249 | |
3250 | template <class _Tp> struct __libcpp_nothrow_destructor |
3251 | : public integral_constant<bool, is_scalar<_Tp>::value || |
3252 | is_reference<_Tp>::value> {}; |
3253 | |
3254 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible |
3255 | : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; |
3256 | |
3257 | template <class _Tp> |
3258 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> |
3259 | : public false_type {}; |
3260 | |
3261 | #endif |
3262 | |
3263 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3264 | template <class _Tp> |
3265 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v |
3266 | = is_nothrow_destructible<_Tp>::value; |
3267 | #endif |
3268 | |
3269 | // is_pod |
3270 | |
3271 | #if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC) |
3272 | |
3273 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod |
3274 | : public integral_constant<bool, __is_pod(_Tp)> {}; |
3275 | |
3276 | #else |
3277 | |
3278 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod |
3279 | : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && |
3280 | is_trivially_copy_constructible<_Tp>::value && |
3281 | is_trivially_copy_assignable<_Tp>::value && |
3282 | is_trivially_destructible<_Tp>::value> {}; |
3283 | |
3284 | #endif |
3285 | |
3286 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3287 | template <class _Tp> |
3288 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v |
3289 | = is_pod<_Tp>::value; |
3290 | #endif |
3291 | |
3292 | // is_literal_type; |
3293 | |
3294 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type |
3295 | : public integral_constant<bool, __is_literal_type(_Tp)> |
3296 | {}; |
3297 | |
3298 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3299 | template <class _Tp> |
3300 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v |
3301 | = is_literal_type<_Tp>::value; |
3302 | #endif |
3303 | |
3304 | // is_standard_layout; |
3305 | |
3306 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout |
3307 | #if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC) |
3308 | : public integral_constant<bool, __is_standard_layout(_Tp)> |
3309 | #else |
3310 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> |
3311 | #endif |
3312 | {}; |
3313 | |
3314 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3315 | template <class _Tp> |
3316 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v |
3317 | = is_standard_layout<_Tp>::value; |
3318 | #endif |
3319 | |
3320 | // is_trivially_copyable; |
3321 | |
3322 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable |
3323 | #if __has_feature(is_trivially_copyable) |
3324 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> |
3325 | #elif _GNUC_VER >= 501 |
3326 | : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)> |
3327 | #else |
3328 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> |
3329 | #endif |
3330 | {}; |
3331 | |
3332 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3333 | template <class _Tp> |
3334 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v |
3335 | = is_trivially_copyable<_Tp>::value; |
3336 | #endif |
3337 | |
3338 | // is_trivial; |
3339 | |
3340 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial |
3341 | #if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC) |
3342 | : public integral_constant<bool, __is_trivial(_Tp)> |
3343 | #else |
3344 | : integral_constant<bool, is_trivially_copyable<_Tp>::value && |
3345 | is_trivially_default_constructible<_Tp>::value> |
3346 | #endif |
3347 | {}; |
3348 | |
3349 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3350 | template <class _Tp> |
3351 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v |
3352 | = is_trivial<_Tp>::value; |
3353 | #endif |
3354 | |
3355 | template <class _Tp> struct __is_reference_wrapper_impl : public false_type {}; |
3356 | template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {}; |
3357 | template <class _Tp> struct __is_reference_wrapper |
3358 | : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {}; |
3359 | |
3360 | #ifndef _LIBCPP_CXX03_LANG |
3361 | |
3362 | template <class _Fp, class _A0, |
3363 | class _DecayFp = typename decay<_Fp>::type, |
3364 | class _DecayA0 = typename decay<_A0>::type, |
3365 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
3366 | using __enable_if_bullet1 = typename enable_if |
3367 | < |
3368 | is_member_function_pointer<_DecayFp>::value |
3369 | && is_base_of<_ClassT, _DecayA0>::value |
3370 | >::type; |
3371 | |
3372 | template <class _Fp, class _A0, |
3373 | class _DecayFp = typename decay<_Fp>::type, |
3374 | class _DecayA0 = typename decay<_A0>::type> |
3375 | using __enable_if_bullet2 = typename enable_if |
3376 | < |
3377 | is_member_function_pointer<_DecayFp>::value |
3378 | && __is_reference_wrapper<_DecayA0>::value |
3379 | >::type; |
3380 | |
3381 | template <class _Fp, class _A0, |
3382 | class _DecayFp = typename decay<_Fp>::type, |
3383 | class _DecayA0 = typename decay<_A0>::type, |
3384 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
3385 | using __enable_if_bullet3 = typename enable_if |
3386 | < |
3387 | is_member_function_pointer<_DecayFp>::value |
3388 | && !is_base_of<_ClassT, _DecayA0>::value |
3389 | && !__is_reference_wrapper<_DecayA0>::value |
3390 | >::type; |
3391 | |
3392 | template <class _Fp, class _A0, |
3393 | class _DecayFp = typename decay<_Fp>::type, |
3394 | class _DecayA0 = typename decay<_A0>::type, |
3395 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
3396 | using __enable_if_bullet4 = typename enable_if |
3397 | < |
3398 | is_member_object_pointer<_DecayFp>::value |
3399 | && is_base_of<_ClassT, _DecayA0>::value |
3400 | >::type; |
3401 | |
3402 | template <class _Fp, class _A0, |
3403 | class _DecayFp = typename decay<_Fp>::type, |
3404 | class _DecayA0 = typename decay<_A0>::type> |
3405 | using __enable_if_bullet5 = typename enable_if |
3406 | < |
3407 | is_member_object_pointer<_DecayFp>::value |
3408 | && __is_reference_wrapper<_DecayA0>::value |
3409 | >::type; |
3410 | |
3411 | template <class _Fp, class _A0, |
3412 | class _DecayFp = typename decay<_Fp>::type, |
3413 | class _DecayA0 = typename decay<_A0>::type, |
3414 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
3415 | using __enable_if_bullet6 = typename enable_if |
3416 | < |
3417 | is_member_object_pointer<_DecayFp>::value |
3418 | && !is_base_of<_ClassT, _DecayA0>::value |
3419 | && !__is_reference_wrapper<_DecayA0>::value |
3420 | >::type; |
3421 | |
3422 | // __invoke forward declarations |
3423 | |
3424 | // fall back - none of the bullets |
3425 | |
3426 | #define _LIBCPP_INVOKE_RETURN(...) \ |
3427 | noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ |
3428 | { return __VA_ARGS__; } |
3429 | |
3430 | template <class ..._Args> |
3431 | auto __invoke(__any, _Args&& ...__args) -> __nat; |
3432 | |
3433 | template <class ..._Args> |
3434 | auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat; |
3435 | |
3436 | // bullets 1, 2 and 3 |
3437 | |
3438 | template <class _Fp, class _A0, class ..._Args, |
3439 | class = __enable_if_bullet1<_Fp, _A0>> |
3440 | inline _LIBCPP_INLINE_VISIBILITY |
3441 | auto |
3442 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
3443 | _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) |
3444 | |
3445 | template <class _Fp, class _A0, class ..._Args, |
3446 | class = __enable_if_bullet1<_Fp, _A0>> |
3447 | inline _LIBCPP_INLINE_VISIBILITY |
3448 | _LIBCPP_CONSTEXPR auto |
3449 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
3450 | _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) |
3451 | |
3452 | template <class _Fp, class _A0, class ..._Args, |
3453 | class = __enable_if_bullet2<_Fp, _A0>> |
3454 | inline _LIBCPP_INLINE_VISIBILITY |
3455 | auto |
3456 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
3457 | _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) |
3458 | |
3459 | template <class _Fp, class _A0, class ..._Args, |
3460 | class = __enable_if_bullet2<_Fp, _A0>> |
3461 | inline _LIBCPP_INLINE_VISIBILITY |
3462 | _LIBCPP_CONSTEXPR auto |
3463 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
3464 | _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) |
3465 | |
3466 | template <class _Fp, class _A0, class ..._Args, |
3467 | class = __enable_if_bullet3<_Fp, _A0>> |
3468 | inline _LIBCPP_INLINE_VISIBILITY |
3469 | auto |
3470 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
3471 | _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) |
3472 | |
3473 | template <class _Fp, class _A0, class ..._Args, |
3474 | class = __enable_if_bullet3<_Fp, _A0>> |
3475 | inline _LIBCPP_INLINE_VISIBILITY |
3476 | _LIBCPP_CONSTEXPR auto |
3477 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
3478 | _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) |
3479 | |
3480 | // bullets 4, 5 and 6 |
3481 | |
3482 | template <class _Fp, class _A0, |
3483 | class = __enable_if_bullet4<_Fp, _A0>> |
3484 | inline _LIBCPP_INLINE_VISIBILITY |
3485 | auto |
3486 | __invoke(_Fp&& __f, _A0&& __a0) |
3487 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) |
3488 | |
3489 | template <class _Fp, class _A0, |
3490 | class = __enable_if_bullet4<_Fp, _A0>> |
3491 | inline _LIBCPP_INLINE_VISIBILITY |
3492 | _LIBCPP_CONSTEXPR auto |
3493 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
3494 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) |
3495 | |
3496 | template <class _Fp, class _A0, |
3497 | class = __enable_if_bullet5<_Fp, _A0>> |
3498 | inline _LIBCPP_INLINE_VISIBILITY |
3499 | auto |
3500 | __invoke(_Fp&& __f, _A0&& __a0) |
3501 | _LIBCPP_INVOKE_RETURN(__a0.get().*__f) |
3502 | |
3503 | template <class _Fp, class _A0, |
3504 | class = __enable_if_bullet5<_Fp, _A0>> |
3505 | inline _LIBCPP_INLINE_VISIBILITY |
3506 | _LIBCPP_CONSTEXPR auto |
3507 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
3508 | _LIBCPP_INVOKE_RETURN(__a0.get().*__f) |
3509 | |
3510 | template <class _Fp, class _A0, |
3511 | class = __enable_if_bullet6<_Fp, _A0>> |
3512 | inline _LIBCPP_INLINE_VISIBILITY |
3513 | auto |
3514 | __invoke(_Fp&& __f, _A0&& __a0) |
3515 | _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) |
3516 | |
3517 | template <class _Fp, class _A0, |
3518 | class = __enable_if_bullet6<_Fp, _A0>> |
3519 | inline _LIBCPP_INLINE_VISIBILITY |
3520 | _LIBCPP_CONSTEXPR auto |
3521 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
3522 | _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) |
3523 | |
3524 | // bullet 7 |
3525 | |
3526 | template <class _Fp, class ..._Args> |
3527 | inline _LIBCPP_INLINE_VISIBILITY |
3528 | auto |
3529 | __invoke(_Fp&& __f, _Args&& ...__args) |
3530 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) |
3531 | |
3532 | template <class _Fp, class ..._Args> |
3533 | inline _LIBCPP_INLINE_VISIBILITY |
3534 | _LIBCPP_CONSTEXPR auto |
3535 | __invoke_constexpr(_Fp&& __f, _Args&& ...__args) |
3536 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) |
3537 | |
3538 | #undef _LIBCPP_INVOKE_RETURN |
3539 | |
3540 | // __invokable |
3541 | template <class _Ret, class _Fp, class ..._Args> |
3542 | struct __invokable_r |
3543 | { |
3544 | template <class _XFp, class ..._XArgs> |
3545 | static auto __try_call(int) -> decltype( |
3546 | _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...)); |
3547 | template <class _XFp, class ..._XArgs> |
3548 | static __nat __try_call(...); |
3549 | |
3550 | // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void, |
3551 | // or incomplete array types as required by the standard. |
3552 | using _Result = decltype(__try_call<_Fp, _Args...>(0)); |
3553 | |
3554 | using type = |
3555 | typename conditional< |
3556 | _IsNotSame<_Result, __nat>::value, |
3557 | typename conditional< |
3558 | is_void<_Ret>::value, |
3559 | true_type, |
3560 | is_convertible<_Result, _Ret> |
3561 | >::type, |
3562 | false_type |
3563 | >::type; |
3564 | static const bool value = type::value; |
3565 | }; |
3566 | template <class _Fp, class ..._Args> |
3567 | using __invokable = __invokable_r<void, _Fp, _Args...>; |
3568 | |
3569 | template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args> |
3570 | struct __nothrow_invokable_r_imp { |
3571 | static const bool value = false; |
3572 | }; |
3573 | |
3574 | template <class _Ret, class _Fp, class ..._Args> |
3575 | struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> |
3576 | { |
3577 | typedef __nothrow_invokable_r_imp _ThisT; |
3578 | |
3579 | template <class _Tp> |
3580 | static void __test_noexcept(_Tp) noexcept; |
3581 | |
3582 | static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( |
3583 | _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...))); |
3584 | }; |
3585 | |
3586 | template <class _Ret, class _Fp, class ..._Args> |
3587 | struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> |
3588 | { |
3589 | static const bool value = noexcept( |
3590 | _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)); |
3591 | }; |
3592 | |
3593 | template <class _Ret, class _Fp, class ..._Args> |
3594 | using __nothrow_invokable_r = |
3595 | __nothrow_invokable_r_imp< |
3596 | __invokable_r<_Ret, _Fp, _Args...>::value, |
3597 | is_void<_Ret>::value, |
3598 | _Ret, _Fp, _Args... |
3599 | >; |
3600 | |
3601 | template <class _Fp, class ..._Args> |
3602 | using __nothrow_invokable = |
3603 | __nothrow_invokable_r_imp< |
3604 | __invokable<_Fp, _Args...>::value, |
3605 | true, void, _Fp, _Args... |
3606 | >; |
3607 | |
3608 | template <class _Fp, class ..._Args> |
3609 | struct __invoke_of |
3610 | : public enable_if< |
3611 | __invokable<_Fp, _Args...>::value, |
3612 | typename __invokable_r<void, _Fp, _Args...>::_Result> |
3613 | { |
3614 | }; |
3615 | |
3616 | // result_of |
3617 | |
3618 | template <class _Fp, class ..._Args> |
3619 | class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> |
3620 | : public __invoke_of<_Fp, _Args...> |
3621 | { |
3622 | }; |
3623 | |
3624 | #if _LIBCPP_STD_VER > 11 |
3625 | template <class _Tp> using result_of_t = typename result_of<_Tp>::type; |
3626 | #endif |
3627 | |
3628 | #if _LIBCPP_STD_VER > 14 |
3629 | |
3630 | // invoke_result |
3631 | |
3632 | template <class _Fn, class... _Args> |
3633 | struct _LIBCPP_TEMPLATE_VIS invoke_result |
3634 | : __invoke_of<_Fn, _Args...> |
3635 | { |
3636 | }; |
3637 | |
3638 | template <class _Fn, class... _Args> |
3639 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; |
3640 | |
3641 | // is_invocable |
3642 | |
3643 | template <class _Fn, class ..._Args> |
3644 | struct _LIBCPP_TEMPLATE_VIS is_invocable |
3645 | : integral_constant<bool, __invokable<_Fn, _Args...>::value> {}; |
3646 | |
3647 | template <class _Ret, class _Fn, class ..._Args> |
3648 | struct _LIBCPP_TEMPLATE_VIS is_invocable_r |
3649 | : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; |
3650 | |
3651 | template <class _Fn, class ..._Args> |
3652 | _LIBCPP_INLINE_VAR constexpr bool is_invocable_v |
3653 | = is_invocable<_Fn, _Args...>::value; |
3654 | |
3655 | template <class _Ret, class _Fn, class ..._Args> |
3656 | _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v |
3657 | = is_invocable_r<_Ret, _Fn, _Args...>::value; |
3658 | |
3659 | // is_nothrow_invocable |
3660 | |
3661 | template <class _Fn, class ..._Args> |
3662 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable |
3663 | : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {}; |
3664 | |
3665 | template <class _Ret, class _Fn, class ..._Args> |
3666 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r |
3667 | : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; |
3668 | |
3669 | template <class _Fn, class ..._Args> |
3670 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v |
3671 | = is_nothrow_invocable<_Fn, _Args...>::value; |
3672 | |
3673 | template <class _Ret, class _Fn, class ..._Args> |
3674 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v |
3675 | = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; |
3676 | |
3677 | #endif // _LIBCPP_STD_VER > 14 |
3678 | |
3679 | #endif // !defined(_LIBCPP_CXX03_LANG) |
3680 | |
3681 | template <class _Tp> struct __is_swappable; |
3682 | template <class _Tp> struct __is_nothrow_swappable; |
3683 | |
3684 | template <class _Tp> |
3685 | inline _LIBCPP_INLINE_VISIBILITY |
3686 | #ifndef _LIBCPP_CXX03_LANG |
3687 | typename enable_if |
3688 | < |
3689 | is_move_constructible<_Tp>::value && |
3690 | is_move_assignable<_Tp>::value |
3691 | >::type |
3692 | #else |
3693 | void |
3694 | #endif |
3695 | _LIBCPP_CONSTEXPR_AFTER_CXX17 |
3696 | swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && |
3697 | is_nothrow_move_assignable<_Tp>::value) |
3698 | { |
3699 | _Tp __t(_VSTD::move(__x)); |
3700 | __x = _VSTD::move(__y); |
3701 | __y = _VSTD::move(__t); |
3702 | } |
3703 | |
3704 | template<class _Tp, size_t _Np> |
3705 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
3706 | typename enable_if< |
3707 | __is_swappable<_Tp>::value |
3708 | >::type |
3709 | swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); |
3710 | |
3711 | template <class _ForwardIterator1, class _ForwardIterator2> |
3712 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
3713 | void |
3714 | iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) |
3715 | // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) |
3716 | _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), |
3717 | *_VSTD::declval<_ForwardIterator2>()))) |
3718 | { |
3719 | swap(*__a, *__b); |
3720 | } |
3721 | |
3722 | // __swappable |
3723 | |
3724 | namespace __detail |
3725 | { |
3726 | // ALL generic swap overloads MUST already have a declaration available at this point. |
3727 | |
3728 | template <class _Tp, class _Up = _Tp, |
3729 | bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value> |
3730 | struct __swappable_with |
3731 | { |
3732 | template <class _LHS, class _RHS> |
3733 | static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>())) |
3734 | __test_swap(int); |
3735 | template <class, class> |
3736 | static __nat __test_swap(long); |
3737 | |
3738 | // Extra parens are needed for the C++03 definition of decltype. |
3739 | typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1; |
3740 | typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2; |
3741 | |
3742 | static const bool value = _IsNotSame<__swap1, __nat>::value |
3743 | && _IsNotSame<__swap2, __nat>::value; |
3744 | }; |
3745 | |
3746 | template <class _Tp, class _Up> |
3747 | struct __swappable_with<_Tp, _Up, false> : false_type {}; |
3748 | |
3749 | template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value> |
3750 | struct __nothrow_swappable_with { |
3751 | static const bool value = |
3752 | #ifndef _LIBCPP_HAS_NO_NOEXCEPT |
3753 | noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>())) |
3754 | && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>())); |
3755 | #else |
3756 | false; |
3757 | #endif |
3758 | }; |
3759 | |
3760 | template <class _Tp, class _Up> |
3761 | struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {}; |
3762 | |
3763 | } // __detail |
3764 | |
3765 | template <class _Tp> |
3766 | struct __is_swappable |
3767 | : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> |
3768 | { |
3769 | }; |
3770 | |
3771 | template <class _Tp> |
3772 | struct __is_nothrow_swappable |
3773 | : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> |
3774 | { |
3775 | }; |
3776 | |
3777 | #if _LIBCPP_STD_VER > 14 |
3778 | |
3779 | template <class _Tp, class _Up> |
3780 | struct _LIBCPP_TEMPLATE_VIS is_swappable_with |
3781 | : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> |
3782 | { |
3783 | }; |
3784 | |
3785 | template <class _Tp> |
3786 | struct _LIBCPP_TEMPLATE_VIS is_swappable |
3787 | : public conditional< |
3788 | __is_referenceable<_Tp>::value, |
3789 | is_swappable_with< |
3790 | typename add_lvalue_reference<_Tp>::type, |
3791 | typename add_lvalue_reference<_Tp>::type>, |
3792 | false_type |
3793 | >::type |
3794 | { |
3795 | }; |
3796 | |
3797 | template <class _Tp, class _Up> |
3798 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with |
3799 | : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> |
3800 | { |
3801 | }; |
3802 | |
3803 | template <class _Tp> |
3804 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable |
3805 | : public conditional< |
3806 | __is_referenceable<_Tp>::value, |
3807 | is_nothrow_swappable_with< |
3808 | typename add_lvalue_reference<_Tp>::type, |
3809 | typename add_lvalue_reference<_Tp>::type>, |
3810 | false_type |
3811 | >::type |
3812 | { |
3813 | }; |
3814 | |
3815 | template <class _Tp, class _Up> |
3816 | _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v |
3817 | = is_swappable_with<_Tp, _Up>::value; |
3818 | |
3819 | template <class _Tp> |
3820 | _LIBCPP_INLINE_VAR constexpr bool is_swappable_v |
3821 | = is_swappable<_Tp>::value; |
3822 | |
3823 | template <class _Tp, class _Up> |
3824 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v |
3825 | = is_nothrow_swappable_with<_Tp, _Up>::value; |
3826 | |
3827 | template <class _Tp> |
3828 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v |
3829 | = is_nothrow_swappable<_Tp>::value; |
3830 | |
3831 | #endif // _LIBCPP_STD_VER > 14 |
3832 | |
3833 | template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl; |
3834 | |
3835 | template <class _Tp> |
3836 | struct __underlying_type_impl<_Tp, false> {}; |
3837 | |
3838 | template <class _Tp> |
3839 | struct __underlying_type_impl<_Tp, true> |
3840 | { |
3841 | typedef __underlying_type(_Tp) type; |
3842 | }; |
3843 | |
3844 | template <class _Tp> |
3845 | struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; |
3846 | |
3847 | #if _LIBCPP_STD_VER > 11 |
3848 | template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; |
3849 | #endif |
3850 | |
3851 | |
3852 | template <class _Tp, bool = is_enum<_Tp>::value> |
3853 | struct __sfinae_underlying_type |
3854 | { |
3855 | typedef typename underlying_type<_Tp>::type type; |
3856 | typedef decltype(((type)1) + 0) __promoted_type; |
3857 | }; |
3858 | |
3859 | template <class _Tp> |
3860 | struct __sfinae_underlying_type<_Tp, false> {}; |
3861 | |
3862 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3863 | int __convert_to_integral(int __val) { return __val; } |
3864 | |
3865 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3866 | unsigned __convert_to_integral(unsigned __val) { return __val; } |
3867 | |
3868 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3869 | long __convert_to_integral(long __val) { return __val; } |
3870 | |
3871 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3872 | unsigned long __convert_to_integral(unsigned long __val) { return __val; } |
3873 | |
3874 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3875 | long long __convert_to_integral(long long __val) { return __val; } |
3876 | |
3877 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3878 | unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } |
3879 | |
3880 | template<typename _Fp> |
3881 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3882 | typename enable_if<is_floating_point<_Fp>::value, long long>::type |
3883 | __convert_to_integral(_Fp __val) { return __val; } |
3884 | |
3885 | #ifndef _LIBCPP_HAS_NO_INT128 |
3886 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3887 | __int128_t __convert_to_integral(__int128_t __val) { return __val; } |
3888 | |
3889 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3890 | __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } |
3891 | #endif |
3892 | |
3893 | template <class _Tp> |
3894 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
3895 | typename __sfinae_underlying_type<_Tp>::__promoted_type |
3896 | __convert_to_integral(_Tp __val) { return __val; } |
3897 | |
3898 | #ifndef _LIBCPP_CXX03_LANG |
3899 | |
3900 | template <class _Tp> |
3901 | struct __has_operator_addressof_member_imp |
3902 | { |
3903 | template <class _Up> |
3904 | static auto __test(int) |
3905 | -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type; |
3906 | template <class> |
3907 | static auto __test(long) -> false_type; |
3908 | |
3909 | static const bool value = decltype(__test<_Tp>(0))::value; |
3910 | }; |
3911 | |
3912 | template <class _Tp> |
3913 | struct __has_operator_addressof_free_imp |
3914 | { |
3915 | template <class _Up> |
3916 | static auto __test(int) |
3917 | -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type; |
3918 | template <class> |
3919 | static auto __test(long) -> false_type; |
3920 | |
3921 | static const bool value = decltype(__test<_Tp>(0))::value; |
3922 | }; |
3923 | |
3924 | template <class _Tp> |
3925 | struct __has_operator_addressof |
3926 | : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value |
3927 | || __has_operator_addressof_free_imp<_Tp>::value> |
3928 | {}; |
3929 | |
3930 | #endif // _LIBCPP_CXX03_LANG |
3931 | |
3932 | #if _LIBCPP_STD_VER > 14 |
3933 | |
3934 | template <class...> using void_t = void; |
3935 | |
3936 | template <class... _Args> |
3937 | struct conjunction : _And<_Args...> {}; |
3938 | template<class... _Args> |
3939 | _LIBCPP_INLINE_VAR constexpr bool conjunction_v |
3940 | = conjunction<_Args...>::value; |
3941 | |
3942 | template <class... _Args> |
3943 | struct disjunction : _Or<_Args...> {}; |
3944 | template<class... _Args> |
3945 | _LIBCPP_INLINE_VAR constexpr bool disjunction_v |
3946 | = disjunction<_Args...>::value; |
3947 | |
3948 | template <class _Tp> |
3949 | struct negation : _Not<_Tp> {}; |
3950 | template<class _Tp> |
3951 | _LIBCPP_INLINE_VAR constexpr bool negation_v |
3952 | = negation<_Tp>::value; |
3953 | #endif // _LIBCPP_STD_VER > 14 |
3954 | |
3955 | // These traits are used in __tree and __hash_table |
3956 | #ifndef _LIBCPP_CXX03_LANG |
3957 | struct {}; |
3958 | struct {}; |
3959 | struct {}; |
3960 | |
3961 | template <class _ValTy, class _Key, |
3962 | class _RawValTy = typename __unconstref<_ValTy>::type> |
3963 | struct |
3964 | : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag, |
3965 | __extract_key_fail_tag>::type {}; |
3966 | |
3967 | template <class _Pair, class _Key, class _First, class _Second> |
3968 | struct <_Pair, _Key, pair<_First, _Second>> |
3969 | : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value, |
3970 | __extract_key_first_tag, __extract_key_fail_tag>::type {}; |
3971 | |
3972 | // __can_extract_map_key uses true_type/false_type instead of the tags. |
3973 | // It returns true if _Key != _ContainerValueTy (the container is a map not a set) |
3974 | // and _ValTy == _Key. |
3975 | template <class _ValTy, class _Key, class _ContainerValueTy, |
3976 | class _RawValTy = typename __unconstref<_ValTy>::type> |
3977 | struct |
3978 | : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {}; |
3979 | |
3980 | // This specialization returns __extract_key_fail_tag for non-map containers |
3981 | // because _Key == _ContainerValueTy |
3982 | template <class _ValTy, class _Key, class _RawValTy> |
3983 | struct <_ValTy, _Key, _Key, _RawValTy> |
3984 | : false_type {}; |
3985 | |
3986 | #endif |
3987 | |
3988 | #if _LIBCPP_STD_VER > 17 |
3989 | enum class endian |
3990 | { |
3991 | little = 0xDEAD, |
3992 | big = 0xFACE, |
3993 | #if defined(_LIBCPP_LITTLE_ENDIAN) |
3994 | native = little |
3995 | #elif defined(_LIBCPP_BIG_ENDIAN) |
3996 | native = big |
3997 | #else |
3998 | native = 0xCAFE |
3999 | #endif |
4000 | }; |
4001 | #endif |
4002 | |
4003 | #ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED |
4004 | #if _LIBCPP_STD_VER > 17 |
4005 | _LIBCPP_INLINE_VISIBILITY |
4006 | inline constexpr bool is_constant_evaluated() noexcept { |
4007 | return __builtin_is_constant_evaluated(); |
4008 | } |
4009 | #endif |
4010 | |
4011 | inline _LIBCPP_CONSTEXPR |
4012 | bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); } |
4013 | #else |
4014 | inline _LIBCPP_CONSTEXPR |
4015 | bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; } |
4016 | #endif |
4017 | |
4018 | template <class _CharT> |
4019 | using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; |
4020 | |
4021 | _LIBCPP_END_NAMESPACE_STD |
4022 | |
4023 | #if _LIBCPP_STD_VER > 14 |
4024 | // std::byte |
4025 | namespace std // purposefully not versioned |
4026 | { |
4027 | template <class _Integer> |
4028 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & |
4029 | operator<<=(byte& __lhs, _Integer __shift) noexcept |
4030 | { return __lhs = __lhs << __shift; } |
4031 | |
4032 | template <class _Integer> |
4033 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type |
4034 | operator<< (byte __lhs, _Integer __shift) noexcept |
4035 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); } |
4036 | |
4037 | template <class _Integer> |
4038 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & |
4039 | operator>>=(byte& __lhs, _Integer __shift) noexcept |
4040 | { return __lhs = __lhs >> __shift; } |
4041 | |
4042 | template <class _Integer> |
4043 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type |
4044 | (byte __lhs, _Integer __shift) noexcept |
4045 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); } |
4046 | |
4047 | template <class _Integer> |
4048 | constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type |
4049 | to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } |
4050 | |
4051 | } |
4052 | #endif |
4053 | |
4054 | #endif // _LIBCPP_TYPE_TRAITS |
4055 | |