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