forked from cplusplus/draft
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmeta.tex
2764 lines (2440 loc) · 108 KB
/
meta.tex
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
%!TEX root = std.tex
\rSec0[meta]{Metaprogramming library}
\rSec1[meta.general]{General}
\pnum
This Clause describes metaprogramming facilities.
These facilities are summarized in \tref{meta.summary}.
\begin{libsumtab}{Metaprogramming library summary}{meta.summary}
\ref{intseq} & Integer sequences & \tcode{<utility>} \\ \rowsep
\ref{type.traits} & Type traits & \tcode{<type_traits>} \\ \rowsep
\ref{ratio} & Rational arithmetic & \tcode{<ratio>} \\
\end{libsumtab}
\rSec1[intseq]{Compile-time integer sequences}
\rSec2[intseq.general]{General}
\pnum
The library provides a class template that can represent an integer sequence.
When used as an argument to a function template the template parameter pack defining the
sequence can be deduced and used in a pack expansion.
\begin{note}
The \tcode{index_sequence} alias template is provided for the common case of
an integer sequence of type \tcode{size_t}; see also \ref{tuple.apply}.
\end{note}
\rSec2[intseq.intseq]{Class template \tcode{integer_sequence}}
\indexlibraryglobal{integer_sequence}%
\indexlibrarymember{value_type}{integer_sequence}%
\begin{codeblock}
namespace std {
template<class T, T... I> struct integer_sequence {
using value_type = T;
static constexpr size_t size() noexcept { return sizeof...(I); }
};
}
\end{codeblock}
\pnum
\mandates
\tcode{T} is an integer type.
\rSec2[intseq.make]{Alias template \tcode{make_integer_sequence}}
\indexlibraryglobal{make_integer_sequence}%
\begin{itemdecl}
template<class T, T N>
using make_integer_sequence = integer_sequence<T, @\seebelow{}@>;
\end{itemdecl}
\begin{itemdescr}
\pnum
\mandates
$\tcode{N} \geq 0$.
\pnum
The alias template
\tcode{make_integer_sequence} denotes a specialization of
\tcode{integer_sequence} with \tcode{N} non-type template arguments.
The type \tcode{make_integer_sequence<T, N>} is an alias for the type
\tcode{integer_sequence<T, 0, 1, ..., N-1>}.
\begin{note}
\tcode{make_integer_sequence<int, 0>} is an alias for the type
\tcode{integer_sequence<int>}.
\end{note}
\end{itemdescr}
\rSec1[type.traits]{Metaprogramming and type traits}
\rSec2[type.traits.general]{General}
\pnum
Subclause \ref{type.traits} describes components used by \Cpp{} programs, particularly in
templates, to support the widest possible range of types, optimize
template code usage, detect type related user errors, and perform
type inference and transformation at compile time. It includes type
classification traits, type property inspection traits, and type
transformations. The type classification traits describe a complete taxonomy
of all possible \Cpp{} types, and state where in that taxonomy a given
type belongs. The type property inspection traits allow important
characteristics of types or of combinations of types to be inspected. The
type transformations allow certain properties of types to be manipulated.
\pnum
\indextext{signal-safe!type traits}%
All functions specified in \ref{type.traits} are signal-safe\iref{support.signal}.
\rSec2[meta.rqmts]{Requirements}
\pnum
A \defnoldconcept{UnaryTypeTrait} describes a property
of a type. It shall be a class template that takes one template type
argument and, optionally, additional arguments that help define the
property being described. It shall be \oldconceptref{DefaultConstructible},
\oldconceptref{CopyConstructible},
and publicly and unambiguously derived, directly or indirectly, from
its \defn{base characteristic}, which is
a specialization of the template
\libglobalref{integral_constant}, with
the arguments to the template \tcode{integral_constant} determined by the
requirements for the particular property being described.
The member names of the base characteristic shall not be hidden and shall be
unambiguously available in the \oldconcept{UnaryTypeTrait}.
\pnum
A \defnoldconcept{BinaryTypeTrait} describes a
relationship between two types. It shall be a class template that
takes two template type arguments and, optionally, additional
arguments that help define the relationship being described. It shall
be \oldconceptref{DefaultConstructible}, \oldconceptref{CopyConstructible},
and publicly and unambiguously derived, directly or
indirectly, from
its \term{base characteristic}, which is a specialization
of the template
\libglobalref{integral_constant}, with
the arguments to the template \tcode{integral_constant} determined by the
requirements for the particular relationship being described.
The member names of the base characteristic shall not be hidden and shall be
unambiguously available in the \oldconcept{BinaryTypeTrait}.
\pnum
A \defnoldconcept{TransformationTrait}
modifies a property
of a type. It shall be a class template that takes one
template type argument and, optionally, additional arguments that help
define the modification. It shall define a publicly accessible nested type
named \tcode{type}, which shall be a synonym for the modified type.
\pnum
Unless otherwise specified,
the behavior of a program that adds specializations
for any of the templates specified in \ref{type.traits}
is undefined.
\pnum
Unless otherwise specified, an incomplete type may be used
to instantiate a template specified in \ref{type.traits}.
The behavior of a program is undefined if
\begin{itemize}
\item
an instantiation of a template specified in \ref{type.traits}
directly or indirectly depends on
an incompletely-defined object type \tcode{T}, and
\item
that instantiation could yield a different result
were \tcode{T} hypothetically completed.
\end{itemize}
\rSec2[meta.type.synop]{Header \tcode{<type_traits>} synopsis}
\indexheader{type_traits}%
% FIXME: Many index entries missing.
\begin{codeblock}
// all freestanding
namespace std {
// \ref{meta.help}, helper class
template<class T, T v> struct integral_constant;
template<bool B>
using @\libglobal{bool_constant}@ = integral_constant<bool, B>;
using @\libglobal{true_type}@ = bool_constant<true>;
using @\libglobal{false_type}@ = bool_constant<false>;
// \ref{meta.unary.cat}, primary type categories
template<class T> struct is_void;
template<class T> struct is_null_pointer;
template<class T> struct is_integral;
template<class T> struct is_floating_point;
template<class T> struct is_array;
template<class T> struct is_pointer;
template<class T> struct is_lvalue_reference;
template<class T> struct is_rvalue_reference;
template<class T> struct is_member_object_pointer;
template<class T> struct is_member_function_pointer;
template<class T> struct is_enum;
template<class T> struct is_union;
template<class T> struct is_class;
template<class T> struct is_function;
// \ref{meta.unary.comp}, composite type categories
template<class T> struct is_reference;
template<class T> struct is_arithmetic;
template<class T> struct is_fundamental;
template<class T> struct is_object;
template<class T> struct is_scalar;
template<class T> struct is_compound;
template<class T> struct is_member_pointer;
// \ref{meta.unary.prop}, type properties
template<class T> struct is_const;
template<class T> struct is_volatile;
template<class T> struct is_trivially_copyable;
template<class T> struct is_standard_layout;
template<class T> struct is_empty;
template<class T> struct is_polymorphic;
template<class T> struct is_abstract;
template<class T> struct is_final;
template<class T> struct is_aggregate;
template<class T> struct is_signed;
template<class T> struct is_unsigned;
template<class T> struct is_bounded_array;
template<class T> struct is_unbounded_array;
template<class T> struct is_scoped_enum;
template<class T, class... Args> struct is_constructible;
template<class T> struct is_default_constructible;
template<class T> struct is_copy_constructible;
template<class T> struct is_move_constructible;
template<class T, class U> struct is_assignable;
template<class T> struct is_copy_assignable;
template<class T> struct is_move_assignable;
template<class T, class U> struct is_swappable_with;
template<class T> struct is_swappable;
template<class T> struct is_destructible;
template<class T, class... Args> struct is_trivially_constructible;
template<class T> struct is_trivially_default_constructible;
template<class T> struct is_trivially_copy_constructible;
template<class T> struct is_trivially_move_constructible;
template<class T, class U> struct is_trivially_assignable;
template<class T> struct is_trivially_copy_assignable;
template<class T> struct is_trivially_move_assignable;
template<class T> struct is_trivially_destructible;
template<class T, class... Args> struct is_nothrow_constructible;
template<class T> struct is_nothrow_default_constructible;
template<class T> struct is_nothrow_copy_constructible;
template<class T> struct is_nothrow_move_constructible;
template<class T, class U> struct is_nothrow_assignable;
template<class T> struct is_nothrow_copy_assignable;
template<class T> struct is_nothrow_move_assignable;
template<class T, class U> struct is_nothrow_swappable_with;
template<class T> struct is_nothrow_swappable;
template<class T> struct is_nothrow_destructible;
template<class T> struct is_implicit_lifetime;
template<class T> struct has_virtual_destructor;
template<class T> struct has_unique_object_representations;
template<class T, class U> struct reference_constructs_from_temporary;
template<class T, class U> struct reference_converts_from_temporary;
// \ref{meta.unary.prop.query}, type property queries
template<class T> struct alignment_of;
template<class T> struct rank;
template<class T, unsigned I = 0> struct extent;
// \ref{meta.rel}, type relations
template<class T, class U> struct is_same;
template<class Base, class Derived> struct is_base_of;
template<class Base, class Derived> struct is_virtual_base_of;
template<class From, class To> struct is_convertible;
template<class From, class To> struct is_nothrow_convertible;
template<class T, class U> struct is_layout_compatible;
template<class Base, class Derived> struct is_pointer_interconvertible_base_of;
template<class Fn, class... ArgTypes> struct is_invocable;
template<class R, class Fn, class... ArgTypes> struct is_invocable_r;
template<class Fn, class... ArgTypes> struct is_nothrow_invocable;
template<class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
// \ref{meta.trans.cv}, const-volatile modifications
template<class T> struct remove_const;
template<class T> struct remove_volatile;
template<class T> struct remove_cv;
template<class T> struct add_const;
template<class T> struct add_volatile;
template<class T> struct add_cv;
template<class T>
using @\libglobal{remove_const_t}@ = typename @\libglobalref{remove_const}@<T>::type;
template<class T>
using @\libglobal{remove_volatile_t}@ = typename @\libglobalref{remove_volatile}@<T>::type;
template<class T>
using @\libglobal{remove_cv_t}@ = typename @\libglobalref{remove_cv}@<T>::type;
template<class T>
using @\libglobal{add_const_t}@ = typename @\libglobalref{add_const}@<T>::type;
template<class T>
using @\libglobal{add_volatile_t}@ = typename @\libglobalref{add_volatile}@<T>::type;
template<class T>
using @\libglobal{add_cv_t}@ = typename @\libglobalref{add_cv}@<T>::type;
// \ref{meta.trans.ref}, reference modifications
template<class T> struct remove_reference;
template<class T> struct add_lvalue_reference;
template<class T> struct add_rvalue_reference;
template<class T>
using @\libglobal{remove_reference_t}@ = typename @\libglobalref{remove_reference}@<T>::type;
template<class T>
using @\libglobal{add_lvalue_reference_t}@ = typename @\libglobalref{add_lvalue_reference}@<T>::type;
template<class T>
using @\libglobal{add_rvalue_reference_t}@ = typename @\libglobalref{add_rvalue_reference}@<T>::type;
// \ref{meta.trans.sign}, sign modifications
template<class T> struct make_signed;
template<class T> struct make_unsigned;
template<class T>
using @\libglobal{make_signed_t}@ = typename @\libglobalref{make_signed}@<T>::type;
template<class T>
using @\libglobal{make_unsigned_t}@ = typename @\libglobalref{make_unsigned}@<T>::type;
// \ref{meta.trans.arr}, array modifications
template<class T> struct remove_extent;
template<class T> struct remove_all_extents;
template<class T>
using @\libglobal{remove_extent_t}@ = typename @\libglobalref{remove_extent}@<T>::type;
template<class T>
using @\libglobal{remove_all_extents_t}@ = typename @\libglobalref{remove_all_extents}@<T>::type;
// \ref{meta.trans.ptr}, pointer modifications
template<class T> struct remove_pointer;
template<class T> struct add_pointer;
template<class T>
using @\libglobal{remove_pointer_t}@ = typename @\libglobalref{remove_pointer}@<T>::type;
template<class T>
using @\libglobal{add_pointer_t}@ = typename @\libglobalref{add_pointer}@<T>::type;
// \ref{meta.trans.other}, other transformations
template<class T> struct type_identity;
template<class T> struct remove_cvref;
template<class T> struct decay;
template<bool, class T = void> struct enable_if;
template<bool, class T, class F> struct conditional;
template<class... T> struct common_type;
template<class T, class U, template<class> class TQual, template<class> class UQual>
struct basic_common_reference { };
template<class... T> struct common_reference;
template<class T> struct underlying_type;
template<class Fn, class... ArgTypes> struct invoke_result;
template<class T> struct unwrap_reference;
template<class T> struct unwrap_ref_decay;
template<class T>
using @\libglobal{type_identity_t}@ = typename @\libglobalref{type_identity}@<T>::type;
template<class T>
using @\libglobal{remove_cvref_t}@ = typename @\libglobalref{remove_cvref}@<T>::type;
template<class T>
using @\libglobal{decay_t}@ = typename @\libglobalref{decay}@<T>::type;
template<bool B, class T = void>
using @\libglobal{enable_if_t}@ = typename @\libglobalref{enable_if}@<B, T>::type;
template<bool B, class T, class F>
using @\libglobal{conditional_t}@ = typename @\libglobalref{conditional}@<B, T, F>::type;
template<class... T>
using @\libglobal{common_type_t}@ = typename @\libglobalref{common_type}@<T...>::type;
template<class... T>
using @\libglobal{common_reference_t}@ = typename @\libglobalref{common_reference}@<T...>::type;
template<class T>
using @\libglobal{underlying_type_t}@ = typename @\libglobalref{underlying_type}@<T>::type;
template<class Fn, class... ArgTypes>
using @\libglobal{invoke_result_t}@ = typename @\libglobalref{invoke_result}@<Fn, ArgTypes...>::type;
template<class T>
using @\libglobal{unwrap_reference_t}@ = typename @\libglobalref{unwrap_reference}@<T>::type;
template<class T>
using @\libglobal{unwrap_ref_decay_t}@ = typename @\libglobalref{unwrap_ref_decay}@<T>::type;
template<class...>
using @\libglobal{void_t}@ = void;
// \ref{meta.logical}, logical operator traits
template<class... B> struct conjunction;
template<class... B> struct disjunction;
template<class B> struct negation;
// \ref{meta.unary.cat}, primary type categories
template<class T>
constexpr bool @\libglobal{is_void_v}@ = @\libglobalref{is_void}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_null_pointer_v}@ = @\libglobalref{is_null_pointer}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_integral_v}@ = @\libglobalref{is_integral}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_floating_point_v}@ = @\libglobalref{is_floating_point}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_array_v}@ = @\libglobalref{is_array}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_pointer_v}@ = @\libglobalref{is_pointer}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_lvalue_reference_v}@ = @\libglobalref{is_lvalue_reference}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_rvalue_reference_v}@ = @\libglobalref{is_rvalue_reference}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_member_object_pointer_v}@ = @\libglobalref{is_member_object_pointer}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_member_function_pointer_v}@ = @\libglobalref{is_member_function_pointer}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_enum_v}@ = @\libglobalref{is_enum}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_union_v}@ = @\libglobalref{is_union}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_class_v}@ = @\libglobalref{is_class}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_function_v}@ = @\libglobalref{is_function}@<T>::value;
// \ref{meta.unary.comp}, composite type categories
template<class T>
constexpr bool @\libglobal{is_reference_v}@ = @\libglobalref{is_reference}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_arithmetic_v}@ = @\libglobalref{is_arithmetic}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_fundamental_v}@ = @\libglobalref{is_fundamental}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_object_v}@ = @\libglobalref{is_object}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_scalar_v}@ = @\libglobalref{is_scalar}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_compound_v}@ = @\libglobalref{is_compound}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_member_pointer_v}@ = @\libglobalref{is_member_pointer}@<T>::value;
// \ref{meta.unary.prop}, type properties
template<class T>
constexpr bool @\libglobal{is_const_v}@ = @\libglobalref{is_const}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_volatile_v}@ = @\libglobalref{is_volatile}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_copyable_v}@ = @\libglobalref{is_trivially_copyable}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_standard_layout_v}@ = @\libglobalref{is_standard_layout}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_empty_v}@ = is_empty<T>::value;
template<class T>
constexpr bool @\libglobal{is_polymorphic_v}@ = @\libglobalref{is_polymorphic}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_abstract_v}@ = @\libglobalref{is_abstract}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_final_v}@ = @\libglobalref{is_final}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_aggregate_v}@ = @\libglobalref{is_aggregate}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_signed_v}@ = is_signed<T>::value;
template<class T>
constexpr bool @\libglobal{is_unsigned_v}@ = @\libglobalref{is_unsigned}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_bounded_array_v}@ = @\libglobalref{is_bounded_array}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_unbounded_array_v}@ = @\libglobalref{is_unbounded_array}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_scoped_enum_v}@ = @\libglobalref{is_scoped_enum}@<T>::value;
template<class T, class... Args>
constexpr bool @\libglobal{is_constructible_v}@ = @\libglobalref{is_constructible}@<T, Args...>::value;
template<class T>
constexpr bool @\libglobal{is_default_constructible_v}@ = @\libglobalref{is_default_constructible}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_copy_constructible_v}@ = @\libglobalref{is_copy_constructible}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_move_constructible_v}@ = @\libglobalref{is_move_constructible}@<T>::value;
template<class T, class U>
constexpr bool @\libglobal{is_assignable_v}@ = @\libglobalref{is_assignable}@<T, U>::value;
template<class T>
constexpr bool @\libglobal{is_copy_assignable_v}@ = @\libglobalref{is_copy_assignable}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_move_assignable_v}@ = @\libglobalref{is_move_assignable}@<T>::value;
template<class T, class U>
constexpr bool @\libglobal{is_swappable_with_v}@ = @\libglobalref{is_swappable_with}@<T, U>::value;
template<class T>
constexpr bool @\libglobal{is_swappable_v}@ = @\libglobalref{is_swappable}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_destructible_v}@ = @\libglobalref{is_destructible}@<T>::value;
template<class T, class... Args>
constexpr @\libglobal{bool is_trivially_constructible_v}@
= @\libglobalref{is_trivially_constructible}@<T, Args...>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_default_constructible_v}@
= @\libglobalref{is_trivially_default_constructible}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_copy_constructible_v}@
= @\libglobalref{is_trivially_copy_constructible}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_move_constructible_v}@
= @\libglobalref{is_trivially_move_constructible}@<T>::value;
template<class T, class U>
constexpr bool @\libglobal{is_trivially_assignable_v}@ = @\libglobalref{is_trivially_assignable}@<T, U>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_copy_assignable_v}@
= @\libglobalref{is_trivially_copy_assignable}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_move_assignable_v}@
= @\libglobalref{is_trivially_move_assignable}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_destructible_v}@ = @\libglobalref{is_trivially_destructible}@<T>::value;
template<class T, class... Args>
constexpr bool @\libglobal{is_nothrow_constructible_v}@
= @\libglobalref{is_nothrow_constructible}@<T, Args...>::value;
template<class T>
constexpr bool @\libglobal{is_nothrow_default_constructible_v}@
= @\libglobalref{is_nothrow_default_constructible}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_nothrow_copy_constructible_v}@
= @\libglobalref{is_nothrow_copy_constructible}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_nothrow_move_constructible_v}@
= @\libglobalref{is_nothrow_move_constructible}@<T>::value;
template<class T, class U>
constexpr bool @\libglobal{is_nothrow_assignable_v}@ = @\libglobalref{is_nothrow_assignable}@<T, U>::value;
template<class T>
constexpr bool @\libglobal{is_nothrow_copy_assignable_v}@ = @\libglobalref{is_nothrow_copy_assignable}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_nothrow_move_assignable_v}@ = @\libglobalref{is_nothrow_move_assignable}@<T>::value;
template<class T, class U>
constexpr bool @\libglobal{is_nothrow_swappable_with_v}@ = @\libglobalref{is_nothrow_swappable_with}@<T, U>::value;
template<class T>
constexpr bool @\libglobal{is_nothrow_swappable_v}@ = @\libglobalref{is_nothrow_swappable}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_nothrow_destructible_v}@ = @\libglobalref{is_nothrow_destructible}@<T>::value;
template<class T>
constexpr bool @\libglobal{is_implicit_lifetime_v}@ = @\libglobalref{is_implicit_lifetime}@<T>::value;
template<class T>
constexpr bool @\libglobal{has_virtual_destructor_v}@ = @\libglobalref{has_virtual_destructor}@<T>::value;
template<class T>
constexpr bool @\libglobal{has_unique_object_representations_v}@
= @\libglobalref{has_unique_object_representations}@<T>::value;
template<class T, class U>
constexpr bool @\libglobal{reference_constructs_from_temporary_v}@
= @\libglobalref{reference_constructs_from_temporary}@<T, U>::value;
template<class T, class U>
constexpr bool @\libglobal{reference_converts_from_temporary_v}@
= @\libglobalref{reference_converts_from_temporary}@<T, U>::value;
// \ref{meta.unary.prop.query}, type property queries
template<class T>
constexpr size_t @\libglobal{alignment_of_v}@ = @\libglobalref{alignment_of}@<T>::value;
template<class T>
constexpr size_t @\libglobal{rank_v}@ = @\libglobalref{rank}@<T>::value;
template<class T, unsigned I = 0>
constexpr size_t @\libglobal{extent_v}@ = @\libglobalref{extent}@<T, I>::value;
// \ref{meta.rel}, type relations
template<class T, class U>
constexpr bool @\libglobal{is_same_v}@ = @\libglobalref{is_same}@<T, U>::value;
template<class Base, class Derived>
constexpr bool @\libglobal{is_base_of_v}@ = @\libglobalref{is_base_of}@<Base, Derived>::value;
template<class Base, class Derived>
constexpr bool @\libglobal{is_virtual_base_of_v}@ = @\libglobalref{is_virtual_base_of}@<Base, Derived>::value;
template<class From, class To>
constexpr bool @\libglobal{is_convertible_v}@ = @\libglobalref{is_convertible}@<From, To>::value;
template<class From, class To>
constexpr bool @\libglobal{is_nothrow_convertible_v}@ = @\libglobalref{is_nothrow_convertible}@<From, To>::value;
template<class T, class U>
constexpr bool @\libglobal{is_layout_compatible_v}@ = @\libglobalref{is_layout_compatible}@<T, U>::value;
template<class Base, class Derived>
constexpr bool @\libglobal{is_pointer_interconvertible_base_of_v}@
= @\libglobalref{is_pointer_interconvertible_base_of}@<Base, Derived>::value;
template<class Fn, class... ArgTypes>
constexpr bool @\libglobal{is_invocable_v}@ = @\libglobalref{is_invocable}@<Fn, ArgTypes...>::value;
template<class R, class Fn, class... ArgTypes>
constexpr bool @\libglobal{is_invocable_r_v}@ = @\libglobalref{is_invocable_r}@<R, Fn, ArgTypes...>::value;
template<class Fn, class... ArgTypes>
constexpr bool @\libglobal{is_nothrow_invocable_v}@ = @\libglobalref{is_nothrow_invocable}@<Fn, ArgTypes...>::value;
template<class R, class Fn, class... ArgTypes>
constexpr bool is_nothrow_invocable_r_v
= @\libglobalref{is_nothrow_invocable_r}@<R, Fn, ArgTypes...>::value;
// \ref{meta.logical}, logical operator traits
template<class... B>
constexpr bool @\libglobal{conjunction_v}@ = @\libglobalref{conjunction}@<B...>::value;
template<class... B>
constexpr bool @\libglobal{disjunction_v}@ = @\libglobalref{disjunction}@<B...>::value;
template<class B>
constexpr bool @\libglobal{negation_v}@ = @\libglobalref{negation}@<B>::value;
// \ref{meta.member}, member relationships
template<class S, class M>
constexpr bool is_pointer_interconvertible_with_class(M S::*m) noexcept;
template<class S1, class S2, class M1, class M2>
constexpr bool is_corresponding_member(M1 S1::*m1, M2 S2::*m2) noexcept;
// \ref{meta.const.eval}, constant evaluation context
constexpr bool is_constant_evaluated() noexcept;
consteval bool is_within_lifetime(const auto*) noexcept;
}
\end{codeblock}
\rSec2[meta.help]{Helper classes}
\indexlibrarymember{value_type}{integral_constant}%
\begin{codeblock}
namespace std {
template<class T, T v> struct @\libglobal{integral_constant}@ {
static constexpr T value = v;
using value_type = T;
using type = integral_constant<T, v>;
constexpr operator value_type() const noexcept { return value; }
constexpr value_type operator()() const noexcept { return value; }
};
}
\end{codeblock}
\indexlibraryglobal{bool_constant}%
\indexlibraryglobal{true_type}%
\indexlibraryglobal{false_type}%
\pnum
The class template \tcode{integral_constant},
alias template \tcode{bool_constant}, and
its associated \grammarterm{typedef-name}{s}
\tcode{true_type} and \tcode{false_type}
are used as base classes to define
the interface for various type traits.
\rSec2[meta.unary]{Unary type traits}
\rSec3[meta.unary.general]{General}
\pnum
Subclause \ref{meta.unary} contains templates that may be used to query the
properties of a type at compile time.
\pnum
Each of these templates shall be a
\oldconceptref{UnaryTypeTrait}
with a base characteristic of
\tcode{true_type} if the corresponding condition is \tcode{true}, otherwise
\tcode{false_type}.
\rSec3[meta.unary.cat]{Primary type categories}
\pnum
The primary type categories specified in \tref{meta.unary.cat}
correspond to the descriptions given in
subclause~\ref{basic.types} of the \Cpp{} standard.
\pnum
For any given type \tcode{T}, the result of applying one of these templates to
\tcode{T} and to \cv{}~\tcode{T} shall yield the same result.
\pnum
\begin{note}
For any given type \tcode{T}, exactly one of the primary type categories
has a \tcode{value} member that evaluates to \tcode{true}.
\end{note}
\begin{libreqtab3e}{Primary type category predicates}{meta.unary.cat}
\\ \topline
\lhdr{Template} & \chdr{Condition} & \rhdr{Comments} \\\capsep
\endfirsthead
\continuedcaption\\
\topline
\lhdr{Template} & \chdr{Condition} & \rhdr{Comments} \\ \capsep
\endhead
\tcode{template<class T>}\br
\tcode{struct \libglobal{is_void};} &
\tcode{T} is \keyword{void} & \\ \rowsep
\tcode{template<class T>}\br
\tcode{struct \libglobal{is_null_pointer};} &
\tcode{T} is \tcode{nullptr_t}\iref{basic.fundamental} & \\ \rowsep
\tcode{template<class T>}\br
\tcode{struct \libglobal{is_integral};} &
\tcode{T} is an integral type\iref{basic.fundamental} & \\ \rowsep
\indexlibraryglobal{is_floating_point}%
\tcode{template<class T>}\br
\tcode{struct is_floating_point;} &
\tcode{T} is a floating-point type\iref{basic.fundamental} & \\ \rowsep
\indexlibraryglobal{is_array}%
\tcode{template<class T>}\br
\tcode{struct is_array;} &
\tcode{T} is an array type\iref{basic.compound} of known or unknown extent &
Class template \tcode{array}\iref{array}
is not an array type. \\ \rowsep
\indexlibraryglobal{is_pointer}%
\tcode{template<class T>}\br
\tcode{struct is_pointer;} &
\tcode{T} is a pointer type\iref{basic.compound} &
Includes pointers to functions
but not pointers to non-static members. \\ \rowsep
\indexlibraryglobal{is_lvalue_reference}%
\tcode{template<class T>}\br
\tcode{struct is_lvalue_reference;} &
\tcode{T} is an lvalue reference type\iref{dcl.ref} & \\ \rowsep
\indexlibraryglobal{is_rvalue_reference}%
\tcode{template<class T>}\br
\tcode{struct is_rvalue_reference;} &
\tcode{T} is an rvalue reference type\iref{dcl.ref} & \\ \rowsep
\indexlibraryglobal{is_member_object_pointer}%
\tcode{template<class T>}\br
\tcode{struct is_member_object_pointer;}&
\tcode{T} is a pointer to data member & \\ \rowsep
\indexlibraryglobal{is_member_function_pointer}%
\tcode{template<class T>}\br
\tcode{struct is_member_function_pointer;}&
\tcode{T} is a pointer to member function & \\ \rowsep
\indexlibraryglobal{is_enum}%
\tcode{template<class T>}\br
\tcode{struct is_enum;} &
\tcode{T} is an enumeration type\iref{basic.compound} & \\ \rowsep
\indexlibraryglobal{is_union}%
\tcode{template<class T>}\br
\tcode{struct is_union;} &
\tcode{T} is a union type\iref{basic.compound} & \\ \rowsep
\indexlibraryglobal{is_class}%
\tcode{template<class T>}\br
\tcode{struct is_class;} &
\tcode{T} is a non-union class type\iref{basic.compound} & \\ \rowsep
\indexlibraryglobal{is_function}%
\tcode{template<class T>}\br
\tcode{struct is_function;} &
\tcode{T} is a function type\iref{basic.compound} & \\
\end{libreqtab3e}
\rSec3[meta.unary.comp]{Composite type traits}
\pnum
The templates specified in \tref{meta.unary.comp}
provide convenient compositions of the primary type categories,
corresponding to the descriptions given in subclause~\ref{basic.types}.
\pnum
For any given type \tcode{T}, the result of applying one of these templates to
\tcode{T} and to \cv{}~\tcode{T} shall yield the same result.
\begin{libreqtab3b}{Composite type category predicates}{meta.unary.comp}
\\ \topline
\lhdr{Template} & \chdr{Condition} & \rhdr{Comments} \\ \capsep
\endfirsthead
\continuedcaption\\
\topline
\lhdr{Template} & \chdr{Condition} & \rhdr{Comments} \\ \capsep
\endhead
\indexlibraryglobal{is_reference}%
\tcode{template<class T>}\br
\tcode{struct is_reference;} &
\tcode{T} is an lvalue reference or an rvalue reference & \\ \rowsep
\indexlibraryglobal{is_arithmetic}%
\tcode{template<class T>}\br
\tcode{struct is_arithmetic;} &
\tcode{T} is an arithmetic type\iref{basic.fundamental} & \\ \rowsep
\indexlibraryglobal{is_fundamental}%
\tcode{template<class T>}\br
\tcode{struct is_fundamental;} &
\tcode{T} is a fundamental type\iref{basic.fundamental} & \\ \rowsep
\indexlibraryglobal{is_object}%
\tcode{template<class T>}\br
\tcode{struct is_object;} &
\tcode{T} is an object type\iref{term.object.type} & \\ \rowsep
\indexlibraryglobal{is_scalar}%
\tcode{template<class T>}\br
\tcode{struct is_scalar;} &
\tcode{T} is a scalar type\iref{term.scalar.type} & \\ \rowsep
\indexlibraryglobal{is_compound}%
\tcode{template<class T>}\br
\tcode{struct is_compound;} &
\tcode{T} is a compound type\iref{basic.compound} & \\ \rowsep
\indexlibraryglobal{is_member_pointer}%
\tcode{template<class T>}\br
\tcode{struct is_member_pointer;} &
\tcode{T} is a pointer-to-member type\iref{basic.compound} & \\
\end{libreqtab3b}
\rSec3[meta.unary.prop]{Type properties}
\pnum
The templates specified in \tref{meta.unary.prop}
provide access to some of the more important properties of types.
\pnum
It is unspecified whether the library defines any full or partial
specializations of any of these templates.
\pnum
For all of the class templates \tcode{X} declared in this subclause,
instantiating that template with a template-argument that is a class
template specialization may result in the implicit instantiation of
the template argument if and only if the semantics of \tcode{X} require that
the argument is a complete type.
\pnum
For the purpose of defining the templates in this subclause,
a function call expression \tcode{declval<T>()} for any type \tcode{T}
is considered to be a trivial\iref{term.trivial.type,special} function call
that is not an odr-use\iref{term.odr.use} of \tcode{declval}
in the context of the corresponding definition
notwithstanding the restrictions of~\ref{declval}.
\pnum
For the purpose of defining the templates in this subclause,
let \tcode{\placeholdernc{VAL}<T>} for some type \tcode{T} be
an expression defined as follows:
\begin{itemize}
\item
If \tcode{T} is a reference or function type,
\tcode{\placeholdernc{VAL}<T>} is an expression
with the same type and value category as \tcode{declval<T>()}.
\item
Otherwise, \tcode{\placeholdernc{VAL}<T>} is a prvalue
that initially has type \tcode{T}.
\begin{note}
If \tcode{T} is cv-qualified,
the cv-qualification is subject to adjustment\iref{expr.type}.
\end{note}
\end{itemize}
\begin{libreqtab3b}{Type property predicates}{meta.unary.prop}
\\ \topline
\lhdr{Template} & \chdr{Condition} & \rhdr{Preconditions} \\ \capsep
\endfirsthead
\continuedcaption\\
\topline
\lhdr{Template} & \chdr{Condition} & \rhdr{Preconditions} \\ \capsep
\endhead
\indexlibraryglobal{is_const}%
\tcode{template<class T>}\br
\tcode{struct is_const;} &
\tcode{T} is const-qualified\iref{basic.type.qualifier} & \\ \rowsep
\indexlibraryglobal{is_volatile}%
\tcode{template<class T>}\br
\tcode{struct is_volatile;} &
\tcode{T} is volatile-qualified\iref{basic.type.qualifier} & \\ \rowsep
\indexlibraryglobal{is_trivially_copyable}%
\tcode{template<class T>}\br
\tcode{struct is_trivially_copyable;} &
\tcode{T} is a trivially copyable type\iref{term.trivially.copyable.type} &
\tcode{remove_all_extents_t<T>} shall be a complete type or
\cv{}~\keyword{void}. \\ \rowsep
\indexlibraryglobal{is_standard_layout}%
\tcode{template<class T>}\br
\tcode{struct is_standard_layout;} &
\tcode{T} is a standard-layout type\iref{term.standard.layout.type} &
\tcode{remove_all_extents_t<T>} shall be a complete
type or \cv{}~\keyword{void}. \\ \rowsep
\indexlibrary{\idxcode{is_empty}!class}%
\tcode{template<class T>}\br
\tcode{struct is_empty;} &
\tcode{T} is a class type, but not a union type, with no non-static data
members other than subobjects of zero size, no virtual member functions,
no virtual base classes, and no base class \tcode{B} for
which \tcode{is_empty_v<B>} is \tcode{false}. &
If \tcode{T} is a non-union class type, \tcode{T} shall be a complete type. \\ \rowsep
\indexlibraryglobal{is_polymorphic}%
\tcode{template<class T>}\br
\tcode{struct is_polymorphic;} &
\tcode{T} is a polymorphic class\iref{class.virtual} &
If \tcode{T} is a non-union class type, \tcode{T} shall be a complete type. \\ \rowsep
\indexlibraryglobal{is_abstract}%
\tcode{template<class T>}\br
\tcode{struct is_abstract;} &
\tcode{T} is an abstract class\iref{class.abstract} &
If \tcode{T} is a non-union class type, \tcode{T} shall be a complete type. \\ \rowsep
\tcode{template<class T>}\br
\tcode{struct \libglobal{is_final};} &
\tcode{T} is a class type marked with the \grammarterm{class-virt-specifier}
\tcode{final}\iref{class.pre}.
\begin{tailnote}
A union is a class type that
can be marked with \tcode{final}.
\end{tailnote}
&
If \tcode{T} is a class type, \tcode{T} shall be a complete type. \\ \rowsep
\tcode{template<class T>}\br
\tcode{struct \libglobal{is_aggregate};} &
\tcode{T} is an aggregate type\iref{dcl.init.aggr} &
\tcode{T} shall be an array type, a complete type, or \cv~\keyword{void}. \\ \rowsep
\indexlibrary{\idxcode{is_signed}!class}%
\tcode{template<class T>}\br
\tcode{struct is_signed;} &
If \tcode{is_arithmetic_v<T>} is \tcode{true}, the same result as
\tcode{T(-1) < T(0)};
otherwise, \tcode{false} & \\ \rowsep
\tcode{template<class T>}\br
\tcode{struct \libglobal{is_unsigned};} &
If \tcode{is_arithmetic_v<T>} is \tcode{true}, the same result as
\tcode{T(0) < T(-1)};
otherwise, \tcode{false} & \\ \rowsep
\tcode{template<class T>}\br
\tcode{struct \libglobal{is_bounded_array};} &
\tcode{T} is an array type of known bound\iref{dcl.array}
& \\ \rowsep
\indexlibraryglobal{is_unbounded_array}%
\tcode{template<class T>}\br
\tcode{struct is_unbounded_array;} &
\tcode{T} is an array type of unknown bound\iref{dcl.array}
& \\ \rowsep
\indexlibraryglobal{is_scoped_enum}%
\tcode{template<class T>}\br
\tcode{struct is_scoped_enum;} &
\tcode{T} is a scoped enumeration\iref{dcl.enum}
& \\ \rowsep
\indexlibraryglobal{is_constructible}%
\tcode{template<class T, class... Args>}\br
\tcode{struct is_constructible;} &
For a function type \tcode{T} or
for a \cv{}~\keyword{void} type \tcode{T},
\tcode{is_constructible_v<T, Args...>} is \tcode{false},
otherwise \seebelow &
\tcode{T} and all types in the template parameter pack \tcode{Args}
shall be complete types, \cv{}~\keyword{void},
or arrays of unknown bound. \\ \rowsep
\indexlibraryglobal{is_default_constructible}%
\tcode{template<class T>}\br
\tcode{struct is_default_constructible;} &
\tcode{is_constructible_v<T>} is \tcode{true}. &
\tcode{T} shall be a complete type, \cv{}~\keyword{void},
or an array of unknown bound. \\ \rowsep
\indexlibraryglobal{is_copy_constructible}%
\tcode{template<class T>}\br
\tcode{struct is_copy_constructible;} &
For a referenceable type \tcode{T}\iref{defns.referenceable}, the same result as
\tcode{is_constructible_v<T, const T\&>}, otherwise \tcode{false}. &
\tcode{T} shall be a complete type, \cv{}~\keyword{void},
or an array of unknown bound. \\ \rowsep
\indexlibraryglobal{is_move_constructible}%
\tcode{template<class T>}\br
\tcode{struct is_move_constructible;} &
For a referenceable type \tcode{T}, the same result as
\tcode{is_constructible_v<T, T\&\&>}, otherwise \tcode{false}. &
\tcode{T} shall be a complete type, \cv{}~\keyword{void},
or an array of unknown bound. \\ \rowsep
\indexlibraryglobal{is_assignable}%
\tcode{template<class T, class U>}\br
\tcode{struct is_assignable;} &
The expression \tcode{declval<T>() =} \tcode{declval<U>()} is well-formed
when treated as an unevaluated
operand\iref{term.unevaluated.operand}. Access checking is performed as if in a context
unrelated to \tcode{T} and \tcode{U}. Only the validity of the immediate context
of the assignment expression is considered.
\begin{tailnote}
The compilation of the
expression can result in side effects such as the instantiation of class template
specializations and function template specializations, the generation of
implicitly-defined functions, and so on. Such side effects are not in the ``immediate
context'' and can result in the program being ill-formed.
\end{tailnote}
&
\tcode{T} and \tcode{U} shall be complete types, \cv{}~\keyword{void},
or arrays of unknown bound. \\ \rowsep
\indexlibraryglobal{is_copy_assignable}%
\tcode{template<class T>}\br
\tcode{struct is_copy_assignable;} &
For a referenceable type \tcode{T}, the same result as
\tcode{is_assignable_v<T\&, const T\&>}, otherwise \tcode{false}. &
\tcode{T} shall be a complete type, \cv{}~\keyword{void},
or an array of unknown bound. \\ \rowsep
\indexlibraryglobal{is_move_assignable}%
\tcode{template<class T>}\br
\tcode{struct is_move_assignable;} &
For a referenceable type \tcode{T}, the same result as
\tcode{is_assignable_v<T\&, T\&\&>}, otherwise \tcode{false}. &
\tcode{T} shall be a complete type, \cv{}~\keyword{void},
or an array of unknown bound. \\ \rowsep
\indexlibraryglobal{is_swappable_with}%
\tcode{template<class T, class U>}\br
\tcode{struct is_swappable_with;} &
The expressions \tcode{swap(declval<T>(), declval<U>())} and
\tcode{swap(declval<U>(), declval<T>())} are each well-formed
when treated as an unevaluated operand\iref{term.unevaluated.operand}
in an overload-resolution context
for swappable values\iref{swappable.requirements}.
Access checking is performed as if in a context
unrelated to \tcode{T} and \tcode{U}.
Only the validity of the immediate context
of the \tcode{swap} expressions is considered.
\begin{tailnote}
The compilation of the expressions can result in side effects
such as the instantiation of class template specializations and
function template specializations,
the generation of implicitly-defined functions, and so on.
Such side effects are not in the ``immediate context'' and
can result in the program being ill-formed.
\end{tailnote}
&
\tcode{T} and \tcode{U} shall be complete types,