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