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 | template <class> |
431 | struct __void_t { typedef void type; }; |
432 | |
433 | template <class _Tp> |
434 | struct __identity { typedef _Tp type; }; |
435 | |
436 | template <class _Tp, bool> |
437 | struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; |
438 | |
439 | template <bool _Bp, class _If, class _Then> |
440 | struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; |
441 | template <class _If, class _Then> |
442 | struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;}; |
443 | |
444 | #if _LIBCPP_STD_VER > 11 |
445 | template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; |
446 | #endif |
447 | |
448 | template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {}; |
449 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;}; |
450 | |
451 | template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {}; |
452 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;}; |
453 | |
454 | #if _LIBCPP_STD_VER > 11 |
455 | template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; |
456 | #endif |
457 | |
458 | // addressof |
459 | #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF |
460 | |
461 | template <class _Tp> |
462 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 |
463 | _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY |
464 | _Tp* |
465 | addressof(_Tp& __x) _NOEXCEPT |
466 | { |
467 | return __builtin_addressof(__x); |
468 | } |
469 | |
470 | #else |
471 | |
472 | template <class _Tp> |
473 | inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY |
474 | _Tp* |
475 | addressof(_Tp& __x) _NOEXCEPT |
476 | { |
477 | return reinterpret_cast<_Tp *>( |
478 | const_cast<char *>(&reinterpret_cast<const volatile char &>(__x))); |
479 | } |
480 | |
481 | #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF |
482 | |
483 | #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) |
484 | // Objective-C++ Automatic Reference Counting uses qualified pointers |
485 | // that require special addressof() signatures. When |
486 | // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler |
487 | // itself is providing these definitions. Otherwise, we provide them. |
488 | template <class _Tp> |
489 | inline _LIBCPP_INLINE_VISIBILITY |
490 | __strong _Tp* |
491 | addressof(__strong _Tp& __x) _NOEXCEPT |
492 | { |
493 | return &__x; |
494 | } |
495 | |
496 | #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK |
497 | template <class _Tp> |
498 | inline _LIBCPP_INLINE_VISIBILITY |
499 | __weak _Tp* |
500 | addressof(__weak _Tp& __x) _NOEXCEPT |
501 | { |
502 | return &__x; |
503 | } |
504 | #endif |
505 | |
506 | template <class _Tp> |
507 | inline _LIBCPP_INLINE_VISIBILITY |
508 | __autoreleasing _Tp* |
509 | addressof(__autoreleasing _Tp& __x) _NOEXCEPT |
510 | { |
511 | return &__x; |
512 | } |
513 | |
514 | template <class _Tp> |
515 | inline _LIBCPP_INLINE_VISIBILITY |
516 | __unsafe_unretained _Tp* |
517 | addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT |
518 | { |
519 | return &__x; |
520 | } |
521 | #endif |
522 | |
523 | #if !defined(_LIBCPP_CXX03_LANG) |
524 | template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete; |
525 | #endif |
526 | |
527 | struct __two {char __lx[2];}; |
528 | |
529 | // helper class: |
530 | |
531 | template <class _Tp, _Tp __v> |
532 | struct _LIBCPP_TEMPLATE_VIS integral_constant |
533 | { |
534 | static _LIBCPP_CONSTEXPR const _Tp value = __v; |
535 | typedef _Tp value_type; |
536 | typedef integral_constant type; |
537 | _LIBCPP_INLINE_VISIBILITY |
538 | _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} |
539 | #if _LIBCPP_STD_VER > 11 |
540 | _LIBCPP_INLINE_VISIBILITY |
541 | constexpr value_type operator ()() const _NOEXCEPT {return value;} |
542 | #endif |
543 | }; |
544 | |
545 | template <class _Tp, _Tp __v> |
546 | _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; |
547 | |
548 | #if _LIBCPP_STD_VER > 14 |
549 | template <bool __b> |
550 | using bool_constant = integral_constant<bool, __b>; |
551 | #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> |
552 | #else |
553 | #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> |
554 | #endif |
555 | |
556 | typedef _LIBCPP_BOOL_CONSTANT(true) true_type; |
557 | typedef _LIBCPP_BOOL_CONSTANT(false) false_type; |
558 | |
559 | #if !defined(_LIBCPP_CXX03_LANG) |
560 | |
561 | // __lazy_and |
562 | |
563 | template <bool _Last, class ..._Preds> |
564 | struct __lazy_and_impl; |
565 | |
566 | template <class ..._Preds> |
567 | struct __lazy_and_impl<false, _Preds...> : false_type {}; |
568 | |
569 | template <> |
570 | struct __lazy_and_impl<true> : true_type {}; |
571 | |
572 | template <class _Pred> |
573 | struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {}; |
574 | |
575 | template <class _Hp, class ..._Tp> |
576 | struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {}; |
577 | |
578 | template <class _P1, class ..._Pr> |
579 | struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; |
580 | |
581 | // __lazy_or |
582 | |
583 | template <bool _List, class ..._Preds> |
584 | struct __lazy_or_impl; |
585 | |
586 | template <class ..._Preds> |
587 | struct __lazy_or_impl<true, _Preds...> : true_type {}; |
588 | |
589 | template <> |
590 | struct __lazy_or_impl<false> : false_type {}; |
591 | |
592 | template <class _Hp, class ..._Tp> |
593 | struct __lazy_or_impl<false, _Hp, _Tp...> |
594 | : __lazy_or_impl<_Hp::type::value, _Tp...> {}; |
595 | |
596 | template <class _P1, class ..._Pr> |
597 | struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {}; |
598 | |
599 | // __lazy_not |
600 | |
601 | template <class _Pred> |
602 | struct __lazy_not : integral_constant<bool, !_Pred::type::value> {}; |
603 | |
604 | // __and_ |
605 | template<class...> struct __and_; |
606 | template<> struct __and_<> : true_type {}; |
607 | |
608 | template<class _B0> struct __and_<_B0> : _B0 {}; |
609 | |
610 | template<class _B0, class _B1> |
611 | struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {}; |
612 | |
613 | template<class _B0, class _B1, class _B2, class... _Bn> |
614 | struct __and_<_B0, _B1, _B2, _Bn...> |
615 | : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {}; |
616 | |
617 | // __or_ |
618 | template<class...> struct __or_; |
619 | template<> struct __or_<> : false_type {}; |
620 | |
621 | template<class _B0> struct __or_<_B0> : _B0 {}; |
622 | |
623 | template<class _B0, class _B1> |
624 | struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {}; |
625 | |
626 | template<class _B0, class _B1, class _B2, class... _Bn> |
627 | struct __or_<_B0, _B1, _B2, _Bn...> |
628 | : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {}; |
629 | |
630 | // __not_ |
631 | template<class _Tp> |
632 | struct __not_ : conditional<_Tp::value, false_type, true_type>::type {}; |
633 | |
634 | #endif // !defined(_LIBCPP_CXX03_LANG) |
635 | |
636 | // is_const |
637 | |
638 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; |
639 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; |
640 | |
641 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
642 | template <class _Tp> |
643 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v |
644 | = is_const<_Tp>::value; |
645 | #endif |
646 | |
647 | // is_volatile |
648 | |
649 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; |
650 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; |
651 | |
652 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
653 | template <class _Tp> |
654 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v |
655 | = is_volatile<_Tp>::value; |
656 | #endif |
657 | |
658 | // remove_const |
659 | |
660 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; |
661 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; |
662 | #if _LIBCPP_STD_VER > 11 |
663 | template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; |
664 | #endif |
665 | |
666 | // remove_volatile |
667 | |
668 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; |
669 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; |
670 | #if _LIBCPP_STD_VER > 11 |
671 | template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; |
672 | #endif |
673 | |
674 | // remove_cv |
675 | |
676 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv |
677 | {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; |
678 | #if _LIBCPP_STD_VER > 11 |
679 | template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; |
680 | #endif |
681 | |
682 | // is_void |
683 | |
684 | template <class _Tp> struct __libcpp_is_void : public false_type {}; |
685 | template <> struct __libcpp_is_void<void> : public true_type {}; |
686 | |
687 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void |
688 | : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; |
689 | |
690 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
691 | template <class _Tp> |
692 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v |
693 | = is_void<_Tp>::value; |
694 | #endif |
695 | |
696 | // __is_nullptr_t |
697 | |
698 | template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; |
699 | template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; |
700 | |
701 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t |
702 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; |
703 | |
704 | #if _LIBCPP_STD_VER > 11 |
705 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer |
706 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; |
707 | |
708 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
709 | template <class _Tp> |
710 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v |
711 | = is_null_pointer<_Tp>::value; |
712 | #endif |
713 | #endif |
714 | |
715 | // is_integral |
716 | |
717 | template <class _Tp> struct __libcpp_is_integral : public false_type {}; |
718 | template <> struct __libcpp_is_integral<bool> : public true_type {}; |
719 | template <> struct __libcpp_is_integral<char> : public true_type {}; |
720 | template <> struct __libcpp_is_integral<signed char> : public true_type {}; |
721 | template <> struct __libcpp_is_integral<unsigned char> : public true_type {}; |
722 | template <> struct __libcpp_is_integral<wchar_t> : public true_type {}; |
723 | #ifndef _LIBCPP_NO_HAS_CHAR8_T |
724 | template <> struct __libcpp_is_integral<char8_t> : public true_type {}; |
725 | #endif |
726 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
727 | template <> struct __libcpp_is_integral<char16_t> : public true_type {}; |
728 | template <> struct __libcpp_is_integral<char32_t> : public true_type {}; |
729 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS |
730 | template <> struct __libcpp_is_integral<short> : public true_type {}; |
731 | template <> struct __libcpp_is_integral<unsigned short> : public true_type {}; |
732 | template <> struct __libcpp_is_integral<int> : public true_type {}; |
733 | template <> struct __libcpp_is_integral<unsigned int> : public true_type {}; |
734 | template <> struct __libcpp_is_integral<long> : public true_type {}; |
735 | template <> struct __libcpp_is_integral<unsigned long> : public true_type {}; |
736 | template <> struct __libcpp_is_integral<long long> : public true_type {}; |
737 | template <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; |
738 | #ifndef _LIBCPP_HAS_NO_INT128 |
739 | template <> struct __libcpp_is_integral<__int128_t> : public true_type {}; |
740 | template <> struct __libcpp_is_integral<__uint128_t> : public true_type {}; |
741 | #endif |
742 | |
743 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral |
744 | : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; |
745 | |
746 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
747 | template <class _Tp> |
748 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v |
749 | = is_integral<_Tp>::value; |
750 | #endif |
751 | |
752 | // is_floating_point |
753 | |
754 | template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; |
755 | template <> struct __libcpp_is_floating_point<float> : public true_type {}; |
756 | template <> struct __libcpp_is_floating_point<double> : public true_type {}; |
757 | template <> struct __libcpp_is_floating_point<long double> : public true_type {}; |
758 | |
759 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point |
760 | : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; |
761 | |
762 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
763 | template <class _Tp> |
764 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v |
765 | = is_floating_point<_Tp>::value; |
766 | #endif |
767 | |
768 | // is_array |
769 | |
770 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array |
771 | : public false_type {}; |
772 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> |
773 | : public true_type {}; |
774 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> |
775 | : public true_type {}; |
776 | |
777 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
778 | template <class _Tp> |
779 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v |
780 | = is_array<_Tp>::value; |
781 | #endif |
782 | |
783 | // is_pointer |
784 | |
785 | template <class _Tp> struct __libcpp_is_pointer : public false_type {}; |
786 | template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; |
787 | |
788 | template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; |
789 | #if defined(_LIBCPP_HAS_OBJC_ARC) |
790 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; |
791 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; |
792 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; |
793 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; |
794 | #endif |
795 | |
796 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer |
797 | : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {}; |
798 | |
799 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
800 | template <class _Tp> |
801 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v |
802 | = is_pointer<_Tp>::value; |
803 | #endif |
804 | |
805 | // is_reference |
806 | |
807 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; |
808 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; |
809 | |
810 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; |
811 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
812 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; |
813 | #endif |
814 | |
815 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; |
816 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; |
817 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
818 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; |
819 | #endif |
820 | |
821 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
822 | template <class _Tp> |
823 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v |
824 | = is_reference<_Tp>::value; |
825 | |
826 | template <class _Tp> |
827 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v |
828 | = is_lvalue_reference<_Tp>::value; |
829 | |
830 | template <class _Tp> |
831 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v |
832 | = is_rvalue_reference<_Tp>::value; |
833 | #endif |
834 | // is_union |
835 | |
836 | #if __has_feature(is_union) || (_GNUC_VER >= 403) |
837 | |
838 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union |
839 | : public integral_constant<bool, __is_union(_Tp)> {}; |
840 | |
841 | #else |
842 | |
843 | template <class _Tp> struct __libcpp_union : public false_type {}; |
844 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union |
845 | : public __libcpp_union<typename remove_cv<_Tp>::type> {}; |
846 | |
847 | #endif |
848 | |
849 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
850 | template <class _Tp> |
851 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v |
852 | = is_union<_Tp>::value; |
853 | #endif |
854 | |
855 | // is_class |
856 | |
857 | #if __has_feature(is_class) || (_GNUC_VER >= 403) |
858 | |
859 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class |
860 | : public integral_constant<bool, __is_class(_Tp)> {}; |
861 | |
862 | #else |
863 | |
864 | namespace __is_class_imp |
865 | { |
866 | template <class _Tp> char __test(int _Tp::*); |
867 | template <class _Tp> __two __test(...); |
868 | } |
869 | |
870 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class |
871 | : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; |
872 | |
873 | #endif |
874 | |
875 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
876 | template <class _Tp> |
877 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v |
878 | = is_class<_Tp>::value; |
879 | #endif |
880 | |
881 | // is_same |
882 | |
883 | template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; |
884 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; |
885 | |
886 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
887 | template <class _Tp, class _Up> |
888 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v |
889 | = is_same<_Tp, _Up>::value; |
890 | #endif |
891 | |
892 | // is_function |
893 | |
894 | namespace __libcpp_is_function_imp |
895 | { |
896 | struct __dummy_type {}; |
897 | template <class _Tp> char __test(_Tp*); |
898 | template <class _Tp> char __test(__dummy_type); |
899 | template <class _Tp> __two __test(...); |
900 | template <class _Tp> _Tp& __source(int); |
901 | template <class _Tp> __dummy_type __source(...); |
902 | } |
903 | |
904 | template <class _Tp, bool = is_class<_Tp>::value || |
905 | is_union<_Tp>::value || |
906 | is_void<_Tp>::value || |
907 | is_reference<_Tp>::value || |
908 | __is_nullptr_t<_Tp>::value > |
909 | struct __libcpp_is_function |
910 | : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1> |
911 | {}; |
912 | template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {}; |
913 | |
914 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function |
915 | : public __libcpp_is_function<_Tp> {}; |
916 | |
917 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
918 | template <class _Tp> |
919 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v |
920 | = is_function<_Tp>::value; |
921 | #endif |
922 | |
923 | // is_member_function_pointer |
924 | |
925 | // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {}; |
926 | // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; |
927 | // |
928 | |
929 | template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> |
930 | struct __member_pointer_traits_imp |
931 | { // forward declaration; specializations later |
932 | }; |
933 | |
934 | |
935 | template <class _Tp> struct __libcpp_is_member_function_pointer |
936 | : public false_type {}; |
937 | |
938 | template <class _Ret, class _Class> |
939 | struct __libcpp_is_member_function_pointer<_Ret _Class::*> |
940 | : public is_function<_Ret> {}; |
941 | |
942 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer |
943 | : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {}; |
944 | |
945 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
946 | template <class _Tp> |
947 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v |
948 | = is_member_function_pointer<_Tp>::value; |
949 | #endif |
950 | |
951 | // is_member_pointer |
952 | |
953 | template <class _Tp> struct __libcpp_is_member_pointer : public false_type {}; |
954 | template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; |
955 | |
956 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer |
957 | : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {}; |
958 | |
959 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
960 | template <class _Tp> |
961 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v |
962 | = is_member_pointer<_Tp>::value; |
963 | #endif |
964 | |
965 | // is_member_object_pointer |
966 | |
967 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer |
968 | : public integral_constant<bool, is_member_pointer<_Tp>::value && |
969 | !is_member_function_pointer<_Tp>::value> {}; |
970 | |
971 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
972 | template <class _Tp> |
973 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v |
974 | = is_member_object_pointer<_Tp>::value; |
975 | #endif |
976 | |
977 | // is_enum |
978 | |
979 | #if __has_feature(is_enum) || (_GNUC_VER >= 403) |
980 | |
981 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
982 | : public integral_constant<bool, __is_enum(_Tp)> {}; |
983 | |
984 | #else |
985 | |
986 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
987 | : public integral_constant<bool, !is_void<_Tp>::value && |
988 | !is_integral<_Tp>::value && |
989 | !is_floating_point<_Tp>::value && |
990 | !is_array<_Tp>::value && |
991 | !is_pointer<_Tp>::value && |
992 | !is_reference<_Tp>::value && |
993 | !is_member_pointer<_Tp>::value && |
994 | !is_union<_Tp>::value && |
995 | !is_class<_Tp>::value && |
996 | !is_function<_Tp>::value > {}; |
997 | |
998 | #endif |
999 | |
1000 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1001 | template <class _Tp> |
1002 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v |
1003 | = is_enum<_Tp>::value; |
1004 | #endif |
1005 | |
1006 | // is_arithmetic |
1007 | |
1008 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic |
1009 | : public integral_constant<bool, is_integral<_Tp>::value || |
1010 | is_floating_point<_Tp>::value> {}; |
1011 | |
1012 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1013 | template <class _Tp> |
1014 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v |
1015 | = is_arithmetic<_Tp>::value; |
1016 | #endif |
1017 | |
1018 | // is_fundamental |
1019 | |
1020 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental |
1021 | : public integral_constant<bool, is_void<_Tp>::value || |
1022 | __is_nullptr_t<_Tp>::value || |
1023 | is_arithmetic<_Tp>::value> {}; |
1024 | |
1025 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1026 | template <class _Tp> |
1027 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v |
1028 | = is_fundamental<_Tp>::value; |
1029 | #endif |
1030 | |
1031 | // is_scalar |
1032 | |
1033 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar |
1034 | : public integral_constant<bool, is_arithmetic<_Tp>::value || |
1035 | is_member_pointer<_Tp>::value || |
1036 | is_pointer<_Tp>::value || |
1037 | __is_nullptr_t<_Tp>::value || |
1038 | is_enum<_Tp>::value > {}; |
1039 | |
1040 | template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; |
1041 | |
1042 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1043 | template <class _Tp> |
1044 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v |
1045 | = is_scalar<_Tp>::value; |
1046 | #endif |
1047 | |
1048 | // is_object |
1049 | |
1050 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object |
1051 | : public integral_constant<bool, is_scalar<_Tp>::value || |
1052 | is_array<_Tp>::value || |
1053 | is_union<_Tp>::value || |
1054 | is_class<_Tp>::value > {}; |
1055 | |
1056 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1057 | template <class _Tp> |
1058 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v |
1059 | = is_object<_Tp>::value; |
1060 | #endif |
1061 | |
1062 | // is_compound |
1063 | |
1064 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound |
1065 | : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; |
1066 | |
1067 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1068 | template <class _Tp> |
1069 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v |
1070 | = is_compound<_Tp>::value; |
1071 | #endif |
1072 | |
1073 | |
1074 | // __is_referenceable [defns.referenceable] |
1075 | |
1076 | struct __is_referenceable_impl { |
1077 | template <class _Tp> static _Tp& __test(int); |
1078 | template <class _Tp> static __two __test(...); |
1079 | }; |
1080 | |
1081 | template <class _Tp> |
1082 | struct __is_referenceable : integral_constant<bool, |
1083 | !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {}; |
1084 | |
1085 | |
1086 | // add_const |
1087 | |
1088 | template <class _Tp, bool = is_reference<_Tp>::value || |
1089 | is_function<_Tp>::value || |
1090 | is_const<_Tp>::value > |
1091 | struct __add_const {typedef _Tp type;}; |
1092 | |
1093 | template <class _Tp> |
1094 | struct __add_const<_Tp, false> {typedef const _Tp type;}; |
1095 | |
1096 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const |
1097 | {typedef typename __add_const<_Tp>::type type;}; |
1098 | |
1099 | #if _LIBCPP_STD_VER > 11 |
1100 | template <class _Tp> using add_const_t = typename add_const<_Tp>::type; |
1101 | #endif |
1102 | |
1103 | // add_volatile |
1104 | |
1105 | template <class _Tp, bool = is_reference<_Tp>::value || |
1106 | is_function<_Tp>::value || |
1107 | is_volatile<_Tp>::value > |
1108 | struct __add_volatile {typedef _Tp type;}; |
1109 | |
1110 | template <class _Tp> |
1111 | struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; |
1112 | |
1113 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile |
1114 | {typedef typename __add_volatile<_Tp>::type type;}; |
1115 | |
1116 | #if _LIBCPP_STD_VER > 11 |
1117 | template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; |
1118 | #endif |
1119 | |
1120 | // add_cv |
1121 | |
1122 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv |
1123 | {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;}; |
1124 | |
1125 | #if _LIBCPP_STD_VER > 11 |
1126 | template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; |
1127 | #endif |
1128 | |
1129 | // remove_reference |
1130 | |
1131 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;}; |
1132 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;}; |
1133 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
1134 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;}; |
1135 | #endif |
1136 | |
1137 | #if _LIBCPP_STD_VER > 11 |
1138 | template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; |
1139 | #endif |
1140 | |
1141 | // add_lvalue_reference |
1142 | |
1143 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; }; |
1144 | template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; }; |
1145 | |
1146 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference |
1147 | {typedef typename __add_lvalue_reference_impl<_Tp>::type type;}; |
1148 | |
1149 | #if _LIBCPP_STD_VER > 11 |
1150 | template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; |
1151 | #endif |
1152 | |
1153 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
1154 | |
1155 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; }; |
1156 | template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; }; |
1157 | |
1158 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference |
1159 | {typedef typename __add_rvalue_reference_impl<_Tp>::type type;}; |
1160 | |
1161 | #if _LIBCPP_STD_VER > 11 |
1162 | template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; |
1163 | #endif |
1164 | |
1165 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
1166 | |
1167 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
1168 | |
1169 | template <class _Tp> _Tp&& __declval(int); |
1170 | template <class _Tp> _Tp __declval(long); |
1171 | |
1172 | template <class _Tp> |
1173 | decltype(_VSTD::__declval<_Tp>(0)) |
1174 | declval() _NOEXCEPT; |
1175 | |
1176 | #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
1177 | |
1178 | template <class _Tp> |
1179 | typename add_lvalue_reference<_Tp>::type |
1180 | declval(); |
1181 | |
1182 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
1183 | |
1184 | // __uncvref |
1185 | |
1186 | template <class _Tp> |
1187 | struct __uncvref { |
1188 | typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type; |
1189 | }; |
1190 | |
1191 | template <class _Tp> |
1192 | struct __unconstref { |
1193 | typedef typename remove_const<typename remove_reference<_Tp>::type>::type type; |
1194 | }; |
1195 | |
1196 | #ifndef _LIBCPP_CXX03_LANG |
1197 | template <class _Tp> |
1198 | using __uncvref_t = typename __uncvref<_Tp>::type; |
1199 | #endif |
1200 | |
1201 | // __is_same_uncvref |
1202 | |
1203 | template <class _Tp, class _Up> |
1204 | struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type, |
1205 | typename __uncvref<_Up>::type> {}; |
1206 | |
1207 | #if _LIBCPP_STD_VER > 17 |
1208 | // remove_cvref - same as __uncvref |
1209 | template <class _Tp> |
1210 | struct remove_cvref : public __uncvref<_Tp> {}; |
1211 | |
1212 | template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; |
1213 | #endif |
1214 | |
1215 | |
1216 | struct __any |
1217 | { |
1218 | __any(...); |
1219 | }; |
1220 | |
1221 | // remove_pointer |
1222 | |
1223 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;}; |
1224 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;}; |
1225 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;}; |
1226 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;}; |
1227 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;}; |
1228 | |
1229 | #if _LIBCPP_STD_VER > 11 |
1230 | template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; |
1231 | #endif |
1232 | |
1233 | // add_pointer |
1234 | |
1235 | template <class _Tp, |
1236 | bool = __is_referenceable<_Tp>::value || |
1237 | is_same<typename remove_cv<_Tp>::type, void>::value> |
1238 | struct __add_pointer_impl |
1239 | {typedef typename remove_reference<_Tp>::type* type;}; |
1240 | template <class _Tp> struct __add_pointer_impl<_Tp, false> |
1241 | {typedef _Tp type;}; |
1242 | |
1243 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer |
1244 | {typedef typename __add_pointer_impl<_Tp>::type type;}; |
1245 | |
1246 | #if _LIBCPP_STD_VER > 11 |
1247 | template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; |
1248 | #endif |
1249 | |
1250 | // type_identity |
1251 | #if _LIBCPP_STD_VER > 17 |
1252 | template<class _Tp> struct type_identity { typedef _Tp type; }; |
1253 | template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; |
1254 | #endif |
1255 | |
1256 | // is_signed |
1257 | |
1258 | template <class _Tp, bool = is_integral<_Tp>::value> |
1259 | struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; |
1260 | |
1261 | template <class _Tp> |
1262 | struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point |
1263 | |
1264 | template <class _Tp, bool = is_arithmetic<_Tp>::value> |
1265 | struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; |
1266 | |
1267 | template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; |
1268 | |
1269 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_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_signed_v |
1274 | = is_signed<_Tp>::value; |
1275 | #endif |
1276 | |
1277 | // is_unsigned |
1278 | |
1279 | template <class _Tp, bool = is_integral<_Tp>::value> |
1280 | struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; |
1281 | |
1282 | template <class _Tp> |
1283 | struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point |
1284 | |
1285 | template <class _Tp, bool = is_arithmetic<_Tp>::value> |
1286 | struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; |
1287 | |
1288 | template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; |
1289 | |
1290 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; |
1291 | |
1292 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1293 | template <class _Tp> |
1294 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v |
1295 | = is_unsigned<_Tp>::value; |
1296 | #endif |
1297 | |
1298 | // rank |
1299 | |
1300 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank |
1301 | : public integral_constant<size_t, 0> {}; |
1302 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> |
1303 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
1304 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> |
1305 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
1306 | |
1307 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1308 | template <class _Tp> |
1309 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v |
1310 | = rank<_Tp>::value; |
1311 | #endif |
1312 | |
1313 | // extent |
1314 | |
1315 | template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent |
1316 | : public integral_constant<size_t, 0> {}; |
1317 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> |
1318 | : public integral_constant<size_t, 0> {}; |
1319 | template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> |
1320 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; |
1321 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> |
1322 | : public integral_constant<size_t, _Np> {}; |
1323 | template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> |
1324 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; |
1325 | |
1326 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1327 | template <class _Tp, unsigned _Ip = 0> |
1328 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v |
1329 | = extent<_Tp, _Ip>::value; |
1330 | #endif |
1331 | |
1332 | // remove_extent |
1333 | |
1334 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent |
1335 | {typedef _Tp type;}; |
1336 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> |
1337 | {typedef _Tp type;}; |
1338 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> |
1339 | {typedef _Tp type;}; |
1340 | |
1341 | #if _LIBCPP_STD_VER > 11 |
1342 | template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; |
1343 | #endif |
1344 | |
1345 | // remove_all_extents |
1346 | |
1347 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents |
1348 | {typedef _Tp type;}; |
1349 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> |
1350 | {typedef typename remove_all_extents<_Tp>::type type;}; |
1351 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> |
1352 | {typedef typename remove_all_extents<_Tp>::type type;}; |
1353 | |
1354 | #if _LIBCPP_STD_VER > 11 |
1355 | template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; |
1356 | #endif |
1357 | |
1358 | #if _LIBCPP_STD_VER > 17 |
1359 | // is_bounded_array |
1360 | |
1361 | template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; |
1362 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; |
1363 | |
1364 | template <class _Tp> |
1365 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR |
1366 | bool is_bounded_array_v = is_bounded_array<_Tp>::value; |
1367 | |
1368 | // is_unbounded_array |
1369 | |
1370 | template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; |
1371 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; |
1372 | |
1373 | template <class _Tp> |
1374 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR |
1375 | bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; |
1376 | #endif |
1377 | |
1378 | // decay |
1379 | |
1380 | template <class _Up, bool> |
1381 | struct __decay { |
1382 | typedef typename remove_cv<_Up>::type type; |
1383 | }; |
1384 | |
1385 | template <class _Up> |
1386 | struct __decay<_Up, true> { |
1387 | public: |
1388 | typedef typename conditional |
1389 | < |
1390 | is_array<_Up>::value, |
1391 | typename remove_extent<_Up>::type*, |
1392 | typename conditional |
1393 | < |
1394 | is_function<_Up>::value, |
1395 | typename add_pointer<_Up>::type, |
1396 | typename remove_cv<_Up>::type |
1397 | >::type |
1398 | >::type type; |
1399 | }; |
1400 | |
1401 | template <class _Tp> |
1402 | struct _LIBCPP_TEMPLATE_VIS decay |
1403 | { |
1404 | private: |
1405 | typedef typename remove_reference<_Tp>::type _Up; |
1406 | public: |
1407 | typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type; |
1408 | }; |
1409 | |
1410 | #if _LIBCPP_STD_VER > 11 |
1411 | template <class _Tp> using decay_t = typename decay<_Tp>::type; |
1412 | #endif |
1413 | |
1414 | // is_abstract |
1415 | |
1416 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract |
1417 | : public integral_constant<bool, __is_abstract(_Tp)> {}; |
1418 | |
1419 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1420 | template <class _Tp> |
1421 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v |
1422 | = is_abstract<_Tp>::value; |
1423 | #endif |
1424 | |
1425 | // is_final |
1426 | |
1427 | #if defined(_LIBCPP_HAS_IS_FINAL) |
1428 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
1429 | __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {}; |
1430 | #else |
1431 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
1432 | __libcpp_is_final : public false_type {}; |
1433 | #endif |
1434 | |
1435 | #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11 |
1436 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
1437 | is_final : public integral_constant<bool, __is_final(_Tp)> {}; |
1438 | #endif |
1439 | |
1440 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1441 | template <class _Tp> |
1442 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v |
1443 | = is_final<_Tp>::value; |
1444 | #endif |
1445 | |
1446 | // is_aggregate |
1447 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) |
1448 | |
1449 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
1450 | is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; |
1451 | |
1452 | #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1453 | template <class _Tp> |
1454 | _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v |
1455 | = is_aggregate<_Tp>::value; |
1456 | #endif |
1457 | |
1458 | #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) |
1459 | |
1460 | // is_base_of |
1461 | |
1462 | #ifdef _LIBCPP_HAS_IS_BASE_OF |
1463 | |
1464 | template <class _Bp, class _Dp> |
1465 | struct _LIBCPP_TEMPLATE_VIS is_base_of |
1466 | : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; |
1467 | |
1468 | #else // _LIBCPP_HAS_IS_BASE_OF |
1469 | |
1470 | namespace __is_base_of_imp |
1471 | { |
1472 | template <class _Tp> |
1473 | struct _Dst |
1474 | { |
1475 | _Dst(const volatile _Tp &); |
1476 | }; |
1477 | template <class _Tp> |
1478 | struct _Src |
1479 | { |
1480 | operator const volatile _Tp &(); |
1481 | template <class _Up> operator const _Dst<_Up> &(); |
1482 | }; |
1483 | template <size_t> struct __one { typedef char type; }; |
1484 | template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int); |
1485 | template <class _Bp, class _Dp> __two __test(...); |
1486 | } |
1487 | |
1488 | template <class _Bp, class _Dp> |
1489 | struct _LIBCPP_TEMPLATE_VIS is_base_of |
1490 | : public integral_constant<bool, is_class<_Bp>::value && |
1491 | sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; |
1492 | |
1493 | #endif // _LIBCPP_HAS_IS_BASE_OF |
1494 | |
1495 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1496 | template <class _Bp, class _Dp> |
1497 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v |
1498 | = is_base_of<_Bp, _Dp>::value; |
1499 | #endif |
1500 | |
1501 | // is_convertible |
1502 | |
1503 | #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) |
1504 | |
1505 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible |
1506 | : public integral_constant<bool, __is_convertible_to(_T1, _T2) && |
1507 | !is_abstract<_T2>::value> {}; |
1508 | |
1509 | #else // __has_feature(is_convertible_to) |
1510 | |
1511 | namespace __is_convertible_imp |
1512 | { |
1513 | template <class _Tp> void __test_convert(_Tp); |
1514 | |
1515 | template <class _From, class _To, class = void> |
1516 | struct __is_convertible_test : public false_type {}; |
1517 | |
1518 | template <class _From, class _To> |
1519 | struct __is_convertible_test<_From, _To, |
1520 | decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type |
1521 | {}; |
1522 | |
1523 | template <class _Tp, bool _IsArray = is_array<_Tp>::value, |
1524 | bool _IsFunction = is_function<_Tp>::value, |
1525 | bool _IsVoid = is_void<_Tp>::value> |
1526 | struct __is_array_function_or_void {enum {value = 0};}; |
1527 | template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; |
1528 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; |
1529 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; |
1530 | } |
1531 | |
1532 | template <class _Tp, |
1533 | unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> |
1534 | struct __is_convertible_check |
1535 | { |
1536 | static const size_t __v = 0; |
1537 | }; |
1538 | |
1539 | template <class _Tp> |
1540 | struct __is_convertible_check<_Tp, 0> |
1541 | { |
1542 | static const size_t __v = sizeof(_Tp); |
1543 | }; |
1544 | |
1545 | template <class _T1, class _T2, |
1546 | unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, |
1547 | unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> |
1548 | struct __is_convertible |
1549 | : public integral_constant<bool, |
1550 | __is_convertible_imp::__is_convertible_test<_T1, _T2>::value |
1551 | #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) |
1552 | && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value |
1553 | && (!is_const<typename remove_reference<_T2>::type>::value |
1554 | || is_volatile<typename remove_reference<_T2>::type>::value) |
1555 | && (is_same<typename remove_cv<_T1>::type, |
1556 | typename remove_cv<typename remove_reference<_T2>::type>::type>::value |
1557 | || is_base_of<typename remove_reference<_T2>::type, _T1>::value)) |
1558 | #endif |
1559 | > |
1560 | {}; |
1561 | |
1562 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; |
1563 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; |
1564 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; |
1565 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; |
1566 | |
1567 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; |
1568 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; |
1569 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; |
1570 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; |
1571 | |
1572 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; |
1573 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; |
1574 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; |
1575 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; |
1576 | |
1577 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible |
1578 | : public __is_convertible<_T1, _T2> |
1579 | { |
1580 | static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; |
1581 | static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; |
1582 | }; |
1583 | |
1584 | #endif // __has_feature(is_convertible_to) |
1585 | |
1586 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1587 | template <class _From, class _To> |
1588 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v |
1589 | = is_convertible<_From, _To>::value; |
1590 | #endif |
1591 | |
1592 | // is_nothrow_convertible |
1593 | |
1594 | #if _LIBCPP_STD_VER > 17 |
1595 | |
1596 | template <typename _Tp> |
1597 | static void __test_noexcept(_Tp) noexcept; |
1598 | |
1599 | template<typename _Fm, typename _To> |
1600 | static bool_constant<noexcept(__test_noexcept<_To>(declval<_Fm>()))> |
1601 | __is_nothrow_convertible_test(); |
1602 | |
1603 | template <typename _Fm, typename _To> |
1604 | struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) |
1605 | { }; |
1606 | |
1607 | template <typename _Fm, typename _To> |
1608 | struct is_nothrow_convertible : __or_< |
1609 | __and_<is_void<_To>, is_void<_Fm>>, |
1610 | __and_<is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> |
1611 | >::type { }; |
1612 | |
1613 | template <typename _Fm, typename _To> |
1614 | inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; |
1615 | |
1616 | #endif // _LIBCPP_STD_VER > 17 |
1617 | |
1618 | // is_empty |
1619 | |
1620 | #if __has_feature(is_empty) || (_GNUC_VER >= 407) |
1621 | |
1622 | template <class _Tp> |
1623 | struct _LIBCPP_TEMPLATE_VIS is_empty |
1624 | : public integral_constant<bool, __is_empty(_Tp)> {}; |
1625 | |
1626 | #else // __has_feature(is_empty) |
1627 | |
1628 | template <class _Tp> |
1629 | struct __is_empty1 |
1630 | : public _Tp |
1631 | { |
1632 | double __lx; |
1633 | }; |
1634 | |
1635 | struct __is_empty2 |
1636 | { |
1637 | double __lx; |
1638 | }; |
1639 | |
1640 | template <class _Tp, bool = is_class<_Tp>::value> |
1641 | struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; |
1642 | |
1643 | template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; |
1644 | |
1645 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {}; |
1646 | |
1647 | #endif // __has_feature(is_empty) |
1648 | |
1649 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1650 | template <class _Tp> |
1651 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v |
1652 | = is_empty<_Tp>::value; |
1653 | #endif |
1654 | |
1655 | // is_polymorphic |
1656 | |
1657 | #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC) |
1658 | |
1659 | template <class _Tp> |
1660 | struct _LIBCPP_TEMPLATE_VIS is_polymorphic |
1661 | : public integral_constant<bool, __is_polymorphic(_Tp)> {}; |
1662 | |
1663 | #else |
1664 | |
1665 | template<typename _Tp> char &__is_polymorphic_impl( |
1666 | typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, |
1667 | int>::type); |
1668 | template<typename _Tp> __two &__is_polymorphic_impl(...); |
1669 | |
1670 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic |
1671 | : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; |
1672 | |
1673 | #endif // __has_feature(is_polymorphic) |
1674 | |
1675 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1676 | template <class _Tp> |
1677 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v |
1678 | = is_polymorphic<_Tp>::value; |
1679 | #endif |
1680 | |
1681 | // has_virtual_destructor |
1682 | |
1683 | #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403) |
1684 | |
1685 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor |
1686 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; |
1687 | |
1688 | #else |
1689 | |
1690 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor |
1691 | : public false_type {}; |
1692 | |
1693 | #endif |
1694 | |
1695 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1696 | template <class _Tp> |
1697 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v |
1698 | = has_virtual_destructor<_Tp>::value; |
1699 | #endif |
1700 | |
1701 | // has_unique_object_representations |
1702 | |
1703 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) |
1704 | |
1705 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations |
1706 | : public integral_constant<bool, |
1707 | __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; |
1708 | |
1709 | #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1710 | template <class _Tp> |
1711 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v |
1712 | = has_unique_object_representations<_Tp>::value; |
1713 | #endif |
1714 | |
1715 | #endif |
1716 | |
1717 | // alignment_of |
1718 | |
1719 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of |
1720 | : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; |
1721 | |
1722 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
1723 | template <class _Tp> |
1724 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v |
1725 | = alignment_of<_Tp>::value; |
1726 | #endif |
1727 | |
1728 | // aligned_storage |
1729 | |
1730 | template <class _Hp, class _Tp> |
1731 | struct __type_list |
1732 | { |
1733 | typedef _Hp _Head; |
1734 | typedef _Tp _Tail; |
1735 | }; |
1736 | |
1737 | struct __nat |
1738 | { |
1739 | #ifndef _LIBCPP_CXX03_LANG |
1740 | __nat() = delete; |
1741 | __nat(const __nat&) = delete; |
1742 | __nat& operator=(const __nat&) = delete; |
1743 | ~__nat() = delete; |
1744 | #endif |
1745 | }; |
1746 | |
1747 | template <class _Tp> |
1748 | struct __align_type |
1749 | { |
1750 | static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); |
1751 | typedef _Tp type; |
1752 | }; |
1753 | |
1754 | struct __struct_double {long double __lx;}; |
1755 | struct __struct_double4 {double __lx[4];}; |
1756 | |
1757 | typedef |
1758 | __type_list<__align_type<unsigned char>, |
1759 | __type_list<__align_type<unsigned short>, |
1760 | __type_list<__align_type<unsigned int>, |
1761 | __type_list<__align_type<unsigned long>, |
1762 | __type_list<__align_type<unsigned long long>, |
1763 | __type_list<__align_type<double>, |
1764 | __type_list<__align_type<long double>, |
1765 | __type_list<__align_type<__struct_double>, |
1766 | __type_list<__align_type<__struct_double4>, |
1767 | __type_list<__align_type<int*>, |
1768 | __nat |
1769 | > > > > > > > > > > __all_types; |
1770 | |
1771 | template <class _TL, size_t _Align> struct __find_pod; |
1772 | |
1773 | template <class _Hp, size_t _Align> |
1774 | struct __find_pod<__type_list<_Hp, __nat>, _Align> |
1775 | { |
1776 | typedef typename conditional< |
1777 | _Align == _Hp::value, |
1778 | typename _Hp::type, |
1779 | void |
1780 | >::type type; |
1781 | }; |
1782 | |
1783 | template <class _Hp, class _Tp, size_t _Align> |
1784 | struct __find_pod<__type_list<_Hp, _Tp>, _Align> |
1785 | { |
1786 | typedef typename conditional< |
1787 | _Align == _Hp::value, |
1788 | typename _Hp::type, |
1789 | typename __find_pod<_Tp, _Align>::type |
1790 | >::type type; |
1791 | }; |
1792 | |
1793 | template <class _TL, size_t _Len> struct __find_max_align; |
1794 | |
1795 | template <class _Hp, size_t _Len> |
1796 | struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; |
1797 | |
1798 | template <size_t _Len, size_t _A1, size_t _A2> |
1799 | struct __select_align |
1800 | { |
1801 | private: |
1802 | static const size_t __min = _A2 < _A1 ? _A2 : _A1; |
1803 | static const size_t __max = _A1 < _A2 ? _A2 : _A1; |
1804 | public: |
1805 | static const size_t value = _Len < __max ? __min : __max; |
1806 | }; |
1807 | |
1808 | template <class _Hp, class _Tp, size_t _Len> |
1809 | struct __find_max_align<__type_list<_Hp, _Tp>, _Len> |
1810 | : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; |
1811 | |
1812 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
1813 | struct _LIBCPP_TEMPLATE_VIS aligned_storage |
1814 | { |
1815 | typedef typename __find_pod<__all_types, _Align>::type _Aligner; |
1816 | static_assert(!is_void<_Aligner>::value, "" ); |
1817 | union type |
1818 | { |
1819 | _Aligner __align; |
1820 | unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; |
1821 | }; |
1822 | }; |
1823 | |
1824 | #if _LIBCPP_STD_VER > 11 |
1825 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
1826 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; |
1827 | #endif |
1828 | |
1829 | #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ |
1830 | template <size_t _Len>\ |
1831 | struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ |
1832 | {\ |
1833 | struct _ALIGNAS(n) type\ |
1834 | {\ |
1835 | unsigned char __lx[(_Len + n - 1)/n * n];\ |
1836 | };\ |
1837 | } |
1838 | |
1839 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); |
1840 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); |
1841 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); |
1842 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); |
1843 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); |
1844 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); |
1845 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); |
1846 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); |
1847 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); |
1848 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); |
1849 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); |
1850 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); |
1851 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); |
1852 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); |
1853 | // PE/COFF does not support alignment beyond 8192 (=0x2000) |
1854 | #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
1855 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); |
1856 | #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
1857 | |
1858 | #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION |
1859 | |
1860 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
1861 | |
1862 | // aligned_union |
1863 | |
1864 | template <size_t _I0, size_t ..._In> |
1865 | struct __static_max; |
1866 | |
1867 | template <size_t _I0> |
1868 | struct __static_max<_I0> |
1869 | { |
1870 | static const size_t value = _I0; |
1871 | }; |
1872 | |
1873 | template <size_t _I0, size_t _I1, size_t ..._In> |
1874 | struct __static_max<_I0, _I1, _In...> |
1875 | { |
1876 | static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : |
1877 | __static_max<_I1, _In...>::value; |
1878 | }; |
1879 | |
1880 | template <size_t _Len, class _Type0, class ..._Types> |
1881 | struct aligned_union |
1882 | { |
1883 | static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), |
1884 | _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; |
1885 | static const size_t __len = __static_max<_Len, sizeof(_Type0), |
1886 | sizeof(_Types)...>::value; |
1887 | typedef typename aligned_storage<__len, alignment_value>::type type; |
1888 | }; |
1889 | |
1890 | #if _LIBCPP_STD_VER > 11 |
1891 | template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; |
1892 | #endif |
1893 | |
1894 | #endif // _LIBCPP_HAS_NO_VARIADICS |
1895 | |
1896 | template <class _Tp> |
1897 | struct __numeric_type |
1898 | { |
1899 | static void __test(...); |
1900 | static float __test(float); |
1901 | static double __test(char); |
1902 | static double __test(int); |
1903 | static double __test(unsigned); |
1904 | static double __test(long); |
1905 | static double __test(unsigned long); |
1906 | static double __test(long long); |
1907 | static double __test(unsigned long long); |
1908 | static double __test(double); |
1909 | static long double __test(long double); |
1910 | |
1911 | typedef decltype(__test(declval<_Tp>())) type; |
1912 | static const bool value = !is_same<type, void>::value; |
1913 | }; |
1914 | |
1915 | template <> |
1916 | struct __numeric_type<void> |
1917 | { |
1918 | static const bool value = true; |
1919 | }; |
1920 | |
1921 | // __promote |
1922 | |
1923 | template <class _A1, class _A2 = void, class _A3 = void, |
1924 | bool = __numeric_type<_A1>::value && |
1925 | __numeric_type<_A2>::value && |
1926 | __numeric_type<_A3>::value> |
1927 | class __promote_imp |
1928 | { |
1929 | public: |
1930 | static const bool value = false; |
1931 | }; |
1932 | |
1933 | template <class _A1, class _A2, class _A3> |
1934 | class __promote_imp<_A1, _A2, _A3, true> |
1935 | { |
1936 | private: |
1937 | typedef typename __promote_imp<_A1>::type __type1; |
1938 | typedef typename __promote_imp<_A2>::type __type2; |
1939 | typedef typename __promote_imp<_A3>::type __type3; |
1940 | public: |
1941 | typedef decltype(__type1() + __type2() + __type3()) type; |
1942 | static const bool value = true; |
1943 | }; |
1944 | |
1945 | template <class _A1, class _A2> |
1946 | class __promote_imp<_A1, _A2, void, true> |
1947 | { |
1948 | private: |
1949 | typedef typename __promote_imp<_A1>::type __type1; |
1950 | typedef typename __promote_imp<_A2>::type __type2; |
1951 | public: |
1952 | typedef decltype(__type1() + __type2()) type; |
1953 | static const bool value = true; |
1954 | }; |
1955 | |
1956 | template <class _A1> |
1957 | class __promote_imp<_A1, void, void, true> |
1958 | { |
1959 | public: |
1960 | typedef typename __numeric_type<_A1>::type type; |
1961 | static const bool value = true; |
1962 | }; |
1963 | |
1964 | template <class _A1, class _A2 = void, class _A3 = void> |
1965 | class __promote : public __promote_imp<_A1, _A2, _A3> {}; |
1966 | |
1967 | // make_signed / make_unsigned |
1968 | |
1969 | typedef |
1970 | __type_list<signed char, |
1971 | __type_list<signed short, |
1972 | __type_list<signed int, |
1973 | __type_list<signed long, |
1974 | __type_list<signed long long, |
1975 | #ifndef _LIBCPP_HAS_NO_INT128 |
1976 | __type_list<__int128_t, |
1977 | #endif |
1978 | __nat |
1979 | #ifndef _LIBCPP_HAS_NO_INT128 |
1980 | > |
1981 | #endif |
1982 | > > > > > __signed_types; |
1983 | |
1984 | typedef |
1985 | __type_list<unsigned char, |
1986 | __type_list<unsigned short, |
1987 | __type_list<unsigned int, |
1988 | __type_list<unsigned long, |
1989 | __type_list<unsigned long long, |
1990 | #ifndef _LIBCPP_HAS_NO_INT128 |
1991 | __type_list<__uint128_t, |
1992 | #endif |
1993 | __nat |
1994 | #ifndef _LIBCPP_HAS_NO_INT128 |
1995 | > |
1996 | #endif |
1997 | > > > > > __unsigned_types; |
1998 | |
1999 | template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; |
2000 | |
2001 | template <class _Hp, class _Tp, size_t _Size> |
2002 | struct __find_first<__type_list<_Hp, _Tp>, _Size, true> |
2003 | { |
2004 | typedef _Hp type; |
2005 | }; |
2006 | |
2007 | template <class _Hp, class _Tp, size_t _Size> |
2008 | struct __find_first<__type_list<_Hp, _Tp>, _Size, false> |
2009 | { |
2010 | typedef typename __find_first<_Tp, _Size>::type type; |
2011 | }; |
2012 | |
2013 | template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, |
2014 | bool = is_volatile<typename remove_reference<_Tp>::type>::value> |
2015 | struct __apply_cv |
2016 | { |
2017 | typedef _Up type; |
2018 | }; |
2019 | |
2020 | template <class _Tp, class _Up> |
2021 | struct __apply_cv<_Tp, _Up, true, false> |
2022 | { |
2023 | typedef const _Up type; |
2024 | }; |
2025 | |
2026 | template <class _Tp, class _Up> |
2027 | struct __apply_cv<_Tp, _Up, false, true> |
2028 | { |
2029 | typedef volatile _Up type; |
2030 | }; |
2031 | |
2032 | template <class _Tp, class _Up> |
2033 | struct __apply_cv<_Tp, _Up, true, true> |
2034 | { |
2035 | typedef const volatile _Up type; |
2036 | }; |
2037 | |
2038 | template <class _Tp, class _Up> |
2039 | struct __apply_cv<_Tp&, _Up, false, false> |
2040 | { |
2041 | typedef _Up& type; |
2042 | }; |
2043 | |
2044 | template <class _Tp, class _Up> |
2045 | struct __apply_cv<_Tp&, _Up, true, false> |
2046 | { |
2047 | typedef const _Up& type; |
2048 | }; |
2049 | |
2050 | template <class _Tp, class _Up> |
2051 | struct __apply_cv<_Tp&, _Up, false, true> |
2052 | { |
2053 | typedef volatile _Up& type; |
2054 | }; |
2055 | |
2056 | template <class _Tp, class _Up> |
2057 | struct __apply_cv<_Tp&, _Up, true, true> |
2058 | { |
2059 | typedef const volatile _Up& type; |
2060 | }; |
2061 | |
2062 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
2063 | struct __make_signed {}; |
2064 | |
2065 | template <class _Tp> |
2066 | struct __make_signed<_Tp, true> |
2067 | { |
2068 | typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; |
2069 | }; |
2070 | |
2071 | template <> struct __make_signed<bool, true> {}; |
2072 | template <> struct __make_signed< signed short, true> {typedef short type;}; |
2073 | template <> struct __make_signed<unsigned short, true> {typedef short type;}; |
2074 | template <> struct __make_signed< signed int, true> {typedef int type;}; |
2075 | template <> struct __make_signed<unsigned int, true> {typedef int type;}; |
2076 | template <> struct __make_signed< signed long, true> {typedef long type;}; |
2077 | template <> struct __make_signed<unsigned long, true> {typedef long type;}; |
2078 | template <> struct __make_signed< signed long long, true> {typedef long long type;}; |
2079 | template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; |
2080 | #ifndef _LIBCPP_HAS_NO_INT128 |
2081 | template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; |
2082 | template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; |
2083 | #endif |
2084 | |
2085 | template <class _Tp> |
2086 | struct _LIBCPP_TEMPLATE_VIS make_signed |
2087 | { |
2088 | typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; |
2089 | }; |
2090 | |
2091 | #if _LIBCPP_STD_VER > 11 |
2092 | template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; |
2093 | #endif |
2094 | |
2095 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
2096 | struct __make_unsigned {}; |
2097 | |
2098 | template <class _Tp> |
2099 | struct __make_unsigned<_Tp, true> |
2100 | { |
2101 | typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; |
2102 | }; |
2103 | |
2104 | template <> struct __make_unsigned<bool, true> {}; |
2105 | template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; |
2106 | template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; |
2107 | template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; |
2108 | template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; |
2109 | template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; |
2110 | template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; |
2111 | template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; |
2112 | template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; |
2113 | #ifndef _LIBCPP_HAS_NO_INT128 |
2114 | template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; |
2115 | template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; |
2116 | #endif |
2117 | |
2118 | template <class _Tp> |
2119 | struct _LIBCPP_TEMPLATE_VIS make_unsigned |
2120 | { |
2121 | typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; |
2122 | }; |
2123 | |
2124 | #if _LIBCPP_STD_VER > 11 |
2125 | template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; |
2126 | #endif |
2127 | |
2128 | template <class _Tp, class _Up, class = void> |
2129 | struct __common_type2_imp {}; |
2130 | |
2131 | template <class _Tp, class _Up> |
2132 | struct __common_type2_imp<_Tp, _Up, |
2133 | typename __void_t<decltype( |
2134 | true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() |
2135 | )>::type> |
2136 | { |
2137 | typedef typename decay<decltype( |
2138 | true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() |
2139 | )>::type type; |
2140 | }; |
2141 | |
2142 | template <class, class = void> |
2143 | struct __common_type_impl {}; |
2144 | |
2145 | // Clang provides variadic templates in C++03 as an extension. |
2146 | #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) |
2147 | # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ |
2148 | template <class... Tp> |
2149 | struct __common_types; |
2150 | template <class... _Tp> |
2151 | struct _LIBCPP_TEMPLATE_VIS common_type; |
2152 | #else |
2153 | # define _LIBCPP_OPTIONAL_PACK(...) |
2154 | struct __no_arg; |
2155 | template <class _Tp, class _Up, class = __no_arg> |
2156 | struct __common_types; |
2157 | template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, |
2158 | class _Unused = __no_arg> |
2159 | struct common_type { |
2160 | static_assert(sizeof(_Unused) == 0, |
2161 | "common_type accepts at most 3 arguments in C++03" ); |
2162 | }; |
2163 | #endif // _LIBCPP_CXX03_LANG |
2164 | |
2165 | template <class _Tp, class _Up> |
2166 | struct __common_type_impl< |
2167 | __common_types<_Tp, _Up>, |
2168 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> |
2169 | { |
2170 | typedef typename common_type<_Tp, _Up>::type type; |
2171 | }; |
2172 | |
2173 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> |
2174 | struct __common_type_impl< |
2175 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, |
2176 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> |
2177 | : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, |
2178 | _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { |
2179 | }; |
2180 | |
2181 | // bullet 1 - sizeof...(Tp) == 0 |
2182 | |
2183 | template <> |
2184 | struct _LIBCPP_TEMPLATE_VIS common_type<> {}; |
2185 | |
2186 | // bullet 2 - sizeof...(Tp) == 1 |
2187 | |
2188 | template <class _Tp> |
2189 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> |
2190 | : public common_type<_Tp, _Tp> {}; |
2191 | |
2192 | // bullet 3 - sizeof...(Tp) == 2 |
2193 | |
2194 | template <class _Tp, class _Up> |
2195 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> |
2196 | : conditional< |
2197 | is_same<_Tp, typename decay<_Tp>::type>::value && is_same<_Up, typename decay<_Up>::type>::value, |
2198 | __common_type2_imp<_Tp, _Up>, |
2199 | common_type<typename decay<_Tp>::type, typename decay<_Up>::type> |
2200 | >::type |
2201 | {}; |
2202 | |
2203 | // bullet 4 - sizeof...(Tp) > 2 |
2204 | |
2205 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> |
2206 | struct _LIBCPP_TEMPLATE_VIS |
2207 | common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> |
2208 | : __common_type_impl< |
2209 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; |
2210 | |
2211 | #undef _LIBCPP_OPTIONAL_PACK |
2212 | |
2213 | #if _LIBCPP_STD_VER > 11 |
2214 | template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; |
2215 | #endif |
2216 | |
2217 | // is_assignable |
2218 | |
2219 | template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; }; |
2220 | |
2221 | template <class _Tp, class _Arg> |
2222 | typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type |
2223 | __is_assignable_test(int); |
2224 | |
2225 | template <class, class> |
2226 | false_type __is_assignable_test(...); |
2227 | |
2228 | |
2229 | template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> |
2230 | struct __is_assignable_imp |
2231 | : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {}; |
2232 | |
2233 | template <class _Tp, class _Arg> |
2234 | struct __is_assignable_imp<_Tp, _Arg, true> |
2235 | : public false_type |
2236 | { |
2237 | }; |
2238 | |
2239 | template <class _Tp, class _Arg> |
2240 | struct is_assignable |
2241 | : public __is_assignable_imp<_Tp, _Arg> {}; |
2242 | |
2243 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2244 | template <class _Tp, class _Arg> |
2245 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v |
2246 | = is_assignable<_Tp, _Arg>::value; |
2247 | #endif |
2248 | |
2249 | // is_copy_assignable |
2250 | |
2251 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable |
2252 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, |
2253 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
2254 | |
2255 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2256 | template <class _Tp> |
2257 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v |
2258 | = is_copy_assignable<_Tp>::value; |
2259 | #endif |
2260 | |
2261 | // is_move_assignable |
2262 | |
2263 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable |
2264 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
2265 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, |
2266 | typename add_rvalue_reference<_Tp>::type> {}; |
2267 | #else |
2268 | : public is_copy_assignable<_Tp> {}; |
2269 | #endif |
2270 | |
2271 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2272 | template <class _Tp> |
2273 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v |
2274 | = is_move_assignable<_Tp>::value; |
2275 | #endif |
2276 | |
2277 | // is_destructible |
2278 | |
2279 | // if it's a reference, return true |
2280 | // if it's a function, return false |
2281 | // if it's void, return false |
2282 | // if it's an array of unknown bound, return false |
2283 | // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed |
2284 | // where _Up is remove_all_extents<_Tp>::type |
2285 | |
2286 | template <class> |
2287 | struct __is_destructible_apply { typedef int type; }; |
2288 | |
2289 | template <typename _Tp> |
2290 | struct __is_destructor_wellformed { |
2291 | template <typename _Tp1> |
2292 | static char __test ( |
2293 | typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type |
2294 | ); |
2295 | |
2296 | template <typename _Tp1> |
2297 | static __two __test (...); |
2298 | |
2299 | static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); |
2300 | }; |
2301 | |
2302 | template <class _Tp, bool> |
2303 | struct __destructible_imp; |
2304 | |
2305 | template <class _Tp> |
2306 | struct __destructible_imp<_Tp, false> |
2307 | : public _VSTD::integral_constant<bool, |
2308 | __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {}; |
2309 | |
2310 | template <class _Tp> |
2311 | struct __destructible_imp<_Tp, true> |
2312 | : public _VSTD::true_type {}; |
2313 | |
2314 | template <class _Tp, bool> |
2315 | struct __destructible_false; |
2316 | |
2317 | template <class _Tp> |
2318 | struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {}; |
2319 | |
2320 | template <class _Tp> |
2321 | struct __destructible_false<_Tp, true> : public _VSTD::false_type {}; |
2322 | |
2323 | template <class _Tp> |
2324 | struct is_destructible |
2325 | : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {}; |
2326 | |
2327 | template <class _Tp> |
2328 | struct is_destructible<_Tp[]> |
2329 | : public _VSTD::false_type {}; |
2330 | |
2331 | template <> |
2332 | struct is_destructible<void> |
2333 | : public _VSTD::false_type {}; |
2334 | |
2335 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
2336 | template <class _Tp> |
2337 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v |
2338 | = is_destructible<_Tp>::value; |
2339 | #endif |
2340 | |
2341 | // move |
2342 | |
2343 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
2344 | |
2345 | template <class _Tp> |
2346 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
2347 | typename remove_reference<_Tp>::type&& |
2348 | move(_Tp&& __t) _NOEXCEPT |
2349 | { |
2350 | typedef typename remove_reference<_Tp>::type _Up; |
2351 | return static_cast<_Up&&>(__t); |
2352 | } |
2353 | |
2354 | template <class _Tp> |
2355 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
2356 | _Tp&& |
2357 | forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT |
2358 | { |
2359 | return static_cast<_Tp&&>(__t); |
2360 | } |
2361 | |
2362 | template <class _Tp> |
2363 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
2364 | _Tp&& |
2365 | forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT |
2366 | { |
2367 | static_assert(!is_lvalue_reference<_Tp>::value, |
2368 | "can not forward an rvalue as an lvalue" ); |
2369 | return static_cast<_Tp&&>(__t); |
2370 | } |
2371 | |
2372 | #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
2373 | |
2374 | template <class _Tp> |
2375 | inline _LIBCPP_INLINE_VISIBILITY |
2376 | _Tp& |
2377 | move(_Tp& __t) |
2378 | { |
2379 | return __t; |
2380 | } |
2381 | |
2382 | template <class _Tp> |
2383 | inline _LIBCPP_INLINE_VISIBILITY |
2384 | const _Tp& |
2385 | move(const _Tp& __t) |
2386 | { |
2387 | return __t; |
2388 | } |
2389 | |
2390 | template <class _Tp> |
2391 | inline _LIBCPP_INLINE_VISIBILITY |
2392 | _Tp& |
2393 | forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT |
2394 | { |
2395 | return __t; |
2396 | } |
2397 | |
2398 | |
2399 | template <class _Tp> |
2400 | class __rv |
2401 | { |
2402 | typedef typename remove_reference<_Tp>::type _Trr; |
2403 | _Trr& t_; |
2404 | public: |
2405 | _LIBCPP_INLINE_VISIBILITY |
2406 | _Trr* operator->() {return &t_;} |
2407 | _LIBCPP_INLINE_VISIBILITY |
2408 | explicit __rv(_Trr& __t) : t_(__t) {} |
2409 | }; |
2410 | |
2411 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
2412 | |
2413 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
2414 | |
2415 | template <class _Tp> |
2416 | inline _LIBCPP_INLINE_VISIBILITY |
2417 | typename decay<_Tp>::type |
2418 | __decay_copy(_Tp&& __t) |
2419 | { |
2420 | return _VSTD::forward<_Tp>(__t); |
2421 | } |
2422 | |
2423 | #else |
2424 | |
2425 | template <class _Tp> |
2426 | inline _LIBCPP_INLINE_VISIBILITY |
2427 | typename decay<_Tp>::type |
2428 | __decay_copy(const _Tp& __t) |
2429 | { |
2430 | return _VSTD::forward<_Tp>(__t); |
2431 | } |
2432 | |
2433 | #endif |
2434 | |
2435 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
2436 | |
2437 | template <class _Rp, class _Class, class ..._Param> |
2438 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> |
2439 | { |
2440 | typedef _Class _ClassType; |
2441 | typedef _Rp _ReturnType; |
2442 | typedef _Rp (_FnType) (_Param...); |
2443 | }; |
2444 | |
2445 | template <class _Rp, class _Class, class ..._Param> |
2446 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> |
2447 | { |
2448 | typedef _Class _ClassType; |
2449 | typedef _Rp _ReturnType; |
2450 | typedef _Rp (_FnType) (_Param..., ...); |
2451 | }; |
2452 | |
2453 | template <class _Rp, class _Class, class ..._Param> |
2454 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> |
2455 | { |
2456 | typedef _Class const _ClassType; |
2457 | typedef _Rp _ReturnType; |
2458 | typedef _Rp (_FnType) (_Param...); |
2459 | }; |
2460 | |
2461 | template <class _Rp, class _Class, class ..._Param> |
2462 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> |
2463 | { |
2464 | typedef _Class const _ClassType; |
2465 | typedef _Rp _ReturnType; |
2466 | typedef _Rp (_FnType) (_Param..., ...); |
2467 | }; |
2468 | |
2469 | template <class _Rp, class _Class, class ..._Param> |
2470 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> |
2471 | { |
2472 | typedef _Class volatile _ClassType; |
2473 | typedef _Rp _ReturnType; |
2474 | typedef _Rp (_FnType) (_Param...); |
2475 | }; |
2476 | |
2477 | template <class _Rp, class _Class, class ..._Param> |
2478 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> |
2479 | { |
2480 | typedef _Class volatile _ClassType; |
2481 | typedef _Rp _ReturnType; |
2482 | typedef _Rp (_FnType) (_Param..., ...); |
2483 | }; |
2484 | |
2485 | template <class _Rp, class _Class, class ..._Param> |
2486 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> |
2487 | { |
2488 | typedef _Class const volatile _ClassType; |
2489 | typedef _Rp _ReturnType; |
2490 | typedef _Rp (_FnType) (_Param...); |
2491 | }; |
2492 | |
2493 | template <class _Rp, class _Class, class ..._Param> |
2494 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> |
2495 | { |
2496 | typedef _Class const volatile _ClassType; |
2497 | typedef _Rp _ReturnType; |
2498 | typedef _Rp (_FnType) (_Param..., ...); |
2499 | }; |
2500 | |
2501 | #if __has_feature(cxx_reference_qualified_functions) || \ |
2502 | (defined(_GNUC_VER) && _GNUC_VER >= 409) |
2503 | |
2504 | template <class _Rp, class _Class, class ..._Param> |
2505 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> |
2506 | { |
2507 | typedef _Class& _ClassType; |
2508 | typedef _Rp _ReturnType; |
2509 | typedef _Rp (_FnType) (_Param...); |
2510 | }; |
2511 | |
2512 | template <class _Rp, class _Class, class ..._Param> |
2513 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false> |
2514 | { |
2515 | typedef _Class& _ClassType; |
2516 | typedef _Rp _ReturnType; |
2517 | typedef _Rp (_FnType) (_Param..., ...); |
2518 | }; |
2519 | |
2520 | template <class _Rp, class _Class, class ..._Param> |
2521 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> |
2522 | { |
2523 | typedef _Class const& _ClassType; |
2524 | typedef _Rp _ReturnType; |
2525 | typedef _Rp (_FnType) (_Param...); |
2526 | }; |
2527 | |
2528 | template <class _Rp, class _Class, class ..._Param> |
2529 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> |
2530 | { |
2531 | typedef _Class const& _ClassType; |
2532 | typedef _Rp _ReturnType; |
2533 | typedef _Rp (_FnType) (_Param..., ...); |
2534 | }; |
2535 | |
2536 | template <class _Rp, class _Class, class ..._Param> |
2537 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> |
2538 | { |
2539 | typedef _Class volatile& _ClassType; |
2540 | typedef _Rp _ReturnType; |
2541 | typedef _Rp (_FnType) (_Param...); |
2542 | }; |
2543 | |
2544 | template <class _Rp, class _Class, class ..._Param> |
2545 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> |
2546 | { |
2547 | typedef _Class volatile& _ClassType; |
2548 | typedef _Rp _ReturnType; |
2549 | typedef _Rp (_FnType) (_Param..., ...); |
2550 | }; |
2551 | |
2552 | template <class _Rp, class _Class, class ..._Param> |
2553 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> |
2554 | { |
2555 | typedef _Class const volatile& _ClassType; |
2556 | typedef _Rp _ReturnType; |
2557 | typedef _Rp (_FnType) (_Param...); |
2558 | }; |
2559 | |
2560 | template <class _Rp, class _Class, class ..._Param> |
2561 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> |
2562 | { |
2563 | typedef _Class const volatile& _ClassType; |
2564 | typedef _Rp _ReturnType; |
2565 | typedef _Rp (_FnType) (_Param..., ...); |
2566 | }; |
2567 | |
2568 | template <class _Rp, class _Class, class ..._Param> |
2569 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> |
2570 | { |
2571 | typedef _Class&& _ClassType; |
2572 | typedef _Rp _ReturnType; |
2573 | typedef _Rp (_FnType) (_Param...); |
2574 | }; |
2575 | |
2576 | template <class _Rp, class _Class, class ..._Param> |
2577 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false> |
2578 | { |
2579 | typedef _Class&& _ClassType; |
2580 | typedef _Rp _ReturnType; |
2581 | typedef _Rp (_FnType) (_Param..., ...); |
2582 | }; |
2583 | |
2584 | template <class _Rp, class _Class, class ..._Param> |
2585 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> |
2586 | { |
2587 | typedef _Class const&& _ClassType; |
2588 | typedef _Rp _ReturnType; |
2589 | typedef _Rp (_FnType) (_Param...); |
2590 | }; |
2591 | |
2592 | template <class _Rp, class _Class, class ..._Param> |
2593 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> |
2594 | { |
2595 | typedef _Class const&& _ClassType; |
2596 | typedef _Rp _ReturnType; |
2597 | typedef _Rp (_FnType) (_Param..., ...); |
2598 | }; |
2599 | |
2600 | template <class _Rp, class _Class, class ..._Param> |
2601 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> |
2602 | { |
2603 | typedef _Class volatile&& _ClassType; |
2604 | typedef _Rp _ReturnType; |
2605 | typedef _Rp (_FnType) (_Param...); |
2606 | }; |
2607 | |
2608 | template <class _Rp, class _Class, class ..._Param> |
2609 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> |
2610 | { |
2611 | typedef _Class volatile&& _ClassType; |
2612 | typedef _Rp _ReturnType; |
2613 | typedef _Rp (_FnType) (_Param..., ...); |
2614 | }; |
2615 | |
2616 | template <class _Rp, class _Class, class ..._Param> |
2617 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> |
2618 | { |
2619 | typedef _Class const volatile&& _ClassType; |
2620 | typedef _Rp _ReturnType; |
2621 | typedef _Rp (_FnType) (_Param...); |
2622 | }; |
2623 | |
2624 | template <class _Rp, class _Class, class ..._Param> |
2625 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> |
2626 | { |
2627 | typedef _Class const volatile&& _ClassType; |
2628 | typedef _Rp _ReturnType; |
2629 | typedef _Rp (_FnType) (_Param..., ...); |
2630 | }; |
2631 | |
2632 | #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409 |
2633 | |
2634 | #else // _LIBCPP_HAS_NO_VARIADICS |
2635 | |
2636 | template <class _Rp, class _Class> |
2637 | struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> |
2638 | { |
2639 | typedef _Class _ClassType; |
2640 | typedef _Rp _ReturnType; |
2641 | typedef _Rp (_FnType) (); |
2642 | }; |
2643 | |
2644 | template <class _Rp, class _Class> |
2645 | struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false> |
2646 | { |
2647 | typedef _Class _ClassType; |
2648 | typedef _Rp _ReturnType; |
2649 | typedef _Rp (_FnType) (...); |
2650 | }; |
2651 | |
2652 | template <class _Rp, class _Class, class _P0> |
2653 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> |
2654 | { |
2655 | typedef _Class _ClassType; |
2656 | typedef _Rp _ReturnType; |
2657 | typedef _Rp (_FnType) (_P0); |
2658 | }; |
2659 | |
2660 | template <class _Rp, class _Class, class _P0> |
2661 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false> |
2662 | { |
2663 | typedef _Class _ClassType; |
2664 | typedef _Rp _ReturnType; |
2665 | typedef _Rp (_FnType) (_P0, ...); |
2666 | }; |
2667 | |
2668 | template <class _Rp, class _Class, class _P0, class _P1> |
2669 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> |
2670 | { |
2671 | typedef _Class _ClassType; |
2672 | typedef _Rp _ReturnType; |
2673 | typedef _Rp (_FnType) (_P0, _P1); |
2674 | }; |
2675 | |
2676 | template <class _Rp, class _Class, class _P0, class _P1> |
2677 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false> |
2678 | { |
2679 | typedef _Class _ClassType; |
2680 | typedef _Rp _ReturnType; |
2681 | typedef _Rp (_FnType) (_P0, _P1, ...); |
2682 | }; |
2683 | |
2684 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2685 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> |
2686 | { |
2687 | typedef _Class _ClassType; |
2688 | typedef _Rp _ReturnType; |
2689 | typedef _Rp (_FnType) (_P0, _P1, _P2); |
2690 | }; |
2691 | |
2692 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2693 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false> |
2694 | { |
2695 | typedef _Class _ClassType; |
2696 | typedef _Rp _ReturnType; |
2697 | typedef _Rp (_FnType) (_P0, _P1, _P2, ...); |
2698 | }; |
2699 | |
2700 | template <class _Rp, class _Class> |
2701 | struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> |
2702 | { |
2703 | typedef _Class const _ClassType; |
2704 | typedef _Rp _ReturnType; |
2705 | typedef _Rp (_FnType) (); |
2706 | }; |
2707 | |
2708 | template <class _Rp, class _Class> |
2709 | struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false> |
2710 | { |
2711 | typedef _Class const _ClassType; |
2712 | typedef _Rp _ReturnType; |
2713 | typedef _Rp (_FnType) (...); |
2714 | }; |
2715 | |
2716 | template <class _Rp, class _Class, class _P0> |
2717 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> |
2718 | { |
2719 | typedef _Class const _ClassType; |
2720 | typedef _Rp _ReturnType; |
2721 | typedef _Rp (_FnType) (_P0); |
2722 | }; |
2723 | |
2724 | template <class _Rp, class _Class, class _P0> |
2725 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false> |
2726 | { |
2727 | typedef _Class const _ClassType; |
2728 | typedef _Rp _ReturnType; |
2729 | typedef _Rp (_FnType) (_P0, ...); |
2730 | }; |
2731 | |
2732 | template <class _Rp, class _Class, class _P0, class _P1> |
2733 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> |
2734 | { |
2735 | typedef _Class const _ClassType; |
2736 | typedef _Rp _ReturnType; |
2737 | typedef _Rp (_FnType) (_P0, _P1); |
2738 | }; |
2739 | |
2740 | template <class _Rp, class _Class, class _P0, class _P1> |
2741 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false> |
2742 | { |
2743 | typedef _Class const _ClassType; |
2744 | typedef _Rp _ReturnType; |
2745 | typedef _Rp (_FnType) (_P0, _P1, ...); |
2746 | }; |
2747 | |
2748 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2749 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> |
2750 | { |
2751 | typedef _Class const _ClassType; |
2752 | typedef _Rp _ReturnType; |
2753 | typedef _Rp (_FnType) (_P0, _P1, _P2); |
2754 | }; |
2755 | |
2756 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2757 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false> |
2758 | { |
2759 | typedef _Class const _ClassType; |
2760 | typedef _Rp _ReturnType; |
2761 | typedef _Rp (_FnType) (_P0, _P1, _P2, ...); |
2762 | }; |
2763 | |
2764 | template <class _Rp, class _Class> |
2765 | struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> |
2766 | { |
2767 | typedef _Class volatile _ClassType; |
2768 | typedef _Rp _ReturnType; |
2769 | typedef _Rp (_FnType) (); |
2770 | }; |
2771 | |
2772 | template <class _Rp, class _Class> |
2773 | struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false> |
2774 | { |
2775 | typedef _Class volatile _ClassType; |
2776 | typedef _Rp _ReturnType; |
2777 | typedef _Rp (_FnType) (...); |
2778 | }; |
2779 | |
2780 | template <class _Rp, class _Class, class _P0> |
2781 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> |
2782 | { |
2783 | typedef _Class volatile _ClassType; |
2784 | typedef _Rp _ReturnType; |
2785 | typedef _Rp (_FnType) (_P0); |
2786 | }; |
2787 | |
2788 | template <class _Rp, class _Class, class _P0> |
2789 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false> |
2790 | { |
2791 | typedef _Class volatile _ClassType; |
2792 | typedef _Rp _ReturnType; |
2793 | typedef _Rp (_FnType) (_P0, ...); |
2794 | }; |
2795 | |
2796 | template <class _Rp, class _Class, class _P0, class _P1> |
2797 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> |
2798 | { |
2799 | typedef _Class volatile _ClassType; |
2800 | typedef _Rp _ReturnType; |
2801 | typedef _Rp (_FnType) (_P0, _P1); |
2802 | }; |
2803 | |
2804 | template <class _Rp, class _Class, class _P0, class _P1> |
2805 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false> |
2806 | { |
2807 | typedef _Class volatile _ClassType; |
2808 | typedef _Rp _ReturnType; |
2809 | typedef _Rp (_FnType) (_P0, _P1, ...); |
2810 | }; |
2811 | |
2812 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2813 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> |
2814 | { |
2815 | typedef _Class volatile _ClassType; |
2816 | typedef _Rp _ReturnType; |
2817 | typedef _Rp (_FnType) (_P0, _P1, _P2); |
2818 | }; |
2819 | |
2820 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2821 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false> |
2822 | { |
2823 | typedef _Class volatile _ClassType; |
2824 | typedef _Rp _ReturnType; |
2825 | typedef _Rp (_FnType) (_P0, _P1, _P2, ...); |
2826 | }; |
2827 | |
2828 | template <class _Rp, class _Class> |
2829 | struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> |
2830 | { |
2831 | typedef _Class const volatile _ClassType; |
2832 | typedef _Rp _ReturnType; |
2833 | typedef _Rp (_FnType) (); |
2834 | }; |
2835 | |
2836 | template <class _Rp, class _Class> |
2837 | struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false> |
2838 | { |
2839 | typedef _Class const volatile _ClassType; |
2840 | typedef _Rp _ReturnType; |
2841 | typedef _Rp (_FnType) (...); |
2842 | }; |
2843 | |
2844 | template <class _Rp, class _Class, class _P0> |
2845 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> |
2846 | { |
2847 | typedef _Class const volatile _ClassType; |
2848 | typedef _Rp _ReturnType; |
2849 | typedef _Rp (_FnType) (_P0); |
2850 | }; |
2851 | |
2852 | template <class _Rp, class _Class, class _P0> |
2853 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false> |
2854 | { |
2855 | typedef _Class const volatile _ClassType; |
2856 | typedef _Rp _ReturnType; |
2857 | typedef _Rp (_FnType) (_P0, ...); |
2858 | }; |
2859 | |
2860 | template <class _Rp, class _Class, class _P0, class _P1> |
2861 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> |
2862 | { |
2863 | typedef _Class const volatile _ClassType; |
2864 | typedef _Rp _ReturnType; |
2865 | typedef _Rp (_FnType) (_P0, _P1); |
2866 | }; |
2867 | |
2868 | template <class _Rp, class _Class, class _P0, class _P1> |
2869 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false> |
2870 | { |
2871 | typedef _Class const volatile _ClassType; |
2872 | typedef _Rp _ReturnType; |
2873 | typedef _Rp (_FnType) (_P0, _P1, ...); |
2874 | }; |
2875 | |
2876 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2877 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> |
2878 | { |
2879 | typedef _Class const volatile _ClassType; |
2880 | typedef _Rp _ReturnType; |
2881 | typedef _Rp (_FnType) (_P0, _P1, _P2); |
2882 | }; |
2883 | |
2884 | template <class _Rp, class _Class, class _P0, class _P1, class _P2> |
2885 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false> |
2886 | { |
2887 | typedef _Class const volatile _ClassType; |
2888 | typedef _Rp _ReturnType; |
2889 | typedef _Rp (_FnType) (_P0, _P1, _P2, ...); |
2890 | }; |
2891 | |
2892 | #endif // _LIBCPP_HAS_NO_VARIADICS |
2893 | |
2894 | template <class _Rp, class _Class> |
2895 | struct __member_pointer_traits_imp<_Rp _Class::*, false, true> |
2896 | { |
2897 | typedef _Class _ClassType; |
2898 | typedef _Rp _ReturnType; |
2899 | }; |
2900 | |
2901 | template <class _MP> |
2902 | struct __member_pointer_traits |
2903 | : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, |
2904 | is_member_function_pointer<_MP>::value, |
2905 | is_member_object_pointer<_MP>::value> |
2906 | { |
2907 | // typedef ... _ClassType; |
2908 | // typedef ... _ReturnType; |
2909 | // typedef ... _FnType; |
2910 | }; |
2911 | |
2912 | |
2913 | template <class _DecayedFp> |
2914 | struct __member_pointer_class_type {}; |
2915 | |
2916 | template <class _Ret, class _ClassType> |
2917 | struct __member_pointer_class_type<_Ret _ClassType::*> { |
2918 | typedef _ClassType type; |
2919 | }; |
2920 | |
2921 | // result_of |
2922 | |
2923 | template <class _Callable> class result_of; |
2924 | |
2925 | #ifdef _LIBCPP_HAS_NO_VARIADICS |
2926 | |
2927 | template <class _Fn, bool, bool> |
2928 | class __result_of |
2929 | { |
2930 | }; |
2931 | |
2932 | template <class _Fn> |
2933 | class __result_of<_Fn(), true, false> |
2934 | { |
2935 | public: |
2936 | typedef decltype(declval<_Fn>()()) type; |
2937 | }; |
2938 | |
2939 | template <class _Fn, class _A0> |
2940 | class __result_of<_Fn(_A0), true, false> |
2941 | { |
2942 | public: |
2943 | typedef decltype(declval<_Fn>()(declval<_A0>())) type; |
2944 | }; |
2945 | |
2946 | template <class _Fn, class _A0, class _A1> |
2947 | class __result_of<_Fn(_A0, _A1), true, false> |
2948 | { |
2949 | public: |
2950 | typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; |
2951 | }; |
2952 | |
2953 | template <class _Fn, class _A0, class _A1, class _A2> |
2954 | class __result_of<_Fn(_A0, _A1, _A2), true, false> |
2955 | { |
2956 | public: |
2957 | typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; |
2958 | }; |
2959 | |
2960 | template <class _MP, class _Tp, bool _IsMemberFunctionPtr> |
2961 | struct __result_of_mp; |
2962 | |
2963 | // member function pointer |
2964 | |
2965 | template <class _MP, class _Tp> |
2966 | struct __result_of_mp<_MP, _Tp, true> |
2967 | : public __identity<typename __member_pointer_traits<_MP>::_ReturnType> |
2968 | { |
2969 | }; |
2970 | |
2971 | // member data pointer |
2972 | |
2973 | template <class _MP, class _Tp, bool> |
2974 | struct __result_of_mdp; |
2975 | |
2976 | template <class _Rp, class _Class, class _Tp> |
2977 | struct __result_of_mdp<_Rp _Class::*, _Tp, false> |
2978 | { |
2979 | typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type; |
2980 | }; |
2981 | |
2982 | template <class _Rp, class _Class, class _Tp> |
2983 | struct __result_of_mdp<_Rp _Class::*, _Tp, true> |
2984 | { |
2985 | typedef typename __apply_cv<_Tp, _Rp>::type& type; |
2986 | }; |
2987 | |
2988 | template <class _Rp, class _Class, class _Tp> |
2989 | struct __result_of_mp<_Rp _Class::*, _Tp, false> |
2990 | : public __result_of_mdp<_Rp _Class::*, _Tp, |
2991 | is_base_of<_Class, typename remove_reference<_Tp>::type>::value> |
2992 | { |
2993 | }; |
2994 | |
2995 | |
2996 | |
2997 | template <class _Fn, class _Tp> |
2998 | class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer |
2999 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
3000 | _Tp, |
3001 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
3002 | { |
3003 | }; |
3004 | |
3005 | template <class _Fn, class _Tp, class _A0> |
3006 | class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer |
3007 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
3008 | _Tp, |
3009 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
3010 | { |
3011 | }; |
3012 | |
3013 | template <class _Fn, class _Tp, class _A0, class _A1> |
3014 | class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer |
3015 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
3016 | _Tp, |
3017 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
3018 | { |
3019 | }; |
3020 | |
3021 | template <class _Fn, class _Tp, class _A0, class _A1, class _A2> |
3022 | class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer |
3023 | : public __result_of_mp<typename remove_reference<_Fn>::type, |
3024 | _Tp, |
3025 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
3026 | { |
3027 | }; |
3028 | |
3029 | // result_of |
3030 | |
3031 | template <class _Fn> |
3032 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn()> |
3033 | : public __result_of<_Fn(), |
3034 | is_class<typename remove_reference<_Fn>::type>::value || |
3035 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
3036 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
3037 | > |
3038 | { |
3039 | }; |
3040 | |
3041 | template <class _Fn, class _A0> |
3042 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)> |
3043 | : public __result_of<_Fn(_A0), |
3044 | is_class<typename remove_reference<_Fn>::type>::value || |
3045 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
3046 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
3047 | > |
3048 | { |
3049 | }; |
3050 | |
3051 | template <class _Fn, class _A0, class _A1> |
3052 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)> |
3053 | : public __result_of<_Fn(_A0, _A1), |
3054 | is_class<typename remove_reference<_Fn>::type>::value || |
3055 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
3056 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
3057 | > |
3058 | { |
3059 | }; |
3060 | |
3061 | template <class _Fn, class _A0, class _A1, class _A2> |
3062 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)> |
3063 | : public __result_of<_Fn(_A0, _A1, _A2), |
3064 | is_class<typename remove_reference<_Fn>::type>::value || |
3065 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
3066 | is_member_pointer<typename remove_reference<_Fn>::type>::value |
3067 | > |
3068 | { |
3069 | }; |
3070 | |
3071 | #endif // _LIBCPP_HAS_NO_VARIADICS |
3072 | |
3073 | // template <class T, class... Args> struct is_constructible; |
3074 | |
3075 | namespace __is_construct |
3076 | { |
3077 | struct __nat {}; |
3078 | } |
3079 | |
3080 | #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \ |
3081 | defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE)) |
3082 | |
3083 | template <class _Tp, class... _Args> |
3084 | struct __libcpp_is_constructible; |
3085 | |
3086 | template <class _To, class _From> |
3087 | struct __is_invalid_base_to_derived_cast { |
3088 | static_assert(is_reference<_To>::value, "Wrong specialization" ); |
3089 | using _RawFrom = __uncvref_t<_From>; |
3090 | using _RawTo = __uncvref_t<_To>; |
3091 | static const bool value = __lazy_and< |
3092 | __lazy_not<is_same<_RawFrom, _RawTo>>, |
3093 | is_base_of<_RawFrom, _RawTo>, |
3094 | __lazy_not<__libcpp_is_constructible<_RawTo, _From>> |
3095 | >::value; |
3096 | }; |
3097 | |
3098 | template <class _To, class _From> |
3099 | struct __is_invalid_lvalue_to_rvalue_cast : false_type { |
3100 | static_assert(is_reference<_To>::value, "Wrong specialization" ); |
3101 | }; |
3102 | |
3103 | template <class _ToRef, class _FromRef> |
3104 | struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> { |
3105 | using _RawFrom = __uncvref_t<_FromRef>; |
3106 | using _RawTo = __uncvref_t<_ToRef>; |
3107 | static const bool value = __lazy_and< |
3108 | __lazy_not<is_function<_RawTo>>, |
3109 | __lazy_or< |
3110 | is_same<_RawFrom, _RawTo>, |
3111 | is_base_of<_RawTo, _RawFrom>> |
3112 | >::value; |
3113 | }; |
3114 | |
3115 | struct __is_constructible_helper |
3116 | { |
3117 | template <class _To> |
3118 | static void __eat(_To); |
3119 | |
3120 | // This overload is needed to work around a Clang bug that disallows |
3121 | // static_cast<T&&>(e) for non-reference-compatible types. |
3122 | // Example: static_cast<int&&>(declval<double>()); |
3123 | // NOTE: The static_cast implementation below is required to support |
3124 | // classes with explicit conversion operators. |
3125 | template <class _To, class _From, |
3126 | class = decltype(__eat<_To>(_VSTD::declval<_From>()))> |
3127 | static true_type __test_cast(int); |
3128 | |
3129 | template <class _To, class _From, |
3130 | class = decltype(static_cast<_To>(_VSTD::declval<_From>()))> |
3131 | static integral_constant<bool, |
3132 | !__is_invalid_base_to_derived_cast<_To, _From>::value && |
3133 | !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value |
3134 | > __test_cast(long); |
3135 | |
3136 | template <class, class> |
3137 | static false_type __test_cast(...); |
3138 | |
3139 | template <class _Tp, class ..._Args, |
3140 | class = decltype(_Tp(_VSTD::declval<_Args>()...))> |
3141 | static true_type __test_nary(int); |
3142 | template <class _Tp, class...> |
3143 | static false_type __test_nary(...); |
3144 | |
3145 | template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))> |
3146 | static is_destructible<_Tp> __test_unary(int); |
3147 | template <class, class> |
3148 | static false_type __test_unary(...); |
3149 | }; |
3150 | |
3151 | template <class _Tp, bool = is_void<_Tp>::value> |
3152 | struct __is_default_constructible |
3153 | : decltype(__is_constructible_helper::__test_nary<_Tp>(0)) |
3154 | {}; |
3155 | |
3156 | template <class _Tp> |
3157 | struct __is_default_constructible<_Tp, true> : false_type {}; |
3158 | |
3159 | template <class _Tp> |
3160 | struct __is_default_constructible<_Tp[], false> : false_type {}; |
3161 | |
3162 | template <class _Tp, size_t _Nx> |
3163 | struct __is_default_constructible<_Tp[_Nx], false> |
3164 | : __is_default_constructible<typename remove_all_extents<_Tp>::type> {}; |
3165 | |
3166 | template <class _Tp, class... _Args> |
3167 | struct __libcpp_is_constructible |
3168 | { |
3169 | static_assert(sizeof...(_Args) > 1, "Wrong specialization" ); |
3170 | typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0)) |
3171 | type; |
3172 | }; |
3173 | |
3174 | template <class _Tp> |
3175 | struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {}; |
3176 | |
3177 | template <class _Tp, class _A0> |
3178 | struct __libcpp_is_constructible<_Tp, _A0> |
3179 | : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0)) |
3180 | {}; |
3181 | |
3182 | template <class _Tp, class _A0> |
3183 | struct __libcpp_is_constructible<_Tp&, _A0> |
3184 | : public decltype(__is_constructible_helper:: |
3185 | __test_cast<_Tp&, _A0>(0)) |
3186 | {}; |
3187 | |
3188 | template <class _Tp, class _A0> |
3189 | struct __libcpp_is_constructible<_Tp&&, _A0> |
3190 | : public decltype(__is_constructible_helper:: |
3191 | __test_cast<_Tp&&, _A0>(0)) |
3192 | {}; |
3193 | |
3194 | #endif |
3195 | |
3196 | #if __has_feature(is_constructible) |
3197 | template <class _Tp, class ..._Args> |
3198 | struct _LIBCPP_TEMPLATE_VIS is_constructible |
3199 | : public integral_constant<bool, __is_constructible(_Tp, _Args...)> |
3200 | {}; |
3201 | #elif !defined(_LIBCPP_CXX03_LANG) |
3202 | template <class _Tp, class... _Args> |
3203 | struct _LIBCPP_TEMPLATE_VIS is_constructible |
3204 | : public __libcpp_is_constructible<_Tp, _Args...>::type {}; |
3205 | #else |
3206 | // template <class T> struct is_constructible0; |
3207 | |
3208 | // main is_constructible0 test |
3209 | |
3210 | template <class _Tp> |
3211 | decltype((_Tp(), true_type())) |
3212 | __is_constructible0_test(_Tp&); |
3213 | |
3214 | false_type |
3215 | __is_constructible0_test(__any); |
3216 | |
3217 | template <class _Tp, class _A0> |
3218 | decltype((_Tp(_VSTD::declval<_A0>()), true_type())) |
3219 | __is_constructible1_test(_Tp&, _A0&); |
3220 | |
3221 | template <class _A0> |
3222 | false_type |
3223 | __is_constructible1_test(__any, _A0&); |
3224 | |
3225 | template <class _Tp, class _A0, class _A1> |
3226 | decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) |
3227 | __is_constructible2_test(_Tp&, _A0&, _A1&); |
3228 | |
3229 | template <class _A0, class _A1> |
3230 | false_type |
3231 | __is_constructible2_test(__any, _A0&, _A1&); |
3232 | |
3233 | template <class _Tp, class _A0, class _A1, class _A2> |
3234 | decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type())) |
3235 | __is_constructible3_test(_Tp&, _A0&, _A1&, _A2&); |
3236 | |
3237 | template <class _A0, class _A1, class _A2> |
3238 | false_type |
3239 | __is_constructible3_test(__any, _A0&, _A1&, _A2&); |
3240 | |
3241 | template <bool, class _Tp> |
3242 | struct __is_constructible0_imp // false, _Tp is not a scalar |
3243 | : public common_type |
3244 | < |
3245 | decltype(__is_constructible0_test(declval<_Tp&>())) |
3246 | >::type |
3247 | {}; |
3248 | |
3249 | template <bool, class _Tp, class _A0> |
3250 | struct __is_constructible1_imp // false, _Tp is not a scalar |
3251 | : public common_type |
3252 | < |
3253 | decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) |
3254 | >::type |
3255 | {}; |
3256 | |
3257 | template <bool, class _Tp, class _A0, class _A1> |
3258 | struct __is_constructible2_imp // false, _Tp is not a scalar |
3259 | : public common_type |
3260 | < |
3261 | decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) |
3262 | >::type |
3263 | {}; |
3264 | |
3265 | template <bool, class _Tp, class _A0, class _A1, class _A2> |
3266 | struct __is_constructible3_imp // false, _Tp is not a scalar |
3267 | : public common_type |
3268 | < |
3269 | decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>())) |
3270 | >::type |
3271 | {}; |
3272 | |
3273 | // handle scalars and reference types |
3274 | |
3275 | // Scalars are default constructible, references are not |
3276 | |
3277 | template <class _Tp> |
3278 | struct __is_constructible0_imp<true, _Tp> |
3279 | : public is_scalar<_Tp> |
3280 | {}; |
3281 | |
3282 | template <class _Tp, class _A0> |
3283 | struct __is_constructible1_imp<true, _Tp, _A0> |
3284 | : public is_convertible<_A0, _Tp> |
3285 | {}; |
3286 | |
3287 | template <class _Tp, class _A0, class _A1> |
3288 | struct __is_constructible2_imp<true, _Tp, _A0, _A1> |
3289 | : public false_type |
3290 | {}; |
3291 | |
3292 | template <class _Tp, class _A0, class _A1, class _A2> |
3293 | struct __is_constructible3_imp<true, _Tp, _A0, _A1, _A2> |
3294 | : public false_type |
3295 | {}; |
3296 | |
3297 | // Treat scalars and reference types separately |
3298 | |
3299 | template <bool, class _Tp> |
3300 | struct __is_constructible0_void_check |
3301 | : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, |
3302 | _Tp> |
3303 | {}; |
3304 | |
3305 | template <bool, class _Tp, class _A0> |
3306 | struct __is_constructible1_void_check |
3307 | : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, |
3308 | _Tp, _A0> |
3309 | {}; |
3310 | |
3311 | template <bool, class _Tp, class _A0, class _A1> |
3312 | struct __is_constructible2_void_check |
3313 | : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, |
3314 | _Tp, _A0, _A1> |
3315 | {}; |
3316 | |
3317 | template <bool, class _Tp, class _A0, class _A1, class _A2> |
3318 | struct __is_constructible3_void_check |
3319 | : public __is_constructible3_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, |
3320 | _Tp, _A0, _A1, _A2> |
3321 | {}; |
3322 | |
3323 | // If any of T or Args is void, is_constructible should be false |
3324 | |
3325 | template <class _Tp> |
3326 | struct __is_constructible0_void_check<true, _Tp> |
3327 | : public false_type |
3328 | {}; |
3329 | |
3330 | template <class _Tp, class _A0> |
3331 | struct __is_constructible1_void_check<true, _Tp, _A0> |
3332 | : public false_type |
3333 | {}; |
3334 | |
3335 | template <class _Tp, class _A0, class _A1> |
3336 | struct __is_constructible2_void_check<true, _Tp, _A0, _A1> |
3337 | : public false_type |
3338 | {}; |
3339 | |
3340 | template <class _Tp, class _A0, class _A1, class _A2> |
3341 | struct __is_constructible3_void_check<true, _Tp, _A0, _A1, _A2> |
3342 | : public false_type |
3343 | {}; |
3344 | |
3345 | // is_constructible entry point |
3346 | |
3347 | template <class _Tp, class _A0 = __is_construct::__nat, |
3348 | class _A1 = __is_construct::__nat, |
3349 | class _A2 = __is_construct::__nat> |
3350 | struct _LIBCPP_TEMPLATE_VIS is_constructible |
3351 | : public __is_constructible3_void_check<is_void<_Tp>::value |
3352 | || is_abstract<_Tp>::value |
3353 | || is_function<_Tp>::value |
3354 | || is_void<_A0>::value |
3355 | || is_void<_A1>::value |
3356 | || is_void<_A2>::value, |
3357 | _Tp, _A0, _A1, _A2> |
3358 | {}; |
3359 | |
3360 | template <class _Tp> |
3361 | struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> |
3362 | : public __is_constructible0_void_check<is_void<_Tp>::value |
3363 | || is_abstract<_Tp>::value |
3364 | || is_function<_Tp>::value, |
3365 | _Tp> |
3366 | {}; |
3367 | |
3368 | template <class _Tp, class _A0> |
3369 | struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat> |
3370 | : public __is_constructible1_void_check<is_void<_Tp>::value |
3371 | || is_abstract<_Tp>::value |
3372 | || is_function<_Tp>::value |
3373 | || is_void<_A0>::value, |
3374 | _Tp, _A0> |
3375 | {}; |
3376 | |
3377 | template <class _Tp, class _A0, class _A1> |
3378 | struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, _A1, __is_construct::__nat> |
3379 | : public __is_constructible2_void_check<is_void<_Tp>::value |
3380 | || is_abstract<_Tp>::value |
3381 | || is_function<_Tp>::value |
3382 | || is_void<_A0>::value |
3383 | || is_void<_A1>::value, |
3384 | _Tp, _A0, _A1> |
3385 | {}; |
3386 | |
3387 | // Array types are default constructible if their element type |
3388 | // is default constructible |
3389 | |
3390 | template <class _Ap, size_t _Np> |
3391 | struct __is_constructible0_imp<false, _Ap[_Np]> |
3392 | : public is_constructible<typename remove_all_extents<_Ap>::type> |
3393 | {}; |
3394 | |
3395 | template <class _Ap, size_t _Np, class _A0> |
3396 | struct __is_constructible1_imp<false, _Ap[_Np], _A0> |
3397 | : public false_type |
3398 | {}; |
3399 | |
3400 | template <class _Ap, size_t _Np, class _A0, class _A1> |
3401 | struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1> |
3402 | : public false_type |
3403 | {}; |
3404 | |
3405 | template <class _Ap, size_t _Np, class _A0, class _A1, class _A2> |
3406 | struct __is_constructible3_imp<false, _Ap[_Np], _A0, _A1, _A2> |
3407 | : public false_type |
3408 | {}; |
3409 | |
3410 | // Incomplete array types are not constructible |
3411 | |
3412 | template <class _Ap> |
3413 | struct __is_constructible0_imp<false, _Ap[]> |
3414 | : public false_type |
3415 | {}; |
3416 | |
3417 | template <class _Ap, class _A0> |
3418 | struct __is_constructible1_imp<false, _Ap[], _A0> |
3419 | : public false_type |
3420 | {}; |
3421 | |
3422 | template <class _Ap, class _A0, class _A1> |
3423 | struct __is_constructible2_imp<false, _Ap[], _A0, _A1> |
3424 | : public false_type |
3425 | {}; |
3426 | |
3427 | template <class _Ap, class _A0, class _A1, class _A2> |
3428 | struct __is_constructible3_imp<false, _Ap[], _A0, _A1, _A2> |
3429 | : public false_type |
3430 | {}; |
3431 | |
3432 | #endif // __has_feature(is_constructible) |
3433 | |
3434 | |
3435 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
3436 | template <class _Tp, class ..._Args> |
3437 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v |
3438 | = is_constructible<_Tp, _Args...>::value; |
3439 | #endif |
3440 | |
3441 | // is_default_constructible |
3442 | |
3443 | template <class _Tp> |
3444 | struct _LIBCPP_TEMPLATE_VIS is_default_constructible |
3445 | : public is_constructible<_Tp> |
3446 | {}; |
3447 | |
3448 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3449 | template <class _Tp> |
3450 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v |
3451 | = is_default_constructible<_Tp>::value; |
3452 | #endif |
3453 | |
3454 | // is_copy_constructible |
3455 | |
3456 | template <class _Tp> |
3457 | struct _LIBCPP_TEMPLATE_VIS is_copy_constructible |
3458 | : public is_constructible<_Tp, |
3459 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
3460 | |
3461 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3462 | template <class _Tp> |
3463 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v |
3464 | = is_copy_constructible<_Tp>::value; |
3465 | #endif |
3466 | |
3467 | // is_move_constructible |
3468 | |
3469 | template <class _Tp> |
3470 | struct _LIBCPP_TEMPLATE_VIS is_move_constructible |
3471 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3472 | : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
3473 | #else |
3474 | : public is_copy_constructible<_Tp> |
3475 | #endif |
3476 | {}; |
3477 | |
3478 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3479 | template <class _Tp> |
3480 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v |
3481 | = is_move_constructible<_Tp>::value; |
3482 | #endif |
3483 | |
3484 | // is_trivially_constructible |
3485 | |
3486 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
3487 | |
3488 | #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 |
3489 | |
3490 | template <class _Tp, class... _Args> |
3491 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible |
3492 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> |
3493 | { |
3494 | }; |
3495 | |
3496 | #else // !__has_feature(is_trivially_constructible) |
3497 | |
3498 | template <class _Tp, class... _Args> |
3499 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible |
3500 | : false_type |
3501 | { |
3502 | }; |
3503 | |
3504 | template <class _Tp> |
3505 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp> |
3506 | #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403) |
3507 | : integral_constant<bool, __has_trivial_constructor(_Tp)> |
3508 | #else |
3509 | : integral_constant<bool, is_scalar<_Tp>::value> |
3510 | #endif |
3511 | { |
3512 | }; |
3513 | |
3514 | template <class _Tp> |
3515 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3516 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&> |
3517 | #else |
3518 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp> |
3519 | #endif |
3520 | : integral_constant<bool, is_scalar<_Tp>::value> |
3521 | { |
3522 | }; |
3523 | |
3524 | template <class _Tp> |
3525 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&> |
3526 | : integral_constant<bool, is_scalar<_Tp>::value> |
3527 | { |
3528 | }; |
3529 | |
3530 | template <class _Tp> |
3531 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&> |
3532 | : integral_constant<bool, is_scalar<_Tp>::value> |
3533 | { |
3534 | }; |
3535 | |
3536 | #endif // !__has_feature(is_trivially_constructible) |
3537 | |
3538 | #else // _LIBCPP_HAS_NO_VARIADICS |
3539 | |
3540 | template <class _Tp, class _A0 = __is_construct::__nat, |
3541 | class _A1 = __is_construct::__nat> |
3542 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible |
3543 | : false_type |
3544 | { |
3545 | }; |
3546 | |
3547 | #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 |
3548 | |
3549 | template <class _Tp> |
3550 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, |
3551 | __is_construct::__nat> |
3552 | : integral_constant<bool, __is_trivially_constructible(_Tp)> |
3553 | { |
3554 | }; |
3555 | |
3556 | template <class _Tp> |
3557 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp, |
3558 | __is_construct::__nat> |
3559 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> |
3560 | { |
3561 | }; |
3562 | |
3563 | template <class _Tp> |
3564 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&, |
3565 | __is_construct::__nat> |
3566 | : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> |
3567 | { |
3568 | }; |
3569 | |
3570 | template <class _Tp> |
3571 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&, |
3572 | __is_construct::__nat> |
3573 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> |
3574 | { |
3575 | }; |
3576 | |
3577 | #else // !__has_feature(is_trivially_constructible) |
3578 | |
3579 | template <class _Tp> |
3580 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, |
3581 | __is_construct::__nat> |
3582 | : integral_constant<bool, is_scalar<_Tp>::value> |
3583 | { |
3584 | }; |
3585 | |
3586 | template <class _Tp> |
3587 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp, |
3588 | __is_construct::__nat> |
3589 | : integral_constant<bool, is_scalar<_Tp>::value> |
3590 | { |
3591 | }; |
3592 | |
3593 | template <class _Tp> |
3594 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&, |
3595 | __is_construct::__nat> |
3596 | : integral_constant<bool, is_scalar<_Tp>::value> |
3597 | { |
3598 | }; |
3599 | |
3600 | template <class _Tp> |
3601 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&, |
3602 | __is_construct::__nat> |
3603 | : integral_constant<bool, is_scalar<_Tp>::value> |
3604 | { |
3605 | }; |
3606 | |
3607 | #endif // !__has_feature(is_trivially_constructible) |
3608 | |
3609 | #endif // _LIBCPP_HAS_NO_VARIADICS |
3610 | |
3611 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
3612 | template <class _Tp, class... _Args> |
3613 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v |
3614 | = is_trivially_constructible<_Tp, _Args...>::value; |
3615 | #endif |
3616 | |
3617 | // is_trivially_default_constructible |
3618 | |
3619 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible |
3620 | : public is_trivially_constructible<_Tp> |
3621 | {}; |
3622 | |
3623 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3624 | template <class _Tp> |
3625 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v |
3626 | = is_trivially_default_constructible<_Tp>::value; |
3627 | #endif |
3628 | |
3629 | // is_trivially_copy_constructible |
3630 | |
3631 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible |
3632 | : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> |
3633 | {}; |
3634 | |
3635 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3636 | template <class _Tp> |
3637 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v |
3638 | = is_trivially_copy_constructible<_Tp>::value; |
3639 | #endif |
3640 | |
3641 | // is_trivially_move_constructible |
3642 | |
3643 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible |
3644 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3645 | : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
3646 | #else |
3647 | : public is_trivially_copy_constructible<_Tp> |
3648 | #endif |
3649 | {}; |
3650 | |
3651 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3652 | template <class _Tp> |
3653 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v |
3654 | = is_trivially_move_constructible<_Tp>::value; |
3655 | #endif |
3656 | |
3657 | // is_trivially_assignable |
3658 | |
3659 | #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 |
3660 | |
3661 | template <class _Tp, class _Arg> |
3662 | struct is_trivially_assignable |
3663 | : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> |
3664 | { |
3665 | }; |
3666 | |
3667 | #else // !__has_feature(is_trivially_assignable) |
3668 | |
3669 | template <class _Tp, class _Arg> |
3670 | struct is_trivially_assignable |
3671 | : public false_type {}; |
3672 | |
3673 | template <class _Tp> |
3674 | struct is_trivially_assignable<_Tp&, _Tp> |
3675 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
3676 | |
3677 | template <class _Tp> |
3678 | struct is_trivially_assignable<_Tp&, _Tp&> |
3679 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
3680 | |
3681 | template <class _Tp> |
3682 | struct is_trivially_assignable<_Tp&, const _Tp&> |
3683 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
3684 | |
3685 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3686 | |
3687 | template <class _Tp> |
3688 | struct is_trivially_assignable<_Tp&, _Tp&&> |
3689 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
3690 | |
3691 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3692 | |
3693 | #endif // !__has_feature(is_trivially_assignable) |
3694 | |
3695 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3696 | template <class _Tp, class _Arg> |
3697 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v |
3698 | = is_trivially_assignable<_Tp, _Arg>::value; |
3699 | #endif |
3700 | |
3701 | // is_trivially_copy_assignable |
3702 | |
3703 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable |
3704 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, |
3705 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
3706 | |
3707 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3708 | template <class _Tp> |
3709 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v |
3710 | = is_trivially_copy_assignable<_Tp>::value; |
3711 | #endif |
3712 | |
3713 | // is_trivially_move_assignable |
3714 | |
3715 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable |
3716 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, |
3717 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3718 | typename add_rvalue_reference<_Tp>::type> |
3719 | #else |
3720 | typename add_lvalue_reference<_Tp>::type> |
3721 | #endif |
3722 | {}; |
3723 | |
3724 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3725 | template <class _Tp> |
3726 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v |
3727 | = is_trivially_move_assignable<_Tp>::value; |
3728 | #endif |
3729 | |
3730 | // is_trivially_destructible |
3731 | |
3732 | #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) |
3733 | |
3734 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible |
3735 | : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {}; |
3736 | |
3737 | #else |
3738 | |
3739 | template <class _Tp> struct __libcpp_trivial_destructor |
3740 | : public integral_constant<bool, is_scalar<_Tp>::value || |
3741 | is_reference<_Tp>::value> {}; |
3742 | |
3743 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible |
3744 | : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; |
3745 | |
3746 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]> |
3747 | : public false_type {}; |
3748 | |
3749 | #endif |
3750 | |
3751 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3752 | template <class _Tp> |
3753 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v |
3754 | = is_trivially_destructible<_Tp>::value; |
3755 | #endif |
3756 | |
3757 | // is_nothrow_constructible |
3758 | |
3759 | #if 0 |
3760 | template <class _Tp, class... _Args> |
3761 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible |
3762 | : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))> |
3763 | { |
3764 | }; |
3765 | |
3766 | #else |
3767 | |
3768 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
3769 | |
3770 | #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) |
3771 | |
3772 | template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; |
3773 | |
3774 | template <class _Tp, class... _Args> |
3775 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...> |
3776 | : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> |
3777 | { |
3778 | }; |
3779 | |
3780 | template <class _Tp> |
3781 | void __implicit_conversion_to(_Tp) noexcept { } |
3782 | |
3783 | template <class _Tp, class _Arg> |
3784 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg> |
3785 | : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))> |
3786 | { |
3787 | }; |
3788 | |
3789 | template <class _Tp, bool _IsReference, class... _Args> |
3790 | struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...> |
3791 | : public false_type |
3792 | { |
3793 | }; |
3794 | |
3795 | template <class _Tp, class... _Args> |
3796 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible |
3797 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...> |
3798 | { |
3799 | }; |
3800 | |
3801 | template <class _Tp, size_t _Ns> |
3802 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> |
3803 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> |
3804 | { |
3805 | }; |
3806 | |
3807 | #else // __has_feature(cxx_noexcept) |
3808 | |
3809 | template <class _Tp, class... _Args> |
3810 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible |
3811 | : false_type |
3812 | { |
3813 | }; |
3814 | |
3815 | template <class _Tp> |
3816 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp> |
3817 | #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403) |
3818 | : integral_constant<bool, __has_nothrow_constructor(_Tp)> |
3819 | #else |
3820 | : integral_constant<bool, is_scalar<_Tp>::value> |
3821 | #endif |
3822 | { |
3823 | }; |
3824 | |
3825 | template <class _Tp> |
3826 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3827 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&> |
3828 | #else |
3829 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp> |
3830 | #endif |
3831 | #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) |
3832 | : integral_constant<bool, __has_nothrow_copy(_Tp)> |
3833 | #else |
3834 | : integral_constant<bool, is_scalar<_Tp>::value> |
3835 | #endif |
3836 | { |
3837 | }; |
3838 | |
3839 | template <class _Tp> |
3840 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&> |
3841 | #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) |
3842 | : integral_constant<bool, __has_nothrow_copy(_Tp)> |
3843 | #else |
3844 | : integral_constant<bool, is_scalar<_Tp>::value> |
3845 | #endif |
3846 | { |
3847 | }; |
3848 | |
3849 | template <class _Tp> |
3850 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&> |
3851 | #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) |
3852 | : integral_constant<bool, __has_nothrow_copy(_Tp)> |
3853 | #else |
3854 | : integral_constant<bool, is_scalar<_Tp>::value> |
3855 | #endif |
3856 | { |
3857 | }; |
3858 | |
3859 | #endif // __has_feature(cxx_noexcept) |
3860 | |
3861 | #else // _LIBCPP_HAS_NO_VARIADICS |
3862 | |
3863 | template <class _Tp, class _A0 = __is_construct::__nat, |
3864 | class _A1 = __is_construct::__nat> |
3865 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible |
3866 | : false_type |
3867 | { |
3868 | }; |
3869 | |
3870 | template <class _Tp> |
3871 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat, |
3872 | __is_construct::__nat> |
3873 | #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403) |
3874 | : integral_constant<bool, __has_nothrow_constructor(_Tp)> |
3875 | #else |
3876 | : integral_constant<bool, is_scalar<_Tp>::value> |
3877 | #endif |
3878 | { |
3879 | }; |
3880 | |
3881 | template <class _Tp> |
3882 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp, |
3883 | __is_construct::__nat> |
3884 | #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) |
3885 | : integral_constant<bool, __has_nothrow_copy(_Tp)> |
3886 | #else |
3887 | : integral_constant<bool, is_scalar<_Tp>::value> |
3888 | #endif |
3889 | { |
3890 | }; |
3891 | |
3892 | template <class _Tp> |
3893 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&, |
3894 | __is_construct::__nat> |
3895 | #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) |
3896 | : integral_constant<bool, __has_nothrow_copy(_Tp)> |
3897 | #else |
3898 | : integral_constant<bool, is_scalar<_Tp>::value> |
3899 | #endif |
3900 | { |
3901 | }; |
3902 | |
3903 | template <class _Tp> |
3904 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&, |
3905 | __is_construct::__nat> |
3906 | #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) |
3907 | : integral_constant<bool, __has_nothrow_copy(_Tp)> |
3908 | #else |
3909 | : integral_constant<bool, is_scalar<_Tp>::value> |
3910 | #endif |
3911 | { |
3912 | }; |
3913 | |
3914 | #endif // _LIBCPP_HAS_NO_VARIADICS |
3915 | #endif // __has_feature(is_nothrow_constructible) |
3916 | |
3917 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
3918 | template <class _Tp, class ..._Args> |
3919 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v |
3920 | = is_nothrow_constructible<_Tp, _Args...>::value; |
3921 | #endif |
3922 | |
3923 | // is_nothrow_default_constructible |
3924 | |
3925 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible |
3926 | : public is_nothrow_constructible<_Tp> |
3927 | {}; |
3928 | |
3929 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3930 | template <class _Tp> |
3931 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v |
3932 | = is_nothrow_default_constructible<_Tp>::value; |
3933 | #endif |
3934 | |
3935 | // is_nothrow_copy_constructible |
3936 | |
3937 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible |
3938 | : public is_nothrow_constructible<_Tp, |
3939 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
3940 | |
3941 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3942 | template <class _Tp> |
3943 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v |
3944 | = is_nothrow_copy_constructible<_Tp>::value; |
3945 | #endif |
3946 | |
3947 | // is_nothrow_move_constructible |
3948 | |
3949 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible |
3950 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
3951 | : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
3952 | #else |
3953 | : public is_nothrow_copy_constructible<_Tp> |
3954 | #endif |
3955 | {}; |
3956 | |
3957 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
3958 | template <class _Tp> |
3959 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v |
3960 | = is_nothrow_move_constructible<_Tp>::value; |
3961 | #endif |
3962 | |
3963 | // is_nothrow_assignable |
3964 | |
3965 | #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) |
3966 | |
3967 | template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; |
3968 | |
3969 | template <class _Tp, class _Arg> |
3970 | struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> |
3971 | : public false_type |
3972 | { |
3973 | }; |
3974 | |
3975 | template <class _Tp, class _Arg> |
3976 | struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> |
3977 | : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > |
3978 | { |
3979 | }; |
3980 | |
3981 | template <class _Tp, class _Arg> |
3982 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable |
3983 | : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> |
3984 | { |
3985 | }; |
3986 | |
3987 | #else // __has_feature(cxx_noexcept) |
3988 | |
3989 | template <class _Tp, class _Arg> |
3990 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable |
3991 | : public false_type {}; |
3992 | |
3993 | template <class _Tp> |
3994 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp> |
3995 | #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) |
3996 | : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; |
3997 | #else |
3998 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
3999 | #endif |
4000 | |
4001 | template <class _Tp> |
4002 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&> |
4003 | #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) |
4004 | : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; |
4005 | #else |
4006 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
4007 | #endif |
4008 | |
4009 | template <class _Tp> |
4010 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&> |
4011 | #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) |
4012 | : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; |
4013 | #else |
4014 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
4015 | #endif |
4016 | |
4017 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
4018 | |
4019 | template <class _Tp> |
4020 | struct is_nothrow_assignable<_Tp&, _Tp&&> |
4021 | #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) |
4022 | : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; |
4023 | #else |
4024 | : integral_constant<bool, is_scalar<_Tp>::value> {}; |
4025 | #endif |
4026 | |
4027 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
4028 | |
4029 | #endif // __has_feature(cxx_noexcept) |
4030 | |
4031 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4032 | template <class _Tp, class _Arg> |
4033 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v |
4034 | = is_nothrow_assignable<_Tp, _Arg>::value; |
4035 | #endif |
4036 | |
4037 | // is_nothrow_copy_assignable |
4038 | |
4039 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable |
4040 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, |
4041 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
4042 | |
4043 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4044 | template <class _Tp> |
4045 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v |
4046 | = is_nothrow_copy_assignable<_Tp>::value; |
4047 | #endif |
4048 | |
4049 | // is_nothrow_move_assignable |
4050 | |
4051 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable |
4052 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, |
4053 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
4054 | typename add_rvalue_reference<_Tp>::type> |
4055 | #else |
4056 | typename add_lvalue_reference<_Tp>::type> |
4057 | #endif |
4058 | {}; |
4059 | |
4060 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4061 | template <class _Tp> |
4062 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v |
4063 | = is_nothrow_move_assignable<_Tp>::value; |
4064 | #endif |
4065 | |
4066 | // is_nothrow_destructible |
4067 | |
4068 | #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) |
4069 | |
4070 | template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; |
4071 | |
4072 | template <class _Tp> |
4073 | struct __libcpp_is_nothrow_destructible<false, _Tp> |
4074 | : public false_type |
4075 | { |
4076 | }; |
4077 | |
4078 | template <class _Tp> |
4079 | struct __libcpp_is_nothrow_destructible<true, _Tp> |
4080 | : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > |
4081 | { |
4082 | }; |
4083 | |
4084 | template <class _Tp> |
4085 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible |
4086 | : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> |
4087 | { |
4088 | }; |
4089 | |
4090 | template <class _Tp, size_t _Ns> |
4091 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> |
4092 | : public is_nothrow_destructible<_Tp> |
4093 | { |
4094 | }; |
4095 | |
4096 | template <class _Tp> |
4097 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> |
4098 | : public true_type |
4099 | { |
4100 | }; |
4101 | |
4102 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
4103 | |
4104 | template <class _Tp> |
4105 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> |
4106 | : public true_type |
4107 | { |
4108 | }; |
4109 | |
4110 | #endif |
4111 | |
4112 | #else |
4113 | |
4114 | template <class _Tp> struct __libcpp_nothrow_destructor |
4115 | : public integral_constant<bool, is_scalar<_Tp>::value || |
4116 | is_reference<_Tp>::value> {}; |
4117 | |
4118 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible |
4119 | : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; |
4120 | |
4121 | template <class _Tp> |
4122 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> |
4123 | : public false_type {}; |
4124 | |
4125 | #endif |
4126 | |
4127 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4128 | template <class _Tp> |
4129 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v |
4130 | = is_nothrow_destructible<_Tp>::value; |
4131 | #endif |
4132 | |
4133 | // is_pod |
4134 | |
4135 | #if __has_feature(is_pod) || (_GNUC_VER >= 403) |
4136 | |
4137 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod |
4138 | : public integral_constant<bool, __is_pod(_Tp)> {}; |
4139 | |
4140 | #else |
4141 | |
4142 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod |
4143 | : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && |
4144 | is_trivially_copy_constructible<_Tp>::value && |
4145 | is_trivially_copy_assignable<_Tp>::value && |
4146 | is_trivially_destructible<_Tp>::value> {}; |
4147 | |
4148 | #endif |
4149 | |
4150 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4151 | template <class _Tp> |
4152 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v |
4153 | = is_pod<_Tp>::value; |
4154 | #endif |
4155 | |
4156 | // is_literal_type; |
4157 | |
4158 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type |
4159 | #ifdef _LIBCPP_IS_LITERAL |
4160 | : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)> |
4161 | #else |
4162 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || |
4163 | is_reference<typename remove_all_extents<_Tp>::type>::value> |
4164 | #endif |
4165 | {}; |
4166 | |
4167 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4168 | template <class _Tp> |
4169 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v |
4170 | = is_literal_type<_Tp>::value; |
4171 | #endif |
4172 | |
4173 | // is_standard_layout; |
4174 | |
4175 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout |
4176 | #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407) |
4177 | : public integral_constant<bool, __is_standard_layout(_Tp)> |
4178 | #else |
4179 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> |
4180 | #endif |
4181 | {}; |
4182 | |
4183 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4184 | template <class _Tp> |
4185 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v |
4186 | = is_standard_layout<_Tp>::value; |
4187 | #endif |
4188 | |
4189 | // is_trivially_copyable; |
4190 | |
4191 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable |
4192 | #if __has_feature(is_trivially_copyable) |
4193 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> |
4194 | #elif _GNUC_VER >= 501 |
4195 | : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)> |
4196 | #else |
4197 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> |
4198 | #endif |
4199 | {}; |
4200 | |
4201 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4202 | template <class _Tp> |
4203 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v |
4204 | = is_trivially_copyable<_Tp>::value; |
4205 | #endif |
4206 | |
4207 | // is_trivial; |
4208 | |
4209 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial |
4210 | #if __has_feature(is_trivial) || _GNUC_VER >= 407 |
4211 | : public integral_constant<bool, __is_trivial(_Tp)> |
4212 | #else |
4213 | : integral_constant<bool, is_trivially_copyable<_Tp>::value && |
4214 | is_trivially_default_constructible<_Tp>::value> |
4215 | #endif |
4216 | {}; |
4217 | |
4218 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) |
4219 | template <class _Tp> |
4220 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v |
4221 | = is_trivial<_Tp>::value; |
4222 | #endif |
4223 | |
4224 | template <class _Tp> struct __is_reference_wrapper_impl : public false_type {}; |
4225 | template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {}; |
4226 | template <class _Tp> struct __is_reference_wrapper |
4227 | : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {}; |
4228 | |
4229 | #ifndef _LIBCPP_CXX03_LANG |
4230 | |
4231 | template <class _Fp, class _A0, |
4232 | class _DecayFp = typename decay<_Fp>::type, |
4233 | class _DecayA0 = typename decay<_A0>::type, |
4234 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
4235 | using __enable_if_bullet1 = typename enable_if |
4236 | < |
4237 | is_member_function_pointer<_DecayFp>::value |
4238 | && is_base_of<_ClassT, _DecayA0>::value |
4239 | >::type; |
4240 | |
4241 | template <class _Fp, class _A0, |
4242 | class _DecayFp = typename decay<_Fp>::type, |
4243 | class _DecayA0 = typename decay<_A0>::type> |
4244 | using __enable_if_bullet2 = typename enable_if |
4245 | < |
4246 | is_member_function_pointer<_DecayFp>::value |
4247 | && __is_reference_wrapper<_DecayA0>::value |
4248 | >::type; |
4249 | |
4250 | template <class _Fp, class _A0, |
4251 | class _DecayFp = typename decay<_Fp>::type, |
4252 | class _DecayA0 = typename decay<_A0>::type, |
4253 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
4254 | using __enable_if_bullet3 = typename enable_if |
4255 | < |
4256 | is_member_function_pointer<_DecayFp>::value |
4257 | && !is_base_of<_ClassT, _DecayA0>::value |
4258 | && !__is_reference_wrapper<_DecayA0>::value |
4259 | >::type; |
4260 | |
4261 | template <class _Fp, class _A0, |
4262 | class _DecayFp = typename decay<_Fp>::type, |
4263 | class _DecayA0 = typename decay<_A0>::type, |
4264 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
4265 | using __enable_if_bullet4 = typename enable_if |
4266 | < |
4267 | is_member_object_pointer<_DecayFp>::value |
4268 | && is_base_of<_ClassT, _DecayA0>::value |
4269 | >::type; |
4270 | |
4271 | template <class _Fp, class _A0, |
4272 | class _DecayFp = typename decay<_Fp>::type, |
4273 | class _DecayA0 = typename decay<_A0>::type> |
4274 | using __enable_if_bullet5 = typename enable_if |
4275 | < |
4276 | is_member_object_pointer<_DecayFp>::value |
4277 | && __is_reference_wrapper<_DecayA0>::value |
4278 | >::type; |
4279 | |
4280 | template <class _Fp, class _A0, |
4281 | class _DecayFp = typename decay<_Fp>::type, |
4282 | class _DecayA0 = typename decay<_A0>::type, |
4283 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
4284 | using __enable_if_bullet6 = typename enable_if |
4285 | < |
4286 | is_member_object_pointer<_DecayFp>::value |
4287 | && !is_base_of<_ClassT, _DecayA0>::value |
4288 | && !__is_reference_wrapper<_DecayA0>::value |
4289 | >::type; |
4290 | |
4291 | // __invoke forward declarations |
4292 | |
4293 | // fall back - none of the bullets |
4294 | |
4295 | #define _LIBCPP_INVOKE_RETURN(...) \ |
4296 | noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ |
4297 | { return __VA_ARGS__; } |
4298 | |
4299 | template <class ..._Args> |
4300 | auto __invoke(__any, _Args&& ...__args) -> __nat; |
4301 | |
4302 | template <class ..._Args> |
4303 | auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat; |
4304 | |
4305 | // bullets 1, 2 and 3 |
4306 | |
4307 | template <class _Fp, class _A0, class ..._Args, |
4308 | class = __enable_if_bullet1<_Fp, _A0>> |
4309 | inline _LIBCPP_INLINE_VISIBILITY |
4310 | auto |
4311 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
4312 | _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) |
4313 | |
4314 | template <class _Fp, class _A0, class ..._Args, |
4315 | class = __enable_if_bullet1<_Fp, _A0>> |
4316 | inline _LIBCPP_INLINE_VISIBILITY |
4317 | _LIBCPP_CONSTEXPR auto |
4318 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
4319 | _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) |
4320 | |
4321 | template <class _Fp, class _A0, class ..._Args, |
4322 | class = __enable_if_bullet2<_Fp, _A0>> |
4323 | inline _LIBCPP_INLINE_VISIBILITY |
4324 | auto |
4325 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
4326 | _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) |
4327 | |
4328 | template <class _Fp, class _A0, class ..._Args, |
4329 | class = __enable_if_bullet2<_Fp, _A0>> |
4330 | inline _LIBCPP_INLINE_VISIBILITY |
4331 | _LIBCPP_CONSTEXPR auto |
4332 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
4333 | _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) |
4334 | |
4335 | template <class _Fp, class _A0, class ..._Args, |
4336 | class = __enable_if_bullet3<_Fp, _A0>> |
4337 | inline _LIBCPP_INLINE_VISIBILITY |
4338 | auto |
4339 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
4340 | _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) |
4341 | |
4342 | template <class _Fp, class _A0, class ..._Args, |
4343 | class = __enable_if_bullet3<_Fp, _A0>> |
4344 | inline _LIBCPP_INLINE_VISIBILITY |
4345 | _LIBCPP_CONSTEXPR auto |
4346 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
4347 | _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) |
4348 | |
4349 | // bullets 4, 5 and 6 |
4350 | |
4351 | template <class _Fp, class _A0, |
4352 | class = __enable_if_bullet4<_Fp, _A0>> |
4353 | inline _LIBCPP_INLINE_VISIBILITY |
4354 | auto |
4355 | __invoke(_Fp&& __f, _A0&& __a0) |
4356 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) |
4357 | |
4358 | template <class _Fp, class _A0, |
4359 | class = __enable_if_bullet4<_Fp, _A0>> |
4360 | inline _LIBCPP_INLINE_VISIBILITY |
4361 | _LIBCPP_CONSTEXPR auto |
4362 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
4363 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) |
4364 | |
4365 | template <class _Fp, class _A0, |
4366 | class = __enable_if_bullet5<_Fp, _A0>> |
4367 | inline _LIBCPP_INLINE_VISIBILITY |
4368 | auto |
4369 | __invoke(_Fp&& __f, _A0&& __a0) |
4370 | _LIBCPP_INVOKE_RETURN(__a0.get().*__f) |
4371 | |
4372 | template <class _Fp, class _A0, |
4373 | class = __enable_if_bullet5<_Fp, _A0>> |
4374 | inline _LIBCPP_INLINE_VISIBILITY |
4375 | _LIBCPP_CONSTEXPR auto |
4376 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
4377 | _LIBCPP_INVOKE_RETURN(__a0.get().*__f) |
4378 | |
4379 | template <class _Fp, class _A0, |
4380 | class = __enable_if_bullet6<_Fp, _A0>> |
4381 | inline _LIBCPP_INLINE_VISIBILITY |
4382 | auto |
4383 | __invoke(_Fp&& __f, _A0&& __a0) |
4384 | _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) |
4385 | |
4386 | template <class _Fp, class _A0, |
4387 | class = __enable_if_bullet6<_Fp, _A0>> |
4388 | inline _LIBCPP_INLINE_VISIBILITY |
4389 | _LIBCPP_CONSTEXPR auto |
4390 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
4391 | _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) |
4392 | |
4393 | // bullet 7 |
4394 | |
4395 | template <class _Fp, class ..._Args> |
4396 | inline _LIBCPP_INLINE_VISIBILITY |
4397 | auto |
4398 | __invoke(_Fp&& __f, _Args&& ...__args) |
4399 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) |
4400 | |
4401 | template <class _Fp, class ..._Args> |
4402 | inline _LIBCPP_INLINE_VISIBILITY |
4403 | _LIBCPP_CONSTEXPR auto |
4404 | __invoke_constexpr(_Fp&& __f, _Args&& ...__args) |
4405 | _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) |
4406 | |
4407 | #undef _LIBCPP_INVOKE_RETURN |
4408 | |
4409 | // __invokable |
4410 | template <class _Ret, class _Fp, class ..._Args> |
4411 | struct __invokable_r |
4412 | { |
4413 | template <class _XFp, class ..._XArgs> |
4414 | static auto __try_call(int) -> decltype( |
4415 | _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...)); |
4416 | template <class _XFp, class ..._XArgs> |
4417 | static __nat __try_call(...); |
4418 | |
4419 | // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void, |
4420 | // or incomplete array types as required by the standard. |
4421 | using _Result = decltype(__try_call<_Fp, _Args...>(0)); |
4422 | |
4423 | using type = |
4424 | typename conditional< |
4425 | !is_same<_Result, __nat>::value, |
4426 | typename conditional< |
4427 | is_void<_Ret>::value, |
4428 | true_type, |
4429 | is_convertible<_Result, _Ret> |
4430 | >::type, |
4431 | false_type |
4432 | >::type; |
4433 | static const bool value = type::value; |
4434 | }; |
4435 | template <class _Fp, class ..._Args> |
4436 | using __invokable = __invokable_r<void, _Fp, _Args...>; |
4437 | |
4438 | template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args> |
4439 | struct __nothrow_invokable_r_imp { |
4440 | static const bool value = false; |
4441 | }; |
4442 | |
4443 | template <class _Ret, class _Fp, class ..._Args> |
4444 | struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> |
4445 | { |
4446 | typedef __nothrow_invokable_r_imp _ThisT; |
4447 | |
4448 | template <class _Tp> |
4449 | static void __test_noexcept(_Tp) noexcept; |
4450 | |
4451 | static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( |
4452 | _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...))); |
4453 | }; |
4454 | |
4455 | template <class _Ret, class _Fp, class ..._Args> |
4456 | struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> |
4457 | { |
4458 | static const bool value = noexcept( |
4459 | _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)); |
4460 | }; |
4461 | |
4462 | template <class _Ret, class _Fp, class ..._Args> |
4463 | using __nothrow_invokable_r = |
4464 | __nothrow_invokable_r_imp< |
4465 | __invokable_r<_Ret, _Fp, _Args...>::value, |
4466 | is_void<_Ret>::value, |
4467 | _Ret, _Fp, _Args... |
4468 | >; |
4469 | |
4470 | template <class _Fp, class ..._Args> |
4471 | using __nothrow_invokable = |
4472 | __nothrow_invokable_r_imp< |
4473 | __invokable<_Fp, _Args...>::value, |
4474 | true, void, _Fp, _Args... |
4475 | >; |
4476 | |
4477 | template <class _Fp, class ..._Args> |
4478 | struct __invoke_of |
4479 | : public enable_if< |
4480 | __invokable<_Fp, _Args...>::value, |
4481 | typename __invokable_r<void, _Fp, _Args...>::_Result> |
4482 | { |
4483 | }; |
4484 | |
4485 | // result_of |
4486 | |
4487 | template <class _Fp, class ..._Args> |
4488 | class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> |
4489 | : public __invoke_of<_Fp, _Args...> |
4490 | { |
4491 | }; |
4492 | |
4493 | #if _LIBCPP_STD_VER > 11 |
4494 | template <class _Tp> using result_of_t = typename result_of<_Tp>::type; |
4495 | #endif |
4496 | |
4497 | #if _LIBCPP_STD_VER > 14 |
4498 | |
4499 | // invoke_result |
4500 | |
4501 | template <class _Fn, class... _Args> |
4502 | struct _LIBCPP_TEMPLATE_VIS invoke_result |
4503 | : __invoke_of<_Fn, _Args...> |
4504 | { |
4505 | }; |
4506 | |
4507 | template <class _Fn, class... _Args> |
4508 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; |
4509 | |
4510 | // is_invocable |
4511 | |
4512 | template <class _Fn, class ..._Args> |
4513 | struct _LIBCPP_TEMPLATE_VIS is_invocable |
4514 | : integral_constant<bool, __invokable<_Fn, _Args...>::value> {}; |
4515 | |
4516 | template <class _Ret, class _Fn, class ..._Args> |
4517 | struct _LIBCPP_TEMPLATE_VIS is_invocable_r |
4518 | : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; |
4519 | |
4520 | template <class _Fn, class ..._Args> |
4521 | _LIBCPP_INLINE_VAR constexpr bool is_invocable_v |
4522 | = is_invocable<_Fn, _Args...>::value; |
4523 | |
4524 | template <class _Ret, class _Fn, class ..._Args> |
4525 | _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v |
4526 | = is_invocable_r<_Ret, _Fn, _Args...>::value; |
4527 | |
4528 | // is_nothrow_invocable |
4529 | |
4530 | template <class _Fn, class ..._Args> |
4531 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable |
4532 | : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {}; |
4533 | |
4534 | template <class _Ret, class _Fn, class ..._Args> |
4535 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r |
4536 | : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; |
4537 | |
4538 | template <class _Fn, class ..._Args> |
4539 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v |
4540 | = is_nothrow_invocable<_Fn, _Args...>::value; |
4541 | |
4542 | template <class _Ret, class _Fn, class ..._Args> |
4543 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v |
4544 | = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; |
4545 | |
4546 | #endif // _LIBCPP_STD_VER > 14 |
4547 | |
4548 | #endif // !defined(_LIBCPP_CXX03_LANG) |
4549 | |
4550 | template <class _Tp> struct __is_swappable; |
4551 | template <class _Tp> struct __is_nothrow_swappable; |
4552 | |
4553 | template <class _Tp> |
4554 | inline _LIBCPP_INLINE_VISIBILITY |
4555 | #ifndef _LIBCPP_CXX03_LANG |
4556 | typename enable_if |
4557 | < |
4558 | is_move_constructible<_Tp>::value && |
4559 | is_move_assignable<_Tp>::value |
4560 | >::type |
4561 | #else |
4562 | void |
4563 | #endif |
4564 | swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && |
4565 | is_nothrow_move_assignable<_Tp>::value) |
4566 | { |
4567 | _Tp __t(_VSTD::move(__x)); |
4568 | __x = _VSTD::move(__y); |
4569 | __y = _VSTD::move(__t); |
4570 | } |
4571 | |
4572 | template<class _Tp, size_t _Np> |
4573 | inline _LIBCPP_INLINE_VISIBILITY |
4574 | typename enable_if< |
4575 | __is_swappable<_Tp>::value |
4576 | >::type |
4577 | swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); |
4578 | |
4579 | template <class _ForwardIterator1, class _ForwardIterator2> |
4580 | inline _LIBCPP_INLINE_VISIBILITY |
4581 | void |
4582 | iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) |
4583 | // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) |
4584 | _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), |
4585 | *_VSTD::declval<_ForwardIterator2>()))) |
4586 | { |
4587 | swap(*__a, *__b); |
4588 | } |
4589 | |
4590 | // __swappable |
4591 | |
4592 | namespace __detail |
4593 | { |
4594 | // ALL generic swap overloads MUST already have a declaration available at this point. |
4595 | |
4596 | template <class _Tp, class _Up = _Tp, |
4597 | bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value> |
4598 | struct __swappable_with |
4599 | { |
4600 | template <class _LHS, class _RHS> |
4601 | static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>())) |
4602 | __test_swap(int); |
4603 | template <class, class> |
4604 | static __nat __test_swap(long); |
4605 | |
4606 | // Extra parens are needed for the C++03 definition of decltype. |
4607 | typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1; |
4608 | typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2; |
4609 | |
4610 | static const bool value = !is_same<__swap1, __nat>::value |
4611 | && !is_same<__swap2, __nat>::value; |
4612 | }; |
4613 | |
4614 | template <class _Tp, class _Up> |
4615 | struct __swappable_with<_Tp, _Up, false> : false_type {}; |
4616 | |
4617 | template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value> |
4618 | struct __nothrow_swappable_with { |
4619 | static const bool value = |
4620 | #ifndef _LIBCPP_HAS_NO_NOEXCEPT |
4621 | noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>())) |
4622 | && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>())); |
4623 | #else |
4624 | false; |
4625 | #endif |
4626 | }; |
4627 | |
4628 | template <class _Tp, class _Up> |
4629 | struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {}; |
4630 | |
4631 | } // __detail |
4632 | |
4633 | template <class _Tp> |
4634 | struct __is_swappable |
4635 | : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> |
4636 | { |
4637 | }; |
4638 | |
4639 | template <class _Tp> |
4640 | struct __is_nothrow_swappable |
4641 | : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> |
4642 | { |
4643 | }; |
4644 | |
4645 | #if _LIBCPP_STD_VER > 14 |
4646 | |
4647 | template <class _Tp, class _Up> |
4648 | struct _LIBCPP_TEMPLATE_VIS is_swappable_with |
4649 | : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> |
4650 | { |
4651 | }; |
4652 | |
4653 | template <class _Tp> |
4654 | struct _LIBCPP_TEMPLATE_VIS is_swappable |
4655 | : public conditional< |
4656 | __is_referenceable<_Tp>::value, |
4657 | is_swappable_with< |
4658 | typename add_lvalue_reference<_Tp>::type, |
4659 | typename add_lvalue_reference<_Tp>::type>, |
4660 | false_type |
4661 | >::type |
4662 | { |
4663 | }; |
4664 | |
4665 | template <class _Tp, class _Up> |
4666 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with |
4667 | : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> |
4668 | { |
4669 | }; |
4670 | |
4671 | template <class _Tp> |
4672 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable |
4673 | : public conditional< |
4674 | __is_referenceable<_Tp>::value, |
4675 | is_nothrow_swappable_with< |
4676 | typename add_lvalue_reference<_Tp>::type, |
4677 | typename add_lvalue_reference<_Tp>::type>, |
4678 | false_type |
4679 | >::type |
4680 | { |
4681 | }; |
4682 | |
4683 | template <class _Tp, class _Up> |
4684 | _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v |
4685 | = is_swappable_with<_Tp, _Up>::value; |
4686 | |
4687 | template <class _Tp> |
4688 | _LIBCPP_INLINE_VAR constexpr bool is_swappable_v |
4689 | = is_swappable<_Tp>::value; |
4690 | |
4691 | template <class _Tp, class _Up> |
4692 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v |
4693 | = is_nothrow_swappable_with<_Tp, _Up>::value; |
4694 | |
4695 | template <class _Tp> |
4696 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v |
4697 | = is_nothrow_swappable<_Tp>::value; |
4698 | |
4699 | #endif // _LIBCPP_STD_VER > 14 |
4700 | |
4701 | #ifdef _LIBCPP_UNDERLYING_TYPE |
4702 | |
4703 | template <class _Tp> |
4704 | struct underlying_type |
4705 | { |
4706 | typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type; |
4707 | }; |
4708 | |
4709 | #if _LIBCPP_STD_VER > 11 |
4710 | template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; |
4711 | #endif |
4712 | |
4713 | #else // _LIBCPP_UNDERLYING_TYPE |
4714 | |
4715 | template <class _Tp, bool _Support = false> |
4716 | struct underlying_type |
4717 | { |
4718 | static_assert(_Support, "The underyling_type trait requires compiler " |
4719 | "support. Either no such support exists or " |
4720 | "libc++ does not know how to use it." ); |
4721 | }; |
4722 | |
4723 | #endif // _LIBCPP_UNDERLYING_TYPE |
4724 | |
4725 | |
4726 | template <class _Tp, bool = is_enum<_Tp>::value> |
4727 | struct __sfinae_underlying_type |
4728 | { |
4729 | typedef typename underlying_type<_Tp>::type type; |
4730 | typedef decltype(((type)1) + 0) __promoted_type; |
4731 | }; |
4732 | |
4733 | template <class _Tp> |
4734 | struct __sfinae_underlying_type<_Tp, false> {}; |
4735 | |
4736 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4737 | int __convert_to_integral(int __val) { return __val; } |
4738 | |
4739 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4740 | unsigned __convert_to_integral(unsigned __val) { return __val; } |
4741 | |
4742 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4743 | long __convert_to_integral(long __val) { return __val; } |
4744 | |
4745 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4746 | unsigned long __convert_to_integral(unsigned long __val) { return __val; } |
4747 | |
4748 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4749 | long long __convert_to_integral(long long __val) { return __val; } |
4750 | |
4751 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4752 | unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } |
4753 | |
4754 | template<typename _Fp> |
4755 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4756 | typename enable_if<is_floating_point<_Fp>::value, long long>::type |
4757 | __convert_to_integral(_Fp __val) { return __val; } |
4758 | |
4759 | #ifndef _LIBCPP_HAS_NO_INT128 |
4760 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4761 | __int128_t __convert_to_integral(__int128_t __val) { return __val; } |
4762 | |
4763 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4764 | __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } |
4765 | #endif |
4766 | |
4767 | template <class _Tp> |
4768 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
4769 | typename __sfinae_underlying_type<_Tp>::__promoted_type |
4770 | __convert_to_integral(_Tp __val) { return __val; } |
4771 | |
4772 | #ifndef _LIBCPP_CXX03_LANG |
4773 | |
4774 | template <class _Tp> |
4775 | struct __has_operator_addressof_member_imp |
4776 | { |
4777 | template <class _Up> |
4778 | static auto __test(int) |
4779 | -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type; |
4780 | template <class> |
4781 | static auto __test(long) -> false_type; |
4782 | |
4783 | static const bool value = decltype(__test<_Tp>(0))::value; |
4784 | }; |
4785 | |
4786 | template <class _Tp> |
4787 | struct __has_operator_addressof_free_imp |
4788 | { |
4789 | template <class _Up> |
4790 | static auto __test(int) |
4791 | -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type; |
4792 | template <class> |
4793 | static auto __test(long) -> false_type; |
4794 | |
4795 | static const bool value = decltype(__test<_Tp>(0))::value; |
4796 | }; |
4797 | |
4798 | template <class _Tp> |
4799 | struct __has_operator_addressof |
4800 | : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value |
4801 | || __has_operator_addressof_free_imp<_Tp>::value> |
4802 | {}; |
4803 | |
4804 | #endif // _LIBCPP_CXX03_LANG |
4805 | |
4806 | #if _LIBCPP_STD_VER > 14 |
4807 | |
4808 | template <class...> using void_t = void; |
4809 | |
4810 | # ifndef _LIBCPP_HAS_NO_VARIADICS |
4811 | template <class... _Args> |
4812 | struct conjunction : __and_<_Args...> {}; |
4813 | template<class... _Args> |
4814 | _LIBCPP_INLINE_VAR constexpr bool conjunction_v |
4815 | = conjunction<_Args...>::value; |
4816 | |
4817 | template <class... _Args> |
4818 | struct disjunction : __or_<_Args...> {}; |
4819 | template<class... _Args> |
4820 | _LIBCPP_INLINE_VAR constexpr bool disjunction_v |
4821 | = disjunction<_Args...>::value; |
4822 | |
4823 | template <class _Tp> |
4824 | struct negation : __not_<_Tp> {}; |
4825 | template<class _Tp> |
4826 | _LIBCPP_INLINE_VAR constexpr bool negation_v |
4827 | = negation<_Tp>::value; |
4828 | # endif // _LIBCPP_HAS_NO_VARIADICS |
4829 | #endif // _LIBCPP_STD_VER > 14 |
4830 | |
4831 | // These traits are used in __tree and __hash_table |
4832 | #ifndef _LIBCPP_CXX03_LANG |
4833 | struct {}; |
4834 | struct {}; |
4835 | struct {}; |
4836 | |
4837 | template <class _ValTy, class _Key, |
4838 | class _RawValTy = typename __unconstref<_ValTy>::type> |
4839 | struct |
4840 | : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag, |
4841 | __extract_key_fail_tag>::type {}; |
4842 | |
4843 | template <class _Pair, class _Key, class _First, class _Second> |
4844 | struct <_Pair, _Key, pair<_First, _Second>> |
4845 | : conditional<is_same<typename remove_const<_First>::type, _Key>::value, |
4846 | __extract_key_first_tag, __extract_key_fail_tag>::type {}; |
4847 | |
4848 | // __can_extract_map_key uses true_type/false_type instead of the tags. |
4849 | // It returns true if _Key != _ContainerValueTy (the container is a map not a set) |
4850 | // and _ValTy == _Key. |
4851 | template <class _ValTy, class _Key, class _ContainerValueTy, |
4852 | class _RawValTy = typename __unconstref<_ValTy>::type> |
4853 | struct |
4854 | : integral_constant<bool, is_same<_RawValTy, _Key>::value> {}; |
4855 | |
4856 | // This specialization returns __extract_key_fail_tag for non-map containers |
4857 | // because _Key == _ContainerValueTy |
4858 | template <class _ValTy, class _Key, class _RawValTy> |
4859 | struct <_ValTy, _Key, _Key, _RawValTy> |
4860 | : false_type {}; |
4861 | |
4862 | #endif |
4863 | |
4864 | #if _LIBCPP_STD_VER > 17 |
4865 | enum class endian |
4866 | { |
4867 | little = 0xDEAD, |
4868 | big = 0xFACE, |
4869 | #if defined(_LIBCPP_LITTLE_ENDIAN) |
4870 | native = little |
4871 | #elif defined(_LIBCPP_BIG_ENDIAN) |
4872 | native = big |
4873 | #else |
4874 | native = 0xCAFE |
4875 | #endif |
4876 | }; |
4877 | #endif |
4878 | |
4879 | _LIBCPP_END_NAMESPACE_STD |
4880 | |
4881 | #if _LIBCPP_STD_VER > 14 |
4882 | // std::byte |
4883 | namespace std // purposefully not versioned |
4884 | { |
4885 | template <class _Integer> |
4886 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & |
4887 | operator<<=(byte& __lhs, _Integer __shift) noexcept |
4888 | { return __lhs = __lhs << __shift; } |
4889 | |
4890 | template <class _Integer> |
4891 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type |
4892 | operator<< (byte __lhs, _Integer __shift) noexcept |
4893 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); } |
4894 | |
4895 | template <class _Integer> |
4896 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & |
4897 | operator>>=(byte& __lhs, _Integer __shift) noexcept |
4898 | { return __lhs = __lhs >> __shift; } |
4899 | |
4900 | template <class _Integer> |
4901 | constexpr typename enable_if<is_integral_v<_Integer>, byte>::type |
4902 | operator>> (byte __lhs, _Integer __shift) noexcept |
4903 | { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); } |
4904 | |
4905 | template <class _Integer> |
4906 | constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type |
4907 | to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } |
4908 | |
4909 | } |
4910 | #endif |
4911 | |
4912 | #endif // _LIBCPP_TYPE_TRAITS |
4913 | |