Go to the documentation of this file. 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_invocable
51#define __glibcxx_want_is_layout_compatible
52#define __glibcxx_want_is_nothrow_convertible
53#define __glibcxx_want_is_null_pointer
54#define __glibcxx_want_is_pointer_interconvertible
55#define __glibcxx_want_is_scoped_enum
56#define __glibcxx_want_is_swappable
57#define __glibcxx_want_is_virtual_base_of
58#define __glibcxx_want_logical_traits
59#define __glibcxx_want_reference_from_temporary
60#define __glibcxx_want_remove_cvref
61#define __glibcxx_want_result_of_sfinae
62#define __glibcxx_want_transformation_trait_aliases
63#define __glibcxx_want_type_identity
64#define __glibcxx_want_type_trait_variable_templates
65#define __glibcxx_want_unwrap_ref
66#define __glibcxx_want_void_t
67#include <bits/version.h>
71namespace std _GLIBCXX_VISIBILITY(default)
73_GLIBCXX_BEGIN_NAMESPACE_VERSION
75 template<typename _Tp>
76 class reference_wrapper;
79 * @
defgroup metaprogramming Metaprogramming
82 * Template utilities for compile-time introspection and modification,
83 * including type classification traits, type property inspection traits
84 * and type transformation traits.
92 template<typename _Tp, _Tp __v>
93 struct integral_constant
95 static constexpr _Tp value = __v;
96 using value_type = _Tp;
97 using type = integral_constant<_Tp, __v>;
98 constexpr operator value_type() const noexcept {
return value; }
100#ifdef __cpp_lib_integral_constant_callable // C++ >= 14
101 constexpr value_type operator()() const noexcept {
return value; }
105#if ! __cpp_inline_variables
106 template<typename _Tp, _Tp __v>
107 constexpr _Tp integral_constant<_Tp, __v>::value;
110 /// @
cond undocumented
111 /// bool_constant for C++11
113 using __bool_constant = integral_constant<bool, __v>;
116 /// The type used as a compile-time boolean with true value.
117 using true_type = __bool_constant<true>;
119 /// The type used as a compile-time boolean with false value.
120 using false_type = __bool_constant<false>;
122#ifdef __cpp_lib_bool_constant // C++ >= 17
123 /// Alias template for compile-time boolean constant types.
126 using bool_constant = __bool_constant<__v>;
129 // Metaprogramming helper types.
132 /// Define a member typedef `
type`
only if a boolean constant is true.
133 template<bool, typename _Tp = void>
137 // Partial specialization for true.
138 template<typename _Tp>
139 struct enable_if<true, _Tp>
140 {
using type = _Tp; };
142 // __enable_if_t (std::enable_if_t for C++11)
143 template<bool _Cond, typename _Tp = void>
144 using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
149 template<typename _Tp, typename>
154 struct __conditional<false>
156 template<typename, typename _Up>
160 // More efficient version of std::conditional_t for internal use (and C++11)
161 template<bool _Cond, typename _If, typename _Else>
162 using __conditional_t
163 = typename __conditional<_Cond>::template type<_If, _Else>;
165 /// @
cond undocumented
166 template <typename _Type>
167 struct __type_identity
168 {
using type = _Type; };
170 template<typename _Tp>
171 using __type_identity_t = typename __type_identity<_Tp>::type;
175 // A variadic alias template that resolves to its first argument.
176 template<typename _Tp, typename...>
177 using __first_t = _Tp;
179 // These are deliberately not defined.
180 template<typename... _Bn>
181 auto __or_fn(int) -> __first_t<false_type,
182 __enable_if_t<!bool(_Bn::value)>...>;
184 template<typename... _Bn>
185 auto __or_fn(...) -> true_type;
187 template<typename... _Bn>
188 auto __and_fn(int) -> __first_t<true_type,
189 __enable_if_t<bool(_Bn::value)>...>;
191 template<typename... _Bn>
192 auto __and_fn(...) -> false_type;
193 }
// namespace detail
195 // Like C++17 std::dis/conjunction, but usable in C++11 and resolves
196 // to either true_type or false_type which allows for a more efficient
197 // implementation that avoids recursive class template instantiation.
198 template<typename... _Bn>
200 : decltype(__detail::__or_fn<_Bn...>(0))
203 template<typename... _Bn>
205 : decltype(__detail::__and_fn<_Bn...>(0))
208 template<typename _Pp>
210 : __bool_constant<!bool(_Pp::value)>
214#ifdef __cpp_lib_logical_traits // C++ >= 17
216 /// @
cond undocumented
217 template<typename... _Bn>
218 inline constexpr bool __or_v = __or_<_Bn...>::value;
219 template<typename... _Bn>
220 inline constexpr bool __and_v = __and_<_Bn...>::value;
224 template<typename /* = void */, typename _B1, typename... _Bn>
225 struct __disjunction_impl
226 {
using type = _B1; };
228 template<typename _B1, typename _B2, typename... _Bn>
229 struct __disjunction_impl<__enable_if_t<!bool(_B1::value)>, _B1, _B2, _Bn...>
230 {
using type = typename __disjunction_impl<void, _B2, _Bn...>::type; };
232 template<typename /* = void */, typename _B1, typename... _Bn>
233 struct __conjunction_impl
234 {
using type = _B1; };
236 template<typename _B1, typename _B2, typename... _Bn>
237 struct __conjunction_impl<__enable_if_t<bool(_B1::value)>, _B1, _B2, _Bn...>
238 {
using type = typename __conjunction_impl<void, _B2, _Bn...>::type; };
239 }
// namespace __detail
242 template<typename... _Bn>
244 : __detail::__conjunction_impl<void, _Bn...>::type
252 template<typename... _Bn>
254 : __detail::__disjunction_impl<void, _Bn...>::type
262 template<typename _Pp>
267 /** @
ingroup variable_templates
270 template<typename... _Bn>
271 inline constexpr bool conjunction_v = conjunction<_Bn...>::value;
273 template<typename... _Bn>
274 inline constexpr bool disjunction_v = disjunction<_Bn...>::value;
276 template<typename _Pp>
277 inline constexpr bool negation_v = negation<_Pp>::value;
280#endif // __cpp_lib_logical_traits
282 // Forward declarations
290 /// @
cond undocumented
292 struct __is_array_unknown_bounds;
294 // An object type which is not an unbounded array.
295 // It might still be an incomplete type, but if this is false_type
296 // then we can be certain it's not a complete object type.
297 template<typename _Tp>
298 using __maybe_complete_object_type
299 = __and_<is_object<_Tp>, __not_<__is_array_unknown_bounds<_Tp>>>;
301 // Helper functions that return false_type for incomplete classes,
302 // incomplete unions and arrays of known bound from those.
304 // More specialized overload for complete object types (returning true_type).
305 template<typename _Tp,
306 typename = __enable_if_t<__maybe_complete_object_type<_Tp>::value>,
307 size_t = sizeof(_Tp)>
309 __is_complete_or_unbounded(__type_identity<_Tp>)
312 // Less specialized overload for reference and unknown-bound array types
313 // (returning true_type), and incomplete types (returning false_type).
314 template<typename _TypeIdentity,
315 typename _NestedType = typename _TypeIdentity::type>
316 constexpr typename __not_<__maybe_complete_object_type<_NestedType>>::type
317 __is_complete_or_unbounded(_TypeIdentity)
320 // __remove_cv_t (std::remove_cv_t for C++11).
321 template<typename _Tp>
322 using __remove_cv_t = typename remove_cv<_Tp>::type;
325 // Primary type categories.
328 template<typename _Tp>
330 : public false_type { };
334 : public true_type { };
337 struct is_void<const void>
338 : public true_type { };
341 struct is_void<volatile void>
342 : public true_type { };
345 struct is_void<const volatile void>
346 : public true_type { };
348 /// @
cond undocumented
350 struct __is_integral_helper
351 : public false_type { };
354 struct __is_integral_helper<bool>
355 : public true_type { };
358 struct __is_integral_helper<char>
359 : public true_type { };
362 struct __is_integral_helper<signed char>
363 : public true_type { };
366 struct __is_integral_helper<unsigned char>
367 : public true_type { };
369 // We want is_integral<wchar_t> to be true (and make_signed/unsigned to work)
370 // even when libc doesn't provide working <wchar.h> and related functions,
371 // so don't check _GLIBCXX_USE_WCHAR_T here.
373 struct __is_integral_helper<wchar_t>
374 : public true_type { };
376#ifdef _GLIBCXX_USE_CHAR8_T
378 struct __is_integral_helper<char8_t>
379 : public true_type { };
383 struct __is_integral_helper<char16_t>
384 : public true_type { };
387 struct __is_integral_helper<char32_t>
388 : public true_type { };
391 struct __is_integral_helper<short>
392 : public true_type { };
395 struct __is_integral_helper<unsigned short>
396 : public true_type { };
399 struct __is_integral_helper<int>
400 : public true_type { };
403 struct __is_integral_helper<unsigned int>
404 : public true_type { };
407 struct __is_integral_helper<long>
408 : public true_type { };
411 struct __is_integral_helper<unsigned long>
412 : public true_type { };
415 struct __is_integral_helper<long long>
416 : public true_type { };
419 struct __is_integral_helper<unsigned long long>
420 : public true_type { };
422 // Conditionalizing on __STRICT_ANSI__ here will break any port that
423 // uses one of these types for size_t.
424#if defined(__GLIBCXX_TYPE_INT_N_0)
427 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
428 : public true_type { };
432 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
433 : public true_type { };
435#if defined(__GLIBCXX_TYPE_INT_N_1)
438 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
439 : public true_type { };
443 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
444 : public true_type { };
446#if defined(__GLIBCXX_TYPE_INT_N_2)
449 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
450 : public true_type { };
454 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
455 : public true_type { };
457#if defined(__GLIBCXX_TYPE_INT_N_3)
460 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
461 : public true_type { };
465 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
466 : public true_type { };
469#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
472 struct __is_integral_helper<__int128>
473 : public true_type { };
477 struct __is_integral_helper<unsigned __int128>
478 : public true_type { };
484 template<typename _Tp>
486 : public __is_integral_helper<__remove_cv_t<_Tp>>::type
489 /// @
cond undocumented
491 struct __is_floating_point_helper
492 : public false_type { };
495 struct __is_floating_point_helper<float>
496 : public true_type { };
499 struct __is_floating_point_helper<double>
500 : public true_type { };
503 struct __is_floating_point_helper<long double>
504 : public true_type { };
506#ifdef __STDCPP_FLOAT16_T__
508 struct __is_floating_point_helper<_Float16>
509 : public true_type { };
512#ifdef __STDCPP_FLOAT32_T__
514 struct __is_floating_point_helper<_Float32>
515 : public true_type { };
518#ifdef __STDCPP_FLOAT64_T__
520 struct __is_floating_point_helper<_Float64>
521 : public true_type { };
524#ifdef __STDCPP_FLOAT128_T__
526 struct __is_floating_point_helper<_Float128>
527 : public true_type { };
530#ifdef __STDCPP_BFLOAT16_T__
532 struct __is_floating_point_helper<__gnu_cxx::__bfloat16_t>
533 : public true_type { };
536#ifdef _GLIBCXX_USE_FLOAT128
538 struct __is_floating_point_helper<__float128>
539 : public true_type { };
543 /// is_floating_point
544 template<typename _Tp>
545 struct is_floating_point
546 : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type
550#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_array)
551 template<typename _Tp>
553 : public __bool_constant<__is_array(_Tp)>
558 : public false_type { };
560 template<typename _Tp, std::size_t _Size>
561 struct is_array<_Tp[
_Size]
>
562 : public true_type { };
564 template<typename _Tp>
565 struct is_array<_Tp[]
>
566 : public true_type { };
570#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
571 template<typename _Tp>
573 : public __bool_constant<__is_pointer(_Tp)>
576 template<typename _Tp>
578 : public false_type { };
580 template<typename _Tp>
581 struct is_pointer<_Tp*>
582 : public true_type { };
584 template<typename _Tp>
585 struct is_pointer<_Tp* const>
586 : public true_type { };
588 template<typename _Tp>
589 struct is_pointer<_Tp* volatile>
590 : public true_type { };
592 template<typename _Tp>
593 struct is_pointer<_Tp* const volatile>
594 : public true_type { };
597 /// is_lvalue_reference
599 struct is_lvalue_reference
600 : public false_type { };
602 template<typename _Tp>
603 struct is_lvalue_reference<_Tp&>
604 : public true_type { };
606 /// is_rvalue_reference
608 struct is_rvalue_reference
609 : public false_type { };
611 template<typename _Tp>
612 struct is_rvalue_reference<_Tp&&>
613 : public true_type { };
615 /// is_member_object_pointer
616#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_object_pointer)
617 template<typename _Tp>
618 struct is_member_object_pointer
619 : public __bool_constant<__is_member_object_pointer(_Tp)>
623 struct __is_member_object_pointer_helper
624 : public false_type { };
626 template<typename _Tp, typename _Cp>
627 struct __is_member_object_pointer_helper<_Tp _Cp::*>
628 : public __not_<is_function<_Tp>>::type { };
631 template<typename _Tp>
632 struct is_member_object_pointer
633 : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type
637#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_function_pointer)
638 /// is_member_function_pointer
639 template<typename _Tp>
640 struct is_member_function_pointer
641 : public __bool_constant<__is_member_function_pointer(_Tp)>
645 struct __is_member_function_pointer_helper
646 : public false_type { };
648 template<typename _Tp, typename _Cp>
649 struct __is_member_function_pointer_helper<_Tp _Cp::*>
650 : public is_function<_Tp>::type { };
652 /// is_member_function_pointer
653 template<typename _Tp>
654 struct is_member_function_pointer
655 : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type
660 template<typename _Tp>
662 : public __bool_constant<__is_enum(_Tp)>
666 template<typename _Tp>
668 : public __bool_constant<__is_union(_Tp)>
672 template<typename _Tp>
674 : public __bool_constant<__is_class(_Tp)>
678#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function)
679 template<typename _Tp>
681 : public __bool_constant<__is_function(_Tp)>
684 template<typename _Tp>
686 : public __bool_constant<!is_const<const _Tp>::value> { };
688 template<typename _Tp>
689 struct is_function<_Tp&>
690 : public false_type { };
692 template<typename _Tp>
693 struct is_function<_Tp&&>
694 : public false_type { };
697#ifdef __cpp_lib_is_null_pointer // C++ >= 11
698 /// is_null_pointer (LWG 2247).
699 template<typename _Tp>
700 struct is_null_pointer
701 : public false_type { };
704 struct is_null_pointer<std::nullptr_t>
705 : public true_type { };
708 struct is_null_pointer<const std::nullptr_t>
709 : public true_type { };
712 struct is_null_pointer<volatile std::nullptr_t>
713 : public true_type { };
716 struct is_null_pointer<const volatile std::nullptr_t>
717 : public true_type { };
719 /// __is_nullptr_t (deprecated extension).
720 /// @
deprecated Non-standard. Use `
is_null_pointer`
instead.
721 template<typename _Tp>
722 struct __is_nullptr_t
723 : public is_null_pointer<_Tp>
724 { }
_GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer");
725#endif // __cpp_lib_is_null_pointer
727 // Composite type categories.
730#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference)
731 template<typename _Tp>
733 : public __bool_constant<__is_reference(_Tp)>
736 template<typename _Tp>
741 template<typename _Tp>
742 struct is_reference<_Tp&>
746 template<typename _Tp>
747 struct is_reference<_Tp&&>
753 template<typename _Tp>
755 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
759 template<typename _Tp>
760 struct is_fundamental
761 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
762 is_null_pointer<_Tp>>::type
766#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object)
767 template<typename _Tp>
769 : public __bool_constant<__is_object(_Tp)>
772 template<typename _Tp>
774 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
780 struct is_member_pointer;
783 template<typename _Tp>
785 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
786 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
790 template<typename _Tp>
792 : public __bool_constant<!is_fundamental<_Tp>::value> { };
794 /// is_member_pointer
795#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_pointer)
796 template<typename _Tp>
797 struct is_member_pointer
798 : public __bool_constant<__is_member_pointer(_Tp)>
801 /// @
cond undocumented
802 template<typename _Tp>
803 struct __is_member_pointer_helper
804 : public false_type { };
806 template<typename _Tp, typename _Cp>
807 struct __is_member_pointer_helper<_Tp _Cp::*>
808 : public true_type { };
811 template<typename _Tp>
812 struct is_member_pointer
813 : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type
817 template<typename, typename>
820 /// @
cond undocumented
821 template<typename _Tp, typename... _Types>
822 using __is_one_of = __or_<is_same<_Tp, _Types>...>;
824 // Check if a type is one of the signed integer types.
826 template<typename _Tp>
827 using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>,
828 signed char, signed short, signed int, signed long,
830#if defined(__GLIBCXX_TYPE_INT_N_0)
831 , signed __GLIBCXX_TYPE_INT_N_0
833#if defined(__GLIBCXX_TYPE_INT_N_1)
834 , signed __GLIBCXX_TYPE_INT_N_1
836#if defined(__GLIBCXX_TYPE_INT_N_2)
837 , signed __GLIBCXX_TYPE_INT_N_2
839#if defined(__GLIBCXX_TYPE_INT_N_3)
840 , signed __GLIBCXX_TYPE_INT_N_3
844 // Check if a type is one of the unsigned integer types.
846 template<typename _Tp>
847 using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>,
848 unsigned char, unsigned short, unsigned int, unsigned long,
850#if defined(__GLIBCXX_TYPE_INT_N_0)
851 , unsigned __GLIBCXX_TYPE_INT_N_0
853#if defined(__GLIBCXX_TYPE_INT_N_1)
854 , unsigned __GLIBCXX_TYPE_INT_N_1
856#if defined(__GLIBCXX_TYPE_INT_N_2)
857 , unsigned __GLIBCXX_TYPE_INT_N_2
859#if defined(__GLIBCXX_TYPE_INT_N_3)
860 , unsigned __GLIBCXX_TYPE_INT_N_3
864 // Check if a type is one of the signed or unsigned integer types.
865 template<typename _Tp>
866 using __is_standard_integer
867 = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>;
869 // __void_t (std::void_t for C++11)
870 template<typename...> using __void_t = void;
876#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const)
877 template<typename _Tp>
879 : public __bool_constant<__is_const(_Tp)>
884 : public false_type { };
886 template<typename _Tp>
887 struct is_const<_Tp const>
888 : public true_type { };
892#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile)
893 template<typename _Tp>
895 : public __bool_constant<__is_volatile(_Tp)>
900 : public false_type { };
902 template<typename _Tp>
903 struct is_volatile<_Tp volatile>
904 : public true_type { };
908 * @
deprecated Deprecated in C++26.
909 * Use a combination of one or more more specialized type traits instead,
910 * such as `
is_trivially_default_constructible`
,
911 * `
is_trivially_copy_constructible`
, `
is_trivially_copy_assignable`
,
912 * etc., depending on the exact check(s) needed.
914 template<typename _Tp>
916 _GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible && is_trivially_copyable")
918 : public __bool_constant<__is_trivial(_Tp)>
920 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
921 "template argument must be a complete class or an unbounded array");
924 /// is_trivially_copyable
925 template<typename _Tp>
926 struct is_trivially_copyable
927 : public __bool_constant<__is_trivially_copyable(_Tp)>
929 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
930 "template argument must be a complete class or an unbounded array");
933 /// is_standard_layout
934 template<typename _Tp>
935 struct is_standard_layout
936 : public __bool_constant<__is_standard_layout(_Tp)>
938 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
939 "template argument must be a complete class or an unbounded array");
943 * @
deprecated Deprecated in C++20.
944 * Use `
is_standard_layout && is_trivial`
instead.
946 // Could use is_standard_layout && is_trivial instead of the builtin.
947 template<typename _Tp>
949 _GLIBCXX20_DEPRECATED_SUGGEST("is_standard_layout && is_trivial")
951 : public __bool_constant<__is_pod(_Tp)>
953 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
954 "template argument must be a complete class or an unbounded array");
958 * @
deprecated Deprecated in C++17, removed in C++20.
959 * The idea of a literal type isn't useful.
961 template<typename _Tp>
963 _GLIBCXX17_DEPRECATED
965 : public __bool_constant<__is_literal_type(_Tp)>
967 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
968 "template argument must be a complete class or an unbounded array");
972 template<typename _Tp>
974 : public __bool_constant<__is_empty(_Tp)>
978 template<typename _Tp>
979 struct is_polymorphic
980 : public __bool_constant<__is_polymorphic(_Tp)>
983#ifdef __cpp_lib_is_final // C++ >= 14
986 template<typename _Tp>
988 : public __bool_constant<__is_final(_Tp)>
993 template<typename _Tp>
995 : public __bool_constant<__is_abstract(_Tp)>
998 /// @
cond undocumented
999 template<typename _Tp,
1000 bool = is_arithmetic<_Tp>::value>
1001 struct __is_signed_helper
1002 : public false_type { };
1004 template<typename _Tp>
1005 struct __is_signed_helper<_Tp, true>
1006 : public __bool_constant<_Tp(-1) < _Tp(0)>
1011 template<typename _Tp>
1013 : public __is_signed_helper<_Tp>::type
1017 template<typename _Tp>
1019 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
1022 /// @
cond undocumented
1023 template<typename _Tp, typename _Up = _Tp&&>
1027 template<typename _Tp>
1032 template<typename _Tp>
1033 auto declval() noexcept -> decltype(__declval<_Tp>(0));
1036 struct remove_all_extents;
1038 /// @
cond undocumented
1039 template<typename _Tp>
1040 struct __is_array_known_bounds
1044 template<typename _Tp, size_t _Size>
1045 struct __is_array_known_bounds<_Tp[
_Size]
>
1049 template<typename _Tp>
1050 struct __is_array_unknown_bounds
1054 template<typename _Tp>
1055 struct __is_array_unknown_bounds<_Tp[]
>
1060 // Destructible and constructible type properties.
1062#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_destructible)
1064 template<typename _Tp>
1065 struct is_destructible
1066 : public __bool_constant<__is_destructible(_Tp)>
1069 /// @
cond undocumented
1071 // In N3290 is_destructible does not say anything about function
1072 // types and abstract types, see LWG 2049.
This implementation
1073 // describes function types as non-destructible and all complete
1074 // object types as destructible, iff the explicit destructor
1075 // call expression is wellformed.
1076 struct __do_is_destructible_impl
1078 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
1079 static true_type __test(int);
1082 static false_type __test(...);
1085 template<typename _Tp>
1086 struct __is_destructible_impl
1087 : public __do_is_destructible_impl
1089 using type = decltype(__test<_Tp>(0));
1092 template<typename _Tp,
1093 bool = __or_<is_void<_Tp>,
1094 __is_array_unknown_bounds<_Tp>,
1095 is_function<_Tp>>::value,
1096 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
1097 struct __is_destructible_safe;
1099 template<typename _Tp>
1100 struct __is_destructible_safe<_Tp, false, false>
1101 : public __is_destructible_impl<typename
1102 remove_all_extents<_Tp>::type>::type
1105 template<typename _Tp>
1106 struct __is_destructible_safe<_Tp, true, false>
1107 : public false_type { };
1109 template<typename _Tp>
1110 struct __is_destructible_safe<_Tp, false, true>
1111 : public true_type { };
1115 template<typename _Tp>
1116 struct is_destructible
1117 : public __is_destructible_safe<_Tp>::type
1119 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1120 "template argument must be a complete class or an unbounded array");
1124#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_destructible)
1125 /// is_nothrow_destructible
1126 template<typename _Tp>
1127 struct is_nothrow_destructible
1128 : public __bool_constant<__is_nothrow_destructible(_Tp)>
1131 /// @
cond undocumented
1133 // is_nothrow_destructible requires that is_destructible is
1134 // satisfied as well. We realize that by mimicing the
1135 // implementation of is_destructible but refer to noexcept(expr)
1136 // instead of decltype(expr).
1137 struct __do_is_nt_destructible_impl
1139 template<typename _Tp>
1140 static __bool_constant<noexcept(declval<_Tp&>().~_Tp())>
1144 static false_type __test(...);
1147 template<typename _Tp>
1148 struct __is_nt_destructible_impl
1149 : public __do_is_nt_destructible_impl
1151 using type = decltype(__test<_Tp>(0));
1154 template<typename _Tp,
1155 bool = __or_<is_void<_Tp>,
1156 __is_array_unknown_bounds<_Tp>,
1157 is_function<_Tp>>::value,
1158 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
1159 struct __is_nt_destructible_safe;
1161 template<typename _Tp>
1162 struct __is_nt_destructible_safe<_Tp, false, false>
1163 : public __is_nt_destructible_impl<typename
1164 remove_all_extents<_Tp>::type>::type
1167 template<typename _Tp>
1168 struct __is_nt_destructible_safe<_Tp, true, false>
1169 : public false_type { };
1171 template<typename _Tp>
1172 struct __is_nt_destructible_safe<_Tp, false, true>
1173 : public true_type { };
1176 /// is_nothrow_destructible
1177 template<typename _Tp>
1178 struct is_nothrow_destructible
1179 : public __is_nt_destructible_safe<_Tp>::type
1181 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1182 "template argument must be a complete class or an unbounded array");
1186 /// @
cond undocumented
1187 template<typename _Tp, typename... _Args>
1188 using __is_constructible_impl
1189 = __bool_constant<__is_constructible(_Tp, _Args...)>;
1192 /// is_constructible
1193 template<typename _Tp, typename... _Args>
1194 struct is_constructible
1195 : public __is_constructible_impl<_Tp, _Args...>
1197 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1198 "template argument must be a complete class or an unbounded array");
1201 /// is_default_constructible
1202 template<typename _Tp>
1203 struct is_default_constructible
1204 : public __is_constructible_impl<_Tp>
1206 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1207 "template argument must be a complete class or an unbounded array");
1210 /// @
cond undocumented
1211#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_lvalue_reference)
1212 template<typename _Tp>
1213 using __add_lval_ref_t = __add_lvalue_reference(_Tp);
1215 template<typename _Tp, typename = void>
1216 struct __add_lvalue_reference_helper
1217 {
using type = _Tp; };
1219 template<typename _Tp>
1220 struct __add_lvalue_reference_helper<_Tp, __void_t<_Tp&>>
1221 {
using type = _Tp&; };
1223 template<typename _Tp>
1224 using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type;
1228 /// is_copy_constructible
1229 template<typename _Tp>
1230 struct is_copy_constructible
1231 : public __is_constructible_impl<_Tp, __add_lval_ref_t<const _Tp>>
1233 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1234 "template argument must be a complete class or an unbounded array");
1237 /// @
cond undocumented
1238#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_rvalue_reference)
1239 template<typename _Tp>
1240 using __add_rval_ref_t = __add_rvalue_reference(_Tp);
1242 template<typename _Tp, typename = void>
1243 struct __add_rvalue_reference_helper
1244 {
using type = _Tp; };
1246 template<typename _Tp>
1247 struct __add_rvalue_reference_helper<_Tp, __void_t<_Tp&&>>
1248 {
using type = _Tp&&; };
1250 template<typename _Tp>
1251 using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type;
1255 /// is_move_constructible
1256 template<typename _Tp>
1257 struct is_move_constructible
1258 : public __is_constructible_impl<_Tp, __add_rval_ref_t<_Tp>>
1260 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1261 "template argument must be a complete class or an unbounded array");
1264 /// @
cond undocumented
1265 template<typename _Tp, typename... _Args>
1266 using __is_nothrow_constructible_impl
1267 = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>;
1270 /// is_nothrow_constructible
1271 template<typename _Tp, typename... _Args>
1272 struct is_nothrow_constructible
1273 : public __is_nothrow_constructible_impl<_Tp, _Args...>
1275 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1276 "template argument must be a complete class or an unbounded array");
1279 /// is_nothrow_default_constructible
1280 template<typename _Tp>
1281 struct is_nothrow_default_constructible
1282 : public __is_nothrow_constructible_impl<_Tp>
1284 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1285 "template argument must be a complete class or an unbounded array");
1288 /// is_nothrow_copy_constructible
1289 template<typename _Tp>
1290 struct is_nothrow_copy_constructible
1291 : public __is_nothrow_constructible_impl<_Tp, __add_lval_ref_t<const _Tp>>
1293 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1294 "template argument must be a complete class or an unbounded array");
1297 /// is_nothrow_move_constructible
1298 template<typename _Tp>
1299 struct is_nothrow_move_constructible
1300 : public __is_nothrow_constructible_impl<_Tp, __add_rval_ref_t<_Tp>>
1302 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1303 "template argument must be a complete class or an unbounded array");
1306 /// @
cond undocumented
1307 template<typename _Tp, typename _Up>
1308 using __is_assignable_impl = __bool_constant<__is_assignable(_Tp, _Up)>;
1312 template<typename _Tp, typename _Up>
1313 struct is_assignable
1314 : public __is_assignable_impl<_Tp, _Up>
1316 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1317 "template argument must be a complete class or an unbounded array");
1320 /// is_copy_assignable
1321 template<typename _Tp>
1322 struct is_copy_assignable
1323 : public __is_assignable_impl<__add_lval_ref_t<_Tp>,
1324 __add_lval_ref_t<const _Tp>>
1326 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1327 "template argument must be a complete class or an unbounded array");
1330 /// is_move_assignable
1331 template<typename _Tp>
1332 struct is_move_assignable
1333 : public __is_assignable_impl<__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>>
1335 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1336 "template argument must be a complete class or an unbounded array");
1339 /// @
cond undocumented
1340 template<typename _Tp, typename _Up>
1341 using __is_nothrow_assignable_impl
1342 = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>;
1345 /// is_nothrow_assignable
1346 template<typename _Tp, typename _Up>
1347 struct is_nothrow_assignable
1348 : public __is_nothrow_assignable_impl<_Tp, _Up>
1350 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1351 "template argument must be a complete class or an unbounded array");
1354 /// is_nothrow_copy_assignable
1355 template<typename _Tp>
1356 struct is_nothrow_copy_assignable
1357 : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>,
1358 __add_lval_ref_t<const _Tp>>
1360 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1361 "template argument must be a complete class or an unbounded array");
1364 /// is_nothrow_move_assignable
1365 template<typename _Tp>
1366 struct is_nothrow_move_assignable
1367 : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>,
1368 __add_rval_ref_t<_Tp>>
1370 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1371 "template argument must be a complete class or an unbounded array");
1374 /// @
cond undocumented
1375 template<typename _Tp, typename... _Args>
1376 using __is_trivially_constructible_impl
1377 = __bool_constant<__is_trivially_constructible(_Tp, _Args...)>;
1380 /// is_trivially_constructible
1381 template<typename _Tp, typename... _Args>
1382 struct is_trivially_constructible
1383 : public __is_trivially_constructible_impl<_Tp, _Args...>
1385 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1386 "template argument must be a complete class or an unbounded array");
1389 /// is_trivially_default_constructible
1390 template<typename _Tp>
1391 struct is_trivially_default_constructible
1392 : public __is_trivially_constructible_impl<_Tp>
1394 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1395 "template argument must be a complete class or an unbounded array");
1398#if __cpp_variable_templates && __cpp_concepts
1399 template<typename _Tp>
1400 constexpr bool __is_implicitly_default_constructible_v
1401 = requires (void(&__f)(_Tp)) {
__f({}
); };
1403 template<typename _Tp>
1404 struct __is_implicitly_default_constructible
1405 : __bool_constant<__is_implicitly_default_constructible_v<_Tp>>
1408 struct __do_is_implicitly_default_constructible_impl
1410 template <typename _Tp>
1411 static void __helper(const _Tp&);
1413 template <typename _Tp>
1414 static true_type __test(const _Tp&,
1415 decltype(__helper<const _Tp&>({}
))* = 0);
1417 static false_type __test(...);
1420 template<typename _Tp>
1421 struct __is_implicitly_default_constructible_impl
1422 : public __do_is_implicitly_default_constructible_impl
1424 using type = decltype(__test(declval<_Tp>()));
1427 template<typename _Tp>
1428 struct __is_implicitly_default_constructible_safe
1429 : public __is_implicitly_default_constructible_impl<_Tp>::type
1432 template <typename _Tp>
1433 struct __is_implicitly_default_constructible
1434 : public __and_<__is_constructible_impl<_Tp>,
1435 __is_implicitly_default_constructible_safe<_Tp>>::type
1439 /// is_trivially_copy_constructible
1440 template<typename _Tp>
1441 struct is_trivially_copy_constructible
1442 : public __is_trivially_constructible_impl<_Tp, __add_lval_ref_t<const _Tp>>
1444 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1445 "template argument must be a complete class or an unbounded array");
1448 /// is_trivially_move_constructible
1449 template<typename _Tp>
1450 struct is_trivially_move_constructible
1451 : public __is_trivially_constructible_impl<_Tp, __add_rval_ref_t<_Tp>>
1453 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1454 "template argument must be a complete class or an unbounded array");
1457 /// @
cond undocumented
1458 template<typename _Tp, typename _Up>
1459 using __is_trivially_assignable_impl
1460 = __bool_constant<__is_trivially_assignable(_Tp, _Up)>;
1463 /// is_trivially_assignable
1464 template<typename _Tp, typename _Up>
1465 struct is_trivially_assignable
1466 : public __is_trivially_assignable_impl<_Tp, _Up>
1468 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1469 "template argument must be a complete class or an unbounded array");
1472 /// is_trivially_copy_assignable
1473 template<typename _Tp>
1474 struct is_trivially_copy_assignable
1475 : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>,
1476 __add_lval_ref_t<const _Tp>>
1478 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1479 "template argument must be a complete class or an unbounded array");
1482 /// is_trivially_move_assignable
1483 template<typename _Tp>
1484 struct is_trivially_move_assignable
1485 : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>,
1486 __add_rval_ref_t<_Tp>>
1488 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1489 "template argument must be a complete class or an unbounded array");
1492#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_trivially_destructible)
1493 /// is_trivially_destructible
1494 template<typename _Tp>
1495 struct is_trivially_destructible
1496 : public __bool_constant<__is_trivially_destructible(_Tp)>
1499 /// is_trivially_destructible
1500 template<typename _Tp>
1501 struct is_trivially_destructible
1502 : public __and_<__is_destructible_safe<_Tp>,
1503 __bool_constant<__has_trivial_destructor(_Tp)>>::type
1505 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1506 "template argument must be a complete class or an unbounded array");
1510 /// has_virtual_destructor
1511 template<typename _Tp>
1512 struct has_virtual_destructor
1513 : public __bool_constant<__has_virtual_destructor(_Tp)>
1515 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1516 "template argument must be a complete class or an unbounded array");
1520 // type property queries.
1523 template<typename _Tp>
1525 : public integral_constant<std::size_t, alignof(_Tp)>
1527 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
1528 "template argument must be a complete class or an unbounded array");
1532#if _GLIBCXX_USE_BUILTIN_TRAIT(__array_rank) \
1533 && (!defined(__clang__) || __clang_major__ >= 20) // PR118559
1534 template<typename _Tp>
1536 : public integral_constant<std::size_t, __array_rank(_Tp)> { };
1540 : public integral_constant<std::size_t, 0> { };
1542 template<typename _Tp, std::size_t _Size>
1543 struct rank<_Tp[
_Size]
>
1544 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1546 template<typename _Tp>
1548 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1552 template<typename, unsigned _Uint = 0>
1554 : public integral_constant<size_t, 0> { };
1556 template<typename _Tp, size_t _Size>
1557 struct extent<_Tp[
_Size]
, 0>
1558 : public integral_constant<size_t, _Size> { };
1560 template<typename _Tp, unsigned _Uint, size_t _Size>
1561 struct extent<_Tp[
_Size]
, _Uint>
1562 : public extent<_Tp, _Uint - 1>::type { };
1564 template<typename _Tp>
1565 struct extent<_Tp[]
, 0>
1566 : public integral_constant<size_t, 0> { };
1568 template<typename _Tp, unsigned _Uint>
1569 struct extent<_Tp[]
, _Uint>
1570 : public extent<_Tp, _Uint - 1>::type { };
1576#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
1577 template<typename _Tp, typename _Up>
1579 : public __bool_constant<__is_same(_Tp, _Up)>
1582 template<typename _Tp, typename _Up>
1587 template<typename _Tp>
1588 struct is_same<_Tp, _Tp>
1594 template<typename _Base, typename _Derived>
1596 : public __bool_constant<__is_base_of(_Base, _Derived)>
1599#ifdef __cpp_lib_is_virtual_base_of // C++ >= 26
1600 /// is_virtual_base_of
1602 template<typename _Base, typename _Derived>
1603 struct is_virtual_base_of
1604 : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)>
1608#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible)
1609 template<typename _From, typename _To>
1610 struct is_convertible
1611 : public __bool_constant<__is_convertible(_From, _To)>
1614 template<typename _From, typename _To,
1615 bool = __or_<is_void<_From>, is_function<_To>,
1616 is_array<_To>>::value>
1617 struct __is_convertible_helper
1619 using type = typename is_void<_To>::type;
1622#pragma GCC diagnostic push
1623#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
1624 template<typename _From, typename _To>
1625 class __is_convertible_helper<_From, _To, false>
1627 template<typename _To1>
1628 static void __test_aux(_To1) noexcept;
1630 template<typename _From1, typename _To1,
1631 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1635 template<typename, typename>
1640 using type = decltype(__test<_From, _To>(0));
1642#pragma GCC diagnostic pop
1645 template<typename _From, typename _To>
1646 struct is_convertible
1647 : public __is_convertible_helper<_From, _To>::type
1651 // helper trait for unique_ptr<T[]
>, shared_ptr<T[]
>, and span<T, N>
1652 template<typename _ToElementType, typename _FromElementType>
1653 using __is_array_convertible
1654 = is_convertible<_FromElementType(*)[]
, _ToElementType(*)[]
>;
1656#ifdef __cpp_lib_is_nothrow_convertible // C++ >= 20
1658#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_convertible)
1659 /// is_nothrow_convertible_v
1660 template<typename _From, typename _To>
1661 inline constexpr bool is_nothrow_convertible_v
1662 = __is_nothrow_convertible(_From, _To);
1664 /// is_nothrow_convertible
1665 template<typename _From, typename _To>
1666 struct is_nothrow_convertible
1667 : public bool_constant<is_nothrow_convertible_v<_From, _To>>
1670 template<typename _From, typename _To,
1671 bool = __or_<is_void<_From>, is_function<_To>,
1672 is_array<_To>>::value>
1673 struct __is_nt_convertible_helper
1677#pragma GCC diagnostic push
1678#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
1679 template<typename _From, typename _To>
1680 class __is_nt_convertible_helper<_From, _To, false>
1682 template<typename _To1>
1683 static void __test_aux(_To1) noexcept;
1685 template<typename _From1, typename _To1>
1687 __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))>
1690 template<typename, typename>
1695 using type = decltype(__test<_From, _To>(0));
1697#pragma GCC diagnostic pop
1699 /// is_nothrow_convertible
1700 template<typename _From, typename _To>
1701 struct is_nothrow_convertible
1702 : public __is_nt_convertible_helper<_From, _To>::type
1705 /// is_nothrow_convertible_v
1706 template<typename _From, typename _To>
1707 inline constexpr bool is_nothrow_convertible_v
1708 = is_nothrow_convertible<_From, _To>::value;
1710#endif // __cpp_lib_is_nothrow_convertible
1712#pragma GCC diagnostic push
1713#pragma GCC diagnostic ignored "-Wc++14-extensions" // for variable templates
1714 template<typename _Tp, typename... _Args>
1715 struct __is_nothrow_new_constructible_impl
1717 noexcept(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))
1721 template<typename _Tp, typename... _Args>
1722 _GLIBCXX17_INLINE constexpr bool __is_nothrow_new_constructible
1723 = __and_<is_constructible<_Tp, _Args...>,
1724 __is_nothrow_new_constructible_impl<_Tp, _Args...>>::value;
1725#pragma GCC diagnostic pop
1727 // Const-volatile modifications.
1730 template<typename _Tp>
1732 {
using type = _Tp; };
1734 template<typename _Tp>
1735 struct remove_const<_Tp const>
1736 {
using type = _Tp; };
1739 template<typename _Tp>
1740 struct remove_volatile
1741 {
using type = _Tp; };
1743 template<typename _Tp>
1744 struct remove_volatile<_Tp volatile>
1745 {
using type = _Tp; };
1748#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cv)
1749 template<typename _Tp>
1751 {
using type = __remove_cv(_Tp); };
1753 template<typename _Tp>
1755 {
using type = _Tp; };
1757 template<typename _Tp>
1758 struct remove_cv<const _Tp>
1759 {
using type = _Tp; };
1761 template<typename _Tp>
1762 struct remove_cv<volatile _Tp>
1763 {
using type = _Tp; };
1765 template<typename _Tp>
1766 struct remove_cv<const volatile _Tp>
1767 {
using type = _Tp; };
1771 template<typename _Tp>
1773 {
using type = _Tp const; };
1776 template<typename _Tp>
1778 {
using type = _Tp volatile; };
1781 template<typename _Tp>
1783 {
using type = _Tp const volatile; };
1785#ifdef __cpp_lib_transformation_trait_aliases // C++ >= 14
1786 /// Alias template for remove_const
1787 template<typename _Tp>
1788 using remove_const_t = typename remove_const<_Tp>::type;
1790 /// Alias template for remove_volatile
1791 template<typename _Tp>
1792 using remove_volatile_t = typename remove_volatile<_Tp>::type;
1794 /// Alias template for remove_cv
1795 template<typename _Tp>
1796 using remove_cv_t = typename remove_cv<_Tp>::type;
1798 /// Alias template for add_const
1799 template<typename _Tp>
1800 using add_const_t = typename add_const<_Tp>::type;
1802 /// Alias template for add_volatile
1803 template<typename _Tp>
1804 using add_volatile_t = typename add_volatile<_Tp>::type;
1806 /// Alias template for add_cv
1807 template<typename _Tp>
1808 using add_cv_t = typename add_cv<_Tp>::type;
1811 // Reference transformations.
1813 /// remove_reference
1814#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_reference)
1815 template<typename _Tp>
1816 struct remove_reference
1817 {
using type = __remove_reference(_Tp); };
1819 template<typename _Tp>
1820 struct remove_reference
1821 {
using type = _Tp; };
1823 template<typename _Tp>
1824 struct remove_reference<_Tp&>
1825 {
using type = _Tp; };
1827 template<typename _Tp>
1828 struct remove_reference<_Tp&&>
1829 {
using type = _Tp; };
1832 /// add_lvalue_reference
1833 template<typename _Tp>
1834 struct add_lvalue_reference
1835 {
using type = __add_lval_ref_t<_Tp>; };
1837 /// add_rvalue_reference
1838 template<typename _Tp>
1839 struct add_rvalue_reference
1840 {
using type = __add_rval_ref_t<_Tp>; };
1842#if __cplusplus > 201103L
1843 /// Alias template for remove_reference
1844 template<typename _Tp>
1845 using remove_reference_t = typename remove_reference<_Tp>::type;
1847 /// Alias template for add_lvalue_reference
1848 template<typename _Tp>
1849 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1851 /// Alias template for add_rvalue_reference
1852 template<typename _Tp>
1853 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1856 // Sign modifications.
1858 /// @
cond undocumented
1860 // Utility for constructing identically cv-qualified types.
1861 template<typename _Unqualified, bool _IsConst, bool _IsVol>
1862 struct __cv_selector;
1864 template<typename _Unqualified>
1865 struct __cv_selector<_Unqualified, false, false>
1866 {
using __type = _Unqualified; };
1868 template<typename _Unqualified>
1869 struct __cv_selector<_Unqualified, false, true>
1870 {
using __type = volatile _Unqualified; };
1872 template<typename _Unqualified>
1873 struct __cv_selector<_Unqualified, true, false>
1874 {
using __type = const _Unqualified; };
1876 template<typename _Unqualified>
1877 struct __cv_selector<_Unqualified, true, true>
1878 {
using __type = const volatile _Unqualified; };
1880 template<typename _Qualified, typename _Unqualified,
1881 bool _IsConst = is_const<_Qualified>::value,
1882 bool _IsVol = is_volatile<_Qualified>::value>
1883 class __match_cv_qualifiers
1885 using __match = __cv_selector<_Unqualified, _IsConst, _IsVol>;
1888 using __type = typename __match::__type;
1891 // Utility for finding the unsigned versions of signed integral types.
1892 template<typename _Tp>
1893 struct __make_unsigned
1894 {
using __type = _Tp; };
1897 struct __make_unsigned<char>
1898 {
using __type = unsigned char; };
1901 struct __make_unsigned<signed char>
1902 {
using __type = unsigned char; };
1905 struct __make_unsigned<short>
1906 {
using __type = unsigned short; };
1909 struct __make_unsigned<int>
1910 {
using __type = unsigned int; };
1913 struct __make_unsigned<long>
1914 {
using __type = unsigned long; };
1917 struct __make_unsigned<long long>
1918 {
using __type = unsigned long long; };
1920#if defined(__GLIBCXX_TYPE_INT_N_0)
1923 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1924 {
using __type = unsigned __GLIBCXX_TYPE_INT_N_0; };
1926#if defined(__GLIBCXX_TYPE_INT_N_1)
1929 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1930 {
using __type = unsigned __GLIBCXX_TYPE_INT_N_1; };
1932#if defined(__GLIBCXX_TYPE_INT_N_2)
1935 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1936 {
using __type = unsigned __GLIBCXX_TYPE_INT_N_2; };
1938#if defined(__GLIBCXX_TYPE_INT_N_3)
1941 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1942 {
using __type = unsigned __GLIBCXX_TYPE_INT_N_3; };
1944#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
1947 struct __make_unsigned<__int128>
1948 {
using __type = unsigned __int128; };
1951 // Select between integral and enum: not possible to be both.
1952 template<typename _Tp,
1953 bool _IsInt = is_integral<_Tp>::value,
1954 bool _IsEnum = __is_enum(_Tp)>
1955 class __make_unsigned_selector;
1957 template<typename _Tp>
1958 class __make_unsigned_selector<_Tp, true, false>
1960 using __unsigned_type
1961 = typename __make_unsigned<__remove_cv_t<_Tp>>::__type;
1965 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type;
1968 class __make_unsigned_selector_base
1971 template<typename...> struct _List { };
1973 template<typename _Tp, typename... _Up>
1974 struct _List<_Tp, _Up...> : _List<_Up...>
1975 {
static constexpr size_t __size = sizeof(_Tp); };
1977 template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
1980 template<size_t _Sz, typename _Uint, typename... _UInts>
1981 struct __select<_Sz, _List<_Uint, _UInts...>, true>
1982 {
using __type = _Uint; };
1984 template<size_t _Sz, typename _Uint, typename... _UInts>
1985 struct __select<_Sz, _List<_Uint, _UInts...>, false>
1986 : __select<_Sz, _List<_UInts...>>
1990 // Choose unsigned integer type with the smallest rank and same size as _Tp
1991 template<typename _Tp>
1992 class __make_unsigned_selector<_Tp, false, true>
1993 : __make_unsigned_selector_base
1995 // With -fshort-enums, an enum may be as small as a char.
1997 using _UInts = _List<unsigned char, unsigned short, unsigned int,
1998 unsigned long, unsigned long long
1999#ifdef __SIZEOF_INT128__
2004 using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type;
2008 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type;
2011 // wchar_t, char8_t, char16_t and char32_t are integral types but are
2012 // neither signed integer types nor unsigned integer types, so must be
2013 // transformed to the unsigned integer type with the smallest rank.
2014 // Use the partial specialization for enumeration types to do that.
2016 struct __make_unsigned<wchar_t>
2019 = typename __make_unsigned_selector<wchar_t, false, true>::__type;
2022#ifdef _GLIBCXX_USE_CHAR8_T
2024 struct __make_unsigned<char8_t>
2027 = typename __make_unsigned_selector<char8_t, false, true>::__type;
2032 struct __make_unsigned<char16_t>
2035 = typename __make_unsigned_selector<char16_t, false, true>::__type;
2039 struct __make_unsigned<char32_t>
2042 = typename __make_unsigned_selector<char32_t, false, true>::__type;
2046 // Given an integral/enum type, return the corresponding unsigned
2048 // Primary template.
2050 template<typename _Tp>
2051 struct make_unsigned
2052 {
using type = typename __make_unsigned_selector<_Tp>::__type; };
2054 // Integral, but don't define.
2055 template<> struct make_unsigned<bool>;
2056 template<> struct make_unsigned<bool const>;
2057 template<> struct make_unsigned<bool volatile>;
2058 template<> struct make_unsigned<bool const volatile>;
2060 /// @
cond undocumented
2062 // Utility for finding the signed versions of unsigned integral types.
2063 template<typename _Tp>
2064 struct __make_signed
2065 {
using __type = _Tp; };
2068 struct __make_signed<char>
2069 {
using __type = signed char; };
2072 struct __make_signed<unsigned char>
2073 {
using __type = signed char; };
2076 struct __make_signed<unsigned short>
2077 {
using __type = signed short; };
2080 struct __make_signed<unsigned int>
2081 {
using __type = signed int; };
2084 struct __make_signed<unsigned long>
2085 {
using __type = signed long; };
2088 struct __make_signed<unsigned long long>
2089 {
using __type = signed long long; };
2091#if defined(__GLIBCXX_TYPE_INT_N_0)
2094 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
2095 {
using __type = __GLIBCXX_TYPE_INT_N_0; };
2097#if defined(__GLIBCXX_TYPE_INT_N_1)
2100 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
2101 {
using __type = __GLIBCXX_TYPE_INT_N_1; };
2103#if defined(__GLIBCXX_TYPE_INT_N_2)
2106 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
2107 {
using __type = __GLIBCXX_TYPE_INT_N_2; };
2109#if defined(__GLIBCXX_TYPE_INT_N_3)
2112 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
2113 {
using __type = __GLIBCXX_TYPE_INT_N_3; };
2115#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
2118 struct __make_signed<unsigned __int128>
2119 {
using __type = __int128; };
2122 // Select between integral and enum: not possible to be both.
2123 template<typename _Tp,
2124 bool _IsInt = is_integral<_Tp>::value,
2125 bool _IsEnum = __is_enum(_Tp)>
2126 class __make_signed_selector;
2128 template<typename _Tp>
2129 class __make_signed_selector<_Tp, true, false>
2132 = typename __make_signed<__remove_cv_t<_Tp>>::__type;
2136 = typename __match_cv_qualifiers<_Tp, __signed_type>::__type;
2139 // Choose signed integer type with the smallest rank and same size as _Tp
2140 template<typename _Tp>
2141 class __make_signed_selector<_Tp, false, true>
2143 using __unsigned_type = typename __make_unsigned_selector<_Tp>::__type;
2146 using __type = typename __make_signed_selector<__unsigned_type>::__type;
2149 // wchar_t, char16_t and char32_t are integral types but are neither
2150 // signed integer types nor unsigned integer types, so must be
2151 // transformed to the signed integer type with the smallest rank.
2152 // Use the partial specialization for enumeration types to do that.
2154 struct __make_signed<wchar_t>
2157 = typename __make_signed_selector<wchar_t, false, true>::__type;
2160#if defined(_GLIBCXX_USE_CHAR8_T)
2162 struct __make_signed<char8_t>
2165 = typename __make_signed_selector<char8_t, false, true>::__type;
2170 struct __make_signed<char16_t>
2173 = typename __make_signed_selector<char16_t, false, true>::__type;
2177 struct __make_signed<char32_t>
2180 = typename __make_signed_selector<char32_t, false, true>::__type;
2184 // Given an integral/enum type, return the corresponding signed
2186 // Primary template.
2188 template<typename _Tp>
2190 {
using type = typename __make_signed_selector<_Tp>::__type; };
2192 // Integral, but don't define.
2193 template<> struct make_signed<bool>;
2194 template<> struct make_signed<bool const>;
2195 template<> struct make_signed<bool volatile>;
2196 template<> struct make_signed<bool const volatile>;
2198#if __cplusplus > 201103L
2199 /// Alias template for make_signed
2200 template<typename _Tp>
2201 using make_signed_t = typename make_signed<_Tp>::type;
2203 /// Alias template for make_unsigned
2204 template<typename _Tp>
2205 using make_unsigned_t = typename make_unsigned<_Tp>::type;
2208 // Array modifications.
2211#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_extent)
2212 template<typename _Tp>
2213 struct remove_extent
2214 {
using type = __remove_extent(_Tp); };
2216 template<typename _Tp>
2217 struct remove_extent
2218 {
using type = _Tp; };
2220 template<typename _Tp, std::size_t _Size>
2221 struct remove_extent<_Tp[
_Size]
>
2222 {
using type = _Tp; };
2224 template<typename _Tp>
2225 struct remove_extent<_Tp[]
>
2226 {
using type = _Tp; };
2229 /// remove_all_extents
2230#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_all_extents)
2231 template<typename _Tp>
2232 struct remove_all_extents
2233 {
using type = __remove_all_extents(_Tp); };
2235 template<typename _Tp>
2236 struct remove_all_extents
2237 {
using type = _Tp; };
2239 template<typename _Tp, std::size_t _Size>
2240 struct remove_all_extents<_Tp[
_Size]
>
2241 {
using type = typename remove_all_extents<_Tp>::type; };
2243 template<typename _Tp>
2244 struct remove_all_extents<_Tp[]
>
2245 {
using type = typename remove_all_extents<_Tp>::type; };
2248#if __cplusplus > 201103L
2249 /// Alias template for remove_extent
2250 template<typename _Tp>
2251 using remove_extent_t = typename remove_extent<_Tp>::type;
2253 /// Alias template for remove_all_extents
2254 template<typename _Tp>
2255 using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
2258 // Pointer modifications.
2261#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_pointer)
2262 template<typename _Tp>
2263 struct remove_pointer
2264 {
using type = __remove_pointer(_Tp); };
2266 template<typename _Tp, typename>
2267 struct __remove_pointer_helper
2268 {
using type = _Tp; };
2270 template<typename _Tp, typename _Up>
2271 struct __remove_pointer_helper<_Tp, _Up*>
2272 {
using type = _Up; };
2274 template<typename _Tp>
2275 struct remove_pointer
2276 : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>>
2281#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_pointer)
2282 template<typename _Tp>
2284 {
using type = __add_pointer(_Tp); };
2286 template<typename _Tp, typename = void>
2287 struct __add_pointer_helper
2288 {
using type = _Tp; };
2290 template<typename _Tp>
2291 struct __add_pointer_helper<_Tp, __void_t<_Tp*>>
2292 {
using type = _Tp*; };
2294 template<typename _Tp>
2296 : public __add_pointer_helper<_Tp>
2299 template<typename _Tp>
2300 struct add_pointer<_Tp&>
2301 {
using type = _Tp*; };
2303 template<typename _Tp>
2304 struct add_pointer<_Tp&&>
2305 {
using type = _Tp*; };
2308#if __cplusplus > 201103L
2309 /// Alias template for remove_pointer
2310 template<typename _Tp>
2311 using remove_pointer_t = typename remove_pointer<_Tp>::type;
2313 /// Alias template for add_pointer
2314 template<typename _Tp>
2315 using add_pointer_t = typename add_pointer<_Tp>::type;
2318 /// @
cond undocumented
2320 // Aligned to maximum fundamental alignment
2321 struct __attribute__((__aligned__)) __aligned_storage_max_align_t
2325 __aligned_storage_default_alignment([[
__maybe_unused__]]
size_t __len)
2327#if _GLIBCXX_INLINE_VERSION
2329 = integral_constant<size_t, alignof(__aligned_storage_max_align_t)>;
2331 return __len > (_Max_align::value / 2)
2333# if _GLIBCXX_USE_BUILTIN_TRAIT(__builtin_clzg)
2334 : 1 << (__SIZE_WIDTH__ - __builtin_clzg(__len - 1u));
2336 : 1 << (__LLONG_WIDTH__ - __builtin_clzll(__len - 1ull));
2339 // Returning a fixed value is incorrect, but kept for ABI compatibility.
2340 // XXX GLIBCXX_ABI Deprecated
2341 return alignof(__aligned_storage_max_align_t);
2347 * @
brief Aligned storage
2349 * The member typedef `
type`
is be a POD type suitable for use as
2350 * uninitialized storage for any object whose size is at most `
_Len`
2351 * and whose alignment is a divisor of `
_Align`
.
2353 * It is important to use the nested `
type`
as uninitialized storage,
2354 * not the `
std::aligned_storage`
type itself which is an empty class
2355 * with 1-byte alignment. So this is correct:
2357 * `
typename std::aligned_storage<sizeof(X), alignof(X)>::type m_xobj;`
2361 * `
std::aligned_storage<sizeof(X), alignof(X)> m_xobj;`
2363 * In C++14 and later `
std::aligned_storage_t<sizeof(X), alignof(X)>`
2364 * can be used to refer to the `
type`
member typedef.
2366 * The default value of _Align is supposed to be the most stringent
2367 * fundamental alignment requirement for any C++ object type whose size
2368 * is no greater than `
_Len`
(see [
basic.align]
in the C++ standard).
2370 * @
bug In this implementation the default value for _Align is always the
2371 * maximum fundamental alignment, i.e. `
alignof(max_align_t)`
, which is
2372 * incorrect. It should be an alignment value no greater than `
_Len`
.
2374 * @
deprecated Deprecated in C++23.
Uses can be replaced by an
2375 * array `
std::byte[
_Len]`
declared with `
alignas(_Align)`
.
2377 template<size_t _Len,
2378 size_t _Align = __aligned_storage_default_alignment(_Len)>
2380 _GLIBCXX23_DEPRECATED
2385 alignas(_Align) unsigned char __data[
_Len];
2389 template <typename... _Types>
2390 struct __strictest_alignment
2392 static const size_t _S_alignment = 0;
2393 static const size_t _S_size = 0;
2396 template <typename _Tp, typename... _Types>
2397 struct __strictest_alignment<_Tp, _Types...>
2399 static const size_t _S_alignment =
2400 alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment
2401 ?
alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment;
2402 static const size_t _S_size =
2403 sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size
2404 ?
sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size;
2407#pragma GCC diagnostic push
2408#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
2411 * @
brief Provide aligned storage for types.
2413 * [
meta.trans.other]
2415 * Provides aligned storage for any of the provided types of at
2418 * @
see aligned_storage
2420 * @
deprecated Deprecated in C++23.
2422 template <size_t _Len, typename... _Types>
2424 _GLIBCXX23_DEPRECATED
2428 static_assert(sizeof...(_Types) != 0, "At least one type is required");
2430 using __strictest = __strictest_alignment<_Types...>;
2431 static const size_t _S_len = _Len > __strictest::_S_size
2432 ?
_Len : __strictest::_S_size;
2434 /// The value of the strictest alignment of _Types.
2435 static const size_t alignment_value = __strictest::_S_alignment;
2437 using type = typename aligned_storage<_S_len, alignment_value>::type;
2440 template <size_t _Len, typename... _Types>
2441 const size_t aligned_union<_Len, _Types...>::alignment_value;
2442#pragma GCC diagnostic pop
2444 /// @
cond undocumented
2446#if _GLIBCXX_USE_BUILTIN_TRAIT(__decay)
2447 template<typename _Tp>
2449 {
using type = __decay(_Tp); };
2451 // Decay trait for arrays and functions, used for perfect forwarding
2452 // in make_pair, make_tuple, etc.
2453 template<typename _Up>
2454 struct __decay_selector
2455 : __conditional_t<is_const<const _Up>::value, // false for functions
2456 remove_cv<_Up>, // N.B. DR 705.
2457 add_pointer<_Up>> // function decays to pointer
2460 template<typename _Up, size_t _Nm>
2461 struct __decay_selector<_Up[
_Nm]
>
2462 {
using type = _Up*; };
2464 template<typename _Up>
2465 struct __decay_selector<_Up[]
>
2466 {
using type = _Up*; };
2471 template<typename _Tp>
2473 {
using type = typename __decay_selector<_Tp>::type; };
2475 template<typename _Tp>
2477 {
using type = typename __decay_selector<_Tp>::type; };
2479 template<typename _Tp>
2481 {
using type = typename __decay_selector<_Tp>::type; };
2484 /// @
cond undocumented
2486 // Helper which adds a reference to a type when given a reference_wrapper
2487 template<typename _Tp>
2488 struct __strip_reference_wrapper
2493 template<typename _Tp>
2494 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
2496 using __type = _Tp&;
2499 // __decay_t (std::decay_t for C++11).
2500 template<typename _Tp>
2501 using __decay_t = typename decay<_Tp>::type;
2503 template<typename _Tp>
2504 using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>;
2507 /// @
cond undocumented
2509 // Helper for SFINAE constraints
2510 template<typename... _Cond>
2511 using _Require = __enable_if_t<__and_<_Cond...>::value>;
2513 // __remove_cvref_t (std::remove_cvref_t for C++11).
2514 template<typename _Tp>
2515 using __remove_cvref_t
2516 = typename remove_cv<typename remove_reference<_Tp>::type>::type;
2519 // Primary template.
2520 /// Define a member typedef @
c type to one of two argument types.
2521 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2523 {
using type = _Iftrue; };
2525 // Partial specialization for false.
2526 template<typename _Iftrue, typename _Iffalse>
2527 struct conditional<false, _Iftrue, _Iffalse>
2528 {
using type = _Iffalse; };
2531 template<typename... _Tp>
2534 // Sfinae-friendly common_type implementation:
2536 /// @
cond undocumented
2538 // For several sfinae-friendly trait implementations we transport both the
2539 // result information (as the member type) and the failure information (no
2540 // member type). This is very similar to std::enable_if, but we cannot use
2541 // that, because we need to derive from them as an implementation detail.
2543 template<typename _Tp>
2544 struct __success_type
2545 {
using type = _Tp; };
2547 struct __failure_type
2550 struct __do_common_type_impl
2552 template<typename _Tp, typename _Up>
2554 = decltype(true ?
std::declval<_Tp>() : std::declval<_Up>());
2556 // if decay_t<decltype(false ?
declval<D1>() : declval<D2>())>
2557 // denotes a valid type, let C denote that type.
2558 template<typename _Tp, typename _Up>
2559 static __success_type<__decay_t<__cond_t<_Tp, _Up>>>
2562#if __cplusplus > 201703L
2563 // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type,
2564 // let C denote the type decay_t<COND-RES(CREF(D1), CREF(D2))>.
2565 template<typename _Tp, typename _Up>
2566 static __success_type<__remove_cvref_t<__cond_t<const _Tp&, const _Up&>>>
2570 template<typename, typename>
2571 static __failure_type
2574 template<typename _Tp, typename _Up>
2575 static decltype(_S_test_2<_Tp, _Up>(0))
2579 // If sizeof...(T) is zero, there shall be no member type.
2581 struct common_type<>
2584 // If sizeof...(T) is one, the same type, if any, as common_type_t<T0, T0>.
2585 template<typename _Tp0>
2586 struct common_type<_Tp0>
2587 : public common_type<_Tp0, _Tp0>
2590 // If sizeof...(T) is two, ...
2591 template<typename _Tp1, typename _Tp2,
2592 typename _Dp1 = __decay_t<_Tp1>, typename _Dp2 = __decay_t<_Tp2>>
2593 struct __common_type_impl
2595 // If is_same_v<T1, D1> is false or is_same_v<T2, D2> is false,
2596 // let C denote the same type, if any, as common_type_t<D1, D2>.
2597 using type = common_type<_Dp1, _Dp2>;
2600 template<typename _Tp1, typename _Tp2>
2601 struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2>
2602 : private __do_common_type_impl
2604 // Otherwise, if decay_t<decltype(false ?
declval<D1>() : declval<D2>())>
2605 // denotes a valid type, let C denote that type.
2606 using type = decltype(_S_test<_Tp1, _Tp2>(0));
2609 // If sizeof...(T) is two, ...
2610 template<typename _Tp1, typename _Tp2>
2611 struct common_type<_Tp1, _Tp2>
2612 : public __common_type_impl<_Tp1, _Tp2>::type
2615 template<typename...>
2616 struct __common_type_pack
2619 template<typename, typename, typename = void>
2620 struct __common_type_fold;
2622 // If sizeof...(T) is greater than two, ...
2623 template<typename _Tp1, typename _Tp2, typename... _Rp>
2624 struct common_type<_Tp1, _Tp2, _Rp...>
2625 : public __common_type_fold<common_type<_Tp1, _Tp2>,
2626 __common_type_pack<_Rp...>>
2629 // Let C denote the same type, if any, as common_type_t<T1, T2>.
2630 // If there is such a type C, type shall denote the same type, if any,
2631 // as common_type_t<C, R...>.
2632 template<typename _CTp, typename... _Rp>
2633 struct __common_type_fold<_CTp, __common_type_pack<_Rp...>,
2634 __void_t<typename _CTp::type>>
2635 : public common_type<typename _CTp::type, _Rp...>
2638 // Otherwise, there shall be no member type.
2639 template<typename _CTp, typename _Rp>
2640 struct __common_type_fold<_CTp, _Rp, void>
2643 template<typename _Tp, bool = __is_enum(_Tp)>
2644 struct __underlying_type_impl
2646 using type = __underlying_type(_Tp);
2649 template<typename _Tp>
2650 struct __underlying_type_impl<_Tp, false>
2654 /// The underlying type of an enum.
2655 template<typename _Tp>
2656 struct underlying_type
2657 : public __underlying_type_impl<_Tp>
2660 /// @
cond undocumented
2661 template<typename _Tp>
2662 struct __declval_protector
2664 static const bool __stop = false;
2668 /** Utility to simplify expressions used in unevaluated operands
2670 * @
ingroup utilities
2672 template<typename _Tp>
2673 auto declval() noexcept -> decltype(__declval<_Tp>(0))
2675 static_assert(__declval_protector<_Tp>::__stop,
2676 "declval() must not be used!");
2677 return __declval<_Tp>(0);
2681 template<typename _Signature>
2684 // Sfinae-friendly result_of implementation:
2686 /// @
cond undocumented
2687 struct __invoke_memfun_ref { };
2688 struct __invoke_memfun_deref { };
2689 struct __invoke_memobj_ref { };
2690 struct __invoke_memobj_deref { };
2691 struct __invoke_other { };
2693 // Associate a tag type with a specialization of __success_type.
2694 template<typename _Tp, typename _Tag>
2695 struct __result_of_success : __success_type<_Tp>
2696 {
using __invoke_type = _Tag; };
2698 // [
func.require]
paragraph 1 bullet 1:
2699 struct __result_of_memfun_ref_impl
2701 template<typename _Fp, typename _Tp1, typename... _Args>
2702 static __result_of_success<decltype(
2703 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
2704 ), __invoke_memfun_ref> _S_test(int);
2706 template<typename...>
2707 static __failure_type _S_test(...);
2710 template<typename _MemPtr, typename _Arg, typename... _Args>
2711 struct __result_of_memfun_ref
2712 : private __result_of_memfun_ref_impl
2714 using type = decltype(_S_test<_MemPtr, _Arg, _Args...>(0));
2717 // [
func.require]
paragraph 1 bullet 2:
2718 struct __result_of_memfun_deref_impl
2720 template<typename _Fp, typename _Tp1, typename... _Args>
2721 static __result_of_success<decltype(
2722 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
2723 ), __invoke_memfun_deref> _S_test(int);
2725 template<typename...>
2726 static __failure_type _S_test(...);
2729 template<typename _MemPtr, typename _Arg, typename... _Args>
2730 struct __result_of_memfun_deref
2731 : private __result_of_memfun_deref_impl
2733 using type = decltype(_S_test<_MemPtr, _Arg, _Args...>(0));
2736 // [
func.require]
paragraph 1 bullet 3:
2737 struct __result_of_memobj_ref_impl
2739 template<typename _Fp, typename _Tp1>
2740 static __result_of_success<decltype(
2741 std::declval<_Tp1>().*std::declval<_Fp>()
2742 ), __invoke_memobj_ref> _S_test(int);
2744 template<typename, typename>
2745 static __failure_type _S_test(...);
2748 template<typename _MemPtr, typename _Arg>
2749 struct __result_of_memobj_ref
2750 : private __result_of_memobj_ref_impl
2752 using type = decltype(_S_test<_MemPtr, _Arg>(0));
2755 // [
func.require]
paragraph 1 bullet 4:
2756 struct __result_of_memobj_deref_impl
2758 template<typename _Fp, typename _Tp1>
2759 static __result_of_success<decltype(
2760 (*std::declval<_Tp1>()).*std::declval<_Fp>()
2761 ), __invoke_memobj_deref> _S_test(int);
2763 template<typename, typename>
2764 static __failure_type _S_test(...);
2767 template<typename _MemPtr, typename _Arg>
2768 struct __result_of_memobj_deref
2769 : private __result_of_memobj_deref_impl
2771 using type = decltype(_S_test<_MemPtr, _Arg>(0));
2774 template<typename _MemPtr, typename _Arg>
2775 struct __result_of_memobj;
2777 template<typename _Res, typename _Class, typename _Arg>
2778 struct __result_of_memobj<_Res _Class::*, _Arg>
2780 using _Argval = __remove_cvref_t<_Arg>;
2781 using _MemPtr = _Res _Class::*;
2782 using type = typename __conditional_t<__or_<is_same<_Argval, _Class>,
2783 is_base_of<_Class, _Argval>>::value,
2784 __result_of_memobj_ref<_MemPtr, _Arg>,
2785 __result_of_memobj_deref<_MemPtr, _Arg>
2789 template<typename _MemPtr, typename _Arg, typename... _Args>
2790 struct __result_of_memfun;
2792 template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2793 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
2795 using _Argval = typename remove_reference<_Arg>::type;
2796 using _MemPtr = _Res _Class::*;
2797 using type = typename __conditional_t<is_base_of<_Class, _Argval>::value,
2798 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
2799 __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
2803 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2804 // 2219.
INVOKE-ing a pointer to member with a reference_wrapper
2805 // as the object expression
2807 // Used by result_of, invoke etc. to unwrap a reference_wrapper.
2808 template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>>
2814 template<typename _Tp, typename _Up>
2815 struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2820 template<bool, bool, typename _Functor, typename... _ArgTypes>
2821 struct __result_of_impl
2823 using type = __failure_type;
2826 template<typename _MemPtr, typename _Arg>
2827 struct __result_of_impl<true, false, _MemPtr, _Arg>
2828 : public __result_of_memobj<__decay_t<_MemPtr>,
2829 typename __inv_unwrap<_Arg>::type>
2832 template<typename _MemPtr, typename _Arg, typename... _Args>
2833 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2834 : public __result_of_memfun<__decay_t<_MemPtr>,
2835 typename __inv_unwrap<_Arg>::type, _Args...>
2838 // [
func.require]
paragraph 1 bullet 5:
2839 struct __result_of_other_impl
2841 template<typename _Fn, typename... _Args>
2842 static __result_of_success<decltype(
2843 std::declval<_Fn>()(std::declval<_Args>()...)
2844 ), __invoke_other> _S_test(int);
2846 template<typename...>
2847 static __failure_type _S_test(...);
2850 template<typename _Functor, typename... _ArgTypes>
2851 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2852 : private __result_of_other_impl
2854 using type = decltype(_S_test<_Functor, _ArgTypes...>(0));
2857 // __invoke_result (std::invoke_result for C++11)
2858 template<typename _Functor, typename... _ArgTypes>
2859 struct __invoke_result
2860 : public __result_of_impl<
2861 is_member_object_pointer<
2862 typename remove_reference<_Functor>::type
2864 is_member_function_pointer<
2865 typename remove_reference<_Functor>::type
2867 _Functor, _ArgTypes...
2871 // __invoke_result_t (std::invoke_result_t for C++11)
2872 template<typename _Fn, typename... _Args>
2873 using __invoke_result_t = typename __invoke_result<_Fn, _Args...>::type;
2876 template<typename _Functor, typename... _ArgTypes>
2877 struct result_of<_Functor(_ArgTypes...)>
2878 : public __invoke_result<_Functor, _ArgTypes...>
2879 { }
_GLIBCXX17_DEPRECATED_SUGGEST("std::invoke_result");
2881#if __cplusplus >= 201402L
2882#pragma GCC diagnostic push
2883#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
2884 /// Alias template for aligned_storage
2885 template<size_t _Len,
2886 size_t _Align = __aligned_storage_default_alignment(_Len)>
2887 using aligned_storage_t _GLIBCXX23_DEPRECATED = typename aligned_storage<_Len, _Align>::type;
2889 template <size_t _Len, typename... _Types>
2890 using aligned_union_t _GLIBCXX23_DEPRECATED = typename aligned_union<_Len, _Types...>::type;
2891#pragma GCC diagnostic pop
2893 /// Alias template for decay
2894 template<typename _Tp>
2895 using decay_t = typename decay<_Tp>::type;
2897 /// Alias template for enable_if
2898 template<bool _Cond, typename _Tp = void>
2899 using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2901 /// Alias template for conditional
2902 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2903 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2905 /// Alias template for common_type
2906 template<typename... _Tp>
2907 using common_type_t = typename common_type<_Tp...>::type;
2909 /// Alias template for underlying_type
2910 template<typename _Tp>
2911 using underlying_type_t = typename underlying_type<_Tp>::type;
2913 /// Alias template for result_of
2914 template<typename _Tp>
2915 using result_of_t = typename result_of<_Tp>::type;
2918#ifdef __cpp_lib_void_t // C++ >= 17 || GNU++ >= 11
2919 /// A metafunction that always yields void, used for detecting valid types.
2920 template<typename...> using void_t = void;
2923 /// @
cond undocumented
2926 // Detect whether _Op<_Args...> is a valid type, use default _Def if not.
2929 // Implementation of the detection idiom (negative case).
2930 template<typename _Def, template<typename...> class _Op, typename... _Args>
2931 struct __detected_or
2934 using __is_detected = false_type;
2937 // Implementation of the detection idiom (positive case).
2938 template<typename _Def, template<typename...> class _Op, typename... _Args>
2939 requires requires {
typename _Op<_Args...>; }
2940 struct __detected_or<_Def, _Op, _Args...>
2942 using type = _Op<_Args...>;
2943 using __is_detected = true_type;
2946 /// Implementation of the detection idiom (negative case).
2947 template<typename _Default, typename _AlwaysVoid,
2948 template<typename...> class _Op, typename... _Args>
2951 using type = _Default;
2952 using __is_detected = false_type;
2955 /// Implementation of the detection idiom (positive case).
2956 template<typename _Default, template<typename...> class _Op,
2958 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2960 using type = _Op<_Args...>;
2961 using __is_detected = true_type;
2964 template<typename _Default, template<typename...> class _Op,
2966 using __detected_or = __detector<_Default, void, _Op, _Args...>;
2967#endif // __cpp_concepts
2969 // _Op<_Args...> if that is a valid type, otherwise _Default.
2970 template<typename _Default, template<typename...> class _Op,
2972 using __detected_or_t
2973 = typename __detected_or<_Default, _Op, _Args...>::type;
2976 * Use SFINAE to determine if the type _Tp has a publicly-accessible
2977 * member type _NTYPE.
2979#define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2980 template<typename _Tp, typename = __void_t<>> \
2981 struct __has_##_NTYPE \
2984 template<typename _Tp> \
2985 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2989 template <typename _Tp>
2990 struct __is_swappable;
2992 template <typename _Tp>
2993 struct __is_nothrow_swappable;
2996 struct __is_tuple_like_impl : false_type
2999 // Internal type trait that allows us to sfinae-protect tuple_cat.
3000 template<typename _Tp>
3001 struct __is_tuple_like
3002 : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type
3006 template<typename _Tp>
3007 _GLIBCXX20_CONSTEXPR
3009 _Require<__not_<__is_tuple_like<_Tp>>,
3010 is_move_constructible<_Tp>,
3011 is_move_assignable<_Tp>>
3013 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
3014 is_nothrow_move_assignable<_Tp>>::value);
3016 template<typename _Tp, size_t _Nm>
3017 _GLIBCXX20_CONSTEXPR
3019 __enable_if_t<__is_swappable<_Tp>::value>
3020 swap(_Tp (&__a)[
_Nm]
, _Tp (&__b)[
_Nm]
)
3021 noexcept(__is_nothrow_swappable<_Tp>::value);
3023 /// @
cond undocumented
3024 namespace __swappable_details {
3027 struct __do_is_swappable_impl
3029 template<typename _Tp, typename
3030 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
3031 static true_type __test(int);
3034 static false_type __test(...);
3037 struct __do_is_nothrow_swappable_impl
3039 template<typename _Tp>
3040 static __bool_constant<
3041 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
3045 static false_type __test(...);
3048 }
// namespace __swappable_details
3050 template<typename _Tp>
3051 struct __is_swappable_impl
3052 : public __swappable_details::__do_is_swappable_impl
3054 using type = decltype(__test<_Tp>(0));
3057 template<typename _Tp>
3058 struct __is_nothrow_swappable_impl
3059 : public __swappable_details::__do_is_nothrow_swappable_impl
3061 using type = decltype(__test<_Tp>(0));
3064 template<typename _Tp>
3065 struct __is_swappable
3066 : public __is_swappable_impl<_Tp>::type
3069 template<typename _Tp>
3070 struct __is_nothrow_swappable
3071 : public __is_nothrow_swappable_impl<_Tp>::type
3075#ifdef __cpp_lib_is_swappable // C++ >= 17 || GNU++ >= 11
3076 /// Metafunctions used for detecting swappable types: p0185r1
3079 template<typename _Tp>
3081 : public __is_swappable_impl<_Tp>::type
3083 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
3084 "template argument must be a complete class or an unbounded array");
3087 /// is_nothrow_swappable
3088 template<typename _Tp>
3089 struct is_nothrow_swappable
3090 : public __is_nothrow_swappable_impl<_Tp>::type
3092 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
3093 "template argument must be a complete class or an unbounded array");
3096#if __cplusplus >= 201402L
3098 template<typename _Tp>
3099 _GLIBCXX17_INLINE constexpr bool is_swappable_v =
3100 is_swappable<_Tp>::value;
3102 /// is_nothrow_swappable_v
3103 template<typename _Tp>
3104 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v =
3105 is_nothrow_swappable<_Tp>::value;
3106#endif // __cplusplus >= 201402L
3108 /// @
cond undocumented
3109 namespace __swappable_with_details {
3112 struct __do_is_swappable_with_impl
3114 template<typename _Tp, typename _Up, typename
3115 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
3117 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
3118 static true_type __test(int);
3120 template<typename, typename>
3121 static false_type __test(...);
3124 struct __do_is_nothrow_swappable_with_impl
3126 template<typename _Tp, typename _Up>
3127 static __bool_constant<
3128 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
3130 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
3133 template<typename, typename>
3134 static false_type __test(...);
3137 }
// namespace __swappable_with_details
3139 template<typename _Tp, typename _Up>
3140 struct __is_swappable_with_impl
3141 : public __swappable_with_details::__do_is_swappable_with_impl
3143 using type = decltype(__test<_Tp, _Up>(0));
3146 // Optimization for the homogenous lvalue case, not required:
3147 template<typename _Tp>
3148 struct __is_swappable_with_impl<_Tp&, _Tp&>
3149 : public __swappable_details::__do_is_swappable_impl
3151 using type = decltype(__test<_Tp&>(0));
3154 template<typename _Tp, typename _Up>
3155 struct __is_nothrow_swappable_with_impl
3156 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
3158 using type = decltype(__test<_Tp, _Up>(0));
3161 // Optimization for the homogenous lvalue case, not required:
3162 template<typename _Tp>
3163 struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&>
3164 : public __swappable_details::__do_is_nothrow_swappable_impl
3166 using type = decltype(__test<_Tp&>(0));
3170 /// is_swappable_with
3171 template<typename _Tp, typename _Up>
3172 struct is_swappable_with
3173 : public __is_swappable_with_impl<_Tp, _Up>::type
3175 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
3176 "first template argument must be a complete class or an unbounded array");
3177 static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}
),
3178 "second template argument must be a complete class or an unbounded array");
3181 /// is_nothrow_swappable_with
3182 template<typename _Tp, typename _Up>
3183 struct is_nothrow_swappable_with
3184 : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type
3186 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
3187 "first template argument must be a complete class or an unbounded array");
3188 static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}
),
3189 "second template argument must be a complete class or an unbounded array");
3192#if __cplusplus >= 201402L
3193 /// is_swappable_with_v
3194 template<typename _Tp, typename _Up>
3195 _GLIBCXX17_INLINE constexpr bool is_swappable_with_v =
3196 is_swappable_with<_Tp, _Up>::value;
3198 /// is_nothrow_swappable_with_v
3199 template<typename _Tp, typename _Up>
3200 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v =
3201 is_nothrow_swappable_with<_Tp, _Up>::value;
3202#endif // __cplusplus >= 201402L
3204#endif // __cpp_lib_is_swappable
3206 /// @
cond undocumented
3208 // __is_invocable (std::is_invocable for C++11)
3210 // The primary template is used for invalid INVOKE expressions.
3211 template<typename _Result, typename _Ret,
3212 bool = is_void<_Ret>::value, typename = void>
3213 struct __is_invocable_impl
3216 using __nothrow_conv = false_type;
// For is_nothrow_invocable_r
3219 // Used for valid INVOKE and INVOKE<void> expressions.
3220 template<typename _Result, typename _Ret>
3221 struct __is_invocable_impl<_Result, _Ret,
3222 /* is_void<_Ret> = */ true,
3223 __void_t<typename _Result::type>>
3226 using __nothrow_conv = true_type;
// For is_nothrow_invocable_r
3229#pragma GCC diagnostic push
3230#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
3231 // Used for INVOKE<R> expressions to check the implicit conversion to R.
3232 template<typename _Result, typename _Ret>
3233 struct __is_invocable_impl<_Result, _Ret,
3234 /* is_void<_Ret> = */ false,
3235 __void_t<typename _Result::type>>
3238 // The type of the INVOKE expression.
3239 using _Res_t = typename _Result::type;
3241 // Unlike declval, this doesn't add_rvalue_reference, so it respects
3242 // guaranteed copy elision.
3243 static _Res_t _S_get() noexcept;
3245 // Used to check if _Res_t can implicitly convert to _Tp.
3246 template<typename _Tp>
3247 static void _S_conv(__type_identity_t<_Tp>) noexcept;
3249 // This overload is viable if INVOKE(f, args...) can convert to _Tp.
3250 template<typename _Tp,
3251 bool _Nothrow = noexcept(_S_conv<_Tp>(_S_get())),
3252 typename = decltype(_S_conv<_Tp>(_S_get())),
3253#if __has_builtin(__reference_converts_from_temporary)
3254 bool _Dangle = __reference_converts_from_temporary(_Tp, _Res_t)
3256 bool _Dangle = false
3259 static __bool_constant<_Nothrow && !_Dangle>
3262 template<typename _Tp, bool = false>
3267 // For is_invocable_r
3268 using type = decltype(_S_test<_Ret, /* Nothrow = */ true>(1));
3270 // For is_nothrow_invocable_r
3271 using __nothrow_conv = decltype(_S_test<_Ret>(1));
3273#pragma GCC diagnostic pop
3275 template<typename _Fn, typename... _ArgTypes>
3276 struct __is_invocable
3277#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable)
3278 : __bool_constant<__is_invocable(_Fn, _ArgTypes...)>
3280 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
3284 template<typename _Fn, typename _Tp, typename... _Args>
3285 constexpr bool __call_is_nt(__invoke_memfun_ref)
3287 using _Up = typename __inv_unwrap<_Tp>::type;
3288 return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
3289 std::declval<_Args>()...));
3292 template<typename _Fn, typename _Tp, typename... _Args>
3293 constexpr bool __call_is_nt(__invoke_memfun_deref)
3295 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
3296 std::declval<_Args>()...));
3299 template<typename _Fn, typename _Tp>
3300 constexpr bool __call_is_nt(__invoke_memobj_ref)
3302 using _Up = typename __inv_unwrap<_Tp>::type;
3303 return noexcept(std::declval<_Up>().*std::declval<_Fn>());
3306 template<typename _Fn, typename _Tp>
3307 constexpr bool __call_is_nt(__invoke_memobj_deref)
3309 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
3312 template<typename _Fn, typename... _Args>
3313 constexpr bool __call_is_nt(__invoke_other)
3315 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
3318 template<typename _Result, typename _Fn, typename... _Args>
3319 struct __call_is_nothrow
3321 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}
)
3325 template<typename _Fn, typename... _Args>
3326 using __call_is_nothrow_
3327 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>;
3329 // __is_nothrow_invocable (std::is_nothrow_invocable for C++11)
3330 template<typename _Fn, typename... _Args>
3331 struct __is_nothrow_invocable
3332#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable)
3333 : __bool_constant<__is_nothrow_invocable(_Fn, _Args...)>
3335 : __and_<__is_invocable<_Fn, _Args...>,
3336 __call_is_nothrow_<_Fn, _Args...>>::type
3340#pragma GCC diagnostic push
3341#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
3342 struct __nonesuchbase {};
3343 struct __nonesuch : private __nonesuchbase {
3344 ~__nonesuch() = delete;
3345 __nonesuch(__nonesuch const&) = delete;
3346 void operator=(__nonesuch const&) = delete;
3348#pragma GCC diagnostic pop
3351#ifdef __cpp_lib_is_invocable // C++ >= 17
3352 /// std::invoke_result
3353 template<typename _Functor, typename... _ArgTypes>
3354 struct invoke_result
3355 : public __invoke_result<_Functor, _ArgTypes...>
3357 static_assert(std::__is_complete_or_unbounded(__type_identity<_Functor>{}
),
3358 "_Functor must be a complete class or an unbounded array");
3359 static_assert((std::__is_complete_or_unbounded(
3360 __type_identity<_ArgTypes>{}
) && ...),
3361 "each argument type must be a complete class or an unbounded array");
3364 /// std::invoke_result_t
3365 template<typename _Fn, typename... _Args>
3366 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
3368 /// std::is_invocable
3369 template<typename _Fn, typename... _ArgTypes>
3371#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable)
3372 : public __bool_constant<__is_invocable(_Fn, _ArgTypes...)>
3374 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
3377 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}
),
3378 "_Fn must be a complete class or an unbounded array");
3379 static_assert((std::__is_complete_or_unbounded(
3380 __type_identity<_ArgTypes>{}
) && ...),
3381 "each argument type must be a complete class or an unbounded array");
3384 /// std::is_invocable_r
3385 template<typename _Ret, typename _Fn, typename... _ArgTypes>
3386 struct is_invocable_r
3387 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type
3389 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}
),
3390 "_Fn must be a complete class or an unbounded array");
3391 static_assert((std::__is_complete_or_unbounded(
3392 __type_identity<_ArgTypes>{}
) && ...),
3393 "each argument type must be a complete class or an unbounded array");
3394 static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}
),
3395 "_Ret must be a complete class or an unbounded array");
3398 /// std::is_nothrow_invocable
3399 template<typename _Fn, typename... _ArgTypes>
3400 struct is_nothrow_invocable
3401#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable)
3402 : public __bool_constant<__is_nothrow_invocable(_Fn, _ArgTypes...)>
3404 : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>,
3405 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
3408 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}
),
3409 "_Fn must be a complete class or an unbounded array");
3410 static_assert((std::__is_complete_or_unbounded(
3411 __type_identity<_ArgTypes>{}
) && ...),
3412 "each argument type must be a complete class or an unbounded array");
3415 /// @
cond undocumented
3416 // This checks that the INVOKE<R> expression is well-formed and that the
3417 // conversion to R does not throw. It does *not* check whether the INVOKE
3418 // expression itself can throw. That is done by __call_is_nothrow_ instead.
3419 template<typename _Result, typename _Ret>
3420 using __is_nt_invocable_impl
3421 = typename __is_invocable_impl<_Result, _Ret>::__nothrow_conv;
3424 /// std::is_nothrow_invocable_r
3425 template<typename _Ret, typename _Fn, typename... _ArgTypes>
3426 struct is_nothrow_invocable_r
3427 : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>,
3428 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
3430 static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}
),
3431 "_Fn must be a complete class or an unbounded array");
3432 static_assert((std::__is_complete_or_unbounded(
3433 __type_identity<_ArgTypes>{}
) && ...),
3434 "each argument type must be a complete class or an unbounded array");
3435 static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}
),
3436 "_Ret must be a complete class or an unbounded array");
3438#endif // __cpp_lib_is_invocable
3440#if __cpp_lib_type_trait_variable_templates // C++ >= 17
3442 * @
defgroup variable_templates Variable templates for type traits
3443 * @
ingroup metaprogramming
3445 * Each variable `
is_xxx_v<T>`
is a boolean constant with the same value
3446 * as the `
value`
member of the corresponding type trait `
is_xxx<T>`
.
3448 * @
since C++17 unless noted otherwise.
3453 * @
ingroup variable_templates
3455template <typename _Tp>
3456 inline constexpr bool is_void_v = is_void<_Tp>::value;
3457template <typename _Tp>
3458 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
3459template <typename _Tp>
3460 inline constexpr bool is_integral_v = is_integral<_Tp>::value;
3461template <typename _Tp>
3462 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
3464#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_array)
3465template <typename _Tp>
3466 inline constexpr bool is_array_v = __is_array(_Tp);
3468template <typename _Tp>
3469 inline constexpr bool is_array_v = false;
3470template <typename _Tp>
3471 inline constexpr bool is_array_v<_Tp[]
> = true;
3472template <typename _Tp, size_t _Num>
3473 inline constexpr bool is_array_v<_Tp[
_Num]
> = true;
3476#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
3477template <typename _Tp>
3478 inline constexpr bool is_pointer_v = __is_pointer(_Tp);
3480template <typename _Tp>
3481 inline constexpr bool is_pointer_v = false;
3482template <typename _Tp>
3483 inline constexpr bool is_pointer_v<_Tp*> = true;
3484template <typename _Tp>
3485 inline constexpr bool is_pointer_v<_Tp* const> = true;
3486template <typename _Tp>
3487 inline constexpr bool is_pointer_v<_Tp* volatile> = true;
3488template <typename _Tp>
3489 inline constexpr bool is_pointer_v<_Tp* const volatile> = true;
3492template <typename _Tp>
3493 inline constexpr bool is_lvalue_reference_v = false;
3494template <typename _Tp>
3495 inline constexpr bool is_lvalue_reference_v<_Tp&> = true;
3496template <typename _Tp>
3497 inline constexpr bool is_rvalue_reference_v = false;
3498template <typename _Tp>
3499 inline constexpr bool is_rvalue_reference_v<_Tp&&> = true;
3501#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_object_pointer)
3502template <typename _Tp>
3503 inline constexpr bool is_member_object_pointer_v =
3504 __is_member_object_pointer(_Tp);
3506template <typename _Tp>
3507 inline constexpr bool is_member_object_pointer_v =
3508 is_member_object_pointer<_Tp>::value;
3511#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_function_pointer)
3512template <typename _Tp>
3513 inline constexpr bool is_member_function_pointer_v =
3514 __is_member_function_pointer(_Tp);
3516template <typename _Tp>
3517 inline constexpr bool is_member_function_pointer_v =
3518 is_member_function_pointer<_Tp>::value;
3521template <typename _Tp>
3522 inline constexpr bool is_enum_v = __is_enum(_Tp);
3523template <typename _Tp>
3524 inline constexpr bool is_union_v = __is_union(_Tp);
3525template <typename _Tp>
3526 inline constexpr bool is_class_v = __is_class(_Tp);
3527// is_function_v is defined below, after is_const_v.
3529#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference)
3530template <typename _Tp>
3531 inline constexpr bool is_reference_v = __is_reference(_Tp);
3533template <typename _Tp>
3534 inline constexpr bool is_reference_v = false;
3535template <typename _Tp>
3536 inline constexpr bool is_reference_v<_Tp&> = true;
3537template <typename _Tp>
3538 inline constexpr bool is_reference_v<_Tp&&> = true;
3541template <typename _Tp>
3542 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
3543template <typename _Tp>
3544 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
3546#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object)
3547template <typename _Tp>
3548 inline constexpr bool is_object_v = __is_object(_Tp);
3550template <typename _Tp>
3551 inline constexpr bool is_object_v = is_object<_Tp>::value;
3554template <typename _Tp>
3555 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
3556template <typename _Tp>
3557 inline constexpr bool is_compound_v = !is_fundamental_v<_Tp>;
3559#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_pointer)
3560template <typename _Tp>
3561 inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
3563template <typename _Tp>
3564 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
3567#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const)
3568template <typename _Tp>
3569 inline constexpr bool is_const_v = __is_const(_Tp);
3571template <typename _Tp>
3572 inline constexpr bool is_const_v = false;
3573template <typename _Tp>
3574 inline constexpr bool is_const_v<const _Tp> = true;
3577#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function)
3578template <typename _Tp>
3579 inline constexpr bool is_function_v = __is_function(_Tp);
3581template <typename _Tp>
3582 inline constexpr bool is_function_v = !is_const_v<const _Tp>;
3583template <typename _Tp>
3584 inline constexpr bool is_function_v<_Tp&> = false;
3585template <typename _Tp>
3586 inline constexpr bool is_function_v<_Tp&&> = false;
3589#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile)
3590template <typename _Tp>
3591 inline constexpr bool is_volatile_v = __is_volatile(_Tp);
3593template <typename _Tp>
3594 inline constexpr bool is_volatile_v = false;
3595template <typename _Tp>
3596 inline constexpr bool is_volatile_v<volatile _Tp> = true;
3599template <typename _Tp>
3600 _GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible_v && is_trivially_copyable_v")
3601 inline constexpr bool is_trivial_v = __is_trivial(_Tp);
3602template <typename _Tp>
3603 inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);
3604template <typename _Tp>
3605 inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp);
3606template <typename _Tp>
3607 _GLIBCXX20_DEPRECATED_SUGGEST("is_standard_layout_v && is_trivial_v")
3608 inline constexpr bool is_pod_v = __is_pod(_Tp);
3609template <typename _Tp>
3610 _GLIBCXX17_DEPRECATED
3611 inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);
3612template <typename _Tp>
3613 inline constexpr bool is_empty_v = __is_empty(_Tp);
3614template <typename _Tp>
3615 inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp);
3616template <typename _Tp>
3617 inline constexpr bool is_abstract_v = __is_abstract(_Tp);
3618template <typename _Tp>
3619 inline constexpr bool is_final_v = __is_final(_Tp);
3621template <typename _Tp>
3622 inline constexpr bool is_signed_v = is_signed<_Tp>::value;
3623template <typename _Tp>
3624 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
3626template <typename _Tp, typename... _Args>
3627 inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);
3628template <typename _Tp>
3629 inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
3630template <typename _Tp>
3631 inline constexpr bool is_copy_constructible_v
3632 = __is_constructible(_Tp, __add_lval_ref_t<const _Tp>);
3633template <typename _Tp>
3634 inline constexpr bool is_move_constructible_v
3635 = __is_constructible(_Tp, __add_rval_ref_t<_Tp>);
3637template <typename _Tp, typename _Up>
3638 inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Up);
3639template <typename _Tp>
3640 inline constexpr bool is_copy_assignable_v
3641 = __is_assignable(__add_lval_ref_t<_Tp>, __add_lval_ref_t<const _Tp>);
3642template <typename _Tp>
3643 inline constexpr bool is_move_assignable_v
3644 = __is_assignable(__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>);
3646#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_destructible)
3647template <typename _Tp>
3648 inline constexpr bool is_destructible_v = __is_destructible(_Tp);
3650template <typename _Tp>
3651 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
3654template <typename _Tp, typename... _Args>
3655 inline constexpr bool is_trivially_constructible_v
3656 = __is_trivially_constructible(_Tp, _Args...);
3657template <typename _Tp>
3658 inline constexpr bool is_trivially_default_constructible_v
3659 = __is_trivially_constructible(_Tp);
3660template <typename _Tp>
3661 inline constexpr bool is_trivially_copy_constructible_v
3662 = __is_trivially_constructible(_Tp, __add_lval_ref_t<const _Tp>);
3663template <typename _Tp>
3664 inline constexpr bool is_trivially_move_constructible_v
3665 = __is_trivially_constructible(_Tp, __add_rval_ref_t<_Tp>);
3667template <typename _Tp, typename _Up>
3668 inline constexpr bool is_trivially_assignable_v
3669 = __is_trivially_assignable(_Tp, _Up);
3670template <typename _Tp>
3671 inline constexpr bool is_trivially_copy_assignable_v
3672 = __is_trivially_assignable(__add_lval_ref_t<_Tp>,
3673 __add_lval_ref_t<const _Tp>);
3674template <typename _Tp>
3675 inline constexpr bool is_trivially_move_assignable_v
3676 = __is_trivially_assignable(__add_lval_ref_t<_Tp>,
3677 __add_rval_ref_t<_Tp>);
3679#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_trivially_destructible)
3680template <typename _Tp>
3681 inline constexpr bool is_trivially_destructible_v
3682 = __is_trivially_destructible(_Tp);
3684template <typename _Tp>
3685 inline constexpr bool is_trivially_destructible_v = false;
3687template <typename _Tp>
3688 requires (!is_reference_v<_Tp>) && requires (_Tp& __t) {
__t.~_Tp(); }
3689 inline constexpr bool is_trivially_destructible_v<_Tp>
3690 = __has_trivial_destructor(_Tp);
3691template <typename _Tp>
3692 inline constexpr bool is_trivially_destructible_v<_Tp&> = true;
3693template <typename _Tp>
3694 inline constexpr bool is_trivially_destructible_v<_Tp&&> = true;
3695template <typename _Tp, size_t _Nm>
3696 inline constexpr bool is_trivially_destructible_v<_Tp[
_Nm]
>
3697 = is_trivially_destructible_v<_Tp>;
3699template <typename _Tp>
3700 inline constexpr bool is_trivially_destructible_v =
3701 is_trivially_destructible<_Tp>::value;
3704template <typename _Tp, typename... _Args>
3705 inline constexpr bool is_nothrow_constructible_v
3706 = __is_nothrow_constructible(_Tp, _Args...);
3707template <typename _Tp>
3708 inline constexpr bool is_nothrow_default_constructible_v
3709 = __is_nothrow_constructible(_Tp);
3710template <typename _Tp>
3711 inline constexpr bool is_nothrow_copy_constructible_v
3712 = __is_nothrow_constructible(_Tp, __add_lval_ref_t<const _Tp>);
3713template <typename _Tp>
3714 inline constexpr bool is_nothrow_move_constructible_v
3715 = __is_nothrow_constructible(_Tp, __add_rval_ref_t<_Tp>);
3717template <typename _Tp, typename _Up>
3718 inline constexpr bool is_nothrow_assignable_v
3719 = __is_nothrow_assignable(_Tp, _Up);
3720template <typename _Tp>
3721 inline constexpr bool is_nothrow_copy_assignable_v
3722 = __is_nothrow_assignable(__add_lval_ref_t<_Tp>,
3723 __add_lval_ref_t<const _Tp>);
3724template <typename _Tp>
3725 inline constexpr bool is_nothrow_move_assignable_v
3726 = __is_nothrow_assignable(__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>);
3728#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_destructible)
3729template <typename _Tp>
3730 inline constexpr bool is_nothrow_destructible_v
3731 = __is_nothrow_destructible(_Tp);
3733template <typename _Tp>
3734 inline constexpr bool is_nothrow_destructible_v =
3735 is_nothrow_destructible<_Tp>::value;
3738template <typename _Tp>
3739 inline constexpr bool has_virtual_destructor_v
3740 = __has_virtual_destructor(_Tp);
3742template <typename _Tp>
3743 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
3745#if _GLIBCXX_USE_BUILTIN_TRAIT(__array_rank) \
3746 && (!defined(__clang__) || __clang_major__ >= 20) // PR118559
3747template <typename _Tp>
3748 inline constexpr size_t rank_v = __array_rank(_Tp);
3750template <typename _Tp>
3751 inline constexpr size_t rank_v = 0;
3752template <typename _Tp, size_t _Size>
3753 inline constexpr size_t rank_v<_Tp[
_Size]
> = 1 + rank_v<_Tp>;
3754template <typename _Tp>
3755 inline constexpr size_t rank_v<_Tp[]
> = 1 + rank_v<_Tp>;
3758template <typename _Tp, unsigned _Idx = 0>
3759 inline constexpr size_t extent_v = 0;
3760template <typename _Tp, size_t _Size>
3761 inline constexpr size_t extent_v<_Tp[
_Size]
, 0> = _Size;
3762template <typename _Tp, unsigned _Idx, size_t _Size>
3763 inline constexpr size_t extent_v<_Tp[
_Size]
, _Idx> = extent_v<_Tp, _Idx - 1>;
3764template <typename _Tp>
3765 inline constexpr size_t extent_v<_Tp[]
, 0> = 0;
3766template <typename _Tp, unsigned _Idx>
3767 inline constexpr size_t extent_v<_Tp[]
, _Idx> = extent_v<_Tp, _Idx - 1>;
3769#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
3770template <typename _Tp, typename _Up>
3771 inline constexpr bool is_same_v = __is_same(_Tp, _Up);
3773template <typename _Tp, typename _Up>
3774 inline constexpr bool is_same_v = false;
3775template <typename _Tp>
3776 inline constexpr bool is_same_v<_Tp, _Tp> = true;
3778template <typename _Base, typename _Derived>
3779 inline constexpr bool is_base_of_v = __is_base_of(_Base, _Derived);
3780#ifdef __cpp_lib_is_virtual_base_of // C++ >= 26
3781template <typename _Base, typename _Derived>
3782 inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived);
3784#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible)
3785template <typename _From, typename _To>
3786 inline constexpr bool is_convertible_v = __is_convertible(_From, _To);
3788template <typename _From, typename _To>
3789 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
3791template<typename _Fn, typename... _Args>
3792 inline constexpr bool is_invocable_v
3793#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable)
3794 = __is_invocable(_Fn, _Args...);
3796 = is_invocable<_Fn, _Args...>::value;
3798template<typename _Fn, typename... _Args>
3799 inline constexpr bool is_nothrow_invocable_v
3800#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable)
3801 = __is_nothrow_invocable(_Fn, _Args...);
3803 = is_nothrow_invocable<_Fn, _Args...>::value;
3805template<typename _Ret, typename _Fn, typename... _Args>
3806 inline constexpr bool is_invocable_r_v
3807 = is_invocable_r<_Ret, _Fn, _Args...>::value;
3808template<typename _Ret, typename _Fn, typename... _Args>
3809 inline constexpr bool is_nothrow_invocable_r_v
3810 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
3812#endif // __cpp_lib_type_trait_variable_templates
3814#ifdef __cpp_lib_has_unique_object_representations // C++ >= 17 && HAS_UNIQ_OBJ_REP
3815 /// has_unique_object_representations
3817 template<typename _Tp>
3818 struct has_unique_object_representations
3819 : bool_constant<__has_unique_object_representations(
3820 remove_cv_t<remove_all_extents_t<_Tp>>
3823 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
),
3824 "template argument must be a complete class or an unbounded array");
3827# if __cpp_lib_type_trait_variable_templates // C++ >= 17
3828 /// @
ingroup variable_templates
3829 template<typename _Tp>
3830 inline constexpr bool has_unique_object_representations_v
3831 = has_unique_object_representations<_Tp>::value;
3835#ifdef __cpp_lib_is_aggregate // C++ >= 17 && builtin_is_aggregate
3836 /// is_aggregate - true if the type is an aggregate.
3838 template<typename _Tp>
3840 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)>
3843# if __cpp_lib_type_trait_variable_templates // C++ >= 17
3844 /** is_aggregate_v - true if the type is an aggregate.
3845 * @
ingroup variable_templates
3848 template<typename _Tp>
3849 inline constexpr bool is_aggregate_v = __is_aggregate(remove_cv_t<_Tp>);
3853 /** * Remove references and cv-qualifiers.
3857#ifdef __cpp_lib_remove_cvref // C++ >= 20
3858# if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cvref)
3859 template<typename _Tp>
3861 {
using type = __remove_cvref(_Tp); };
3863 template<typename _Tp>
3865 {
using type = typename remove_cv<_Tp>::type; };
3867 template<typename _Tp>
3868 struct remove_cvref<_Tp&>
3869 {
using type = typename remove_cv<_Tp>::type; };
3871 template<typename _Tp>
3872 struct remove_cvref<_Tp&&>
3873 {
using type = typename remove_cv<_Tp>::type; };
3876 template<typename _Tp>
3877 using remove_cvref_t = typename remove_cvref<_Tp>::type;
3879#endif // __cpp_lib_remove_cvref
3881#ifdef __cpp_lib_type_identity // C++ >= 20
3882 /** * Identity metafunction.
3886 template<typename _Tp>
3887 struct type_identity {
using type = _Tp; };
3889 template<typename _Tp>
3890 using type_identity_t = typename type_identity<_Tp>::type;
3894#ifdef __cpp_lib_unwrap_ref // C++ >= 20
3895 /** Unwrap a reference_wrapper
3899 template<typename _Tp>
3900 struct unwrap_reference {
using type = _Tp; };
3902 template<typename _Tp>
3903 struct unwrap_reference<reference_wrapper<_Tp>> {
using type = _Tp&; };
3905 template<typename _Tp>
3906 using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
3909 /** Decay type and if it's a reference_wrapper, unwrap it
3913 template<typename _Tp>
3914 struct unwrap_ref_decay {
using type = unwrap_reference_t<decay_t<_Tp>>; };
3916 template<typename _Tp>
3917 using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
3919#endif // __cpp_lib_unwrap_ref
3921#ifdef __cpp_lib_bounded_array_traits // C++ >= 20
3922 /// True for a type that is an array of known bound.
3923 /// @
ingroup variable_templates
3925# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_bounded_array)
3926 template<typename _Tp>
3927 inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
3929 template<typename _Tp>
3930 inline constexpr bool is_bounded_array_v = false;
3932 template<typename _Tp, size_t _Size>
3933 inline constexpr bool is_bounded_array_v<_Tp[
_Size]
> = true;
3936 /// True for a type that is an array of unknown bound.
3937 /// @
ingroup variable_templates
3939# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_unbounded_array)
3940 template<typename _Tp>
3941 inline constexpr bool is_unbounded_array_v = __is_unbounded_array(_Tp);
3943 template<typename _Tp>
3944 inline constexpr bool is_unbounded_array_v = false;
3946 template<typename _Tp>
3947 inline constexpr bool is_unbounded_array_v<_Tp[]
> = true;
3950 /// True for a type that is an array of known bound.
3952 template<typename _Tp>
3953 struct is_bounded_array
3954 : public bool_constant<is_bounded_array_v<_Tp>>
3957 /// True for a type that is an array of unknown bound.
3959 template<typename _Tp>
3960 struct is_unbounded_array
3961 : public bool_constant<is_unbounded_array_v<_Tp>>
3963#endif // __cpp_lib_bounded_array_traits
3965#if __has_builtin(__is_layout_compatible) && __cplusplus >= 202002L
3968 template<typename _Tp, typename _Up>
3969 struct is_layout_compatible
3970 : bool_constant<__is_layout_compatible(_Tp, _Up)>
3973 /// @
ingroup variable_templates
3975 template<typename _Tp, typename _Up>
3976 constexpr bool is_layout_compatible_v
3977 = __is_layout_compatible(_Tp, _Up);
3979#if __has_builtin(__builtin_is_corresponding_member)
3980# ifndef __cpp_lib_is_layout_compatible
3981# error "libstdc++ bug: is_corresponding_member and is_layout_compatible are provided but their FTM is not set"
3985 template<typename _S1, typename _S2, typename _M1, typename _M2>
3987 is_corresponding_member(_M1 _S1::*__m1, _M2 _S2::*__m2) noexcept
3988 {
return __builtin_is_corresponding_member(__m1, __m2); }
3992#if __has_builtin(__is_pointer_interconvertible_base_of) \
3993 && __cplusplus >= 202002L
3994 /// True if `
_Derived`
is standard-layout and has a base class of type `
_Base`
3996 template<typename _Base, typename _Derived>
3997 struct is_pointer_interconvertible_base_of
3998 : bool_constant<__is_pointer_interconvertible_base_of(_Base, _Derived)>
4001 /// @
ingroup variable_templates
4003 template<typename _Base, typename _Derived>
4004 constexpr bool is_pointer_interconvertible_base_of_v
4005 = __is_pointer_interconvertible_base_of(_Base, _Derived);
4007#if __has_builtin(__builtin_is_pointer_interconvertible_with_class)
4008# ifndef __cpp_lib_is_pointer_interconvertible
4009# error "libstdc++ bug: is_pointer_interconvertible available but FTM is not set"
4012 /// True if `
__mp`
points to the first member of a standard-layout type
4013 /// @
returns true if `
s.*__mp`
is pointer-interconvertible with `
s`
4015 template<typename _Tp, typename _Mem>
4017 is_pointer_interconvertible_with_class(_Mem _Tp::*__mp) noexcept
4018 {
return __builtin_is_pointer_interconvertible_with_class(__mp); }
4022#ifdef __cpp_lib_is_scoped_enum // C++ >= 23
4023 /// True if the type is a scoped enumeration type.
4026# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum)
4027 template<typename _Tp>
4028 struct is_scoped_enum
4029 : bool_constant<__is_scoped_enum(_Tp)>
4032 template<typename _Tp>
4033 struct is_scoped_enum
4037 template<typename _Tp>
4038 requires __is_enum(_Tp)
4039 && requires(remove_cv_t<_Tp> __t) {
__t = __t; }
// fails if incomplete
4040 struct is_scoped_enum<_Tp>
4041 : bool_constant<!requires(_Tp __t, void(*__f)(int)) {
__f(__t); }
>
4045 /// @
ingroup variable_templates
4047# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum)
4048 template<typename _Tp>
4049 inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);
4051 template<typename _Tp>
4052 inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
4056#ifdef __cpp_lib_reference_from_temporary // C++ >= 23 && ref_{converts,constructs}_from_temp
4057 /// True if _Tp is a reference type, a _Up value can be bound to _Tp in
4058 /// direct-initialization, and a temporary object would be bound to
4059 /// the reference, false otherwise.
4061 template<typename _Tp, typename _Up>
4062 struct reference_constructs_from_temporary
4063 : public bool_constant<__reference_constructs_from_temporary(_Tp, _Up)>
4065 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
)
4066 && std::__is_complete_or_unbounded(__type_identity<_Up>{}
),
4067 "template argument must be a complete class or an unbounded array");
4070 /// True if _Tp is a reference type, a _Up value can be bound to _Tp in
4071 /// copy-initialization, and a temporary object would be bound to
4072 /// the reference, false otherwise.
4074 template<typename _Tp, typename _Up>
4075 struct reference_converts_from_temporary
4076 : public bool_constant<__reference_converts_from_temporary(_Tp, _Up)>
4078 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}
)
4079 && std::__is_complete_or_unbounded(__type_identity<_Up>{}
),
4080 "template argument must be a complete class or an unbounded array");
4083 /// @
ingroup variable_templates
4085 template<typename _Tp, typename _Up>
4086 inline constexpr bool reference_constructs_from_temporary_v
4087 = reference_constructs_from_temporary<_Tp, _Up>::value;
4089 /// @
ingroup variable_templates
4091 template<typename _Tp, typename _Up>
4092 inline constexpr bool reference_converts_from_temporary_v
4093 = reference_converts_from_temporary<_Tp, _Up>::value;
4094#endif // __cpp_lib_reference_from_temporary
4096#ifdef __cpp_lib_is_constant_evaluated // C++ >= 20 && HAVE_IS_CONST_EVAL
4097 /// Returns true only when called during constant evaluation.
4099 [[
__gnu__::__always_inline__]]
4101 is_constant_evaluated() noexcept
4103#if __cpp_if_consteval >= 202106L
4104 if consteval {
return true; }
else {
return false; }
4106 return __builtin_is_constant_evaluated();
4111#if __cplusplus >= 202002L
4112 /// @
cond undocumented
4113 template<typename _From, typename _To>
4114 using __copy_cv = typename __match_cv_qualifiers<_From, _To>::__type;
4116 template<typename _Xp, typename _Yp>
4118 = decltype(false ?
declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
4120 template<typename _Ap, typename _Bp, typename = void>
4121 struct __common_ref_impl
4124 // [
meta.trans.other]
, COMMON-REF(A, B)
4125 template<typename _Ap, typename _Bp>
4126 using __common_ref = typename __common_ref_impl<_Ap, _Bp>::type;
4128 // COND-RES(COPYCV(X, Y) &, COPYCV(Y, X) &)
4129 template<typename _Xp, typename _Yp>
4130 using __condres_cvref
4131 = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>;
4133 // If A and B are both lvalue reference types, ...
4134 template<typename _Xp, typename _Yp>
4135 struct __common_ref_impl<_Xp&, _Yp&, __void_t<__condres_cvref<_Xp, _Yp>>>
4136 : enable_if<is_reference_v<__condres_cvref<_Xp, _Yp>>,
4137 __condres_cvref<_Xp, _Yp>>
4140 // let C be remove_reference_t<COMMON-REF(X&, Y&)>&&
4141 template<typename _Xp, typename _Yp>
4142 using __common_ref_C = remove_reference_t<__common_ref<_Xp&, _Yp&>>&&;
4144 // If A and B are both rvalue reference types, ...
4145 template<typename _Xp, typename _Yp>
4146 struct __common_ref_impl<_Xp&&, _Yp&&,
4147 _Require<is_convertible<_Xp&&, __common_ref_C<_Xp, _Yp>>,
4148 is_convertible<_Yp&&, __common_ref_C<_Xp, _Yp>>>>
4149 {
using type = __common_ref_C<_Xp, _Yp>; };
4151 // let D be COMMON-REF(const X&, Y&)
4152 template<typename _Xp, typename _Yp>
4153 using __common_ref_D = __common_ref<const _Xp&, _Yp&>;
4155 // If A is an rvalue reference and B is an lvalue reference, ...
4156 template<typename _Xp, typename _Yp>
4157 struct __common_ref_impl<_Xp&&, _Yp&,
4158 _Require<is_convertible<_Xp&&, __common_ref_D<_Xp, _Yp>>>>
4159 {
using type = __common_ref_D<_Xp, _Yp>; };
4161 // If A is an lvalue reference and B is an rvalue reference, ...
4162 template<typename _Xp, typename _Yp>
4163 struct __common_ref_impl<_Xp&, _Yp&&>
4164 : __common_ref_impl<_Yp&&, _Xp&>
4168 template<typename _Tp, typename _Up,
4169 template<typename> class _TQual, template<typename> class _UQual>
4170 struct basic_common_reference
4173 /// @
cond undocumented
4174 template<typename _Tp>
4176 {
template<typename _Up> using __type = __copy_cv<_Tp, _Up>; };
4178 template<typename _Tp>
4180 {
template<typename _Up> using __type = __copy_cv<_Tp, _Up>&; };
4182 template<typename _Tp>
4183 struct __xref<_Tp&&>
4184 {
template<typename _Up> using __type = __copy_cv<_Tp, _Up>&&; };
4186 template<typename _Tp1, typename _Tp2>
4187 using __basic_common_ref
4188 = typename basic_common_reference<remove_cvref_t<_Tp1>,
4189 remove_cvref_t<_Tp2>,
4190 __xref<_Tp1>::template __type,
4191 __xref<_Tp2>::template __type>::type;
4194 template<typename... _Tp>
4195 struct common_reference;
4197 template<typename... _Tp>
4198 using common_reference_t = typename common_reference<_Tp...>::type;
4200 // If sizeof...(T) is zero, there shall be no member type.
4202 struct common_reference<>
4205 // If sizeof...(T) is one ...
4206 template<typename _Tp0>
4207 struct common_reference<_Tp0>
4208 {
using type = _Tp0; };
4210 /// @
cond undocumented
4211 template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void>
4212 struct __common_reference_impl
4213 : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1>
4216 // If sizeof...(T) is two ...
4217 template<typename _Tp1, typename _Tp2>
4218 struct common_reference<_Tp1, _Tp2>
4219 : __common_reference_impl<_Tp1, _Tp2>
4222 // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ...
4223 template<typename _Tp1, typename _Tp2>
4224 struct __common_reference_impl<_Tp1&, _Tp2&, 1,
4225 void_t<__common_ref<_Tp1&, _Tp2&>>>
4226 {
using type = __common_ref<_Tp1&, _Tp2&>; };
4228 template<typename _Tp1, typename _Tp2>
4229 struct __common_reference_impl<_Tp1&&, _Tp2&&, 1,
4230 void_t<__common_ref<_Tp1&&, _Tp2&&>>>
4231 {
using type = __common_ref<_Tp1&&, _Tp2&&>; };
4233 template<typename _Tp1, typename _Tp2>
4234 struct __common_reference_impl<_Tp1&, _Tp2&&, 1,
4235 void_t<__common_ref<_Tp1&, _Tp2&&>>>
4236 {
using type = __common_ref<_Tp1&, _Tp2&&>; };
4238 template<typename _Tp1, typename _Tp2>
4239 struct __common_reference_impl<_Tp1&&, _Tp2&, 1,
4240 void_t<__common_ref<_Tp1&&, _Tp2&>>>
4241 {
using type = __common_ref<_Tp1&&, _Tp2&>; };
4243 // Otherwise, if basic_common_reference<...>::type is well-formed, ...
4244 template<typename _Tp1, typename _Tp2>
4245 struct __common_reference_impl<_Tp1, _Tp2, 2,
4246 void_t<__basic_common_ref<_Tp1, _Tp2>>>
4247 {
using type = __basic_common_ref<_Tp1, _Tp2>; };
4249 // Otherwise, if COND-RES(T1, T2) is well-formed, ...
4250 template<typename _Tp1, typename _Tp2>
4251 struct __common_reference_impl<_Tp1, _Tp2, 3,
4252 void_t<__cond_res<_Tp1, _Tp2>>>
4253 {
using type = __cond_res<_Tp1, _Tp2>; };
4255 // Otherwise, if common_type_t<T1, T2> is well-formed, ...
4256 template<typename _Tp1, typename _Tp2>
4257 struct __common_reference_impl<_Tp1, _Tp2, 4,
4258 void_t<common_type_t<_Tp1, _Tp2>>>
4259 {
using type = common_type_t<_Tp1, _Tp2>; };
4261 // Otherwise, there shall be no member type.
4262 template<typename _Tp1, typename _Tp2>
4263 struct __common_reference_impl<_Tp1, _Tp2, 5, void>
4266 // Otherwise, if sizeof...(T) is greater than two, ...
4267 template<typename _Tp1, typename _Tp2, typename... _Rest>
4268 struct common_reference<_Tp1, _Tp2, _Rest...>
4269 : __common_type_fold<common_reference<_Tp1, _Tp2>,
4270 __common_type_pack<_Rest...>>
4273 // Reuse __common_type_fold for common_reference<T1, T2, Rest...>
4274 template<typename _Tp1, typename _Tp2, typename... _Rest>
4275 struct __common_type_fold<common_reference<_Tp1, _Tp2>,
4276 __common_type_pack<_Rest...>,
4277 void_t<common_reference_t<_Tp1, _Tp2>>>
4278 : public common_reference<common_reference_t<_Tp1, _Tp2>, _Rest...>
4284#if __cplusplus >= 201103L
4285 // Stores a tuple of indices. Used by tuple and pair, and by bind() to
4286 // extract the elements in a tuple.
4287 template<size_t... _Indexes> struct _Index_tuple { };
4289 // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
4290 template<size_t _Num>
4291 struct _Build_index_tuple
4293#if __has_builtin(__make_integer_seq)
4294 template<typename, size_t... _Indices>
4295 using _IdxTuple = _Index_tuple<_Indices...>;
4297 // Clang defines __make_integer_seq for this purpose.
4298 using __type = __make_integer_seq<_IdxTuple, size_t, _Num>;
4300 // For GCC and other compilers, use __integer_pack instead.
4301 using __type = _Index_tuple<__integer_pack(_Num)...>;
4306#ifdef __cpp_lib_constant_wrapper // C++ >= 26
4307 template<typename _Tp>
4308 struct _CwFixedValue
4313 _CwFixedValue(__type __v) noexcept
4319 template<typename _Tp, size_t _Extent>
4320 struct _CwFixedValue<_Tp[
_Extent]
>
4322 using __type = _Tp[
_Extent];
4325 _CwFixedValue(_Tp (&__arr)[
_Extent]
) noexcept
4326 : _CwFixedValue(__arr, typename _Build_index_tuple<_Extent>::__type())
4329 template<size_t... _Indices>
4331 _CwFixedValue(_Tp (&__arr)[
_Extent]
, _Index_tuple<_Indices...>) noexcept
4332 : _M_data{
__arr[
_Indices]
...}
4335 _Tp _M_data[
_Extent];
4338 template<typename _Tp, size_t _Extent>
4339 _CwFixedValue(_Tp (&)[
_Extent]
) -> _CwFixedValue<_Tp[
_Extent]
>;
4341 template<_CwFixedValue _Xv,
4342 typename = typename decltype(_CwFixedValue(_Xv))::__type>
4343 struct constant_wrapper;
4345 template<typename _Tp>
4346 concept _ConstExprParam = requires
4348 typename constant_wrapper<_Tp::value>;
4353 template<_ConstExprParam _Tp>
4354 friend constexpr auto
4355 operator+(_Tp) noexcept -> constant_wrapper<(+_Tp::value)>
4358 template<_ConstExprParam _Tp>
4359 friend constexpr auto
4360 operator-(_Tp) noexcept -> constant_wrapper<(-_Tp::value)>
4363 template<_ConstExprParam _Tp>
4364 friend constexpr auto
4365 operator~(_Tp) noexcept -> constant_wrapper<(~_Tp::value)>
4368 template<_ConstExprParam _Tp>
4369 friend constexpr auto
4370 operator!(_Tp) noexcept -> constant_wrapper<(!_Tp::value)>
4373 template<_ConstExprParam _Tp>
4374 friend constexpr auto
4375 operator&(_Tp) noexcept -> constant_wrapper<(&_Tp::value)>
4378 template<_ConstExprParam _Tp>
4379 friend constexpr auto
4380 operator*(_Tp) noexcept -> constant_wrapper<(*_Tp::value)>
4383 template<_ConstExprParam _Left, _ConstExprParam _Right>
4384 friend constexpr auto
4385 operator+(_Left, _Right) noexcept
4386 -> constant_wrapper<(_Left::value + _Right::value)>
4389 template<_ConstExprParam _Left, _ConstExprParam _Right>
4390 friend constexpr auto
4391 operator-(_Left, _Right) noexcept
4392 -> constant_wrapper<(_Left::value - _Right::value)>
4395 template<_ConstExprParam _Left, _ConstExprParam _Right>
4396 friend constexpr auto
4397 operator*(_Left, _Right) noexcept
4398 -> constant_wrapper<(_Left::value * _Right::value)>
4401 template<_ConstExprParam _Left, _ConstExprParam _Right>
4402 friend constexpr auto
4403 operator/(_Left, _Right) noexcept
4404 -> constant_wrapper<(_Left::value / _Right::value)>
4407 template<_ConstExprParam _Left, _ConstExprParam _Right>
4408 friend constexpr auto
4409 operator%(_Left, _Right) noexcept
4410 -> constant_wrapper<(_Left::value % _Right::value)>
4413 template<_ConstExprParam _Left, _ConstExprParam _Right>
4414 friend constexpr auto
4415 operator<<(_Left, _Right) noexcept
4416 -> constant_wrapper<(_Left::value << _Right::value)>
4419 template<_ConstExprParam _Left, _ConstExprParam _Right>
4420 friend constexpr auto
4421 operator>>(_Left, _Right) noexcept
4422 -> constant_wrapper<(_Left::value >> _Right::value)>
4425 template<_ConstExprParam _Left, _ConstExprParam _Right>
4426 friend constexpr auto
4427 operator&(_Left, _Right) noexcept
4428 -> constant_wrapper<(_Left::value & _Right::value)>
4431 template<_ConstExprParam _Left, _ConstExprParam _Right>
4432 friend constexpr auto
4433 operator|(_Left, _Right) noexcept
4434 -> constant_wrapper<(_Left::value | _Right::value)>
4437 template<_ConstExprParam _Left, _ConstExprParam _Right>
4438 friend constexpr auto
4439 operator^(_Left, _Right) noexcept
4440 -> constant_wrapper<(_Left::value ^ _Right::value)>
4443 template<_ConstExprParam _Left, _ConstExprParam _Right>
4444 requires (!is_constructible_v<bool, decltype(_Left::value)>
4445 || !is_constructible_v<bool, decltype(_Right::value)>)
4446 friend constexpr auto
4447 operator&&(_Left, _Right) noexcept
4448 -> constant_wrapper<(_Left::value && _Right::value)>
4451 template<_ConstExprParam _Left, _ConstExprParam _Right>
4452 requires (!is_constructible_v<bool, decltype(_Left::value)>
4453 || !is_constructible_v<bool, decltype(_Right::value)>)
4454 friend constexpr auto
4455 operator||(_Left, _Right) noexcept
4456 -> constant_wrapper<(_Left::value || _Right::value)>
4459 template<_ConstExprParam _Left, _ConstExprParam _Right>
4460 friend constexpr auto
4461 operator<=>(_Left, _Right) noexcept
4462 -> constant_wrapper<(_Left::value <=> _Right::value)>
4465 template<_ConstExprParam _Left, _ConstExprParam _Right>
4466 friend constexpr auto
4467 operator<(_Left, _Right) noexcept
4468 -> constant_wrapper<(_Left::value < _Right::value)>
4471 template<_ConstExprParam _Left, _ConstExprParam _Right>
4472 friend constexpr auto
4473 operator<=(_Left, _Right) noexcept
4474 -> constant_wrapper<(_Left::value <= _Right::value)>
4477 template<_ConstExprParam _Left, _ConstExprParam _Right>
4478 friend constexpr auto
4479 operator==(_Left, _Right) noexcept
4480 -> constant_wrapper<(_Left::value == _Right::value)>
4483 template<_ConstExprParam _Left, _ConstExprParam _Right>
4484 friend constexpr auto
4485 operator!=(_Left, _Right) noexcept
4486 -> constant_wrapper<(_Left::value != _Right::value)>
4489 template<_ConstExprParam _Left, _ConstExprParam _Right>
4490 friend constexpr auto
4491 operator>(_Left, _Right) noexcept
4492 -> constant_wrapper<(_Left::value > _Right::value)>
4495 template<_ConstExprParam _Left, _ConstExprParam _Right>
4496 friend constexpr auto
4497 operator>=(_Left, _Right) noexcept
4498 -> constant_wrapper<(_Left::value >= _Right::value)>
4501 template<_ConstExprParam _Left, _ConstExprParam _Right>
4502 friend constexpr auto
4503 operator,(_Left, _Right) noexcept = delete;
4505 template<_ConstExprParam _Left, _ConstExprParam _Right>
4506 friend constexpr auto
4507 operator->*(_Left, _Right) noexcept
4508 -> constant_wrapper<_Left::value->*(_Right::value)>
4511 template<_ConstExprParam _Tp, _ConstExprParam... _Args>
4513 operator()(this _Tp, _Args...) noexcept
4515 requires(_Args...) {
constant_wrapper<_Tp::value(_Args::value...)>(); }
4516 {
return constant_wrapper<_Tp::value(_Args::value...)>{}; }
4518 template<_ConstExprParam _Tp, _ConstExprParam... _Args>
4520 operator[]
(this _Tp, _Args...) noexcept
4521 -> constant_wrapper<(_Tp::value[
_Args::value...]
)>
4524 template<_ConstExprParam _Tp>
4526 operator++(this _Tp) noexcept
4527 requires requires(_Tp::value_type __x) {
++__x; }
4529 return constant_wrapper<
4530 [] {
auto __x = _Tp::value;
return ++__x; }
()>{};
4533 template<_ConstExprParam _Tp>
4535 operator++(this _Tp, int) noexcept
4536 requires requires(_Tp::value_type __x) {
__x++; }
4538 return constant_wrapper<
4539 [] {
auto __x = _Tp::value;
return __x++; }
()>{};
4542 template<_ConstExprParam _Tp>
4545 requires requires(_Tp::value_type __x) {
4547 return constant_wrapper<
4548 [] {
auto __x = _Tp::value;
return
4551 template<_ConstExprParam _Tp>
4554 requires requires(_Tp::value_type __x) {
__x
4556 return constant_wrapper<
4557 [] {
auto __x = _Tp::value;
return __x
4560 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4562 operator+=(this _Tp, _Right) noexcept
4563 requires requires(_Tp::value_type __x) {
__x += _Right::value; }
4565 return constant_wrapper<
4566 [] {
auto __x = _Tp::value;
return __x += _Right::value; }
()>{};
4569 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4571 operator-=(this _Tp, _Right) noexcept
4572 requires requires(_Tp::value_type __x) {
__x -= _Right::value; }
4574 return constant_wrapper<
4575 [] {
auto __x = _Tp::value;
return __x -= _Right::value; }
()>{};
4578 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4580 operator*=(this _Tp, _Right) noexcept
4581 requires requires(_Tp::value_type __x) {
__x *= _Right::value; }
4583 return constant_wrapper<
4584 [] {
auto __x = _Tp::value;
return __x *= _Right::value; }
()>{};
4587 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4589 operator/=(this _Tp, _Right) noexcept
4590 requires requires(_Tp::value_type __x) {
__x /= _Right::value; }
4592 return constant_wrapper<
4593 [] {
auto __x = _Tp::value;
return __x /= _Right::value; }
()>{};
4596 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4598 operator%=(this _Tp, _Right) noexcept
4599 requires requires(_Tp::value_type __x) {
__x %= _Right::value; }
4601 return constant_wrapper<
4602 [] {
auto __x = _Tp::value;
return __x %= _Right::value; }
()>{};
4605 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4607 operator&=(this _Tp, _Right) noexcept
4608 requires requires(_Tp::value_type __x) {
__x &= _Right::value; }
4610 return constant_wrapper<
4611 [] {
auto __x = _Tp::value;
return __x &= _Right::value; }
()>{};
4614 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4616 operator|=(this _Tp, _Right) noexcept
4617 requires requires(_Tp::value_type __x) {
__x |= _Right::value; }
4619 return constant_wrapper<
4620 [] {
auto __x = _Tp::value;
return __x |= _Right::value; }
()>{};
4623 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4625 operator^=(this _Tp, _Right) noexcept
4626 requires requires(_Tp::value_type __x) {
__x ^= _Right::value; }
4628 return constant_wrapper<
4629 [] {
auto __x = _Tp::value;
return __x ^= _Right::value; }
()>{};
4632 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4634 operator<<=(this _Tp, _Right) noexcept
4635 requires requires(_Tp::value_type __x) {
__x <<= _Right::value; }
4637 return constant_wrapper<
4638 [] {
auto __x = _Tp::value;
return __x <<= _Right::value; }
()>{};
4641 template<_ConstExprParam _Tp, _ConstExprParam _Right>
4643 operator>>=(this _Tp, _Right) noexcept
4644 requires requires(_Tp::value_type __x) {
__x >>= _Right::value; }
4646 return constant_wrapper<
4647 [] {
auto __x = _Tp::value;
return __x >>= _Right::value; }
()>{};
4651 template<_CwFixedValue _Xv, typename>
4652 struct constant_wrapper : _CwOperators
4654 static constexpr const auto& value = _Xv._M_data;
4655 using type = constant_wrapper;
4656 using value_type = typename decltype(_Xv)::__type;
4658 template<_ConstExprParam _Right>
4660 operator=(_Right) const noexcept
4661 requires requires(value_type __x) {
__x = _Right::value; }
4663 return constant_wrapper<
4664 [] {
auto __x = value;
return __x = _Right::value; }
()>{};
4668 operator decltype(auto)() const noexcept
4672 template<_CwFixedValue _Tp>
4673 constexpr auto cw = constant_wrapper<_Tp>{};
4676 /// @}
group metaprogramming
4678_GLIBCXX_END_NAMESPACE_VERSION
4684#endif // _GLIBCXX_TYPE_TRAITS