mirrored from git://gcc.gnu.org/git/gcc.git
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathtype_traits
More file actions
4409 lines (3739 loc) · 131 KB
/
type_traits
File metadata and controls
4409 lines (3739 loc) · 131 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// C++11 <type_traits> -*- C++ -*-
// Copyright (C) 2007-2026 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/type_traits
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_TYPE_TRAITS
#define _GLIBCXX_TYPE_TRAITS 1
#ifdef _GLIBCXX_SYSHDR
#pragma GCC system_header
#endif
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/c++config.h>
#define __glibcxx_want_bool_constant
#define __glibcxx_want_bounded_array_traits
#define __glibcxx_want_common_reference
#define __glibcxx_want_has_unique_object_representations
#define __glibcxx_want_integral_constant_callable
#define __glibcxx_want_is_aggregate
#define __glibcxx_want_is_constant_evaluated
#define __glibcxx_want_is_final
#define __glibcxx_want_is_implicit_lifetime
#define __glibcxx_want_is_invocable
#define __glibcxx_want_is_layout_compatible
#define __glibcxx_want_is_nothrow_convertible
#define __glibcxx_want_is_null_pointer
#define __glibcxx_want_is_pointer_interconvertible
#define __glibcxx_want_is_scoped_enum
#define __glibcxx_want_is_structural
#define __glibcxx_want_is_swappable
#define __glibcxx_want_is_virtual_base_of
#define __glibcxx_want_logical_traits
#define __glibcxx_want_reference_from_temporary
#define __glibcxx_want_remove_cvref
#define __glibcxx_want_result_of_sfinae
#define __glibcxx_want_transformation_trait_aliases
#define __glibcxx_want_type_identity
#define __glibcxx_want_type_trait_variable_templates
#define __glibcxx_want_unwrap_ref
#define __glibcxx_want_void_t
#include <bits/version.h>
extern "C++"
{
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
class reference_wrapper;
/**
* @defgroup metaprogramming Metaprogramming
* @ingroup utilities
*
* Template utilities for compile-time introspection and modification,
* including type classification traits, type property inspection traits
* and type transformation traits.
*
* @since C++11
*
* @{
*/
/// integral_constant
template<typename _Tp, _Tp __v>
struct integral_constant
{
static constexpr _Tp value = __v;
using value_type = _Tp;
using type = integral_constant<_Tp, __v>;
constexpr operator value_type() const noexcept { return value; }
#ifdef __cpp_lib_integral_constant_callable // C++ >= 14
constexpr value_type operator()() const noexcept { return value; }
#endif
};
#if ! __cpp_inline_variables
template<typename _Tp, _Tp __v>
constexpr _Tp integral_constant<_Tp, __v>::value;
#endif
/// @cond undocumented
/// bool_constant for C++11
template<bool __v>
using __bool_constant = integral_constant<bool, __v>;
/// @endcond
/// The type used as a compile-time boolean with true value.
using true_type = __bool_constant<true>;
/// The type used as a compile-time boolean with false value.
using false_type = __bool_constant<false>;
#ifdef __cpp_lib_bool_constant // C++ >= 17
/// Alias template for compile-time boolean constant types.
/// @since C++17
template<bool __v>
using bool_constant = __bool_constant<__v>;
#endif
// Metaprogramming helper types.
// Primary template.
/// Define a member typedef `type` only if a boolean constant is true.
template<bool, typename _Tp = void>
struct enable_if
{ };
// Partial specialization for true.
template<typename _Tp>
struct enable_if<true, _Tp>
{ using type = _Tp; };
// __enable_if_t (std::enable_if_t for C++11)
template<bool _Cond, typename _Tp = void>
using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
template<bool>
struct __conditional
{
template<typename _Tp, typename>
using type = _Tp;
};
template<>
struct __conditional<false>
{
template<typename, typename _Up>
using type = _Up;
};
// More efficient version of std::conditional_t for internal use (and C++11)
template<bool _Cond, typename _If, typename _Else>
using __conditional_t
= typename __conditional<_Cond>::template type<_If, _Else>;
#ifdef __cpp_lib_type_identity // C++ >= 20
/** Identity metafunction.
* @since C++20
* @{
*/
template<typename _Tp>
struct type_identity { using type = _Tp; };
template<typename _Tp>
using type_identity_t = typename type_identity<_Tp>::type;
/// @}
/// @cond undocumented
template <typename _Tp>
using __type_identity = type_identity<_Tp>;
template<typename _Tp>
using __type_identity_t = typename type_identity<_Tp>::type;
/// @endcond
#else
/// @cond undocumented
template <typename _Type>
struct __type_identity
{ using type = _Type; };
template<typename _Tp>
using __type_identity_t = typename __type_identity<_Tp>::type;
/// @endcond
#endif
/// @cond undocumented
namespace __detail
{
// A variadic alias template that resolves to its first argument.
template<typename _Tp, typename...>
using __first_t = _Tp;
// These are deliberately not defined.
template<typename... _Bn>
auto __or_fn(int) -> __first_t<false_type,
__enable_if_t<!bool(_Bn::value)>...>;
template<typename... _Bn>
auto __or_fn(...) -> true_type;
template<typename... _Bn>
auto __and_fn(int) -> __first_t<true_type,
__enable_if_t<bool(_Bn::value)>...>;
template<typename... _Bn>
auto __and_fn(...) -> false_type;
} // namespace detail
// Like C++17 std::dis/conjunction, but usable in C++11 and resolves
// to either true_type or false_type which allows for a more efficient
// implementation that avoids recursive class template instantiation.
template<typename... _Bn>
struct __or_
: decltype(__detail::__or_fn<_Bn...>(0))
{ };
template<typename... _Bn>
struct __and_
: decltype(__detail::__and_fn<_Bn...>(0))
{ };
template<typename _Pp>
struct __not_
: __bool_constant<!bool(_Pp::value)>
{ };
/// @endcond
#ifdef __cpp_lib_logical_traits // C++ >= 17
/// @cond undocumented
template<typename... _Bn>
inline constexpr bool __or_v = __or_<_Bn...>::value;
template<typename... _Bn>
inline constexpr bool __and_v = __and_<_Bn...>::value;
namespace __detail
{
template<typename /* = void */, typename _B1, typename... _Bn>
struct __disjunction_impl
{ using type = _B1; };
template<typename _B1, typename _B2, typename... _Bn>
struct __disjunction_impl<__enable_if_t<!bool(_B1::value)>, _B1, _B2, _Bn...>
{ using type = typename __disjunction_impl<void, _B2, _Bn...>::type; };
template<typename /* = void */, typename _B1, typename... _Bn>
struct __conjunction_impl
{ using type = _B1; };
template<typename _B1, typename _B2, typename... _Bn>
struct __conjunction_impl<__enable_if_t<bool(_B1::value)>, _B1, _B2, _Bn...>
{ using type = typename __conjunction_impl<void, _B2, _Bn...>::type; };
} // namespace __detail
/// @endcond
template<typename... _Bn>
struct conjunction
: __detail::__conjunction_impl<void, _Bn...>::type
{ };
template<>
struct conjunction<>
: true_type
{ };
template<typename... _Bn>
struct disjunction
: __detail::__disjunction_impl<void, _Bn...>::type
{ };
template<>
struct disjunction<>
: false_type
{ };
template<typename _Pp>
struct negation
: __not_<_Pp>::type
{ };
/** @ingroup variable_templates
* @{
*/
template<typename... _Bn>
inline constexpr bool conjunction_v = conjunction<_Bn...>::value;
template<typename... _Bn>
inline constexpr bool disjunction_v = disjunction<_Bn...>::value;
template<typename _Pp>
inline constexpr bool negation_v = negation<_Pp>::value;
/// @}
#endif // __cpp_lib_logical_traits
// Forward declarations
template<typename>
struct is_object;
template<typename>
struct remove_cv;
template<typename>
struct is_const;
/// @cond undocumented
template<typename>
struct __is_array_unknown_bounds;
// An object type which is not an unbounded array.
// It might still be an incomplete type, but if this is false_type
// then we can be certain it's not a complete object type.
template<typename _Tp>
using __maybe_complete_object_type
= __and_<is_object<_Tp>, __not_<__is_array_unknown_bounds<_Tp>>>;
// Helper functions that return false_type for incomplete classes,
// incomplete unions and arrays of known bound from those.
// More specialized overload for complete object types (returning true_type).
template<typename _Tp,
typename = __enable_if_t<__maybe_complete_object_type<_Tp>::value>,
size_t = sizeof(_Tp)>
constexpr true_type
__is_complete_or_unbounded(__type_identity<_Tp>)
{ return {}; };
// Less specialized overload for reference and unknown-bound array types
// (returning true_type), and incomplete types (returning false_type).
template<typename _TypeIdentity,
typename _NestedType = typename _TypeIdentity::type>
constexpr typename __not_<__maybe_complete_object_type<_NestedType>>::type
__is_complete_or_unbounded(_TypeIdentity)
{ return {}; }
// __remove_cv_t (std::remove_cv_t for C++11).
template<typename _Tp>
using __remove_cv_t = typename remove_cv<_Tp>::type;
/// @endcond
// Primary type categories.
/// is_void
template<typename _Tp>
struct is_void
: public false_type { };
template<>
struct is_void<void>
: public true_type { };
template<>
struct is_void<const void>
: public true_type { };
template<>
struct is_void<volatile void>
: public true_type { };
template<>
struct is_void<const volatile void>
: public true_type { };
/// @cond undocumented
// Every integral type is either one of the character types, one of the
// signed integer types, one of the unsigned integer types, or bool,
// or a cv-qualified version of one of those types ([basic.fundamental]).
// For now we only need to distinguish the signed/unsigned integer types.
enum class _Integer_kind { _None, _Signed, _Unsigned };
template<typename>
struct __is_integral_helper
: public false_type
{ static constexpr auto _S_kind = _Integer_kind::_None; };
template<>
struct __is_integral_helper<bool>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_None; };
template<>
struct __is_integral_helper<char>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_None; };
template<>
struct __is_integral_helper<signed char>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
template<>
struct __is_integral_helper<unsigned char>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
// We want is_integral<wchar_t> to be true (and make_signed/unsigned to work)
// even when libc doesn't provide working <wchar.h> and related functions,
// so don't check _GLIBCXX_USE_WCHAR_T here.
template<>
struct __is_integral_helper<wchar_t>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_None; };
#ifdef _GLIBCXX_USE_CHAR8_T
template<>
struct __is_integral_helper<char8_t>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_None; };
#endif
template<>
struct __is_integral_helper<char16_t>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_None; };
template<>
struct __is_integral_helper<char32_t>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_None; };
template<>
struct __is_integral_helper<short>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
template<>
struct __is_integral_helper<unsigned short>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
template<>
struct __is_integral_helper<int>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
template<>
struct __is_integral_helper<unsigned int>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
template<>
struct __is_integral_helper<long>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
template<>
struct __is_integral_helper<unsigned long>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
template<>
struct __is_integral_helper<long long>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
template<>
struct __is_integral_helper<unsigned long long>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
// Conditionalizing on __STRICT_ANSI__ here will break any port that
// uses one of these types for size_t.
#if defined(__GLIBCXX_TYPE_INT_N_0)
__extension__
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
__extension__
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_1)
__extension__
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
__extension__
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_2)
__extension__
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
__extension__
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_3)
__extension__
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
__extension__
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
#endif
#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
__extension__
template<>
struct __is_integral_helper<__int128>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Signed; };
__extension__
template<>
struct __is_integral_helper<unsigned __int128>
: public true_type
{ static constexpr auto _S_kind = _Integer_kind::_Unsigned; };
#endif
// Check if a type is one of the signed integer types.
template<typename _Tp>
using __is_signed_integer
= __bool_constant<__is_integral_helper<_Tp>::_S_kind
== _Integer_kind::_Signed>;
// Check if a type is one of the unsigned integer types.
template<typename _Tp>
using __is_unsigned_integer
= __bool_constant<__is_integral_helper<_Tp>::_S_kind
== _Integer_kind::_Unsigned>;
// Check if a type is one of the signed or unsigned integer types.
// i.e. an integral type except bool, char, wchar_t, and charN_t.
template<typename _Tp>
using __is_signed_or_unsigned_integer
= __bool_constant<__is_integral_helper<_Tp>::_S_kind
!= _Integer_kind::_None>;
/// @endcond
/// is_integral
template<typename _Tp>
struct is_integral
: public __is_integral_helper<__remove_cv_t<_Tp>>::type
{ };
/// @cond undocumented
template<typename>
struct __is_floating_point_helper
: public false_type { };
template<>
struct __is_floating_point_helper<float>
: public true_type { };
template<>
struct __is_floating_point_helper<double>
: public true_type { };
template<>
struct __is_floating_point_helper<long double>
: public true_type { };
#ifdef __STDCPP_FLOAT16_T__
template<>
struct __is_floating_point_helper<_Float16>
: public true_type { };
#endif
#ifdef __STDCPP_FLOAT32_T__
template<>
struct __is_floating_point_helper<_Float32>
: public true_type { };
#endif
#ifdef __STDCPP_FLOAT64_T__
template<>
struct __is_floating_point_helper<_Float64>
: public true_type { };
#endif
#ifdef __STDCPP_FLOAT128_T__
template<>
struct __is_floating_point_helper<_Float128>
: public true_type { };
#endif
#ifdef __STDCPP_BFLOAT16_T__
template<>
struct __is_floating_point_helper<__gnu_cxx::__bfloat16_t>
: public true_type { };
#endif
#ifdef _GLIBCXX_USE_FLOAT128
template<>
struct __is_floating_point_helper<__float128>
: public true_type { };
#endif
/// @endcond
/// is_floating_point
template<typename _Tp>
struct is_floating_point
: public __is_floating_point_helper<__remove_cv_t<_Tp>>::type
{ };
/// is_array
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_array)
template<typename _Tp>
struct is_array
: public __bool_constant<__is_array(_Tp)>
{ };
#else
template<typename>
struct is_array
: public false_type { };
template<typename _Tp, std::size_t _Size>
struct is_array<_Tp[_Size]>
: public true_type { };
template<typename _Tp>
struct is_array<_Tp[]>
: public true_type { };
#endif
/// is_pointer
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
template<typename _Tp>
struct is_pointer
: public __bool_constant<__is_pointer(_Tp)>
{ };
#else
template<typename _Tp>
struct is_pointer
: public false_type { };
template<typename _Tp>
struct is_pointer<_Tp*>
: public true_type { };
template<typename _Tp>
struct is_pointer<_Tp* const>
: public true_type { };
template<typename _Tp>
struct is_pointer<_Tp* volatile>
: public true_type { };
template<typename _Tp>
struct is_pointer<_Tp* const volatile>
: public true_type { };
#endif
/// is_lvalue_reference
template<typename>
struct is_lvalue_reference
: public false_type { };
template<typename _Tp>
struct is_lvalue_reference<_Tp&>
: public true_type { };
/// is_rvalue_reference
template<typename>
struct is_rvalue_reference
: public false_type { };
template<typename _Tp>
struct is_rvalue_reference<_Tp&&>
: public true_type { };
/// is_member_object_pointer
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_object_pointer)
template<typename _Tp>
struct is_member_object_pointer
: public __bool_constant<__is_member_object_pointer(_Tp)>
{ };
#else
template<typename _Tp>
struct is_function;
template<typename>
struct __is_member_object_pointer_helper
: public false_type { };
template<typename _Tp, typename _Cp>
struct __is_member_object_pointer_helper<_Tp _Cp::*>
: public __not_<is_function<_Tp>>::type { };
template<typename _Tp>
struct is_member_object_pointer
: public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type
{ };
#endif
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_function_pointer)
/// is_member_function_pointer
template<typename _Tp>
struct is_member_function_pointer
: public __bool_constant<__is_member_function_pointer(_Tp)>
{ };
#else
template<typename _Tp>
struct is_function;
template<typename>
struct __is_member_function_pointer_helper
: public false_type { };
template<typename _Tp, typename _Cp>
struct __is_member_function_pointer_helper<_Tp _Cp::*>
: public is_function<_Tp>::type { };
/// is_member_function_pointer
template<typename _Tp>
struct is_member_function_pointer
: public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type
{ };
#endif
/// is_enum
template<typename _Tp>
struct is_enum
: public __bool_constant<__is_enum(_Tp)>
{ };
/// is_union
template<typename _Tp>
struct is_union
: public __bool_constant<__is_union(_Tp)>
{ };
/// is_class
template<typename _Tp>
struct is_class
: public __bool_constant<__is_class(_Tp)>
{ };
/// is_function
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function)
template<typename _Tp>
struct is_function
: public __bool_constant<__is_function(_Tp)>
{ };
#else
template<typename _Tp>
struct is_function
: public __bool_constant<!is_const<const _Tp>::value> { };
template<typename _Tp>
struct is_function<_Tp&>
: public false_type { };
template<typename _Tp>
struct is_function<_Tp&&>
: public false_type { };
#endif
#if __cpp_impl_reflection >= 202506L // C++ >= 26
/// is_reflection
template<typename _Tp>
struct is_reflection
: public false_type { };
template<>
struct is_reflection<decltype(^^int)>
: public true_type { };
template<>
struct is_reflection<const decltype(^^int)>
: public true_type { };
template<>
struct is_reflection<volatile decltype(^^int)>
: public true_type { };
template<>
struct is_reflection<const volatile decltype(^^int)>
: public true_type { };
#endif
#ifdef __cpp_lib_is_null_pointer // C++ >= 11
/// is_null_pointer (LWG 2247).
template<typename _Tp>
struct is_null_pointer
: public false_type { };
template<>
struct is_null_pointer<std::nullptr_t>
: public true_type { };
template<>
struct is_null_pointer<const std::nullptr_t>
: public true_type { };
template<>
struct is_null_pointer<volatile std::nullptr_t>
: public true_type { };
template<>
struct is_null_pointer<const volatile std::nullptr_t>
: public true_type { };
/// __is_nullptr_t (deprecated extension).
/// @deprecated Non-standard. Use `is_null_pointer` instead.
template<typename _Tp>
struct __is_nullptr_t
: public is_null_pointer<_Tp>
{ } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer");
#endif // __cpp_lib_is_null_pointer
// Composite type categories.
/// is_reference
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference)
template<typename _Tp>
struct is_reference
: public __bool_constant<__is_reference(_Tp)>
{ };
#else
template<typename _Tp>
struct is_reference
: public false_type
{ };
template<typename _Tp>
struct is_reference<_Tp&>
: public true_type
{ };
template<typename _Tp>
struct is_reference<_Tp&&>
: public true_type
{ };
#endif
/// is_arithmetic
template<typename _Tp>
struct is_arithmetic
: public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
{ };
/// is_fundamental
template<typename _Tp>
struct is_fundamental
: public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
is_null_pointer<_Tp>
#if __cpp_impl_reflection >= 202506L
, is_reflection<_Tp>
#endif
>::type
{ };
/// is_object
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object)
template<typename _Tp>
struct is_object
: public __bool_constant<__is_object(_Tp)>
{ };
#else
template<typename _Tp>
struct is_object
: public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
is_void<_Tp>>>::type
{ };
#endif
template<typename>
struct is_member_pointer;
/// is_scalar
template<typename _Tp>
struct is_scalar
: public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
is_member_pointer<_Tp>, is_null_pointer<_Tp>
#if __cpp_impl_reflection >= 202506L
, is_reflection<_Tp>
#endif
>::type
{ };
/// is_compound
template<typename _Tp>
struct is_compound
: public __bool_constant<!is_fundamental<_Tp>::value> { };
/// is_member_pointer
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_pointer)
template<typename _Tp>
struct is_member_pointer
: public __bool_constant<__is_member_pointer(_Tp)>
{ };
#else
/// @cond undocumented
template<typename _Tp>
struct __is_member_pointer_helper
: public false_type { };
template<typename _Tp, typename _Cp>
struct __is_member_pointer_helper<_Tp _Cp::*>
: public true_type { };
/// @endcond
template<typename _Tp>
struct is_member_pointer
: public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type
{ };
#endif
template<typename, typename>
struct is_same;
/// @cond undocumented
template<typename _Tp, typename... _Types>
using __is_one_of = __or_<is_same<_Tp, _Types>...>;
// __void_t (std::void_t for C++11)
template<typename...> using __void_t = void;
/// @endcond
// Type properties.
/// is_const
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const)
template<typename _Tp>
struct is_const
: public __bool_constant<__is_const(_Tp)>
{ };
#else
template<typename>
struct is_const
: public false_type { };
template<typename _Tp>
struct is_const<_Tp const>
: public true_type { };
#endif
/// is_volatile
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile)
template<typename _Tp>
struct is_volatile
: public __bool_constant<__is_volatile(_Tp)>
{ };
#else
template<typename>
struct is_volatile
: public false_type { };
template<typename _Tp>
struct is_volatile<_Tp volatile>
: public true_type { };
#endif
/** is_trivial
* @deprecated Deprecated in C++26.
* Use a combination of one or more more specialized type traits instead,
* such as `is_trivially_default_constructible`,
* `is_trivially_copy_constructible`, `is_trivially_copy_assignable`,
* etc., depending on the exact check(s) needed.
*/
template<typename _Tp>
struct
_GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible && is_trivially_copyable")
is_trivial
: public __bool_constant<__is_trivial(_Tp)>
{
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
"template argument must be a complete class or an unbounded array");
};
/// is_trivially_copyable
template<typename _Tp>
struct is_trivially_copyable
: public __bool_constant<__is_trivially_copyable(_Tp)>
{
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
"template argument must be a complete class or an unbounded array");