-
Notifications
You must be signed in to change notification settings - Fork 751
/
support.tex
5858 lines (5020 loc) · 181 KB
/
support.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[support]{Language support library}
\rSec1[support.general]{General}
\pnum
This Clause describes the function signatures that are called
implicitly, and the types of objects generated implicitly, during the execution
of some \Cpp{} programs.
It also describes the headers that declare these function
signatures and define any related types.
\pnum
The following subclauses describe
common type definitions used throughout the library,
characteristics of the predefined types,
functions supporting start and termination of a \Cpp{} program,
support for dynamic memory management,
support for dynamic type identification,
support for exception processing, support for initializer lists,
and other runtime support,
as summarized in \tref{support.summary}.
\begin{libsumtab}{Language support library summary}{support.summary}
\ref{support.types} & Common definitions &
\tcode{<cstddef>}, \tcode{<cstdlib>} \\ \rowsep
\ref{support.limits} & Implementation properties &
\tcode{<cfloat>}, \tcode{<climits>}, \tcode{<limits>}, \tcode{<version>} \\ \rowsep
\ref{cstdint} & Integer types & \tcode{<cstdint>} \\ \rowsep
\ref{support.start.term} & Start and termination & \tcode{<cstdlib>} \\ \rowsep
\ref{support.dynamic} & Dynamic memory management & \tcode{<new>} \\ \rowsep
\ref{support.rtti} & Type identification & \tcode{<typeinfo>} \\ \rowsep
\ref{support.srcloc} & Source location & \tcode{<source_location>} \\ \rowsep
\ref{support.exception} & Exception handling & \tcode{<exception>} \\ \rowsep
\ref{support.initlist} & Initializer lists & \tcode{<initializer_list>} \\ \rowsep
\ref{cmp} & Comparisons & \tcode{<compare>} \\ \rowsep
\ref{support.coroutine} & Coroutines & \tcode{<coroutine>} \\ \rowsep
\ref{support.runtime} & Other runtime support &
\tcode{<csetjmp>}, \tcode{<csignal>}, \tcode{<cstdarg>}, \tcode{<cstdlib>} \\
\end{libsumtab}
\rSec1[support.types]{Common definitions}
\rSec2[cstddef.syn]{Header \tcode{<cstddef>} synopsis}
\indexlibraryglobal{NULL}%
\indexlibraryglobal{offsetof}%
\indexlibraryglobal{ptrdiff_t}%
\indexlibraryglobal{size_t}%
\indexlibraryglobal{max_align_t}%
\indexlibraryglobal{nullptr_t}%
\indexlibraryglobal{byte}%
\begin{codeblock}
namespace std {
using ptrdiff_t = @\seebelow@;
using size_t = @\seebelow@;
using max_align_t = @\seebelow@;
using nullptr_t = decltype(nullptr);
enum class byte : unsigned char {};
// \ref{support.types.byteops}, \tcode{byte} type operations
template<class IntType>
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
template<class IntType>
constexpr byte operator<<(byte b, IntType shift) noexcept;
template<class IntType>
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
template<class IntType>
constexpr byte operator>>(byte b, IntType shift) noexcept;
constexpr byte& operator|=(byte& l, byte r) noexcept;
constexpr byte operator|(byte l, byte r) noexcept;
constexpr byte& operator&=(byte& l, byte r) noexcept;
constexpr byte operator&(byte l, byte r) noexcept;
constexpr byte& operator^=(byte& l, byte r) noexcept;
constexpr byte operator^(byte l, byte r) noexcept;
constexpr byte operator~(byte b) noexcept;
template<class IntType>
constexpr IntType to_integer(byte b) noexcept;
}
#define NULL @\seebelow@
#define offsetof(P, D) @\seebelow@
\end{codeblock}
\pnum
The contents and meaning of the header \libheaderdef{cstddef} are the same as
the C standard library header \libheader{stddef.h},
except that it does not declare the type \keyword{wchar_t},
that it also declares the type \tcode{byte}
and its associated operations\iref{support.types.byteops},
and as noted in
\ref{support.types.nullptr} and
\ref{support.types.layout}.
\xrefc{7.19}
\rSec2[cstdlib.syn]{Header \tcode{<cstdlib>} synopsis}
\indexheader{cstdlib}%
\indexlibraryglobal{EXIT_FAILURE}%
\indexlibraryglobal{EXIT_SUCCESS}%
\indexlibraryglobal{MB_CUR_MAX}%
\indexlibraryglobal{NULL}%
\indexlibraryglobal{RAND_MAX}%
\indexlibraryglobal{_Exit}%
\indexlibraryglobal{abort}%
\indexlibraryglobal{abs}%
\indexlibraryglobal{aligned_alloc}%
\indexlibraryglobal{at_quick_exit}%
\indexlibraryglobal{atexit}%
\indexlibraryglobal{atof}%
\indexlibraryglobal{atoi}%
\indexlibraryglobal{atol}%
\indexlibraryglobal{atoll}%
\indexlibraryglobal{bsearch}%
\indexlibraryglobal{calloc}%
\indexlibraryglobal{div}%
\indexlibraryglobal{div_t}%
\indexlibraryglobal{exit}%
\indexlibraryglobal{free}%
\indexlibraryglobal{getenv}%
\indexlibraryglobal{labs}%
\indexlibraryglobal{ldiv}%
\indexlibraryglobal{ldiv_t}%
\indexlibraryglobal{llabs}%
\indexlibraryglobal{lldiv}%
\indexlibraryglobal{lldiv_t}%
\indexlibraryglobal{malloc}%
\indexlibraryglobal{mblen}%
\indexlibraryglobal{mbstowcs}%
\indexlibraryglobal{mbtowc}%
\indexlibraryglobal{qsort}%
\indexlibraryglobal{quick_exit}%
\indexlibraryglobal{rand}%
\indexlibraryglobal{realloc}%
\indexlibraryglobal{size_t}%
\indexlibraryglobal{srand}%
\indexlibraryglobal{strtod}%
\indexlibraryglobal{strtof}%
\indexlibraryglobal{strtol}%
\indexlibraryglobal{strtold}%
\indexlibraryglobal{strtoll}%
\indexlibraryglobal{strtoul}%
\indexlibraryglobal{strtoull}%
\indexlibraryglobal{system}%
\indexlibraryglobal{wcstombs}%
\indexlibraryglobal{wctomb}%
\begin{codeblock}
namespace std {
using size_t = @\seebelow@;
using div_t = @\seebelow@;
using ldiv_t = @\seebelow@;
using lldiv_t = @\seebelow@;
}
#define NULL @\seebelow@
#define EXIT_FAILURE @\seebelow@
#define EXIT_SUCCESS @\seebelow@
#define RAND_MAX @\seebelow@
#define MB_CUR_MAX @\seebelow@
namespace std {
// Exposition-only function type aliases
extern "C" using @\placeholdernc{c-atexit-handler}@ = void(); // \expos
extern "C++" using @\placeholdernc{atexit-handler}@ = void(); // \expos
extern "C" using @\placeholdernc{c-compare-pred}@ = int(const void*, const void*); // \expos
extern "C++" using @\placeholdernc{compare-pred}@ = int(const void*, const void*); // \expos
// \ref{support.start.term}, start and termination
[[noreturn]] void abort() noexcept;
int atexit(@\placeholder{c-atexit-handler}@* func) noexcept;
int atexit(@\placeholder{atexit-handler}@* func) noexcept;
int at_quick_exit(@\placeholder{c-atexit-handler}@* func) noexcept;
int at_quick_exit(@\placeholder{atexit-handler}@* func) noexcept;
[[noreturn]] void exit(int status);
[[noreturn]] void _Exit(int status) noexcept;
[[noreturn]] void quick_exit(int status) noexcept;
char* getenv(const char* name);
int system(const char* string);
// \ref{c.malloc}, C library memory allocation
void* aligned_alloc(size_t alignment, size_t size);
void* calloc(size_t nmemb, size_t size);
void free(void* ptr);
void* malloc(size_t size);
void* realloc(void* ptr, size_t size);
double atof(const char* nptr);
int atoi(const char* nptr);
long int atol(const char* nptr);
long long int atoll(const char* nptr);
double strtod(const char* nptr, char** endptr);
float strtof(const char* nptr, char** endptr);
long double strtold(const char* nptr, char** endptr);
long int strtol(const char* nptr, char** endptr, int base);
long long int strtoll(const char* nptr, char** endptr, int base);
unsigned long int strtoul(const char* nptr, char** endptr, int base);
unsigned long long int strtoull(const char* nptr, char** endptr, int base);
// \ref{c.mb.wcs}, multibyte / wide string and character conversion functions
int mblen(const char* s, size_t n);
int mbtowc(wchar_t* pwc, const char* s, size_t n);
int wctomb(char* s, wchar_t wchar);
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
// \ref{alg.c.library}, C standard library algorithms
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
@\placeholder{c-compare-pred}@*@\itcorr[-1]@ compar);
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
@\placeholder{compare-pred}@*@\itcorr[-1]@ compar);
void qsort(void* base, size_t nmemb, size_t size, @\placeholder{c-compare-pred}@*@\itcorr[-1]@ compar);
void qsort(void* base, size_t nmemb, size_t size, @\placeholder{compare-pred}@*@\itcorr[-1]@ compar);
// \ref{c.math.rand}, low-quality random number generation
int rand();
void srand(unsigned int seed);
// \ref{c.math.abs}, absolute values
int abs(int j);
long int abs(long int j);
long long int abs(long long int j);
float abs(float j);
double abs(double j);
long double abs(long double j);
long int labs(long int j);
long long int llabs(long long int j);
div_t div(int numer, int denom);
ldiv_t div(long int numer, long int denom); // see \ref{library.c}
lldiv_t div(long long int numer, long long int denom); // see \ref{library.c}
ldiv_t ldiv(long int numer, long int denom);
lldiv_t lldiv(long long int numer, long long int denom);
}
\end{codeblock}
\pnum
The contents and meaning of the header \libheader{cstdlib} are the same as
the C standard library header \libheader{stdlib.h},
except that it does not declare the type \keyword{wchar_t},
and except as noted in
\ref{support.types.nullptr},
\ref{support.types.layout},
\ref{support.start.term},
\ref{c.malloc},
\ref{c.mb.wcs},
\ref{alg.c.library},
\ref{c.math.rand}, and
\ref{c.math.abs}.
\begin{note}
Several functions have additional overloads in this document,
but they have the same behavior as in the C standard library\iref{library.c}.
\end{note}
\xrefc{7.22}
\rSec2[support.types.nullptr]{Null pointers}
\pnum
\indexlibraryglobal{nullptr_t}%
The type \tcode{nullptr_t} is a synonym
for the type of a \keyword{nullptr} expression, and it
has the characteristics
described in~\ref{basic.fundamental} and~\ref{conv.ptr}.
\begin{note}
Although \keyword{nullptr}'s address cannot be taken, the address of another
\tcode{nullptr_t} object that is an lvalue can be taken.
\end{note}
\pnum
The macro
\indexlibraryglobal{NULL}%
\tcode{NULL}
is an \impldef{definition of \tcode{NULL}} null pointer constant.
\begin{footnote}
Possible definitions include
\tcode{0}
and
\tcode{0L},
but not
\tcode{(void*)0}.
\end{footnote}
\xrefc{7.19}
\rSec2[support.types.layout]{Sizes, alignments, and offsets}
\pnum
The macro
\indexlibraryglobal{offsetof}%
\tcode{offsetof(\placeholder{type}, \placeholder{member-designator})}
has the same semantics as the corresponding macro in
the C standard library header \libheader{stddef.h}, but
accepts a restricted set of \tcode{\placeholder{type}}
arguments in this document.
Use of the \tcode{offsetof} macro with a \tcode{\placeholder{type}}
other than a standard-layout class\iref{class.prop}
is conditionally-supported.
\begin{footnote}
Note that \tcode{offsetof}
is required to work as specified even if unary
\tcode{operator\&}
is overloaded for any of the types involved.
\end{footnote}
The expression \tcode{offsetof(\placeholder{type}, \placeholder{member-designator})}
is never type-dependent\iref{temp.dep.expr} and it is
value-dependent\iref{temp.dep.constexpr} if and only if \tcode{\placeholder{type}} is
dependent. The result of applying the \tcode{offsetof} macro to
a static data member or a function member is undefined.
No operation invoked by the \tcode{offsetof} macro shall throw an exception and
\tcode{noexcept(offsetof(\placeholder{type}, \placeholder{member-designator}))} shall be \tcode{true}.
\pnum
The type \tcode{ptrdiff_t} is an
\impldef{type of \tcode{ptrdiff_t}}
signed integer type that can
hold the difference of two subscripts in an array object, as described in~\ref{expr.add}.
\pnum
The type \tcode{size_t} is an
\impldef{type of \tcode{size_t}}
unsigned integer type that is large enough
to contain the size in bytes of any object\iref{expr.sizeof}.
\pnum
\begin{note}
It is recommended that implementations choose types for \tcode{ptrdiff_t} and \tcode{size_t}
whose integer conversion ranks\iref{conv.rank} are no greater than that of
\tcode{signed long int} unless a larger size is necessary to contain all the possible values.
\end{note}
\pnum
The type
\indexlibraryglobal{max_align_t}%
\tcode{max_align_t} is a trivial standard-layout type whose alignment requirement
is at least as great as that of every scalar type, and whose alignment
requirement is supported in every context\iref{basic.align}.
\xrefc{7.19}
\rSec2[support.types.byteops]{\tcode{byte} type operations}
\indexlibrarymember{operator<<=}{byte}%
\begin{itemdecl}
template<class IntType>
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\constraints
\tcode{is_integral_v<IntType>} is \tcode{true}.
\pnum
\effects
Equivalent to:
\tcode{return b = b << shift;}
\end{itemdescr}
\indexlibrarymember{operator<<}{byte}%
\begin{itemdecl}
template<class IntType>
constexpr byte operator<<(byte b, IntType shift) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\constraints
\tcode{is_integral_v<IntType>} is \tcode{true}.
\pnum
\effects
Equivalent to:
\begin{codeblock}
return static_cast<byte>(static_cast<unsigned int>(b) << shift);
\end{codeblock}
\end{itemdescr}
\indexlibrarymember{operator>>=}{byte}%
\begin{itemdecl}
template<class IntType>
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\constraints
\tcode{is_integral_v<IntType>} is \tcode{true}.
\pnum
\effects
Equivalent to:
\tcode{return b = b >> shift;}
\end{itemdescr}
\indexlibrarymember{operator>>}{byte}%
\begin{itemdecl}
template<class IntType>
constexpr byte operator>>(byte b, IntType shift) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\constraints
\tcode{is_integral_v<IntType>} is \tcode{true}.
\pnum
\effects
Equivalent to:
\begin{codeblock}
return static_cast<byte>(static_cast<unsigned int>(b) >> shift);
\end{codeblock}
\end{itemdescr}
\indexlibrarymember{operator"|=}{byte}%
\begin{itemdecl}
constexpr byte& operator|=(byte& l, byte r) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return l = l | r;}
\end{itemdescr}
\indexlibrarymember{operator"|}{byte}%
\begin{itemdecl}
constexpr byte operator|(byte l, byte r) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
return static_cast<byte>(static_cast<unsigned int>(l) | static_cast<unsigned int>(r));
\end{codeblock}
\end{itemdescr}
\indexlibrarymember{operator\&=}{byte}%
\begin{itemdecl}
constexpr byte& operator&=(byte& l, byte r) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return l = l \& r;}
\end{itemdescr}
\indexlibrarymember{operator\&}{byte}%
\begin{itemdecl}
constexpr byte operator&(byte l, byte r) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
return static_cast<byte>(static_cast<unsigned int>(l) & static_cast<unsigned int>(r));
\end{codeblock}
\end{itemdescr}
\indexlibrarymember{operator\caret=}{byte}%
\begin{itemdecl}
constexpr byte& operator^=(byte& l, byte r) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return l = l \caret{} r;}
\end{itemdescr}
\indexlibrarymember{operator\caret}{byte}%
\begin{itemdecl}
constexpr byte operator^(byte l, byte r) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
return static_cast<byte>(static_cast<unsigned int>(l) ^ static_cast<unsigned int>(r));
\end{codeblock}
\end{itemdescr}
\indexlibrarymember{operator\~{}}{byte}%
\begin{itemdecl}
constexpr byte operator~(byte b) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
return static_cast<byte>(~static_cast<unsigned int>(b));
\end{codeblock}
\end{itemdescr}
\indexlibrarymember{to_integer}{byte}%
\begin{itemdecl}
template<class IntType>
constexpr IntType to_integer(byte b) noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
\constraints
\tcode{is_integral_v<IntType>} is \tcode{true}.
\pnum
\effects
Equivalent to: \tcode{return static_cast<IntType>(b);}
\end{itemdescr}
\rSec1[support.limits]{Implementation properties}
\rSec2[support.limits.general]{General}
\pnum
The headers
\libheaderref{limits},
\libheaderref{climits}, and
\libheaderref{cfloat}
supply characteristics of
\indextext{implementation-dependent}%
imple\-mentation-dependent
arithmetic types\iref{basic.fundamental}.
\rSec2[version.syn]{Header \tcode{<version>} synopsis}
\pnum
The header \libheaderdef{version}
supplies implementation-dependent information
about the \Cpp{} standard library
(e.g., version number and release date).
\pnum
Each of the macros defined in \libheader{version} is also defined
after inclusion of any member of the set of library headers
indicated in the corresponding comment in this synopsis.
\begin{note}
Future revisions of \Cpp{} might replace
the values of these macros with greater values.
\end{note}
\begin{codeblock}
#define @\defnlibxname{cpp_lib_addressof_constexpr}@ 201603L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_allocate_at_least}@ 202106L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_allocator_traits_is_always_equal}@ 201411L
// also in \libheader{memory}, \libheader{scoped_allocator}, \libheader{string}, \libheader{deque}, \libheader{forward_list}, \libheader{list}, \libheader{vector},
// \libheader{map}, \libheader{set}, \libheader{unordered_map}, \libheader{unordered_set}
#define @\defnlibxname{cpp_lib_adaptor_iterator_pair_constructor}@ 202106L // also in \libheader{stack}, \libheader{queue}
#define @\defnlibxname{cpp_lib_any}@ 201606L // also in \libheader{any}
#define @\defnlibxname{cpp_lib_apply}@ 201603L // also in \libheader{tuple}
#define @\defnlibxname{cpp_lib_array_constexpr}@ 201811L // also in \libheader{iterator}, \libheader{array}
#define @\defnlibxname{cpp_lib_as_const}@ 201510L // also in \libheader{utility}
#define @\defnlibxname{cpp_lib_assume_aligned}@ 201811L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_atomic_flag_test}@ 201907L // also in \libheader{atomic}
#define @\defnlibxname{cpp_lib_atomic_float}@ 201711L // also in \libheader{atomic}
#define @\defnlibxname{cpp_lib_atomic_is_always_lock_free}@ 201603L // also in \libheader{atomic}
#define @\defnlibxname{cpp_lib_atomic_lock_free_type_aliases}@ 201907L // also in \libheader{atomic}
#define @\defnlibxname{cpp_lib_atomic_ref}@ 201806L // also in \libheader{atomic}
#define @\defnlibxname{cpp_lib_atomic_shared_ptr}@ 201711L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_atomic_value_initialization}@ 201911L // also in \libheader{atomic}, \libheader{memory}
#define @\defnlibxname{cpp_lib_atomic_wait}@ 201907L // also in \libheader{atomic}
#define @\defnlibxname{cpp_lib_barrier}@ 201907L // also in \libheader{barrier}
#define @\defnlibxname{cpp_lib_bind_front}@ 201907L // also in \libheader{functional}
#define @\defnlibxname{cpp_lib_bit_cast}@ 201806L // also in \libheader{bit}
#define @\defnlibxname{cpp_lib_bitops}@ 201907L // also in \libheader{bit}
#define @\defnlibxname{cpp_lib_bool_constant}@ 201505L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_bounded_array_traits}@ 201902L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_boyer_moore_searcher}@ 201603L // also in \libheader{functional}
#define @\defnlibxname{cpp_lib_byte}@ 201603L // also in \libheader{cstddef}
#define @\defnlibxname{cpp_lib_char8_t}@ 201907L
// also in \libheader{atomic}, \libheader{filesystem}, \libheader{istream}, \libheader{limits}, \libheader{locale}, \libheader{ostream}, \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_chrono}@ 201907L // also in \libheader{chrono}
#define @\defnlibxname{cpp_lib_chrono_udls}@ 201304L // also in \libheader{chrono}
#define @\defnlibxname{cpp_lib_clamp}@ 201603L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_complex_udls}@ 201309L // also in \libheader{complex}
#define @\defnlibxname{cpp_lib_concepts}@ 202002L // also in \libheader{concepts}
#define @\defnlibxname{cpp_lib_constexpr_algorithms}@ 201806L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_constexpr_complex}@ 201711L // also in \libheader{complex}
#define @\defnlibxname{cpp_lib_constexpr_dynamic_alloc}@ 201907L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_constexpr_functional}@ 201907L // also in \libheader{functional}
#define @\defnlibxname{cpp_lib_constexpr_iterator}@ 201811L // also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_constexpr_memory}@ 201811L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_constexpr_numeric}@ 201911L // also in \libheader{numeric}
#define @\defnlibxname{cpp_lib_constexpr_string}@ 201907L // also in \libheader{string}
#define @\defnlibxname{cpp_lib_constexpr_string_view}@ 201811L // also in \libheader{string_view}
#define @\defnlibxname{cpp_lib_constexpr_tuple}@ 201811L // also in \libheader{tuple}
#define @\defnlibxname{cpp_lib_constexpr_typeinfo}@ 202106L // also in \libheader{typeinfo}
#define @\defnlibxname{cpp_lib_constexpr_utility}@ 201811L // also in \libheader{utility}
#define @\defnlibxname{cpp_lib_constexpr_vector}@ 201907L // also in \libheader{vector}
#define @\defnlibxname{cpp_lib_coroutine}@ 201902L // also in \libheader{coroutine}
#define @\defnlibxname{cpp_lib_destroying_delete}@ 201806L // also in \libheader{new}
#define @\defnlibxname{cpp_lib_enable_shared_from_this}@ 201603L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_endian}@ 201907L // also in \libheader{bit}
#define @\defnlibxname{cpp_lib_erase_if}@ 202002L
// also in \libheader{string}, \libheader{deque}, \libheader{forward_list}, \libheader{list}, \libheader{vector}, \libheader{map}, \libheader{set}, \libheader{unordered_map},
// \libheader{unordered_set}
#define @\defnlibxname{cpp_lib_exchange_function}@ 201304L // also in \libheader{utility}
#define @\defnlibxname{cpp_lib_execution}@ 201902L // also in \libheader{execution}
#define @\defnlibxname{cpp_lib_filesystem}@ 201703L // also in \libheader{filesystem}
#define @\defnlibxname{cpp_lib_format}@ 202106L // also in \libheader{format}
#define @\defnlibxname{cpp_lib_gcd_lcm}@ 201606L // also in \libheader{numeric}
#define @\defnlibxname{cpp_lib_generic_associative_lookup}@ 201304L // also in \libheader{map}, \libheader{set}
#define @\defnlibxname{cpp_lib_generic_unordered_lookup}@ 201811L
// also in \libheader{unordered_map}, \libheader{unordered_set}
#define @\defnlibxname{cpp_lib_hardware_interference_size}@ 201703L // also in \libheader{new}
#define @\defnlibxname{cpp_lib_has_unique_object_representations}@ 201606L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_hypot}@ 201603L // also in \libheader{cmath}
#define @\defnlibxname{cpp_lib_incomplete_container_elements}@ 201505L
// also in \libheader{forward_list}, \libheader{list}, \libheader{vector}
#define @\defnlibxname{cpp_lib_int_pow2}@ 202002L // also in \libheader{bit}
#define @\defnlibxname{cpp_lib_integer_comparison_functions}@ 202002L // also in \libheader{utility}
#define @\defnlibxname{cpp_lib_integer_sequence}@ 201304L // also in \libheader{utility}
#define @\defnlibxname{cpp_lib_integral_constant_callable}@ 201304L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_interpolate}@ 201902L // also in \libheader{cmath}, \libheader{numeric}
#define @\defnlibxname{cpp_lib_invoke}@ 201411L // also in \libheader{functional}
#define @\defnlibxname{cpp_lib_invoke_r}@ 202106L // also in \libheader{functional}
#define @\defnlibxname{cpp_lib_is_aggregate}@ 201703L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_constant_evaluated}@ 201811L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_final}@ 201402L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_invocable}@ 201703L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_layout_compatible}@ 201907L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_nothrow_convertible}@ 201806L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_null_pointer}@ 201309L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_pointer_interconvertible}@ 201907L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_scoped_enum}@ 202011L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_is_swappable}@ 201603L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_jthread}@ 201911L // also in \libheader{stop_token}, \libheader{thread}
#define @\defnlibxname{cpp_lib_latch}@ 201907L // also in \libheader{latch}
#define @\defnlibxname{cpp_lib_launder}@ 201606L // also in \libheader{new}
#define @\defnlibxname{cpp_lib_list_remove_return_type}@ 201806L // also in \libheader{forward_list}, \libheader{list}
#define @\defnlibxname{cpp_lib_logical_traits}@ 201510L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_make_from_tuple}@ 201606L // also in \libheader{tuple}
#define @\defnlibxname{cpp_lib_make_reverse_iterator}@ 201402L // also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_make_unique}@ 201304L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_map_try_emplace}@ 201411L // also in \libheader{map}
#define @\defnlibxname{cpp_lib_math_constants}@ 201907L // also in \libheader{numbers}
#define @\defnlibxname{cpp_lib_math_special_functions}@ 201603L // also in \libheader{cmath}
#define @\defnlibxname{cpp_lib_memory_resource}@ 201603L // also in \libheader{memory_resource}
#define @\defnlibxname{cpp_lib_node_extract}@ 201606L
// also in \libheader{map}, \libheader{set}, \libheader{unordered_map}, \libheader{unordered_set}
#define @\defnlibxname{cpp_lib_nonmember_container_access}@ 201411L
// also in \libheader{array}, \libheader{deque}, \libheader{forward_list}, \libheader{iterator}, \libheader{list}, \libheader{map}, \libheader{regex}, \libheader{set}, \libheader{string},
// \libheader{unordered_map}, \libheader{unordered_set}, \libheader{vector}
#define @\defnlibxname{cpp_lib_not_fn}@ 201603L // also in \libheader{functional}
#define @\defnlibxname{cpp_lib_null_iterators}@ 201304L // also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_optional}@ 202106L // also in \libheader{optional}
#define @\defnlibxname{cpp_lib_out_ptr}@ 202106L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_parallel_algorithm}@ 201603L // also in \libheader{algorithm}, \libheader{numeric}
#define @\defnlibxname{cpp_lib_polymorphic_allocator}@ 201902L // also in \libheader{memory_resource}
#define @\defnlibxname{cpp_lib_quoted_string_io}@ 201304L // also in \libheader{iomanip}
#define @\defnlibxname{cpp_lib_ranges}@ 202106L
// also in \libheader{algorithm}, \libheader{functional}, \libheader{iterator}, \libheader{memory}, \libheader{ranges}
#define @\defnlibxname{cpp_lib_ranges_starts_ends_with}@ 202106L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_raw_memory_algorithms}@ 201606L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_remove_cvref}@ 201711L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_result_of_sfinae}@ 201210L // also in \libheader{functional}, \libheader{type_traits}
#define @\defnlibxname{cpp_lib_robust_nonmodifying_seq_ops}@ 201304L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_sample}@ 201603L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_scoped_lock}@ 201703L // also in \libheader{mutex}
#define @\defnlibxname{cpp_lib_semaphore}@ 201907L // also in \libheader{semaphore}
#define @\defnlibxname{cpp_lib_shared_mutex}@ 201505L // also in \libheader{shared_mutex}
#define @\defnlibxname{cpp_lib_shared_ptr_arrays}@ 201707L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_shared_ptr_weak_type}@ 201606L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_shared_timed_mutex}@ 201402L // also in \libheader{shared_mutex}
#define @\defnlibxname{cpp_lib_shift}@ 201806L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_smart_ptr_for_overwrite}@ 202002L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_source_location}@ 201907L // also in \libheader{source_location}
#define @\defnlibxname{cpp_lib_span}@ 202002L // also in \libheader{span}
#define @\defnlibxname{cpp_lib_spanstream}@ 202106L // also in \libheader{spanstream}
#define @\defnlibxname{cpp_lib_ssize}@ 201902L // also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_stacktrace}@ 202011L // also in \libheader{stacktrace}
#define @\defnlibxname{cpp_lib_starts_ends_with}@ 201711L // also in \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_stdatomic_h}@ 202011L // also in \libheader{stdatomic.h}
#define @\defnlibxname{cpp_lib_string_contains}@ 202011L // also in \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_string_udls}@ 201304L // also in \libheader{string}
#define @\defnlibxname{cpp_lib_string_view}@ 201803L // also in \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_syncbuf}@ 201803L // also in \libheader{syncstream}
#define @\defnlibxname{cpp_lib_three_way_comparison}@ 201907L // also in \libheader{compare}
#define @\defnlibxname{cpp_lib_to_address}@ 201711L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_to_array}@ 201907L // also in \libheader{array}
#define @\defnlibxname{cpp_lib_to_chars}@ 201611L // also in \libheader{charconv}
#define @\defnlibxname{cpp_lib_to_underlying}@ 202102L // also in \libheader{utility}
#define @\defnlibxname{cpp_lib_transformation_trait_aliases}@ 201304L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_transparent_operators}@ 201510L // also in \libheader{memory}, \libheader{functional}
#define @\defnlibxname{cpp_lib_tuple_element_t}@ 201402L // also in \libheader{tuple}
#define @\defnlibxname{cpp_lib_tuples_by_type}@ 201304L // also in \libheader{utility}, \libheader{tuple}
#define @\defnlibxname{cpp_lib_type_identity}@ 201806L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_type_trait_variable_templates}@ 201510L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_uncaught_exceptions}@ 201411L // also in \libheader{exception}
#define @\defnlibxname{cpp_lib_unordered_map_try_emplace}@ 201411L // also in \libheader{unordered_map}
#define @\defnlibxname{cpp_lib_unwrap_ref}@ 201811L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_variant}@ 202106L // also in \libheader{variant}
#define @\defnlibxname{cpp_lib_void_t}@ 201411L // also in \libheader{type_traits}
\end{codeblock}
\rSec2[limits.syn]{Header \tcode{<limits>} synopsis}
\indexheader{limits}%
\indextext{\idxcode{numeric_limits}}%
\indexlibraryglobal{numeric_limits}%
\indexlibraryglobal{float_round_style}%
\indexlibraryglobal{float_denorm_style}%
\begin{codeblock}
namespace std {
// \ref{fp.style}, floating-point type properties
enum float_round_style;
enum float_denorm_style;
// \ref{numeric.limits}, class template \tcode{numeric_limits}
template<class T> class numeric_limits;
template<class T> class numeric_limits<const T>;
template<class T> class numeric_limits<volatile T>;
template<class T> class numeric_limits<const volatile T>;
template<> class numeric_limits<bool>;
template<> class numeric_limits<char>;
template<> class numeric_limits<signed char>;
template<> class numeric_limits<unsigned char>;
template<> class numeric_limits<char8_t>;
template<> class numeric_limits<char16_t>;
template<> class numeric_limits<char32_t>;
template<> class numeric_limits<wchar_t>;
template<> class numeric_limits<short>;
template<> class numeric_limits<int>;
template<> class numeric_limits<long>;
template<> class numeric_limits<long long>;
template<> class numeric_limits<unsigned short>;
template<> class numeric_limits<unsigned int>;
template<> class numeric_limits<unsigned long>;
template<> class numeric_limits<unsigned long long>;
template<> class numeric_limits<float>;
template<> class numeric_limits<double>;
template<> class numeric_limits<long double>;
}
\end{codeblock}
\rSec2[fp.style]{Floating-point type properties}
\rSec3[round.style]{Type \tcode{float_round_style}}
\indexlibraryglobal{float_round_style}%
\begin{codeblock}
namespace std {
enum float_round_style {
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
}
\end{codeblock}
\pnum
The rounding mode for floating-point arithmetic is characterized by the
values:
\begin{itemize}
\item
\indexlibraryglobal{round_indeterminate}%
\tcode{round_indeterminate}
if the rounding style is indeterminable
\item
\indexlibraryglobal{round_toward_zero}%
\tcode{round_toward_zero}
if the rounding style is toward zero
\item
\indexlibraryglobal{round_to_nearest}%
\tcode{round_to_nearest}
if the rounding style is to the nearest representable value
\item
\indexlibraryglobal{round_toward_infinity}%
\tcode{round_toward_infinity}
if the rounding style is toward infinity
\item
\indexlibraryglobal{round_toward_neg_infinity}%
\tcode{round_toward_neg_infinity}
if the rounding style is toward negative infinity
\end{itemize}
\rSec3[denorm.style]{Type \tcode{float_denorm_style}}
\indexlibraryglobal{float_denorm_style}%
\begin{codeblock}
namespace std {
enum float_denorm_style {
denorm_indeterminate = -1,
denorm_absent = 0,
denorm_present = 1
};
}
\end{codeblock}
\indextext{denormalized value|see{number, subnormal}}%
\indextext{value!denormalized|see{number, subnormal}}%
\indextext{subnormal number|see{number, subnormal}}%
\indextext{number!subnormal}%
\pnum
The presence or absence of subnormal numbers (variable number of exponent bits)
is characterized by the values:
\begin{itemize}
\item
\indexlibraryglobal{denorm_indeterminate}%
\tcode{denorm_indeterminate}
if it cannot be determined whether or not the type allows subnormal values
\item
\indexlibraryglobal{denorm_absent}%
\tcode{denorm_absent}
if the type does not allow subnormal values
\item
\indexlibraryglobal{denorm_present}%
\tcode{denorm_present}
if the type does allow subnormal values
\end{itemize}
\rSec2[numeric.limits]{Class template \tcode{numeric_limits}}
\rSec3[numeric.limits.general]{General}
\pnum
The
\indexlibraryglobal{numeric_limits}%
\tcode{numeric_limits}
class template provides a \Cpp{} program with information about various properties of
the implementation's representation of the
arithmetic types.
\indexlibraryglobal{numeric_limits}%
\begin{codeblock}
namespace std {
template<class T> class numeric_limits {
public:
static constexpr bool is_specialized = false;
static constexpr T min() noexcept { return T(); }
static constexpr T max() noexcept { return T(); }
static constexpr T lowest() noexcept { return T(); }
static constexpr int digits = 0;
static constexpr int digits10 = 0;
static constexpr int max_digits10 = 0;
static constexpr bool is_signed = false;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr int radix = 0;
static constexpr T epsilon() noexcept { return T(); }
static constexpr T round_error() noexcept { return T(); }
static constexpr int min_exponent = 0;
static constexpr int min_exponent10 = 0;
static constexpr int max_exponent = 0;
static constexpr int max_exponent10 = 0;
static constexpr bool has_infinity = false;
static constexpr bool has_quiet_NaN = false;
static constexpr bool has_signaling_NaN = false;
static constexpr float_denorm_style has_denorm = denorm_absent;
static constexpr bool has_denorm_loss = false;
static constexpr T infinity() noexcept { return T(); }
static constexpr T quiet_NaN() noexcept { return T(); }
static constexpr T signaling_NaN() noexcept { return T(); }
static constexpr T denorm_min() noexcept { return T(); }
static constexpr bool is_iec559 = false;
static constexpr bool is_bounded = false;
static constexpr bool is_modulo = false;
static constexpr bool traps = false;
static constexpr bool tinyness_before = false;
static constexpr float_round_style round_style = round_toward_zero;
};
}
\end{codeblock}
\pnum
For all members declared
\keyword{static} \keyword{constexpr}
in the
\tcode{numeric_limits}
template, specializations shall define these values in such a way
that they are usable as
constant expressions.
\pnum
For the
\tcode{numeric_limits}
primary template, all data members are value-initialized and all
member functions return a value-initialized object.
\begin{note}
This means all members have zero or \tcode{false} values
unless \tcode{numeric_limits} is specialized for a type.
\end{note}
\pnum
Specializations shall be provided for each
arithmetic type,
both floating-point and integer, including
\tcode{bool}.
The member
\tcode{is_specialized}
shall be
\tcode{true}
for all such specializations of
\tcode{numeric_limits}.
\pnum
The value of each member of a specialization of
\tcode{numeric_limits} on a cv-qualified type
\tcode{cv T} shall be equal to the value of the corresponding member of
the specialization on the unqualified type \tcode{T}.
\pnum
Non-arithmetic standard types, such as
\tcode{complex<T>}\iref{complex}, shall not have specializations.
\rSec3[numeric.limits.members]{\tcode{numeric_limits} members}
\pnum
\indextext{signal-safe!\idxcode{numeric_limits} members}%
Each member function defined in this subclause is signal-safe\iref{support.signal}.
\indexlibrarymember{min}{numeric_limits}%
\begin{itemdecl}
static constexpr T min() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Minimum finite value.
\begin{footnote}
Equivalent to \tcode{CHAR_MIN}, \tcode{SHRT_MIN},
\tcode{FLT_MIN}, \tcode{DBL_MIN}, etc.
\end{footnote}
\indextext{number!subnormal}%
\pnum
For floating-point types with subnormal numbers, returns the minimum positive
normalized value.
\pnum
Meaningful for all specializations in which
\tcode{is_bounded != false},
or
\tcode{is_bounded == false \&\& is_signed == false}.
\end{itemdescr}
\indexlibrarymember{max}{numeric_limits}%
\begin{itemdecl}
static constexpr T max() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Maximum finite value.
\begin{footnote}
Equivalent to \tcode{CHAR_MAX}, \tcode{SHRT_MAX},
\tcode{FLT_MAX}, \tcode{DBL_MAX}, etc.
\end{footnote}
\pnum
Meaningful for all specializations in which
\tcode{is_bounded != false}.
\end{itemdescr}
\indexlibrarymember{lowest}{numeric_limits}%
\begin{itemdecl}
static constexpr T lowest() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
A finite value \tcode{x} such that there is no other finite
value \tcode{y} where \tcode{y < x}.
\begin{footnote}
\tcode{lowest()} is necessary because not all
floating-point representations have a smallest (most negative) value that is
the negative of the largest (most positive) finite value.
\end{footnote}
\pnum
Meaningful for all specializations in which \tcode{is_bounded != false}.
\end{itemdescr}
\indexlibrarymember{digits}{numeric_limits}%
\begin{itemdecl}