1 | // C++11 <type_traits> -*- C++ -*- |
2 | |
3 | // Copyright (C) 2007-2021 Free Software Foundation, Inc. |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free |
6 | // software; you can redistribute it and/or modify it under the |
7 | // terms of the GNU General Public License as published by the |
8 | // Free Software Foundation; either version 3, or (at your option) |
9 | // any later version. |
10 | |
11 | // This library is distributed in the hope that it will be useful, |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | // GNU General Public License for more details. |
15 | |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version |
18 | // 3.1, as published by the Free Software Foundation. |
19 | |
20 | // You should have received a copy of the GNU General Public License and |
21 | // a copy of the GCC Runtime Library Exception along with this program; |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
23 | // <http://www.gnu.org/licenses/>. |
24 | |
25 | /** @file include/type_traits |
26 | * This is a Standard C++ Library header. |
27 | */ |
28 | |
29 | #ifndef _GLIBCXX_TYPE_TRAITS |
30 | #define _GLIBCXX_TYPE_TRAITS 1 |
31 | |
32 | #pragma GCC system_header |
33 | |
34 | #if __cplusplus < 201103L |
35 | # include <bits/c++0x_warning.h> |
36 | #else |
37 | |
38 | #include <bits/c++config.h> |
39 | |
40 | namespace std _GLIBCXX_VISIBILITY(default) |
41 | { |
42 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
43 | |
44 | template<typename... _Elements> |
45 | class tuple; |
46 | |
47 | template<typename _Tp> |
48 | class reference_wrapper; |
49 | |
50 | /** |
51 | * @defgroup metaprogramming Metaprogramming |
52 | * @ingroup utilities |
53 | * |
54 | * Template utilities for compile-time introspection and modification, |
55 | * including type classification traits, type property inspection traits |
56 | * and type transformation traits. |
57 | * |
58 | * @since C++11 |
59 | * |
60 | * @{ |
61 | */ |
62 | |
63 | /// integral_constant |
64 | template<typename _Tp, _Tp __v> |
65 | struct integral_constant |
66 | { |
67 | static constexpr _Tp value = __v; |
68 | typedef _Tp value_type; |
69 | typedef integral_constant<_Tp, __v> type; |
70 | constexpr operator value_type() const noexcept { return value; } |
71 | #if __cplusplus > 201103L |
72 | |
73 | #define __cpp_lib_integral_constant_callable 201304 |
74 | |
75 | constexpr value_type operator()() const noexcept { return value; } |
76 | #endif |
77 | }; |
78 | |
79 | template<typename _Tp, _Tp __v> |
80 | constexpr _Tp integral_constant<_Tp, __v>::value; |
81 | |
82 | /// The type used as a compile-time boolean with true value. |
83 | using true_type = integral_constant<bool, true>; |
84 | |
85 | /// The type used as a compile-time boolean with false value. |
86 | using false_type = integral_constant<bool, false>; |
87 | |
88 | /// @cond undocumented |
89 | /// bool_constant for C++11 |
90 | template<bool __v> |
91 | using __bool_constant = integral_constant<bool, __v>; |
92 | /// @endcond |
93 | |
94 | #if __cplusplus >= 201703L |
95 | # define __cpp_lib_bool_constant 201505 |
96 | /// Alias template for compile-time boolean constant types. |
97 | /// @since C++17 |
98 | template<bool __v> |
99 | using bool_constant = integral_constant<bool, __v>; |
100 | #endif |
101 | |
102 | // Metaprogramming helper types. |
103 | |
104 | template<bool, typename, typename> |
105 | struct conditional; |
106 | |
107 | /// @cond undocumented |
108 | template <typename _Type> |
109 | struct __type_identity |
110 | { using type = _Type; }; |
111 | |
112 | template<typename _Tp> |
113 | using __type_identity_t = typename __type_identity<_Tp>::type; |
114 | |
115 | template<typename...> |
116 | struct __or_; |
117 | |
118 | template<> |
119 | struct __or_<> |
120 | : public false_type |
121 | { }; |
122 | |
123 | template<typename _B1> |
124 | struct __or_<_B1> |
125 | : public _B1 |
126 | { }; |
127 | |
128 | template<typename _B1, typename _B2> |
129 | struct __or_<_B1, _B2> |
130 | : public conditional<_B1::value, _B1, _B2>::type |
131 | { }; |
132 | |
133 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> |
134 | struct __or_<_B1, _B2, _B3, _Bn...> |
135 | : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type |
136 | { }; |
137 | |
138 | template<typename...> |
139 | struct __and_; |
140 | |
141 | template<> |
142 | struct __and_<> |
143 | : public true_type |
144 | { }; |
145 | |
146 | template<typename _B1> |
147 | struct __and_<_B1> |
148 | : public _B1 |
149 | { }; |
150 | |
151 | template<typename _B1, typename _B2> |
152 | struct __and_<_B1, _B2> |
153 | : public conditional<_B1::value, _B2, _B1>::type |
154 | { }; |
155 | |
156 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> |
157 | struct __and_<_B1, _B2, _B3, _Bn...> |
158 | : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type |
159 | { }; |
160 | |
161 | template<typename _Pp> |
162 | struct __not_ |
163 | : public __bool_constant<!bool(_Pp::value)> |
164 | { }; |
165 | /// @endcond |
166 | |
167 | #if __cplusplus >= 201703L |
168 | |
169 | /// @cond undocumented |
170 | template<typename... _Bn> |
171 | inline constexpr bool __or_v = __or_<_Bn...>::value; |
172 | template<typename... _Bn> |
173 | inline constexpr bool __and_v = __and_<_Bn...>::value; |
174 | /// @endcond |
175 | |
176 | #define __cpp_lib_logical_traits 201510 |
177 | |
178 | template<typename... _Bn> |
179 | struct conjunction |
180 | : __and_<_Bn...> |
181 | { }; |
182 | |
183 | template<typename... _Bn> |
184 | struct disjunction |
185 | : __or_<_Bn...> |
186 | { }; |
187 | |
188 | template<typename _Pp> |
189 | struct negation |
190 | : __not_<_Pp> |
191 | { }; |
192 | |
193 | /** @ingroup variable_templates |
194 | * @{ |
195 | */ |
196 | template<typename... _Bn> |
197 | inline constexpr bool conjunction_v = conjunction<_Bn...>::value; |
198 | |
199 | template<typename... _Bn> |
200 | inline constexpr bool disjunction_v = disjunction<_Bn...>::value; |
201 | |
202 | template<typename _Pp> |
203 | inline constexpr bool negation_v = negation<_Pp>::value; |
204 | /// @} |
205 | |
206 | #endif // C++17 |
207 | |
208 | // Forward declarations |
209 | template<typename> |
210 | struct is_reference; |
211 | template<typename> |
212 | struct is_function; |
213 | template<typename> |
214 | struct is_void; |
215 | template<typename> |
216 | struct remove_cv; |
217 | template<typename> |
218 | struct is_const; |
219 | |
220 | /// @cond undocumented |
221 | template<typename> |
222 | struct __is_array_unknown_bounds; |
223 | |
224 | // Helper functions that return false_type for incomplete classes, |
225 | // incomplete unions and arrays of known bound from those. |
226 | |
227 | template <typename _Tp, size_t = sizeof(_Tp)> |
228 | constexpr true_type __is_complete_or_unbounded(__type_identity<_Tp>) |
229 | { return {}; } |
230 | |
231 | template <typename _TypeIdentity, |
232 | typename _NestedType = typename _TypeIdentity::type> |
233 | constexpr typename __or_< |
234 | is_reference<_NestedType>, |
235 | is_function<_NestedType>, |
236 | is_void<_NestedType>, |
237 | __is_array_unknown_bounds<_NestedType> |
238 | >::type __is_complete_or_unbounded(_TypeIdentity) |
239 | { return {}; } |
240 | |
241 | // For several sfinae-friendly trait implementations we transport both the |
242 | // result information (as the member type) and the failure information (no |
243 | // member type). This is very similar to std::enable_if, but we cannot use |
244 | // them, because we need to derive from them as an implementation detail. |
245 | |
246 | template<typename _Tp> |
247 | struct __success_type |
248 | { typedef _Tp type; }; |
249 | |
250 | struct __failure_type |
251 | { }; |
252 | |
253 | // __remove_cv_t (std::remove_cv_t for C++11). |
254 | template<typename _Tp> |
255 | using __remove_cv_t = typename remove_cv<_Tp>::type; |
256 | |
257 | // Primary type categories. |
258 | |
259 | template<typename> |
260 | struct __is_void_helper |
261 | : public false_type { }; |
262 | |
263 | template<> |
264 | struct __is_void_helper<void> |
265 | : public true_type { }; |
266 | /// @endcond |
267 | |
268 | /// is_void |
269 | template<typename _Tp> |
270 | struct is_void |
271 | : public __is_void_helper<__remove_cv_t<_Tp>>::type |
272 | { }; |
273 | |
274 | /// @cond undocumented |
275 | template<typename> |
276 | struct __is_integral_helper |
277 | : public false_type { }; |
278 | |
279 | template<> |
280 | struct __is_integral_helper<bool> |
281 | : public true_type { }; |
282 | |
283 | template<> |
284 | struct __is_integral_helper<char> |
285 | : public true_type { }; |
286 | |
287 | template<> |
288 | struct __is_integral_helper<signed char> |
289 | : public true_type { }; |
290 | |
291 | template<> |
292 | struct __is_integral_helper<unsigned char> |
293 | : public true_type { }; |
294 | |
295 | // We want is_integral<wchar_t> to be true (and make_signed/unsigned to work) |
296 | // even when libc doesn't provide working <wchar.h> and related functions, |
297 | // so check __WCHAR_TYPE__ instead of _GLIBCXX_USE_WCHAR_T. |
298 | #ifdef __WCHAR_TYPE__ |
299 | template<> |
300 | struct __is_integral_helper<wchar_t> |
301 | : public true_type { }; |
302 | #endif |
303 | |
304 | #ifdef _GLIBCXX_USE_CHAR8_T |
305 | template<> |
306 | struct __is_integral_helper<char8_t> |
307 | : public true_type { }; |
308 | #endif |
309 | |
310 | template<> |
311 | struct __is_integral_helper<char16_t> |
312 | : public true_type { }; |
313 | |
314 | template<> |
315 | struct __is_integral_helper<char32_t> |
316 | : public true_type { }; |
317 | |
318 | template<> |
319 | struct __is_integral_helper<short> |
320 | : public true_type { }; |
321 | |
322 | template<> |
323 | struct __is_integral_helper<unsigned short> |
324 | : public true_type { }; |
325 | |
326 | template<> |
327 | struct __is_integral_helper<int> |
328 | : public true_type { }; |
329 | |
330 | template<> |
331 | struct __is_integral_helper<unsigned int> |
332 | : public true_type { }; |
333 | |
334 | template<> |
335 | struct __is_integral_helper<long> |
336 | : public true_type { }; |
337 | |
338 | template<> |
339 | struct __is_integral_helper<unsigned long> |
340 | : public true_type { }; |
341 | |
342 | template<> |
343 | struct __is_integral_helper<long long> |
344 | : public true_type { }; |
345 | |
346 | template<> |
347 | struct __is_integral_helper<unsigned long long> |
348 | : public true_type { }; |
349 | |
350 | // Conditionalizing on __STRICT_ANSI__ here will break any port that |
351 | // uses one of these types for size_t. |
352 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
353 | template<> |
354 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> |
355 | : public true_type { }; |
356 | |
357 | template<> |
358 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> |
359 | : public true_type { }; |
360 | #endif |
361 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
362 | template<> |
363 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> |
364 | : public true_type { }; |
365 | |
366 | template<> |
367 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> |
368 | : public true_type { }; |
369 | #endif |
370 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
371 | template<> |
372 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> |
373 | : public true_type { }; |
374 | |
375 | template<> |
376 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> |
377 | : public true_type { }; |
378 | #endif |
379 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
380 | template<> |
381 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> |
382 | : public true_type { }; |
383 | |
384 | template<> |
385 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> |
386 | : public true_type { }; |
387 | #endif |
388 | /// @endcond |
389 | |
390 | /// is_integral |
391 | template<typename _Tp> |
392 | struct is_integral |
393 | : public __is_integral_helper<__remove_cv_t<_Tp>>::type |
394 | { }; |
395 | |
396 | /// @cond undocumented |
397 | template<typename> |
398 | struct __is_floating_point_helper |
399 | : public false_type { }; |
400 | |
401 | template<> |
402 | struct __is_floating_point_helper<float> |
403 | : public true_type { }; |
404 | |
405 | template<> |
406 | struct __is_floating_point_helper<double> |
407 | : public true_type { }; |
408 | |
409 | template<> |
410 | struct __is_floating_point_helper<long double> |
411 | : public true_type { }; |
412 | |
413 | #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__) |
414 | template<> |
415 | struct __is_floating_point_helper<__float128> |
416 | : public true_type { }; |
417 | #endif |
418 | /// @endcond |
419 | |
420 | /// is_floating_point |
421 | template<typename _Tp> |
422 | struct is_floating_point |
423 | : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type |
424 | { }; |
425 | |
426 | /// is_array |
427 | template<typename> |
428 | struct is_array |
429 | : public false_type { }; |
430 | |
431 | template<typename _Tp, std::size_t _Size> |
432 | struct is_array<_Tp[_Size]> |
433 | : public true_type { }; |
434 | |
435 | template<typename _Tp> |
436 | struct is_array<_Tp[]> |
437 | : public true_type { }; |
438 | |
439 | template<typename> |
440 | struct __is_pointer_helper |
441 | : public false_type { }; |
442 | |
443 | template<typename _Tp> |
444 | struct __is_pointer_helper<_Tp*> |
445 | : public true_type { }; |
446 | |
447 | /// is_pointer |
448 | template<typename _Tp> |
449 | struct is_pointer |
450 | : public __is_pointer_helper<__remove_cv_t<_Tp>>::type |
451 | { }; |
452 | |
453 | /// is_lvalue_reference |
454 | template<typename> |
455 | struct is_lvalue_reference |
456 | : public false_type { }; |
457 | |
458 | template<typename _Tp> |
459 | struct is_lvalue_reference<_Tp&> |
460 | : public true_type { }; |
461 | |
462 | /// is_rvalue_reference |
463 | template<typename> |
464 | struct is_rvalue_reference |
465 | : public false_type { }; |
466 | |
467 | template<typename _Tp> |
468 | struct is_rvalue_reference<_Tp&&> |
469 | : public true_type { }; |
470 | |
471 | template<typename> |
472 | struct __is_member_object_pointer_helper |
473 | : public false_type { }; |
474 | |
475 | template<typename _Tp, typename _Cp> |
476 | struct __is_member_object_pointer_helper<_Tp _Cp::*> |
477 | : public __not_<is_function<_Tp>>::type { }; |
478 | |
479 | /// is_member_object_pointer |
480 | template<typename _Tp> |
481 | struct is_member_object_pointer |
482 | : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type |
483 | { }; |
484 | |
485 | template<typename> |
486 | struct __is_member_function_pointer_helper |
487 | : public false_type { }; |
488 | |
489 | template<typename _Tp, typename _Cp> |
490 | struct __is_member_function_pointer_helper<_Tp _Cp::*> |
491 | : public is_function<_Tp>::type { }; |
492 | |
493 | /// is_member_function_pointer |
494 | template<typename _Tp> |
495 | struct is_member_function_pointer |
496 | : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type |
497 | { }; |
498 | |
499 | /// is_enum |
500 | template<typename _Tp> |
501 | struct is_enum |
502 | : public integral_constant<bool, __is_enum(_Tp)> |
503 | { }; |
504 | |
505 | /// is_union |
506 | template<typename _Tp> |
507 | struct is_union |
508 | : public integral_constant<bool, __is_union(_Tp)> |
509 | { }; |
510 | |
511 | /// is_class |
512 | template<typename _Tp> |
513 | struct is_class |
514 | : public integral_constant<bool, __is_class(_Tp)> |
515 | { }; |
516 | |
517 | /// is_function |
518 | template<typename _Tp> |
519 | struct is_function |
520 | : public __bool_constant<!is_const<const _Tp>::value> { }; |
521 | |
522 | template<typename _Tp> |
523 | struct is_function<_Tp&> |
524 | : public false_type { }; |
525 | |
526 | template<typename _Tp> |
527 | struct is_function<_Tp&&> |
528 | : public false_type { }; |
529 | |
530 | #define __cpp_lib_is_null_pointer 201309 |
531 | |
532 | template<typename> |
533 | struct __is_null_pointer_helper |
534 | : public false_type { }; |
535 | |
536 | template<> |
537 | struct __is_null_pointer_helper<std::nullptr_t> |
538 | : public true_type { }; |
539 | |
540 | /// is_null_pointer (LWG 2247). |
541 | template<typename _Tp> |
542 | struct is_null_pointer |
543 | : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type |
544 | { }; |
545 | |
546 | /// __is_nullptr_t (deprecated extension). |
547 | /// @deprecated Use `is_null_pointer` instead. |
548 | template<typename _Tp> |
549 | struct __is_nullptr_t |
550 | : public is_null_pointer<_Tp> |
551 | { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer" ); |
552 | |
553 | // Composite type categories. |
554 | |
555 | /// is_reference |
556 | template<typename _Tp> |
557 | struct is_reference |
558 | : public __or_<is_lvalue_reference<_Tp>, |
559 | is_rvalue_reference<_Tp>>::type |
560 | { }; |
561 | |
562 | /// is_arithmetic |
563 | template<typename _Tp> |
564 | struct is_arithmetic |
565 | : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type |
566 | { }; |
567 | |
568 | /// is_fundamental |
569 | template<typename _Tp> |
570 | struct is_fundamental |
571 | : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, |
572 | is_null_pointer<_Tp>>::type |
573 | { }; |
574 | |
575 | /// is_object |
576 | template<typename _Tp> |
577 | struct is_object |
578 | : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, |
579 | is_void<_Tp>>>::type |
580 | { }; |
581 | |
582 | template<typename> |
583 | struct is_member_pointer; |
584 | |
585 | /// is_scalar |
586 | template<typename _Tp> |
587 | struct is_scalar |
588 | : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, |
589 | is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type |
590 | { }; |
591 | |
592 | /// is_compound |
593 | template<typename _Tp> |
594 | struct is_compound |
595 | : public __not_<is_fundamental<_Tp>>::type { }; |
596 | |
597 | /// @cond undocumented |
598 | template<typename _Tp> |
599 | struct __is_member_pointer_helper |
600 | : public false_type { }; |
601 | |
602 | template<typename _Tp, typename _Cp> |
603 | struct __is_member_pointer_helper<_Tp _Cp::*> |
604 | : public true_type { }; |
605 | /// @endcond |
606 | |
607 | /// is_member_pointer |
608 | template<typename _Tp> |
609 | struct is_member_pointer |
610 | : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type |
611 | { }; |
612 | |
613 | template<typename, typename> |
614 | struct is_same; |
615 | |
616 | /// @cond undocumented |
617 | template<typename _Tp, typename... _Types> |
618 | using __is_one_of = __or_<is_same<_Tp, _Types>...>; |
619 | |
620 | // Check if a type is one of the signed integer types. |
621 | template<typename _Tp> |
622 | using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>, |
623 | signed char, signed short, signed int, signed long, |
624 | signed long long |
625 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
626 | , signed __GLIBCXX_TYPE_INT_N_0 |
627 | #endif |
628 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
629 | , signed __GLIBCXX_TYPE_INT_N_1 |
630 | #endif |
631 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
632 | , signed __GLIBCXX_TYPE_INT_N_2 |
633 | #endif |
634 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
635 | , signed __GLIBCXX_TYPE_INT_N_3 |
636 | #endif |
637 | >; |
638 | |
639 | // Check if a type is one of the unsigned integer types. |
640 | template<typename _Tp> |
641 | using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>, |
642 | unsigned char, unsigned short, unsigned int, unsigned long, |
643 | unsigned long long |
644 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
645 | , unsigned __GLIBCXX_TYPE_INT_N_0 |
646 | #endif |
647 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
648 | , unsigned __GLIBCXX_TYPE_INT_N_1 |
649 | #endif |
650 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
651 | , unsigned __GLIBCXX_TYPE_INT_N_2 |
652 | #endif |
653 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
654 | , unsigned __GLIBCXX_TYPE_INT_N_3 |
655 | #endif |
656 | >; |
657 | |
658 | // Check if a type is one of the signed or unsigned integer types. |
659 | template<typename _Tp> |
660 | using __is_standard_integer |
661 | = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>; |
662 | |
663 | // __void_t (std::void_t for C++11) |
664 | template<typename...> using __void_t = void; |
665 | |
666 | // Utility to detect referenceable types ([defns.referenceable]). |
667 | |
668 | template<typename _Tp, typename = void> |
669 | struct __is_referenceable |
670 | : public false_type |
671 | { }; |
672 | |
673 | template<typename _Tp> |
674 | struct __is_referenceable<_Tp, __void_t<_Tp&>> |
675 | : public true_type |
676 | { }; |
677 | /// @endcond |
678 | |
679 | // Type properties. |
680 | |
681 | /// is_const |
682 | template<typename> |
683 | struct is_const |
684 | : public false_type { }; |
685 | |
686 | template<typename _Tp> |
687 | struct is_const<_Tp const> |
688 | : public true_type { }; |
689 | |
690 | /// is_volatile |
691 | template<typename> |
692 | struct is_volatile |
693 | : public false_type { }; |
694 | |
695 | template<typename _Tp> |
696 | struct is_volatile<_Tp volatile> |
697 | : public true_type { }; |
698 | |
699 | /// is_trivial |
700 | template<typename _Tp> |
701 | struct is_trivial |
702 | : public integral_constant<bool, __is_trivial(_Tp)> |
703 | { |
704 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
705 | "template argument must be a complete class or an unbounded array" ); |
706 | }; |
707 | |
708 | /// is_trivially_copyable |
709 | template<typename _Tp> |
710 | struct is_trivially_copyable |
711 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> |
712 | { |
713 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
714 | "template argument must be a complete class or an unbounded array" ); |
715 | }; |
716 | |
717 | /// is_standard_layout |
718 | template<typename _Tp> |
719 | struct is_standard_layout |
720 | : public integral_constant<bool, __is_standard_layout(_Tp)> |
721 | { |
722 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
723 | "template argument must be a complete class or an unbounded array" ); |
724 | }; |
725 | |
726 | /** is_pod (deprecated in C++20) |
727 | * @deprecated Use `is_standard_layout && is_trivial` instead. |
728 | */ |
729 | // Could use is_standard_layout && is_trivial instead of the builtin. |
730 | template<typename _Tp> |
731 | struct |
732 | _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead" ) |
733 | is_pod |
734 | : public integral_constant<bool, __is_pod(_Tp)> |
735 | { |
736 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
737 | "template argument must be a complete class or an unbounded array" ); |
738 | }; |
739 | |
740 | /** is_literal_type |
741 | * @deprecated Deprecated in C++20. The idea of a literal type isn't useful. |
742 | */ |
743 | template<typename _Tp> |
744 | struct |
745 | _GLIBCXX17_DEPRECATED |
746 | is_literal_type |
747 | : public integral_constant<bool, __is_literal_type(_Tp)> |
748 | { |
749 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
750 | "template argument must be a complete class or an unbounded array" ); |
751 | }; |
752 | |
753 | /// is_empty |
754 | template<typename _Tp> |
755 | struct is_empty |
756 | : public integral_constant<bool, __is_empty(_Tp)> |
757 | { }; |
758 | |
759 | /// is_polymorphic |
760 | template<typename _Tp> |
761 | struct is_polymorphic |
762 | : public integral_constant<bool, __is_polymorphic(_Tp)> |
763 | { }; |
764 | |
765 | #if __cplusplus >= 201402L |
766 | #define __cpp_lib_is_final 201402L |
767 | /// is_final |
768 | /// @since C++14 |
769 | template<typename _Tp> |
770 | struct is_final |
771 | : public integral_constant<bool, __is_final(_Tp)> |
772 | { }; |
773 | #endif |
774 | |
775 | /// is_abstract |
776 | template<typename _Tp> |
777 | struct is_abstract |
778 | : public integral_constant<bool, __is_abstract(_Tp)> |
779 | { }; |
780 | |
781 | /// @cond undocumented |
782 | template<typename _Tp, |
783 | bool = is_arithmetic<_Tp>::value> |
784 | struct __is_signed_helper |
785 | : public false_type { }; |
786 | |
787 | template<typename _Tp> |
788 | struct __is_signed_helper<_Tp, true> |
789 | : public integral_constant<bool, _Tp(-1) < _Tp(0)> |
790 | { }; |
791 | /// @endcond |
792 | |
793 | /// is_signed |
794 | template<typename _Tp> |
795 | struct is_signed |
796 | : public __is_signed_helper<_Tp>::type |
797 | { }; |
798 | |
799 | /// is_unsigned |
800 | template<typename _Tp> |
801 | struct is_unsigned |
802 | : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> |
803 | { }; |
804 | |
805 | /// @cond undocumented |
806 | template<typename _Tp, typename _Up = _Tp&&> |
807 | _Up |
808 | __declval(int); |
809 | |
810 | template<typename _Tp> |
811 | _Tp |
812 | __declval(long); |
813 | /// @endcond |
814 | |
815 | template<typename _Tp> |
816 | auto declval() noexcept -> decltype(__declval<_Tp>(0)); |
817 | |
818 | template<typename, unsigned = 0> |
819 | struct extent; |
820 | |
821 | template<typename> |
822 | struct remove_all_extents; |
823 | |
824 | /// @cond undocumented |
825 | template<typename _Tp> |
826 | struct __is_array_known_bounds |
827 | : public integral_constant<bool, (extent<_Tp>::value > 0)> |
828 | { }; |
829 | |
830 | template<typename _Tp> |
831 | struct __is_array_unknown_bounds |
832 | : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> |
833 | { }; |
834 | |
835 | // Destructible and constructible type properties. |
836 | |
837 | // In N3290 is_destructible does not say anything about function |
838 | // types and abstract types, see LWG 2049. This implementation |
839 | // describes function types as non-destructible and all complete |
840 | // object types as destructible, iff the explicit destructor |
841 | // call expression is wellformed. |
842 | struct __do_is_destructible_impl |
843 | { |
844 | template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> |
845 | static true_type __test(int); |
846 | |
847 | template<typename> |
848 | static false_type __test(...); |
849 | }; |
850 | |
851 | template<typename _Tp> |
852 | struct __is_destructible_impl |
853 | : public __do_is_destructible_impl |
854 | { |
855 | typedef decltype(__test<_Tp>(0)) type; |
856 | }; |
857 | |
858 | template<typename _Tp, |
859 | bool = __or_<is_void<_Tp>, |
860 | __is_array_unknown_bounds<_Tp>, |
861 | is_function<_Tp>>::value, |
862 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> |
863 | struct __is_destructible_safe; |
864 | |
865 | template<typename _Tp> |
866 | struct __is_destructible_safe<_Tp, false, false> |
867 | : public __is_destructible_impl<typename |
868 | remove_all_extents<_Tp>::type>::type |
869 | { }; |
870 | |
871 | template<typename _Tp> |
872 | struct __is_destructible_safe<_Tp, true, false> |
873 | : public false_type { }; |
874 | |
875 | template<typename _Tp> |
876 | struct __is_destructible_safe<_Tp, false, true> |
877 | : public true_type { }; |
878 | /// @endcond |
879 | |
880 | /// is_destructible |
881 | template<typename _Tp> |
882 | struct is_destructible |
883 | : public __is_destructible_safe<_Tp>::type |
884 | { |
885 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
886 | "template argument must be a complete class or an unbounded array" ); |
887 | }; |
888 | |
889 | /// @cond undocumented |
890 | |
891 | // is_nothrow_destructible requires that is_destructible is |
892 | // satisfied as well. We realize that by mimicing the |
893 | // implementation of is_destructible but refer to noexcept(expr) |
894 | // instead of decltype(expr). |
895 | struct __do_is_nt_destructible_impl |
896 | { |
897 | template<typename _Tp> |
898 | static __bool_constant<noexcept(declval<_Tp&>().~_Tp())> |
899 | __test(int); |
900 | |
901 | template<typename> |
902 | static false_type __test(...); |
903 | }; |
904 | |
905 | template<typename _Tp> |
906 | struct __is_nt_destructible_impl |
907 | : public __do_is_nt_destructible_impl |
908 | { |
909 | typedef decltype(__test<_Tp>(0)) type; |
910 | }; |
911 | |
912 | template<typename _Tp, |
913 | bool = __or_<is_void<_Tp>, |
914 | __is_array_unknown_bounds<_Tp>, |
915 | is_function<_Tp>>::value, |
916 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> |
917 | struct __is_nt_destructible_safe; |
918 | |
919 | template<typename _Tp> |
920 | struct __is_nt_destructible_safe<_Tp, false, false> |
921 | : public __is_nt_destructible_impl<typename |
922 | remove_all_extents<_Tp>::type>::type |
923 | { }; |
924 | |
925 | template<typename _Tp> |
926 | struct __is_nt_destructible_safe<_Tp, true, false> |
927 | : public false_type { }; |
928 | |
929 | template<typename _Tp> |
930 | struct __is_nt_destructible_safe<_Tp, false, true> |
931 | : public true_type { }; |
932 | /// @endcond |
933 | |
934 | /// is_nothrow_destructible |
935 | template<typename _Tp> |
936 | struct is_nothrow_destructible |
937 | : public __is_nt_destructible_safe<_Tp>::type |
938 | { |
939 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
940 | "template argument must be a complete class or an unbounded array" ); |
941 | }; |
942 | |
943 | /// @cond undocumented |
944 | template<typename _Tp, typename... _Args> |
945 | struct __is_constructible_impl |
946 | : public __bool_constant<__is_constructible(_Tp, _Args...)> |
947 | { }; |
948 | /// @endcond |
949 | |
950 | /// is_constructible |
951 | template<typename _Tp, typename... _Args> |
952 | struct is_constructible |
953 | : public __is_constructible_impl<_Tp, _Args...> |
954 | { |
955 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
956 | "template argument must be a complete class or an unbounded array" ); |
957 | }; |
958 | |
959 | /// is_default_constructible |
960 | template<typename _Tp> |
961 | struct is_default_constructible |
962 | : public __is_constructible_impl<_Tp>::type |
963 | { |
964 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
965 | "template argument must be a complete class or an unbounded array" ); |
966 | }; |
967 | |
968 | /// @cond undocumented |
969 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
970 | struct __is_copy_constructible_impl; |
971 | |
972 | template<typename _Tp> |
973 | struct __is_copy_constructible_impl<_Tp, false> |
974 | : public false_type { }; |
975 | |
976 | template<typename _Tp> |
977 | struct __is_copy_constructible_impl<_Tp, true> |
978 | : public __is_constructible_impl<_Tp, const _Tp&> |
979 | { }; |
980 | /// @endcond |
981 | |
982 | /// is_copy_constructible |
983 | template<typename _Tp> |
984 | struct is_copy_constructible |
985 | : public __is_copy_constructible_impl<_Tp> |
986 | { |
987 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
988 | "template argument must be a complete class or an unbounded array" ); |
989 | }; |
990 | |
991 | /// @cond undocumented |
992 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
993 | struct __is_move_constructible_impl; |
994 | |
995 | template<typename _Tp> |
996 | struct __is_move_constructible_impl<_Tp, false> |
997 | : public false_type { }; |
998 | |
999 | template<typename _Tp> |
1000 | struct __is_move_constructible_impl<_Tp, true> |
1001 | : public __is_constructible_impl<_Tp, _Tp&&> |
1002 | { }; |
1003 | /// @endcond |
1004 | |
1005 | /// is_move_constructible |
1006 | template<typename _Tp> |
1007 | struct is_move_constructible |
1008 | : public __is_move_constructible_impl<_Tp> |
1009 | { |
1010 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1011 | "template argument must be a complete class or an unbounded array" ); |
1012 | }; |
1013 | |
1014 | /// @cond undocumented |
1015 | template<typename _Tp, typename... _Args> |
1016 | using __is_nothrow_constructible_impl |
1017 | = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>; |
1018 | /// @endcond |
1019 | |
1020 | /// is_nothrow_constructible |
1021 | template<typename _Tp, typename... _Args> |
1022 | struct is_nothrow_constructible |
1023 | : public __is_nothrow_constructible_impl<_Tp, _Args...>::type |
1024 | { |
1025 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1026 | "template argument must be a complete class or an unbounded array" ); |
1027 | }; |
1028 | |
1029 | /// is_nothrow_default_constructible |
1030 | template<typename _Tp> |
1031 | struct is_nothrow_default_constructible |
1032 | : public __bool_constant<__is_nothrow_constructible(_Tp)> |
1033 | { |
1034 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1035 | "template argument must be a complete class or an unbounded array" ); |
1036 | }; |
1037 | |
1038 | /// @cond undocumented |
1039 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1040 | struct __is_nothrow_copy_constructible_impl; |
1041 | |
1042 | template<typename _Tp> |
1043 | struct __is_nothrow_copy_constructible_impl<_Tp, false> |
1044 | : public false_type { }; |
1045 | |
1046 | template<typename _Tp> |
1047 | struct __is_nothrow_copy_constructible_impl<_Tp, true> |
1048 | : public __is_nothrow_constructible_impl<_Tp, const _Tp&> |
1049 | { }; |
1050 | /// @endcond |
1051 | |
1052 | /// is_nothrow_copy_constructible |
1053 | template<typename _Tp> |
1054 | struct is_nothrow_copy_constructible |
1055 | : public __is_nothrow_copy_constructible_impl<_Tp>::type |
1056 | { |
1057 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1058 | "template argument must be a complete class or an unbounded array" ); |
1059 | }; |
1060 | |
1061 | /// @cond undocumented |
1062 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1063 | struct __is_nothrow_move_constructible_impl; |
1064 | |
1065 | template<typename _Tp> |
1066 | struct __is_nothrow_move_constructible_impl<_Tp, false> |
1067 | : public false_type { }; |
1068 | |
1069 | template<typename _Tp> |
1070 | struct __is_nothrow_move_constructible_impl<_Tp, true> |
1071 | : public __is_nothrow_constructible_impl<_Tp, _Tp&&> |
1072 | { }; |
1073 | /// @endcond |
1074 | |
1075 | /// is_nothrow_move_constructible |
1076 | template<typename _Tp> |
1077 | struct is_nothrow_move_constructible |
1078 | : public __is_nothrow_move_constructible_impl<_Tp>::type |
1079 | { |
1080 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1081 | "template argument must be a complete class or an unbounded array" ); |
1082 | }; |
1083 | |
1084 | /// is_assignable |
1085 | template<typename _Tp, typename _Up> |
1086 | struct is_assignable |
1087 | : public __bool_constant<__is_assignable(_Tp, _Up)> |
1088 | { |
1089 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1090 | "template argument must be a complete class or an unbounded array" ); |
1091 | }; |
1092 | |
1093 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1094 | struct __is_copy_assignable_impl; |
1095 | |
1096 | template<typename _Tp> |
1097 | struct __is_copy_assignable_impl<_Tp, false> |
1098 | : public false_type { }; |
1099 | |
1100 | template<typename _Tp> |
1101 | struct __is_copy_assignable_impl<_Tp, true> |
1102 | : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> |
1103 | { }; |
1104 | |
1105 | /// is_copy_assignable |
1106 | template<typename _Tp> |
1107 | struct is_copy_assignable |
1108 | : public __is_copy_assignable_impl<_Tp>::type |
1109 | { |
1110 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1111 | "template argument must be a complete class or an unbounded array" ); |
1112 | }; |
1113 | |
1114 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1115 | struct __is_move_assignable_impl; |
1116 | |
1117 | template<typename _Tp> |
1118 | struct __is_move_assignable_impl<_Tp, false> |
1119 | : public false_type { }; |
1120 | |
1121 | template<typename _Tp> |
1122 | struct __is_move_assignable_impl<_Tp, true> |
1123 | : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> |
1124 | { }; |
1125 | |
1126 | /// is_move_assignable |
1127 | template<typename _Tp> |
1128 | struct is_move_assignable |
1129 | : public __is_move_assignable_impl<_Tp>::type |
1130 | { |
1131 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1132 | "template argument must be a complete class or an unbounded array" ); |
1133 | }; |
1134 | |
1135 | template<typename _Tp, typename _Up> |
1136 | using __is_nothrow_assignable_impl |
1137 | = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>; |
1138 | |
1139 | /// is_nothrow_assignable |
1140 | template<typename _Tp, typename _Up> |
1141 | struct is_nothrow_assignable |
1142 | : public __is_nothrow_assignable_impl<_Tp, _Up> |
1143 | { |
1144 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1145 | "template argument must be a complete class or an unbounded array" ); |
1146 | }; |
1147 | |
1148 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1149 | struct __is_nt_copy_assignable_impl; |
1150 | |
1151 | template<typename _Tp> |
1152 | struct __is_nt_copy_assignable_impl<_Tp, false> |
1153 | : public false_type { }; |
1154 | |
1155 | template<typename _Tp> |
1156 | struct __is_nt_copy_assignable_impl<_Tp, true> |
1157 | : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> |
1158 | { }; |
1159 | |
1160 | /// is_nothrow_copy_assignable |
1161 | template<typename _Tp> |
1162 | struct is_nothrow_copy_assignable |
1163 | : public __is_nt_copy_assignable_impl<_Tp> |
1164 | { |
1165 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1166 | "template argument must be a complete class or an unbounded array" ); |
1167 | }; |
1168 | |
1169 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1170 | struct __is_nt_move_assignable_impl; |
1171 | |
1172 | template<typename _Tp> |
1173 | struct __is_nt_move_assignable_impl<_Tp, false> |
1174 | : public false_type { }; |
1175 | |
1176 | template<typename _Tp> |
1177 | struct __is_nt_move_assignable_impl<_Tp, true> |
1178 | : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> |
1179 | { }; |
1180 | |
1181 | /// is_nothrow_move_assignable |
1182 | template<typename _Tp> |
1183 | struct is_nothrow_move_assignable |
1184 | : public __is_nt_move_assignable_impl<_Tp> |
1185 | { |
1186 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1187 | "template argument must be a complete class or an unbounded array" ); |
1188 | }; |
1189 | |
1190 | /// is_trivially_constructible |
1191 | template<typename _Tp, typename... _Args> |
1192 | struct is_trivially_constructible |
1193 | : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> |
1194 | { |
1195 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1196 | "template argument must be a complete class or an unbounded array" ); |
1197 | }; |
1198 | |
1199 | /// is_trivially_default_constructible |
1200 | template<typename _Tp> |
1201 | struct is_trivially_default_constructible |
1202 | : public __bool_constant<__is_trivially_constructible(_Tp)> |
1203 | { |
1204 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1205 | "template argument must be a complete class or an unbounded array" ); |
1206 | }; |
1207 | |
1208 | struct __do_is_implicitly_default_constructible_impl |
1209 | { |
1210 | template <typename _Tp> |
1211 | static void __helper(const _Tp&); |
1212 | |
1213 | template <typename _Tp> |
1214 | static true_type __test(const _Tp&, |
1215 | decltype(__helper<const _Tp&>({}))* = 0); |
1216 | |
1217 | static false_type __test(...); |
1218 | }; |
1219 | |
1220 | template<typename _Tp> |
1221 | struct __is_implicitly_default_constructible_impl |
1222 | : public __do_is_implicitly_default_constructible_impl |
1223 | { |
1224 | typedef decltype(__test(declval<_Tp>())) type; |
1225 | }; |
1226 | |
1227 | template<typename _Tp> |
1228 | struct __is_implicitly_default_constructible_safe |
1229 | : public __is_implicitly_default_constructible_impl<_Tp>::type |
1230 | { }; |
1231 | |
1232 | template <typename _Tp> |
1233 | struct __is_implicitly_default_constructible |
1234 | : public __and_<__is_constructible_impl<_Tp>, |
1235 | __is_implicitly_default_constructible_safe<_Tp>> |
1236 | { }; |
1237 | |
1238 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1239 | struct __is_trivially_copy_constructible_impl; |
1240 | |
1241 | template<typename _Tp> |
1242 | struct __is_trivially_copy_constructible_impl<_Tp, false> |
1243 | : public false_type { }; |
1244 | |
1245 | template<typename _Tp> |
1246 | struct __is_trivially_copy_constructible_impl<_Tp, true> |
1247 | : public __and_<__is_copy_constructible_impl<_Tp>, |
1248 | integral_constant<bool, |
1249 | __is_trivially_constructible(_Tp, const _Tp&)>> |
1250 | { }; |
1251 | |
1252 | /// is_trivially_copy_constructible |
1253 | template<typename _Tp> |
1254 | struct is_trivially_copy_constructible |
1255 | : public __is_trivially_copy_constructible_impl<_Tp> |
1256 | { |
1257 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1258 | "template argument must be a complete class or an unbounded array" ); |
1259 | }; |
1260 | |
1261 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1262 | struct __is_trivially_move_constructible_impl; |
1263 | |
1264 | template<typename _Tp> |
1265 | struct __is_trivially_move_constructible_impl<_Tp, false> |
1266 | : public false_type { }; |
1267 | |
1268 | template<typename _Tp> |
1269 | struct __is_trivially_move_constructible_impl<_Tp, true> |
1270 | : public __and_<__is_move_constructible_impl<_Tp>, |
1271 | integral_constant<bool, |
1272 | __is_trivially_constructible(_Tp, _Tp&&)>> |
1273 | { }; |
1274 | |
1275 | /// is_trivially_move_constructible |
1276 | template<typename _Tp> |
1277 | struct is_trivially_move_constructible |
1278 | : public __is_trivially_move_constructible_impl<_Tp> |
1279 | { |
1280 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1281 | "template argument must be a complete class or an unbounded array" ); |
1282 | }; |
1283 | |
1284 | /// is_trivially_assignable |
1285 | template<typename _Tp, typename _Up> |
1286 | struct is_trivially_assignable |
1287 | : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> |
1288 | { |
1289 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1290 | "template argument must be a complete class or an unbounded array" ); |
1291 | }; |
1292 | |
1293 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1294 | struct __is_trivially_copy_assignable_impl; |
1295 | |
1296 | template<typename _Tp> |
1297 | struct __is_trivially_copy_assignable_impl<_Tp, false> |
1298 | : public false_type { }; |
1299 | |
1300 | template<typename _Tp> |
1301 | struct __is_trivially_copy_assignable_impl<_Tp, true> |
1302 | : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> |
1303 | { }; |
1304 | |
1305 | /// is_trivially_copy_assignable |
1306 | template<typename _Tp> |
1307 | struct is_trivially_copy_assignable |
1308 | : public __is_trivially_copy_assignable_impl<_Tp> |
1309 | { |
1310 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1311 | "template argument must be a complete class or an unbounded array" ); |
1312 | }; |
1313 | |
1314 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1315 | struct __is_trivially_move_assignable_impl; |
1316 | |
1317 | template<typename _Tp> |
1318 | struct __is_trivially_move_assignable_impl<_Tp, false> |
1319 | : public false_type { }; |
1320 | |
1321 | template<typename _Tp> |
1322 | struct __is_trivially_move_assignable_impl<_Tp, true> |
1323 | : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> |
1324 | { }; |
1325 | |
1326 | /// is_trivially_move_assignable |
1327 | template<typename _Tp> |
1328 | struct is_trivially_move_assignable |
1329 | : public __is_trivially_move_assignable_impl<_Tp> |
1330 | { |
1331 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1332 | "template argument must be a complete class or an unbounded array" ); |
1333 | }; |
1334 | |
1335 | /// is_trivially_destructible |
1336 | template<typename _Tp> |
1337 | struct is_trivially_destructible |
1338 | : public __and_<__is_destructible_safe<_Tp>, |
1339 | __bool_constant<__has_trivial_destructor(_Tp)>> |
1340 | { |
1341 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1342 | "template argument must be a complete class or an unbounded array" ); |
1343 | }; |
1344 | |
1345 | |
1346 | /// has_virtual_destructor |
1347 | template<typename _Tp> |
1348 | struct has_virtual_destructor |
1349 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> |
1350 | { |
1351 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1352 | "template argument must be a complete class or an unbounded array" ); |
1353 | }; |
1354 | |
1355 | |
1356 | // type property queries. |
1357 | |
1358 | /// alignment_of |
1359 | template<typename _Tp> |
1360 | struct alignment_of |
1361 | : public integral_constant<std::size_t, alignof(_Tp)> |
1362 | { |
1363 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
1364 | "template argument must be a complete class or an unbounded array" ); |
1365 | }; |
1366 | |
1367 | /// rank |
1368 | template<typename> |
1369 | struct rank |
1370 | : public integral_constant<std::size_t, 0> { }; |
1371 | |
1372 | template<typename _Tp, std::size_t _Size> |
1373 | struct rank<_Tp[_Size]> |
1374 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; |
1375 | |
1376 | template<typename _Tp> |
1377 | struct rank<_Tp[]> |
1378 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; |
1379 | |
1380 | /// extent |
1381 | template<typename, unsigned _Uint> |
1382 | struct extent |
1383 | : public integral_constant<std::size_t, 0> { }; |
1384 | |
1385 | template<typename _Tp, unsigned _Uint, std::size_t _Size> |
1386 | struct extent<_Tp[_Size], _Uint> |
1387 | : public integral_constant<std::size_t, |
1388 | _Uint == 0 ? _Size : extent<_Tp, |
1389 | _Uint - 1>::value> |
1390 | { }; |
1391 | |
1392 | template<typename _Tp, unsigned _Uint> |
1393 | struct extent<_Tp[], _Uint> |
1394 | : public integral_constant<std::size_t, |
1395 | _Uint == 0 ? 0 : extent<_Tp, |
1396 | _Uint - 1>::value> |
1397 | { }; |
1398 | |
1399 | |
1400 | // Type relations. |
1401 | |
1402 | /// is_same |
1403 | template<typename _Tp, typename _Up> |
1404 | struct is_same |
1405 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME |
1406 | : public integral_constant<bool, __is_same(_Tp, _Up)> |
1407 | #else |
1408 | : public false_type |
1409 | #endif |
1410 | { }; |
1411 | |
1412 | #ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME |
1413 | template<typename _Tp> |
1414 | struct is_same<_Tp, _Tp> |
1415 | : public true_type |
1416 | { }; |
1417 | #endif |
1418 | |
1419 | /// is_base_of |
1420 | template<typename _Base, typename _Derived> |
1421 | struct is_base_of |
1422 | : public integral_constant<bool, __is_base_of(_Base, _Derived)> |
1423 | { }; |
1424 | |
1425 | template<typename _From, typename _To, |
1426 | bool = __or_<is_void<_From>, is_function<_To>, |
1427 | is_array<_To>>::value> |
1428 | struct __is_convertible_helper |
1429 | { |
1430 | typedef typename is_void<_To>::type type; |
1431 | }; |
1432 | |
1433 | #pragma GCC diagnostic push |
1434 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
1435 | template<typename _From, typename _To> |
1436 | class __is_convertible_helper<_From, _To, false> |
1437 | { |
1438 | template<typename _To1> |
1439 | static void __test_aux(_To1) noexcept; |
1440 | |
1441 | template<typename _From1, typename _To1, |
1442 | typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> |
1443 | static true_type |
1444 | __test(int); |
1445 | |
1446 | template<typename, typename> |
1447 | static false_type |
1448 | __test(...); |
1449 | |
1450 | public: |
1451 | typedef decltype(__test<_From, _To>(0)) type; |
1452 | }; |
1453 | #pragma GCC diagnostic pop |
1454 | |
1455 | /// is_convertible |
1456 | template<typename _From, typename _To> |
1457 | struct is_convertible |
1458 | : public __is_convertible_helper<_From, _To>::type |
1459 | { }; |
1460 | |
1461 | // helper trait for unique_ptr<T[]>, shared_ptr<T[]>, and span<T, N> |
1462 | template<typename _ToElementType, typename _FromElementType> |
1463 | using __is_array_convertible |
1464 | = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; |
1465 | |
1466 | template<typename _From, typename _To, |
1467 | bool = __or_<is_void<_From>, is_function<_To>, |
1468 | is_array<_To>>::value> |
1469 | struct __is_nt_convertible_helper |
1470 | : is_void<_To> |
1471 | { }; |
1472 | |
1473 | #pragma GCC diagnostic push |
1474 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
1475 | template<typename _From, typename _To> |
1476 | class __is_nt_convertible_helper<_From, _To, false> |
1477 | { |
1478 | template<typename _To1> |
1479 | static void __test_aux(_To1) noexcept; |
1480 | |
1481 | template<typename _From1, typename _To1> |
1482 | static |
1483 | __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))> |
1484 | __test(int); |
1485 | |
1486 | template<typename, typename> |
1487 | static false_type |
1488 | __test(...); |
1489 | |
1490 | public: |
1491 | using type = decltype(__test<_From, _To>(0)); |
1492 | }; |
1493 | #pragma GCC diagnostic pop |
1494 | |
1495 | #if __cplusplus > 201703L |
1496 | #define __cpp_lib_is_nothrow_convertible 201806L |
1497 | /// is_nothrow_convertible |
1498 | template<typename _From, typename _To> |
1499 | struct is_nothrow_convertible |
1500 | : public __is_nt_convertible_helper<_From, _To>::type |
1501 | { }; |
1502 | |
1503 | /// is_nothrow_convertible_v |
1504 | template<typename _From, typename _To> |
1505 | inline constexpr bool is_nothrow_convertible_v |
1506 | = is_nothrow_convertible<_From, _To>::value; |
1507 | #endif // C++2a |
1508 | |
1509 | // Const-volatile modifications. |
1510 | |
1511 | /// remove_const |
1512 | template<typename _Tp> |
1513 | struct remove_const |
1514 | { typedef _Tp type; }; |
1515 | |
1516 | template<typename _Tp> |
1517 | struct remove_const<_Tp const> |
1518 | { typedef _Tp type; }; |
1519 | |
1520 | /// remove_volatile |
1521 | template<typename _Tp> |
1522 | struct remove_volatile |
1523 | { typedef _Tp type; }; |
1524 | |
1525 | template<typename _Tp> |
1526 | struct remove_volatile<_Tp volatile> |
1527 | { typedef _Tp type; }; |
1528 | |
1529 | /// remove_cv |
1530 | template<typename _Tp> |
1531 | struct remove_cv |
1532 | { using type = _Tp; }; |
1533 | |
1534 | template<typename _Tp> |
1535 | struct remove_cv<const _Tp> |
1536 | { using type = _Tp; }; |
1537 | |
1538 | template<typename _Tp> |
1539 | struct remove_cv<volatile _Tp> |
1540 | { using type = _Tp; }; |
1541 | |
1542 | template<typename _Tp> |
1543 | struct remove_cv<const volatile _Tp> |
1544 | { using type = _Tp; }; |
1545 | |
1546 | /// add_const |
1547 | template<typename _Tp> |
1548 | struct add_const |
1549 | { typedef _Tp const type; }; |
1550 | |
1551 | /// add_volatile |
1552 | template<typename _Tp> |
1553 | struct add_volatile |
1554 | { typedef _Tp volatile type; }; |
1555 | |
1556 | /// add_cv |
1557 | template<typename _Tp> |
1558 | struct add_cv |
1559 | { |
1560 | typedef typename |
1561 | add_const<typename add_volatile<_Tp>::type>::type type; |
1562 | }; |
1563 | |
1564 | #if __cplusplus > 201103L |
1565 | |
1566 | #define __cpp_lib_transformation_trait_aliases 201304 |
1567 | |
1568 | /// Alias template for remove_const |
1569 | template<typename _Tp> |
1570 | using remove_const_t = typename remove_const<_Tp>::type; |
1571 | |
1572 | /// Alias template for remove_volatile |
1573 | template<typename _Tp> |
1574 | using remove_volatile_t = typename remove_volatile<_Tp>::type; |
1575 | |
1576 | /// Alias template for remove_cv |
1577 | template<typename _Tp> |
1578 | using remove_cv_t = typename remove_cv<_Tp>::type; |
1579 | |
1580 | /// Alias template for add_const |
1581 | template<typename _Tp> |
1582 | using add_const_t = typename add_const<_Tp>::type; |
1583 | |
1584 | /// Alias template for add_volatile |
1585 | template<typename _Tp> |
1586 | using add_volatile_t = typename add_volatile<_Tp>::type; |
1587 | |
1588 | /// Alias template for add_cv |
1589 | template<typename _Tp> |
1590 | using add_cv_t = typename add_cv<_Tp>::type; |
1591 | #endif |
1592 | |
1593 | // Reference transformations. |
1594 | |
1595 | /// remove_reference |
1596 | template<typename _Tp> |
1597 | struct remove_reference |
1598 | { typedef _Tp type; }; |
1599 | |
1600 | template<typename _Tp> |
1601 | struct remove_reference<_Tp&> |
1602 | { typedef _Tp type; }; |
1603 | |
1604 | template<typename _Tp> |
1605 | struct remove_reference<_Tp&&> |
1606 | { typedef _Tp type; }; |
1607 | |
1608 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1609 | struct __add_lvalue_reference_helper |
1610 | { typedef _Tp type; }; |
1611 | |
1612 | template<typename _Tp> |
1613 | struct __add_lvalue_reference_helper<_Tp, true> |
1614 | { typedef _Tp& type; }; |
1615 | |
1616 | /// add_lvalue_reference |
1617 | template<typename _Tp> |
1618 | struct add_lvalue_reference |
1619 | : public __add_lvalue_reference_helper<_Tp> |
1620 | { }; |
1621 | |
1622 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1623 | struct __add_rvalue_reference_helper |
1624 | { typedef _Tp type; }; |
1625 | |
1626 | template<typename _Tp> |
1627 | struct __add_rvalue_reference_helper<_Tp, true> |
1628 | { typedef _Tp&& type; }; |
1629 | |
1630 | /// add_rvalue_reference |
1631 | template<typename _Tp> |
1632 | struct add_rvalue_reference |
1633 | : public __add_rvalue_reference_helper<_Tp> |
1634 | { }; |
1635 | |
1636 | #if __cplusplus > 201103L |
1637 | /// Alias template for remove_reference |
1638 | template<typename _Tp> |
1639 | using remove_reference_t = typename remove_reference<_Tp>::type; |
1640 | |
1641 | /// Alias template for add_lvalue_reference |
1642 | template<typename _Tp> |
1643 | using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; |
1644 | |
1645 | /// Alias template for add_rvalue_reference |
1646 | template<typename _Tp> |
1647 | using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; |
1648 | #endif |
1649 | |
1650 | // Sign modifications. |
1651 | |
1652 | /// @cond undocumented |
1653 | |
1654 | // Utility for constructing identically cv-qualified types. |
1655 | template<typename _Unqualified, bool _IsConst, bool _IsVol> |
1656 | struct __cv_selector; |
1657 | |
1658 | template<typename _Unqualified> |
1659 | struct __cv_selector<_Unqualified, false, false> |
1660 | { typedef _Unqualified __type; }; |
1661 | |
1662 | template<typename _Unqualified> |
1663 | struct __cv_selector<_Unqualified, false, true> |
1664 | { typedef volatile _Unqualified __type; }; |
1665 | |
1666 | template<typename _Unqualified> |
1667 | struct __cv_selector<_Unqualified, true, false> |
1668 | { typedef const _Unqualified __type; }; |
1669 | |
1670 | template<typename _Unqualified> |
1671 | struct __cv_selector<_Unqualified, true, true> |
1672 | { typedef const volatile _Unqualified __type; }; |
1673 | |
1674 | template<typename _Qualified, typename _Unqualified, |
1675 | bool _IsConst = is_const<_Qualified>::value, |
1676 | bool _IsVol = is_volatile<_Qualified>::value> |
1677 | class __match_cv_qualifiers |
1678 | { |
1679 | typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; |
1680 | |
1681 | public: |
1682 | typedef typename __match::__type __type; |
1683 | }; |
1684 | |
1685 | // Utility for finding the unsigned versions of signed integral types. |
1686 | template<typename _Tp> |
1687 | struct __make_unsigned |
1688 | { typedef _Tp __type; }; |
1689 | |
1690 | template<> |
1691 | struct __make_unsigned<char> |
1692 | { typedef unsigned char __type; }; |
1693 | |
1694 | template<> |
1695 | struct __make_unsigned<signed char> |
1696 | { typedef unsigned char __type; }; |
1697 | |
1698 | template<> |
1699 | struct __make_unsigned<short> |
1700 | { typedef unsigned short __type; }; |
1701 | |
1702 | template<> |
1703 | struct __make_unsigned<int> |
1704 | { typedef unsigned int __type; }; |
1705 | |
1706 | template<> |
1707 | struct __make_unsigned<long> |
1708 | { typedef unsigned long __type; }; |
1709 | |
1710 | template<> |
1711 | struct __make_unsigned<long long> |
1712 | { typedef unsigned long long __type; }; |
1713 | |
1714 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1715 | template<> |
1716 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> |
1717 | { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; |
1718 | #endif |
1719 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
1720 | template<> |
1721 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> |
1722 | { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; |
1723 | #endif |
1724 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
1725 | template<> |
1726 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> |
1727 | { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; |
1728 | #endif |
1729 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
1730 | template<> |
1731 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> |
1732 | { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; |
1733 | #endif |
1734 | |
1735 | // Select between integral and enum: not possible to be both. |
1736 | template<typename _Tp, |
1737 | bool _IsInt = is_integral<_Tp>::value, |
1738 | bool _IsEnum = is_enum<_Tp>::value> |
1739 | class __make_unsigned_selector; |
1740 | |
1741 | template<typename _Tp> |
1742 | class __make_unsigned_selector<_Tp, true, false> |
1743 | { |
1744 | using __unsigned_type |
1745 | = typename __make_unsigned<__remove_cv_t<_Tp>>::__type; |
1746 | |
1747 | public: |
1748 | using __type |
1749 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; |
1750 | }; |
1751 | |
1752 | class __make_unsigned_selector_base |
1753 | { |
1754 | protected: |
1755 | template<typename...> struct _List { }; |
1756 | |
1757 | template<typename _Tp, typename... _Up> |
1758 | struct _List<_Tp, _Up...> : _List<_Up...> |
1759 | { static constexpr size_t __size = sizeof(_Tp); }; |
1760 | |
1761 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> |
1762 | struct __select; |
1763 | |
1764 | template<size_t _Sz, typename _Uint, typename... _UInts> |
1765 | struct __select<_Sz, _List<_Uint, _UInts...>, true> |
1766 | { using __type = _Uint; }; |
1767 | |
1768 | template<size_t _Sz, typename _Uint, typename... _UInts> |
1769 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
1770 | : __select<_Sz, _List<_UInts...>> |
1771 | { }; |
1772 | }; |
1773 | |
1774 | // Choose unsigned integer type with the smallest rank and same size as _Tp |
1775 | template<typename _Tp> |
1776 | class __make_unsigned_selector<_Tp, false, true> |
1777 | : __make_unsigned_selector_base |
1778 | { |
1779 | // With -fshort-enums, an enum may be as small as a char. |
1780 | using _UInts = _List<unsigned char, unsigned short, unsigned int, |
1781 | unsigned long, unsigned long long>; |
1782 | |
1783 | using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; |
1784 | |
1785 | public: |
1786 | using __type |
1787 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; |
1788 | }; |
1789 | |
1790 | // wchar_t, char8_t, char16_t and char32_t are integral types but are |
1791 | // neither signed integer types nor unsigned integer types, so must be |
1792 | // transformed to the unsigned integer type with the smallest rank. |
1793 | // Use the partial specialization for enumeration types to do that. |
1794 | #ifdef __WCHAR_TYPE__ |
1795 | template<> |
1796 | struct __make_unsigned<wchar_t> |
1797 | { |
1798 | using __type |
1799 | = typename __make_unsigned_selector<wchar_t, false, true>::__type; |
1800 | }; |
1801 | #endif |
1802 | |
1803 | #ifdef _GLIBCXX_USE_CHAR8_T |
1804 | template<> |
1805 | struct __make_unsigned<char8_t> |
1806 | { |
1807 | using __type |
1808 | = typename __make_unsigned_selector<char8_t, false, true>::__type; |
1809 | }; |
1810 | #endif |
1811 | |
1812 | template<> |
1813 | struct __make_unsigned<char16_t> |
1814 | { |
1815 | using __type |
1816 | = typename __make_unsigned_selector<char16_t, false, true>::__type; |
1817 | }; |
1818 | |
1819 | template<> |
1820 | struct __make_unsigned<char32_t> |
1821 | { |
1822 | using __type |
1823 | = typename __make_unsigned_selector<char32_t, false, true>::__type; |
1824 | }; |
1825 | /// @endcond |
1826 | |
1827 | // Given an integral/enum type, return the corresponding unsigned |
1828 | // integer type. |
1829 | // Primary template. |
1830 | /// make_unsigned |
1831 | template<typename _Tp> |
1832 | struct make_unsigned |
1833 | { typedef typename __make_unsigned_selector<_Tp>::__type type; }; |
1834 | |
1835 | // Integral, but don't define. |
1836 | template<> |
1837 | struct make_unsigned<bool>; |
1838 | |
1839 | /// @cond undocumented |
1840 | |
1841 | // Utility for finding the signed versions of unsigned integral types. |
1842 | template<typename _Tp> |
1843 | struct __make_signed |
1844 | { typedef _Tp __type; }; |
1845 | |
1846 | template<> |
1847 | struct __make_signed<char> |
1848 | { typedef signed char __type; }; |
1849 | |
1850 | template<> |
1851 | struct __make_signed<unsigned char> |
1852 | { typedef signed char __type; }; |
1853 | |
1854 | template<> |
1855 | struct __make_signed<unsigned short> |
1856 | { typedef signed short __type; }; |
1857 | |
1858 | template<> |
1859 | struct __make_signed<unsigned int> |
1860 | { typedef signed int __type; }; |
1861 | |
1862 | template<> |
1863 | struct __make_signed<unsigned long> |
1864 | { typedef signed long __type; }; |
1865 | |
1866 | template<> |
1867 | struct __make_signed<unsigned long long> |
1868 | { typedef signed long long __type; }; |
1869 | |
1870 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1871 | template<> |
1872 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> |
1873 | { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; |
1874 | #endif |
1875 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
1876 | template<> |
1877 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> |
1878 | { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; |
1879 | #endif |
1880 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
1881 | template<> |
1882 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> |
1883 | { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; |
1884 | #endif |
1885 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
1886 | template<> |
1887 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> |
1888 | { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; |
1889 | #endif |
1890 | |
1891 | // Select between integral and enum: not possible to be both. |
1892 | template<typename _Tp, |
1893 | bool _IsInt = is_integral<_Tp>::value, |
1894 | bool _IsEnum = is_enum<_Tp>::value> |
1895 | class __make_signed_selector; |
1896 | |
1897 | template<typename _Tp> |
1898 | class __make_signed_selector<_Tp, true, false> |
1899 | { |
1900 | using __signed_type |
1901 | = typename __make_signed<__remove_cv_t<_Tp>>::__type; |
1902 | |
1903 | public: |
1904 | using __type |
1905 | = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; |
1906 | }; |
1907 | |
1908 | // Choose signed integer type with the smallest rank and same size as _Tp |
1909 | template<typename _Tp> |
1910 | class __make_signed_selector<_Tp, false, true> |
1911 | { |
1912 | typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; |
1913 | |
1914 | public: |
1915 | typedef typename __make_signed_selector<__unsigned_type>::__type __type; |
1916 | }; |
1917 | |
1918 | // wchar_t, char16_t and char32_t are integral types but are neither |
1919 | // signed integer types nor unsigned integer types, so must be |
1920 | // transformed to the signed integer type with the smallest rank. |
1921 | // Use the partial specialization for enumeration types to do that. |
1922 | #if defined(__WCHAR_TYPE__) |
1923 | template<> |
1924 | struct __make_signed<wchar_t> |
1925 | { |
1926 | using __type |
1927 | = typename __make_signed_selector<wchar_t, false, true>::__type; |
1928 | }; |
1929 | #endif |
1930 | |
1931 | #if defined(_GLIBCXX_USE_CHAR8_T) |
1932 | template<> |
1933 | struct __make_signed<char8_t> |
1934 | { |
1935 | using __type |
1936 | = typename __make_signed_selector<char8_t, false, true>::__type; |
1937 | }; |
1938 | #endif |
1939 | |
1940 | template<> |
1941 | struct __make_signed<char16_t> |
1942 | { |
1943 | using __type |
1944 | = typename __make_signed_selector<char16_t, false, true>::__type; |
1945 | }; |
1946 | |
1947 | template<> |
1948 | struct __make_signed<char32_t> |
1949 | { |
1950 | using __type |
1951 | = typename __make_signed_selector<char32_t, false, true>::__type; |
1952 | }; |
1953 | /// @endcond |
1954 | |
1955 | // Given an integral/enum type, return the corresponding signed |
1956 | // integer type. |
1957 | // Primary template. |
1958 | /// make_signed |
1959 | template<typename _Tp> |
1960 | struct make_signed |
1961 | { typedef typename __make_signed_selector<_Tp>::__type type; }; |
1962 | |
1963 | // Integral, but don't define. |
1964 | template<> |
1965 | struct make_signed<bool>; |
1966 | |
1967 | #if __cplusplus > 201103L |
1968 | /// Alias template for make_signed |
1969 | template<typename _Tp> |
1970 | using make_signed_t = typename make_signed<_Tp>::type; |
1971 | |
1972 | /// Alias template for make_unsigned |
1973 | template<typename _Tp> |
1974 | using make_unsigned_t = typename make_unsigned<_Tp>::type; |
1975 | #endif |
1976 | |
1977 | // Array modifications. |
1978 | |
1979 | /// remove_extent |
1980 | template<typename _Tp> |
1981 | struct remove_extent |
1982 | { typedef _Tp type; }; |
1983 | |
1984 | template<typename _Tp, std::size_t _Size> |
1985 | struct remove_extent<_Tp[_Size]> |
1986 | { typedef _Tp type; }; |
1987 | |
1988 | template<typename _Tp> |
1989 | struct remove_extent<_Tp[]> |
1990 | { typedef _Tp type; }; |
1991 | |
1992 | /// remove_all_extents |
1993 | template<typename _Tp> |
1994 | struct remove_all_extents |
1995 | { typedef _Tp type; }; |
1996 | |
1997 | template<typename _Tp, std::size_t _Size> |
1998 | struct remove_all_extents<_Tp[_Size]> |
1999 | { typedef typename remove_all_extents<_Tp>::type type; }; |
2000 | |
2001 | template<typename _Tp> |
2002 | struct remove_all_extents<_Tp[]> |
2003 | { typedef typename remove_all_extents<_Tp>::type type; }; |
2004 | |
2005 | #if __cplusplus > 201103L |
2006 | /// Alias template for remove_extent |
2007 | template<typename _Tp> |
2008 | using remove_extent_t = typename remove_extent<_Tp>::type; |
2009 | |
2010 | /// Alias template for remove_all_extents |
2011 | template<typename _Tp> |
2012 | using remove_all_extents_t = typename remove_all_extents<_Tp>::type; |
2013 | #endif |
2014 | |
2015 | // Pointer modifications. |
2016 | |
2017 | template<typename _Tp, typename> |
2018 | struct __remove_pointer_helper |
2019 | { typedef _Tp type; }; |
2020 | |
2021 | template<typename _Tp, typename _Up> |
2022 | struct __remove_pointer_helper<_Tp, _Up*> |
2023 | { typedef _Up type; }; |
2024 | |
2025 | /// remove_pointer |
2026 | template<typename _Tp> |
2027 | struct remove_pointer |
2028 | : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>> |
2029 | { }; |
2030 | |
2031 | template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, |
2032 | is_void<_Tp>>::value> |
2033 | struct __add_pointer_helper |
2034 | { typedef _Tp type; }; |
2035 | |
2036 | template<typename _Tp> |
2037 | struct __add_pointer_helper<_Tp, true> |
2038 | { typedef typename remove_reference<_Tp>::type* type; }; |
2039 | |
2040 | /// add_pointer |
2041 | template<typename _Tp> |
2042 | struct add_pointer |
2043 | : public __add_pointer_helper<_Tp> |
2044 | { }; |
2045 | |
2046 | #if __cplusplus > 201103L |
2047 | /// Alias template for remove_pointer |
2048 | template<typename _Tp> |
2049 | using remove_pointer_t = typename remove_pointer<_Tp>::type; |
2050 | |
2051 | /// Alias template for add_pointer |
2052 | template<typename _Tp> |
2053 | using add_pointer_t = typename add_pointer<_Tp>::type; |
2054 | #endif |
2055 | |
2056 | template<std::size_t _Len> |
2057 | struct __aligned_storage_msa |
2058 | { |
2059 | union __type |
2060 | { |
2061 | unsigned char __data[_Len]; |
2062 | struct __attribute__((__aligned__)) { } __align; |
2063 | }; |
2064 | }; |
2065 | |
2066 | /** |
2067 | * @brief Alignment type. |
2068 | * |
2069 | * The value of _Align is a default-alignment which shall be the |
2070 | * most stringent alignment requirement for any C++ object type |
2071 | * whose size is no greater than _Len (3.9). The member typedef |
2072 | * type shall be a POD type suitable for use as uninitialized |
2073 | * storage for any object whose size is at most _Len and whose |
2074 | * alignment is a divisor of _Align. |
2075 | */ |
2076 | template<std::size_t _Len, std::size_t _Align = |
2077 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> |
2078 | struct aligned_storage |
2079 | { |
2080 | union type |
2081 | { |
2082 | unsigned char __data[_Len]; |
2083 | struct __attribute__((__aligned__((_Align)))) { } __align; |
2084 | }; |
2085 | }; |
2086 | |
2087 | template <typename... _Types> |
2088 | struct __strictest_alignment |
2089 | { |
2090 | static const size_t _S_alignment = 0; |
2091 | static const size_t _S_size = 0; |
2092 | }; |
2093 | |
2094 | template <typename _Tp, typename... _Types> |
2095 | struct __strictest_alignment<_Tp, _Types...> |
2096 | { |
2097 | static const size_t _S_alignment = |
2098 | alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment |
2099 | ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; |
2100 | static const size_t _S_size = |
2101 | sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size |
2102 | ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; |
2103 | }; |
2104 | |
2105 | /** |
2106 | * @brief Provide aligned storage for types. |
2107 | * |
2108 | * [meta.trans.other] |
2109 | * |
2110 | * Provides aligned storage for any of the provided types of at |
2111 | * least size _Len. |
2112 | * |
2113 | * @see aligned_storage |
2114 | */ |
2115 | template <size_t _Len, typename... _Types> |
2116 | struct aligned_union |
2117 | { |
2118 | private: |
2119 | static_assert(sizeof...(_Types) != 0, "At least one type is required" ); |
2120 | |
2121 | using __strictest = __strictest_alignment<_Types...>; |
2122 | static const size_t _S_len = _Len > __strictest::_S_size |
2123 | ? _Len : __strictest::_S_size; |
2124 | public: |
2125 | /// The value of the strictest alignment of _Types. |
2126 | static const size_t alignment_value = __strictest::_S_alignment; |
2127 | /// The storage. |
2128 | typedef typename aligned_storage<_S_len, alignment_value>::type type; |
2129 | }; |
2130 | |
2131 | template <size_t _Len, typename... _Types> |
2132 | const size_t aligned_union<_Len, _Types...>::alignment_value; |
2133 | |
2134 | /// @cond undocumented |
2135 | |
2136 | // Decay trait for arrays and functions, used for perfect forwarding |
2137 | // in make_pair, make_tuple, etc. |
2138 | template<typename _Up, |
2139 | bool _IsArray = is_array<_Up>::value, |
2140 | bool _IsFunction = is_function<_Up>::value> |
2141 | struct __decay_selector; |
2142 | |
2143 | // NB: DR 705. |
2144 | template<typename _Up> |
2145 | struct __decay_selector<_Up, false, false> |
2146 | { typedef __remove_cv_t<_Up> __type; }; |
2147 | |
2148 | template<typename _Up> |
2149 | struct __decay_selector<_Up, true, false> |
2150 | { typedef typename remove_extent<_Up>::type* __type; }; |
2151 | |
2152 | template<typename _Up> |
2153 | struct __decay_selector<_Up, false, true> |
2154 | { typedef typename add_pointer<_Up>::type __type; }; |
2155 | /// @endcond |
2156 | |
2157 | /// decay |
2158 | template<typename _Tp> |
2159 | class decay |
2160 | { |
2161 | typedef typename remove_reference<_Tp>::type __remove_type; |
2162 | |
2163 | public: |
2164 | typedef typename __decay_selector<__remove_type>::__type type; |
2165 | }; |
2166 | |
2167 | /// @cond undocumented |
2168 | |
2169 | // Helper which adds a reference to a type when given a reference_wrapper |
2170 | template<typename _Tp> |
2171 | struct __strip_reference_wrapper |
2172 | { |
2173 | typedef _Tp __type; |
2174 | }; |
2175 | |
2176 | template<typename _Tp> |
2177 | struct __strip_reference_wrapper<reference_wrapper<_Tp> > |
2178 | { |
2179 | typedef _Tp& __type; |
2180 | }; |
2181 | |
2182 | // __decay_t (std::decay_t for C++11). |
2183 | template<typename _Tp> |
2184 | using __decay_t = typename decay<_Tp>::type; |
2185 | |
2186 | template<typename _Tp> |
2187 | using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>; |
2188 | /// @endcond |
2189 | |
2190 | // Primary template. |
2191 | /// Define a member typedef `type` only if a boolean constant is true. |
2192 | template<bool, typename _Tp = void> |
2193 | struct enable_if |
2194 | { }; |
2195 | |
2196 | // Partial specialization for true. |
2197 | template<typename _Tp> |
2198 | struct enable_if<true, _Tp> |
2199 | { typedef _Tp type; }; |
2200 | |
2201 | /// @cond undocumented |
2202 | |
2203 | // __enable_if_t (std::enable_if_t for C++11) |
2204 | template<bool _Cond, typename _Tp = void> |
2205 | using __enable_if_t = typename enable_if<_Cond, _Tp>::type; |
2206 | |
2207 | // Helper for SFINAE constraints |
2208 | template<typename... _Cond> |
2209 | using _Require = __enable_if_t<__and_<_Cond...>::value>; |
2210 | |
2211 | // __remove_cvref_t (std::remove_cvref_t for C++11). |
2212 | template<typename _Tp> |
2213 | using __remove_cvref_t |
2214 | = typename remove_cv<typename remove_reference<_Tp>::type>::type; |
2215 | /// @endcond |
2216 | |
2217 | // Primary template. |
2218 | /// Define a member typedef @c type to one of two argument types. |
2219 | template<bool _Cond, typename _Iftrue, typename _Iffalse> |
2220 | struct conditional |
2221 | { typedef _Iftrue type; }; |
2222 | |
2223 | // Partial specialization for false. |
2224 | template<typename _Iftrue, typename _Iffalse> |
2225 | struct conditional<false, _Iftrue, _Iffalse> |
2226 | { typedef _Iffalse type; }; |
2227 | |
2228 | /// common_type |
2229 | template<typename... _Tp> |
2230 | struct common_type; |
2231 | |
2232 | // Sfinae-friendly common_type implementation: |
2233 | |
2234 | /// @cond undocumented |
2235 | struct __do_common_type_impl |
2236 | { |
2237 | template<typename _Tp, typename _Up> |
2238 | using __cond_t |
2239 | = decltype(true ? std::declval<_Tp>() : std::declval<_Up>()); |
2240 | |
2241 | // if decay_t<decltype(false ? declval<D1>() : declval<D2>())> |
2242 | // denotes a valid type, let C denote that type. |
2243 | template<typename _Tp, typename _Up> |
2244 | static __success_type<__decay_t<__cond_t<_Tp, _Up>>> |
2245 | _S_test(int); |
2246 | |
2247 | #if __cplusplus > 201703L |
2248 | // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type, |
2249 | // let C denote the type decay_t<COND-RES(CREF(D1), CREF(D2))>. |
2250 | template<typename _Tp, typename _Up> |
2251 | static __success_type<__remove_cvref_t<__cond_t<const _Tp&, const _Up&>>> |
2252 | _S_test_2(int); |
2253 | #endif |
2254 | |
2255 | template<typename, typename> |
2256 | static __failure_type |
2257 | _S_test_2(...); |
2258 | |
2259 | template<typename _Tp, typename _Up> |
2260 | static decltype(_S_test_2<_Tp, _Up>(0)) |
2261 | _S_test(...); |
2262 | }; |
2263 | |
2264 | // If sizeof...(T) is zero, there shall be no member type. |
2265 | template<> |
2266 | struct common_type<> |
2267 | { }; |
2268 | |
2269 | // If sizeof...(T) is one, the same type, if any, as common_type_t<T0, T0>. |
2270 | template<typename _Tp0> |
2271 | struct common_type<_Tp0> |
2272 | : public common_type<_Tp0, _Tp0> |
2273 | { }; |
2274 | |
2275 | // If sizeof...(T) is two, ... |
2276 | template<typename _Tp1, typename _Tp2, |
2277 | typename _Dp1 = __decay_t<_Tp1>, typename _Dp2 = __decay_t<_Tp2>> |
2278 | struct __common_type_impl |
2279 | { |
2280 | // If is_same_v<T1, D1> is false or is_same_v<T2, D2> is false, |
2281 | // let C denote the same type, if any, as common_type_t<D1, D2>. |
2282 | using type = common_type<_Dp1, _Dp2>; |
2283 | }; |
2284 | |
2285 | template<typename _Tp1, typename _Tp2> |
2286 | struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2> |
2287 | : private __do_common_type_impl |
2288 | { |
2289 | // Otherwise, if decay_t<decltype(false ? declval<D1>() : declval<D2>())> |
2290 | // denotes a valid type, let C denote that type. |
2291 | using type = decltype(_S_test<_Tp1, _Tp2>(0)); |
2292 | }; |
2293 | |
2294 | // If sizeof...(T) is two, ... |
2295 | template<typename _Tp1, typename _Tp2> |
2296 | struct common_type<_Tp1, _Tp2> |
2297 | : public __common_type_impl<_Tp1, _Tp2>::type |
2298 | { }; |
2299 | |
2300 | template<typename...> |
2301 | struct __common_type_pack |
2302 | { }; |
2303 | |
2304 | template<typename, typename, typename = void> |
2305 | struct __common_type_fold; |
2306 | |
2307 | // If sizeof...(T) is greater than two, ... |
2308 | template<typename _Tp1, typename _Tp2, typename... _Rp> |
2309 | struct common_type<_Tp1, _Tp2, _Rp...> |
2310 | : public __common_type_fold<common_type<_Tp1, _Tp2>, |
2311 | __common_type_pack<_Rp...>> |
2312 | { }; |
2313 | |
2314 | // Let C denote the same type, if any, as common_type_t<T1, T2>. |
2315 | // If there is such a type C, type shall denote the same type, if any, |
2316 | // as common_type_t<C, R...>. |
2317 | template<typename _CTp, typename... _Rp> |
2318 | struct __common_type_fold<_CTp, __common_type_pack<_Rp...>, |
2319 | __void_t<typename _CTp::type>> |
2320 | : public common_type<typename _CTp::type, _Rp...> |
2321 | { }; |
2322 | |
2323 | // Otherwise, there shall be no member type. |
2324 | template<typename _CTp, typename _Rp> |
2325 | struct __common_type_fold<_CTp, _Rp, void> |
2326 | { }; |
2327 | |
2328 | template<typename _Tp, bool = is_enum<_Tp>::value> |
2329 | struct __underlying_type_impl |
2330 | { |
2331 | using type = __underlying_type(_Tp); |
2332 | }; |
2333 | |
2334 | template<typename _Tp> |
2335 | struct __underlying_type_impl<_Tp, false> |
2336 | { }; |
2337 | /// @endcond |
2338 | |
2339 | /// The underlying type of an enum. |
2340 | template<typename _Tp> |
2341 | struct underlying_type |
2342 | : public __underlying_type_impl<_Tp> |
2343 | { }; |
2344 | |
2345 | /// @cond undocumented |
2346 | template<typename _Tp> |
2347 | struct __declval_protector |
2348 | { |
2349 | static const bool __stop = false; |
2350 | }; |
2351 | /// @endcond |
2352 | |
2353 | /** Utility to simplify expressions used in unevaluated operands |
2354 | * @since C++11 |
2355 | * @ingroup utilities |
2356 | */ |
2357 | template<typename _Tp> |
2358 | auto declval() noexcept -> decltype(__declval<_Tp>(0)) |
2359 | { |
2360 | static_assert(__declval_protector<_Tp>::__stop, |
2361 | "declval() must not be used!" ); |
2362 | return __declval<_Tp>(0); |
2363 | } |
2364 | |
2365 | /// result_of |
2366 | template<typename _Signature> |
2367 | struct result_of; |
2368 | |
2369 | // Sfinae-friendly result_of implementation: |
2370 | |
2371 | #define __cpp_lib_result_of_sfinae 201210 |
2372 | |
2373 | /// @cond undocumented |
2374 | struct __invoke_memfun_ref { }; |
2375 | struct __invoke_memfun_deref { }; |
2376 | struct __invoke_memobj_ref { }; |
2377 | struct __invoke_memobj_deref { }; |
2378 | struct __invoke_other { }; |
2379 | |
2380 | // Associate a tag type with a specialization of __success_type. |
2381 | template<typename _Tp, typename _Tag> |
2382 | struct __result_of_success : __success_type<_Tp> |
2383 | { using __invoke_type = _Tag; }; |
2384 | |
2385 | // [func.require] paragraph 1 bullet 1: |
2386 | struct __result_of_memfun_ref_impl |
2387 | { |
2388 | template<typename _Fp, typename _Tp1, typename... _Args> |
2389 | static __result_of_success<decltype( |
2390 | (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) |
2391 | ), __invoke_memfun_ref> _S_test(int); |
2392 | |
2393 | template<typename...> |
2394 | static __failure_type _S_test(...); |
2395 | }; |
2396 | |
2397 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2398 | struct __result_of_memfun_ref |
2399 | : private __result_of_memfun_ref_impl |
2400 | { |
2401 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; |
2402 | }; |
2403 | |
2404 | // [func.require] paragraph 1 bullet 2: |
2405 | struct __result_of_memfun_deref_impl |
2406 | { |
2407 | template<typename _Fp, typename _Tp1, typename... _Args> |
2408 | static __result_of_success<decltype( |
2409 | ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) |
2410 | ), __invoke_memfun_deref> _S_test(int); |
2411 | |
2412 | template<typename...> |
2413 | static __failure_type _S_test(...); |
2414 | }; |
2415 | |
2416 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2417 | struct __result_of_memfun_deref |
2418 | : private __result_of_memfun_deref_impl |
2419 | { |
2420 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; |
2421 | }; |
2422 | |
2423 | // [func.require] paragraph 1 bullet 3: |
2424 | struct __result_of_memobj_ref_impl |
2425 | { |
2426 | template<typename _Fp, typename _Tp1> |
2427 | static __result_of_success<decltype( |
2428 | std::declval<_Tp1>().*std::declval<_Fp>() |
2429 | ), __invoke_memobj_ref> _S_test(int); |
2430 | |
2431 | template<typename, typename> |
2432 | static __failure_type _S_test(...); |
2433 | }; |
2434 | |
2435 | template<typename _MemPtr, typename _Arg> |
2436 | struct __result_of_memobj_ref |
2437 | : private __result_of_memobj_ref_impl |
2438 | { |
2439 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; |
2440 | }; |
2441 | |
2442 | // [func.require] paragraph 1 bullet 4: |
2443 | struct __result_of_memobj_deref_impl |
2444 | { |
2445 | template<typename _Fp, typename _Tp1> |
2446 | static __result_of_success<decltype( |
2447 | (*std::declval<_Tp1>()).*std::declval<_Fp>() |
2448 | ), __invoke_memobj_deref> _S_test(int); |
2449 | |
2450 | template<typename, typename> |
2451 | static __failure_type _S_test(...); |
2452 | }; |
2453 | |
2454 | template<typename _MemPtr, typename _Arg> |
2455 | struct __result_of_memobj_deref |
2456 | : private __result_of_memobj_deref_impl |
2457 | { |
2458 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; |
2459 | }; |
2460 | |
2461 | template<typename _MemPtr, typename _Arg> |
2462 | struct __result_of_memobj; |
2463 | |
2464 | template<typename _Res, typename _Class, typename _Arg> |
2465 | struct __result_of_memobj<_Res _Class::*, _Arg> |
2466 | { |
2467 | typedef __remove_cvref_t<_Arg> _Argval; |
2468 | typedef _Res _Class::* _MemPtr; |
2469 | typedef typename conditional<__or_<is_same<_Argval, _Class>, |
2470 | is_base_of<_Class, _Argval>>::value, |
2471 | __result_of_memobj_ref<_MemPtr, _Arg>, |
2472 | __result_of_memobj_deref<_MemPtr, _Arg> |
2473 | >::type::type type; |
2474 | }; |
2475 | |
2476 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2477 | struct __result_of_memfun; |
2478 | |
2479 | template<typename _Res, typename _Class, typename _Arg, typename... _Args> |
2480 | struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> |
2481 | { |
2482 | typedef typename remove_reference<_Arg>::type _Argval; |
2483 | typedef _Res _Class::* _MemPtr; |
2484 | typedef typename conditional<is_base_of<_Class, _Argval>::value, |
2485 | __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, |
2486 | __result_of_memfun_deref<_MemPtr, _Arg, _Args...> |
2487 | >::type::type type; |
2488 | }; |
2489 | |
2490 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
2491 | // 2219. INVOKE-ing a pointer to member with a reference_wrapper |
2492 | // as the object expression |
2493 | |
2494 | // Used by result_of, invoke etc. to unwrap a reference_wrapper. |
2495 | template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>> |
2496 | struct __inv_unwrap |
2497 | { |
2498 | using type = _Tp; |
2499 | }; |
2500 | |
2501 | template<typename _Tp, typename _Up> |
2502 | struct __inv_unwrap<_Tp, reference_wrapper<_Up>> |
2503 | { |
2504 | using type = _Up&; |
2505 | }; |
2506 | |
2507 | template<bool, bool, typename _Functor, typename... _ArgTypes> |
2508 | struct __result_of_impl |
2509 | { |
2510 | typedef __failure_type type; |
2511 | }; |
2512 | |
2513 | template<typename _MemPtr, typename _Arg> |
2514 | struct __result_of_impl<true, false, _MemPtr, _Arg> |
2515 | : public __result_of_memobj<__decay_t<_MemPtr>, |
2516 | typename __inv_unwrap<_Arg>::type> |
2517 | { }; |
2518 | |
2519 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2520 | struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> |
2521 | : public __result_of_memfun<__decay_t<_MemPtr>, |
2522 | typename __inv_unwrap<_Arg>::type, _Args...> |
2523 | { }; |
2524 | |
2525 | // [func.require] paragraph 1 bullet 5: |
2526 | struct __result_of_other_impl |
2527 | { |
2528 | template<typename _Fn, typename... _Args> |
2529 | static __result_of_success<decltype( |
2530 | std::declval<_Fn>()(std::declval<_Args>()...) |
2531 | ), __invoke_other> _S_test(int); |
2532 | |
2533 | template<typename...> |
2534 | static __failure_type _S_test(...); |
2535 | }; |
2536 | |
2537 | template<typename _Functor, typename... _ArgTypes> |
2538 | struct __result_of_impl<false, false, _Functor, _ArgTypes...> |
2539 | : private __result_of_other_impl |
2540 | { |
2541 | typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; |
2542 | }; |
2543 | |
2544 | // __invoke_result (std::invoke_result for C++11) |
2545 | template<typename _Functor, typename... _ArgTypes> |
2546 | struct __invoke_result |
2547 | : public __result_of_impl< |
2548 | is_member_object_pointer< |
2549 | typename remove_reference<_Functor>::type |
2550 | >::value, |
2551 | is_member_function_pointer< |
2552 | typename remove_reference<_Functor>::type |
2553 | >::value, |
2554 | _Functor, _ArgTypes... |
2555 | >::type |
2556 | { }; |
2557 | /// @endcond |
2558 | |
2559 | template<typename _Functor, typename... _ArgTypes> |
2560 | struct result_of<_Functor(_ArgTypes...)> |
2561 | : public __invoke_result<_Functor, _ArgTypes...> |
2562 | { }; |
2563 | |
2564 | #if __cplusplus >= 201402L |
2565 | /// Alias template for aligned_storage |
2566 | template<size_t _Len, size_t _Align = |
2567 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> |
2568 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; |
2569 | |
2570 | template <size_t _Len, typename... _Types> |
2571 | using aligned_union_t = typename aligned_union<_Len, _Types...>::type; |
2572 | |
2573 | /// Alias template for decay |
2574 | template<typename _Tp> |
2575 | using decay_t = typename decay<_Tp>::type; |
2576 | |
2577 | /// Alias template for enable_if |
2578 | template<bool _Cond, typename _Tp = void> |
2579 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; |
2580 | |
2581 | /// Alias template for conditional |
2582 | template<bool _Cond, typename _Iftrue, typename _Iffalse> |
2583 | using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; |
2584 | |
2585 | /// Alias template for common_type |
2586 | template<typename... _Tp> |
2587 | using common_type_t = typename common_type<_Tp...>::type; |
2588 | |
2589 | /// Alias template for underlying_type |
2590 | template<typename _Tp> |
2591 | using underlying_type_t = typename underlying_type<_Tp>::type; |
2592 | |
2593 | /// Alias template for result_of |
2594 | template<typename _Tp> |
2595 | using result_of_t = typename result_of<_Tp>::type; |
2596 | #endif // C++14 |
2597 | |
2598 | #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 |
2599 | #define __cpp_lib_void_t 201411 |
2600 | /// A metafunction that always yields void, used for detecting valid types. |
2601 | template<typename...> using void_t = void; |
2602 | #endif |
2603 | |
2604 | /// @cond undocumented |
2605 | |
2606 | /// Implementation of the detection idiom (negative case). |
2607 | template<typename _Default, typename _AlwaysVoid, |
2608 | template<typename...> class _Op, typename... _Args> |
2609 | struct __detector |
2610 | { |
2611 | using value_t = false_type; |
2612 | using type = _Default; |
2613 | }; |
2614 | |
2615 | /// Implementation of the detection idiom (positive case). |
2616 | template<typename _Default, template<typename...> class _Op, |
2617 | typename... _Args> |
2618 | struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> |
2619 | { |
2620 | using value_t = true_type; |
2621 | using type = _Op<_Args...>; |
2622 | }; |
2623 | |
2624 | // Detect whether _Op<_Args...> is a valid type, use _Default if not. |
2625 | template<typename _Default, template<typename...> class _Op, |
2626 | typename... _Args> |
2627 | using __detected_or = __detector<_Default, void, _Op, _Args...>; |
2628 | |
2629 | // _Op<_Args...> if that is a valid type, otherwise _Default. |
2630 | template<typename _Default, template<typename...> class _Op, |
2631 | typename... _Args> |
2632 | using __detected_or_t |
2633 | = typename __detected_or<_Default, _Op, _Args...>::type; |
2634 | |
2635 | /** |
2636 | * Use SFINAE to determine if the type _Tp has a publicly-accessible |
2637 | * member type _NTYPE. |
2638 | */ |
2639 | #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ |
2640 | template<typename _Tp, typename = __void_t<>> \ |
2641 | struct __has_##_NTYPE \ |
2642 | : false_type \ |
2643 | { }; \ |
2644 | template<typename _Tp> \ |
2645 | struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ |
2646 | : true_type \ |
2647 | { }; |
2648 | |
2649 | template <typename _Tp> |
2650 | struct __is_swappable; |
2651 | |
2652 | template <typename _Tp> |
2653 | struct __is_nothrow_swappable; |
2654 | |
2655 | template<typename> |
2656 | struct __is_tuple_like_impl : false_type |
2657 | { }; |
2658 | |
2659 | template<typename... _Tps> |
2660 | struct __is_tuple_like_impl<tuple<_Tps...>> : true_type |
2661 | { }; |
2662 | |
2663 | // Internal type trait that allows us to sfinae-protect tuple_cat. |
2664 | template<typename _Tp> |
2665 | struct __is_tuple_like |
2666 | : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type |
2667 | { }; |
2668 | /// @endcond |
2669 | |
2670 | template<typename _Tp> |
2671 | _GLIBCXX20_CONSTEXPR |
2672 | inline |
2673 | _Require<__not_<__is_tuple_like<_Tp>>, |
2674 | is_move_constructible<_Tp>, |
2675 | is_move_assignable<_Tp>> |
2676 | swap(_Tp&, _Tp&) |
2677 | noexcept(__and_<is_nothrow_move_constructible<_Tp>, |
2678 | is_nothrow_move_assignable<_Tp>>::value); |
2679 | |
2680 | template<typename _Tp, size_t _Nm> |
2681 | _GLIBCXX20_CONSTEXPR |
2682 | inline |
2683 | __enable_if_t<__is_swappable<_Tp>::value> |
2684 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) |
2685 | noexcept(__is_nothrow_swappable<_Tp>::value); |
2686 | |
2687 | /// @cond undocumented |
2688 | namespace __swappable_details { |
2689 | using std::swap; |
2690 | |
2691 | struct __do_is_swappable_impl |
2692 | { |
2693 | template<typename _Tp, typename |
2694 | = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> |
2695 | static true_type __test(int); |
2696 | |
2697 | template<typename> |
2698 | static false_type __test(...); |
2699 | }; |
2700 | |
2701 | struct __do_is_nothrow_swappable_impl |
2702 | { |
2703 | template<typename _Tp> |
2704 | static __bool_constant< |
2705 | noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) |
2706 | > __test(int); |
2707 | |
2708 | template<typename> |
2709 | static false_type __test(...); |
2710 | }; |
2711 | |
2712 | } // namespace __swappable_details |
2713 | |
2714 | template<typename _Tp> |
2715 | struct __is_swappable_impl |
2716 | : public __swappable_details::__do_is_swappable_impl |
2717 | { |
2718 | typedef decltype(__test<_Tp>(0)) type; |
2719 | }; |
2720 | |
2721 | template<typename _Tp> |
2722 | struct __is_nothrow_swappable_impl |
2723 | : public __swappable_details::__do_is_nothrow_swappable_impl |
2724 | { |
2725 | typedef decltype(__test<_Tp>(0)) type; |
2726 | }; |
2727 | |
2728 | template<typename _Tp> |
2729 | struct __is_swappable |
2730 | : public __is_swappable_impl<_Tp>::type |
2731 | { }; |
2732 | |
2733 | template<typename _Tp> |
2734 | struct __is_nothrow_swappable |
2735 | : public __is_nothrow_swappable_impl<_Tp>::type |
2736 | { }; |
2737 | /// @endcond |
2738 | |
2739 | #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 |
2740 | #define __cpp_lib_is_swappable 201603 |
2741 | /// Metafunctions used for detecting swappable types: p0185r1 |
2742 | |
2743 | /// is_swappable |
2744 | template<typename _Tp> |
2745 | struct is_swappable |
2746 | : public __is_swappable_impl<_Tp>::type |
2747 | { |
2748 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
2749 | "template argument must be a complete class or an unbounded array" ); |
2750 | }; |
2751 | |
2752 | /// is_nothrow_swappable |
2753 | template<typename _Tp> |
2754 | struct is_nothrow_swappable |
2755 | : public __is_nothrow_swappable_impl<_Tp>::type |
2756 | { |
2757 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
2758 | "template argument must be a complete class or an unbounded array" ); |
2759 | }; |
2760 | |
2761 | #if __cplusplus >= 201402L |
2762 | /// is_swappable_v |
2763 | template<typename _Tp> |
2764 | _GLIBCXX17_INLINE constexpr bool is_swappable_v = |
2765 | is_swappable<_Tp>::value; |
2766 | |
2767 | /// is_nothrow_swappable_v |
2768 | template<typename _Tp> |
2769 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = |
2770 | is_nothrow_swappable<_Tp>::value; |
2771 | #endif // __cplusplus >= 201402L |
2772 | |
2773 | /// @cond undocumented |
2774 | namespace __swappable_with_details { |
2775 | using std::swap; |
2776 | |
2777 | struct __do_is_swappable_with_impl |
2778 | { |
2779 | template<typename _Tp, typename _Up, typename |
2780 | = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), |
2781 | typename |
2782 | = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> |
2783 | static true_type __test(int); |
2784 | |
2785 | template<typename, typename> |
2786 | static false_type __test(...); |
2787 | }; |
2788 | |
2789 | struct __do_is_nothrow_swappable_with_impl |
2790 | { |
2791 | template<typename _Tp, typename _Up> |
2792 | static __bool_constant< |
2793 | noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) |
2794 | && |
2795 | noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) |
2796 | > __test(int); |
2797 | |
2798 | template<typename, typename> |
2799 | static false_type __test(...); |
2800 | }; |
2801 | |
2802 | } // namespace __swappable_with_details |
2803 | |
2804 | template<typename _Tp, typename _Up> |
2805 | struct __is_swappable_with_impl |
2806 | : public __swappable_with_details::__do_is_swappable_with_impl |
2807 | { |
2808 | typedef decltype(__test<_Tp, _Up>(0)) type; |
2809 | }; |
2810 | |
2811 | // Optimization for the homogenous lvalue case, not required: |
2812 | template<typename _Tp> |
2813 | struct __is_swappable_with_impl<_Tp&, _Tp&> |
2814 | : public __swappable_details::__do_is_swappable_impl |
2815 | { |
2816 | typedef decltype(__test<_Tp&>(0)) type; |
2817 | }; |
2818 | |
2819 | template<typename _Tp, typename _Up> |
2820 | struct __is_nothrow_swappable_with_impl |
2821 | : public __swappable_with_details::__do_is_nothrow_swappable_with_impl |
2822 | { |
2823 | typedef decltype(__test<_Tp, _Up>(0)) type; |
2824 | }; |
2825 | |
2826 | // Optimization for the homogenous lvalue case, not required: |
2827 | template<typename _Tp> |
2828 | struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> |
2829 | : public __swappable_details::__do_is_nothrow_swappable_impl |
2830 | { |
2831 | typedef decltype(__test<_Tp&>(0)) type; |
2832 | }; |
2833 | /// @endcond |
2834 | |
2835 | /// is_swappable_with |
2836 | template<typename _Tp, typename _Up> |
2837 | struct is_swappable_with |
2838 | : public __is_swappable_with_impl<_Tp, _Up>::type |
2839 | { |
2840 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
2841 | "first template argument must be a complete class or an unbounded array" ); |
2842 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), |
2843 | "second template argument must be a complete class or an unbounded array" ); |
2844 | }; |
2845 | |
2846 | /// is_nothrow_swappable_with |
2847 | template<typename _Tp, typename _Up> |
2848 | struct is_nothrow_swappable_with |
2849 | : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type |
2850 | { |
2851 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
2852 | "first template argument must be a complete class or an unbounded array" ); |
2853 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), |
2854 | "second template argument must be a complete class or an unbounded array" ); |
2855 | }; |
2856 | |
2857 | #if __cplusplus >= 201402L |
2858 | /// is_swappable_with_v |
2859 | template<typename _Tp, typename _Up> |
2860 | _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = |
2861 | is_swappable_with<_Tp, _Up>::value; |
2862 | |
2863 | /// is_nothrow_swappable_with_v |
2864 | template<typename _Tp, typename _Up> |
2865 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = |
2866 | is_nothrow_swappable_with<_Tp, _Up>::value; |
2867 | #endif // __cplusplus >= 201402L |
2868 | |
2869 | #endif// c++1z or gnu++11 |
2870 | |
2871 | /// @cond undocumented |
2872 | |
2873 | // __is_invocable (std::is_invocable for C++11) |
2874 | |
2875 | // The primary template is used for invalid INVOKE expressions. |
2876 | template<typename _Result, typename _Ret, |
2877 | bool = is_void<_Ret>::value, typename = void> |
2878 | struct __is_invocable_impl |
2879 | : false_type |
2880 | { |
2881 | using __nothrow_type = false_type; // For is_nothrow_invocable_r |
2882 | }; |
2883 | |
2884 | // Used for valid INVOKE and INVOKE<void> expressions. |
2885 | template<typename _Result, typename _Ret> |
2886 | struct __is_invocable_impl<_Result, _Ret, |
2887 | /* is_void<_Ret> = */ true, |
2888 | __void_t<typename _Result::type>> |
2889 | : true_type |
2890 | { |
2891 | using __nothrow_type = true_type; // For is_nothrow_invocable_r |
2892 | }; |
2893 | |
2894 | #pragma GCC diagnostic push |
2895 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
2896 | // Used for INVOKE<R> expressions to check the implicit conversion to R. |
2897 | template<typename _Result, typename _Ret> |
2898 | struct __is_invocable_impl<_Result, _Ret, |
2899 | /* is_void<_Ret> = */ false, |
2900 | __void_t<typename _Result::type>> |
2901 | { |
2902 | private: |
2903 | // The type of the INVOKE expression. |
2904 | // Unlike declval, this doesn't add_rvalue_reference, so it respects |
2905 | // guaranteed copy elision. |
2906 | static typename _Result::type _S_get() noexcept; |
2907 | |
2908 | template<typename _Tp> |
2909 | static void _S_conv(_Tp) noexcept; |
2910 | |
2911 | // This overload is viable if INVOKE(f, args...) can convert to _Tp. |
2912 | template<typename _Tp, bool _Check_Noex = false, |
2913 | typename = decltype(_S_conv<_Tp>(_S_get())), |
2914 | bool _Noex = noexcept(_S_conv<_Tp>(_S_get()))> |
2915 | static __bool_constant<_Check_Noex ? _Noex : true> |
2916 | _S_test(int); |
2917 | |
2918 | template<typename _Tp, bool = false> |
2919 | static false_type |
2920 | _S_test(...); |
2921 | |
2922 | public: |
2923 | // For is_invocable_r |
2924 | using type = decltype(_S_test<_Ret>(1)); |
2925 | |
2926 | // For is_nothrow_invocable_r |
2927 | using __nothrow_type = decltype(_S_test<_Ret, true>(1)); |
2928 | }; |
2929 | #pragma GCC diagnostic pop |
2930 | |
2931 | template<typename _Fn, typename... _ArgTypes> |
2932 | struct __is_invocable |
2933 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type |
2934 | { }; |
2935 | |
2936 | template<typename _Fn, typename _Tp, typename... _Args> |
2937 | constexpr bool __call_is_nt(__invoke_memfun_ref) |
2938 | { |
2939 | using _Up = typename __inv_unwrap<_Tp>::type; |
2940 | return noexcept((std::declval<_Up>().*std::declval<_Fn>())( |
2941 | std::declval<_Args>()...)); |
2942 | } |
2943 | |
2944 | template<typename _Fn, typename _Tp, typename... _Args> |
2945 | constexpr bool __call_is_nt(__invoke_memfun_deref) |
2946 | { |
2947 | return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( |
2948 | std::declval<_Args>()...)); |
2949 | } |
2950 | |
2951 | template<typename _Fn, typename _Tp> |
2952 | constexpr bool __call_is_nt(__invoke_memobj_ref) |
2953 | { |
2954 | using _Up = typename __inv_unwrap<_Tp>::type; |
2955 | return noexcept(std::declval<_Up>().*std::declval<_Fn>()); |
2956 | } |
2957 | |
2958 | template<typename _Fn, typename _Tp> |
2959 | constexpr bool __call_is_nt(__invoke_memobj_deref) |
2960 | { |
2961 | return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); |
2962 | } |
2963 | |
2964 | template<typename _Fn, typename... _Args> |
2965 | constexpr bool __call_is_nt(__invoke_other) |
2966 | { |
2967 | return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); |
2968 | } |
2969 | |
2970 | template<typename _Result, typename _Fn, typename... _Args> |
2971 | struct __call_is_nothrow |
2972 | : __bool_constant< |
2973 | std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) |
2974 | > |
2975 | { }; |
2976 | |
2977 | template<typename _Fn, typename... _Args> |
2978 | using __call_is_nothrow_ |
2979 | = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; |
2980 | |
2981 | // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) |
2982 | template<typename _Fn, typename... _Args> |
2983 | struct __is_nothrow_invocable |
2984 | : __and_<__is_invocable<_Fn, _Args...>, |
2985 | __call_is_nothrow_<_Fn, _Args...>>::type |
2986 | { }; |
2987 | |
2988 | #pragma GCC diagnostic push |
2989 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
2990 | struct __nonesuchbase {}; |
2991 | struct __nonesuch : private __nonesuchbase { |
2992 | ~__nonesuch() = delete; |
2993 | __nonesuch(__nonesuch const&) = delete; |
2994 | void operator=(__nonesuch const&) = delete; |
2995 | }; |
2996 | #pragma GCC diagnostic pop |
2997 | /// @endcond |
2998 | |
2999 | #if __cplusplus >= 201703L |
3000 | # define __cpp_lib_is_invocable 201703 |
3001 | |
3002 | /// std::invoke_result |
3003 | template<typename _Functor, typename... _ArgTypes> |
3004 | struct invoke_result |
3005 | : public __invoke_result<_Functor, _ArgTypes...> |
3006 | { |
3007 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Functor>{}), |
3008 | "_Functor must be a complete class or an unbounded array" ); |
3009 | static_assert((std::__is_complete_or_unbounded( |
3010 | __type_identity<_ArgTypes>{}) && ...), |
3011 | "each argument type must be a complete class or an unbounded array" ); |
3012 | }; |
3013 | |
3014 | /// std::invoke_result_t |
3015 | template<typename _Fn, typename... _Args> |
3016 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; |
3017 | |
3018 | /// std::is_invocable |
3019 | template<typename _Fn, typename... _ArgTypes> |
3020 | struct is_invocable |
3021 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type |
3022 | { |
3023 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
3024 | "_Fn must be a complete class or an unbounded array" ); |
3025 | static_assert((std::__is_complete_or_unbounded( |
3026 | __type_identity<_ArgTypes>{}) && ...), |
3027 | "each argument type must be a complete class or an unbounded array" ); |
3028 | }; |
3029 | |
3030 | /// std::is_invocable_r |
3031 | template<typename _Ret, typename _Fn, typename... _ArgTypes> |
3032 | struct is_invocable_r |
3033 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type |
3034 | { |
3035 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
3036 | "_Fn must be a complete class or an unbounded array" ); |
3037 | static_assert((std::__is_complete_or_unbounded( |
3038 | __type_identity<_ArgTypes>{}) && ...), |
3039 | "each argument type must be a complete class or an unbounded array" ); |
3040 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), |
3041 | "_Ret must be a complete class or an unbounded array" ); |
3042 | }; |
3043 | |
3044 | /// std::is_nothrow_invocable |
3045 | template<typename _Fn, typename... _ArgTypes> |
3046 | struct is_nothrow_invocable |
3047 | : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, |
3048 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
3049 | { |
3050 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
3051 | "_Fn must be a complete class or an unbounded array" ); |
3052 | static_assert((std::__is_complete_or_unbounded( |
3053 | __type_identity<_ArgTypes>{}) && ...), |
3054 | "each argument type must be a complete class or an unbounded array" ); |
3055 | }; |
3056 | |
3057 | /// @cond undocumented |
3058 | template<typename _Result, typename _Ret> |
3059 | using __is_nt_invocable_impl |
3060 | = typename __is_invocable_impl<_Result, _Ret>::__nothrow_type; |
3061 | /// @endcond |
3062 | |
3063 | /// std::is_nothrow_invocable_r |
3064 | template<typename _Ret, typename _Fn, typename... _ArgTypes> |
3065 | struct is_nothrow_invocable_r |
3066 | : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, |
3067 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
3068 | { |
3069 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
3070 | "_Fn must be a complete class or an unbounded array" ); |
3071 | static_assert((std::__is_complete_or_unbounded( |
3072 | __type_identity<_ArgTypes>{}) && ...), |
3073 | "each argument type must be a complete class or an unbounded array" ); |
3074 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), |
3075 | "_Ret must be a complete class or an unbounded array" ); |
3076 | }; |
3077 | #endif // C++17 |
3078 | |
3079 | #if __cplusplus >= 201703L |
3080 | # define __cpp_lib_type_trait_variable_templates 201510L |
3081 | /** |
3082 | * @defgroup variable_templates Variable templates for type traits. |
3083 | * @ingroup metaprogramming |
3084 | * |
3085 | * The variable `is_foo_v<T>` is a boolean constant with the same value |
3086 | * as the type trait `is_foo<T>::value`. |
3087 | * |
3088 | * @since C++17 |
3089 | */ |
3090 | |
3091 | /** @ingroup variable_templates |
3092 | * @{ |
3093 | */ |
3094 | template <typename _Tp> |
3095 | inline constexpr bool is_void_v = is_void<_Tp>::value; |
3096 | template <typename _Tp> |
3097 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; |
3098 | template <typename _Tp> |
3099 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; |
3100 | template <typename _Tp> |
3101 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; |
3102 | template <typename _Tp> |
3103 | inline constexpr bool is_array_v = is_array<_Tp>::value; |
3104 | template <typename _Tp> |
3105 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; |
3106 | template <typename _Tp> |
3107 | inline constexpr bool is_lvalue_reference_v = |
3108 | is_lvalue_reference<_Tp>::value; |
3109 | template <typename _Tp> |
3110 | inline constexpr bool is_rvalue_reference_v = |
3111 | is_rvalue_reference<_Tp>::value; |
3112 | template <typename _Tp> |
3113 | inline constexpr bool is_member_object_pointer_v = |
3114 | is_member_object_pointer<_Tp>::value; |
3115 | template <typename _Tp> |
3116 | inline constexpr bool is_member_function_pointer_v = |
3117 | is_member_function_pointer<_Tp>::value; |
3118 | template <typename _Tp> |
3119 | inline constexpr bool is_enum_v = is_enum<_Tp>::value; |
3120 | template <typename _Tp> |
3121 | inline constexpr bool is_union_v = is_union<_Tp>::value; |
3122 | template <typename _Tp> |
3123 | inline constexpr bool is_class_v = is_class<_Tp>::value; |
3124 | template <typename _Tp> |
3125 | inline constexpr bool is_function_v = is_function<_Tp>::value; |
3126 | template <typename _Tp> |
3127 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; |
3128 | template <typename _Tp> |
3129 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; |
3130 | template <typename _Tp> |
3131 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; |
3132 | template <typename _Tp> |
3133 | inline constexpr bool is_object_v = is_object<_Tp>::value; |
3134 | template <typename _Tp> |
3135 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; |
3136 | template <typename _Tp> |
3137 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; |
3138 | template <typename _Tp> |
3139 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; |
3140 | template <typename _Tp> |
3141 | inline constexpr bool is_const_v = is_const<_Tp>::value; |
3142 | template <typename _Tp> |
3143 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; |
3144 | template <typename _Tp> |
3145 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; |
3146 | template <typename _Tp> |
3147 | inline constexpr bool is_trivially_copyable_v = |
3148 | is_trivially_copyable<_Tp>::value; |
3149 | template <typename _Tp> |
3150 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; |
3151 | #pragma GCC diagnostic push |
3152 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
3153 | template <typename _Tp> |
3154 | _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v instead" ) |
3155 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; |
3156 | template <typename _Tp> |
3157 | _GLIBCXX17_DEPRECATED |
3158 | inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; |
3159 | #pragma GCC diagnostic pop |
3160 | template <typename _Tp> |
3161 | inline constexpr bool is_empty_v = is_empty<_Tp>::value; |
3162 | template <typename _Tp> |
3163 | inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; |
3164 | template <typename _Tp> |
3165 | inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; |
3166 | template <typename _Tp> |
3167 | inline constexpr bool is_final_v = is_final<_Tp>::value; |
3168 | template <typename _Tp> |
3169 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; |
3170 | template <typename _Tp> |
3171 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; |
3172 | template <typename _Tp, typename... _Args> |
3173 | inline constexpr bool is_constructible_v = |
3174 | is_constructible<_Tp, _Args...>::value; |
3175 | template <typename _Tp> |
3176 | inline constexpr bool is_default_constructible_v = |
3177 | is_default_constructible<_Tp>::value; |
3178 | template <typename _Tp> |
3179 | inline constexpr bool is_copy_constructible_v = |
3180 | is_copy_constructible<_Tp>::value; |
3181 | template <typename _Tp> |
3182 | inline constexpr bool is_move_constructible_v = |
3183 | is_move_constructible<_Tp>::value; |
3184 | template <typename _Tp, typename _Up> |
3185 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; |
3186 | template <typename _Tp> |
3187 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; |
3188 | template <typename _Tp> |
3189 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; |
3190 | template <typename _Tp> |
3191 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; |
3192 | template <typename _Tp, typename... _Args> |
3193 | inline constexpr bool is_trivially_constructible_v = |
3194 | is_trivially_constructible<_Tp, _Args...>::value; |
3195 | template <typename _Tp> |
3196 | inline constexpr bool is_trivially_default_constructible_v = |
3197 | is_trivially_default_constructible<_Tp>::value; |
3198 | template <typename _Tp> |
3199 | inline constexpr bool is_trivially_copy_constructible_v = |
3200 | is_trivially_copy_constructible<_Tp>::value; |
3201 | template <typename _Tp> |
3202 | inline constexpr bool is_trivially_move_constructible_v = |
3203 | is_trivially_move_constructible<_Tp>::value; |
3204 | template <typename _Tp, typename _Up> |
3205 | inline constexpr bool is_trivially_assignable_v = |
3206 | is_trivially_assignable<_Tp, _Up>::value; |
3207 | template <typename _Tp> |
3208 | inline constexpr bool is_trivially_copy_assignable_v = |
3209 | is_trivially_copy_assignable<_Tp>::value; |
3210 | template <typename _Tp> |
3211 | inline constexpr bool is_trivially_move_assignable_v = |
3212 | is_trivially_move_assignable<_Tp>::value; |
3213 | template <typename _Tp> |
3214 | inline constexpr bool is_trivially_destructible_v = |
3215 | is_trivially_destructible<_Tp>::value; |
3216 | template <typename _Tp, typename... _Args> |
3217 | inline constexpr bool is_nothrow_constructible_v = |
3218 | is_nothrow_constructible<_Tp, _Args...>::value; |
3219 | template <typename _Tp> |
3220 | inline constexpr bool is_nothrow_default_constructible_v = |
3221 | is_nothrow_default_constructible<_Tp>::value; |
3222 | template <typename _Tp> |
3223 | inline constexpr bool is_nothrow_copy_constructible_v = |
3224 | is_nothrow_copy_constructible<_Tp>::value; |
3225 | template <typename _Tp> |
3226 | inline constexpr bool is_nothrow_move_constructible_v = |
3227 | is_nothrow_move_constructible<_Tp>::value; |
3228 | template <typename _Tp, typename _Up> |
3229 | inline constexpr bool is_nothrow_assignable_v = |
3230 | is_nothrow_assignable<_Tp, _Up>::value; |
3231 | template <typename _Tp> |
3232 | inline constexpr bool is_nothrow_copy_assignable_v = |
3233 | is_nothrow_copy_assignable<_Tp>::value; |
3234 | template <typename _Tp> |
3235 | inline constexpr bool is_nothrow_move_assignable_v = |
3236 | is_nothrow_move_assignable<_Tp>::value; |
3237 | template <typename _Tp> |
3238 | inline constexpr bool is_nothrow_destructible_v = |
3239 | is_nothrow_destructible<_Tp>::value; |
3240 | template <typename _Tp> |
3241 | inline constexpr bool has_virtual_destructor_v = |
3242 | has_virtual_destructor<_Tp>::value; |
3243 | template <typename _Tp> |
3244 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; |
3245 | template <typename _Tp> |
3246 | inline constexpr size_t rank_v = rank<_Tp>::value; |
3247 | template <typename _Tp, unsigned _Idx = 0> |
3248 | inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; |
3249 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME |
3250 | template <typename _Tp, typename _Up> |
3251 | inline constexpr bool is_same_v = __is_same(_Tp, _Up); |
3252 | #else |
3253 | template <typename _Tp, typename _Up> |
3254 | inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value; |
3255 | #endif |
3256 | template <typename _Base, typename _Derived> |
3257 | inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; |
3258 | template <typename _From, typename _To> |
3259 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; |
3260 | template<typename _Fn, typename... _Args> |
3261 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; |
3262 | template<typename _Fn, typename... _Args> |
3263 | inline constexpr bool is_nothrow_invocable_v |
3264 | = is_nothrow_invocable<_Fn, _Args...>::value; |
3265 | template<typename _Ret, typename _Fn, typename... _Args> |
3266 | inline constexpr bool is_invocable_r_v |
3267 | = is_invocable_r<_Ret, _Fn, _Args...>::value; |
3268 | template<typename _Ret, typename _Fn, typename... _Args> |
3269 | inline constexpr bool is_nothrow_invocable_r_v |
3270 | = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; |
3271 | /// @} |
3272 | |
3273 | #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP |
3274 | # define __cpp_lib_has_unique_object_representations 201606 |
3275 | /// has_unique_object_representations |
3276 | template<typename _Tp> |
3277 | struct has_unique_object_representations |
3278 | : bool_constant<__has_unique_object_representations( |
3279 | remove_cv_t<remove_all_extents_t<_Tp>> |
3280 | )> |
3281 | { |
3282 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
3283 | "template argument must be a complete class or an unbounded array" ); |
3284 | }; |
3285 | |
3286 | /// @ingroup variable_templates |
3287 | template<typename _Tp> |
3288 | inline constexpr bool has_unique_object_representations_v |
3289 | = has_unique_object_representations<_Tp>::value; |
3290 | #endif |
3291 | |
3292 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE |
3293 | # define __cpp_lib_is_aggregate 201703 |
3294 | /// is_aggregate |
3295 | template<typename _Tp> |
3296 | struct is_aggregate |
3297 | : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> |
3298 | { }; |
3299 | |
3300 | /// @ingroup variable_templates |
3301 | template<typename _Tp> |
3302 | inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; |
3303 | #endif |
3304 | #endif // C++17 |
3305 | |
3306 | #if __cplusplus > 201703L |
3307 | #define __cpp_lib_remove_cvref 201711L |
3308 | |
3309 | /// Remove references and cv-qualifiers. |
3310 | template<typename _Tp> |
3311 | struct remove_cvref |
3312 | : remove_cv<_Tp> |
3313 | { }; |
3314 | |
3315 | template<typename _Tp> |
3316 | struct remove_cvref<_Tp&> |
3317 | : remove_cv<_Tp> |
3318 | { }; |
3319 | |
3320 | template<typename _Tp> |
3321 | struct remove_cvref<_Tp&&> |
3322 | : remove_cv<_Tp> |
3323 | { }; |
3324 | |
3325 | template<typename _Tp> |
3326 | using remove_cvref_t = typename remove_cvref<_Tp>::type; |
3327 | |
3328 | #define __cpp_lib_type_identity 201806L |
3329 | /// Identity metafunction. |
3330 | template<typename _Tp> |
3331 | struct type_identity { using type = _Tp; }; |
3332 | |
3333 | template<typename _Tp> |
3334 | using type_identity_t = typename type_identity<_Tp>::type; |
3335 | |
3336 | #define __cpp_lib_unwrap_ref 201811L |
3337 | |
3338 | /// Unwrap a reference_wrapper |
3339 | template<typename _Tp> |
3340 | struct unwrap_reference { using type = _Tp; }; |
3341 | |
3342 | template<typename _Tp> |
3343 | struct unwrap_reference<reference_wrapper<_Tp>> { using type = _Tp&; }; |
3344 | |
3345 | template<typename _Tp> |
3346 | using unwrap_reference_t = typename unwrap_reference<_Tp>::type; |
3347 | |
3348 | /// Decay type and if it's a reference_wrapper, unwrap it |
3349 | template<typename _Tp> |
3350 | struct unwrap_ref_decay { using type = unwrap_reference_t<decay_t<_Tp>>; }; |
3351 | |
3352 | template<typename _Tp> |
3353 | using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; |
3354 | |
3355 | #define __cpp_lib_bounded_array_traits 201902L |
3356 | |
3357 | /// True for a type that is an array of known bound. |
3358 | template<typename _Tp> |
3359 | struct is_bounded_array |
3360 | : public __is_array_known_bounds<_Tp> |
3361 | { }; |
3362 | |
3363 | /// True for a type that is an array of unknown bound. |
3364 | template<typename _Tp> |
3365 | struct is_unbounded_array |
3366 | : public __is_array_unknown_bounds<_Tp> |
3367 | { }; |
3368 | |
3369 | /// @ingroup variable_templates |
3370 | template<typename _Tp> |
3371 | inline constexpr bool is_bounded_array_v |
3372 | = is_bounded_array<_Tp>::value; |
3373 | |
3374 | /// @ingroup variable_templates |
3375 | template<typename _Tp> |
3376 | inline constexpr bool is_unbounded_array_v |
3377 | = is_unbounded_array<_Tp>::value; |
3378 | |
3379 | #if __cplusplus > 202002L |
3380 | #define __cpp_lib_is_scoped_enum 202011L |
3381 | |
3382 | /// @since C++23 |
3383 | //@{ |
3384 | |
3385 | template<typename _Tp> |
3386 | struct is_scoped_enum |
3387 | : false_type |
3388 | { }; |
3389 | |
3390 | template<typename _Tp> |
3391 | requires __is_enum(_Tp) |
3392 | && requires(_Tp __t) { __t = __t; } // fails if incomplete |
3393 | struct is_scoped_enum<_Tp> |
3394 | : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }> |
3395 | { }; |
3396 | |
3397 | // FIXME remove this partial specialization and use remove_cv_t<_Tp> above |
3398 | // when PR c++/99968 is fixed. |
3399 | template<typename _Tp> |
3400 | requires __is_enum(_Tp) |
3401 | && requires(_Tp __t) { __t = __t; } // fails if incomplete |
3402 | struct is_scoped_enum<const _Tp> |
3403 | : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }> |
3404 | { }; |
3405 | |
3406 | /** |
3407 | * @ingroup variable_templates |
3408 | */ |
3409 | template<typename _Tp> |
3410 | inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; |
3411 | #endif // C++23 |
3412 | |
3413 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED |
3414 | |
3415 | #define __cpp_lib_is_constant_evaluated 201811L |
3416 | |
3417 | /// Returns true only when called during constant evaluation. |
3418 | constexpr inline bool |
3419 | is_constant_evaluated() noexcept |
3420 | { return __builtin_is_constant_evaluated(); } |
3421 | /// @} |
3422 | #endif |
3423 | |
3424 | /// @cond undocumented |
3425 | template<typename _From, typename _To> |
3426 | using __copy_cv = typename __match_cv_qualifiers<_From, _To>::__type; |
3427 | |
3428 | template<typename _Xp, typename _Yp> |
3429 | using __cond_res |
3430 | = decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); |
3431 | |
3432 | template<typename _Ap, typename _Bp, typename = void> |
3433 | struct __common_ref_impl |
3434 | { }; |
3435 | |
3436 | // [meta.trans.other], COMMON-REF(A, B) |
3437 | template<typename _Ap, typename _Bp> |
3438 | using __common_ref = typename __common_ref_impl<_Ap, _Bp>::type; |
3439 | |
3440 | // COND-RES(COPYCV(X, Y) &, COPYCV(Y, X) &) |
3441 | template<typename _Xp, typename _Yp> |
3442 | using __condres_cvref |
3443 | = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>; |
3444 | |
3445 | // If A and B are both lvalue reference types, ... |
3446 | template<typename _Xp, typename _Yp> |
3447 | struct __common_ref_impl<_Xp&, _Yp&, __void_t<__condres_cvref<_Xp, _Yp>>> |
3448 | : enable_if<is_reference_v<__condres_cvref<_Xp, _Yp>>, |
3449 | __condres_cvref<_Xp, _Yp>> |
3450 | { }; |
3451 | |
3452 | // let C be remove_reference_t<COMMON-REF(X&, Y&)>&& |
3453 | template<typename _Xp, typename _Yp> |
3454 | using __common_ref_C = remove_reference_t<__common_ref<_Xp&, _Yp&>>&&; |
3455 | |
3456 | // If A and B are both rvalue reference types, ... |
3457 | template<typename _Xp, typename _Yp> |
3458 | struct __common_ref_impl<_Xp&&, _Yp&&, |
3459 | _Require<is_convertible<_Xp&&, __common_ref_C<_Xp, _Yp>>, |
3460 | is_convertible<_Yp&&, __common_ref_C<_Xp, _Yp>>>> |
3461 | { using type = __common_ref_C<_Xp, _Yp>; }; |
3462 | |
3463 | // let D be COMMON-REF(const X&, Y&) |
3464 | template<typename _Xp, typename _Yp> |
3465 | using __common_ref_D = __common_ref<const _Xp&, _Yp&>; |
3466 | |
3467 | // If A is an rvalue reference and B is an lvalue reference, ... |
3468 | template<typename _Xp, typename _Yp> |
3469 | struct __common_ref_impl<_Xp&&, _Yp&, |
3470 | _Require<is_convertible<_Xp&&, __common_ref_D<_Xp, _Yp>>>> |
3471 | { using type = __common_ref_D<_Xp, _Yp>; }; |
3472 | |
3473 | // If A is an lvalue reference and B is an rvalue reference, ... |
3474 | template<typename _Xp, typename _Yp> |
3475 | struct __common_ref_impl<_Xp&, _Yp&&> |
3476 | : __common_ref_impl<_Yp&&, _Xp&> |
3477 | { }; |
3478 | /// @endcond |
3479 | |
3480 | template<typename _Tp, typename _Up, |
3481 | template<typename> class _TQual, template<typename> class _UQual> |
3482 | struct basic_common_reference |
3483 | { }; |
3484 | |
3485 | /// @cond undocumented |
3486 | template<typename _Tp> |
3487 | struct __xref |
3488 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>; }; |
3489 | |
3490 | template<typename _Tp> |
3491 | struct __xref<_Tp&> |
3492 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&; }; |
3493 | |
3494 | template<typename _Tp> |
3495 | struct __xref<_Tp&&> |
3496 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&&; }; |
3497 | |
3498 | template<typename _Tp1, typename _Tp2> |
3499 | using __basic_common_ref |
3500 | = typename basic_common_reference<remove_cvref_t<_Tp1>, |
3501 | remove_cvref_t<_Tp2>, |
3502 | __xref<_Tp1>::template __type, |
3503 | __xref<_Tp2>::template __type>::type; |
3504 | /// @endcond |
3505 | |
3506 | template<typename... _Tp> |
3507 | struct common_reference; |
3508 | |
3509 | template<typename... _Tp> |
3510 | using common_reference_t = typename common_reference<_Tp...>::type; |
3511 | |
3512 | // If sizeof...(T) is zero, there shall be no member type. |
3513 | template<> |
3514 | struct common_reference<> |
3515 | { }; |
3516 | |
3517 | // If sizeof...(T) is one ... |
3518 | template<typename _Tp0> |
3519 | struct common_reference<_Tp0> |
3520 | { using type = _Tp0; }; |
3521 | |
3522 | /// @cond undocumented |
3523 | template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void> |
3524 | struct __common_reference_impl |
3525 | : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1> |
3526 | { }; |
3527 | |
3528 | // If sizeof...(T) is two ... |
3529 | template<typename _Tp1, typename _Tp2> |
3530 | struct common_reference<_Tp1, _Tp2> |
3531 | : __common_reference_impl<_Tp1, _Tp2> |
3532 | { }; |
3533 | |
3534 | // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ... |
3535 | template<typename _Tp1, typename _Tp2> |
3536 | struct __common_reference_impl<_Tp1&, _Tp2&, 1, |
3537 | void_t<__common_ref<_Tp1&, _Tp2&>>> |
3538 | { using type = __common_ref<_Tp1&, _Tp2&>; }; |
3539 | |
3540 | template<typename _Tp1, typename _Tp2> |
3541 | struct __common_reference_impl<_Tp1&&, _Tp2&&, 1, |
3542 | void_t<__common_ref<_Tp1&&, _Tp2&&>>> |
3543 | { using type = __common_ref<_Tp1&&, _Tp2&&>; }; |
3544 | |
3545 | template<typename _Tp1, typename _Tp2> |
3546 | struct __common_reference_impl<_Tp1&, _Tp2&&, 1, |
3547 | void_t<__common_ref<_Tp1&, _Tp2&&>>> |
3548 | { using type = __common_ref<_Tp1&, _Tp2&&>; }; |
3549 | |
3550 | template<typename _Tp1, typename _Tp2> |
3551 | struct __common_reference_impl<_Tp1&&, _Tp2&, 1, |
3552 | void_t<__common_ref<_Tp1&&, _Tp2&>>> |
3553 | { using type = __common_ref<_Tp1&&, _Tp2&>; }; |
3554 | |
3555 | // Otherwise, if basic_common_reference<...>::type is well-formed, ... |
3556 | template<typename _Tp1, typename _Tp2> |
3557 | struct __common_reference_impl<_Tp1, _Tp2, 2, |
3558 | void_t<__basic_common_ref<_Tp1, _Tp2>>> |
3559 | { using type = __basic_common_ref<_Tp1, _Tp2>; }; |
3560 | |
3561 | // Otherwise, if COND-RES(T1, T2) is well-formed, ... |
3562 | template<typename _Tp1, typename _Tp2> |
3563 | struct __common_reference_impl<_Tp1, _Tp2, 3, |
3564 | void_t<__cond_res<_Tp1, _Tp2>>> |
3565 | { using type = __cond_res<_Tp1, _Tp2>; }; |
3566 | |
3567 | // Otherwise, if common_type_t<T1, T2> is well-formed, ... |
3568 | template<typename _Tp1, typename _Tp2> |
3569 | struct __common_reference_impl<_Tp1, _Tp2, 4, |
3570 | void_t<common_type_t<_Tp1, _Tp2>>> |
3571 | { using type = common_type_t<_Tp1, _Tp2>; }; |
3572 | |
3573 | // Otherwise, there shall be no member type. |
3574 | template<typename _Tp1, typename _Tp2> |
3575 | struct __common_reference_impl<_Tp1, _Tp2, 5, void> |
3576 | { }; |
3577 | |
3578 | // Otherwise, if sizeof...(T) is greater than two, ... |
3579 | template<typename _Tp1, typename _Tp2, typename... _Rest> |
3580 | struct common_reference<_Tp1, _Tp2, _Rest...> |
3581 | : __common_type_fold<common_reference<_Tp1, _Tp2>, |
3582 | __common_type_pack<_Rest...>> |
3583 | { }; |
3584 | |
3585 | // Reuse __common_type_fold for common_reference<T1, T2, Rest...> |
3586 | template<typename _Tp1, typename _Tp2, typename... _Rest> |
3587 | struct __common_type_fold<common_reference<_Tp1, _Tp2>, |
3588 | __common_type_pack<_Rest...>, |
3589 | void_t<common_reference_t<_Tp1, _Tp2>>> |
3590 | : public common_reference<common_reference_t<_Tp1, _Tp2>, _Rest...> |
3591 | { }; |
3592 | /// @endcond |
3593 | |
3594 | #endif // C++2a |
3595 | |
3596 | /// @} group metaprogramming |
3597 | |
3598 | _GLIBCXX_END_NAMESPACE_VERSION |
3599 | } // namespace std |
3600 | |
3601 | #endif // C++11 |
3602 | |
3603 | #endif // _GLIBCXX_TYPE_TRAITS |
3604 | |