forked from cplusplus/draft
/
support.tex
3331 lines (2803 loc) · 95 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
\rSec0[language.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 Table~\ref{tab:lang.sup.lib.summary}.
\begin{libsumtab}{Language support library summary}{tab:lang.sup.lib.summary}
\ref{support.types} & Types & \tcode{<cstddef>} \\ \rowsep
& & \tcode{<limits>} \\
\ref{support.limits} & Implementation properties & \tcode{<climits>} \\
& & \tcode{<cfloat>} \\ \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.exception} & Exception handling & \tcode{<exception>} \\ \rowsep
\ref{support.initlist} & Initializer lists & \tcode{<initializer_list>} \\ \rowsep
& & \tcode{<csignal>} \\
& & \tcode{<csetjmp>} \\
& & \tcode{<cstdalign>} \\
\ref{support.runtime} & Other runtime support & \tcode{<cstdarg>} \\
& & \tcode{<cstdbool>} \\
& & \tcode{<cstdlib>} \\
& & \tcode{<ctime>} \\
\end{libsumtab}
\rSec1[support.types]{Types}
\pnum
Table~\ref{tab:support.hdr.cstddef} describes the header
\tcode{<cstddef>}.
\indexlibrary{\idxcode{NULL}}%
\indexlibrary{\idxcode{offsetof}}%
\indexlibrary{\idxcode{ptrdiff_t}}%
\indexlibrary{\idxcode{size_t}}%
\indexlibrary{\idxcode{max_align_t}}%
\indexlibrary{\idxcode{nullptr_t}}%
\begin{libsyntab3}{cstddef}{tab:support.hdr.cstddef}
\macros & \tcode{NULL} & \tcode{offsetof} \\ \rowsep
\types & \tcode{ptrdiff_t} & \tcode{size_t} \\
& \tcode{max_align_t} & \tcode{nullptr_t} \\
\end{libsyntab3}
\pnum
The contents are the same as the Standard C library header
\tcode{<stddef.h>},
with the following changes:
\pnum
The macro
\indexlibrary{\idxcode{NULL}}%
\tcode{NULL}
is an implementation-defined \Cpp null pointer constant in
\indextext{implementation-defined}%
this International Standard (\ref{conv.ptr}).\footnote{Possible definitions include
\tcode{0}
and
\tcode{0L},
but not
\tcode{(void*)0}.}
\pnum
The macro
\indexlibrary{\idxcode{offsetof}}%
\tcode{offsetof}(\textit{type},
\grammarterm{member-designator}) accepts a restricted set of \textit{type}
arguments in this International Standard. If \textit{type} is not a
standard-layout class
(Clause~\ref{class}), the results are undefined.\footnote{Note that \tcode{offsetof}
is required to work as specified even if unary
\tcode{operator\&}
is overloaded for any of the types involved.}
The expression \tcode{offsetof}(\textit{type}, \grammarterm{member-designator})
is never type-dependent~(\ref{temp.dep.expr}) and it is
value-dependent~(\ref{temp.dep.constexpr}) if and only if \textit{type} is
dependent. The result of applying the \tcode{offsetof} macro to a field that
is 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(type, 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.
\pnum
\enternote
It is recommended that implementations choose types for \tcode{ptrdiff_t} and \tcode{size_t}
whose integer conversion ranks~(\ref{conv.rank}) are no greater than that of
\tcode{signed long int} unless a larger size is necessary to contain all the possible values.
\exitnote
\pnum
The type
\indexlibrary{\idxcode{max_align_t}}%
\tcode{max_align_t} is a POD type whose alignment requirement
is at least as great as that of every scalar type, and whose alignment
requirement is supported in every context.
\pnum
\indexlibrary{\idxcode{nullptr_t}}%
\tcode{nullptr_t} is defined as follows:
\begin{codeblock}
namespace std {
typedef decltype(nullptr) nullptr_t;
}
\end{codeblock}
The type for which \tcode{nullptr_t} is a synonym has the characteristics
described in~\ref{basic.fundamental} and~\ref{conv.ptr}. \enternote Although
\tcode{nullptr}'s address cannot be taken, the address of another
\tcode{nullptr_t} object that is an lvalue can be taken. \exitnote
\xref Alignment~(\ref{basic.align}), Sizeof~(\ref{expr.sizeof}), Additive
operators~(\ref{expr.add}), Free store~(\ref{class.free}), and ISO C~7.1.6.
\rSec1[support.limits]{Implementation properties}
\rSec2[support.limits.general]{In general}
\pnum
The headers
\tcode{<limits>}~(\ref{limits}),
\tcode{<climits>}, and
\tcode{<cfloat>}~(\ref{c.limits})
supply characteristics of implementation-dependent
arithmetic types~(\ref{basic.fundamental}).
\rSec2[limits]{Numeric limits}
\rSec3[limits.numeric]{Class template \tcode{numeric_limits}}
\pnum
The
\indexlibrary{\idxcode{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.
\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
For all members declared
\tcode{static} \tcode{constexpr}
in the
\tcode{numeric_limits}
template, specializations shall define these values in such a way
that they are usable as
constant expressions.
\pnum
Non-arithmetic standard types, such as
\tcode{complex<T>}~(\ref{complex}), shall not have specializations.
\indextext{\idxhdr{limits}}%
\indexlibrary{\idxhdr{limits}}%
\indextext{\idxcode{numeric_limits}}%
\indexlibrary{\idxcode{numeric_limits}}%
\indexlibrary{\idxcode{float_round_style}}%
\indexlibrary{\idxcode{float_denorm_style}}%
\rSec3[limits.syn]{Header \tcode{<limits>} synopsis}
\begin{codeblock}
namespace std {
template<class T> class numeric_limits;
enum float_round_style;
enum float_denorm_style;
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<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}
\rSec3[numeric.limits]{Class template \tcode{numeric_limits}}
\indexlibrary{\idxcode{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;
};
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>;
}
\end{codeblock}
\pnum
The default
\tcode{numeric_limits<T>}
template shall have all members, but with 0 or
\tcode{false}
values.
\pnum
The value of each member of a specialization of
\tcode{numeric_limits} on a \term{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}.
\rSec3[numeric.limits.members]{\tcode{numeric_limits} members}
\indexlibrary{\idxcode{min}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{min}}
\begin{itemdecl}
static constexpr T min() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Minimum finite value.\footnote{Equivalent to \tcode{CHAR_MIN}, \tcode{SHRT_MIN},
\tcode{FLT_MIN}, \tcode{DBL_MIN}, etc.}
\pnum
For floating types with denormalization, 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}
\indexlibrary{\idxcode{max}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{max}}
\begin{itemdecl}
static constexpr T max() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Maximum finite value.\footnote{Equivalent to \tcode{CHAR_MAX}, \tcode{SHRT_MAX},
\tcode{FLT_MAX}, \tcode{DBL_MAX}, etc.}
\pnum
Meaningful for all specializations in which
\tcode{is_bounded != false}.
\end{itemdescr}
\indexlibrary{\idxcode{lowest}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{lowest}}
\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}.\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.}
\pnum
Meaningful for all specializations in which \tcode{is_bounded != false}.
\end{itemdescr}
\indexlibrary{\idxcode{digits}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{digits}}
\begin{itemdecl}
static constexpr int digits;
\end{itemdecl}
\begin{itemdescr}
\pnum
Number of
\tcode{radix}
digits that can be represented without change.
\pnum
For integer types, the number of non-sign bits in the representation.
\pnum For floating point types, the number of \tcode{radix} digits in the
mantissa.\footnote{Equivalent to \tcode{FLT_MANT_DIG}, \tcode{DBL_MANT_DIG},
\tcode{LDBL_MANT_DIG}.} \end{itemdescr}
\indexlibrary{\idxcode{digits10}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{digits10}}
\begin{itemdecl}
static constexpr int digits10;
\end{itemdecl}
\begin{itemdescr}
\pnum
Number of base 10 digits that can be represented without
change.\footnote{Equivalent to \tcode{FLT_DIG}, \tcode{DBL_DIG},
\tcode{LDBL_DIG}.}
\pnum
Meaningful for all specializations in which
\tcode{is_bounded != false}.
\end{itemdescr}
\indexlibrary{\idxcode{max_digits10}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{max_digits10}}
\begin{itemdecl}
static constexpr int max_digits10;
\end{itemdecl}
\begin{itemdescr}
\pnum
Number of base 10 digits required to ensure that values which
differ are always differentiated.
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{is_signed}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{is_signed}}
\begin{itemdecl}
static constexpr bool is_signed;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the type is signed.
\pnum
Meaningful for all specializations.
\end{itemdescr}
\indexlibrary{\idxcode{is_integer}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{is_integer}}
\begin{itemdecl}
static constexpr bool is_integer;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the type is integer.
\pnum
Meaningful for all specializations.
\end{itemdescr}
\indexlibrary{\idxcode{is_exact}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{is_exact}}
\begin{itemdecl}
static constexpr bool is_exact;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the type uses an exact representation.
All integer types are exact, but not all exact types are integer.
For example, rational and fixed-exponent representations are exact but not integer.
\pnum
Meaningful for all specializations.
\end{itemdescr}
\indexlibrary{\idxcode{radix}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{radix}}
\begin{itemdecl}
static constexpr int radix;
\end{itemdecl}
\begin{itemdescr}
\pnum
For floating types, specifies the base or radix of the exponent representation
(often 2).\footnote{Equivalent to \tcode{FLT_RADIX}.}
\pnum
For integer types, specifies the base of the
representation.\footnote{Distinguishes types with bases other than 2 (e.g.
BCD).}
\pnum
Meaningful for all specializations.
\end{itemdescr}
\indexlibrary{\idxcode{epsilon}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{epsilon}}
\begin{itemdecl}
static constexpr T epsilon() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Machine epsilon: the difference between 1 and the least value greater than 1
that is representable.\footnote{Equivalent to \tcode{FLT_EPSILON}, \tcode{DBL_EPSILON}, \tcode{LDBL_EPSILON}.}
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{round_error}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{round_error}}
\begin{itemdecl}
static constexpr T round_error() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Measure of the maximum rounding error.\footnote{Rounding error is described in
ISO/IEC 10967-1 Language independent arithmetic - Part 1
Section 5.2.8 and
Annex A Rationale Section A.5.2.8 - Rounding constants.}
\end{itemdescr}
\indexlibrary{\idxcode{min_exponent}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{min_exponent}}
\begin{itemdecl}
static constexpr int min_exponent;
\end{itemdecl}
\begin{itemdescr}
\pnum
Minimum negative integer such that
\tcode{radix}
raised to the power of one less than that integer is a normalized floating
point number.\footnote{Equivalent to \tcode{FLT_MIN_EXP}, \tcode{DBL_MIN_EXP},
\tcode{LDBL_MIN_EXP}.}
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{min_exponent10}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{min_exponent10}}
\begin{itemdecl}
static constexpr int min_exponent10;
\end{itemdecl}
\begin{itemdescr}
\pnum
Minimum negative integer such that 10 raised to that power is in the range
of normalized floating point numbers.\footnote{Equivalent to
\tcode{FLT_MIN_10_EXP}, \tcode{DBL_MIN_10_EXP}, \tcode{LDBL_MIN_10_EXP}.}
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{max_exponent}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{max_exponent}}
\begin{itemdecl}
static constexpr int max_exponent;
\end{itemdecl}
\begin{itemdescr}
\pnum
Maximum positive integer such that
\tcode{radix}
raised to the power one less than that integer is a representable finite
floating point number.\footnote{Equivalent to \tcode{FLT_MAX_EXP},
\tcode{DBL_MAX_EXP}, \tcode{LDBL_MAX_EXP}.}
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{max_exponent10}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{max_exponent10}}
\begin{itemdecl}
static constexpr int max_exponent10;
\end{itemdecl}
\begin{itemdescr}
\pnum
Maximum positive integer such that 10 raised to that power is in the
range of representable finite floating point numbers.\footnote{Equivalent to
\tcode{FLT_MAX_10_EXP}, \tcode{DBL_MAX_10_EXP}, \tcode{LDBL_MAX_10_EXP}.}
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{has_infinity}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{has_infinity}}
\begin{itemdecl}
static constexpr bool has_infinity;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the type has a representation for positive infinity.
\pnum
Meaningful for all floating point types.
\pnum
Shall be
\tcode{true}
for all specializations in which
\tcode{is_iec559 != false}.
\end{itemdescr}
\indexlibrary{\idxcode{has_quiet_NaN}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{has_quiet_NaN}}
\begin{itemdecl}
static constexpr bool has_quiet_NaN;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the type has a representation for a quiet (non-signaling) ``Not a
Number.''\footnote{Required by LIA-1.}
\pnum
Meaningful for all floating point types.
\pnum
Shall be
\tcode{true}
for all specializations in which
\tcode{is_iec559 != false}.
\end{itemdescr}
\indexlibrary{\idxcode{has_signaling_NaN}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{has_signaling_NaN}}
\begin{itemdecl}
static constexpr bool has_signaling_NaN;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the type has a representation for a signaling ``Not a Number.''\footnote{Required by LIA-1.}
\pnum
Meaningful for all floating point types.
\pnum
Shall be
\tcode{true}
for all specializations in which
\tcode{is_iec559 != false}.
\end{itemdescr}
\indexlibrary{\idxcode{float_denorm_style}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{float_denorm_style}}
\begin{itemdecl}
static constexpr float_denorm_style has_denorm;
\end{itemdecl}
\begin{itemdescr}
\pnum
\tcode{denorm_present}
if the type allows denormalized values
(variable number of exponent bits)\footnote{Required by LIA-1.},
\tcode{denorm_absent}
if the type does not allow denormalized values,
and
\tcode{denorm_indeterminate}
if it is indeterminate at compile time whether the type allows
denormalized values.
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{has_denorm_loss}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{has_denorm_loss}}
\begin{itemdecl}
static constexpr bool has_denorm_loss;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if loss of accuracy is detected as a
denormalization loss, rather than as an inexact result.\footnote{See IEC 559.}
\end{itemdescr}
\indexlibrary{\idxcode{infinity}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{infinity}}
\begin{itemdecl}
static constexpr T infinity() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Representation of positive infinity, if available.\footnote{Required by LIA-1.}
\pnum
Meaningful for all specializations for which
\tcode{has_infinity != false}.
Required in specializations for which
\tcode{is_iec559 != false}.
\end{itemdescr}
\indexlibrary{\idxcode{quiet_NaN}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{quiet_NaN}}
\begin{itemdecl}
static constexpr T quiet_NaN() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Representation of a quiet ``Not a Number,'' if available.\footnote{Required by LIA-1.}
\pnum
Meaningful for all specializations for which
\tcode{has_quiet_NaN != false}.
Required in specializations for which
\tcode{is_iec559 != false}.
\end{itemdescr}
\indexlibrary{\idxcode{signaling_NaN}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{signaling_NaN}}
\begin{itemdecl}
static constexpr T signaling_NaN() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Representation of a signaling ``Not a Number,'' if available.\footnote{Required by LIA-1.}
\pnum
Meaningful for all specializations for which
\tcode{has_signaling_NaN != false}.
Required in specializations for which
\tcode{is_iec559 != false}.
\end{itemdescr}
\indexlibrary{\idxcode{denorm_min}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{denorm_min}}
\begin{itemdecl}
static constexpr T denorm_min() noexcept;
\end{itemdecl}
\begin{itemdescr}
\pnum
Minimum positive denormalized value.\footnote{Required by LIA-1.}
\pnum
Meaningful for all floating point types.
\pnum
In specializations for which
\tcode{has_denorm == false},
returns the minimum positive normalized value.
\end{itemdescr}
\indexlibrary{\idxcode{is_iec559}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{is_iec559}}
\begin{itemdecl}
static constexpr bool is_iec559;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if and only if the type adheres to IEC 559 standard.\footnote{International
Electrotechnical Commission standard 559 is the same as
IEEE 754.}
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{is_bounded}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{is_bounded}}
\begin{itemdecl}
static constexpr bool is_bounded;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the set of values representable by the type is finite.\footnote{Required by LIA-1.}
\enternote All fundamental types~(\ref{basic.fundamental}) are bounded. This member would be false for arbitrary
precision types.\exitnote
\pnum
Meaningful for all specializations.
\end{itemdescr}
\indexlibrary{\idxcode{is_modulo}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{is_modulo}}
\begin{itemdecl}
static constexpr bool is_modulo;
\end{itemdecl}
\begin{itemdescr}
\pnum
True if the type is modulo.\footnote{Required by LIA-1.}
A type is modulo if, for any operation involving \tcode{+}, \tcode{-}, or
\tcode{*} on values of that type whose result would fall outside the range
\crange{min()}{max()}, the value returned differs from the true value by an
integer multiple of \tcode{max() - min() + 1}.
\pnum
On most machines, this is
\tcode{false}
for floating types,
\tcode{true}
for unsigned integers, and
\tcode{true}
for signed integers.
\pnum
Meaningful for all specializations.
\end{itemdescr}
\indexlibrary{\idxcode{traps}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{traps}}
\begin{itemdecl}
static constexpr bool traps;
\end{itemdecl}
\begin{itemdescr}
\pnum
\tcode{true}
if, at program startup, there exists a value of the type that would cause
an arithmetic operation using that value to trap.\footnote{Required by LIA-1.}
\pnum
Meaningful for all specializations.
\end{itemdescr}
\indexlibrary{\idxcode{tinyness_before}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{tinyness_before}}
\begin{itemdecl}
static constexpr bool tinyness_before;
\end{itemdecl}
\begin{itemdescr}
\pnum
\tcode{true}
if tinyness is detected before rounding.\footnote{Refer to IEC 559.
Required by LIA-1.}
\pnum
Meaningful for all floating point types.
\end{itemdescr}
\indexlibrary{\idxcode{round_style}!\idxcode{numeric_limits}}
\indexlibrary{\idxcode{numeric_limits}!\idxcode{round_style}}
\begin{itemdecl}
static constexpr float_round_style round_style;
\end{itemdecl}
\begin{itemdescr}
\pnum
The rounding style for the type.\footnote{Equivalent to \tcode{FLT_ROUNDS}.
Required by LIA-1.}
\pnum
Meaningful for all floating point types.
Specializations for integer types shall return
\tcode{round_toward_zero}.
\end{itemdescr}
\rSec3[round.style]{Type \tcode{float_round_style}}
\indexlibrary{\idxcode{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
\indexlibrary{\idxcode{round_indeterminate}}%
\tcode{round_indeterminate}
if the rounding style is indeterminable
\item
\indexlibrary{\idxcode{round_toward_zero}}%
\tcode{round_toward_zero}
if the rounding style is toward zero
\item
\indexlibrary{\idxcode{round_to_nearest}}%
\tcode{round_to_nearest}
if the rounding style is to the nearest representable value
\item
\indexlibrary{\idxcode{round_toward_infinity}}%
\tcode{round_toward_infinity}
if the rounding style is toward infinity
\item
\indexlibrary{\idxcode{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}}
\indexlibrary{\idxcode{float_denorm_style}}%
\begin{codeblock}
namespace std {
enum float_denorm_style {
denorm_indeterminate = -1,
denorm_absent = 0,
denorm_present = 1
};
}
\end{codeblock}
\pnum
The presence or absence of denormalization (variable number of exponent bits)
is characterized by the values:
\begin{itemize}
\item
\indexlibrary{\idxcode{denorm_indeterminate}}%
\tcode{denorm_indeterminate}
if it cannot be determined whether or not the type allows denormalized values
\item
\indexlibrary{\idxcode{denorm_absent}}%
\tcode{denorm_absent}
if the type does not allow denormalized values
\item
\indexlibrary{\idxcode{denorm_present}}%
\tcode{denorm_present}
if the type does allow denormalized values
\end{itemize}
\rSec3[numeric.special]{\tcode{numeric_limits} specializations}
\pnum
All members shall be provided for all specializations.
However, many values are only required to be meaningful under certain
conditions
(for example,
\tcode{epsilon()}
is only meaningful if
\tcode{is_integer}
is
\tcode{false}).
Any value that is not ``meaningful'' shall be set to 0 or
\tcode{false}.
\pnum
\enterexample
\begin{codeblock}
namespace std {
template<> class numeric_limits<float> {
public:
static constexpr bool is_specialized = true;
inline static constexpr float min() noexcept { return 1.17549435E-38F; }
inline static constexpr float max() noexcept { return 3.40282347E+38F; }
inline static constexpr float lowest() noexcept { return -3.40282347E+38F; }
static constexpr int digits = 24;
static constexpr int digits10 = 6;
static constexpr int max_digits10 = 9;
static constexpr bool is_signed = true;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr int radix = 2;
inline static constexpr float epsilon() noexcept { return 1.19209290E-07F; }
inline static constexpr float round_error() noexcept { return 0.5F; }
static constexpr int min_exponent = -125;
static constexpr int min_exponent10 = - 37;
static constexpr int max_exponent = +128;
static constexpr int max_exponent10 = + 38;
static constexpr bool has_infinity = true;
static constexpr bool has_quiet_NaN = true;
static constexpr bool has_signaling_NaN = true;
static constexpr float_denorm_style has_denorm = denorm_absent;
static constexpr bool has_denorm_loss = false;
inline static constexpr float infinity() noexcept { return @\textit{value}@; }
inline static constexpr float quiet_NaN() noexcept { return @\textit{value}@; }
inline static constexpr float signaling_NaN() noexcept { return @\textit{value}@; }
inline static constexpr float denorm_min() noexcept { return min(); }
static constexpr bool is_iec559 = true;
static constexpr bool is_bounded = true;
static constexpr bool is_modulo = false;
static constexpr bool traps = true;
static constexpr bool tinyness_before = true;
static constexpr float_round_style round_style = round_to_nearest;
};
}
\end{codeblock}
\exitexample
\pnum
The specialization for
\tcode{bool}
shall be provided as follows:
\indexlibrary{\idxcode{numeric_limits<bool>}}%
\begin{codeblock}
namespace std {
template<> class numeric_limits<bool> {
public:
static constexpr bool is_specialized = true;
static constexpr bool min() noexcept { return false; }
static constexpr bool max() noexcept { return true; }
static constexpr bool lowest() noexcept { return false; }
static constexpr int digits = 1;
static constexpr int digits10 = 0;
static constexpr int max_digits10 = 0;
static constexpr bool is_signed = false;
static constexpr bool is_integer = true;
static constexpr bool is_exact = true;
static constexpr int radix = 2;
static constexpr bool epsilon() noexcept { return 0; }
static constexpr bool round_error() noexcept { return 0; }