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