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