1// C++11 <type_traits> -*- C++ -*-
3// Copyright (C) 2007-2025 Free Software Foundation, Inc.
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)
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.
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.
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/>.
25/** @file include/type_traits
26 * This is a Standard C++ Library header.
29#ifndef _GLIBCXX_TYPE_TRAITS
30#define _GLIBCXX_TYPE_TRAITS 1
33#pragma GCC system_header
36#if __cplusplus < 201103L
37# include <bits/c++0x_warning.h>
40#include <bits/c++config.h>
42#define __glibcxx_want_bool_constant
43#define __glibcxx_want_bounded_array_traits
44#define __glibcxx_want_constant_wrapper
45#define __glibcxx_want_has_unique_object_representations
46#define __glibcxx_want_integral_constant_callable
47#define __glibcxx_want_is_aggregate
48#define __glibcxx_want_is_constant_evaluated
49#define __glibcxx_want_is_final
50#define __glibcxx_want_is_implicit_lifetime
51#define __glibcxx_want_is_invocable
52#define __glibcxx_want_is_layout_compatible
53#define __glibcxx_want_is_nothrow_convertible
54#define __glibcxx_want_is_null_pointer
55#define __glibcxx_want_is_pointer_interconvertible
56#define __glibcxx_want_is_scoped_enum
57#define __glibcxx_want_is_swappable
58#define __glibcxx_want_is_virtual_base_of
59#define __glibcxx_want_logical_traits
60#define __glibcxx_want_reference_from_temporary
61#define __glibcxx_want_remove_cvref
62#define __glibcxx_want_result_of_sfinae
63#define __glibcxx_want_transformation_trait_aliases
64#define __glibcxx_want_type_identity
65#define __glibcxx_want_type_trait_variable_templates
66#define __glibcxx_want_unwrap_ref
67#define __glibcxx_want_void_t
68#include <bits/version.h>
72namespace std _GLIBCXX_VISIBILITY(default)
74_GLIBCXX_BEGIN_NAMESPACE_VERSION
76 template<typename _Tp>
77 class reference_wrapper;
80 * @defgroup metaprogramming Metaprogramming
83 * Template utilities for compile-time introspection and modification,
84 * including type classification traits, type property inspection traits
85 * and type transformation traits.
93 template<typename _Tp, _Tp __v>
94 struct integral_constant
96 static constexpr _Tp value = __v;
97 using value_type = _Tp;
98 using type = integral_constant<_Tp, __v>;
99 constexpr operator value_type() const noexcept { return value; }
101#ifdef __cpp_lib_integral_constant_callable // C++ >= 14
102 constexpr value_type operator()() const noexcept { return value; }
106#if ! __cpp_inline_variables
107 template<typename _Tp, _Tp __v>
108 constexpr _Tp integral_constant<_Tp, __v>::value;
111 /// @cond undocumented
112 /// bool_constant for C++11
114 using __bool_constant = integral_constant<bool, __v>;
117 /// The type used as a compile-time boolean with true value.
118 using true_type = __bool_constant<true>;
120 /// The type used as a compile-time boolean with false value.
121 using false_type = __bool_constant<false>;
123#ifdef __cpp_lib_bool_constant // C++ >= 17
124 /// Alias template for compile-time boolean constant types.
127 using bool_constant = __bool_constant<__v>;
130 // Metaprogramming helper types.
133 /// Define a member typedef `type` only if a boolean constant is true.
134 template<bool, typename _Tp = void>
138 // Partial specialization for true.
139 template<typename _Tp>
140 struct enable_if<true, _Tp>
141 { using type = _Tp; };
143 // __enable_if_t (std::enable_if_t for C++11)
144 template<bool _Cond, typename _Tp = void>
145 using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
150 template<typename _Tp, typename>
155 struct __conditional<false>
157 template<typename, typename _Up>
161 // More efficient version of std::conditional_t for internal use (and C++11)
162 template<bool _Cond, typename _If, typename _Else>
163 using __conditional_t
164 = typename __conditional<_Cond>::template type<_If, _Else>;
166 /// @cond undocumented
167 template <typename _Type>
168 struct __type_identity
169 { using type = _Type; };
171 template<typename _Tp>
172 using __type_identity_t = typename __type_identity<_Tp>::type;
176 // A variadic alias template that resolves to its first argument.
177 template<typename _Tp, typename...>
178 using __first_t = _Tp;
180 // These are deliberately not defined.
181 template<typename... _Bn>
182 auto __or_fn(int) -> __first_t<false_type,
183 __enable_if_t<!bool(_Bn::value)>...>;
185 template<typename... _Bn>
186 auto __or_fn(...) -> true_type;
188 template<typename... _Bn>
189 auto __and_fn(int) -> __first_t<true_type,
190 __enable_if_t<bool(_Bn::value)>...>;
192 template<typename... _Bn>
193 auto __and_fn(...) -> false_type;
194 } // namespace detail
196 // Like C++17 std::dis/conjunction, but usable in C++11 and resolves
197 // to either true_type or false_type which allows for a more efficient
198 // implementation that avoids recursive class template instantiation.
199 template<typename... _Bn>
201 : decltype(__detail::__or_fn<_Bn...>(0))
204 template<typename... _Bn>
206 : decltype(__detail::__and_fn<_Bn...>(0))
209 template<typename _Pp>
211 : __bool_constant<!bool(_Pp::value)>
215#ifdef __cpp_lib_logical_traits // C++ >= 17
217 /// @cond undocumented
218 template<typename... _Bn>
219 inline constexpr bool __or_v = __or_<_Bn...>::value;
220 template<typename... _Bn>
221 inline constexpr bool __and_v = __and_<_Bn...>::value;
225 template<typename /* = void */, typename _B1, typename... _Bn>
226 struct __disjunction_impl
227 { using type = _B1; };
229 template<typename _B1, typename _B2, typename... _Bn>
230 struct __disjunction_impl<__enable_if_t<!bool(_B1::value)>, _B1, _B2, _Bn...>
231 { using type = typename __disjunction_impl<void, _B2, _Bn...>::type; };
233 template<typename /* = void */, typename _B1, typename... _Bn>
234 struct __conjunction_impl
235 { using type = _B1; };
237 template<typename _B1, typename _B2, typename... _Bn>
238 struct __conjunction_impl<__enable_if_t<bool(_B1::value)>, _B1, _B2, _Bn...>
239 { using type = typename __conjunction_impl<void, _B2, _Bn...>::type; };
240 } // namespace __detail
243 template<typename... _Bn>
245 : __detail::__conjunction_impl<void, _Bn...>::type
253 template<typename... _Bn>
255 : __detail::__disjunction_impl<void, _Bn...>::type
263 template<typename _Pp>
268 /** @ingroup variable_templates
271 template<typename... _Bn>
272 inline constexpr bool conjunction_v = conjunction<_Bn...>::value;
274 template<typename... _Bn>
275 inline constexpr bool disjunction_v = disjunction<_Bn...>::value;
277 template<typename _Pp>
278 inline constexpr bool negation_v = negation<_Pp>::value;
281#endif // __cpp_lib_logical_traits
283 // Forward declarations
291 /// @cond undocumented
293 struct __is_array_unknown_bounds;
295 // An object type which is not an unbounded array.
296 // It might still be an incomplete type, but if this is false_type
297 // then we can be certain it's not a complete object type.
298 template<typename _Tp>
299 using __maybe_complete_object_type
300 = __and_<is_object<_Tp>, __not_<__is_array_unknown_bounds<_Tp>>>;
302 // Helper functions that return false_type for incomplete classes,
303 // incomplete unions and arrays of known bound from those.
305 // More specialized overload for complete object types (returning true_type).
306 template<typename _Tp,
307 typename = __enable_if_t<__maybe_complete_object_type<_Tp>::value>,
308 size_t = sizeof(_Tp)>
310 __is_complete_or_unbounded(__type_identity<_Tp>)
313 // Less specialized overload for reference and unknown-bound array types
314 // (returning true_type), and incomplete types (returning false_type).
315 template<typename _TypeIdentity,
316 typename _NestedType = typename _TypeIdentity::type>
317 constexpr typename __not_<__maybe_complete_object_type<_NestedType>>::type
318 __is_complete_or_unbounded(_TypeIdentity)
321 // __remove_cv_t (std::remove_cv_t for C++11).
322 template<typename _Tp>
323 using __remove_cv_t = typename remove_cv<_Tp>::type;
326 // Primary type categories.
329 template<typename _Tp>
331 : public false_type { };
335 : public true_type { };
338 struct is_void<const void>
339 : public true_type { };
342 struct is_void<volatile void>
343 : public true_type { };
346 struct is_void<const volatile void>
347 : public true_type { };
349 /// @cond undocumented
351 struct __is_integral_helper
352 : public false_type { };
355 struct __is_integral_helper<bool>
356 : public true_type { };
359 struct __is_integral_helper<char>
360 : public true_type { };
363 struct __is_integral_helper<signed char>
364 : public true_type { };
367 struct __is_integral_helper<unsigned char>
368 : public true_type { };
370 // We want is_integral<wchar_t> to be true (and make_signed/unsigned to work)
371 // even when libc doesn't provide working <wchar.h> and related functions,
372 // so don't check _GLIBCXX_USE_WCHAR_T here.
374 struct __is_integral_helper<wchar_t>
375 : public true_type { };
377#ifdef _GLIBCXX_USE_CHAR8_T
379 struct __is_integral_helper<char8_t>
380 : public true_type { };
384 struct __is_integral_helper<char16_t>
385 : public true_type { };
388 struct __is_integral_helper<char32_t>
389 : public true_type { };
392 struct __is_integral_helper<short>
393 : public true_type { };
396 struct __is_integral_helper<unsigned short>
397 : public true_type { };
400 struct __is_integral_helper<int>
401 : public true_type { };
404 struct __is_integral_helper<unsigned int>
405 : public true_type { };
408 struct __is_integral_helper<long>
409 : public true_type { };
412 struct __is_integral_helper<unsigned long>
413 : public true_type { };
416 struct __is_integral_helper<long long>
417 : public true_type { };
420 struct __is_integral_helper<unsigned long long>
421 : public true_type { };
423 // Conditionalizing on __STRICT_ANSI__ here will break any port that
424 // uses one of these types for size_t.
425#if defined(__GLIBCXX_TYPE_INT_N_0)
428 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
429 : public true_type { };
433 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
434 : public true_type { };
436#if defined(__GLIBCXX_TYPE_INT_N_1)
439 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
440 : public true_type { };
444 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
445 : public true_type { };
447#if defined(__GLIBCXX_TYPE_INT_N_2)
450 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
451 : public true_type { };
455 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
456 : public true_type { };
458#if defined(__GLIBCXX_TYPE_INT_N_3)
461 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
462 : public true_type { };
466 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
467 : public true_type { };
470#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
473 struct __is_integral_helper<__int128>
474 : public true_type { };
478 struct __is_integral_helper<unsigned __int128>
479 : public true_type { };
485 template<typename _Tp>
487 : public __is_integral_helper<__remove_cv_t<_Tp>>::type
490 /// @cond undocumented
492 struct __is_floating_point_helper
493 : public false_type { };
496 struct __is_floating_point_helper<float>
497 : public true_type { };
500 struct __is_floating_point_helper<double>
501 : public true_type { };
504 struct __is_floating_point_helper<long double>
505 : public true_type { };
507#ifdef __STDCPP_FLOAT16_T__
509 struct __is_floating_point_helper<_Float16>
510 : public true_type { };
513#ifdef __STDCPP_FLOAT32_T__
515 struct __is_floating_point_helper<_Float32>
516 : public true_type { };
519#ifdef __STDCPP_FLOAT64_T__
521 struct __is_floating_point_helper<_Float64>
522 : public true_type { };
525#ifdef __STDCPP_FLOAT128_T__
527 struct __is_floating_point_helper<_Float128>
528 : public true_type { };
531#ifdef __STDCPP_BFLOAT16_T__
533 struct __is_floating_point_helper<__gnu_cxx::__bfloat16_t>
534 : public true_type { };
537#ifdef _GLIBCXX_USE_FLOAT128
539 struct __is_floating_point_helper<__float128>
540 : public true_type { };
544 /// is_floating_point
545 template<typename _Tp>
546 struct is_floating_point
547 : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type
551#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_array)
552 template<typename _Tp>
554 : public __bool_constant<__is_array(_Tp)>
559 : public false_type { };
561 template<typename _Tp, std::size_t _Size>
562 struct is_array<_Tp[_Size]>
563 : public true_type { };
565 template<typename _Tp>
566 struct is_array<_Tp[]>
567 : public true_type { };
571#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
572 template<typename _Tp>
574 : public __bool_constant<__is_pointer(_Tp)>
577 template<typename _Tp>
579 : public false_type { };
581 template<typename _Tp>
582 struct is_pointer<_Tp*>
583 : public true_type { };
585 template<typename _Tp>
586 struct is_pointer<_Tp* const>
587 : public true_type { };
589 template<typename _Tp>
590 struct is_pointer<_Tp* volatile>
591 : public true_type { };
593 template<typename _Tp>
594 struct is_pointer<_Tp* const volatile>
595 : public true_type { };
598 /// is_lvalue_reference
600 struct is_lvalue_reference
601 : public false_type { };
603 template<typename _Tp>
604 struct is_lvalue_reference<_Tp&>
605 : public true_type { };
607 /// is_rvalue_reference
609 struct is_rvalue_reference
610 : public false_type { };
612 template<typename _Tp>
613 struct is_rvalue_reference<_Tp&&>
614 : public true_type { };
616 /// is_member_object_pointer
617#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_object_pointer)
618 template<typename _Tp>
619 struct is_member_object_pointer
620 : public __bool_constant<__is_member_object_pointer(_Tp)>
624 struct __is_member_object_pointer_helper
625 : public false_type { };
627 template<typename _Tp, typename _Cp>
628 struct __is_member_object_pointer_helper<_Tp _Cp::*>
629 : public __not_<is_function<_Tp>>::type { };
632 template<typename _Tp>
633 struct is_member_object_pointer
634 : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type
638#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_function_pointer)
639 /// is_member_function_pointer
640 template<typename _Tp>
641 struct is_member_function_pointer
642 : public __bool_constant<__is_member_function_pointer(_Tp)>
646 struct __is_member_function_pointer_helper
647 : public false_type { };
649 template<typename _Tp, typename _Cp>
650 struct __is_member_function_pointer_helper<_Tp _Cp::*>
651 : public is_function<_Tp>::type { };
653 /// is_member_function_pointer
654 template<typename _Tp>
655 struct is_member_function_pointer
656 : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type
661 template<typename _Tp>
663 : public __bool_constant<__is_enum(_Tp)>
667 template<typename _Tp>
669 : public __bool_constant<__is_union(_Tp)>
673 template<typename _Tp>
675 : public __bool_constant<__is_class(_Tp)>
679#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function)
680 template<typename _Tp>
682 : public __bool_constant<__is_function(_Tp)>
685 template<typename _Tp>
687 : public __bool_constant<!is_const<const _Tp>::value> { };
689 template<typename _Tp>
690 struct is_function<_Tp&>
691 : public false_type { };
693 template<typename _Tp>
694 struct is_function<_Tp&&>
695 : public false_type { };
698#ifdef __cpp_lib_is_null_pointer // C++ >= 11
699 /// is_null_pointer (LWG 2247).
700 template<typename _Tp>
701 struct is_null_pointer
702 : public false_type { };
705 struct is_null_pointer<std::nullptr_t>
706 : public true_type { };
709 struct is_null_pointer<const std::nullptr_t>
710 : public true_type { };
713 struct is_null_pointer<volatile std::nullptr_t>
714 : public true_type { };
717 struct is_null_pointer<const volatile std::nullptr_t>
718 : public true_type { };
720 /// __is_nullptr_t (deprecated extension).
721 /// @deprecated Non-standard. Use `is_null_pointer` instead.
722 template<typename _Tp>
723 struct __is_nullptr_t
724 : public is_null_pointer<_Tp>
725 { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer");
726#endif // __cpp_lib_is_null_pointer
728 // Composite type categories.
731#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference)
732 template<typename _Tp>
734 : public __bool_constant<__is_reference(_Tp)>
737 template<typename _Tp>
742 template<typename _Tp>
743 struct is_reference<_Tp&>
747 template<typename _Tp>
748 struct is_reference<_Tp&&>
754 template<typename _Tp>
756 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
760 template<typename _Tp>
761 struct is_fundamental
762 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
763 is_null_pointer<_Tp>>::type
767#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object)
768 template<typename _Tp>
770 : public __bool_constant<__is_object(_Tp)>
773 template<typename _Tp>
775 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
781 struct is_member_pointer;
784 template<typename _Tp>
786 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
787 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
791 template<typename _Tp>
793 : public __bool_constant<!is_fundamental<_Tp>::value> { };
795 /// is_member_pointer
796#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_pointer)
797 template<typename _Tp>
798 struct is_member_pointer
799 : public __bool_constant<__is_member_pointer(_Tp)>
802 /// @cond undocumented
803 template<typename _Tp>
804 struct __is_member_pointer_helper
805 : public false_type { };
807 template<typename _Tp, typename _Cp>
808 struct __is_member_pointer_helper<_Tp _Cp::*>
809 : public true_type { };
812 template<typename _Tp>
813 struct is_member_pointer
814 : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type
818 template<typename, typename>
821 /// @cond undocumented
822 template<typename _Tp, typename... _Types>
823 using __is_one_of = __or_<is_same<_Tp, _Types>...>;
825 // Check if a type is one of the signed integer types.
827 template<typename _Tp>
828 using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>,
829 signed char, signed short, signed int, signed long,
831#if defined(__GLIBCXX_TYPE_INT_N_0)
832 , signed __GLIBCXX_TYPE_INT_N_0
834#if defined(__GLIBCXX_TYPE_INT_N_1)
835 , signed __GLIBCXX_TYPE_INT_N_1
837#if defined(__GLIBCXX_TYPE_INT_N_2)
838 , signed __GLIBCXX_TYPE_INT_N_2
840#if defined(__GLIBCXX_TYPE_INT_N_3)
841 , signed __GLIBCXX_TYPE_INT_N_3
845 // Check if a type is one of the unsigned integer types.
847 template<typename _Tp>
848 using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>,
849 unsigned char, unsigned short, unsigned int, unsigned long,
851#if defined(__GLIBCXX_TYPE_INT_N_0)
852 , unsigned __GLIBCXX_TYPE_INT_N_0
854#if defined(__GLIBCXX_TYPE_INT_N_1)
855 , unsigned __GLIBCXX_TYPE_INT_N_1
857#if defined(__GLIBCXX_TYPE_INT_N_2)
858 , unsigned __GLIBCXX_TYPE_INT_N_2
860#if defined(__GLIBCXX_TYPE_INT_N_3)
861 , unsigned __GLIBCXX_TYPE_INT_N_3
865 // Check if a type is one of the signed or unsigned integer types.
866 template<typename _Tp>
867 using __is_standard_integer
868 = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>;
870 // __void_t (std::void_t for C++11)
871 template<typename...> using __void_t = void;
877#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const)
878 template<typename _Tp>
880 : public __bool_constant<__is_const(_Tp)>
885 : public false_type { };
887 template<typename _Tp>
888 struct is_const<_Tp const>
889 : public true_type { };
893#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile)
894 template<typename _Tp>
896 : public __bool_constant<__is_volatile(_Tp)>
901 : public false_type { };
903 template<typename _Tp>
904 struct is_volatile<_Tp volatile>
905 : public true_type { };
909 * @deprecated Deprecated in C++26.
910 * Use a combination of one or more more specialized type traits instead,
911 * such as `is_trivially_default_constructible`,
912 * `is_trivially_copy_constructible`, `is_trivially_copy_assignable`,
913 * etc., depending on the exact check(s) needed.
915 template<typename _Tp>
917 _GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible && is_trivially_copyable")
919 : public __bool_constant<__is_trivial(_Tp)>
921 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
922 "template argument must be a complete class or an unbounded array");
925 /// is_trivially_copyable
926 template<typename _Tp>
927 struct is_trivially_copyable
928 : public __bool_constant<__is_trivially_copyable(_Tp)>
930 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
931 "template argument must be a complete class or an unbounded array");
934 /// is_standard_layout
935 template<typename _Tp>
936 struct is_standard_layout
937 : public __bool_constant<__is_standard_layout(_Tp)>
939 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
940 "template argument must be a complete class or an unbounded array");
944 * @deprecated Deprecated in C++20.
945 * Use `is_standard_layout && is_trivial` instead.
947 // Could use is_standard_layout && is_trivial instead of the builtin.
948 template<typename _Tp>
950 _GLIBCXX20_DEPRECATED_SUGGEST("is_standard_layout && is_trivial")
952 : public __bool_constant<__is_pod(_Tp)>
954 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
955 "template argument must be a complete class or an unbounded array");
959 * @deprecated Deprecated in C++17, removed in C++20.
960 * The idea of a literal type isn't useful.
962 template<typename _Tp>
964 _GLIBCXX17_DEPRECATED
966 : public __bool_constant<__is_literal_type(_Tp)>
968 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
969 "template argument must be a complete class or an unbounded array");
973 template<typename _Tp>
975 : public __bool_constant<__is_empty(_Tp)>
979 template<typename _Tp>
980 struct is_polymorphic
981 : public __bool_constant<__is_polymorphic(_Tp)>
984#ifdef __cpp_lib_is_final // C++ >= 14
987 template<typename _Tp>
989 : public __bool_constant<__is_final(_Tp)>
994 template<typename _Tp>
996 : public __bool_constant<__is_abstract(_Tp)>
999 /// @cond undocumented
1000 template<typename _Tp,
1001 bool = is_arithmetic<_Tp>::value>
1002 struct __is_signed_helper
1003 : public false_type { };
1005 template<typename _Tp>
1006 struct __is_signed_helper<_Tp, true>
1007 : public __bool_constant<_Tp(-1) < _Tp(0)>
1012 template<typename _Tp>
1014 : public __is_signed_helper<_Tp>::type
1018 template<typename _Tp>
1020 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
1023 /// @cond undocumented
1024 template<typename _Tp, typename _Up = _Tp&&>
1028 template<typename _Tp>
1033 template<typename _Tp>
1034 auto declval() noexcept -> decltype(__declval<_Tp>(0));
1037 struct remove_all_extents;
1039 /// @cond undocumented
1040 template<typename _Tp>
1041 struct __is_array_known_bounds
1045 template<typename _Tp, size_t _Size>
1046 struct __is_array_known_bounds<_Tp[_Size]>
1050 template<typename _Tp>
1051 struct __is_array_unknown_bounds
1055 template<typename _Tp>
1056 struct __is_array_unknown_bounds<_Tp[]>
1061 // Destructible and constructible type properties.
1063#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_destructible)
1065 template<typename _Tp>
1066 struct is_destructible
1067 : public __bool_constant<__is_destructible(_Tp)>
1070 /// @cond undocumented
1072 // In N3290 is_destructible does not say anything about function
1073 // types and abstract types, see LWG 2049. This implementation
1074 // describes function types as non-destructible and all complete
1075 // object types as destructible, iff the explicit destructor
1076 // call expression is wellformed.
1077 struct __do_is_destructible_impl
1079 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
1080 static true_type __test(int);
1083 static false_type __test(...);
1086 template<typename _Tp>
1087 struct __is_destructible_impl
1088 : public __do_is_destructible_impl
1090 using type = decltype(__test<_Tp>(0));
1093 template<typename _Tp,
1094 bool = __or_<is_void<_Tp>,
1095 __is_array_unknown_bounds<_Tp>,
1096 is_function<_Tp>>::value,
1097 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
1098 struct __is_destructible_safe;
1100 template<typename _Tp>
1101 struct __is_destructible_safe<_Tp, false, false>
1102 : public __is_destructible_impl<typename
1103 remove_all_extents<_Tp>::type>::type
1106 template<typename _Tp>
1107 struct __is_destructible_safe<_Tp, true, false>
1108 : public false_type { };
1110 template<typename _Tp>
1111 struct __is_destructible_safe<_Tp, false, true>
1112 : public true_type { };
1116 template<typename _Tp>
1117 struct is_destructible
1118 : public __is_destructible_safe<_Tp>::type
1120 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1121 "template argument must be a complete class or an unbounded array");
1125#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_destructible)
1126 /// is_nothrow_destructible
1127 template<typename _Tp>
1128 struct is_nothrow_destructible
1129 : public __bool_constant<__is_nothrow_destructible(_Tp)>
1132 /// @cond undocumented
1134 // is_nothrow_destructible requires that is_destructible is
1135 // satisfied as well. We realize that by mimicing the
1136 // implementation of is_destructible but refer to noexcept(expr)
1137 // instead of decltype(expr).
1138 struct __do_is_nt_destructible_impl
1140 template<typename _Tp>
1141 static __bool_constant<noexcept(declval<_Tp&>().~_Tp())>
1145 static false_type __test(...);
1148 template<typename _Tp>
1149 struct __is_nt_destructible_impl
1150 : public __do_is_nt_destructible_impl
1152 using type = decltype(__test<_Tp>(0));
1155 template<typename _Tp,
1156 bool = __or_<is_void<_Tp>,
1157 __is_array_unknown_bounds<_Tp>,
1158 is_function<_Tp>>::value,
1159 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
1160 struct __is_nt_destructible_safe;
1162 template<typename _Tp>
1163 struct __is_nt_destructible_safe<_Tp, false, false>
1164 : public __is_nt_destructible_impl<typename
1165 remove_all_extents<_Tp>::type>::type
1168 template<typename _Tp>
1169 struct __is_nt_destructible_safe<_Tp, true, false>
1170 : public false_type { };
1172 template<typename _Tp>
1173 struct __is_nt_destructible_safe<_Tp, false, true>
1174 : public true_type { };
1177 /// is_nothrow_destructible
1178 template<typename _Tp>
1179 struct is_nothrow_destructible
1180 : public __is_nt_destructible_safe<_Tp>::type
1182 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1183 "template argument must be a complete class or an unbounded array");
1187 /// @cond undocumented
1188 template<typename _Tp, typename... _Args>
1189 using __is_constructible_impl
1190 = __bool_constant<__is_constructible(_Tp, _Args...)>;
1193 /// is_constructible
1194 template<typename _Tp, typename... _Args>
1195 struct is_constructible
1196 : public __is_constructible_impl<_Tp, _Args...>
1198 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1199 "template argument must be a complete class or an unbounded array");
1202 /// is_default_constructible
1203 template<typename _Tp>
1204 struct is_default_constructible
1205 : public __is_constructible_impl<_Tp>
1207 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1208 "template argument must be a complete class or an unbounded array");
1211 /// @cond undocumented
1212#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_lvalue_reference)
1213 template<typename _Tp>
1214 using __add_lval_ref_t = __add_lvalue_reference(_Tp);
1216 template<typename _Tp, typename = void>
1217 struct __add_lvalue_reference_helper
1218 { using type = _Tp; };
1220 template<typename _Tp>
1221 struct __add_lvalue_reference_helper<_Tp, __void_t<_Tp&>>
1222 { using type = _Tp&; };
1224 template<typename _Tp>
1225 using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type;
1229 /// is_copy_constructible
1230 template<typename _Tp>
1231 struct is_copy_constructible
1232 : public __is_constructible_impl<_Tp, __add_lval_ref_t<const _Tp>>
1234 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1235 "template argument must be a complete class or an unbounded array");
1238 /// @cond undocumented
1239#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_rvalue_reference)
1240 template<typename _Tp>
1241 using __add_rval_ref_t = __add_rvalue_reference(_Tp);
1243 template<typename _Tp, typename = void>
1244 struct __add_rvalue_reference_helper
1245 { using type = _Tp; };
1247 template<typename _Tp>
1248 struct __add_rvalue_reference_helper<_Tp, __void_t<_Tp&&>>
1249 { using type = _Tp&&; };
1251 template<typename _Tp>
1252 using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type;
1256 /// is_move_constructible
1257 template<typename _Tp>
1258 struct is_move_constructible
1259 : public __is_constructible_impl<_Tp, __add_rval_ref_t<_Tp>>
1261 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1262 "template argument must be a complete class or an unbounded array");
1265 /// @cond undocumented
1266 template<typename _Tp, typename... _Args>
1267 using __is_nothrow_constructible_impl
1268 = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>;
1271 /// is_nothrow_constructible
1272 template<typename _Tp, typename... _Args>
1273 struct is_nothrow_constructible
1274 : public __is_nothrow_constructible_impl<_Tp, _Args...>
1276 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1277 "template argument must be a complete class or an unbounded array");
1280 /// is_nothrow_default_constructible
1281 template<typename _Tp>
1282 struct is_nothrow_default_constructible
1283 : public __is_nothrow_constructible_impl<_Tp>
1285 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1286 "template argument must be a complete class or an unbounded array");
1289 /// is_nothrow_copy_constructible
1290 template<typename _Tp>
1291 struct is_nothrow_copy_constructible
1292 : public __is_nothrow_constructible_impl<_Tp, __add_lval_ref_t<const _Tp>>
1294 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1295 "template argument must be a complete class or an unbounded array");
1298 /// is_nothrow_move_constructible
1299 template<typename _Tp>
1300 struct is_nothrow_move_constructible
1301 : public __is_nothrow_constructible_impl<_Tp, __add_rval_ref_t<_Tp>>
1303 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1304 "template argument must be a complete class or an unbounded array");
1307 /// @cond undocumented
1308 template<typename _Tp, typename _Up>
1309 using __is_assignable_impl = __bool_constant<__is_assignable(_Tp, _Up)>;
1313 template<typename _Tp, typename _Up>
1314 struct is_assignable
1315 : public __is_assignable_impl<_Tp, _Up>
1317 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1318 "template argument must be a complete class or an unbounded array");
1321 /// is_copy_assignable
1322 template<typename _Tp>
1323 struct is_copy_assignable
1324 : public __is_assignable_impl<__add_lval_ref_t<_Tp>,
1325 __add_lval_ref_t<const _Tp>>
1327 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1328 "template argument must be a complete class or an unbounded array");
1331 /// is_move_assignable
1332 template<typename _Tp>
1333 struct is_move_assignable
1334 : public __is_assignable_impl<__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>>
1336 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1337 "template argument must be a complete class or an unbounded array");
1340 /// @cond undocumented
1341 template<typename _Tp, typename _Up>
1342 using __is_nothrow_assignable_impl
1343 = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>;
1346 /// is_nothrow_assignable
1347 template<typename _Tp, typename _Up>
1348 struct is_nothrow_assignable
1349 : public __is_nothrow_assignable_impl<_Tp, _Up>
1351 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1352 "template argument must be a complete class or an unbounded array");
1355 /// is_nothrow_copy_assignable
1356 template<typename _Tp>
1357 struct is_nothrow_copy_assignable
1358 : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>,
1359 __add_lval_ref_t<const _Tp>>
1361 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1362 "template argument must be a complete class or an unbounded array");
1365 /// is_nothrow_move_assignable
1366 template<typename _Tp>
1367 struct is_nothrow_move_assignable
1368 : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>,
1369 __add_rval_ref_t<_Tp>>
1371 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1372 "template argument must be a complete class or an unbounded array");
1375 /// @cond undocumented
1376 template<typename _Tp, typename... _Args>
1377 using __is_trivially_constructible_impl
1378 = __bool_constant<__is_trivially_constructible(_Tp, _Args...)>;
1381 /// is_trivially_constructible
1382 template<typename _Tp, typename... _Args>
1383 struct is_trivially_constructible
1384 : public __is_trivially_constructible_impl<_Tp, _Args...>
1386 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1387 "template argument must be a complete class or an unbounded array");
1390 /// is_trivially_default_constructible
1391 template<typename _Tp>
1392 struct is_trivially_default_constructible
1393 : public __is_trivially_constructible_impl<_Tp>
1395 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1396 "template argument must be a complete class or an unbounded array");
1399#if __cpp_variable_templates && __cpp_concepts
1400 template<typename _Tp>
1401 constexpr bool __is_implicitly_default_constructible_v
1402 = requires (void(&__f)(_Tp)) { __f({}); };
1404 template<typename _Tp>
1405 struct __is_implicitly_default_constructible
1406 : __bool_constant<__is_implicitly_default_constructible_v<_Tp>>
1409 struct __do_is_implicitly_default_constructible_impl
1411 template <typename _Tp>
1412 static void __helper(const _Tp&);
1414 template <typename _Tp>
1415 static true_type __test(const _Tp&,
1416 decltype(__helper<const _Tp&>({}))* = 0);
1418 static false_type __test(...);
1421 template<typename _Tp>
1422 struct __is_implicitly_default_constructible_impl
1423 : public __do_is_implicitly_default_constructible_impl
1425 using type = decltype(__test(declval<_Tp>()));
1428 template<typename _Tp>
1429 struct __is_implicitly_default_constructible_safe
1430 : public __is_implicitly_default_constructible_impl<_Tp>::type
1433 template <typename _Tp>
1434 struct __is_implicitly_default_constructible
1435 : public __and_<__is_constructible_impl<_Tp>,
1436 __is_implicitly_default_constructible_safe<_Tp>>::type
1440 /// is_trivially_copy_constructible
1441 template<typename _Tp>
1442 struct is_trivially_copy_constructible
1443 : public __is_trivially_constructible_impl<_Tp, __add_lval_ref_t<const _Tp>>
1445 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1446 "template argument must be a complete class or an unbounded array");
1449 /// is_trivially_move_constructible
1450 template<typename _Tp>
1451 struct is_trivially_move_constructible
1452 : public __is_trivially_constructible_impl<_Tp, __add_rval_ref_t<_Tp>>
1454 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1455 "template argument must be a complete class or an unbounded array");
1458 /// @cond undocumented
1459 template<typename _Tp, typename _Up>
1460 using __is_trivially_assignable_impl
1461 = __bool_constant<__is_trivially_assignable(_Tp, _Up)>;
1464 /// is_trivially_assignable
1465 template<typename _Tp, typename _Up>
1466 struct is_trivially_assignable
1467 : public __is_trivially_assignable_impl<_Tp, _Up>
1469 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1470 "template argument must be a complete class or an unbounded array");
1473 /// is_trivially_copy_assignable
1474 template<typename _Tp>
1475 struct is_trivially_copy_assignable
1476 : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>,
1477 __add_lval_ref_t<const _Tp>>
1479 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1480 "template argument must be a complete class or an unbounded array");
1483 /// is_trivially_move_assignable
1484 template<typename _Tp>
1485 struct is_trivially_move_assignable
1486 : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>,
1487 __add_rval_ref_t<_Tp>>
1489 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1490 "template argument must be a complete class or an unbounded array");
1493#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_trivially_destructible)
1494 /// is_trivially_destructible
1495 template<typename _Tp>
1496 struct is_trivially_destructible
1497 : public __bool_constant<__is_trivially_destructible(_Tp)>
1500 /// is_trivially_destructible
1501 template<typename _Tp>
1502 struct is_trivially_destructible
1503 : public __and_<__is_destructible_safe<_Tp>,
1504 __bool_constant<__has_trivial_destructor(_Tp)>>::type
1506 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1507 "template argument must be a complete class or an unbounded array");
1511 /// has_virtual_destructor
1512 template<typename _Tp>
1513 struct has_virtual_destructor
1514 : public __bool_constant<__has_virtual_destructor(_Tp)>
1516 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1517 "template argument must be a complete class or an unbounded array");
1521 // type property queries.
1524 template<typename _Tp>
1526 : public integral_constant<std::size_t, alignof(_Tp)>
1528 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
1529 "template argument must be a complete class or an unbounded array");
1533#if _GLIBCXX_USE_BUILTIN_TRAIT(__array_rank) \
1534 && (!defined(__clang__) || __clang_major__ >= 20) // PR118559
1535 template<typename _Tp>
1537 : public integral_constant<std::size_t, __array_rank(_Tp)> { };
1541 : public integral_constant<std::size_t, 0> { };
1543 template<typename _Tp, std::size_t _Size>
1544 struct rank<_Tp[_Size]>
1545 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1547 template<typename _Tp>
1549 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1553 template<typename, unsigned _Uint = 0>
1555 : public integral_constant<size_t, 0> { };
1557 template<typename _Tp, size_t _Size>
1558 struct extent<_Tp[_Size], 0>
1559 : public integral_constant<size_t, _Size> { };
1561 template<typename _Tp, unsigned _Uint, size_t _Size>
1562 struct extent<_Tp[_Size], _Uint>
1563 : public extent<_Tp, _Uint - 1>::type { };
1565 template<typename _Tp>
1566 struct extent<_Tp[], 0>
1567 : public integral_constant<size_t, 0> { };
1569 template<typename _Tp, unsigned _Uint>
1570 struct extent<_Tp[], _Uint>
1571 : public extent<_Tp, _Uint - 1>::type { };
1577#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
1578 template<typename _Tp, typename _Up>
1580 : public __bool_constant<__is_same(_Tp, _Up)>
1583 template<typename _Tp, typename _Up>
1588 template<typename _Tp>
1589 struct is_same<_Tp, _Tp>
1595 template<typename _Base, typename _Derived>
1597 : public __bool_constant<__is_base_of(_Base, _Derived)>
1600#ifdef __cpp_lib_is_virtual_base_of // C++ >= 26
1601 /// is_virtual_base_of
1603 template<typename _Base, typename _Derived>
1604 struct is_virtual_base_of
1605 : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)>
1609#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible)
1610 template<typename _From, typename _To>
1611 struct is_convertible
1612 : public __bool_constant<__is_convertible(_From, _To)>
1615 template<typename _From, typename _To,
1616 bool = __or_<is_void<_From>, is_function<_To>,
1617 is_array<_To>>::value>
1618 struct __is_convertible_helper
1620 using type = typename is_void<_To>::type;
1623#pragma GCC diagnostic push
1624#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
1625 template<typename _From, typename _To>
1626 class __is_convertible_helper<_From, _To, false>
1628 template<typename _To1>
1629 static void __test_aux(_To1) noexcept;
1631 template<typename _From1, typename _To1,
1632 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1636 template<typename, typename>
1641 using type = decltype(__test<_From, _To>(0));
1643#pragma GCC diagnostic pop
1646 template<typename _From, typename _To>
1647 struct is_convertible
1648 : public __is_convertible_helper<_From, _To>::type
1652 // helper trait for unique_ptr<T[]>, shared_ptr<T[]>, and span<T, N>
1653 template<typename _ToElementType, typename _FromElementType>
1654 using __is_array_convertible
1655 = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>;
1657#ifdef __cpp_lib_is_nothrow_convertible // C++ >= 20
1659#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_convertible)
1660 /// is_nothrow_convertible_v
1661 template<typename _From, typename _To>
1662 inline constexpr bool is_nothrow_convertible_v
1663 = __is_nothrow_convertible(_From, _To);
1665 /// is_nothrow_convertible
1666 template<typename _From, typename _To>
1667 struct is_nothrow_convertible
1668 : public bool_constant<is_nothrow_convertible_v<_From, _To>>
1671 template<typename _From, typename _To,
1672 bool = __or_<is_void<_From>, is_function<_To>,
1673 is_array<_To>>::value>
1674 struct __is_nt_convertible_helper
1678#pragma GCC diagnostic push
1679#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
1680 template<typename _From, typename _To>
1681 class __is_nt_convertible_helper<_From, _To, false>
1683 template<typename _To1>
1684 static void __test_aux(_To1) noexcept;
1686 template<typename _From1, typename _To1>
1688 __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))>
1691 template<typename, typename>
1696 using type = decltype(__test<_From, _To>(0));
1698#pragma GCC diagnostic pop
1700 /// is_nothrow_convertible
1701 template<typename _From, typename _To>
1702 struct is_nothrow_convertible
1703 : public __is_nt_convertible_helper<_From, _To>::type
1706 /// is_nothrow_convertible_v
1707 template<typename _From, typename _To>
1708 inline constexpr bool is_nothrow_convertible_v
1709 = is_nothrow_convertible<_From, _To>::value;
1711#endif // __cpp_lib_is_nothrow_convertible
1713#pragma GCC diagnostic push
1714#pragma GCC diagnostic ignored "-Wc++14-extensions" // for variable templates
1715 template<typename _Tp, typename... _Args>
1716 struct __is_nothrow_new_constructible_impl
1718 noexcept(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))
1722 template<typename _Tp, typename... _Args>
1723 _GLIBCXX17_INLINE constexpr bool __is_nothrow_new_constructible
1724 = __and_<is_constructible<_Tp, _Args...>,
1725 __is_nothrow_new_constructible_impl<_Tp, _Args...>>::value;
1726#pragma GCC diagnostic pop
1728 // Const-volatile modifications.
1731 template<typename _Tp>
1733 { using type = _Tp; };
1735 template<typename _Tp>
1736 struct remove_const<_Tp const>
1737 { using type = _Tp; };
1740 template<typename _Tp>
1741 struct remove_volatile
1742 { using type = _Tp; };
1744 template<typename _Tp>
1745 struct remove_volatile<_Tp volatile>
1746 { using type = _Tp; };
1749#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cv)
1750 template<typename _Tp>
1752 { using type = __remove_cv(_Tp); };
1754 template<typename _Tp>
1756 { using type = _Tp; };
1758 template<typename _Tp>
1759 struct remove_cv<const _Tp>
1760 { using type = _Tp; };
1762 template<typename _Tp>
1763 struct remove_cv<volatile _Tp>
1764 { using type = _Tp; };
1766 template<typename _Tp>
1767 struct remove_cv<const volatile _Tp>
1768 { using type = _Tp; };
1772 template<typename _Tp>
1774 { using type = _Tp const; };
1777 template<typename _Tp>
1779 { using type = _Tp volatile; };
1782 template<typename _Tp>
1784 { using type = _Tp const volatile; };
1786#ifdef __cpp_lib_transformation_trait_aliases // C++ >= 14
1787 /// Alias template for remove_const
1788 template<typename _Tp>
1789 using remove_const_t = typename remove_const<_Tp>::type;
1791 /// Alias template for remove_volatile
1792 template<typename _Tp>
1793 using remove_volatile_t = typename remove_volatile<_Tp>::type;
1795 /// Alias template for remove_cv
1796 template<typename _Tp>
1797 using remove_cv_t = typename remove_cv<_Tp>::type;
1799 /// Alias template for add_const
1800 template<typename _Tp>
1801 using add_const_t = typename add_const<_Tp>::type;
1803 /// Alias template for add_volatile
1804 template<typename _Tp>
1805 using add_volatile_t = typename add_volatile<_Tp>::type;
1807 /// Alias template for add_cv
1808 template<typename _Tp>
1809 using add_cv_t = typename add_cv<_Tp>::type;
1812 // Reference transformations.
1814 /// remove_reference
1815#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_reference)
1816 template<typename _Tp>
1817 struct remove_reference
1818 { using type = __remove_reference(_Tp); };
1820 template<typename _Tp>
1821 struct remove_reference
1822 { using type = _Tp; };
1824 template<typename _Tp>
1825 struct remove_reference<_Tp&>
1826 { using type = _Tp; };
1828 template<typename _Tp>
1829 struct remove_reference<_Tp&&>
1830 { using type = _Tp; };
1833 /// add_lvalue_reference
1834 template<typename _Tp>
1835 struct add_lvalue_reference
1836 { using type = __add_lval_ref_t<_Tp>; };
1838 /// add_rvalue_reference
1839 template<typename _Tp>
1840 struct add_rvalue_reference
1841 { using type = __add_rval_ref_t<_Tp>; };
1843#if __cplusplus > 201103L
1844 /// Alias template for remove_reference
1845 template<typename _Tp>
1846 using remove_reference_t = typename remove_reference<_Tp>::type;
1848 /// Alias template for add_lvalue_reference
1849 template<typename _Tp>
1850 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1852 /// Alias template for add_rvalue_reference
1853 template<typename _Tp>
1854 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1857 // Sign modifications.
1859 /// @cond undocumented
1861 // Utility for constructing identically cv-qualified types.
1862 template<typename _Unqualified, bool _IsConst, bool _IsVol>
1863 struct __cv_selector;
1865 template<typename _Unqualified>
1866 struct __cv_selector<_Unqualified, false, false>
1867 { using __type = _Unqualified; };
1869 template<typename _Unqualified>
1870 struct __cv_selector<_Unqualified, false, true>
1871 { using __type = volatile _Unqualified; };
1873 template<typename _Unqualified>
1874 struct __cv_selector<_Unqualified, true, false>
1875 { using __type = const _Unqualified; };
1877 template<typename _Unqualified>
1878 struct __cv_selector<_Unqualified, true, true>
1879 { using __type = const volatile _Unqualified; };
1881 template<typename _Qualified, typename _Unqualified,
1882 bool _IsConst = is_const<_Qualified>::value,
1883 bool _IsVol = is_volatile<_Qualified>::value>
1884 class __match_cv_qualifiers
1886 using __match = __cv_selector<_Unqualified, _IsConst, _IsVol>;
1889 using __type = typename __match::__type;
1892 // Utility for finding the unsigned versions of signed integral types.
1893 template<typename _Tp>
1894 struct __make_unsigned
1895 { using __type = _Tp; };
1898 struct __make_unsigned<char>
1899 { using __type = unsigned char; };
1902 struct __make_unsigned<signed char>
1903 { using __type = unsigned char; };
1906 struct __make_unsigned<short>
1907 { using __type = unsigned short; };
1910 struct __make_unsigned<int>
1911 { using __type = unsigned int; };
1914 struct __make_unsigned<long>
1915 { using __type = unsigned long; };
1918 struct __make_unsigned<long long>
1919 { using __type = unsigned long long; };
1921#if defined(__GLIBCXX_TYPE_INT_N_0)
1924 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1925 { using __type = unsigned __GLIBCXX_TYPE_INT_N_0; };
1927#if defined(__GLIBCXX_TYPE_INT_N_1)
1930 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1931 { using __type = unsigned __GLIBCXX_TYPE_INT_N_1; };
1933#if defined(__GLIBCXX_TYPE_INT_N_2)
1936 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1937 { using __type = unsigned __GLIBCXX_TYPE_INT_N_2; };
1939#if defined(__GLIBCXX_TYPE_INT_N_3)
1942 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1943 { using __type = unsigned __GLIBCXX_TYPE_INT_N_3; };
1945#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
1948 struct __make_unsigned<__int128>
1949 { using __type = unsigned __int128; };
1952 // Select between integral and enum: not possible to be both.
1953 template<typename _Tp,
1954 bool _IsInt = is_integral<_Tp>::value,
1955 bool _IsEnum = __is_enum(_Tp)>
1956 class __make_unsigned_selector;
1958 template<typename _Tp>
1959 class __make_unsigned_selector<_Tp, true, false>
1961 using __unsigned_type
1962 = typename __make_unsigned<__remove_cv_t<_Tp>>::__type;
1966 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type;
1969 class __make_unsigned_selector_base
1972 template<typename...> struct _List { };
1974 template<typename _Tp, typename... _Up>
1975 struct _List<_Tp, _Up...> : _List<_Up...>
1976 { static constexpr size_t __size = sizeof(_Tp); };
1978 template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
1981 template<size_t _Sz, typename _Uint, typename... _UInts>
1982 struct __select<_Sz, _List<_Uint, _UInts...>, true>
1983 { using __type = _Uint; };
1985 template<size_t _Sz, typename _Uint, typename... _UInts>
1986 struct __select<_Sz, _List<_Uint, _UInts...>, false>
1987 : __select<_Sz, _List<_UInts...>>
1991 // Choose unsigned integer type with the smallest rank and same size as _Tp
1992 template<typename _Tp>
1993 class __make_unsigned_selector<_Tp, false, true>
1994 : __make_unsigned_selector_base
1996 // With -fshort-enums, an enum may be as small as a char.
1998 using _UInts = _List<unsigned char, unsigned short, unsigned int,
1999 unsigned long, unsigned long long
2000#ifdef __SIZEOF_INT128__
2005 using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type;
2009 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type;
2012 // wchar_t, char8_t, char16_t and char32_t are integral types but are
2013 // neither signed integer types nor unsigned integer types, so must be
2014 // transformed to the unsigned integer type with the smallest rank.
2015 // Use the partial specialization for enumeration types to do that.
2017 struct __make_unsigned<wchar_t>
2020 = typename __make_unsigned_selector<wchar_t, false, true>::__type;
2023#ifdef _GLIBCXX_USE_CHAR8_T
2025 struct __make_unsigned<char8_t>
2028 = typename __make_unsigned_selector<char8_t, false, true>::__type;
2033 struct __make_unsigned<char16_t>
2036 = typename __make_unsigned_selector<char16_t, false, true>::__type;
2040 struct __make_unsigned<char32_t>
2043 = typename __make_unsigned_selector<char32_t, false, true>::__type;
2047 // Given an integral/enum type, return the corresponding unsigned
2049 // Primary template.
2051 template<typename _Tp>
2052 struct make_unsigned
2053 { using type = typename __make_unsigned_selector<_Tp>::__type; };
2055 // Integral, but don't define.
2056 template<> struct make_unsigned<bool>;
2057 template<> struct make_unsigned<bool const>;
2058 template<> struct make_unsigned<bool volatile>;
2059 template<> struct make_unsigned<bool const volatile>;
2061 /// @cond undocumented
2063 // Utility for finding the signed versions of unsigned integral types.
2064 template<typename _Tp>
2065 struct __make_signed
2066 { using __type = _Tp; };
2069 struct __make_signed<char>
2070 { using __type = signed char; };
2073 struct __make_signed<unsigned char>
2074 { using __type = signed char; };
2077 struct __make_signed<unsigned short>
2078 { using __type = signed short; };
2081 struct __make_signed<unsigned int>
2082 { using __type = signed int; };
2085 struct __make_signed<unsigned long>
2086 { using __type = signed long; };
2089 struct __make_signed<unsigned long long>
2090 { using __type = signed long long; };
2092#if defined(__GLIBCXX_TYPE_INT_N_0)
2095 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
2096 { using __type = __GLIBCXX_TYPE_INT_N_0; };
2098#if defined(__GLIBCXX_TYPE_INT_N_1)
2101 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
2102 { using __type = __GLIBCXX_TYPE_INT_N_1; };
2104#if defined(__GLIBCXX_TYPE_INT_N_2)
2107 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
2108 { using __type = __GLIBCXX_TYPE_INT_N_2; };
2110#if defined(__GLIBCXX_TYPE_INT_N_3)
2113 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
2114 { using __type = __GLIBCXX_TYPE_INT_N_3; };
2116#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
2119 struct __make_signed<unsigned __int128>
2120 { using __type = __int128; };
2123 // Select between integral and enum: not possible to be both.
2124 template<typename _Tp,
2125 bool _IsInt = is_integral<_Tp>::value,
2126 bool _IsEnum = __is_enum(_Tp)>
2127 class __make_signed_selector;
2129 template<typename _Tp>
2130 class __make_signed_selector<_Tp, true, false>
2133 = typename __make_signed<__remove_cv_t<_Tp>>::__type;
2137 = typename __match_cv_qualifiers<_Tp, __signed_type>::__type;
2140 // Choose signed integer type with the smallest rank and same size as _Tp
2141 template<typename _Tp>
2142 class __make_signed_selector<_Tp, false, true>
2144 using __unsigned_type = typename __make_unsigned_selector<_Tp>::__type;
2147 using __type = typename __make_signed_selector<__unsigned_type>::__type;
2150 // wchar_t, char16_t and char32_t are integral types but are neither
2151 // signed integer types nor unsigned integer types, so must be
2152 // transformed to the signed integer type with the smallest rank.
2153 // Use the partial specialization for enumeration types to do that.
2155 struct __make_signed<wchar_t>
2158 = typename __make_signed_selector<wchar_t, false, true>::__type;
2161#if defined(_GLIBCXX_USE_CHAR8_T)
2163 struct __make_signed<char8_t>
2166 = typename __make_signed_selector<char8_t, false, true>::__type;
2171 struct __make_signed<char16_t>
2174 = typename __make_signed_selector<char16_t, false, true>::__type;
2178 struct __make_signed<char32_t>
2181 = typename __make_signed_selector<char32_t, false, true>::__type;
2185 // Given an integral/enum type, return the corresponding signed
2187 // Primary template.
2189 template<typename _Tp>
2191 { using type = typename __make_signed_selector<_Tp>::__type; };
2193 // Integral, but don't define.
2194 template<> struct make_signed<bool>;
2195 template<> struct make_signed<bool const>;
2196 template<> struct make_signed<bool volatile>;
2197 template<> struct make_signed<bool const volatile>;
2199#if __cplusplus > 201103L
2200 /// Alias template for make_signed
2201 template<typename _Tp>
2202 using make_signed_t = typename make_signed<_Tp>::type;
2204 /// Alias template for make_unsigned
2205 template<typename _Tp>
2206 using make_unsigned_t = typename make_unsigned<_Tp>::type;
2209 // Array modifications.
2212#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_extent)
2213 template<typename _Tp>
2214 struct remove_extent
2215 { using type = __remove_extent(_Tp); };
2217 template<typename _Tp>
2218 struct remove_extent
2219 { using type = _Tp; };
2221 template<typename _Tp, std::size_t _Size>
2222 struct remove_extent<_Tp[_Size]>
2223 { using type = _Tp; };
2225 template<typename _Tp>
2226 struct remove_extent<_Tp[]>
2227 { using type = _Tp; };
2230 /// remove_all_extents
2231#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_all_extents)
2232 template<typename _Tp>
2233 struct remove_all_extents
2234 { using type = __remove_all_extents(_Tp); };
2236 template<typename _Tp>
2237 struct remove_all_extents
2238 { using type = _Tp; };
2240 template<typename _Tp, std::size_t _Size>
2241 struct remove_all_extents<_Tp[_Size]>
2242 { using type = typename remove_all_extents<_Tp>::type; };
2244 template<typename _Tp>
2245 struct remove_all_extents<_Tp[]>
2246 { using type = typename remove_all_extents<_Tp>::type; };
2249#if __cplusplus > 201103L
2250 /// Alias template for remove_extent
2251 template<typename _Tp>
2252 using remove_extent_t = typename remove_extent<_Tp>::type;
2254 /// Alias template for remove_all_extents
2255 template<typename _Tp>
2256 using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
2259 // Pointer modifications.
2262#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_pointer)
2263 template<typename _Tp>
2264 struct remove_pointer
2265 { using type = __remove_pointer(_Tp); };
2267 template<typename _Tp, typename>
2268 struct __remove_pointer_helper
2269 { using type = _Tp; };
2271 template<typename _Tp, typename _Up>
2272 struct __remove_pointer_helper<_Tp, _Up*>
2273 { using type = _Up; };
2275 template<typename _Tp>
2276 struct remove_pointer
2277 : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>>
2282#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_pointer)
2283 template<typename _Tp>
2285 { using type = __add_pointer(_Tp); };
2287 template<typename _Tp, typename = void>
2288 struct __add_pointer_helper
2289 { using type = _Tp; };
2291 template<typename _Tp>
2292 struct __add_pointer_helper<_Tp, __void_t<_Tp*>>
2293 { using type = _Tp*; };
2295 template<typename _Tp>
2297 : public __add_pointer_helper<_Tp>
2300 template<typename _Tp>
2301 struct add_pointer<_Tp&>
2302 { using type = _Tp*; };
2304 template<typename _Tp>
2305 struct add_pointer<_Tp&&>
2306 { using type = _Tp*; };
2309#if __cplusplus > 201103L
2310 /// Alias template for remove_pointer
2311 template<typename _Tp>
2312 using remove_pointer_t = typename remove_pointer<_Tp>::type;
2314 /// Alias template for add_pointer
2315 template<typename _Tp>
2316 using add_pointer_t = typename add_pointer<_Tp>::type;
2319 /// @cond undocumented
2321 // Aligned to maximum fundamental alignment
2322 struct __attribute__((__aligned__)) __aligned_storage_max_align_t
2326 __aligned_storage_default_alignment([[__maybe_unused__]] size_t __len)
2328#if _GLIBCXX_INLINE_VERSION
2330 = integral_constant<size_t, alignof(__aligned_storage_max_align_t)>;
2332 return __len > (_Max_align::value / 2)
2334# if _GLIBCXX_USE_BUILTIN_TRAIT(__builtin_clzg)
2335 : 1 << (__SIZE_WIDTH__ - __builtin_clzg(__len - 1u));
2337 : 1 << (__LLONG_WIDTH__ - __builtin_clzll(__len - 1ull));
2340 // Returning a fixed value is incorrect, but kept for ABI compatibility.
2341 // XXX GLIBCXX_ABI Deprecated
2342 return alignof(__aligned_storage_max_align_t);
2348 * @brief Aligned storage
2350 * The member typedef `type` is be a POD type suitable for use as
2351 * uninitialized storage for any object whose size is at most `_Len`
2352 * and whose alignment is a divisor of `_Align`.
2354 * It is important to use the nested `type` as uninitialized storage,
2355 * not the `std::aligned_storage` type itself which is an empty class
2356 * with 1-byte alignment. So this is correct:
2358 * `typename std::aligned_storage<sizeof(X), alignof(X)>::type m_xobj;`
2362 * `std::aligned_storage<sizeof(X), alignof(X)> m_xobj;`
2364 * In C++14 and later `std::aligned_storage_t<sizeof(X), alignof(X)>`
2365 * can be used to refer to the `type` member typedef.
2367 * The default value of _Align is supposed to be the most stringent
2368 * fundamental alignment requirement for any C++ object type whose size
2369 * is no greater than `_Len` (see [basic.align] in the C++ standard).
2371 * @bug In this implementation the default value for _Align is always the
2372 * maximum fundamental alignment, i.e. `alignof(max_align_t)`, which is
2373 * incorrect. It should be an alignment value no greater than `_Len`.
2375 * @deprecated Deprecated in C++23. Uses can be replaced by an
2376 * array `std::byte[_Len]` declared with `alignas(_Align)`.
2378 template<size_t _Len,
2379 size_t _Align = __aligned_storage_default_alignment(_Len)>
2381 _GLIBCXX23_DEPRECATED
2386 alignas(_Align) unsigned char __data[_Len];
2390 template <typename... _Types>
2391 struct __strictest_alignment
2393 static const size_t _S_alignment = 0;
2394 static const size_t _S_size = 0;
2397 template <typename _Tp, typename... _Types>
2398 struct __strictest_alignment<_Tp, _Types...>
2400 static const size_t _S_alignment =
2401 alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment
2402 ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment;
2403 static const size_t _S_size =
2404 sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size
2405 ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size;
2408#pragma GCC diagnostic push
2409#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
2412 * @brief Provide aligned storage for types.
2414 * [meta.trans.other]
2416 * Provides aligned storage for any of the provided types of at
2419 * @see aligned_storage
2421 * @deprecated Deprecated in C++23.
2423 template <size_t _Len, typename... _Types>
2425 _GLIBCXX23_DEPRECATED
2429 static_assert(sizeof...(_Types) != 0, "At least one type is required");
2431 using __strictest = __strictest_alignment<_Types...>;
2432 static const size_t _S_len = _Len > __strictest::_S_size
2433 ? _Len : __strictest::_S_size;
2435 /// The value of the strictest alignment of _Types.
2436 static const size_t alignment_value = __strictest::_S_alignment;
2438 using type = typename aligned_storage<_S_len, alignment_value>::type;
2441 template <size_t _Len, typename... _Types>
2442 const size_t aligned_union<_Len, _Types...>::alignment_value;
2443#pragma GCC diagnostic pop
2445 /// @cond undocumented
2447#if _GLIBCXX_USE_BUILTIN_TRAIT(__decay)
2448 template<typename _Tp>
2450 { using type = __decay(_Tp); };
2452 // Decay trait for arrays and functions, used for perfect forwarding
2453 // in make_pair, make_tuple, etc.
2454 template<typename _Up>
2455 struct __decay_selector
2456 : __conditional_t<is_const<const _Up>::value, // false for functions
2457 remove_cv<_Up>, // N.B. DR 705.
2458 add_pointer<_Up>> // function decays to pointer
2461 template<typename _Up, size_t _Nm>
2462 struct __decay_selector<_Up[_Nm]>
2463 { using type = _Up*; };
2465 template<typename _Up>
2466 struct __decay_selector<_Up[]>
2467 { using type = _Up*; };
2472 template<typename _Tp>
2474 { using type = typename __decay_selector<_Tp>::type; };
2476 template<typename _Tp>
2478 { using type = typename __decay_selector<_Tp>::type; };
2480 template<typename _Tp>
2482 { using type = typename __decay_selector<_Tp>::type; };
2485 /// @cond undocumented
2487 // Helper which adds a reference to a type when given a reference_wrapper
2488 template<typename _Tp>
2489 struct __strip_reference_wrapper
2494 template<typename _Tp>
2495 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
2497 using __type = _Tp&;
2500 // __decay_t (std::decay_t for C++11).
2501 template<typename _Tp>
2502 using __decay_t = typename decay<_Tp>::type;
2504 template<typename _Tp>
2505 using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>;
2508 /// @cond undocumented
2510 // Helper for SFINAE constraints
2511 template<typename... _Cond>
2512 using _Require = __enable_if_t<__and_<_Cond...>::value>;
2514 // __remove_cvref_t (std::remove_cvref_t for C++11).
2515 template<typename _Tp>
2516 using __remove_cvref_t
2517 = typename remove_cv<typename remove_reference<_Tp>::type>::type;
2520 // Primary template.
2521 /// Define a member typedef @c type to one of two argument types.
2522 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2524 { using type = _Iftrue; };
2526 // Partial specialization for false.
2527 template<typename _Iftrue, typename _Iffalse>
2528 struct conditional<false, _Iftrue, _Iffalse>
2529 { using type = _Iffalse; };
2532 template<typename... _Tp>
2535 // Sfinae-friendly common_type implementation:
2537 /// @cond undocumented
2539 // For several sfinae-friendly trait implementations we transport both the
2540 // result information (as the member type) and the failure information (no
2541 // member type). This is very similar to std::enable_if, but we cannot use
2542 // that, because we need to derive from them as an implementation detail.
2544 template<typename _Tp>
2545 struct __success_type
2546 { using type = _Tp; };
2548 struct __failure_type
2551 struct __do_common_type_impl
2553 template<typename _Tp, typename _Up>
2555 = decltype(true ? std::declval<_Tp>() : std::declval<_Up>());
2557 // if decay_t<decltype(false ? declval<D1>() : declval<D2>())>
2558 // denotes a valid type, let C denote that type.
2559 template<typename _Tp, typename _Up>
2560 static __success_type<__decay_t<__cond_t<_Tp, _Up>>>
2563#if __cplusplus > 201703L
2564 // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type,
2565 // let C denote the type decay_t<COND-RES(CREF(D1), CREF(D2))>.
2566 template<typename _Tp, typename _Up>
2567 static __success_type<__remove_cvref_t<__cond_t<const _Tp&, const _Up&>>>
2571 template<typename, typename>
2572 static __failure_type
2575 template<typename _Tp, typename _Up>
2576 static decltype(_S_test_2<_Tp, _Up>(0))
2580 // If sizeof...(T) is zero, there shall be no member type.
2582 struct common_type<>
2585 // If sizeof...(T) is one, the same type, if any, as common_type_t<T0, T0>.
2586 template<typename _Tp0>
2587 struct common_type<_Tp0>
2588 : public common_type<_Tp0, _Tp0>
2591 // If sizeof...(T) is two, ...
2592 template<typename _Tp1, typename _Tp2,
2593 typename _Dp1 = __decay_t<_Tp1>, typename _Dp2 = __decay_t<_Tp2>>
2594 struct __common_type_impl
2596 // If is_same_v<T1, D1> is false or is_same_v<T2, D2> is false,
2597 // let C denote the same type, if any, as common_type_t<D1, D2>.
2598 using type = common_type<_Dp1, _Dp2>;
2601 template<typename _Tp1, typename _Tp2>
2602 struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2>
2603 : private __do_common_type_impl
2605 // Otherwise, if decay_t<decltype(false ? declval<D1>() : declval<D2>())>
2606 // denotes a valid type, let C denote that type.
2607 using type = decltype(_S_test<_Tp1, _Tp2>(0));
2610 // If sizeof...(T) is two, ...
2611 template<typename _Tp1, typename _Tp2>
2612 struct common_type<_Tp1, _Tp2>
2613 : public __common_type_impl<_Tp1, _Tp2>::type
2616 template<typename...>
2617 struct __common_type_pack
2620 template<typename, typename, typename = void>
2621 struct __common_type_fold;
2623 // If sizeof...(T) is greater than two, ...
2624 template<typename _Tp1, typename _Tp2, typename... _Rp>
2625 struct common_type<_Tp1, _Tp2, _Rp...>
2626 : public __common_type_fold<common_type<_Tp1, _Tp2>,
2627 __common_type_pack<_Rp...>>
2630 // Let C denote the same type, if any, as common_type_t<T1, T2>.
2631 // If there is such a type C, type shall denote the same type, if any,
2632 // as common_type_t<C, R...>.
2633 template<typename _CTp, typename... _Rp>
2634 struct __common_type_fold<_CTp, __common_type_pack<_Rp...>,
2635 __void_t<typename _CTp::type>>
2636 : public common_type<typename _CTp::type, _Rp...>
2639 // Otherwise, there shall be no member type.
2640 template<typename _CTp, typename _Rp>
2641 struct __common_type_fold<_CTp, _Rp, void>
2644 template<typename _Tp, bool = __is_enum(_Tp)>
2645 struct __underlying_type_impl
2647 using type = __underlying_type(_Tp);
2650 template<typename _Tp>
2651 struct __underlying_type_impl<_Tp, false>
2655 /// The underlying type of an enum.
2656 template<typename _Tp>
2657 struct underlying_type
2658 : public __underlying_type_impl<_Tp>
2661 /// @cond undocumented
2662 template<typename _Tp>
2663 struct __declval_protector
2665 static const bool __stop = false;
2669 /** Utility to simplify expressions used in unevaluated operands
2671 * @ingroup utilities
2673 template<typename _Tp>
2674 auto declval() noexcept -> decltype(__declval<_Tp>(0))
2676 static_assert(__declval_protector<_Tp>::__stop,
2677 "declval() must not be used!");
2678 return __declval<_Tp>(0);
2682 template<typename _Signature>
2685 // Sfinae-friendly result_of implementation:
2687 /// @cond undocumented
2688 struct __invoke_memfun_ref { };
2689 struct __invoke_memfun_deref { };
2690 struct __invoke_memobj_ref { };
2691 struct __invoke_memobj_deref { };
2692 struct __invoke_other { };
2694 // Associate a tag type with a specialization of __success_type.
2695 template<typename _Tp, typename _Tag>
2696 struct __result_of_success : __success_type<_Tp>
2697 { using __invoke_type = _Tag; };
2699 // [func.require] paragraph 1 bullet 1:
2700 struct __result_of_memfun_ref_impl
2702 template<typename _Fp, typename _Tp1, typename... _Args>
2703 static __result_of_success<decltype(
2704 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
2705 ), __invoke_memfun_ref> _S_test(int);
2707 template<typename...>
2708 static __failure_type _S_test(...);
2711 template<typename _MemPtr, typename _Arg, typename... _Args>
2712 struct __result_of_memfun_ref
2713 : private __result_of_memfun_ref_impl
2715 using type = decltype(_S_test<_MemPtr, _Arg, _Args...>(0));
2718 // [func.require] paragraph 1 bullet 2:
2719 struct __result_of_memfun_deref_impl
2721 template<typename _Fp, typename _Tp1, typename... _Args>
2722 static __result_of_success<decltype(
2723 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
2724 ), __invoke_memfun_deref> _S_test(int);
2726 template<typename...>
2727 static __failure_type _S_test(...);
2730 template<typename _MemPtr, typename _Arg, typename... _Args>
2731 struct __result_of_memfun_deref
2732 : private __result_of_memfun_deref_impl
2734 using type = decltype(_S_test<_MemPtr, _Arg, _Args...>(0));
2737 // [func.require] paragraph 1 bullet 3:
2738 struct __result_of_memobj_ref_impl
2740 template<typename _Fp, typename _Tp1>
2741 static __result_of_success<decltype(
2742 std::declval<_Tp1>().*std::declval<_Fp>()
2743 ), __invoke_memobj_ref> _S_test(int);
2745 template<typename, typename>
2746 static __failure_type _S_test(...);
2749 template<typename _MemPtr, typename _Arg>
2750 struct __result_of_memobj_ref
2751 : private __result_of_memobj_ref_impl
2753 using type = decltype(_S_test<_MemPtr, _Arg>(0));
2756 // [func.require] paragraph 1 bullet 4:
2757 struct __result_of_memobj_deref_impl
2759 template<typename _Fp, typename _Tp1>
2760 static __result_of_success<decltype(
2761 (*std::declval<_Tp1>()).*std::declval<_Fp>()
2762 ), __invoke_memobj_deref> _S_test(int);
2764 template<typename, typename>
2765 static __failure_type _S_test(...);
2768 template<typename _MemPtr, typename _Arg>
2769 struct __result_of_memobj_deref
2770 : private __result_of_memobj_deref_impl
2772 using type = decltype(_S_test<_MemPtr, _Arg>(0));
2775 template<typename _MemPtr, typename _Arg>
2776 struct __result_of_memobj;
2778 template<typename _Res, typename _Class, typename _Arg>
2779 struct __result_of_memobj<_Res _Class::*, _Arg>
2781 using _Argval = __remove_cvref_t<_Arg>;
2782 using _MemPtr = _Res _Class::*;
2783 using type = typename __conditional_t<__or_<is_same<_Argval, _Class>,
2784 is_base_of<_Class, _Argval>>::value,
2785 __result_of_memobj_ref<_MemPtr, _Arg>,
2786 __result_of_memobj_deref<_MemPtr, _Arg>
2790 template<typename _MemPtr, typename _Arg, typename... _Args>
2791 struct __result_of_memfun;
2793 template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2794 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
2796 using _Argval = typename remove_reference<_Arg>::type;
2797 using _MemPtr = _Res _Class::*;
2798 using type = typename __conditional_t<is_base_of<_Class, _Argval>::value,
2799 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
2800 __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
2804 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2805 // 2219. INVOKE-ing a pointer to member with a reference_wrapper
2806 // as the object expression
2808 // Used by result_of, invoke etc. to unwrap a reference_wrapper.
2809 template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>>
2815 template<typename _Tp, typename _Up>
2816 struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2821 template<bool, bool, typename _Functor, typename... _ArgTypes>
2822 struct __result_of_impl
2824 using type = __failure_type;
2827 template<typename _MemPtr, typename _Arg>
2828 struct __result_of_impl<true, false, _MemPtr, _Arg>
2829 : public __result_of_memobj<__decay_t<_MemPtr>,
2830 typename __inv_unwrap<_Arg>::type>
2833 template<typename _MemPtr, typename _Arg, typename... _Args>
2834 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2835 : public __result_of_memfun<__decay_t<_MemPtr>,
2836 typename __inv_unwrap<_Arg>::type, _Args...>
2839 // [func.require] paragraph 1 bullet 5:
2840 struct __result_of_other_impl
2842 template<typename _Fn, typename... _Args>
2843 static __result_of_success<decltype(
2844 std::declval<_Fn>()(std::declval<_Args>()...)
2845 ), __invoke_other> _S_test(int);
2847 template<typename...>
2848 static __failure_type _S_test(...);
2851 template<typename _Functor, typename... _ArgTypes>
2852 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2853 : private __result_of_other_impl
2855 using type = decltype(_S_test<_Functor, _ArgTypes...>(0));
2858 // __invoke_result (std::invoke_result for C++11)
2859 template<typename _Functor, typename... _ArgTypes>
2860 struct __invoke_result
2861 : public __result_of_impl<
2862 is_member_object_pointer<
2863 typename remove_reference<_Functor>::type
2865 is_member_function_pointer<
2866 typename remove_reference<_Functor>::type
2868 _Functor, _ArgTypes...
2872 // __invoke_result_t (std::invoke_result_t for C++11)
2873 template<typename _Fn, typename... _Args>
2874 using __invoke_result_t = typename __invoke_result<_Fn, _Args...>::type;
2877 template<typename _Functor, typename... _ArgTypes>
2878 struct result_of<_Functor(_ArgTypes...)>
2879 : public __invoke_result<_Functor, _ArgTypes...>
2880 { } _GLIBCXX17_DEPRECATED_SUGGEST("std::invoke_result");
2882#if __cplusplus >= 201402L
2883#pragma GCC diagnostic push
2884#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
2885 /// Alias template for aligned_storage
2886 template<size_t _Len,
2887 size_t _Align = __aligned_storage_default_alignment(_Len)>
2888 using aligned_storage_t _GLIBCXX23_DEPRECATED = typename aligned_storage<_Len, _Align>::type;
2890 template <size_t _Len, typename... _Types>
2891 using aligned_union_t _GLIBCXX23_DEPRECATED = typename aligned_union<_Len, _Types...>::type;
2892#pragma GCC diagnostic pop
2894 /// Alias template for decay
2895 template<typename _Tp>
2896 using decay_t = typename decay<_Tp>::type;
2898 /// Alias template for enable_if
2899 template<bool _Cond, typename _Tp = void>
2900 using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2902 /// Alias template for conditional
2903 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2904 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2906 /// Alias template for common_type
2907 template<typename... _Tp>
2908 using common_type_t = typename common_type<_Tp...>::type;
2910 /// Alias template for underlying_type
2911 template<typename _Tp>
2912 using underlying_type_t = typename underlying_type<_Tp>::type;
2914 /// Alias template for result_of
2915 template<typename _Tp>
2916 using result_of_t = typename result_of<_Tp>::type;
2919#ifdef __cpp_lib_void_t // C++ >= 17 || GNU++ >= 11
2920 /// A metafunction that always yields void, used for detecting valid types.
2921 template<typename...> using void_t = void;
2924 /// @cond undocumented
2927 // Detect whether _Op<_Args...> is a valid type, use default _Def if not.
2930 // Implementation of the detection idiom (negative case).
2931 template<typename _Def, template<typename...> class _Op, typename... _Args>
2932 struct __detected_or
2935 using __is_detected = false_type;
2938 // Implementation of the detection idiom (positive case).
2939 template<typename _Def, template<typename...> class _Op, typename... _Args>
2940 requires requires { typename _Op<_Args...>; }
2941 struct __detected_or<_Def, _Op, _Args...>
2943 using type = _Op<_Args...>;
2944 using __is_detected = true_type;
2947 /// Implementation of the detection idiom (negative case).
2948 template<typename _Default, typename _AlwaysVoid,
2949 template<typename...> class _Op, typename... _Args>
2952 using type = _Default;
2953 using __is_detected = false_type;
2956 /// Implementation of the detection idiom (positive case).
2957 template<typename _Default, template<typename...> class _Op,
2959 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2961 using type = _Op<_Args...>;
2962 using __is_detected = true_type;
2965 template<typename _Default, template<typename...> class _Op,
2967 using __detected_or = __detector<_Default, void, _Op, _Args...>;
2968#endif // __cpp_concepts
2970 // _Op<_Args...> if that is a valid type, otherwise _Default.
2971 template<typename _Default, template<typename...> class _Op,
2973 using __detected_or_t
2974 = typename __detected_or<_Default, _Op, _Args...>::type;
2977 * Use SFINAE to determine if the type _Tp has a publicly-accessible
2978 * member type _NTYPE.
2980#define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2981 template<typename _Tp, typename = __void_t<>> \
2982 struct __has_##_NTYPE \
2985 template<typename _Tp> \
2986 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2990 template <typename _Tp>
2991 struct __is_swappable;
2993 template <typename _Tp>
2994 struct __is_nothrow_swappable;
2997 struct __is_tuple_like_impl : false_type
3000 // Internal type trait that allows us to sfinae-protect tuple_cat.
3001 template<typename _Tp>
3002 struct __is_tuple_like
3003 : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type
3007 template<typename _Tp>
3008 _GLIBCXX20_CONSTEXPR
3010 _Require<__not_<__is_tuple_like<_Tp>>,
3011 is_move_constructible<_Tp>,
3012 is_move_assignable<_Tp>>
3014 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
3015 is_nothrow_move_assignable<_Tp>>::value);
3017 template<typename _Tp, size_t _Nm>
3018 _GLIBCXX20_CONSTEXPR
3020 __enable_if_t<__is_swappable<_Tp>::value>
3021 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
3022 noexcept(__is_nothrow_swappable<_Tp>::value);
3024 /// @cond undocumented
3025 namespace __swappable_details {
3028 struct __do_is_swappable_impl
3030 template<typename _Tp, typename
3031 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
3032 static true_type __test(int);
3035 static false_type __test(...);
3038 struct __do_is_nothrow_swappable_impl
3040 template<typename _Tp>
3041 static __bool_constant<
3042 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
3046 static false_type __test(...);
3049 } // namespace __swappable_details
3051 template<typename _Tp>
3052 struct __is_swappable_impl
3053 : public __swappable_details::__do_is_swappable_impl
3055 using type = decltype(__test<_Tp>(0));
3058 template<typename _Tp>
3059 struct __is_nothrow_swappable_impl
3060 : public __swappable_details::__do_is_nothrow_swappable_impl
3062 using type = decltype(__test<_Tp>(0));
3065 template<typename _Tp>
3066 struct __is_swappable
3067 : public __is_swappable_impl<_Tp>::type
3070 template<typename _Tp>
3071 struct __is_nothrow_swappable
3072 : public __is_nothrow_swappable_impl<_Tp>::type
3076#ifdef __cpp_lib_is_swappable // C++ >= 17 || GNU++ >= 11
3077 /// Metafunctions used for detecting swappable types: p0185r1
3080 template<typename _Tp>
3082 : public __is_swappable_impl<_Tp>::type
3084 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
3085 "template argument must be a complete class or an unbounded array");
3088 /// is_nothrow_swappable
3089 template<typename _Tp>
3090 struct is_nothrow_swappable
3091 : public __is_nothrow_swappable_impl<_Tp>::type
3093 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
3094 "template argument must be a complete class or an unbounded array");
3097#if __cplusplus >= 201402L
3099 template<typename _Tp>
3100 _GLIBCXX17_INLINE constexpr bool is_swappable_v =
3101 is_swappable<_Tp>::value;
3103 /// is_nothrow_swappable_v
3104 template<typename _Tp>
3105 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v =
3106 is_nothrow_swappable<_Tp>::value;
3107#endif // __cplusplus >= 201402L
3109 /// @cond undocumented
3110 namespace __swappable_with_details {
3113 struct __do_is_swappable_with_impl
3115 template<typename _Tp, typename _Up, typename
3116 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
3118 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
3119 static true_type __test(int);
3121 template<typename, typename>
3122 static false_type __test(...);
3125 struct __do_is_nothrow_swappable_with_impl
3127 template<typename _Tp, typename _Up>
3128 static __bool_constant<
3129 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
3131 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
3134 template<typename, typename>
3135 static false_type __test(...);
3138 } // namespace __swappable_with_details
3140 template<typename _Tp, typename _Up>
3141 struct __is_swappable_with_impl
3142 : public __swappable_with_details::__do_is_swappable_with_impl
3144 using type = decltype(__test<_Tp, _Up>(0));
3147 // Optimization for the homogenous lvalue case, not required:
3148 template<typename _Tp>
3149 struct __is_swappable_with_impl<_Tp&, _Tp&>
3150 : public __swappable_details::__do_is_swappable_impl
3152 using type = decltype(__test<_Tp&>(0));
3155 template<typename _Tp, typename _Up>
3156 struct __is_nothrow_swappable_with_impl
3157 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
3159 using type = decltype(__test<_Tp, _Up>(0));
3162 // Optimization for the homogenous lvalue case, not required:
3163 template<typename _Tp>
3164 struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&>
3165 : public __swappable_details::__do_is_nothrow_swappable_impl
3167 using type = decltype(__test<_Tp&>(0));
3171 /// is_swappable_with
3172 template<typename _Tp, typename _Up>
3173 struct is_swappable_with
3174 : public __is_swappable_with_impl<_Tp, _Up>::type
3176 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
3177 "first template argument must be a complete class or an unbounded array");
3178 static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}),
3179 "second template argument must be a complete class or an unbounded array");
3182 /// is_nothrow_swappable_with
3183 template<typename _Tp, typename _Up>
3184 struct is_nothrow_swappable_with
3185 : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type
3187 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
3188 "first template argument must be a complete class or an unbounded array");
3189 static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}),
3190 "second template argument must be a complete class or an unbounded array");
3193#if __cplusplus >= 201402L
3194 /// is_swappable_with_v
3195 template<typename _Tp, typename _Up>
3196 _GLIBCXX17_INLINE constexpr bool is_swappable_with_v =
3197 is_swappable_with<_Tp, _Up>::value;
3199 /// is_nothrow_swappable_with_v
3200 template<typename _Tp, typename _Up>
3201 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v =
3202 is_nothrow_swappable_with<_Tp, _Up>::value;
3203#endif // __cplusplus >= 201402L
3205#endif // __cpp_lib_is_swappable
3207 /// @cond undocumented
3209 // __is_invocable (std::is_invocable for C++11)
3211 // The primary template is used for invalid INVOKE expressions.
3212 template<typename _Result, typename _Ret,
3213 bool = is_void<_Ret>::value, typename = void>
3214 struct __is_invocable_impl
3217 using __nothrow_conv = false_type; // For is_nothrow_invocable_r
3220 // Used for valid INVOKE and INVOKE<void> expressions.
3221 template<typename _Result, typename _Ret>
3222 struct __is_invocable_impl<_Result, _Ret,
3223 /* is_void<_Ret> = */ true,
3224 __void_t<typename _Result::type>>
3227 using __nothrow_conv = true_type; // For is_nothrow_invocable_r
3230#pragma GCC diagnostic push
3231#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
3232 // Used for INVOKE<R> expressions to check the implicit conversion to R.
3233 template<typename _Result, typename _Ret>
3234 struct __is_invocable_impl<_Result, _Ret,
3235 /* is_void<_Ret> = */ false,
3236 __void_t<typename _Result::type>>
3239 // The type of the INVOKE expression.
3240 using _Res_t = typename _Result::type;
3242 // Unlike declval, this doesn't add_rvalue_reference, so it respects
3243 // guaranteed copy elision.
3244 static _Res_t _S_get() noexcept;
3246 // Used to check if _Res_t can implicitly convert to _Tp.
3247 template<typename _Tp>
3248 static void _S_conv(__type_identity_t<_Tp>) noexcept;
3250 // This overload is viable if INVOKE(f, args...) can convert to _Tp.
3251 template<typename _Tp,
3252 bool _Nothrow = noexcept(_S_conv<_Tp>(_S_get())),
3253 typename = decltype(_S_conv<_Tp>(_S_get())),
3254#if __has_builtin(__reference_converts_from_temporary)
3255 bool _Dangle = __reference_converts_from_temporary(_Tp, _Res_t)
3257 bool _Dangle = false
3260 static __bool_constant<_Nothrow && !_Dangle>
3263 template<typename _Tp, bool = false>
3268 // For is_invocable_r
3269 using type = decltype(_S_test<_Ret, /* Nothrow = */ true>(1));
3271 // For is_nothrow_invocable_r
3272 using __nothrow_conv = decltype(_S_test<_Ret>(1));
3274#pragma GCC diagnostic pop
3276 template<typename _Fn, typename... _ArgTypes>
3277 struct __is_invocable
3278#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable)
3279 : __bool_constant<__is_invocable(_Fn, _ArgTypes...)>
3281 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
3285 template<typename _Fn, typename _Tp, typename... _Args>
3286 constexpr bool __call_is_nt(__invoke_memfun_ref)
3288 using _Up = typename __inv_unwrap<_Tp>::type;
3289 return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
3290 std::declval<_Args>()...));
3293 template<typename _Fn, typename _Tp, typename... _Args>
3294 constexpr bool __call_is_nt(__invoke_memfun_deref)
3296 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
3297 std::declval<_Args>()...));
3300 template<typename _Fn, typename _Tp>
3301 constexpr bool __call_is_nt(__invoke_memobj_ref)
3303 using _Up = typename __inv_unwrap<_Tp>::type;
3304 return noexcept(std::declval<_Up>().*std::declval<_Fn>());
3307 template<typename _Fn, typename _Tp>
3308 constexpr bool __call_is_nt(__invoke_memobj_deref)
3310 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
3313 template<typename _Fn, typename... _Args>
3314 constexpr bool __call_is_nt(__invoke_other)
3316 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
3319 template<typename _Result, typename _Fn, typename... _Args>
3320 struct __call_is_nothrow
3322 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{})
3326 template<typename _Fn, typename... _Args>
3327 using __call_is_nothrow_
3328 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>;
3330 // __is_nothrow_invocable (std::is_nothrow_invocable for C++11)
3331 template<typename _Fn, typename... _Args>
3332 struct __is_nothrow_invocable
3333#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable)
3334 : __bool_constant<__is_nothrow_invocable(_Fn, _Args...)>
3336 : __and_<__is_invocable<_Fn, _Args...>,
3337 __call_is_nothrow_<_Fn, _Args...>>::type
3341#pragma GCC diagnostic push
3342#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
3343 struct __nonesuchbase {};
3344 struct __nonesuch : private __nonesuchbase {
3345 ~__nonesuch() = delete;
3346 __nonesuch(__nonesuch const&) = delete;
3347 void operator=(__nonesuch const&) = delete;
3349#pragma GCC diagnostic pop
3352#ifdef __cpp_lib_is_invocable // C++ >= 17
3353 /// std::invoke_result
3354 template<typename _Functor, typename... _ArgTypes>
3355 struct invoke_result
3356 : public __invoke_result<_Functor, _ArgTypes...>
3358 static_assert(std::__is_complete_or_unbounded(__type_identity<_Functor>{}),
3359 "_Functor must be a complete class or an unbounded array");
3360 static_assert((std::__is_complete_or_unbounded(
3361 __type_identity<_ArgTypes>{}) && ...),
3362 "each argument type must be a complete class or an unbounded array");
3365 /// std::invoke_result_t
3366 template<typename _Fn, typename... _Args>
3367 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
3369 /// std::is_invocable
3370 template<typename _Fn, typename... _ArgTypes>
3372#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable)
3373 : public __bool_constant<__is_invocable(_Fn, _ArgTypes...)>
3375 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
3378 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}),
3379 "_Fn must be a complete class or an unbounded array");
3380 static_assert((std::__is_complete_or_unbounded(
3381 __type_identity<_ArgTypes>{}) && ...),
3382 "each argument type must be a complete class or an unbounded array");
3385 /// std::is_invocable_r
3386 template<typename _Ret, typename _Fn, typename... _ArgTypes>
3387 struct is_invocable_r
3388 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type
3390 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}),
3391 "_Fn must be a complete class or an unbounded array");
3392 static_assert((std::__is_complete_or_unbounded(
3393 __type_identity<_ArgTypes>{}) && ...),
3394 "each argument type must be a complete class or an unbounded array");
3395 static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}),
3396 "_Ret must be a complete class or an unbounded array");
3399 /// std::is_nothrow_invocable
3400 template<typename _Fn, typename... _ArgTypes>
3401 struct is_nothrow_invocable
3402#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable)
3403 : public __bool_constant<__is_nothrow_invocable(_Fn, _ArgTypes...)>
3405 : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>,
3406 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
3409 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}),
3410 "_Fn must be a complete class or an unbounded array");
3411 static_assert((std::__is_complete_or_unbounded(
3412 __type_identity<_ArgTypes>{}) && ...),
3413 "each argument type must be a complete class or an unbounded array");
3416 /// @cond undocumented
3417 // This checks that the INVOKE<R> expression is well-formed and that the
3418 // conversion to R does not throw. It does *not* check whether the INVOKE
3419 // expression itself can throw. That is done by __call_is_nothrow_ instead.
3420 template<typename _Result, typename _Ret>
3421 using __is_nt_invocable_impl
3422 = typename __is_invocable_impl<_Result, _Ret>::__nothrow_conv;
3425 /// std::is_nothrow_invocable_r
3426 template<typename _Ret, typename _Fn, typename... _ArgTypes>
3427 struct is_nothrow_invocable_r
3428 : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>,
3429 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
3431 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}),
3432 "_Fn must be a complete class or an unbounded array");
3433 static_assert((std::__is_complete_or_unbounded(
3434 __type_identity<_ArgTypes>{}) && ...),
3435 "each argument type must be a complete class or an unbounded array");
3436 static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}),
3437 "_Ret must be a complete class or an unbounded array");
3439#endif // __cpp_lib_is_invocable
3441#if __cpp_lib_type_trait_variable_templates // C++ >= 17
3443 * @defgroup variable_templates Variable templates for type traits
3444 * @ingroup metaprogramming
3446 * Each variable `is_xxx_v<T>` is a boolean constant with the same value
3447 * as the `value` member of the corresponding type trait `is_xxx<T>`.
3449 * @since C++17 unless noted otherwise.
3454 * @ingroup variable_templates
3456template <typename _Tp>
3457 inline constexpr bool is_void_v = is_void<_Tp>::value;
3458template <typename _Tp>
3459 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
3460template <typename _Tp>
3461 inline constexpr bool is_integral_v = is_integral<_Tp>::value;
3462template <typename _Tp>
3463 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
3465#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_array)
3466template <typename _Tp>
3467 inline constexpr bool is_array_v = __is_array(_Tp);
3469template <typename _Tp>
3470 inline constexpr bool is_array_v = false;
3471template <typename _Tp>
3472 inline constexpr bool is_array_v<_Tp[]> = true;
3473template <typename _Tp, size_t _Num>
3474 inline constexpr bool is_array_v<_Tp[_Num]> = true;
3477#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
3478template <typename _Tp>
3479 inline constexpr bool is_pointer_v = __is_pointer(_Tp);
3481template <typename _Tp>
3482 inline constexpr bool is_pointer_v = false;
3483template <typename _Tp>
3484 inline constexpr bool is_pointer_v<_Tp*> = true;
3485template <typename _Tp>
3486 inline constexpr bool is_pointer_v<_Tp* const> = true;
3487template <typename _Tp>
3488 inline constexpr bool is_pointer_v<_Tp* volatile> = true;
3489template <typename _Tp>
3490 inline constexpr bool is_pointer_v<_Tp* const volatile> = true;
3493template <typename _Tp>
3494 inline constexpr bool is_lvalue_reference_v = false;
3495template <typename _Tp>
3496 inline constexpr bool is_lvalue_reference_v<_Tp&> = true;
3497template <typename _Tp>
3498 inline constexpr bool is_rvalue_reference_v = false;
3499template <typename _Tp>
3500 inline constexpr bool is_rvalue_reference_v<_Tp&&> = true;
3502#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_object_pointer)
3503template <typename _Tp>
3504 inline constexpr bool is_member_object_pointer_v =
3505 __is_member_object_pointer(_Tp);
3507template <typename _Tp>
3508 inline constexpr bool is_member_object_pointer_v =
3509 is_member_object_pointer<_Tp>::value;
3512#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_function_pointer)
3513template <typename _Tp>
3514 inline constexpr bool is_member_function_pointer_v =
3515 __is_member_function_pointer(_Tp);
3517template <typename _Tp>
3518 inline constexpr bool is_member_function_pointer_v =
3519 is_member_function_pointer<_Tp>::value;
3522template <typename _Tp>
3523 inline constexpr bool is_enum_v = __is_enum(_Tp);
3524template <typename _Tp>
3525 inline constexpr bool is_union_v = __is_union(_Tp);
3526template <typename _Tp>
3527 inline constexpr bool is_class_v = __is_class(_Tp);
3528// is_function_v is defined below, after is_const_v.
3530#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference)
3531template <typename _Tp>
3532 inline constexpr bool is_reference_v = __is_reference(_Tp);
3534template <typename _Tp>
3535 inline constexpr bool is_reference_v = false;
3536template <typename _Tp>
3537 inline constexpr bool is_reference_v<_Tp&> = true;
3538template <typename _Tp>
3539 inline constexpr bool is_reference_v<_Tp&&> = true;
3542template <typename _Tp>
3543 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
3544template <typename _Tp>
3545 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
3547#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object)
3548template <typename _Tp>
3549 inline constexpr bool is_object_v = __is_object(_Tp);
3551template <typename _Tp>
3552 inline constexpr bool is_object_v = is_object<_Tp>::value;
3555template <typename _Tp>
3556 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
3557template <typename _Tp>
3558 inline constexpr bool is_compound_v = !is_fundamental_v<_Tp>;
3560#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_pointer)
3561template <typename _Tp>
3562 inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
3564template <typename _Tp>
3565 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
3568#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const)
3569template <typename _Tp>
3570 inline constexpr bool is_const_v = __is_const(_Tp);
3572template <typename _Tp>
3573 inline constexpr bool is_const_v = false;
3574template <typename _Tp>
3575 inline constexpr bool is_const_v<const _Tp> = true;
3578#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function)
3579template <typename _Tp>
3580 inline constexpr bool is_function_v = __is_function(_Tp);
3582template <typename _Tp>
3583 inline constexpr bool is_function_v = !is_const_v<const _Tp>;
3584template <typename _Tp>
3585 inline constexpr bool is_function_v<_Tp&> = false;
3586template <typename _Tp>
3587 inline constexpr bool is_function_v<_Tp&&> = false;
3590#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile)
3591template <typename _Tp>
3592 inline constexpr bool is_volatile_v = __is_volatile(_Tp);
3594template <typename _Tp>
3595 inline constexpr bool is_volatile_v = false;
3596template <typename _Tp>
3597 inline constexpr bool is_volatile_v<volatile _Tp> = true;
3600template <typename _Tp>
3601 _GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible_v && is_trivially_copyable_v")
3602 inline constexpr bool is_trivial_v = __is_trivial(_Tp);
3603template <typename _Tp>
3604 inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);
3605template <typename _Tp>
3606 inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp);
3607template <typename _Tp>
3608 _GLIBCXX20_DEPRECATED_SUGGEST("is_standard_layout_v && is_trivial_v")
3609 inline constexpr bool is_pod_v = __is_pod(_Tp);
3610template <typename _Tp>
3611 _GLIBCXX17_DEPRECATED
3612 inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);
3613template <typename _Tp>
3614 inline constexpr bool is_empty_v = __is_empty(_Tp);
3615template <typename _Tp>
3616 inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp);
3617template <typename _Tp>
3618 inline constexpr bool is_abstract_v = __is_abstract(_Tp);
3619template <typename _Tp>
3620 inline constexpr bool is_final_v = __is_final(_Tp);
3622template <typename _Tp>
3623 inline constexpr bool is_signed_v = is_signed<_Tp>::value;
3624template <typename _Tp>
3625 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
3627template <typename _Tp, typename... _Args>
3628 inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);
3629template <typename _Tp>
3630 inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
3631template <typename _Tp>
3632 inline constexpr bool is_copy_constructible_v
3633 = __is_constructible(_Tp, __add_lval_ref_t<const _Tp>);
3634template <typename _Tp>
3635 inline constexpr bool is_move_constructible_v
3636 = __is_constructible(_Tp, __add_rval_ref_t<_Tp>);
3638template <typename _Tp, typename _Up>
3639 inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Up);
3640template <typename _Tp>
3641 inline constexpr bool is_copy_assignable_v
3642 = __is_assignable(__add_lval_ref_t<_Tp>, __add_lval_ref_t<const _Tp>);
3643template <typename _Tp>
3644 inline constexpr bool is_move_assignable_v
3645 = __is_assignable(__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>);
3647#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_destructible)
3648template <typename _Tp>
3649 inline constexpr bool is_destructible_v = __is_destructible(_Tp);
3651template <typename _Tp>
3652 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
3655template <typename _Tp, typename... _Args>
3656 inline constexpr bool is_trivially_constructible_v
3657 = __is_trivially_constructible(_Tp, _Args...);
3658template <typename _Tp>
3659 inline constexpr bool is_trivially_default_constructible_v
3660 = __is_trivially_constructible(_Tp);
3661template <typename _Tp>
3662 inline constexpr bool is_trivially_copy_constructible_v
3663 = __is_trivially_constructible(_Tp, __add_lval_ref_t<const _Tp>);
3664template <typename _Tp>
3665 inline constexpr bool is_trivially_move_constructible_v
3666 = __is_trivially_constructible(_Tp, __add_rval_ref_t<_Tp>);
3668template <typename _Tp, typename _Up>
3669 inline constexpr bool is_trivially_assignable_v
3670 = __is_trivially_assignable(_Tp, _Up);
3671template <typename _Tp>
3672 inline constexpr bool is_trivially_copy_assignable_v
3673 = __is_trivially_assignable(__add_lval_ref_t<_Tp>,
3674 __add_lval_ref_t<const _Tp>);
3675template <typename _Tp>
3676 inline constexpr bool is_trivially_move_assignable_v
3677 = __is_trivially_assignable(__add_lval_ref_t<_Tp>,
3678 __add_rval_ref_t<_Tp>);
3680#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_trivially_destructible)
3681template <typename _Tp>
3682 inline constexpr bool is_trivially_destructible_v
3683 = __is_trivially_destructible(_Tp);
3685template <typename _Tp>
3686 inline constexpr bool is_trivially_destructible_v = false;
3688template <typename _Tp>
3689 requires (!is_reference_v<_Tp>) && requires (_Tp& __t) { __t.~_Tp(); }
3690 inline constexpr bool is_trivially_destructible_v<_Tp>
3691 = __has_trivial_destructor(_Tp);
3692template <typename _Tp>
3693 inline constexpr bool is_trivially_destructible_v<_Tp&> = true;
3694template <typename _Tp>
3695 inline constexpr bool is_trivially_destructible_v<_Tp&&> = true;
3696template <typename _Tp, size_t _Nm>
3697 inline constexpr bool is_trivially_destructible_v<_Tp[_Nm]>
3698 = is_trivially_destructible_v<_Tp>;
3700template <typename _Tp>
3701 inline constexpr bool is_trivially_destructible_v =
3702 is_trivially_destructible<_Tp>::value;
3705template <typename _Tp, typename... _Args>
3706 inline constexpr bool is_nothrow_constructible_v
3707 = __is_nothrow_constructible(_Tp, _Args...);
3708template <typename _Tp>
3709 inline constexpr bool is_nothrow_default_constructible_v
3710 = __is_nothrow_constructible(_Tp);
3711template <typename _Tp>
3712 inline constexpr bool is_nothrow_copy_constructible_v
3713 = __is_nothrow_constructible(_Tp, __add_lval_ref_t<const _Tp>);
3714template <typename _Tp>
3715 inline constexpr bool is_nothrow_move_constructible_v
3716 = __is_nothrow_constructible(_Tp, __add_rval_ref_t<_Tp>);
3718template <typename _Tp, typename _Up>
3719 inline constexpr bool is_nothrow_assignable_v
3720 = __is_nothrow_assignable(_Tp, _Up);
3721template <typename _Tp>
3722 inline constexpr bool is_nothrow_copy_assignable_v
3723 = __is_nothrow_assignable(__add_lval_ref_t<_Tp>,
3724 __add_lval_ref_t<const _Tp>);
3725template <typename _Tp>
3726 inline constexpr bool is_nothrow_move_assignable_v
3727 = __is_nothrow_assignable(__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>);
3729#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_destructible)
3730template <typename _Tp>
3731 inline constexpr bool is_nothrow_destructible_v
3732 = __is_nothrow_destructible(_Tp);
3734template <typename _Tp>
3735 inline constexpr bool is_nothrow_destructible_v =
3736 is_nothrow_destructible<_Tp>::value;
3739template <typename _Tp>
3740 inline constexpr bool has_virtual_destructor_v
3741 = __has_virtual_destructor(_Tp);
3743template <typename _Tp>
3744 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
3746#if _GLIBCXX_USE_BUILTIN_TRAIT(__array_rank) \
3747 && (!defined(__clang__) || __clang_major__ >= 20) // PR118559
3748template <typename _Tp>
3749 inline constexpr size_t rank_v = __array_rank(_Tp);
3751template <typename _Tp>
3752 inline constexpr size_t rank_v = 0;
3753template <typename _Tp, size_t _Size>
3754 inline constexpr size_t rank_v<_Tp[_Size]> = 1 + rank_v<_Tp>;
3755template <typename _Tp>
3756 inline constexpr size_t rank_v<_Tp[]> = 1 + rank_v<_Tp>;
3759template <typename _Tp, unsigned _Idx = 0>
3760 inline constexpr size_t extent_v = 0;
3761template <typename _Tp, size_t _Size>
3762 inline constexpr size_t extent_v<_Tp[_Size], 0> = _Size;
3763template <typename _Tp, unsigned _Idx, size_t _Size>
3764 inline constexpr size_t extent_v<_Tp[_Size], _Idx> = extent_v<_Tp, _Idx - 1>;
3765template <typename _Tp>
3766 inline constexpr size_t extent_v<_Tp[], 0> = 0;
3767template <typename _Tp, unsigned _Idx>
3768 inline constexpr size_t extent_v<_Tp[], _Idx> = extent_v<_Tp, _Idx - 1>;
3770#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
3771template <typename _Tp, typename _Up>
3772 inline constexpr bool is_same_v = __is_same(_Tp, _Up);
3774template <typename _Tp, typename _Up>
3775 inline constexpr bool is_same_v = false;
3776template <typename _Tp>
3777 inline constexpr bool is_same_v<_Tp, _Tp> = true;
3779template <typename _Base, typename _Derived>
3780 inline constexpr bool is_base_of_v = __is_base_of(_Base, _Derived);
3781#ifdef __cpp_lib_is_virtual_base_of // C++ >= 26
3782template <typename _Base, typename _Derived>
3783 inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived);
3785#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible)
3786template <typename _From, typename _To>
3787 inline constexpr bool is_convertible_v = __is_convertible(_From, _To);
3789template <typename _From, typename _To>
3790 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
3792template<typename _Fn, typename... _Args>
3793 inline constexpr bool is_invocable_v
3794#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable)
3795 = __is_invocable(_Fn, _Args...);
3797 = is_invocable<_Fn, _Args...>::value;
3799template<typename _Fn, typename... _Args>
3800 inline constexpr bool is_nothrow_invocable_v
3801#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable)
3802 = __is_nothrow_invocable(_Fn, _Args...);
3804 = is_nothrow_invocable<_Fn, _Args...>::value;
3806template<typename _Ret, typename _Fn, typename... _Args>
3807 inline constexpr bool is_invocable_r_v
3808 = is_invocable_r<_Ret, _Fn, _Args...>::value;
3809template<typename _Ret, typename _Fn, typename... _Args>
3810 inline constexpr bool is_nothrow_invocable_r_v
3811 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
3813#endif // __cpp_lib_type_trait_variable_templates
3815#ifdef __cpp_lib_has_unique_object_representations // C++ >= 17 && HAS_UNIQ_OBJ_REP
3816 /// has_unique_object_representations
3818 template<typename _Tp>
3819 struct has_unique_object_representations
3820 : bool_constant<__has_unique_object_representations(
3821 remove_cv_t<remove_all_extents_t<_Tp>>
3824 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
3825 "template argument must be a complete class or an unbounded array");
3828# if __cpp_lib_type_trait_variable_templates // C++ >= 17
3829 /// @ingroup variable_templates
3830 template<typename _Tp>
3831 inline constexpr bool has_unique_object_representations_v
3832 = has_unique_object_representations<_Tp>::value;
3836#ifdef __cpp_lib_is_aggregate // C++ >= 17 && builtin_is_aggregate
3837 /// is_aggregate - true if the type is an aggregate.
3839 template<typename _Tp>
3841 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)>
3844# if __cpp_lib_type_trait_variable_templates // C++ >= 17
3845 /** is_aggregate_v - true if the type is an aggregate.
3846 * @ingroup variable_templates
3849 template<typename _Tp>
3850 inline constexpr bool is_aggregate_v = __is_aggregate(remove_cv_t<_Tp>);
3854 /** * Remove references and cv-qualifiers.
3858#ifdef __cpp_lib_remove_cvref // C++ >= 20
3859# if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cvref)
3860 template<typename _Tp>
3862 { using type = __remove_cvref(_Tp); };
3864 template<typename _Tp>
3866 { using type = typename remove_cv<_Tp>::type; };
3868 template<typename _Tp>
3869 struct remove_cvref<_Tp&>
3870 { using type = typename remove_cv<_Tp>::type; };
3872 template<typename _Tp>
3873 struct remove_cvref<_Tp&&>
3874 { using type = typename remove_cv<_Tp>::type; };
3877 template<typename _Tp>
3878 using remove_cvref_t = typename remove_cvref<_Tp>::type;
3880#endif // __cpp_lib_remove_cvref
3882#ifdef __cpp_lib_type_identity // C++ >= 20
3883 /** * Identity metafunction.
3887 template<typename _Tp>
3888 struct type_identity { using type = _Tp; };
3890 template<typename _Tp>
3891 using type_identity_t = typename type_identity<_Tp>::type;
3895#ifdef __cpp_lib_unwrap_ref // C++ >= 20
3896 /** Unwrap a reference_wrapper
3900 template<typename _Tp>
3901 struct unwrap_reference { using type = _Tp; };
3903 template<typename _Tp>
3904 struct unwrap_reference<reference_wrapper<_Tp>> { using type = _Tp&; };
3906 template<typename _Tp>
3907 using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
3910 /** Decay type and if it's a reference_wrapper, unwrap it
3914 template<typename _Tp>
3915 struct unwrap_ref_decay { using type = unwrap_reference_t<decay_t<_Tp>>; };
3917 template<typename _Tp>
3918 using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
3920#endif // __cpp_lib_unwrap_ref
3922#ifdef __cpp_lib_bounded_array_traits // C++ >= 20
3923 /// True for a type that is an array of known bound.
3924 /// @ingroup variable_templates
3926# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_bounded_array)
3927 template<typename _Tp>
3928 inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
3930 template<typename _Tp>
3931 inline constexpr bool is_bounded_array_v = false;
3933 template<typename _Tp, size_t _Size>
3934 inline constexpr bool is_bounded_array_v<_Tp[_Size]> = true;
3937 /// True for a type that is an array of unknown bound.
3938 /// @ingroup variable_templates
3940# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_unbounded_array)
3941 template<typename _Tp>
3942 inline constexpr bool is_unbounded_array_v = __is_unbounded_array(_Tp);
3944 template<typename _Tp>
3945 inline constexpr bool is_unbounded_array_v = false;
3947 template<typename _Tp>
3948 inline constexpr bool is_unbounded_array_v<_Tp[]> = true;
3951 /// True for a type that is an array of known bound.
3953 template<typename _Tp>
3954 struct is_bounded_array
3955 : public bool_constant<is_bounded_array_v<_Tp>>
3958 /// True for a type that is an array of unknown bound.
3960 template<typename _Tp>
3961 struct is_unbounded_array
3962 : public bool_constant<is_unbounded_array_v<_Tp>>
3964#endif // __cpp_lib_bounded_array_traits
3966#if __has_builtin(__is_layout_compatible) && __cplusplus >= 202002L
3969 template<typename _Tp, typename _Up>
3970 struct is_layout_compatible
3971 : bool_constant<__is_layout_compatible(_Tp, _Up)>
3974 /// @ingroup variable_templates
3976 template<typename _Tp, typename _Up>
3977 constexpr bool is_layout_compatible_v
3978 = __is_layout_compatible(_Tp, _Up);
3980#if __has_builtin(__builtin_is_corresponding_member)
3981# ifndef __cpp_lib_is_layout_compatible
3982# error "libstdc++ bug: is_corresponding_member and is_layout_compatible are provided but their FTM is not set"
3986 template<typename _S1, typename _S2, typename _M1, typename _M2>
3988 is_corresponding_member(_M1 _S1::*__m1, _M2 _S2::*__m2) noexcept
3989 { return __builtin_is_corresponding_member(__m1, __m2); }
3993#if __has_builtin(__is_pointer_interconvertible_base_of) \
3994 && __cplusplus >= 202002L
3995 /// True if `_Derived` is standard-layout and has a base class of type `_Base`
3997 template<typename _Base, typename _Derived>
3998 struct is_pointer_interconvertible_base_of
3999 : bool_constant<__is_pointer_interconvertible_base_of(_Base, _Derived)>
4002 /// @ingroup variable_templates
4004 template<typename _Base, typename _Derived>
4005 constexpr bool is_pointer_interconvertible_base_of_v
4006 = __is_pointer_interconvertible_base_of(_Base, _Derived);
4008#if __has_builtin(__builtin_is_pointer_interconvertible_with_class)
4009# ifndef __cpp_lib_is_pointer_interconvertible
4010# error "libstdc++ bug: is_pointer_interconvertible available but FTM is not set"
4013 /// True if `__mp` points to the first member of a standard-layout type
4014 /// @returns true if `s.*__mp` is pointer-interconvertible with `s`
4016 template<typename _Tp, typename _Mem>
4018 is_pointer_interconvertible_with_class(_Mem _Tp::*__mp) noexcept
4019 { return __builtin_is_pointer_interconvertible_with_class(__mp); }
4023#ifdef __cpp_lib_is_scoped_enum // C++ >= 23
4024 /// True if the type is a scoped enumeration type.
4027# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum)
4028 template<typename _Tp>
4029 struct is_scoped_enum
4030 : bool_constant<__is_scoped_enum(_Tp)>
4033 template<typename _Tp>
4034 struct is_scoped_enum
4038 template<typename _Tp>
4039 requires __is_enum(_Tp)
4040 && requires(remove_cv_t<_Tp> __t) { __t = __t; } // fails if incomplete
4041 struct is_scoped_enum<_Tp>
4042 : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }>
4046 /// @ingroup variable_templates
4048# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum)
4049 template<typename _Tp>
4050 inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);
4052 template<typename _Tp>
4053 inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
4057#ifdef __cpp_lib_is_implicit_lifetime // C++ >= 23
4058 /// True if the type is an implicit-lifetime type.
4061 template<typename _Tp>
4062 struct is_implicit_lifetime
4063 : bool_constant<__builtin_is_implicit_lifetime(_Tp)>
4066 /// @ingroup variable_templates
4068 template<typename _Tp>
4069 inline constexpr bool is_implicit_lifetime_v
4070 = __builtin_is_implicit_lifetime(_Tp);
4073#ifdef __cpp_lib_reference_from_temporary // C++ >= 23 && ref_{converts,constructs}_from_temp
4074 /// True if _Tp is a reference type, a _Up value can be bound to _Tp in
4075 /// direct-initialization, and a temporary object would be bound to
4076 /// the reference, false otherwise.
4078 template<typename _Tp, typename _Up>
4079 struct reference_constructs_from_temporary
4080 : public bool_constant<__reference_constructs_from_temporary(_Tp, _Up)>
4082 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{})
4083 && std::__is_complete_or_unbounded(__type_identity<_Up>{}),
4084 "template argument must be a complete class or an unbounded array");
4087 /// True if _Tp is a reference type, a _Up value can be bound to _Tp in
4088 /// copy-initialization, and a temporary object would be bound to
4089 /// the reference, false otherwise.
4091 template<typename _Tp, typename _Up>
4092 struct reference_converts_from_temporary
4093 : public bool_constant<__reference_converts_from_temporary(_Tp, _Up)>
4095 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{})
4096 && std::__is_complete_or_unbounded(__type_identity<_Up>{}),
4097 "template argument must be a complete class or an unbounded array");
4100 /// @ingroup variable_templates
4102 template<typename _Tp, typename _Up>
4103 inline constexpr bool reference_constructs_from_temporary_v
4104 = reference_constructs_from_temporary<_Tp, _Up>::value;
4106 /// @ingroup variable_templates
4108 template<typename _Tp, typename _Up>
4109 inline constexpr bool reference_converts_from_temporary_v
4110 = reference_converts_from_temporary<_Tp, _Up>::value;
4111#endif // __cpp_lib_reference_from_temporary
4113#ifdef __cpp_lib_is_constant_evaluated // C++ >= 20 && HAVE_IS_CONST_EVAL
4114 /// Returns true only when called during constant evaluation.
4116 [[__gnu__::__always_inline__]]
4118 is_constant_evaluated() noexcept
4120#if __cpp_if_consteval >= 202106L
4121 if consteval { return true; } else { return false; }
4123 return __builtin_is_constant_evaluated();
4128#if __cplusplus >= 202002L
4129 /// @cond undocumented
4130 template<typename _From, typename _To>
4131 using __copy_cv = typename __match_cv_qualifiers<_From, _To>::__type;
4133 template<typename _Xp, typename _Yp>
4135 = decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
4137 template<typename _Ap, typename _Bp, typename = void>
4138 struct __common_ref_impl
4141 // [meta.trans.other], COMMON-REF(A, B)
4142 template<typename _Ap, typename _Bp>
4143 using __common_ref = typename __common_ref_impl<_Ap, _Bp>::type;
4145 // COND-RES(COPYCV(X, Y) &, COPYCV(Y, X) &)
4146 template<typename _Xp, typename _Yp>
4147 using __condres_cvref
4148 = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>;
4150 // If A and B are both lvalue reference types, ...
4151 template<typename _Xp, typename _Yp>
4152 struct __common_ref_impl<_Xp&, _Yp&, __void_t<__condres_cvref<_Xp, _Yp>>>
4153 : enable_if<is_reference_v<__condres_cvref<_Xp, _Yp>>,
4154 __condres_cvref<_Xp, _Yp>>
4157 // let C be remove_reference_t<COMMON-REF(X&, Y&)>&&
4158 template<typename _Xp, typename _Yp>
4159 using __common_ref_C = remove_reference_t<__common_ref<_Xp&, _Yp&>>&&;
4161 // If A and B are both rvalue reference types, ...
4162 template<typename _Xp, typename _Yp>
4163 struct __common_ref_impl<_Xp&&, _Yp&&,
4164 _Require<is_convertible<_Xp&&, __common_ref_C<_Xp, _Yp>>,
4165 is_convertible<_Yp&&, __common_ref_C<_Xp, _Yp>>>>
4166 { using type = __common_ref_C<_Xp, _Yp>; };
4168 // let D be COMMON-REF(const X&, Y&)
4169 template<typename _Xp, typename _Yp>
4170 using __common_ref_D = __common_ref<const _Xp&, _Yp&>;
4172 // If A is an rvalue reference and B is an lvalue reference, ...
4173 template<typename _Xp, typename _Yp>
4174 struct __common_ref_impl<_Xp&&, _Yp&,
4175 _Require<is_convertible<_Xp&&, __common_ref_D<_Xp, _Yp>>>>
4176 { using type = __common_ref_D<_Xp, _Yp>; };
4178 // If A is an lvalue reference and B is an rvalue reference, ...
4179 template<typename _Xp, typename _Yp>
4180 struct __common_ref_impl<_Xp&, _Yp&&>
4181 : __common_ref_impl<_Yp&&, _Xp&>
4185 template<typename _Tp, typename _Up,
4186 template<typename> class _TQual, template<typename> class _UQual>
4187 struct basic_common_reference
4190 /// @cond undocumented
4191 template<typename _Tp>
4193 { template<typename _Up> using __type = __copy_cv<_Tp, _Up>; };
4195 template<typename _Tp>
4197 { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&; };
4199 template<typename _Tp>
4200 struct __xref<_Tp&&>
4201 { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&&; };
4203 template<typename _Tp1, typename _Tp2>
4204 using __basic_common_ref
4205 = typename basic_common_reference<remove_cvref_t<_Tp1>,
4206 remove_cvref_t<_Tp2>,
4207 __xref<_Tp1>::template __type,
4208 __xref<_Tp2>::template __type>::type;
4211 template<typename... _Tp>
4212 struct common_reference;
4214 template<typename... _Tp>
4215 using common_reference_t = typename common_reference<_Tp...>::type;
4217 // If sizeof...(T) is zero, there shall be no member type.
4219 struct common_reference<>
4222 // If sizeof...(T) is one ...
4223 template<typename _Tp0>
4224 struct common_reference<_Tp0>
4225 { using type = _Tp0; };
4227 /// @cond undocumented
4228 template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void>
4229 struct __common_reference_impl
4230 : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1>
4233 // If sizeof...(T) is two ...
4234 template<typename _Tp1, typename _Tp2>
4235 struct common_reference<_Tp1, _Tp2>
4236 : __common_reference_impl<_Tp1, _Tp2>
4239 // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ...
4240 template<typename _Tp1, typename _Tp2>
4241 struct __common_reference_impl<_Tp1&, _Tp2&, 1,
4242 void_t<__common_ref<_Tp1&, _Tp2&>>>
4243 { using type = __common_ref<_Tp1&, _Tp2&>; };
4245 template<typename _Tp1, typename _Tp2>
4246 struct __common_reference_impl<_Tp1&&, _Tp2&&, 1,
4247 void_t<__common_ref<_Tp1&&, _Tp2&&>>>
4248 { using type = __common_ref<_Tp1&&, _Tp2&&>; };
4250 template<typename _Tp1, typename _Tp2>
4251 struct __common_reference_impl<_Tp1&, _Tp2&&, 1,
4252 void_t<__common_ref<_Tp1&, _Tp2&&>>>
4253 { using type = __common_ref<_Tp1&, _Tp2&&>; };
4255 template<typename _Tp1, typename _Tp2>
4256 struct __common_reference_impl<_Tp1&&, _Tp2&, 1,
4257 void_t<__common_ref<_Tp1&&, _Tp2&>>>
4258 { using type = __common_ref<_Tp1&&, _Tp2&>; };
4260 // Otherwise, if basic_common_reference<...>::type is well-formed, ...
4261 template<typename _Tp1, typename _Tp2>
4262 struct __common_reference_impl<_Tp1, _Tp2, 2,
4263 void_t<__basic_common_ref<_Tp1, _Tp2>>>
4264 { using type = __basic_common_ref<_Tp1, _Tp2>; };
4266 // Otherwise, if COND-RES(T1, T2) is well-formed, ...
4267 template<typename _Tp1, typename _Tp2>
4268 struct __common_reference_impl<_Tp1, _Tp2, 3,
4269 void_t<__cond_res<_Tp1, _Tp2>>>
4270 { using type = __cond_res<_Tp1, _Tp2>; };
4272 // Otherwise, if common_type_t<T1, T2> is well-formed, ...
4273 template<typename _Tp1, typename _Tp2>
4274 struct __common_reference_impl<_Tp1, _Tp2, 4,
4275 void_t<common_type_t<_Tp1, _Tp2>>>
4276 { using type = common_type_t<_Tp1, _Tp2>; };
4278 // Otherwise, there shall be no member type.
4279 template<typename _Tp1, typename _Tp2>
4280 struct __common_reference_impl<_Tp1, _Tp2, 5, void>
4283 // Otherwise, if sizeof...(T) is greater than two, ...
4284 template<typename _Tp1, typename _Tp2, typename... _Rest>
4285 struct common_reference<_Tp1, _Tp2, _Rest...>
4286 : __common_type_fold<common_reference<_Tp1, _Tp2>,
4287 __common_type_pack<_Rest...>>
4290 // Reuse __common_type_fold for common_reference<T1, T2, Rest...>
4291 template<typename _Tp1, typename _Tp2, typename... _Rest>
4292 struct __common_type_fold<common_reference<_Tp1, _Tp2>,
4293 __common_type_pack<_Rest...>,
4294 void_t<common_reference_t<_Tp1, _Tp2>>>
4295 : public common_reference<common_reference_t<_Tp1, _Tp2>, _Rest...>
4301#if __cplusplus >= 201103L
4302 // Stores a tuple of indices. Used by tuple and pair, and by bind() to
4303 // extract the elements in a tuple.
4304 template<size_t... _Indexes> struct _Index_tuple { };
4306 // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
4307 template<size_t _Num>
4308 struct _Build_index_tuple
4310#if __has_builtin(__make_integer_seq)
4311 template<typename, size_t... _Indices>
4312 using _IdxTuple = _Index_tuple<_Indices...>;
4314 // Clang defines __make_integer_seq for this purpose.
4315 using __type = __make_integer_seq<_IdxTuple, size_t, _Num>;
4317 // For GCC and other compilers, use __integer_pack instead.
4318 using __type = _Index_tuple<__integer_pack(_Num)...>;
4323#ifdef __cpp_lib_constant_wrapper // C++ >= 26
4324 template<typename _Tp>
4325 struct _CwFixedValue
4330 _CwFixedValue(__type __v) noexcept
4336 template<typename _Tp, size_t _Extent>
4337 struct _CwFixedValue<_Tp[_Extent]>
4339 using __type = _Tp[_Extent];
4342 _CwFixedValue(_Tp (&__arr)[_Extent]) noexcept
4343 : _CwFixedValue(__arr, typename _Build_index_tuple<_Extent>::__type())
4346 template<size_t... _Indices>
4348 _CwFixedValue(_Tp (&__arr)[_Extent], _Index_tuple<_Indices...>) noexcept
4349 : _M_data{__arr[_Indices]...}
4352 _Tp _M_data[_Extent];
4355 template<typename _Tp, size_t _Extent>
4356 _CwFixedValue(_Tp (&)[_Extent]) -> _CwFixedValue<_Tp[_Extent]>;
4358 template<_CwFixedValue _Xv,
4359 typename = typename decltype(_CwFixedValue(_Xv))::__type>
4360 struct constant_wrapper;
4362 template<typename _Tp>
4363 concept _ConstExprParam = requires
4365 typename constant_wrapper<_Tp::value>;
4370 template<_ConstExprParam _Tp>
4371 friend constexpr auto
4372 operator+(_Tp) noexcept -> constant_wrapper<(+_Tp::value)>
4375 template<_ConstExprParam _Tp>
4376 friend constexpr auto
4377 operator-(_Tp) noexcept -> constant_wrapper<(-_Tp::value)>
4380 template<_ConstExprParam _Tp>
4381 friend constexpr auto
4382 operator~(_Tp) noexcept -> constant_wrapper<(~_Tp::value)>
4385 template<_ConstExprParam _Tp>
4386 friend constexpr auto
4387 operator!(_Tp) noexcept -> constant_wrapper<(!_Tp::value)>
4390 template<_ConstExprParam _Tp>
4391 friend constexpr auto
4392 operator&(_Tp) noexcept -> constant_wrapper<(&_Tp::value)>
4395 template<_ConstExprParam _Tp>
4396 friend constexpr auto
4397 operator*(_Tp) noexcept -> constant_wrapper<(*_Tp::value)>
4400 template<_ConstExprParam _Left, _ConstExprParam _Right>
4401 friend constexpr auto
4402 operator+(_Left, _Right) noexcept
4403 -> constant_wrapper<(_Left::value + _Right::value)>
4406 template<_ConstExprParam _Left, _ConstExprParam _Right>
4407 friend constexpr auto
4408 operator-(_Left, _Right) noexcept
4409 -> constant_wrapper<(_Left::value - _Right::value)>
4412 template<_ConstExprParam _Left, _ConstExprParam _Right>
4413 friend constexpr auto
4414 operator*(_Left, _Right) noexcept
4415 -> constant_wrapper<(_Left::value * _Right::value)>
4418 template<_ConstExprParam _Left, _ConstExprParam _Right>
4419 friend constexpr auto
4420 operator/(_Left, _Right) noexcept
4421 -> constant_wrapper<(_Left::value / _Right::value)>
4424 template<_ConstExprParam _Left, _ConstExprParam _Right>
4425 friend constexpr auto
4426 operator%(_Left, _Right) noexcept
4427 -> constant_wrapper<(_Left::value % _Right::value)>
4430 template<_ConstExprParam _Left, _ConstExprParam _Right>
4431 friend constexpr auto
4432 operator<<(_Left, _Right) noexcept
4433 -> constant_wrapper<(_Left::value << _Right::value)>
4436 template<_ConstExprParam _Left, _ConstExprParam _Right>
4437 friend constexpr auto
4438 operator>>(_Left, _Right) noexcept
4439 -> constant_wrapper<(_Left::value >> _Right::value)>
4442 template<_ConstExprParam _Left, _ConstExprParam _Right>
4443 friend constexpr auto
4444 operator&(_Left, _Right) noexcept
4445 -> constant_wrapper<(_Left::value & _Right::value)>
4448 template<_ConstExprParam _Left, _ConstExprParam _Right>
4449 friend constexpr auto
4450 operator|(_Left, _Right) noexcept
4451 -> constant_wrapper<(_Left::value | _Right::value)>
4454 template<_ConstExprParam _Left, _ConstExprParam _Right>
4455 friend constexpr auto
4456 operator^(_Left, _Right) noexcept
4457 -> constant_wrapper<(_Left::value ^ _Right::value)>
4460 template<_ConstExprParam _Left, _ConstExprParam _Right>
4461 requires (!is_constructible_v<bool, decltype(_Left::value)>
4462 || !is_constructible_v<bool, decltype(_Right::value)>)
4463 friend constexpr auto
4464 operator&&(_Left, _Right) noexcept
4465 -> constant_wrapper<(_Left::value && _Right::value)>
4468 template<_ConstExprParam _Left, _ConstExprParam _Right>
4469 requires (!is_constructible_v<bool, decltype(_Left::value)>
4470 || !is_constructible_v<bool, decltype(_Right::value)>)
4471 friend constexpr auto
4472 operator||(_Left, _Right) noexcept
4473 -> constant_wrapper<(_Left::value || _Right::value)>
4476 template<_ConstExprParam _Left, _ConstExprParam _Right>
4477 friend constexpr auto
4478 operator<=>(_Left, _Right) noexcept
4479 -> constant_wrapper<(_Left::value <=> _Right::value)>
4482 template<_ConstExprParam _Left, _ConstExprParam _Right>
4483 friend constexpr auto
4484 operator<(_Left, _Right) noexcept
4485 -> constant_wrapper<(_Left::value < _Right::value)>
4488 template<_ConstExprParam _Left, _ConstExprParam _Right>
4489 friend constexpr auto
4490 operator<=(_Left, _Right) noexcept
4491 -> constant_wrapper<(_Left::value <= _Right::value)>
4494 template<_ConstExprParam _Left, _ConstExprParam _Right>
4495 friend constexpr auto
4496 operator==(_Left, _Right) noexcept
4497 -> constant_wrapper<(_Left::value == _Right::value)>
4500 template<_ConstExprParam _Left, _ConstExprParam _Right>
4501 friend constexpr auto
4502 operator!=(_Left, _Right) noexcept
4503 -> constant_wrapper<(_Left::value != _Right::value)>
4506 template<_ConstExprParam _Left, _ConstExprParam _Right>
4507 friend constexpr auto
4508 operator>(_Left, _Right) noexcept
4509 -> constant_wrapper<(_Left::value > _Right::value)>
4512 template<_ConstExprParam _Left, _ConstExprParam _Right>
4513 friend constexpr auto
4514 operator>=(_Left, _Right) noexcept
4515 -> constant_wrapper<(_Left::value >= _Right::value)>
4518 template<_ConstExprParam _Left, _ConstExprParam _Right>
4519 friend constexpr auto
4520 operator,(_Left, _Right) noexcept = delete;
4522 template<_ConstExprParam _Left, _ConstExprParam _Right>
4523 friend constexpr auto
4524 operator->*(_Left, _Right) noexcept
4525 -> constant_wrapper<_Left::value->*(_Right::value)>
4528 template<_ConstExprParam _Tp, _ConstExprParam... _Args>
4530 operator()(this _Tp, _Args...) noexcept
4532 requires(_Args...) { constant_wrapper<_Tp::value(_Args::value...)>(); }
4533 { return constant_wrapper<_Tp::value(_Args::value...)>{}; }
4535 template<_ConstExprParam _Tp, _ConstExprParam... _Args>
4537 operator[](this _Tp, _Args...) noexcept
4538 -> constant_wrapper<(_Tp::value[_Args::value...])>
4541 template<_ConstExprParam _Tp>
4543 operator++(this _Tp) noexcept
4544 requires requires(_Tp::value_type __x) { ++__x; }
4546 return constant_wrapper<
4547 [] { auto __x = _Tp::value; return ++__x; }()>{};
4550 template<_ConstExprParam _Tp>
4552 operator++(this _Tp, int) noexcept
4553 requires requires(_Tp::value_type __x) { __x++; }
4555 return constant_wrapper<
4556 [] { auto __x = _Tp::value; return __x++; }()>{};
4559 template<_ConstExprParam _Tp>
4561 operator--(this _Tp) noexcept
4562 requires requires(_Tp::value_type __x) { --__x; }
4564 return constant_wrapper<
4565 [] { auto __x = _Tp::value; return --__x; }()>{};
4568 template<_ConstExprParam _Tp>
4570 operator--(this _Tp, int) noexcept
4571 requires requires(_Tp::value_type __x) { __x--; }
4573 return constant_wrapper<
4574 [] { auto __x = _Tp::value; return __x--; }()>{};
4577 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4579 operator+=(this _Tp, _Right) noexcept
4580 requires requires(_Tp::value_type __x) { __x += _Right::value; }
4582 return constant_wrapper<
4583 [] { auto __x = _Tp::value; return __x += _Right::value; }()>{};
4586 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4588 operator-=(this _Tp, _Right) noexcept
4589 requires requires(_Tp::value_type __x) { __x -= _Right::value; }
4591 return constant_wrapper<
4592 [] { auto __x = _Tp::value; return __x -= _Right::value; }()>{};
4595 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4597 operator*=(this _Tp, _Right) noexcept
4598 requires requires(_Tp::value_type __x) { __x *= _Right::value; }
4600 return constant_wrapper<
4601 [] { auto __x = _Tp::value; return __x *= _Right::value; }()>{};
4604 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4606 operator/=(this _Tp, _Right) noexcept
4607 requires requires(_Tp::value_type __x) { __x /= _Right::value; }
4609 return constant_wrapper<
4610 [] { auto __x = _Tp::value; return __x /= _Right::value; }()>{};
4613 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4615 operator%=(this _Tp, _Right) noexcept
4616 requires requires(_Tp::value_type __x) { __x %= _Right::value; }
4618 return constant_wrapper<
4619 [] { auto __x = _Tp::value; return __x %= _Right::value; }()>{};
4622 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4624 operator&=(this _Tp, _Right) noexcept
4625 requires requires(_Tp::value_type __x) { __x &= _Right::value; }
4627 return constant_wrapper<
4628 [] { auto __x = _Tp::value; return __x &= _Right::value; }()>{};
4631 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4633 operator|=(this _Tp, _Right) noexcept
4634 requires requires(_Tp::value_type __x) { __x |= _Right::value; }
4636 return constant_wrapper<
4637 [] { auto __x = _Tp::value; return __x |= _Right::value; }()>{};
4640 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4642 operator^=(this _Tp, _Right) noexcept
4643 requires requires(_Tp::value_type __x) { __x ^= _Right::value; }
4645 return constant_wrapper<
4646 [] { auto __x = _Tp::value; return __x ^= _Right::value; }()>{};
4649 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4651 operator<<=(this _Tp, _Right) noexcept
4652 requires requires(_Tp::value_type __x) { __x <<= _Right::value; }
4654 return constant_wrapper<
4655 [] { auto __x = _Tp::value; return __x <<= _Right::value; }()>{};
4658 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4660 operator>>=(this _Tp, _Right) noexcept
4661 requires requires(_Tp::value_type __x) { __x >>= _Right::value; }
4663 return constant_wrapper<
4664 [] { auto __x = _Tp::value; return __x >>= _Right::value; }()>{};
4668 template<_CwFixedValue _Xv, typename>
4669 struct constant_wrapper : _CwOperators
4671 static constexpr const auto& value = _Xv._M_data;
4672 using type = constant_wrapper;
4673 using value_type = typename decltype(_Xv)::__type;
4675 template<_ConstExprParam _Right>
4677 operator=(_Right) const noexcept
4678 requires requires(value_type __x) { __x = _Right::value; }
4680 return constant_wrapper<
4681 [] { auto __x = value; return __x = _Right::value; }()>{};
4685 operator decltype(auto)() const noexcept
4689 template<_CwFixedValue _Tp>
4690 constexpr auto cw = constant_wrapper<_Tp>{};
4693 /// @} group metaprogramming
4695_GLIBCXX_END_NAMESPACE_VERSION
4701#endif // _GLIBCXX_TYPE_TRAITS