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