- tmp/tmpl1fnkic5/{from.md → to.md} +1228 -610
tmp/tmpl1fnkic5/{from.md → to.md}
RENAMED
|
@@ -17,119 +17,367 @@ other runtime support, as summarized in Table
|
|
| 17 |
|
| 18 |
**Table: Language support library summary** <a id="tab:lang.sup.lib.summary">[tab:lang.sup.lib.summary]</a>
|
| 19 |
|
| 20 |
| Subclause | | Header |
|
| 21 |
| ---------------------- | ------------------------- | -------------------- |
|
| 22 |
-
| [[support.types]] |
|
| 23 |
-
| | | `<
|
| 24 |
-
| [[support.limits]] | Implementation properties | `<
|
|
|
|
| 25 |
| | | `<cfloat>` |
|
| 26 |
| [[cstdint]] | Integer types | `<cstdint>` |
|
| 27 |
| [[support.start.term]] | Start and termination | `<cstdlib>` |
|
| 28 |
| [[support.dynamic]] | Dynamic memory management | `<new>` |
|
| 29 |
| [[support.rtti]] | Type identification | `<typeinfo>` |
|
| 30 |
| [[support.exception]] | Exception handling | `<exception>` |
|
| 31 |
| [[support.initlist]] | Initializer lists | `<initializer_list>` |
|
| 32 |
-
|
|
| 33 |
| | | `<csetjmp>` |
|
| 34 |
-
| | | `<
|
| 35 |
-
| [[support.runtime]] | Other runtime support | `<cstdarg>` |
|
| 36 |
-
| | | `<cstdbool>` |
|
| 37 |
| | | `<cstdlib>` |
|
| 38 |
-
| | | `<ctime>` |
|
| 39 |
|
| 40 |
|
| 41 |
-
##
|
| 42 |
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
in this International Standard ([[conv.ptr]]).[^1]
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
The type `ptrdiff_t` is an *implementation-defined* signed integer type
|
| 63 |
that can hold the difference of two subscripts in an array object, as
|
| 64 |
described in [[expr.add]].
|
| 65 |
|
| 66 |
The type `size_t` is an *implementation-defined* unsigned integer type
|
| 67 |
that is large enough to contain the size in bytes of any object.
|
| 68 |
|
| 69 |
-
It is recommended that implementations choose types for
|
| 70 |
-
`size_t` whose integer conversion ranks ([[conv.rank]])
|
| 71 |
-
than that of `signed long int` unless a larger size is
|
| 72 |
-
contain all the possible values.
|
| 73 |
|
| 74 |
The type `max_align_t` is a POD type whose alignment requirement is at
|
| 75 |
least as great as that of every scalar type, and whose alignment
|
| 76 |
requirement is supported in every context.
|
| 77 |
|
| 78 |
-
`nullptr_t` is defined as follows:
|
| 79 |
-
|
| 80 |
-
``` cpp
|
| 81 |
-
namespace std {
|
| 82 |
-
typedef decltype(nullptr) nullptr_t;
|
| 83 |
-
}
|
| 84 |
-
```
|
| 85 |
-
|
| 86 |
-
The type for which `nullptr_t` is a synonym has the characteristics
|
| 87 |
-
described in [[basic.fundamental]] and [[conv.ptr]]. Although
|
| 88 |
-
`nullptr`’s address cannot be taken, the address of another `nullptr_t`
|
| 89 |
-
object that is an lvalue can be taken.
|
| 90 |
-
|
| 91 |
Alignment ([[basic.align]]), Sizeof ([[expr.sizeof]]), Additive
|
| 92 |
-
operators ([[expr.add]]), Free store ([[class.free]]), and ISO
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
## Implementation properties <a id="support.limits">[[support.limits]]</a>
|
| 96 |
|
| 97 |
-
###
|
| 98 |
|
| 99 |
-
The headers `<limits>` ([[limits]]), `<climits>`
|
| 100 |
-
[[
|
| 101 |
-
arithmetic types (
|
|
|
|
| 102 |
|
| 103 |
-
###
|
| 104 |
-
|
| 105 |
-
#### Class template `numeric_limits` <a id="limits.numeric">[[limits.numeric]]</a>
|
| 106 |
-
|
| 107 |
-
The `numeric_limits` class template provides a C++program with
|
| 108 |
-
information about various properties of the implementation’s
|
| 109 |
-
representation of the arithmetic types.
|
| 110 |
-
|
| 111 |
-
Specializations shall be provided for each arithmetic type, both
|
| 112 |
-
floating point and integer, including `bool`. The member
|
| 113 |
-
`is_specialized` shall be `true` for all such specializations of
|
| 114 |
-
`numeric_limits`.
|
| 115 |
-
|
| 116 |
-
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 117 |
-
template, specializations shall define these values in such a way that
|
| 118 |
-
they are usable as constant expressions.
|
| 119 |
-
|
| 120 |
-
Non-arithmetic standard types, such as `complex<T>` ([[complex]]),
|
| 121 |
-
shall not have specializations.
|
| 122 |
-
|
| 123 |
-
#### Header `<limits>` synopsis <a id="limits.syn">[[limits.syn]]</a>
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
namespace std {
|
| 127 |
-
|
| 128 |
enum float_round_style;
|
| 129 |
enum float_denorm_style;
|
| 130 |
|
|
|
|
|
|
|
|
|
|
| 131 |
template<> class numeric_limits<bool>;
|
| 132 |
|
| 133 |
template<> class numeric_limits<char>;
|
| 134 |
template<> class numeric_limits<signed char>;
|
| 135 |
template<> class numeric_limits<unsigned char>;
|
|
@@ -150,11 +398,62 @@ namespace std {
|
|
| 150 |
template<> class numeric_limits<double>;
|
| 151 |
template<> class numeric_limits<long double>;
|
| 152 |
}
|
| 153 |
```
|
| 154 |
|
| 155 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
``` cpp
|
| 158 |
namespace std {
|
| 159 |
template<class T> class numeric_limits {
|
| 160 |
public:
|
|
@@ -201,26 +500,41 @@ namespace std {
|
|
| 201 |
template<class T> class numeric_limits<volatile T>;
|
| 202 |
template<class T> class numeric_limits<const volatile T>;
|
| 203 |
}
|
| 204 |
```
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
The default `numeric_limits<T>` template shall have all members, but
|
| 207 |
with 0 or `false` values.
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
The value of each member of a specialization of `numeric_limits` on a
|
| 210 |
-
|
| 211 |
corresponding member of the specialization on the unqualified type `T`.
|
| 212 |
|
|
|
|
|
|
|
|
|
|
| 213 |
#### `numeric_limits` members <a id="numeric.limits.members">[[numeric.limits.members]]</a>
|
| 214 |
|
|
|
|
|
|
|
|
|
|
| 215 |
``` cpp
|
| 216 |
static constexpr T min() noexcept;
|
| 217 |
```
|
| 218 |
|
| 219 |
Minimum finite value.[^3]
|
| 220 |
|
| 221 |
-
For floating types with
|
| 222 |
normalized value.
|
| 223 |
|
| 224 |
Meaningful for all specializations in which `is_bounded != false`, or
|
| 225 |
`is_bounded == false && is_signed == false`.
|
| 226 |
|
|
@@ -247,11 +561,11 @@ static constexpr int digits;
|
|
| 247 |
|
| 248 |
Number of `radix` digits that can be represented without change.
|
| 249 |
|
| 250 |
For integer types, the number of non-sign bits in the representation.
|
| 251 |
|
| 252 |
-
For floating
|
| 253 |
mantissa.[^6]
|
| 254 |
|
| 255 |
``` cpp
|
| 256 |
static constexpr int digits10;
|
| 257 |
```
|
|
@@ -265,33 +579,33 @@ static constexpr int max_digits10;
|
|
| 265 |
```
|
| 266 |
|
| 267 |
Number of base 10 digits required to ensure that values which differ are
|
| 268 |
always differentiated.
|
| 269 |
|
| 270 |
-
Meaningful for all floating
|
| 271 |
|
| 272 |
``` cpp
|
| 273 |
static constexpr bool is_signed;
|
| 274 |
```
|
| 275 |
|
| 276 |
-
|
| 277 |
|
| 278 |
Meaningful for all specializations.
|
| 279 |
|
| 280 |
``` cpp
|
| 281 |
static constexpr bool is_integer;
|
| 282 |
```
|
| 283 |
|
| 284 |
-
|
| 285 |
|
| 286 |
Meaningful for all specializations.
|
| 287 |
|
| 288 |
``` cpp
|
| 289 |
static constexpr bool is_exact;
|
| 290 |
```
|
| 291 |
|
| 292 |
-
|
| 293 |
exact, but not all exact types are integer. For example, rational and
|
| 294 |
fixed-exponent representations are exact but not integer.
|
| 295 |
|
| 296 |
Meaningful for all specializations.
|
| 297 |
|
|
@@ -311,11 +625,11 @@ static constexpr T epsilon() noexcept;
|
|
| 311 |
```
|
| 312 |
|
| 313 |
Machine epsilon: the difference between 1 and the least value greater
|
| 314 |
than 1 that is representable.[^10]
|
| 315 |
|
| 316 |
-
Meaningful for all floating
|
| 317 |
|
| 318 |
``` cpp
|
| 319 |
static constexpr T round_error() noexcept;
|
| 320 |
```
|
| 321 |
|
|
@@ -324,89 +638,89 @@ Measure of the maximum rounding error.[^11]
|
|
| 324 |
``` cpp
|
| 325 |
static constexpr int min_exponent;
|
| 326 |
```
|
| 327 |
|
| 328 |
Minimum negative integer such that `radix` raised to the power of one
|
| 329 |
-
less than that integer is a normalized floating
|
| 330 |
|
| 331 |
-
Meaningful for all floating
|
| 332 |
|
| 333 |
``` cpp
|
| 334 |
static constexpr int min_exponent10;
|
| 335 |
```
|
| 336 |
|
| 337 |
Minimum negative integer such that 10 raised to that power is in the
|
| 338 |
-
range of normalized floating
|
| 339 |
|
| 340 |
-
Meaningful for all floating
|
| 341 |
|
| 342 |
``` cpp
|
| 343 |
static constexpr int max_exponent;
|
| 344 |
```
|
| 345 |
|
| 346 |
Maximum positive integer such that `radix` raised to the power one less
|
| 347 |
-
than that integer is a representable finite floating
|
| 348 |
|
| 349 |
-
Meaningful for all floating
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
static constexpr int max_exponent10;
|
| 353 |
```
|
| 354 |
|
| 355 |
Maximum positive integer such that 10 raised to that power is in the
|
| 356 |
-
range of representable finite floating
|
| 357 |
|
| 358 |
-
Meaningful for all floating
|
| 359 |
|
| 360 |
``` cpp
|
| 361 |
static constexpr bool has_infinity;
|
| 362 |
```
|
| 363 |
|
| 364 |
-
|
| 365 |
|
| 366 |
-
Meaningful for all floating
|
| 367 |
|
| 368 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 369 |
|
| 370 |
``` cpp
|
| 371 |
static constexpr bool has_quiet_NaN;
|
| 372 |
```
|
| 373 |
|
| 374 |
-
|
| 375 |
-
Number
|
| 376 |
|
| 377 |
-
Meaningful for all floating
|
| 378 |
|
| 379 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 380 |
|
| 381 |
``` cpp
|
| 382 |
static constexpr bool has_signaling_NaN;
|
| 383 |
```
|
| 384 |
|
| 385 |
-
|
| 386 |
-
Number
|
| 387 |
|
| 388 |
-
Meaningful for all floating
|
| 389 |
|
| 390 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 391 |
|
| 392 |
``` cpp
|
| 393 |
static constexpr float_denorm_style has_denorm;
|
| 394 |
```
|
| 395 |
|
| 396 |
-
`denorm_present` if the type allows
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
|
| 401 |
-
Meaningful for all floating
|
| 402 |
|
| 403 |
``` cpp
|
| 404 |
static constexpr bool has_denorm_loss;
|
| 405 |
```
|
| 406 |
|
| 407 |
-
|
| 408 |
than as an inexact result.[^19]
|
| 409 |
|
| 410 |
``` cpp
|
| 411 |
static constexpr T infinity() noexcept;
|
| 412 |
```
|
|
@@ -418,65 +732,70 @@ Required in specializations for which `is_iec559 != false`.
|
|
| 418 |
|
| 419 |
``` cpp
|
| 420 |
static constexpr T quiet_NaN() noexcept;
|
| 421 |
```
|
| 422 |
|
| 423 |
-
Representation of a quiet “Not a Number
|
| 424 |
|
| 425 |
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 426 |
Required in specializations for which `is_iec559 != false`.
|
| 427 |
|
| 428 |
``` cpp
|
| 429 |
static constexpr T signaling_NaN() noexcept;
|
| 430 |
```
|
| 431 |
|
| 432 |
-
Representation of a signaling “Not a Number
|
| 433 |
|
| 434 |
Meaningful for all specializations for which
|
| 435 |
`has_signaling_NaN != false`. Required in specializations for which
|
| 436 |
`is_iec559 != false`.
|
| 437 |
|
| 438 |
``` cpp
|
| 439 |
static constexpr T denorm_min() noexcept;
|
| 440 |
```
|
| 441 |
|
| 442 |
-
Minimum positive
|
| 443 |
|
| 444 |
-
Meaningful for all floating
|
| 445 |
|
| 446 |
In specializations for which `has_denorm == false`, returns the minimum
|
| 447 |
positive normalized value.
|
| 448 |
|
| 449 |
``` cpp
|
| 450 |
static constexpr bool is_iec559;
|
| 451 |
```
|
| 452 |
|
| 453 |
-
|
| 454 |
|
| 455 |
-
Meaningful for all floating
|
| 456 |
|
| 457 |
``` cpp
|
| 458 |
static constexpr bool is_bounded;
|
| 459 |
```
|
| 460 |
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
|
|
|
|
|
|
| 464 |
|
| 465 |
Meaningful for all specializations.
|
| 466 |
|
| 467 |
``` cpp
|
| 468 |
static constexpr bool is_modulo;
|
| 469 |
```
|
| 470 |
|
| 471 |
-
|
| 472 |
-
involving `+`, `-`, or `*` on values of that type whose result
|
| 473 |
-
fall outside the range \[`min()`, `max()`\], the value returned
|
| 474 |
-
from the true value by an integer multiple of
|
|
|
|
| 475 |
|
| 476 |
-
|
| 477 |
-
|
|
|
|
|
|
|
| 478 |
|
| 479 |
Meaningful for all specializations.
|
| 480 |
|
| 481 |
``` cpp
|
| 482 |
static constexpr bool traps;
|
|
@@ -491,94 +810,51 @@ Meaningful for all specializations.
|
|
| 491 |
static constexpr bool tinyness_before;
|
| 492 |
```
|
| 493 |
|
| 494 |
`true` if tinyness is detected before rounding.[^28]
|
| 495 |
|
| 496 |
-
Meaningful for all floating
|
| 497 |
|
| 498 |
``` cpp
|
| 499 |
static constexpr float_round_style round_style;
|
| 500 |
```
|
| 501 |
|
| 502 |
The rounding style for the type.[^29]
|
| 503 |
|
| 504 |
-
Meaningful for all floating
|
| 505 |
types shall return `round_toward_zero`.
|
| 506 |
|
| 507 |
-
#### Type `float_round_style` <a id="round.style">[[round.style]]</a>
|
| 508 |
-
|
| 509 |
-
``` cpp
|
| 510 |
-
namespace std {
|
| 511 |
-
enum float_round_style {
|
| 512 |
-
round_indeterminate = -1,
|
| 513 |
-
round_toward_zero = 0,
|
| 514 |
-
round_to_nearest = 1,
|
| 515 |
-
round_toward_infinity = 2,
|
| 516 |
-
round_toward_neg_infinity = 3
|
| 517 |
-
};
|
| 518 |
-
}
|
| 519 |
-
```
|
| 520 |
-
|
| 521 |
-
The rounding mode for floating point arithmetic is characterized by the
|
| 522 |
-
values:
|
| 523 |
-
|
| 524 |
-
- `round_indeterminate` if the rounding style is indeterminable
|
| 525 |
-
- `round_toward_zero` if the rounding style is toward zero
|
| 526 |
-
- `round_to_nearest` if the rounding style is to the nearest
|
| 527 |
-
representable value
|
| 528 |
-
- `round_toward_infinity` if the rounding style is toward infinity
|
| 529 |
-
- `round_toward_neg_infinity` if the rounding style is toward negative
|
| 530 |
-
infinity
|
| 531 |
-
|
| 532 |
-
#### Type `float_denorm_style` <a id="denorm.style">[[denorm.style]]</a>
|
| 533 |
-
|
| 534 |
-
``` cpp
|
| 535 |
-
namespace std {
|
| 536 |
-
enum float_denorm_style {
|
| 537 |
-
denorm_indeterminate = -1,
|
| 538 |
-
denorm_absent = 0,
|
| 539 |
-
denorm_present = 1
|
| 540 |
-
};
|
| 541 |
-
}
|
| 542 |
-
```
|
| 543 |
-
|
| 544 |
-
The presence or absence of denormalization (variable number of exponent
|
| 545 |
-
bits) is characterized by the values:
|
| 546 |
-
|
| 547 |
-
- `denorm_indeterminate` if it cannot be determined whether or not the
|
| 548 |
-
type allows denormalized values
|
| 549 |
-
- `denorm_absent` if the type does not allow denormalized values
|
| 550 |
-
- `denorm_present` if the type does allow denormalized values
|
| 551 |
-
|
| 552 |
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
| 553 |
|
| 554 |
All members shall be provided for all specializations. However, many
|
| 555 |
values are only required to be meaningful under certain conditions (for
|
| 556 |
example, `epsilon()` is only meaningful if `is_integer` is `false`). Any
|
| 557 |
value that is not “meaningful” shall be set to 0 or `false`.
|
| 558 |
|
|
|
|
|
|
|
| 559 |
``` cpp
|
| 560 |
namespace std {
|
| 561 |
template<> class numeric_limits<float> {
|
| 562 |
public:
|
| 563 |
static constexpr bool is_specialized = true;
|
| 564 |
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
|
| 569 |
static constexpr int digits = 24;
|
| 570 |
static constexpr int digits10 = 6;
|
| 571 |
static constexpr int max_digits10 = 9;
|
| 572 |
|
| 573 |
static constexpr bool is_signed = true;
|
| 574 |
static constexpr bool is_integer = false;
|
| 575 |
static constexpr bool is_exact = false;
|
| 576 |
|
| 577 |
static constexpr int radix = 2;
|
| 578 |
-
|
| 579 |
-
|
| 580 |
|
| 581 |
static constexpr int min_exponent = -125;
|
| 582 |
static constexpr int min_exponent10 = - 37;
|
| 583 |
static constexpr int max_exponent = +128;
|
| 584 |
static constexpr int max_exponent10 = + 38;
|
|
@@ -587,14 +863,14 @@ namespace std {
|
|
| 587 |
static constexpr bool has_quiet_NaN = true;
|
| 588 |
static constexpr bool has_signaling_NaN = true;
|
| 589 |
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 590 |
static constexpr bool has_denorm_loss = false;
|
| 591 |
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
|
| 597 |
static constexpr bool is_iec559 = true;
|
| 598 |
static constexpr bool is_bounded = true;
|
| 599 |
static constexpr bool is_modulo = false;
|
| 600 |
static constexpr bool traps = true;
|
|
@@ -603,10 +879,12 @@ namespace std {
|
|
| 603 |
static constexpr float_round_style round_style = round_to_nearest;
|
| 604 |
};
|
| 605 |
}
|
| 606 |
```
|
| 607 |
|
|
|
|
|
|
|
| 608 |
The specialization for `bool` shall be provided as follows:
|
| 609 |
|
| 610 |
``` cpp
|
| 611 |
namespace std {
|
| 612 |
template<> class numeric_limits<bool> {
|
|
@@ -651,66 +929,135 @@ namespace std {
|
|
| 651 |
static constexpr float_round_style round_style = round_toward_zero;
|
| 652 |
};
|
| 653 |
}
|
| 654 |
```
|
| 655 |
|
| 656 |
-
###
|
| 657 |
|
| 658 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 659 |
|
| 660 |
-
The
|
| 661 |
-
|
| 662 |
-
required to match the types to which the macros refer.
|
| 663 |
|
| 664 |
-
|
|
|
|
|
|
|
| 665 |
|
| 666 |
-
|
| 667 |
|
| 668 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 669 |
|
| 670 |
## Integer types <a id="cstdint">[[cstdint]]</a>
|
| 671 |
|
| 672 |
### Header `<cstdint>` synopsis <a id="cstdint.syn">[[cstdint.syn]]</a>
|
| 673 |
|
| 674 |
``` cpp
|
| 675 |
namespace std {
|
| 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 |
The header also defines numerous macros of the form:
|
| 715 |
|
| 716 |
``` cpp
|
|
@@ -726,70 +1073,68 @@ plus function macros of the form:
|
|
| 726 |
|
| 727 |
``` cpp
|
| 728 |
[U]INT{8 16 32 64 MAX}_C
|
| 729 |
```
|
| 730 |
|
| 731 |
-
The header defines all
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
the C standard) play no role in C++.
|
| 736 |
|
| 737 |
## Start and termination <a id="support.start.term">[[support.start.term]]</a>
|
| 738 |
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
The contents are the same as the Standard C library header `<stdlib.h>`,
|
| 743 |
-
with the following changes:
|
| 744 |
|
| 745 |
``` cpp
|
| 746 |
[[noreturn]] void _Exit(int status) noexcept;
|
| 747 |
```
|
| 748 |
|
| 749 |
-
|
| 750 |
-
|
| 751 |
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
|
|
|
| 755 |
|
| 756 |
``` cpp
|
| 757 |
-
[[noreturn]] void abort(
|
| 758 |
```
|
| 759 |
|
| 760 |
-
|
| 761 |
-
|
| 762 |
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
|
|
|
| 766 |
|
| 767 |
``` cpp
|
| 768 |
-
|
| 769 |
-
|
| 770 |
```
|
| 771 |
|
| 772 |
*Effects:* The `atexit()` functions register the function pointed to by
|
| 773 |
`f` to be called without arguments at normal program termination. It is
|
| 774 |
unspecified whether a call to `atexit()` that does not happen
|
| 775 |
-
before ([[intro.multithread]]) a call to `exit()` will succeed.
|
| 776 |
-
|
| 777 |
-
|
|
|
|
| 778 |
|
| 779 |
*Implementation limits:* The implementation shall support the
|
| 780 |
registration of at least 32 functions.
|
| 781 |
|
| 782 |
*Returns:* The `atexit()` function returns zero if the registration
|
| 783 |
-
succeeds,
|
| 784 |
|
| 785 |
``` cpp
|
| 786 |
-
[[noreturn]] void exit(int status)
|
| 787 |
```
|
| 788 |
|
| 789 |
-
|
| 790 |
-
Standard:
|
| 791 |
|
| 792 |
- First, objects with thread storage duration and associated with the
|
| 793 |
current thread are destroyed. Next, objects with static storage
|
| 794 |
duration are destroyed and functions registered by calling `atexit`
|
| 795 |
are called.[^30] See [[basic.start.term]] for the order of
|
|
@@ -808,29 +1153,33 @@ Standard:
|
|
| 808 |
an *implementation-defined* form of the status *unsuccessful
|
| 809 |
termination* is returned. Otherwise the status returned is
|
| 810 |
*implementation-defined*.[^32]
|
| 811 |
|
| 812 |
``` cpp
|
| 813 |
-
|
| 814 |
-
|
| 815 |
```
|
| 816 |
|
| 817 |
*Effects:* The `at_quick_exit()` functions register the function pointed
|
| 818 |
to by `f` to be called without arguments when `quick_exit` is called. It
|
| 819 |
is unspecified whether a call to `at_quick_exit()` that does not happen
|
| 820 |
before ([[intro.multithread]]) all calls to `quick_exit` will succeed.
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 827 |
|
| 828 |
*Implementation limits:* The implementation shall support the
|
| 829 |
registration of at least 32 functions.
|
| 830 |
|
| 831 |
-
*Returns:* Zero if the registration succeeds,
|
| 832 |
|
| 833 |
``` cpp
|
| 834 |
[[noreturn]] void quick_exit(int status) noexcept;
|
| 835 |
```
|
| 836 |
|
|
@@ -841,48 +1190,75 @@ been called at the time it was registered. Objects shall not be
|
|
| 841 |
destroyed as a result of calling `quick_exit`. If control leaves a
|
| 842 |
registered function called by `quick_exit` because the function does not
|
| 843 |
provide a handler for a thrown exception, `std::terminate()` shall be
|
| 844 |
called.
|
| 845 |
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
standard file buffers are not flushed. ISO C 7.20.4.4.
|
| 851 |
|
| 852 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 853 |
|
| 854 |
## Dynamic memory management <a id="support.dynamic">[[support.dynamic]]</a>
|
| 855 |
|
| 856 |
The header `<new>` defines several functions that manage the allocation
|
| 857 |
of dynamic storage in a program. It also defines components for
|
| 858 |
reporting storage management errors.
|
| 859 |
|
|
|
|
|
|
|
| 860 |
``` cpp
|
| 861 |
namespace std {
|
| 862 |
class bad_alloc;
|
| 863 |
class bad_array_new_length;
|
| 864 |
-
|
|
|
|
| 865 |
extern const nothrow_t nothrow;
|
| 866 |
-
|
| 867 |
new_handler get_new_handler() noexcept;
|
| 868 |
new_handler set_new_handler(new_handler new_p) noexcept;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
}
|
| 870 |
|
| 871 |
void* operator new(std::size_t size);
|
|
|
|
| 872 |
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
|
|
|
|
|
|
| 873 |
void operator delete(void* ptr) noexcept;
|
| 874 |
-
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 875 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 876 |
-
void operator delete(void* ptr, std::
|
|
|
|
|
|
|
|
|
|
| 877 |
const std::nothrow_t&) noexcept;
|
| 878 |
void* operator new[](std::size_t size);
|
|
|
|
| 879 |
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
|
|
|
|
|
|
| 880 |
void operator delete[](void* ptr) noexcept;
|
| 881 |
-
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 882 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 883 |
-
void operator delete[](void* ptr, std::
|
|
|
|
|
|
|
|
|
|
| 884 |
const std::nothrow_t&) noexcept;
|
| 885 |
|
| 886 |
void* operator new (std::size_t size, void* ptr) noexcept;
|
| 887 |
void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 888 |
void operator delete (void* ptr, void*) noexcept;
|
|
@@ -892,38 +1268,46 @@ void operator delete[](void* ptr, void*) noexcept;
|
|
| 892 |
[[intro.memory]], [[basic.stc.dynamic]], [[expr.new]],
|
| 893 |
[[expr.delete]], [[class.free]], [[memory]].
|
| 894 |
|
| 895 |
### Storage allocation and deallocation <a id="new.delete">[[new.delete]]</a>
|
| 896 |
|
| 897 |
-
Except where otherwise specified, the provisions of
|
| 898 |
-
[[basic.stc.dynamic]]
|
| 899 |
and `operator
|
| 900 |
-
delete`.
|
|
|
|
| 901 |
|
| 902 |
#### Single-object forms <a id="new.delete.single">[[new.delete.single]]</a>
|
| 903 |
|
| 904 |
``` cpp
|
| 905 |
void* operator new(std::size_t size);
|
|
|
|
| 906 |
```
|
| 907 |
|
| 908 |
-
*Effects:* The
|
| 909 |
called by a *new-expression* ([[expr.new]]) to allocate `size` bytes of
|
| 910 |
-
storage
|
|
|
|
|
|
|
|
|
|
|
|
|
| 911 |
|
| 912 |
-
*Replaceable:*
|
| 913 |
-
|
| 914 |
-
library.
|
| 915 |
|
| 916 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 917 |
storage ([[basic.stc.dynamic]]), or else throw a `bad_alloc` exception.
|
| 918 |
-
This requirement is binding on
|
|
|
|
| 919 |
|
| 920 |
*Default behavior:*
|
| 921 |
|
| 922 |
- Executes a loop: Within the loop, the function first attempts to
|
| 923 |
allocate the requested storage. Whether the attempt involves a call to
|
| 924 |
-
the
|
|
|
|
| 925 |
- Returns a pointer to the allocated storage if the attempt is
|
| 926 |
successful. Otherwise, if the current
|
| 927 |
`new_handler` ([[get.new.handler]]) is a null pointer value, throws
|
| 928 |
`bad_alloc`.
|
| 929 |
- Otherwise, the function calls the current `new_handler`
|
|
@@ -932,277 +1316,308 @@ This requirement is binding on a replacement version of this function.
|
|
| 932 |
- The loop terminates when an attempt to allocate the requested storage
|
| 933 |
is successful or when a called `new_handler` function does not return.
|
| 934 |
|
| 935 |
``` cpp
|
| 936 |
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
|
|
|
| 937 |
```
|
| 938 |
|
| 939 |
-
*Effects:* Same as above, except that
|
| 940 |
version of a *new-expression* when a C++program prefers a null pointer
|
| 941 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 942 |
|
| 943 |
-
*Replaceable:*
|
| 944 |
-
|
| 945 |
-
library.
|
| 946 |
|
| 947 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 948 |
-
storage ([[basic.stc.dynamic]]), or else return a null pointer.
|
| 949 |
-
nothrow
|
| 950 |
-
acquired from the (possibly replaced)
|
| 951 |
-
is binding on
|
|
|
|
| 952 |
|
| 953 |
-
*Default behavior:* Calls `operator new(size)`
|
|
|
|
| 954 |
normally, returns the result of that call. Otherwise, returns a null
|
| 955 |
pointer.
|
| 956 |
|
|
|
|
|
|
|
| 957 |
``` cpp
|
| 958 |
T* p1 = new T; // throws bad_alloc if it fails
|
| 959 |
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 960 |
```
|
| 961 |
|
|
|
|
|
|
|
| 962 |
``` cpp
|
| 963 |
void operator delete(void* ptr) noexcept;
|
| 964 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
|
|
|
|
|
|
| 965 |
```
|
| 966 |
|
| 967 |
-
*Effects:* The
|
| 968 |
-
|
| 969 |
*delete-expression* to render the value of `ptr` invalid.
|
| 970 |
|
| 971 |
-
*Replaceable:*
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
`size` parameter) is defined, the program should also define
|
| 975 |
-
`void operator delete(void* ptr, std::size_t size) noexcept`. If this
|
| 976 |
-
function with `size` parameter is defined, the program shall also define
|
| 977 |
-
the version without the `size` parameter. The default behavior below may
|
| 978 |
-
change in the future, which will require replacing both deallocation
|
| 979 |
-
functions when replacing the allocation function.
|
| 980 |
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 986 |
|
| 987 |
*Requires:* If an implementation has strict pointer
|
| 988 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 989 |
safely-derived pointer.
|
| 990 |
|
| 991 |
-
*Requires:* If
|
| 992 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 993 |
|
| 994 |
-
*Required behavior:*
|
| 995 |
-
|
| 996 |
-
|
| 997 |
-
|
|
|
|
|
|
|
| 998 |
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 999 |
-
`operator delete(ptr)`.
|
| 1000 |
|
| 1001 |
-
*Default behavior:*
|
| 1002 |
-
|
| 1003 |
-
|
| 1004 |
-
|
|
|
|
|
|
|
| 1005 |
|
| 1006 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 1007 |
the storage allocated by the earlier call to `operator new`.
|
| 1008 |
|
| 1009 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 1010 |
reclaimed storage will be allocated by subsequent calls to
|
| 1011 |
-
`operator new` or any of `
|
| 1012 |
-
`<cstdlib>`.
|
| 1013 |
|
| 1014 |
``` cpp
|
| 1015 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 1016 |
-
void operator delete(void* ptr, std::
|
| 1017 |
```
|
| 1018 |
|
| 1019 |
-
*Effects:* The
|
| 1020 |
-
|
| 1021 |
implementation to render the value of `ptr` invalid when the constructor
|
| 1022 |
invoked from a nothrow placement version of the *new-expression* throws
|
| 1023 |
an exception.
|
| 1024 |
|
| 1025 |
-
*Replaceable:*
|
| 1026 |
-
|
| 1027 |
-
|
| 1028 |
-
|
| 1029 |
-
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
both deallocation functions when replacing the allocation function.
|
| 1035 |
|
| 1036 |
*Requires:* If an implementation has strict pointer
|
| 1037 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1038 |
safely-derived pointer.
|
| 1039 |
|
| 1040 |
-
*Requires:* If
|
| 1041 |
-
|
|
|
|
|
|
|
|
|
|
| 1042 |
|
| 1043 |
-
*
|
| 1044 |
-
`operator delete(
|
| 1045 |
-
may be changed to calls to
|
| 1046 |
-
`operator delete(void* ptr, const std::nothrow_t&)` without affecting
|
| 1047 |
-
memory allocation. A conforming implementation is for
|
| 1048 |
-
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)` to
|
| 1049 |
-
simply call `operator delete(void* ptr, const std::nothrow_t&)`.
|
| 1050 |
-
|
| 1051 |
-
*Default behavior:*
|
| 1052 |
-
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 1053 |
-
calls `operator delete(ptr, std::nothrow)`, and
|
| 1054 |
-
`operator delete(void* ptr, const std::nothrow_t&)` calls
|
| 1055 |
-
`operator delete(ptr)`.
|
| 1056 |
|
| 1057 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 1058 |
|
| 1059 |
``` cpp
|
| 1060 |
void* operator new[](std::size_t size);
|
|
|
|
| 1061 |
```
|
| 1062 |
|
| 1063 |
-
*Effects:* The
|
| 1064 |
called by the array form of a *new-expression* ([[expr.new]]) to
|
| 1065 |
-
allocate `size` bytes of storage
|
| 1066 |
-
|
|
|
|
|
|
|
|
|
|
| 1067 |
|
| 1068 |
-
*Replaceable:*
|
| 1069 |
-
|
| 1070 |
-
library.
|
| 1071 |
|
| 1072 |
-
*Required behavior:* Same as for
|
| 1073 |
-
requirement is binding on
|
|
|
|
| 1074 |
|
| 1075 |
-
*Default behavior:* Returns `operator new(size)`
|
|
|
|
| 1076 |
|
| 1077 |
``` cpp
|
| 1078 |
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
|
|
|
| 1079 |
```
|
| 1080 |
|
| 1081 |
-
*Effects:* Same as above, except that
|
| 1082 |
version of a *new-expression* when a C++program prefers a null pointer
|
| 1083 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 1084 |
|
| 1085 |
-
*Replaceable:*
|
| 1086 |
-
|
| 1087 |
-
library.
|
| 1088 |
|
| 1089 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 1090 |
-
storage ([[basic.stc.dynamic]]), or return a null pointer.
|
| 1091 |
-
|
|
|
|
|
|
|
|
|
|
| 1092 |
|
| 1093 |
-
*Default behavior:* Calls `operator new[](size)`
|
|
|
|
| 1094 |
normally, returns the result of that call. Otherwise, returns a null
|
| 1095 |
pointer.
|
| 1096 |
|
| 1097 |
``` cpp
|
| 1098 |
void operator delete[](void* ptr) noexcept;
|
| 1099 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
|
|
|
|
|
|
| 1100 |
```
|
| 1101 |
|
| 1102 |
-
*Effects:* The
|
| 1103 |
-
|
| 1104 |
of a *delete-expression* to render the value of `ptr` invalid.
|
| 1105 |
|
| 1106 |
-
*Replaceable:*
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
-
`size` parameter) is defined, the program should also define
|
| 1110 |
-
`void operator delete[](void* ptr, std::size_t size) noexcept`. If this
|
| 1111 |
-
function with `size` parameter is defined, the program shall also define
|
| 1112 |
-
the version without the `size` parameter. The default behavior below may
|
| 1113 |
-
change in the future, which will require replacing both deallocation
|
| 1114 |
-
functions when replacing the allocation function.
|
| 1115 |
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
|
| 1119 |
-
|
| 1120 |
|
| 1121 |
-
*
|
| 1122 |
-
|
|
|
|
| 1123 |
|
| 1124 |
-
*
|
| 1125 |
-
|
| 1126 |
-
|
| 1127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1128 |
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 1129 |
-
`operator delete[](
|
| 1130 |
|
| 1131 |
-
*
|
| 1132 |
-
|
| 1133 |
-
|
| 1134 |
-
|
| 1135 |
-
|
| 1136 |
-
calls `operator delete[](ptr)`, and `operator delete[](void* ptr)` calls
|
| 1137 |
-
`operator delete(ptr)`.
|
| 1138 |
|
| 1139 |
``` cpp
|
| 1140 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 1141 |
-
void operator delete[](void* ptr, std::
|
| 1142 |
```
|
| 1143 |
|
| 1144 |
-
*Effects:* The
|
| 1145 |
-
|
| 1146 |
implementation to render the value of `ptr` invalid when the constructor
|
| 1147 |
invoked from a nothrow placement version of the array *new-expression*
|
| 1148 |
throws an exception.
|
| 1149 |
|
| 1150 |
-
*Replaceable:*
|
| 1151 |
-
|
| 1152 |
-
|
| 1153 |
-
|
| 1154 |
-
|
| 1155 |
-
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
both deallocation functions when replacing the allocation function.
|
| 1160 |
|
| 1161 |
*Requires:* If an implementation has strict pointer
|
| 1162 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1163 |
safely-derived pointer.
|
| 1164 |
|
| 1165 |
-
*Requires:* If
|
| 1166 |
-
|
|
|
|
|
|
|
|
|
|
| 1167 |
|
| 1168 |
-
*
|
| 1169 |
-
`operator delete[](
|
| 1170 |
-
may be changed to calls to
|
| 1171 |
-
`operator delete[](void* ptr, const std::nothrow_t&)` without affecting
|
| 1172 |
-
memory allocation. A conforming implementation is for
|
| 1173 |
-
`operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 1174 |
-
to simply call `operator delete[](void* ptr, const std::nothrow_t&)`.
|
| 1175 |
|
| 1176 |
-
|
| 1177 |
-
`operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 1178 |
-
calls `operator delete[](ptr, std::nothrow)`, and
|
| 1179 |
-
`operator delete[](void* ptr, const std::nothrow_t&)` calls
|
| 1180 |
-
`operator delete[](ptr)`.
|
| 1181 |
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
displace the versions in the Standard C++library ([[constraints]]). The
|
| 1186 |
-
provisions of ([[basic.stc.dynamic]]) do not apply to these reserved
|
| 1187 |
placement forms of `operator new` and `operator delete`.
|
| 1188 |
|
| 1189 |
``` cpp
|
| 1190 |
void* operator new(std::size_t size, void* ptr) noexcept;
|
| 1191 |
```
|
| 1192 |
|
| 1193 |
*Returns:* `ptr`.
|
| 1194 |
|
| 1195 |
*Remarks:* Intentionally performs no other action.
|
| 1196 |
|
|
|
|
|
|
|
| 1197 |
This can be useful for constructing an object at a known address:
|
| 1198 |
|
| 1199 |
``` cpp
|
| 1200 |
void* place = operator new(sizeof(Something));
|
| 1201 |
Something* p = new (place) Something();
|
| 1202 |
```
|
| 1203 |
|
|
|
|
|
|
|
| 1204 |
``` cpp
|
| 1205 |
void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 1206 |
```
|
| 1207 |
|
| 1208 |
*Returns:* `ptr`.
|
|
@@ -1218,11 +1633,11 @@ void operator delete(void* ptr, void*) noexcept;
|
|
| 1218 |
*Requires:* If an implementation has strict pointer
|
| 1219 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1220 |
safely-derived pointer.
|
| 1221 |
|
| 1222 |
*Remarks:* Default function called when any part of the initialization
|
| 1223 |
-
in a placement new
|
| 1224 |
placement operator new terminates by throwing an
|
| 1225 |
exception ([[expr.new]]).
|
| 1226 |
|
| 1227 |
``` cpp
|
| 1228 |
void operator delete[](void* ptr, void*) noexcept;
|
|
@@ -1233,25 +1648,27 @@ void operator delete[](void* ptr, void*) noexcept;
|
|
| 1233 |
*Requires:* If an implementation has strict pointer
|
| 1234 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1235 |
safely-derived pointer.
|
| 1236 |
|
| 1237 |
*Remarks:* Default function called when any part of the initialization
|
| 1238 |
-
in a placement new
|
| 1239 |
-
operator new terminates by throwing an
|
|
|
|
| 1240 |
|
| 1241 |
#### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
|
| 1242 |
|
| 1243 |
For purposes of determining the existence of data races, the library
|
| 1244 |
versions of `operator new`, user replacement versions of global
|
| 1245 |
-
`operator new`, the C standard library functions `
|
| 1246 |
-
the library versions of `operator delete`, user
|
| 1247 |
-
`operator delete`, the C standard library
|
| 1248 |
-
standard library function `realloc` shall not
|
| 1249 |
-
[[res.on.data.races]]). Calls to these functions
|
| 1250 |
-
deallocate a particular unit of storage shall occur in
|
| 1251 |
-
order, and each such deallocation call shall happen
|
| 1252 |
-
[[intro.multithread]]) the next allocation (if any) in this
|
|
|
|
| 1253 |
|
| 1254 |
### Storage allocation errors <a id="alloc.errors">[[alloc.errors]]</a>
|
| 1255 |
|
| 1256 |
#### Class `bad_alloc` <a id="bad.alloc">[[bad.alloc]]</a>
|
| 1257 |
|
|
@@ -1260,11 +1677,11 @@ namespace std {
|
|
| 1260 |
class bad_alloc : public exception {
|
| 1261 |
public:
|
| 1262 |
bad_alloc() noexcept;
|
| 1263 |
bad_alloc(const bad_alloc&) noexcept;
|
| 1264 |
bad_alloc& operator=(const bad_alloc&) noexcept;
|
| 1265 |
-
|
| 1266 |
};
|
| 1267 |
}
|
| 1268 |
```
|
| 1269 |
|
| 1270 |
The class `bad_alloc` defines the type of objects thrown as exceptions
|
|
@@ -1274,55 +1691,64 @@ by the implementation to report a failure to allocate storage.
|
|
| 1274 |
bad_alloc() noexcept;
|
| 1275 |
```
|
| 1276 |
|
| 1277 |
*Effects:* Constructs an object of class `bad_alloc`.
|
| 1278 |
|
| 1279 |
-
*Remarks:* The result of calling `what()` on the newly constructed
|
| 1280 |
-
object is implementation-defined.
|
| 1281 |
-
|
| 1282 |
``` cpp
|
| 1283 |
bad_alloc(const bad_alloc&) noexcept;
|
| 1284 |
bad_alloc& operator=(const bad_alloc&) noexcept;
|
| 1285 |
```
|
| 1286 |
|
| 1287 |
*Effects:* Copies an object of class `bad_alloc`.
|
| 1288 |
|
| 1289 |
``` cpp
|
| 1290 |
-
|
| 1291 |
```
|
| 1292 |
|
| 1293 |
*Returns:* An *implementation-defined* NTBS.
|
| 1294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1295 |
#### Class `bad_array_new_length` <a id="new.badlength">[[new.badlength]]</a>
|
| 1296 |
|
| 1297 |
``` cpp
|
| 1298 |
namespace std {
|
| 1299 |
class bad_array_new_length : public bad_alloc {
|
| 1300 |
public:
|
| 1301 |
bad_array_new_length() noexcept;
|
|
|
|
| 1302 |
};
|
| 1303 |
}
|
| 1304 |
```
|
| 1305 |
|
| 1306 |
The class `bad_array_new_length` defines the type of objects thrown as
|
| 1307 |
exceptions by the implementation to report an attempt to allocate an
|
| 1308 |
-
array of size less than zero or greater than an implementation-defined
|
| 1309 |
limit ([[expr.new]]).
|
| 1310 |
|
| 1311 |
``` cpp
|
| 1312 |
bad_array_new_length() noexcept;
|
| 1313 |
```
|
| 1314 |
|
| 1315 |
*Effects:* constructs an object of class `bad_array_new_length`.
|
| 1316 |
|
| 1317 |
-
|
| 1318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1319 |
|
| 1320 |
#### Type `new_handler` <a id="new.handler">[[new.handler]]</a>
|
| 1321 |
|
| 1322 |
``` cpp
|
| 1323 |
-
|
| 1324 |
```
|
| 1325 |
|
| 1326 |
The type of a *handler function* to be called by `operator new()` or
|
| 1327 |
`operator new[]()` ([[new.delete]]) when they cannot satisfy a request
|
| 1328 |
for additional storage.
|
|
@@ -1330,11 +1756,11 @@ for additional storage.
|
|
| 1330 |
*Required behavior:* A `new_handler` shall perform one of the following:
|
| 1331 |
|
| 1332 |
- make more storage available for allocation and then return;
|
| 1333 |
- throw an exception of type `bad_alloc` or a class derived from
|
| 1334 |
`bad_alloc`;
|
| 1335 |
-
- terminate execution of the program without returning to the caller
|
| 1336 |
|
| 1337 |
#### `set_new_handler` <a id="set.new.handler">[[set.new.handler]]</a>
|
| 1338 |
|
| 1339 |
``` cpp
|
| 1340 |
new_handler set_new_handler(new_handler new_p) noexcept;
|
|
@@ -1351,19 +1777,110 @@ new_handler set_new_handler(new_handler new_p) noexcept;
|
|
| 1351 |
|
| 1352 |
``` cpp
|
| 1353 |
new_handler get_new_handler() noexcept;
|
| 1354 |
```
|
| 1355 |
|
| 1356 |
-
*Returns:* The current `new_handler`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1357 |
|
| 1358 |
## Type identification <a id="support.rtti">[[support.rtti]]</a>
|
| 1359 |
|
| 1360 |
The header `<typeinfo>` defines a type associated with type information
|
| 1361 |
generated by the implementation. It also defines two types for reporting
|
| 1362 |
dynamic type identification errors.
|
| 1363 |
|
| 1364 |
-
|
| 1365 |
|
| 1366 |
``` cpp
|
| 1367 |
namespace std {
|
| 1368 |
class type_info;
|
| 1369 |
class bad_cast;
|
|
@@ -1427,12 +1944,12 @@ size_t hash_code() const noexcept;
|
|
| 1427 |
|
| 1428 |
*Returns:* An unspecified value, except that within a single execution
|
| 1429 |
of the program, it shall return the same value for any two `type_info`
|
| 1430 |
objects which compare equal.
|
| 1431 |
|
| 1432 |
-
|
| 1433 |
-
objects which do not compare equal.
|
| 1434 |
|
| 1435 |
``` cpp
|
| 1436 |
const char* name() const noexcept;
|
| 1437 |
```
|
| 1438 |
|
|
@@ -1449,37 +1966,34 @@ namespace std {
|
|
| 1449 |
class bad_cast : public exception {
|
| 1450 |
public:
|
| 1451 |
bad_cast() noexcept;
|
| 1452 |
bad_cast(const bad_cast&) noexcept;
|
| 1453 |
bad_cast& operator=(const bad_cast&) noexcept;
|
| 1454 |
-
|
| 1455 |
};
|
| 1456 |
}
|
| 1457 |
```
|
| 1458 |
|
| 1459 |
The class `bad_cast` defines the type of objects thrown as exceptions by
|
| 1460 |
-
the implementation to report the execution of an invalid
|
| 1461 |
expression ([[expr.dynamic.cast]]).
|
| 1462 |
|
| 1463 |
``` cpp
|
| 1464 |
bad_cast() noexcept;
|
| 1465 |
```
|
| 1466 |
|
| 1467 |
*Effects:* Constructs an object of class `bad_cast`.
|
| 1468 |
|
| 1469 |
-
*Remarks:* The result of calling `what()` on the newly constructed
|
| 1470 |
-
object is implementation-defined.
|
| 1471 |
-
|
| 1472 |
``` cpp
|
| 1473 |
bad_cast(const bad_cast&) noexcept;
|
| 1474 |
bad_cast& operator=(const bad_cast&) noexcept;
|
| 1475 |
```
|
| 1476 |
|
| 1477 |
*Effects:* Copies an object of class `bad_cast`.
|
| 1478 |
|
| 1479 |
``` cpp
|
| 1480 |
-
|
| 1481 |
```
|
| 1482 |
|
| 1483 |
*Returns:* An *implementation-defined* NTBS.
|
| 1484 |
|
| 1485 |
*Remarks:* The message may be a null-terminated multibyte
|
|
@@ -1493,37 +2007,34 @@ namespace std {
|
|
| 1493 |
class bad_typeid : public exception {
|
| 1494 |
public:
|
| 1495 |
bad_typeid() noexcept;
|
| 1496 |
bad_typeid(const bad_typeid&) noexcept;
|
| 1497 |
bad_typeid& operator=(const bad_typeid&) noexcept;
|
| 1498 |
-
|
| 1499 |
};
|
| 1500 |
}
|
| 1501 |
```
|
| 1502 |
|
| 1503 |
The class `bad_typeid` defines the type of objects thrown as exceptions
|
| 1504 |
-
by the implementation to report a null pointer in a
|
| 1505 |
expression ([[expr.typeid]]).
|
| 1506 |
|
| 1507 |
``` cpp
|
| 1508 |
bad_typeid() noexcept;
|
| 1509 |
```
|
| 1510 |
|
| 1511 |
*Effects:* Constructs an object of class `bad_typeid`.
|
| 1512 |
|
| 1513 |
-
*Remarks:* The result of calling `what()` on the newly constructed
|
| 1514 |
-
object is implementation-defined.
|
| 1515 |
-
|
| 1516 |
``` cpp
|
| 1517 |
bad_typeid(const bad_typeid&) noexcept;
|
| 1518 |
bad_typeid& operator=(const bad_typeid&) noexcept;
|
| 1519 |
```
|
| 1520 |
|
| 1521 |
*Effects:* Copies an object of class `bad_typeid`.
|
| 1522 |
|
| 1523 |
``` cpp
|
| 1524 |
-
|
| 1525 |
```
|
| 1526 |
|
| 1527 |
*Returns:* An *implementation-defined* NTBS.
|
| 1528 |
|
| 1529 |
*Remarks:* The message may be a null-terminated multibyte
|
|
@@ -1533,29 +2044,26 @@ a `wstring` ([[string.classes]], [[locale.codecvt]])
|
|
| 1533 |
## Exception handling <a id="support.exception">[[support.exception]]</a>
|
| 1534 |
|
| 1535 |
The header `<exception>` defines several types and functions related to
|
| 1536 |
the handling of exceptions in a C++program.
|
| 1537 |
|
|
|
|
|
|
|
| 1538 |
``` cpp
|
| 1539 |
namespace std {
|
| 1540 |
class exception;
|
| 1541 |
class bad_exception;
|
| 1542 |
class nested_exception;
|
| 1543 |
|
| 1544 |
-
|
| 1545 |
-
unexpected_handler get_unexpected() noexcept;
|
| 1546 |
-
unexpected_handler set_unexpected(unexpected_handler f) noexcept;
|
| 1547 |
-
[[noreturn]] void unexpected();
|
| 1548 |
-
|
| 1549 |
-
typedef void (*terminate_handler)();
|
| 1550 |
terminate_handler get_terminate() noexcept;
|
| 1551 |
terminate_handler set_terminate(terminate_handler f) noexcept;
|
| 1552 |
[[noreturn]] void terminate() noexcept;
|
| 1553 |
|
| 1554 |
-
|
| 1555 |
|
| 1556 |
-
|
| 1557 |
|
| 1558 |
exception_ptr current_exception() noexcept;
|
| 1559 |
[[noreturn]] void rethrow_exception(exception_ptr p);
|
| 1560 |
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 1561 |
|
|
@@ -1603,11 +2111,12 @@ exception(const exception& rhs) noexcept;
|
|
| 1603 |
exception& operator=(const exception& rhs) noexcept;
|
| 1604 |
```
|
| 1605 |
|
| 1606 |
*Effects:* Copies an `exception` object.
|
| 1607 |
|
| 1608 |
-
If `*this` and `rhs` both have dynamic type
|
|
|
|
| 1609 |
`strcmp(what(), rhs.what())` shall equal 0.
|
| 1610 |
|
| 1611 |
``` cpp
|
| 1612 |
virtual ~exception();
|
| 1613 |
```
|
|
@@ -1634,36 +2143,35 @@ namespace std {
|
|
| 1634 |
class bad_exception : public exception {
|
| 1635 |
public:
|
| 1636 |
bad_exception() noexcept;
|
| 1637 |
bad_exception(const bad_exception&) noexcept;
|
| 1638 |
bad_exception& operator=(const bad_exception&) noexcept;
|
| 1639 |
-
|
| 1640 |
};
|
| 1641 |
}
|
| 1642 |
```
|
| 1643 |
|
| 1644 |
-
The class `bad_exception` defines the type of
|
| 1645 |
-
|
|
|
|
|
|
|
| 1646 |
|
| 1647 |
``` cpp
|
| 1648 |
bad_exception() noexcept;
|
| 1649 |
```
|
| 1650 |
|
| 1651 |
*Effects:* Constructs an object of class `bad_exception`.
|
| 1652 |
|
| 1653 |
-
*Remarks:* The result of calling `what()` on the newly constructed
|
| 1654 |
-
object is implementation-defined.
|
| 1655 |
-
|
| 1656 |
``` cpp
|
| 1657 |
bad_exception(const bad_exception&) noexcept;
|
| 1658 |
bad_exception& operator=(const bad_exception&) noexcept;
|
| 1659 |
```
|
| 1660 |
|
| 1661 |
*Effects:* Copies an object of class `bad_exception`.
|
| 1662 |
|
| 1663 |
``` cpp
|
| 1664 |
-
|
| 1665 |
```
|
| 1666 |
|
| 1667 |
*Returns:* An *implementation-defined* NTBS.
|
| 1668 |
|
| 1669 |
*Remarks:* The message may be a null-terminated multibyte
|
|
@@ -1673,11 +2181,11 @@ a `wstring` ([[string.classes]], [[locale.codecvt]]).
|
|
| 1673 |
### Abnormal termination <a id="exception.terminate">[[exception.terminate]]</a>
|
| 1674 |
|
| 1675 |
#### Type `terminate_handler` <a id="terminate.handler">[[terminate.handler]]</a>
|
| 1676 |
|
| 1677 |
``` cpp
|
| 1678 |
-
|
| 1679 |
```
|
| 1680 |
|
| 1681 |
The type of a *handler function* to be called by `std::terminate()` when
|
| 1682 |
terminating exception processing.
|
| 1683 |
|
|
@@ -1705,51 +2213,51 @@ default `terminate_handler`.
|
|
| 1705 |
|
| 1706 |
``` cpp
|
| 1707 |
terminate_handler get_terminate() noexcept;
|
| 1708 |
```
|
| 1709 |
|
| 1710 |
-
*Returns:* The current `terminate_handler`.
|
| 1711 |
-
|
|
|
|
| 1712 |
|
| 1713 |
#### `terminate` <a id="terminate">[[terminate]]</a>
|
| 1714 |
|
| 1715 |
``` cpp
|
| 1716 |
[[noreturn]] void terminate() noexcept;
|
| 1717 |
```
|
| 1718 |
|
| 1719 |
*Remarks:* Called by the implementation when exception handling must be
|
| 1720 |
-
abandoned for any of several reasons ([[except.terminate]])
|
| 1721 |
-
|
| 1722 |
-
the program.
|
| 1723 |
|
| 1724 |
-
*Effects:* Calls
|
| 1725 |
-
`terminate_handler`
|
| 1726 |
-
|
|
|
|
| 1727 |
|
| 1728 |
-
|
|
|
|
|
|
|
|
|
|
| 1729 |
|
| 1730 |
``` cpp
|
| 1731 |
-
|
| 1732 |
```
|
| 1733 |
|
| 1734 |
-
*Returns:*
|
| 1735 |
-
object ([[except.throw]]) until a handler for the exception (including
|
| 1736 |
-
`std::unexpected()` or `std::terminate()`) is
|
| 1737 |
-
activated ([[except.handle]]). This includes stack
|
| 1738 |
-
unwinding ([[except.ctor]]).
|
| 1739 |
|
| 1740 |
-
*Remarks:* When `
|
| 1741 |
-
|
| 1742 |
`std::terminate()` ([[except.terminate]]).
|
| 1743 |
|
| 1744 |
### Exception propagation <a id="propagation">[[propagation]]</a>
|
| 1745 |
|
| 1746 |
``` cpp
|
| 1747 |
-
|
| 1748 |
```
|
| 1749 |
|
| 1750 |
-
The type exception_ptr can be used to refer to an exception object.
|
| 1751 |
|
| 1752 |
`exception_ptr` shall satisfy the requirements of
|
| 1753 |
`NullablePointer` ([[nullablepointer.requirements]]).
|
| 1754 |
|
| 1755 |
Two non-null values of type `exception_ptr` are equivalent and compare
|
|
@@ -1759,22 +2267,24 @@ The default constructor of `exception_ptr` produces the null value of
|
|
| 1759 |
the type.
|
| 1760 |
|
| 1761 |
`exception_ptr` shall not be implicitly convertible to any arithmetic,
|
| 1762 |
enumeration, or pointer type.
|
| 1763 |
|
| 1764 |
-
An implementation might use a reference-counted smart
|
| 1765 |
-
`exception_ptr`.
|
| 1766 |
|
| 1767 |
For purposes of determining the presence of a data race, operations on
|
| 1768 |
`exception_ptr` objects shall access and modify only the `exception_ptr`
|
| 1769 |
objects themselves and not the exceptions they refer to. Use of
|
| 1770 |
`rethrow_exception` on `exception_ptr` objects that refer to the same
|
| 1771 |
-
exception object shall not introduce a data race.
|
| 1772 |
-
|
| 1773 |
-
|
| 1774 |
-
|
| 1775 |
-
|
|
|
|
|
|
|
| 1776 |
|
| 1777 |
``` cpp
|
| 1778 |
exception_ptr current_exception() noexcept;
|
| 1779 |
```
|
| 1780 |
|
|
@@ -1784,43 +2294,49 @@ handled exception, or a null `exception_ptr` object if no exception is
|
|
| 1784 |
being handled. The referenced object shall remain valid at least as long
|
| 1785 |
as there is an `exception_ptr` object that refers to it. If the function
|
| 1786 |
needs to allocate memory and the attempt fails, it returns an
|
| 1787 |
`exception_ptr` object that refers to an instance of `bad_alloc`. It is
|
| 1788 |
unspecified whether the return values of two successive calls to
|
| 1789 |
-
`current_exception` refer to the same exception object.
|
| 1790 |
-
|
| 1791 |
-
|
| 1792 |
-
|
| 1793 |
-
|
| 1794 |
-
|
| 1795 |
-
|
| 1796 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1797 |
|
| 1798 |
``` cpp
|
| 1799 |
[[noreturn]] void rethrow_exception(exception_ptr p);
|
| 1800 |
```
|
| 1801 |
|
| 1802 |
*Requires:* `p` shall not be a null pointer.
|
| 1803 |
|
| 1804 |
-
*Throws:*
|
| 1805 |
|
| 1806 |
``` cpp
|
| 1807 |
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 1808 |
```
|
| 1809 |
|
| 1810 |
*Effects:* Creates an `exception_ptr` object that refers to a copy of
|
| 1811 |
-
`e`, as if
|
| 1812 |
|
| 1813 |
``` cpp
|
| 1814 |
try {
|
| 1815 |
throw e;
|
| 1816 |
} catch(...) {
|
| 1817 |
return current_exception();
|
| 1818 |
}
|
| 1819 |
```
|
| 1820 |
|
| 1821 |
-
This function is provided for convenience and efficiency
|
|
|
|
| 1822 |
|
| 1823 |
### `nested_exception` <a id="except.nested">[[except.nested]]</a>
|
| 1824 |
|
| 1825 |
``` cpp
|
| 1826 |
namespace std {
|
|
@@ -1843,12 +2359,13 @@ namespace std {
|
|
| 1843 |
|
| 1844 |
The class `nested_exception` is designed for use as a mixin through
|
| 1845 |
multiple inheritance. It captures the currently handled exception and
|
| 1846 |
stores it for later use.
|
| 1847 |
|
| 1848 |
-
`nested_exception` has a virtual destructor to make it a
|
| 1849 |
-
class. Its presence can be tested for with
|
|
|
|
| 1850 |
|
| 1851 |
``` cpp
|
| 1852 |
nested_exception() noexcept;
|
| 1853 |
```
|
| 1854 |
|
|
@@ -1872,74 +2389,88 @@ object.
|
|
| 1872 |
|
| 1873 |
``` cpp
|
| 1874 |
template <class T> [[noreturn]] void throw_with_nested(T&& t);
|
| 1875 |
```
|
| 1876 |
|
| 1877 |
-
Let `U` be `
|
| 1878 |
|
| 1879 |
*Requires:* `U` shall be `CopyConstructible`.
|
| 1880 |
|
| 1881 |
-
*Throws:*
|
| 1882 |
-
`
|
| 1883 |
-
|
|
|
|
| 1884 |
`std::forward<T>(t)`, otherwise `std::forward<T>(t)`.
|
| 1885 |
|
| 1886 |
``` cpp
|
| 1887 |
template <class E> void rethrow_if_nested(const E& e);
|
| 1888 |
```
|
| 1889 |
|
| 1890 |
-
*Effects:* If
|
| 1891 |
-
|
| 1892 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1893 |
|
| 1894 |
## Initializer lists <a id="support.initlist">[[support.initlist]]</a>
|
| 1895 |
|
| 1896 |
The header `<initializer_list>` defines a class template and several
|
| 1897 |
support functions related to list-initialization (see
|
| 1898 |
-
[[dcl.init.list]]).
|
|
|
|
|
|
|
|
|
|
| 1899 |
|
| 1900 |
``` cpp
|
| 1901 |
namespace std {
|
| 1902 |
template<class E> class initializer_list {
|
| 1903 |
public:
|
| 1904 |
-
|
| 1905 |
-
|
| 1906 |
-
|
| 1907 |
-
|
| 1908 |
|
| 1909 |
-
|
| 1910 |
-
|
| 1911 |
|
| 1912 |
constexpr initializer_list() noexcept;
|
| 1913 |
|
| 1914 |
constexpr size_t size() const noexcept; // number of elements
|
| 1915 |
constexpr const E* begin() const noexcept; // first element
|
| 1916 |
constexpr const E* end() const noexcept; // one past the last element
|
| 1917 |
};
|
| 1918 |
|
| 1919 |
-
// [support.initlist.range] initializer list range access
|
| 1920 |
template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
|
| 1921 |
template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
| 1922 |
}
|
| 1923 |
```
|
| 1924 |
|
| 1925 |
An object of type `initializer_list<E>` provides access to an array of
|
| 1926 |
-
objects of type `const E`.
|
| 1927 |
-
|
| 1928 |
-
|
| 1929 |
-
|
| 1930 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1931 |
|
| 1932 |
### Initializer list constructors <a id="support.initlist.cons">[[support.initlist.cons]]</a>
|
| 1933 |
|
| 1934 |
``` cpp
|
| 1935 |
constexpr initializer_list() noexcept;
|
| 1936 |
```
|
| 1937 |
|
| 1938 |
-
*Effects:*
|
| 1939 |
|
| 1940 |
-
`size() == 0`
|
| 1941 |
|
| 1942 |
### Initializer list access <a id="support.initlist.access">[[support.initlist.access]]</a>
|
| 1943 |
|
| 1944 |
``` cpp
|
| 1945 |
constexpr const E* begin() const noexcept;
|
|
@@ -1951,11 +2482,11 @@ identical.
|
|
| 1951 |
|
| 1952 |
``` cpp
|
| 1953 |
constexpr const E* end() const noexcept;
|
| 1954 |
```
|
| 1955 |
|
| 1956 |
-
*Returns:* `begin() + size()`
|
| 1957 |
|
| 1958 |
``` cpp
|
| 1959 |
constexpr size_t size() const noexcept;
|
| 1960 |
```
|
| 1961 |
|
|
@@ -1978,122 +2509,210 @@ template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
|
| 1978 |
*Returns:* `il.end()`.
|
| 1979 |
|
| 1980 |
## Other runtime support <a id="support.runtime">[[support.runtime]]</a>
|
| 1981 |
|
| 1982 |
Headers `<csetjmp>` (nonlocal jumps), `<csignal>` (signal handling),
|
| 1983 |
-
`<
|
| 1984 |
-
`
|
| 1985 |
-
|
| 1986 |
-
|
| 1987 |
-
|
| 1988 |
-
|
| 1989 |
-
|
| 1990 |
-
|
| 1991 |
-
|
| 1992 |
-
|
| 1993 |
-
|
| 1994 |
-
|
| 1995 |
-
|
| 1996 |
-
|
| 1997 |
-
|
| 1998 |
-
|
| 1999 |
-
|
| 2000 |
-
|
| 2001 |
-
|
| 2002 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2003 |
|
| 2004 |
The function signature `longjmp(jmp_buf jbuf, int val)` has more
|
| 2005 |
restricted behavior in this International Standard. A `setjmp`/`longjmp`
|
| 2006 |
call pair has undefined behavior if replacing the `setjmp` and `longjmp`
|
| 2007 |
by `catch` and `throw` would invoke any non-trivial destructors for any
|
| 2008 |
automatic objects.
|
| 2009 |
|
| 2010 |
-
ISO C 7.
|
| 2011 |
|
| 2012 |
-
|
| 2013 |
-
[[res.on.data.races]]) provided that nothing modifies the environment.
|
| 2014 |
-
Calls to the POSIX functions `setenv` and `putenv` modify the
|
| 2015 |
-
environment.
|
| 2016 |
|
| 2017 |
-
|
| 2018 |
-
|
| 2019 |
-
|
| 2020 |
-
no library function other than `locale::global()` calls the `setlocale`
|
| 2021 |
-
function.
|
| 2022 |
|
| 2023 |
-
|
| 2024 |
-
|
|
|
|
| 2025 |
|
| 2026 |
-
|
| 2027 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2028 |
|
| 2029 |
A call to the function `signal` synchronizes with any resulting
|
| 2030 |
invocation of the signal handler so installed.
|
| 2031 |
|
| 2032 |
-
|
| 2033 |
-
|
| 2034 |
-
|
| 2035 |
-
|
| 2036 |
-
|
| 2037 |
-
|
| 2038 |
-
A
|
| 2039 |
-
|
| 2040 |
-
|
| 2041 |
-
|
| 2042 |
-
|
| 2043 |
-
|
| 2044 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2045 |
|
| 2046 |
<!-- Link reference definitions -->
|
|
|
|
| 2047 |
[alloc.errors]: #alloc.errors
|
| 2048 |
[atomics]: atomics.md#atomics
|
| 2049 |
[bad.alloc]: #bad.alloc
|
| 2050 |
[bad.cast]: #bad.cast
|
| 2051 |
[bad.exception]: #bad.exception
|
| 2052 |
[bad.typeid]: #bad.typeid
|
| 2053 |
[basic.align]: basic.md#basic.align
|
|
|
|
| 2054 |
[basic.fundamental]: basic.md#basic.fundamental
|
|
|
|
| 2055 |
[basic.start]: basic.md#basic.start
|
|
|
|
| 2056 |
[basic.start.term]: basic.md#basic.start.term
|
| 2057 |
[basic.stc.dynamic]: basic.md#basic.stc.dynamic
|
| 2058 |
[basic.stc.dynamic.allocation]: basic.md#basic.stc.dynamic.allocation
|
| 2059 |
[basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
|
| 2060 |
[basic.stc.dynamic.safety]: basic.md#basic.stc.dynamic.safety
|
| 2061 |
-
[c.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2062 |
[class]: class.md#class
|
| 2063 |
[class.free]: special.md#class.free
|
|
|
|
| 2064 |
[complex]: numerics.md#complex
|
| 2065 |
[constraints]: library.md#constraints
|
| 2066 |
[conv.ptr]: conv.md#conv.ptr
|
|
|
|
| 2067 |
[conv.rank]: conv.md#conv.rank
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2068 |
[cstdint]: #cstdint
|
| 2069 |
[cstdint.syn]: #cstdint.syn
|
|
|
|
| 2070 |
[dcl.init.list]: dcl.md#dcl.init.list
|
| 2071 |
[denorm.style]: #denorm.style
|
| 2072 |
-
[except.ctor]: except.md#except.ctor
|
| 2073 |
[except.handle]: except.md#except.handle
|
| 2074 |
[except.nested]: #except.nested
|
| 2075 |
[except.special]: except.md#except.special
|
| 2076 |
[except.terminate]: except.md#except.terminate
|
| 2077 |
-
[except.
|
| 2078 |
-
[except.unexpected]: except.md#except.unexpected
|
| 2079 |
[exception]: #exception
|
|
|
|
| 2080 |
[exception.terminate]: #exception.terminate
|
| 2081 |
[expr.add]: expr.md#expr.add
|
| 2082 |
[expr.delete]: expr.md#expr.delete
|
| 2083 |
[expr.dynamic.cast]: expr.md#expr.dynamic.cast
|
| 2084 |
[expr.new]: expr.md#expr.new
|
|
|
|
| 2085 |
[expr.sizeof]: expr.md#expr.sizeof
|
| 2086 |
[expr.typeid]: expr.md#expr.typeid
|
|
|
|
| 2087 |
[get.new.handler]: #get.new.handler
|
| 2088 |
[get.terminate]: #get.terminate
|
| 2089 |
-
[
|
|
|
|
| 2090 |
[intro.memory]: intro.md#intro.memory
|
| 2091 |
[intro.multithread]: intro.md#intro.multithread
|
| 2092 |
[language.support]: #language.support
|
| 2093 |
-
[
|
| 2094 |
-
[limits.numeric]: #limits.numeric
|
| 2095 |
[limits.syn]: #limits.syn
|
| 2096 |
[locale.codecvt]: localization.md#locale.codecvt
|
| 2097 |
[memory]: utilities.md#memory
|
| 2098 |
[multibyte.strings]: library.md#multibyte.strings
|
| 2099 |
[new.badlength]: #new.badlength
|
|
@@ -2101,19 +2720,22 @@ than a POF used as a signal handler in a C++program is
|
|
| 2101 |
[new.delete.array]: #new.delete.array
|
| 2102 |
[new.delete.dataraces]: #new.delete.dataraces
|
| 2103 |
[new.delete.placement]: #new.delete.placement
|
| 2104 |
[new.delete.single]: #new.delete.single
|
| 2105 |
[new.handler]: #new.handler
|
|
|
|
| 2106 |
[nullablepointer.requirements]: library.md#nullablepointer.requirements
|
| 2107 |
[numeric.limits]: #numeric.limits
|
| 2108 |
[numeric.limits.members]: #numeric.limits.members
|
| 2109 |
[numeric.special]: #numeric.special
|
| 2110 |
[propagation]: #propagation
|
|
|
|
| 2111 |
[res.on.data.races]: library.md#res.on.data.races
|
| 2112 |
[round.style]: #round.style
|
| 2113 |
[set.new.handler]: #set.new.handler
|
| 2114 |
[set.terminate]: #set.terminate
|
|
|
|
| 2115 |
[string.classes]: strings.md#string.classes
|
| 2116 |
[support.dynamic]: #support.dynamic
|
| 2117 |
[support.exception]: #support.exception
|
| 2118 |
[support.general]: #support.general
|
| 2119 |
[support.initlist]: #support.initlist
|
|
@@ -2122,23 +2744,25 @@ than a POF used as a signal handler in a C++program is
|
|
| 2122 |
[support.initlist.range]: #support.initlist.range
|
| 2123 |
[support.limits]: #support.limits
|
| 2124 |
[support.limits.general]: #support.limits.general
|
| 2125 |
[support.rtti]: #support.rtti
|
| 2126 |
[support.runtime]: #support.runtime
|
|
|
|
| 2127 |
[support.start.term]: #support.start.term
|
| 2128 |
[support.types]: #support.types
|
|
|
|
|
|
|
|
|
|
| 2129 |
[tab:lang.sup.lib.summary]: #tab:lang.sup.lib.summary
|
| 2130 |
-
[tab:support.hdr.cfloat]: #tab:support.hdr.cfloat
|
| 2131 |
-
[tab:support.hdr.climits]: #tab:support.hdr.climits
|
| 2132 |
-
[tab:support.hdr.cstddef]: #tab:support.hdr.cstddef
|
| 2133 |
-
[tab:support.hdr.cstdlib]: #tab:support.hdr.cstdlib
|
| 2134 |
[temp.dep.constexpr]: temp.md#temp.dep.constexpr
|
| 2135 |
[temp.dep.expr]: temp.md#temp.dep.expr
|
|
|
|
| 2136 |
[terminate]: #terminate
|
| 2137 |
[terminate.handler]: #terminate.handler
|
| 2138 |
[type.info]: #type.info
|
| 2139 |
-
[
|
|
|
|
| 2140 |
|
| 2141 |
[^1]: Possible definitions include `0` and `0L`, but not `(void*)0`.
|
| 2142 |
|
| 2143 |
[^2]: Note that `offsetof` is required to work as specified even if
|
| 2144 |
unary `operator&` is overloaded for any of the types involved.
|
|
@@ -2159,13 +2783,12 @@ than a POF used as a signal handler in a C++program is
|
|
| 2159 |
|
| 2160 |
[^9]: Distinguishes types with bases other than 2 (e.g. BCD).
|
| 2161 |
|
| 2162 |
[^10]: Equivalent to `FLT_EPSILON`, `DBL_EPSILON`, `LDBL_EPSILON`.
|
| 2163 |
|
| 2164 |
-
[^11]: Rounding error is described in
|
| 2165 |
-
|
| 2166 |
-
Section A.5.2.8 - Rounding constants.
|
| 2167 |
|
| 2168 |
[^12]: Equivalent to `FLT_MIN_EXP`, `DBL_MIN_EXP`, `LDBL_MIN_EXP`.
|
| 2169 |
|
| 2170 |
[^13]: Equivalent to `FLT_MIN_10_EXP`, `DBL_MIN_10_EXP`,
|
| 2171 |
`LDBL_MIN_10_EXP`.
|
|
@@ -2179,55 +2802,50 @@ than a POF used as a signal handler in a C++program is
|
|
| 2179 |
|
| 2180 |
[^17]: Required by LIA-1.
|
| 2181 |
|
| 2182 |
[^18]: Required by LIA-1.
|
| 2183 |
|
| 2184 |
-
[^19]: See IEC
|
| 2185 |
|
| 2186 |
[^20]: Required by LIA-1.
|
| 2187 |
|
| 2188 |
[^21]: Required by LIA-1.
|
| 2189 |
|
| 2190 |
[^22]: Required by LIA-1.
|
| 2191 |
|
| 2192 |
[^23]: Required by LIA-1.
|
| 2193 |
|
| 2194 |
-
[^24]:
|
| 2195 |
-
same as IEEE 754.
|
| 2196 |
|
| 2197 |
[^25]: Required by LIA-1.
|
| 2198 |
|
| 2199 |
[^26]: Required by LIA-1.
|
| 2200 |
|
| 2201 |
[^27]: Required by LIA-1.
|
| 2202 |
|
| 2203 |
-
[^28]: Refer to IEC
|
| 2204 |
|
| 2205 |
[^29]: Equivalent to `FLT_ROUNDS`. Required by LIA-1.
|
| 2206 |
|
| 2207 |
[^30]: A function is called for every time it is registered.
|
| 2208 |
|
| 2209 |
[^31]: Objects with automatic storage duration are all destroyed in a
|
| 2210 |
-
program whose
|
| 2211 |
-
executes the call to `exit()`. Control can be
|
| 2212 |
-
to such a `main
|
| 2213 |
-
`main
|
| 2214 |
|
| 2215 |
[^32]: The macros `EXIT_FAILURE` and `EXIT_SUCCESS` are defined in
|
| 2216 |
`<cstdlib>`.
|
| 2217 |
|
| 2218 |
-
[^33]: It is not the direct responsibility of
|
| 2219 |
-
`operator
|
| 2220 |
-
the
|
| 2221 |
-
|
| 2222 |
-
|
| 2223 |
-
|
| 2224 |
-
supplemental information.
|
| 2225 |
|
| 2226 |
[^34]: Note that `va_start` is required to work as specified even if
|
| 2227 |
unary `operator&` is overloaded for the type of `parmN`.
|
| 2228 |
|
| 2229 |
-
[^35]:
|
| 2230 |
-
|
| 2231 |
-
destruction of objects, including those of the standard library
|
| 2232 |
-
implementation, which, in general, yields undefined behavior in a
|
| 2233 |
-
signal handler (see [[intro.execution]]).
|
|
|
|
| 17 |
|
| 18 |
**Table: Language support library summary** <a id="tab:lang.sup.lib.summary">[tab:lang.sup.lib.summary]</a>
|
| 19 |
|
| 20 |
| Subclause | | Header |
|
| 21 |
| ---------------------- | ------------------------- | -------------------- |
|
| 22 |
+
| [[support.types]] | Common definitions | `<cstddef>` |
|
| 23 |
+
| | | `<cstdlib>` |
|
| 24 |
+
| [[support.limits]] | Implementation properties | `<limits>` |
|
| 25 |
+
| | | `<climits>` |
|
| 26 |
| | | `<cfloat>` |
|
| 27 |
| [[cstdint]] | Integer types | `<cstdint>` |
|
| 28 |
| [[support.start.term]] | Start and termination | `<cstdlib>` |
|
| 29 |
| [[support.dynamic]] | Dynamic memory management | `<new>` |
|
| 30 |
| [[support.rtti]] | Type identification | `<typeinfo>` |
|
| 31 |
| [[support.exception]] | Exception handling | `<exception>` |
|
| 32 |
| [[support.initlist]] | Initializer lists | `<initializer_list>` |
|
| 33 |
+
| [[support.runtime]] | Other runtime support | `<csignal>` |
|
| 34 |
| | | `<csetjmp>` |
|
| 35 |
+
| | | `<cstdarg>` |
|
|
|
|
|
|
|
| 36 |
| | | `<cstdlib>` |
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
+
## Common definitions <a id="support.types">[[support.types]]</a>
|
| 40 |
|
| 41 |
+
### Header `<cstddef>` synopsis <a id="cstddef.syn">[[cstddef.syn]]</a>
|
| 42 |
|
| 43 |
+
``` cpp
|
| 44 |
+
namespace std {
|
| 45 |
+
using ptrdiff_t = see below;
|
| 46 |
+
using size_t = see below;
|
| 47 |
+
using max_align_t = see below;
|
| 48 |
+
using nullptr_t = decltype(nullptr);
|
| 49 |
|
| 50 |
+
enum class byte : unsigned char {};
|
|
|
|
| 51 |
|
| 52 |
+
// [support.types.byteops], byte type operations
|
| 53 |
+
template <class IntType>
|
| 54 |
+
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
|
| 55 |
+
template <class IntType>
|
| 56 |
+
constexpr byte operator<<(byte b, IntType shift) noexcept;
|
| 57 |
+
template <class IntType>
|
| 58 |
+
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
|
| 59 |
+
template <class IntType>
|
| 60 |
+
constexpr byte operator>>(byte b, IntType shift) noexcept;
|
| 61 |
+
constexpr byte& operator|=(byte& l, byte r) noexcept;
|
| 62 |
+
constexpr byte operator|(byte l, byte r) noexcept;
|
| 63 |
+
constexpr byte& operator&=(byte& l, byte r) noexcept;
|
| 64 |
+
constexpr byte operator&(byte l, byte r) noexcept;
|
| 65 |
+
constexpr byte& operator^=(byte& l, byte r) noexcept;
|
| 66 |
+
constexpr byte operator^(byte l, byte r) noexcept;
|
| 67 |
+
constexpr byte operator~(byte b) noexcept;
|
| 68 |
+
template <class IntType>
|
| 69 |
+
constexpr IntType to_integer(byte b) noexcept;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
#define NULL see below
|
| 73 |
+
#define offsetof(P, D) see below
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
The contents and meaning of the header `<cstddef>` are the same as the C
|
| 77 |
+
standard library header `<stddef.h>`, except that it does not declare
|
| 78 |
+
the type `wchar_t`, that it also declares the type `byte` and its
|
| 79 |
+
associated operations ([[support.types.byteops]]), and as noted in
|
| 80 |
+
[[support.types.nullptr]] and [[support.types.layout]].
|
| 81 |
+
|
| 82 |
+
ISO C 7.19
|
| 83 |
+
|
| 84 |
+
### Header `<cstdlib>` synopsis <a id="cstdlib.syn">[[cstdlib.syn]]</a>
|
| 85 |
+
|
| 86 |
+
``` cpp
|
| 87 |
+
namespace std {
|
| 88 |
+
using size_t = see below;
|
| 89 |
+
using div_t = see below;
|
| 90 |
+
using ldiv_t = see below;
|
| 91 |
+
using lldiv_t = see below;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
#define NULL see below
|
| 95 |
+
#define EXIT_FAILURE see below
|
| 96 |
+
#define EXIT_SUCCESS see below
|
| 97 |
+
#define RAND_MAX see below
|
| 98 |
+
#define MB_CUR_MAX see below
|
| 99 |
+
|
| 100 |
+
namespace std {
|
| 101 |
+
// Exposition-only function type aliases
|
| 102 |
+
extern "C" using c-atexit-handler = void(); // exposition only
|
| 103 |
+
extern "C++" using atexit-handler = void(); // exposition only
|
| 104 |
+
extern "C" using c-compare-pred = int(const void*, const void*); // exposition only
|
| 105 |
+
extern "C++" using compare-pred = int(const void*, const void*); // exposition only
|
| 106 |
+
|
| 107 |
+
// [support.start.term], start and termination
|
| 108 |
+
[[noreturn]] void abort() noexcept;
|
| 109 |
+
int atexit(c-atexit-handler* func) noexcept;
|
| 110 |
+
int atexit(atexit-handler* func) noexcept;
|
| 111 |
+
int at_quick_exit(c-atexit-handler* func) noexcept;
|
| 112 |
+
int at_quick_exit(atexit-handler* func) noexcept;
|
| 113 |
+
[[noreturn]] void exit(int status);
|
| 114 |
+
[[noreturn]] void _Exit(int status) noexcept;
|
| 115 |
+
[[noreturn]] void quick_exit(int status) noexcept;
|
| 116 |
+
|
| 117 |
+
char* getenv(const char* name);
|
| 118 |
+
int system(const char* string);
|
| 119 |
+
|
| 120 |
+
// [c.malloc], C library memory allocation
|
| 121 |
+
void* aligned_alloc(size_t alignment, size_t size);
|
| 122 |
+
void* calloc(size_t nmemb, size_t size);
|
| 123 |
+
void free(void* ptr);
|
| 124 |
+
void* malloc(size_t size);
|
| 125 |
+
void* realloc(void* ptr, size_t size);
|
| 126 |
+
|
| 127 |
+
double atof(const char* nptr);
|
| 128 |
+
int atoi(const char* nptr);
|
| 129 |
+
long int atol(const char* nptr);
|
| 130 |
+
long long int atoll(const char* nptr);
|
| 131 |
+
double strtod(const char* nptr, char** endptr);
|
| 132 |
+
float strtof(const char* nptr, char** endptr);
|
| 133 |
+
long double strtold(const char* nptr, char** endptr);
|
| 134 |
+
long int strtol(const char* nptr, char** endptr, int base);
|
| 135 |
+
long long int strtoll(const char* nptr, char** endptr, int base);
|
| 136 |
+
unsigned long int strtoul(const char* nptr, char** endptr, int base);
|
| 137 |
+
unsigned long long int strtoull(const char* nptr, char** endptr, int base);
|
| 138 |
+
|
| 139 |
+
// [c.mb.wcs], multibyte / wide string and character conversion functions
|
| 140 |
+
int mblen(const char* s, size_t n);
|
| 141 |
+
int mbtowc(wchar_t* pwc, const char* s, size_t n);
|
| 142 |
+
int wctomb(char* s, wchar_t wchar);
|
| 143 |
+
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
|
| 144 |
+
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
|
| 145 |
+
|
| 146 |
+
// [alg.c.library], C standard library algorithms
|
| 147 |
+
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
| 148 |
+
c-compare-pred* compar);
|
| 149 |
+
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
| 150 |
+
compare-pred* compar);
|
| 151 |
+
void qsort(void* base, size_t nmemb, size_t size, c-compare-pred* compar);
|
| 152 |
+
void qsort(void* base, size_t nmemb, size_t size, compare-pred* compar);
|
| 153 |
+
|
| 154 |
+
// [c.math.rand], low-quality random number generation
|
| 155 |
+
int rand();
|
| 156 |
+
void srand(unsigned int seed);
|
| 157 |
+
|
| 158 |
+
// [c.math.abs], absolute values
|
| 159 |
+
int abs(int j);
|
| 160 |
+
long int abs(long int j);
|
| 161 |
+
long long int abs(long long int j);
|
| 162 |
+
float abs(float j);
|
| 163 |
+
double abs(double j);
|
| 164 |
+
long double abs(long double j);
|
| 165 |
+
|
| 166 |
+
long int labs(long int j);
|
| 167 |
+
long long int llabs(long long int j);
|
| 168 |
+
|
| 169 |
+
div_t div(int numer, int denom);
|
| 170 |
+
ldiv_t div(long int numer, long int denom); // see [library.c]
|
| 171 |
+
lldiv_t div(long long int numer, long long int denom); // see [library.c]
|
| 172 |
+
ldiv_t ldiv(long int numer, long int denom);
|
| 173 |
+
lldiv_t lldiv(long long int numer, long long int denom);
|
| 174 |
+
}
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
The contents and meaning of the header `<cstdlib>` are the same as the C
|
| 178 |
+
standard library header `<stdlib.h>`, except that it does not declare
|
| 179 |
+
the type `wchar_t`, and except as noted in [[support.types.nullptr]],
|
| 180 |
+
[[support.types.layout]], [[support.start.term]], [[c.malloc]],
|
| 181 |
+
[[c.mb.wcs]], [[alg.c.library]], [[c.math.rand]], and [[c.math.abs]].
|
| 182 |
+
|
| 183 |
+
[*Note 1*: Several functions have additional overloads in this
|
| 184 |
+
International Standard, but they have the same behavior as in the C
|
| 185 |
+
standard library ([[library.c]]). — *end note*]
|
| 186 |
+
|
| 187 |
+
ISO C 7.22
|
| 188 |
+
|
| 189 |
+
### Null pointers <a id="support.types.nullptr">[[support.types.nullptr]]</a>
|
| 190 |
+
|
| 191 |
+
The type `nullptr_t` is a synonym for the type of a `nullptr`
|
| 192 |
+
expression, and it has the characteristics described in
|
| 193 |
+
[[basic.fundamental]] and [[conv.ptr]].
|
| 194 |
+
|
| 195 |
+
[*Note 1*: Although `nullptr`’s address cannot be taken, the address of
|
| 196 |
+
another `nullptr_t` object that is an lvalue can be
|
| 197 |
+
taken. — *end note*]
|
| 198 |
+
|
| 199 |
+
The macro `NULL` is an *implementation-defined* null pointer constant.
|
| 200 |
+
[^1]
|
| 201 |
+
|
| 202 |
+
### Sizes, alignments, and offsets <a id="support.types.layout">[[support.types.layout]]</a>
|
| 203 |
+
|
| 204 |
+
The macro `offsetof(type, member-designator)` has the same semantics as
|
| 205 |
+
the corresponding macro in the C standard library header `<stddef.h>`,
|
| 206 |
+
but accepts a restricted set of `type` arguments in this International
|
| 207 |
+
Standard. Use of the `offsetof` macro with a `type` other than a
|
| 208 |
+
standard-layout class (Clause [[class]]) is
|
| 209 |
+
conditionally-supported.[^2] The expression
|
| 210 |
+
`offsetof(type, member-designator)` is never type-dependent (
|
| 211 |
+
[[temp.dep.expr]]) and it is value-dependent ([[temp.dep.constexpr]])
|
| 212 |
+
if and only if `type` is dependent. The result of applying the
|
| 213 |
+
`offsetof` macro to a static data member or a function member is
|
| 214 |
+
undefined. No operation invoked by the `offsetof` macro shall throw an
|
| 215 |
+
exception and `noexcept(offsetof(type, member-designator))` shall be
|
| 216 |
+
`true`.
|
| 217 |
|
| 218 |
The type `ptrdiff_t` is an *implementation-defined* signed integer type
|
| 219 |
that can hold the difference of two subscripts in an array object, as
|
| 220 |
described in [[expr.add]].
|
| 221 |
|
| 222 |
The type `size_t` is an *implementation-defined* unsigned integer type
|
| 223 |
that is large enough to contain the size in bytes of any object.
|
| 224 |
|
| 225 |
+
[*Note 1*: It is recommended that implementations choose types for
|
| 226 |
+
`ptrdiff_t` and `size_t` whose integer conversion ranks ([[conv.rank]])
|
| 227 |
+
are no greater than that of `signed long int` unless a larger size is
|
| 228 |
+
necessary to contain all the possible values. — *end note*]
|
| 229 |
|
| 230 |
The type `max_align_t` is a POD type whose alignment requirement is at
|
| 231 |
least as great as that of every scalar type, and whose alignment
|
| 232 |
requirement is supported in every context.
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
Alignment ([[basic.align]]), Sizeof ([[expr.sizeof]]), Additive
|
| 235 |
+
operators ([[expr.add]]), Free store ([[class.free]]), and ISO C 7.19.
|
| 236 |
+
|
| 237 |
+
### `byte` type operations <a id="support.types.byteops">[[support.types.byteops]]</a>
|
| 238 |
+
|
| 239 |
+
``` cpp
|
| 240 |
+
template <class IntType>
|
| 241 |
+
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
|
| 242 |
+
```
|
| 243 |
+
|
| 244 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 245 |
+
unless `is_integral_v<IntType>` is `true`.
|
| 246 |
+
|
| 247 |
+
*Effects:* Equivalent to:
|
| 248 |
+
`return b = byte(static_cast<unsigned char>(b) << shift);`
|
| 249 |
+
|
| 250 |
+
``` cpp
|
| 251 |
+
template <class IntType>
|
| 252 |
+
constexpr byte operator<<(byte b, IntType shift) noexcept;
|
| 253 |
+
```
|
| 254 |
+
|
| 255 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 256 |
+
unless `is_integral_v<IntType>` is `true`.
|
| 257 |
+
|
| 258 |
+
*Effects:* Equivalent to:
|
| 259 |
+
`return byte(static_cast<unsigned char>(b) << shift);`
|
| 260 |
+
|
| 261 |
+
``` cpp
|
| 262 |
+
template <class IntType>
|
| 263 |
+
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 267 |
+
unless `is_integral_v<IntType>` is `true`.
|
| 268 |
+
|
| 269 |
+
*Effects:* Equivalent to:
|
| 270 |
+
`return b = byte(static_cast<unsigned char>(b) >> shift);`
|
| 271 |
+
|
| 272 |
+
``` cpp
|
| 273 |
+
template <class IntType>
|
| 274 |
+
constexpr byte operator>>(byte b, IntType shift) noexcept;
|
| 275 |
+
```
|
| 276 |
+
|
| 277 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 278 |
+
unless `is_integral_v<IntType>` is `true`.
|
| 279 |
+
|
| 280 |
+
*Effects:* Equivalent to:
|
| 281 |
+
`return byte(static_cast<unsigned char>(b) >> shift);`
|
| 282 |
+
|
| 283 |
+
``` cpp
|
| 284 |
+
constexpr byte& operator|=(byte& l, byte r) noexcept;
|
| 285 |
+
```
|
| 286 |
+
|
| 287 |
+
*Effects:* Equivalent to:
|
| 288 |
+
|
| 289 |
+
``` cpp
|
| 290 |
+
return l = byte(static_cast<unsigned char>(l) | static_cast<unsigned char>(r));
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
``` cpp
|
| 294 |
+
constexpr byte operator|(byte l, byte r) noexcept;
|
| 295 |
+
```
|
| 296 |
+
|
| 297 |
+
*Effects:* Equivalent to:
|
| 298 |
+
|
| 299 |
+
``` cpp
|
| 300 |
+
return byte(static_cast<unsigned char>(l) | static_cast<unsigned char>(r));
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
``` cpp
|
| 304 |
+
constexpr byte& operator&=(byte& l, byte r) noexcept;
|
| 305 |
+
```
|
| 306 |
+
|
| 307 |
+
*Effects:* Equivalent to:
|
| 308 |
+
|
| 309 |
+
``` cpp
|
| 310 |
+
return l = byte(static_cast<unsigned char>(l) & static_cast<unsigned char>(r));
|
| 311 |
+
```
|
| 312 |
+
|
| 313 |
+
``` cpp
|
| 314 |
+
constexpr byte operator&(byte l, byte r) noexcept;
|
| 315 |
+
```
|
| 316 |
+
|
| 317 |
+
*Effects:* Equivalent to:
|
| 318 |
+
|
| 319 |
+
``` cpp
|
| 320 |
+
return byte(static_cast<unsigned char>(l) & static_cast<unsigned char>(r));
|
| 321 |
+
```
|
| 322 |
+
|
| 323 |
+
``` cpp
|
| 324 |
+
constexpr byte& operator^=(byte& l, byte r) noexcept;
|
| 325 |
+
```
|
| 326 |
+
|
| 327 |
+
*Effects:* Equivalent to:
|
| 328 |
+
|
| 329 |
+
``` cpp
|
| 330 |
+
return l = byte(static_cast<unsigned char>(l) ^ static_cast<unsigned char>(r));
|
| 331 |
+
```
|
| 332 |
+
|
| 333 |
+
``` cpp
|
| 334 |
+
constexpr byte operator^(byte l, byte r) noexcept;
|
| 335 |
+
```
|
| 336 |
+
|
| 337 |
+
*Effects:* Equivalent to:
|
| 338 |
+
|
| 339 |
+
``` cpp
|
| 340 |
+
return byte(static_cast<unsigned char>(l) ^ static_cast<unsigned char>(r));
|
| 341 |
+
```
|
| 342 |
+
|
| 343 |
+
``` cpp
|
| 344 |
+
constexpr byte operator~(byte b) noexcept;
|
| 345 |
+
```
|
| 346 |
+
|
| 347 |
+
*Effects:* Equivalent to: `return byte(s̃tatic_cast<unsigned char>(b));`
|
| 348 |
+
|
| 349 |
+
``` cpp
|
| 350 |
+
template <class IntType>
|
| 351 |
+
constexpr IntType to_integer(byte b) noexcept;
|
| 352 |
+
```
|
| 353 |
+
|
| 354 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 355 |
+
unless `is_integral_v<IntType>` is `true`.
|
| 356 |
+
|
| 357 |
+
*Effects:* Equivalent to: `return IntType(b);`
|
| 358 |
|
| 359 |
## Implementation properties <a id="support.limits">[[support.limits]]</a>
|
| 360 |
|
| 361 |
+
### General <a id="support.limits.general">[[support.limits.general]]</a>
|
| 362 |
|
| 363 |
+
The headers `<limits>` ([[limits.syn]]), `<climits>` (
|
| 364 |
+
[[climits.syn]]), and `<cfloat>` ([[cfloat.syn]]) supply
|
| 365 |
+
characteristics of implementation-dependent arithmetic types (
|
| 366 |
+
[[basic.fundamental]]).
|
| 367 |
|
| 368 |
+
### Header `<limits>` synopsis <a id="limits.syn">[[limits.syn]]</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
|
| 370 |
``` cpp
|
| 371 |
namespace std {
|
| 372 |
+
// [fp.style], floating-point type properties
|
| 373 |
enum float_round_style;
|
| 374 |
enum float_denorm_style;
|
| 375 |
|
| 376 |
+
// [numeric.limits], class template numeric_limits
|
| 377 |
+
template<class T> class numeric_limits;
|
| 378 |
+
|
| 379 |
template<> class numeric_limits<bool>;
|
| 380 |
|
| 381 |
template<> class numeric_limits<char>;
|
| 382 |
template<> class numeric_limits<signed char>;
|
| 383 |
template<> class numeric_limits<unsigned char>;
|
|
|
|
| 398 |
template<> class numeric_limits<double>;
|
| 399 |
template<> class numeric_limits<long double>;
|
| 400 |
}
|
| 401 |
```
|
| 402 |
|
| 403 |
+
### Floating-point type properties <a id="fp.style">[[fp.style]]</a>
|
| 404 |
+
|
| 405 |
+
#### Type `float_round_style` <a id="round.style">[[round.style]]</a>
|
| 406 |
+
|
| 407 |
+
``` cpp
|
| 408 |
+
namespace std {
|
| 409 |
+
enum float_round_style {
|
| 410 |
+
round_indeterminate = -1,
|
| 411 |
+
round_toward_zero = 0,
|
| 412 |
+
round_to_nearest = 1,
|
| 413 |
+
round_toward_infinity = 2,
|
| 414 |
+
round_toward_neg_infinity = 3
|
| 415 |
+
};
|
| 416 |
+
}
|
| 417 |
+
```
|
| 418 |
+
|
| 419 |
+
The rounding mode for floating-point arithmetic is characterized by the
|
| 420 |
+
values:
|
| 421 |
+
|
| 422 |
+
- `round_indeterminate` if the rounding style is indeterminable
|
| 423 |
+
- `round_toward_zero` if the rounding style is toward zero
|
| 424 |
+
- `round_to_nearest` if the rounding style is to the nearest
|
| 425 |
+
representable value
|
| 426 |
+
- `round_toward_infinity` if the rounding style is toward infinity
|
| 427 |
+
- `round_toward_neg_infinity` if the rounding style is toward negative
|
| 428 |
+
infinity
|
| 429 |
+
|
| 430 |
+
#### Type `float_denorm_style` <a id="denorm.style">[[denorm.style]]</a>
|
| 431 |
+
|
| 432 |
+
``` cpp
|
| 433 |
+
namespace std {
|
| 434 |
+
enum float_denorm_style {
|
| 435 |
+
denorm_indeterminate = -1,
|
| 436 |
+
denorm_absent = 0,
|
| 437 |
+
denorm_present = 1
|
| 438 |
+
};
|
| 439 |
+
}
|
| 440 |
+
```
|
| 441 |
+
|
| 442 |
+
The presence or absence of subnormal numbers (variable number of
|
| 443 |
+
exponent bits) is characterized by the values:
|
| 444 |
+
|
| 445 |
+
- `denorm_indeterminate` if it cannot be determined whether or not the
|
| 446 |
+
type allows subnormal values
|
| 447 |
+
- `denorm_absent` if the type does not allow subnormal values
|
| 448 |
+
- `denorm_present` if the type does allow subnormal values
|
| 449 |
+
|
| 450 |
+
### Class template `numeric_limits` <a id="numeric.limits">[[numeric.limits]]</a>
|
| 451 |
+
|
| 452 |
+
The `numeric_limits` class template provides a C++program with
|
| 453 |
+
information about various properties of the implementation’s
|
| 454 |
+
representation of the arithmetic types.
|
| 455 |
|
| 456 |
``` cpp
|
| 457 |
namespace std {
|
| 458 |
template<class T> class numeric_limits {
|
| 459 |
public:
|
|
|
|
| 500 |
template<class T> class numeric_limits<volatile T>;
|
| 501 |
template<class T> class numeric_limits<const volatile T>;
|
| 502 |
}
|
| 503 |
```
|
| 504 |
|
| 505 |
+
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 506 |
+
template, specializations shall define these values in such a way that
|
| 507 |
+
they are usable as constant expressions.
|
| 508 |
+
|
| 509 |
The default `numeric_limits<T>` template shall have all members, but
|
| 510 |
with 0 or `false` values.
|
| 511 |
|
| 512 |
+
Specializations shall be provided for each arithmetic type, both
|
| 513 |
+
floating-point and integer, including `bool`. The member
|
| 514 |
+
`is_specialized` shall be `true` for all such specializations of
|
| 515 |
+
`numeric_limits`.
|
| 516 |
+
|
| 517 |
The value of each member of a specialization of `numeric_limits` on a
|
| 518 |
+
cv-qualified type `cv T` shall be equal to the value of the
|
| 519 |
corresponding member of the specialization on the unqualified type `T`.
|
| 520 |
|
| 521 |
+
Non-arithmetic standard types, such as `complex<T>` ([[complex]]),
|
| 522 |
+
shall not have specializations.
|
| 523 |
+
|
| 524 |
#### `numeric_limits` members <a id="numeric.limits.members">[[numeric.limits.members]]</a>
|
| 525 |
|
| 526 |
+
Each member function defined in this subclause is signal-safe (
|
| 527 |
+
[[csignal.syn]]).
|
| 528 |
+
|
| 529 |
``` cpp
|
| 530 |
static constexpr T min() noexcept;
|
| 531 |
```
|
| 532 |
|
| 533 |
Minimum finite value.[^3]
|
| 534 |
|
| 535 |
+
For floating types with subnormal numbers, returns the minimum positive
|
| 536 |
normalized value.
|
| 537 |
|
| 538 |
Meaningful for all specializations in which `is_bounded != false`, or
|
| 539 |
`is_bounded == false && is_signed == false`.
|
| 540 |
|
|
|
|
| 561 |
|
| 562 |
Number of `radix` digits that can be represented without change.
|
| 563 |
|
| 564 |
For integer types, the number of non-sign bits in the representation.
|
| 565 |
|
| 566 |
+
For floating-point types, the number of `radix` digits in the
|
| 567 |
mantissa.[^6]
|
| 568 |
|
| 569 |
``` cpp
|
| 570 |
static constexpr int digits10;
|
| 571 |
```
|
|
|
|
| 579 |
```
|
| 580 |
|
| 581 |
Number of base 10 digits required to ensure that values which differ are
|
| 582 |
always differentiated.
|
| 583 |
|
| 584 |
+
Meaningful for all floating-point types.
|
| 585 |
|
| 586 |
``` cpp
|
| 587 |
static constexpr bool is_signed;
|
| 588 |
```
|
| 589 |
|
| 590 |
+
`true` if the type is signed.
|
| 591 |
|
| 592 |
Meaningful for all specializations.
|
| 593 |
|
| 594 |
``` cpp
|
| 595 |
static constexpr bool is_integer;
|
| 596 |
```
|
| 597 |
|
| 598 |
+
`true` if the type is integer.
|
| 599 |
|
| 600 |
Meaningful for all specializations.
|
| 601 |
|
| 602 |
``` cpp
|
| 603 |
static constexpr bool is_exact;
|
| 604 |
```
|
| 605 |
|
| 606 |
+
`true` if the type uses an exact representation. All integer types are
|
| 607 |
exact, but not all exact types are integer. For example, rational and
|
| 608 |
fixed-exponent representations are exact but not integer.
|
| 609 |
|
| 610 |
Meaningful for all specializations.
|
| 611 |
|
|
|
|
| 625 |
```
|
| 626 |
|
| 627 |
Machine epsilon: the difference between 1 and the least value greater
|
| 628 |
than 1 that is representable.[^10]
|
| 629 |
|
| 630 |
+
Meaningful for all floating-point types.
|
| 631 |
|
| 632 |
``` cpp
|
| 633 |
static constexpr T round_error() noexcept;
|
| 634 |
```
|
| 635 |
|
|
|
|
| 638 |
``` cpp
|
| 639 |
static constexpr int min_exponent;
|
| 640 |
```
|
| 641 |
|
| 642 |
Minimum negative integer such that `radix` raised to the power of one
|
| 643 |
+
less than that integer is a normalized floating-point number.[^12]
|
| 644 |
|
| 645 |
+
Meaningful for all floating-point types.
|
| 646 |
|
| 647 |
``` cpp
|
| 648 |
static constexpr int min_exponent10;
|
| 649 |
```
|
| 650 |
|
| 651 |
Minimum negative integer such that 10 raised to that power is in the
|
| 652 |
+
range of normalized floating-point numbers.[^13]
|
| 653 |
|
| 654 |
+
Meaningful for all floating-point types.
|
| 655 |
|
| 656 |
``` cpp
|
| 657 |
static constexpr int max_exponent;
|
| 658 |
```
|
| 659 |
|
| 660 |
Maximum positive integer such that `radix` raised to the power one less
|
| 661 |
+
than that integer is a representable finite floating-point number.[^14]
|
| 662 |
|
| 663 |
+
Meaningful for all floating-point types.
|
| 664 |
|
| 665 |
``` cpp
|
| 666 |
static constexpr int max_exponent10;
|
| 667 |
```
|
| 668 |
|
| 669 |
Maximum positive integer such that 10 raised to that power is in the
|
| 670 |
+
range of representable finite floating-point numbers.[^15]
|
| 671 |
|
| 672 |
+
Meaningful for all floating-point types.
|
| 673 |
|
| 674 |
``` cpp
|
| 675 |
static constexpr bool has_infinity;
|
| 676 |
```
|
| 677 |
|
| 678 |
+
`true` if the type has a representation for positive infinity.
|
| 679 |
|
| 680 |
+
Meaningful for all floating-point types.
|
| 681 |
|
| 682 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 683 |
|
| 684 |
``` cpp
|
| 685 |
static constexpr bool has_quiet_NaN;
|
| 686 |
```
|
| 687 |
|
| 688 |
+
`true` if the type has a representation for a quiet (non-signaling) “Not
|
| 689 |
+
a Number”.[^16]
|
| 690 |
|
| 691 |
+
Meaningful for all floating-point types.
|
| 692 |
|
| 693 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 694 |
|
| 695 |
``` cpp
|
| 696 |
static constexpr bool has_signaling_NaN;
|
| 697 |
```
|
| 698 |
|
| 699 |
+
`true` if the type has a representation for a signaling “Not a
|
| 700 |
+
Number”.[^17]
|
| 701 |
|
| 702 |
+
Meaningful for all floating-point types.
|
| 703 |
|
| 704 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 705 |
|
| 706 |
``` cpp
|
| 707 |
static constexpr float_denorm_style has_denorm;
|
| 708 |
```
|
| 709 |
|
| 710 |
+
`denorm_present` if the type allows subnormal values (variable number of
|
| 711 |
+
exponent bits)[^18], `denorm_absent` if the type does not allow
|
| 712 |
+
subnormal values, and `denorm_indeterminate` if it is indeterminate at
|
| 713 |
+
compile time whether the type allows subnormal values.
|
| 714 |
|
| 715 |
+
Meaningful for all floating-point types.
|
| 716 |
|
| 717 |
``` cpp
|
| 718 |
static constexpr bool has_denorm_loss;
|
| 719 |
```
|
| 720 |
|
| 721 |
+
`true` if loss of accuracy is detected as a denormalization loss, rather
|
| 722 |
than as an inexact result.[^19]
|
| 723 |
|
| 724 |
``` cpp
|
| 725 |
static constexpr T infinity() noexcept;
|
| 726 |
```
|
|
|
|
| 732 |
|
| 733 |
``` cpp
|
| 734 |
static constexpr T quiet_NaN() noexcept;
|
| 735 |
```
|
| 736 |
|
| 737 |
+
Representation of a quiet “Not a Number”, if available.[^21]
|
| 738 |
|
| 739 |
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 740 |
Required in specializations for which `is_iec559 != false`.
|
| 741 |
|
| 742 |
``` cpp
|
| 743 |
static constexpr T signaling_NaN() noexcept;
|
| 744 |
```
|
| 745 |
|
| 746 |
+
Representation of a signaling “Not a Number”, if available.[^22]
|
| 747 |
|
| 748 |
Meaningful for all specializations for which
|
| 749 |
`has_signaling_NaN != false`. Required in specializations for which
|
| 750 |
`is_iec559 != false`.
|
| 751 |
|
| 752 |
``` cpp
|
| 753 |
static constexpr T denorm_min() noexcept;
|
| 754 |
```
|
| 755 |
|
| 756 |
+
Minimum positive subnormal value.[^23]
|
| 757 |
|
| 758 |
+
Meaningful for all floating-point types.
|
| 759 |
|
| 760 |
In specializations for which `has_denorm == false`, returns the minimum
|
| 761 |
positive normalized value.
|
| 762 |
|
| 763 |
``` cpp
|
| 764 |
static constexpr bool is_iec559;
|
| 765 |
```
|
| 766 |
|
| 767 |
+
`true` if and only if the type adheres to ISO/IEC/IEEE 60559.[^24]
|
| 768 |
|
| 769 |
+
Meaningful for all floating-point types.
|
| 770 |
|
| 771 |
``` cpp
|
| 772 |
static constexpr bool is_bounded;
|
| 773 |
```
|
| 774 |
|
| 775 |
+
`true` if the set of values representable by the type is finite.[^25]
|
| 776 |
+
|
| 777 |
+
[*Note 1*: All fundamental types ([[basic.fundamental]]) are bounded.
|
| 778 |
+
This member would be `false` for arbitrary precision
|
| 779 |
+
types. — *end note*]
|
| 780 |
|
| 781 |
Meaningful for all specializations.
|
| 782 |
|
| 783 |
``` cpp
|
| 784 |
static constexpr bool is_modulo;
|
| 785 |
```
|
| 786 |
|
| 787 |
+
`true` if the type is modulo.[^26] A type is modulo if, for any
|
| 788 |
+
operation involving `+`, `-`, or `*` on values of that type whose result
|
| 789 |
+
would fall outside the range \[`min()`, `max()`\], the value returned
|
| 790 |
+
differs from the true value by an integer multiple of
|
| 791 |
+
`max() - min() + 1`.
|
| 792 |
|
| 793 |
+
[*Example 1*: `is_modulo` is `false` for signed integer
|
| 794 |
+
types ([[basic.fundamental]]) unless an implementation, as an extension
|
| 795 |
+
to this International Standard, defines signed integer overflow to
|
| 796 |
+
wrap. — *end example*]
|
| 797 |
|
| 798 |
Meaningful for all specializations.
|
| 799 |
|
| 800 |
``` cpp
|
| 801 |
static constexpr bool traps;
|
|
|
|
| 810 |
static constexpr bool tinyness_before;
|
| 811 |
```
|
| 812 |
|
| 813 |
`true` if tinyness is detected before rounding.[^28]
|
| 814 |
|
| 815 |
+
Meaningful for all floating-point types.
|
| 816 |
|
| 817 |
``` cpp
|
| 818 |
static constexpr float_round_style round_style;
|
| 819 |
```
|
| 820 |
|
| 821 |
The rounding style for the type.[^29]
|
| 822 |
|
| 823 |
+
Meaningful for all floating-point types. Specializations for integer
|
| 824 |
types shall return `round_toward_zero`.
|
| 825 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 826 |
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
| 827 |
|
| 828 |
All members shall be provided for all specializations. However, many
|
| 829 |
values are only required to be meaningful under certain conditions (for
|
| 830 |
example, `epsilon()` is only meaningful if `is_integer` is `false`). Any
|
| 831 |
value that is not “meaningful” shall be set to 0 or `false`.
|
| 832 |
|
| 833 |
+
[*Example 1*:
|
| 834 |
+
|
| 835 |
``` cpp
|
| 836 |
namespace std {
|
| 837 |
template<> class numeric_limits<float> {
|
| 838 |
public:
|
| 839 |
static constexpr bool is_specialized = true;
|
| 840 |
|
| 841 |
+
static constexpr float min() noexcept { return 1.17549435E-38F; }
|
| 842 |
+
static constexpr float max() noexcept { return 3.40282347E+38F; }
|
| 843 |
+
static constexpr float lowest() noexcept { return -3.40282347E+38F; }
|
| 844 |
|
| 845 |
static constexpr int digits = 24;
|
| 846 |
static constexpr int digits10 = 6;
|
| 847 |
static constexpr int max_digits10 = 9;
|
| 848 |
|
| 849 |
static constexpr bool is_signed = true;
|
| 850 |
static constexpr bool is_integer = false;
|
| 851 |
static constexpr bool is_exact = false;
|
| 852 |
|
| 853 |
static constexpr int radix = 2;
|
| 854 |
+
static constexpr float epsilon() noexcept { return 1.19209290E-07F; }
|
| 855 |
+
static constexpr float round_error() noexcept { return 0.5F; }
|
| 856 |
|
| 857 |
static constexpr int min_exponent = -125;
|
| 858 |
static constexpr int min_exponent10 = - 37;
|
| 859 |
static constexpr int max_exponent = +128;
|
| 860 |
static constexpr int max_exponent10 = + 38;
|
|
|
|
| 863 |
static constexpr bool has_quiet_NaN = true;
|
| 864 |
static constexpr bool has_signaling_NaN = true;
|
| 865 |
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 866 |
static constexpr bool has_denorm_loss = false;
|
| 867 |
|
| 868 |
+
static constexpr float infinity() noexcept { return value; }
|
| 869 |
+
static constexpr float quiet_NaN() noexcept { return value; }
|
| 870 |
+
static constexpr float signaling_NaN() noexcept { return value; }
|
| 871 |
+
static constexpr float denorm_min() noexcept { return min(); }
|
| 872 |
|
| 873 |
static constexpr bool is_iec559 = true;
|
| 874 |
static constexpr bool is_bounded = true;
|
| 875 |
static constexpr bool is_modulo = false;
|
| 876 |
static constexpr bool traps = true;
|
|
|
|
| 879 |
static constexpr float_round_style round_style = round_to_nearest;
|
| 880 |
};
|
| 881 |
}
|
| 882 |
```
|
| 883 |
|
| 884 |
+
— *end example*]
|
| 885 |
+
|
| 886 |
The specialization for `bool` shall be provided as follows:
|
| 887 |
|
| 888 |
``` cpp
|
| 889 |
namespace std {
|
| 890 |
template<> class numeric_limits<bool> {
|
|
|
|
| 929 |
static constexpr float_round_style round_style = round_toward_zero;
|
| 930 |
};
|
| 931 |
}
|
| 932 |
```
|
| 933 |
|
| 934 |
+
### Header `<climits>` synopsis <a id="climits.syn">[[climits.syn]]</a>
|
| 935 |
|
| 936 |
+
``` cpp
|
| 937 |
+
#define CHAR_BIT see below
|
| 938 |
+
#define SCHAR_MIN see below
|
| 939 |
+
#define SCHAR_MAX see below
|
| 940 |
+
#define UCHAR_MAX see below
|
| 941 |
+
#define CHAR_MIN see below
|
| 942 |
+
#define CHAR_MAX see below
|
| 943 |
+
#define MB_LEN_MAX see below
|
| 944 |
+
#define SHRT_MIN see below
|
| 945 |
+
#define SHRT_MAX see below
|
| 946 |
+
#define USHRT_MAX see below
|
| 947 |
+
#define INT_MIN see below
|
| 948 |
+
#define INT_MAX see below
|
| 949 |
+
#define UINT_MAX see below
|
| 950 |
+
#define LONG_MIN see below
|
| 951 |
+
#define LONG_MAX see below
|
| 952 |
+
#define ULONG_MAX see below
|
| 953 |
+
#define LLONG_MIN see below
|
| 954 |
+
#define LLONG_MAX see below
|
| 955 |
+
#define ULLONG_MAX see below
|
| 956 |
+
```
|
| 957 |
|
| 958 |
+
The header `<climits>` defines all macros the same as the C standard
|
| 959 |
+
library header `<limits.h>`.
|
|
|
|
| 960 |
|
| 961 |
+
[*Note 1*: The types of the constants defined by macros in `<climits>`
|
| 962 |
+
are not required to match the types to which the macros
|
| 963 |
+
refer. — *end note*]
|
| 964 |
|
| 965 |
+
ISO C 5.2.4.2.1
|
| 966 |
|
| 967 |
+
### Header `<cfloat>` synopsis <a id="cfloat.syn">[[cfloat.syn]]</a>
|
| 968 |
+
|
| 969 |
+
``` cpp
|
| 970 |
+
#define FLT_ROUNDS see below
|
| 971 |
+
#define FLT_EVAL_METHOD see below
|
| 972 |
+
#define FLT_HAS_SUBNORM see below
|
| 973 |
+
#define DBL_HAS_SUBNORM see below
|
| 974 |
+
#define LDBL_HAS_SUBNORM see below
|
| 975 |
+
#define FLT_RADIX see below
|
| 976 |
+
#define FLT_MANT_DIG see below
|
| 977 |
+
#define DBL_MANT_DIG see below
|
| 978 |
+
#define LDBL_MANT_DIG see below
|
| 979 |
+
#define FLT_DECIMAL_DIG see below
|
| 980 |
+
#define DBL_DECIMAL_DIG see below
|
| 981 |
+
#define LDBL_DECIMAL_DIG see below
|
| 982 |
+
#define DECIMAL_DIG see below
|
| 983 |
+
#define FLT_DIG see below
|
| 984 |
+
#define DBL_DIG see below
|
| 985 |
+
#define LDBL_DIG see below
|
| 986 |
+
#define FLT_MIN_EXP see below
|
| 987 |
+
#define DBL_MIN_EXP see below
|
| 988 |
+
#define LDBL_MIN_EXP see below
|
| 989 |
+
#define FLT_MIN_10_EXP see below
|
| 990 |
+
#define DBL_MIN_10_EXP see below
|
| 991 |
+
#define LDBL_MIN_10_EXP see below
|
| 992 |
+
#define FLT_MAX_EXP see below
|
| 993 |
+
#define DBL_MAX_EXP see below
|
| 994 |
+
#define LDBL_MAX_EXP see below
|
| 995 |
+
#define FLT_MAX_10_EXP see below
|
| 996 |
+
#define DBL_MAX_10_EXP see below
|
| 997 |
+
#define LDBL_MAX_10_EXP see below
|
| 998 |
+
#define FLT_MAX see below
|
| 999 |
+
#define DBL_MAX see below
|
| 1000 |
+
#define LDBL_MAX see below
|
| 1001 |
+
#define FLT_EPSILON see below
|
| 1002 |
+
#define DBL_EPSILON see below
|
| 1003 |
+
#define LDBL_EPSILON see below
|
| 1004 |
+
#define FLT_MIN see below
|
| 1005 |
+
#define DBL_MIN see below
|
| 1006 |
+
#define LDBL_MIN see below
|
| 1007 |
+
#define FLT_TRUE_MIN see below
|
| 1008 |
+
#define DBL_TRUE_MIN see below
|
| 1009 |
+
#define LDBL_TRUE_MIN see below
|
| 1010 |
+
```
|
| 1011 |
+
|
| 1012 |
+
The header `<cfloat>` defines all macros the same as the C standard
|
| 1013 |
+
library header `<float.h>`.
|
| 1014 |
+
|
| 1015 |
+
ISO C 5.2.4.2.2
|
| 1016 |
|
| 1017 |
## Integer types <a id="cstdint">[[cstdint]]</a>
|
| 1018 |
|
| 1019 |
### Header `<cstdint>` synopsis <a id="cstdint.syn">[[cstdint.syn]]</a>
|
| 1020 |
|
| 1021 |
``` cpp
|
| 1022 |
namespace std {
|
| 1023 |
+
using int8_t = signed integer type; // optional
|
| 1024 |
+
using int16_t = signed integer type; // optional
|
| 1025 |
+
using int32_t = signed integer type; // optional
|
| 1026 |
+
using int64_t = signed integer type; // optional
|
| 1027 |
|
| 1028 |
+
using int_fast8_t = signed integer type;
|
| 1029 |
+
using int_fast16_t = signed integer type;
|
| 1030 |
+
using int_fast32_t = signed integer type;
|
| 1031 |
+
using int_fast64_t = signed integer type;
|
| 1032 |
|
| 1033 |
+
using int_least8_t = signed integer type;
|
| 1034 |
+
using int_least16_t = signed integer type;
|
| 1035 |
+
using int_least32_t = signed integer type;
|
| 1036 |
+
using int_least64_t = signed integer type;
|
| 1037 |
|
| 1038 |
+
using intmax_t = signed integer type;
|
| 1039 |
+
using intptr_t = signed integer type; // optional
|
| 1040 |
|
| 1041 |
+
using uint8_t = unsigned integer type; // optional
|
| 1042 |
+
using uint16_t = unsigned integer type; // optional
|
| 1043 |
+
using uint32_t = unsigned integer type; // optional
|
| 1044 |
+
using uint64_t = unsigned integer type; // optional
|
| 1045 |
|
| 1046 |
+
using uint_fast8_t = unsigned integer type;
|
| 1047 |
+
using uint_fast16_t = unsigned integer type;
|
| 1048 |
+
using uint_fast32_t = unsigned integer type;
|
| 1049 |
+
using uint_fast64_t = unsigned integer type;
|
| 1050 |
|
| 1051 |
+
using uint_least8_t = unsigned integer type;
|
| 1052 |
+
using uint_least16_t = unsigned integer type;
|
| 1053 |
+
using uint_least32_t = unsigned integer type;
|
| 1054 |
+
using uint_least64_t = unsigned integer type;
|
| 1055 |
|
| 1056 |
+
using uintmax_t = unsigned integer type;
|
| 1057 |
+
using uintptr_t = unsigned integer type; // optional
|
| 1058 |
+
}
|
| 1059 |
```
|
| 1060 |
|
| 1061 |
The header also defines numerous macros of the form:
|
| 1062 |
|
| 1063 |
``` cpp
|
|
|
|
| 1073 |
|
| 1074 |
``` cpp
|
| 1075 |
[U]INT{8 16 32 64 MAX}_C
|
| 1076 |
```
|
| 1077 |
|
| 1078 |
+
The header defines all types and macros the same as the C standard
|
| 1079 |
+
library header `<stdint.h>`.
|
| 1080 |
+
|
| 1081 |
+
ISO C 7.20.
|
|
|
|
| 1082 |
|
| 1083 |
## Start and termination <a id="support.start.term">[[support.start.term]]</a>
|
| 1084 |
|
| 1085 |
+
[*Note 1*: The header `<cstdlib>` ([[cstdlib.syn]]) declares the
|
| 1086 |
+
functions described in this subclause. — *end note*]
|
|
|
|
|
|
|
|
|
|
| 1087 |
|
| 1088 |
``` cpp
|
| 1089 |
[[noreturn]] void _Exit(int status) noexcept;
|
| 1090 |
```
|
| 1091 |
|
| 1092 |
+
*Effects:* This function has the semantics specified in the C standard
|
| 1093 |
+
library.
|
| 1094 |
|
| 1095 |
+
*Remarks:* The program is terminated without executing destructors for
|
| 1096 |
+
objects of automatic, thread, or static storage duration and without
|
| 1097 |
+
calling functions passed to `atexit()` ([[basic.start.term]]). The
|
| 1098 |
+
function `_Exit` is signal-safe ([[csignal.syn]]).
|
| 1099 |
|
| 1100 |
``` cpp
|
| 1101 |
+
[[noreturn]] void abort() noexcept;
|
| 1102 |
```
|
| 1103 |
|
| 1104 |
+
*Effects:* This function has the semantics specified in the C standard
|
| 1105 |
+
library.
|
| 1106 |
|
| 1107 |
+
*Remarks:* The program is terminated without executing destructors for
|
| 1108 |
+
objects of automatic, thread, or static storage duration and without
|
| 1109 |
+
calling functions passed to `atexit()` ([[basic.start.term]]). The
|
| 1110 |
+
function `abort` is signal-safe ([[csignal.syn]]).
|
| 1111 |
|
| 1112 |
``` cpp
|
| 1113 |
+
int atexit(c-atexit-handler* f) noexcept;
|
| 1114 |
+
int atexit(atexit-handler* f) noexcept;
|
| 1115 |
```
|
| 1116 |
|
| 1117 |
*Effects:* The `atexit()` functions register the function pointed to by
|
| 1118 |
`f` to be called without arguments at normal program termination. It is
|
| 1119 |
unspecified whether a call to `atexit()` that does not happen
|
| 1120 |
+
before ([[intro.multithread]]) a call to `exit()` will succeed.
|
| 1121 |
+
|
| 1122 |
+
[*Note 1*: The `atexit()` functions do not introduce a data
|
| 1123 |
+
race ([[res.on.data.races]]). — *end note*]
|
| 1124 |
|
| 1125 |
*Implementation limits:* The implementation shall support the
|
| 1126 |
registration of at least 32 functions.
|
| 1127 |
|
| 1128 |
*Returns:* The `atexit()` function returns zero if the registration
|
| 1129 |
+
succeeds, nonzero if it fails.
|
| 1130 |
|
| 1131 |
``` cpp
|
| 1132 |
+
[[noreturn]] void exit(int status);
|
| 1133 |
```
|
| 1134 |
|
| 1135 |
+
*Effects:*
|
|
|
|
| 1136 |
|
| 1137 |
- First, objects with thread storage duration and associated with the
|
| 1138 |
current thread are destroyed. Next, objects with static storage
|
| 1139 |
duration are destroyed and functions registered by calling `atexit`
|
| 1140 |
are called.[^30] See [[basic.start.term]] for the order of
|
|
|
|
| 1153 |
an *implementation-defined* form of the status *unsuccessful
|
| 1154 |
termination* is returned. Otherwise the status returned is
|
| 1155 |
*implementation-defined*.[^32]
|
| 1156 |
|
| 1157 |
``` cpp
|
| 1158 |
+
int at_quick_exit(c-atexit-handler* f) noexcept;
|
| 1159 |
+
int at_quick_exit(atexit-handler* f) noexcept;
|
| 1160 |
```
|
| 1161 |
|
| 1162 |
*Effects:* The `at_quick_exit()` functions register the function pointed
|
| 1163 |
to by `f` to be called without arguments when `quick_exit` is called. It
|
| 1164 |
is unspecified whether a call to `at_quick_exit()` that does not happen
|
| 1165 |
before ([[intro.multithread]]) all calls to `quick_exit` will succeed.
|
| 1166 |
+
|
| 1167 |
+
[*Note 2*: The `at_quick_exit()` functions do not introduce a data
|
| 1168 |
+
race ([[res.on.data.races]]). — *end note*]
|
| 1169 |
+
|
| 1170 |
+
[*Note 3*: The order of registration may be indeterminate if
|
| 1171 |
+
`at_quick_exit` was called from more than one thread. — *end note*]
|
| 1172 |
+
|
| 1173 |
+
[*Note 4*: The `at_quick_exit` registrations are distinct from the
|
| 1174 |
+
`atexit` registrations, and applications may need to call both
|
| 1175 |
+
registration functions with the same argument. — *end note*]
|
| 1176 |
|
| 1177 |
*Implementation limits:* The implementation shall support the
|
| 1178 |
registration of at least 32 functions.
|
| 1179 |
|
| 1180 |
+
*Returns:* Zero if the registration succeeds, nonzero if it fails.
|
| 1181 |
|
| 1182 |
``` cpp
|
| 1183 |
[[noreturn]] void quick_exit(int status) noexcept;
|
| 1184 |
```
|
| 1185 |
|
|
|
|
| 1190 |
destroyed as a result of calling `quick_exit`. If control leaves a
|
| 1191 |
registered function called by `quick_exit` because the function does not
|
| 1192 |
provide a handler for a thrown exception, `std::terminate()` shall be
|
| 1193 |
called.
|
| 1194 |
|
| 1195 |
+
[*Note 5*: A function registered via `at_quick_exit` is invoked by the
|
| 1196 |
+
thread that calls `quick_exit`, which can be a different thread than the
|
| 1197 |
+
one that registered it, so registered functions should not rely on the
|
| 1198 |
+
identity of objects with thread storage duration. — *end note*]
|
|
|
|
| 1199 |
|
| 1200 |
+
After calling registered functions, `quick_exit` shall call
|
| 1201 |
+
`_Exit(status)`.
|
| 1202 |
+
|
| 1203 |
+
[*Note 6*: The standard file buffers are not flushed. — *end note*]
|
| 1204 |
+
|
| 1205 |
+
*Remarks:* The function `quick_exit` is signal-safe ([[csignal.syn]])
|
| 1206 |
+
when the functions registered with `at_quick_exit` are.
|
| 1207 |
+
|
| 1208 |
+
[[basic.start]], [[basic.start.term]], ISO C 7.22.4.
|
| 1209 |
|
| 1210 |
## Dynamic memory management <a id="support.dynamic">[[support.dynamic]]</a>
|
| 1211 |
|
| 1212 |
The header `<new>` defines several functions that manage the allocation
|
| 1213 |
of dynamic storage in a program. It also defines components for
|
| 1214 |
reporting storage management errors.
|
| 1215 |
|
| 1216 |
+
### Header `<new>` synopsis <a id="new.syn">[[new.syn]]</a>
|
| 1217 |
+
|
| 1218 |
``` cpp
|
| 1219 |
namespace std {
|
| 1220 |
class bad_alloc;
|
| 1221 |
class bad_array_new_length;
|
| 1222 |
+
enum class align_val_t : size_t {};
|
| 1223 |
+
struct nothrow_t { explicit nothrow_t() = default; };
|
| 1224 |
extern const nothrow_t nothrow;
|
| 1225 |
+
using new_handler = void (*)();
|
| 1226 |
new_handler get_new_handler() noexcept;
|
| 1227 |
new_handler set_new_handler(new_handler new_p) noexcept;
|
| 1228 |
+
|
| 1229 |
+
// [ptr.launder], pointer optimization barrier
|
| 1230 |
+
template <class T> constexpr T* launder(T* p) noexcept;
|
| 1231 |
+
|
| 1232 |
+
// [hardware.interference], hardware interference size
|
| 1233 |
+
inline constexpr size_t hardware_destructive_interference_size = implementation-defined{};
|
| 1234 |
+
inline constexpr size_t hardware_constructive_interference_size = implementation-defined{};
|
| 1235 |
}
|
| 1236 |
|
| 1237 |
void* operator new(std::size_t size);
|
| 1238 |
+
void* operator new(std::size_t size, std::align_val_t alignment);
|
| 1239 |
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
| 1240 |
+
void* operator new(std::size_t size, std::align_val_t alignment,
|
| 1241 |
+
const std::nothrow_t&) noexcept;
|
| 1242 |
void operator delete(void* ptr) noexcept;
|
|
|
|
| 1243 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 1244 |
+
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 1245 |
+
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1246 |
+
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 1247 |
+
void operator delete(void* ptr, std::align_val_t alignment,
|
| 1248 |
const std::nothrow_t&) noexcept;
|
| 1249 |
void* operator new[](std::size_t size);
|
| 1250 |
+
void* operator new[](std::size_t size, std::align_val_t alignment);
|
| 1251 |
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
| 1252 |
+
void* operator new[](std::size_t size, std::align_val_t alignment,
|
| 1253 |
+
const std::nothrow_t&) noexcept;
|
| 1254 |
void operator delete[](void* ptr) noexcept;
|
|
|
|
| 1255 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 1256 |
+
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 1257 |
+
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1258 |
+
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 1259 |
+
void operator delete[](void* ptr, std::align_val_t alignment,
|
| 1260 |
const std::nothrow_t&) noexcept;
|
| 1261 |
|
| 1262 |
void* operator new (std::size_t size, void* ptr) noexcept;
|
| 1263 |
void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 1264 |
void operator delete (void* ptr, void*) noexcept;
|
|
|
|
| 1268 |
[[intro.memory]], [[basic.stc.dynamic]], [[expr.new]],
|
| 1269 |
[[expr.delete]], [[class.free]], [[memory]].
|
| 1270 |
|
| 1271 |
### Storage allocation and deallocation <a id="new.delete">[[new.delete]]</a>
|
| 1272 |
|
| 1273 |
+
Except where otherwise specified, the provisions of
|
| 1274 |
+
[[basic.stc.dynamic]] apply to the library versions of `operator new`
|
| 1275 |
and `operator
|
| 1276 |
+
delete`. If the value of an alignment argument passed to any of these
|
| 1277 |
+
functions is not a valid alignment value, the behavior is undefined.
|
| 1278 |
|
| 1279 |
#### Single-object forms <a id="new.delete.single">[[new.delete.single]]</a>
|
| 1280 |
|
| 1281 |
``` cpp
|
| 1282 |
void* operator new(std::size_t size);
|
| 1283 |
+
void* operator new(std::size_t size, std::align_val_t alignment);
|
| 1284 |
```
|
| 1285 |
|
| 1286 |
+
*Effects:* The allocation functions ([[basic.stc.dynamic.allocation]])
|
| 1287 |
called by a *new-expression* ([[expr.new]]) to allocate `size` bytes of
|
| 1288 |
+
storage. The second form is called for a type with new-extended
|
| 1289 |
+
alignment, and allocates storage with the specified alignment. The first
|
| 1290 |
+
form is called otherwise, and allocates storage suitably aligned to
|
| 1291 |
+
represent any object of that size provided the object’s type does not
|
| 1292 |
+
have new-extended alignment.
|
| 1293 |
|
| 1294 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 1295 |
+
function signatures, and thereby displace the default versions defined
|
| 1296 |
+
by the C++standard library.
|
| 1297 |
|
| 1298 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 1299 |
storage ([[basic.stc.dynamic]]), or else throw a `bad_alloc` exception.
|
| 1300 |
+
This requirement is binding on any replacement versions of these
|
| 1301 |
+
functions.
|
| 1302 |
|
| 1303 |
*Default behavior:*
|
| 1304 |
|
| 1305 |
- Executes a loop: Within the loop, the function first attempts to
|
| 1306 |
allocate the requested storage. Whether the attempt involves a call to
|
| 1307 |
+
the C standard library functions `malloc` or `aligned_alloc` is
|
| 1308 |
+
unspecified.
|
| 1309 |
- Returns a pointer to the allocated storage if the attempt is
|
| 1310 |
successful. Otherwise, if the current
|
| 1311 |
`new_handler` ([[get.new.handler]]) is a null pointer value, throws
|
| 1312 |
`bad_alloc`.
|
| 1313 |
- Otherwise, the function calls the current `new_handler`
|
|
|
|
| 1316 |
- The loop terminates when an attempt to allocate the requested storage
|
| 1317 |
is successful or when a called `new_handler` function does not return.
|
| 1318 |
|
| 1319 |
``` cpp
|
| 1320 |
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
| 1321 |
+
void* operator new(std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1322 |
```
|
| 1323 |
|
| 1324 |
+
*Effects:* Same as above, except that these are called by a placement
|
| 1325 |
version of a *new-expression* when a C++program prefers a null pointer
|
| 1326 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 1327 |
|
| 1328 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 1329 |
+
function signatures, and thereby displace the default versions defined
|
| 1330 |
+
by the C++standard library.
|
| 1331 |
|
| 1332 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 1333 |
+
storage ([[basic.stc.dynamic]]), or else return a null pointer. Each of
|
| 1334 |
+
these nothrow versions of `operator new` returns a pointer obtained as
|
| 1335 |
+
if acquired from the (possibly replaced) corresponding non-placement
|
| 1336 |
+
function. This requirement is binding on any replacement versions of
|
| 1337 |
+
these functions.
|
| 1338 |
|
| 1339 |
+
*Default behavior:* Calls `operator new(size)`, or
|
| 1340 |
+
`operator new(size, alignment)`, respectively. If the call returns
|
| 1341 |
normally, returns the result of that call. Otherwise, returns a null
|
| 1342 |
pointer.
|
| 1343 |
|
| 1344 |
+
[*Example 1*:
|
| 1345 |
+
|
| 1346 |
``` cpp
|
| 1347 |
T* p1 = new T; // throws bad_alloc if it fails
|
| 1348 |
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 1349 |
```
|
| 1350 |
|
| 1351 |
+
— *end example*]
|
| 1352 |
+
|
| 1353 |
``` cpp
|
| 1354 |
void operator delete(void* ptr) noexcept;
|
| 1355 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 1356 |
+
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 1357 |
+
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1358 |
```
|
| 1359 |
|
| 1360 |
+
*Effects:* The deallocation
|
| 1361 |
+
functions ([[basic.stc.dynamic.deallocation]]) called by a
|
| 1362 |
*delete-expression* to render the value of `ptr` invalid.
|
| 1363 |
|
| 1364 |
+
*Replaceable:* A C++program may define functions with any of these
|
| 1365 |
+
function signatures, and thereby displace the default versions defined
|
| 1366 |
+
by the C++standard library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1367 |
|
| 1368 |
+
If a function without a `size` parameter is defined, the program should
|
| 1369 |
+
also define the corresponding function with a `size` parameter. If a
|
| 1370 |
+
function with a `size` parameter is defined, the program shall also
|
| 1371 |
+
define the corresponding version without the `size` parameter.
|
| 1372 |
+
|
| 1373 |
+
[*Note 1*: The default behavior below may change in the future, which
|
| 1374 |
+
will require replacing both deallocation functions when replacing the
|
| 1375 |
+
allocation function. — *end note*]
|
| 1376 |
+
|
| 1377 |
+
*Requires:* `ptr` shall be a null pointer or its value shall represent
|
| 1378 |
+
the address of a block of memory allocated by an earlier call to a
|
| 1379 |
+
(possibly replaced) `operator new(std::size_t)` or
|
| 1380 |
+
`operator new(std::size_t, std::align_val_t)` which has not been
|
| 1381 |
+
invalidated by an intervening call to `operator delete`.
|
| 1382 |
|
| 1383 |
*Requires:* If an implementation has strict pointer
|
| 1384 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1385 |
safely-derived pointer.
|
| 1386 |
|
| 1387 |
+
*Requires:* If the `alignment` parameter is not present, `ptr` shall
|
| 1388 |
+
have been returned by an allocation function without an `alignment`
|
| 1389 |
+
parameter. If present, the `alignment` argument shall equal the
|
| 1390 |
+
`alignment` argument passed to the allocation function that returned
|
| 1391 |
+
`ptr`. If present, the `size` argument shall equal the `size` argument
|
| 1392 |
+
passed to the allocation function that returned `ptr`.
|
| 1393 |
|
| 1394 |
+
*Required behavior:* A call to an `operator delete` with a `size`
|
| 1395 |
+
parameter may be changed to a call to the corresponding
|
| 1396 |
+
`operator delete` without a `size` parameter, without affecting memory
|
| 1397 |
+
allocation.
|
| 1398 |
+
|
| 1399 |
+
[*Note 2*: A conforming implementation is for
|
| 1400 |
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 1401 |
+
`operator delete(ptr)`. — *end note*]
|
| 1402 |
|
| 1403 |
+
*Default behavior:* The functions that have a `size` parameter forward
|
| 1404 |
+
their other parameters to the corresponding function without a `size`
|
| 1405 |
+
parameter.
|
| 1406 |
+
|
| 1407 |
+
[*Note 3*: See the note in the above *Replaceable:*
|
| 1408 |
+
paragraph. — *end note*]
|
| 1409 |
|
| 1410 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 1411 |
the storage allocated by the earlier call to `operator new`.
|
| 1412 |
|
| 1413 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 1414 |
reclaimed storage will be allocated by subsequent calls to
|
| 1415 |
+
`operator new` or any of `aligned_alloc`, `calloc`, `malloc`, or
|
| 1416 |
+
`realloc`, declared in `<cstdlib>`.
|
| 1417 |
|
| 1418 |
``` cpp
|
| 1419 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 1420 |
+
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1421 |
```
|
| 1422 |
|
| 1423 |
+
*Effects:* The deallocation
|
| 1424 |
+
functions ([[basic.stc.dynamic.deallocation]]) called by the
|
| 1425 |
implementation to render the value of `ptr` invalid when the constructor
|
| 1426 |
invoked from a nothrow placement version of the *new-expression* throws
|
| 1427 |
an exception.
|
| 1428 |
|
| 1429 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 1430 |
+
function signatures, and thereby displace the default versions defined
|
| 1431 |
+
by the C++standard library.
|
| 1432 |
+
|
| 1433 |
+
*Requires:* `ptr` shall be a null pointer or its value shall represent
|
| 1434 |
+
the address of a block of memory allocated by an earlier call to a
|
| 1435 |
+
(possibly replaced) `operator new(std::size_t)` or
|
| 1436 |
+
`operator new(std::size_t, std::align_val_t)` which has not been
|
| 1437 |
+
invalidated by an intervening call to `operator delete`.
|
|
|
|
| 1438 |
|
| 1439 |
*Requires:* If an implementation has strict pointer
|
| 1440 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1441 |
safely-derived pointer.
|
| 1442 |
|
| 1443 |
+
*Requires:* If the `alignment` parameter is not present, `ptr` shall
|
| 1444 |
+
have been returned by an allocation function without an `alignment`
|
| 1445 |
+
parameter. If present, the `alignment` argument shall equal the
|
| 1446 |
+
`alignment` argument passed to the allocation function that returned
|
| 1447 |
+
`ptr`.
|
| 1448 |
|
| 1449 |
+
*Default behavior:* Calls `operator delete(ptr)`, or
|
| 1450 |
+
`operator delete(ptr, alignment)`, respectively.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1451 |
|
| 1452 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 1453 |
|
| 1454 |
``` cpp
|
| 1455 |
void* operator new[](std::size_t size);
|
| 1456 |
+
void* operator new[](std::size_t size, std::align_val_t alignment);
|
| 1457 |
```
|
| 1458 |
|
| 1459 |
+
*Effects:* The allocation functions ([[basic.stc.dynamic.allocation]])
|
| 1460 |
called by the array form of a *new-expression* ([[expr.new]]) to
|
| 1461 |
+
allocate `size` bytes of storage. The second form is called for a type
|
| 1462 |
+
with new-extended alignment, and allocates storage with the specified
|
| 1463 |
+
alignment. The first form is called otherwise, and allocates storage
|
| 1464 |
+
suitably aligned to represent any array object of that size or smaller,
|
| 1465 |
+
provided the object’s type does not have new-extended alignment. [^33]
|
| 1466 |
|
| 1467 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 1468 |
+
function signatures, and thereby displace the default versions defined
|
| 1469 |
+
by the C++standard library.
|
| 1470 |
|
| 1471 |
+
*Required behavior:* Same as for the corresponding single-object forms.
|
| 1472 |
+
This requirement is binding on any replacement versions of these
|
| 1473 |
+
functions.
|
| 1474 |
|
| 1475 |
+
*Default behavior:* Returns `operator new(size)`, or
|
| 1476 |
+
`operator new(size, alignment)`, respectively.
|
| 1477 |
|
| 1478 |
``` cpp
|
| 1479 |
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
| 1480 |
+
void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1481 |
```
|
| 1482 |
|
| 1483 |
+
*Effects:* Same as above, except that these are called by a placement
|
| 1484 |
version of a *new-expression* when a C++program prefers a null pointer
|
| 1485 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 1486 |
|
| 1487 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 1488 |
+
function signatures, and thereby displace the default versions defined
|
| 1489 |
+
by the C++standard library.
|
| 1490 |
|
| 1491 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 1492 |
+
storage ([[basic.stc.dynamic]]), or else return a null pointer. Each of
|
| 1493 |
+
these nothrow versions of `operator new[]` returns a pointer obtained as
|
| 1494 |
+
if acquired from the (possibly replaced) corresponding non-placement
|
| 1495 |
+
function. This requirement is binding on any replacement versions of
|
| 1496 |
+
these functions.
|
| 1497 |
|
| 1498 |
+
*Default behavior:* Calls `operator new[](size)`, or
|
| 1499 |
+
`operator new[](size, alignment)`, respectively. If the call returns
|
| 1500 |
normally, returns the result of that call. Otherwise, returns a null
|
| 1501 |
pointer.
|
| 1502 |
|
| 1503 |
``` cpp
|
| 1504 |
void operator delete[](void* ptr) noexcept;
|
| 1505 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 1506 |
+
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 1507 |
+
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1508 |
```
|
| 1509 |
|
| 1510 |
+
*Effects:* The deallocation
|
| 1511 |
+
functions ([[basic.stc.dynamic.deallocation]]) called by the array form
|
| 1512 |
of a *delete-expression* to render the value of `ptr` invalid.
|
| 1513 |
|
| 1514 |
+
*Replaceable:* A C++program may define functions with any of these
|
| 1515 |
+
function signatures, and thereby displace the default versions defined
|
| 1516 |
+
by the C++standard library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1517 |
|
| 1518 |
+
If a function without a `size` parameter is defined, the program should
|
| 1519 |
+
also define the corresponding function with a `size` parameter. If a
|
| 1520 |
+
function with a `size` parameter is defined, the program shall also
|
| 1521 |
+
define the corresponding version without the `size` parameter.
|
| 1522 |
|
| 1523 |
+
[*Note 1*: The default behavior below may change in the future, which
|
| 1524 |
+
will require replacing both deallocation functions when replacing the
|
| 1525 |
+
allocation function. — *end note*]
|
| 1526 |
|
| 1527 |
+
*Requires:* `ptr` shall be a null pointer or its value shall represent
|
| 1528 |
+
the address of a block of memory allocated by an earlier call to a
|
| 1529 |
+
(possibly replaced) `operator new[](std::size_t)` or
|
| 1530 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 1531 |
+
invalidated by an intervening call to `operator delete[]`.
|
| 1532 |
+
|
| 1533 |
+
*Requires:* If an implementation has strict pointer
|
| 1534 |
+
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1535 |
+
safely-derived pointer.
|
| 1536 |
+
|
| 1537 |
+
*Requires:* If the `alignment` parameter is not present, `ptr` shall
|
| 1538 |
+
have been returned by an allocation function without an `alignment`
|
| 1539 |
+
parameter. If present, the `alignment` argument shall equal the
|
| 1540 |
+
`alignment` argument passed to the allocation function that returned
|
| 1541 |
+
`ptr`. If present, the `size` argument shall equal the `size` argument
|
| 1542 |
+
passed to the allocation function that returned `ptr`.
|
| 1543 |
+
|
| 1544 |
+
*Required behavior:* A call to an `operator delete[]` with a `size`
|
| 1545 |
+
parameter may be changed to a call to the corresponding
|
| 1546 |
+
`operator delete[]` without a `size` parameter, without affecting memory
|
| 1547 |
+
allocation.
|
| 1548 |
+
|
| 1549 |
+
[*Note 2*: A conforming implementation is for
|
| 1550 |
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 1551 |
+
`operator delete[](ptr)`. — *end note*]
|
| 1552 |
|
| 1553 |
+
*Default behavior:* The functions that have a `size` parameter forward
|
| 1554 |
+
their other parameters to the corresponding function without a `size`
|
| 1555 |
+
parameter. The functions that do not have a `size` parameter forward
|
| 1556 |
+
their parameters to the corresponding `operator delete` (single-object)
|
| 1557 |
+
function.
|
|
|
|
|
|
|
| 1558 |
|
| 1559 |
``` cpp
|
| 1560 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 1561 |
+
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1562 |
```
|
| 1563 |
|
| 1564 |
+
*Effects:* The deallocation
|
| 1565 |
+
functions ([[basic.stc.dynamic.deallocation]]) called by the
|
| 1566 |
implementation to render the value of `ptr` invalid when the constructor
|
| 1567 |
invoked from a nothrow placement version of the array *new-expression*
|
| 1568 |
throws an exception.
|
| 1569 |
|
| 1570 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 1571 |
+
function signatures, and thereby displace the default versions defined
|
| 1572 |
+
by the C++standard library.
|
| 1573 |
+
|
| 1574 |
+
*Requires:* `ptr` shall be a null pointer or its value shall represent
|
| 1575 |
+
the address of a block of memory allocated by an earlier call to a
|
| 1576 |
+
(possibly replaced) `operator new[](std::size_t)` or
|
| 1577 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 1578 |
+
invalidated by an intervening call to `operator delete[]`.
|
|
|
|
| 1579 |
|
| 1580 |
*Requires:* If an implementation has strict pointer
|
| 1581 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1582 |
safely-derived pointer.
|
| 1583 |
|
| 1584 |
+
*Requires:* If the `alignment` parameter is not present, `ptr` shall
|
| 1585 |
+
have been returned by an allocation function without an `alignment`
|
| 1586 |
+
parameter. If present, the `alignment` argument shall equal the
|
| 1587 |
+
`alignment` argument passed to the allocation function that returned
|
| 1588 |
+
`ptr`.
|
| 1589 |
|
| 1590 |
+
*Default behavior:* Calls `operator delete[](ptr)`, or
|
| 1591 |
+
`operator delete[](ptr, alignment)`, respectively.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1592 |
|
| 1593 |
+
#### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1594 |
|
| 1595 |
+
These functions are reserved; a C++program may not define functions that
|
| 1596 |
+
displace the versions in the C++standard library ([[constraints]]). The
|
| 1597 |
+
provisions of [[basic.stc.dynamic]] do not apply to these reserved
|
|
|
|
|
|
|
| 1598 |
placement forms of `operator new` and `operator delete`.
|
| 1599 |
|
| 1600 |
``` cpp
|
| 1601 |
void* operator new(std::size_t size, void* ptr) noexcept;
|
| 1602 |
```
|
| 1603 |
|
| 1604 |
*Returns:* `ptr`.
|
| 1605 |
|
| 1606 |
*Remarks:* Intentionally performs no other action.
|
| 1607 |
|
| 1608 |
+
[*Example 1*:
|
| 1609 |
+
|
| 1610 |
This can be useful for constructing an object at a known address:
|
| 1611 |
|
| 1612 |
``` cpp
|
| 1613 |
void* place = operator new(sizeof(Something));
|
| 1614 |
Something* p = new (place) Something();
|
| 1615 |
```
|
| 1616 |
|
| 1617 |
+
— *end example*]
|
| 1618 |
+
|
| 1619 |
``` cpp
|
| 1620 |
void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 1621 |
```
|
| 1622 |
|
| 1623 |
*Returns:* `ptr`.
|
|
|
|
| 1633 |
*Requires:* If an implementation has strict pointer
|
| 1634 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1635 |
safely-derived pointer.
|
| 1636 |
|
| 1637 |
*Remarks:* Default function called when any part of the initialization
|
| 1638 |
+
in a placement *new-expression* that invokes the library’s non-array
|
| 1639 |
placement operator new terminates by throwing an
|
| 1640 |
exception ([[expr.new]]).
|
| 1641 |
|
| 1642 |
``` cpp
|
| 1643 |
void operator delete[](void* ptr, void*) noexcept;
|
|
|
|
| 1648 |
*Requires:* If an implementation has strict pointer
|
| 1649 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 1650 |
safely-derived pointer.
|
| 1651 |
|
| 1652 |
*Remarks:* Default function called when any part of the initialization
|
| 1653 |
+
in a placement *new-expression* that invokes the library’s array
|
| 1654 |
+
placement operator new terminates by throwing an
|
| 1655 |
+
exception ([[expr.new]]).
|
| 1656 |
|
| 1657 |
#### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
|
| 1658 |
|
| 1659 |
For purposes of determining the existence of data races, the library
|
| 1660 |
versions of `operator new`, user replacement versions of global
|
| 1661 |
+
`operator new`, the C standard library functions `aligned_alloc`,
|
| 1662 |
+
`calloc`, and `malloc`, the library versions of `operator delete`, user
|
| 1663 |
+
replacement versions of `operator delete`, the C standard library
|
| 1664 |
+
function `free`, and the C standard library function `realloc` shall not
|
| 1665 |
+
introduce a data race ([[res.on.data.races]]). Calls to these functions
|
| 1666 |
+
that allocate or deallocate a particular unit of storage shall occur in
|
| 1667 |
+
a single total order, and each such deallocation call shall happen
|
| 1668 |
+
before ([[intro.multithread]]) the next allocation (if any) in this
|
| 1669 |
+
order.
|
| 1670 |
|
| 1671 |
### Storage allocation errors <a id="alloc.errors">[[alloc.errors]]</a>
|
| 1672 |
|
| 1673 |
#### Class `bad_alloc` <a id="bad.alloc">[[bad.alloc]]</a>
|
| 1674 |
|
|
|
|
| 1677 |
class bad_alloc : public exception {
|
| 1678 |
public:
|
| 1679 |
bad_alloc() noexcept;
|
| 1680 |
bad_alloc(const bad_alloc&) noexcept;
|
| 1681 |
bad_alloc& operator=(const bad_alloc&) noexcept;
|
| 1682 |
+
const char* what() const noexcept override;
|
| 1683 |
};
|
| 1684 |
}
|
| 1685 |
```
|
| 1686 |
|
| 1687 |
The class `bad_alloc` defines the type of objects thrown as exceptions
|
|
|
|
| 1691 |
bad_alloc() noexcept;
|
| 1692 |
```
|
| 1693 |
|
| 1694 |
*Effects:* Constructs an object of class `bad_alloc`.
|
| 1695 |
|
|
|
|
|
|
|
|
|
|
| 1696 |
``` cpp
|
| 1697 |
bad_alloc(const bad_alloc&) noexcept;
|
| 1698 |
bad_alloc& operator=(const bad_alloc&) noexcept;
|
| 1699 |
```
|
| 1700 |
|
| 1701 |
*Effects:* Copies an object of class `bad_alloc`.
|
| 1702 |
|
| 1703 |
``` cpp
|
| 1704 |
+
const char* what() const noexcept override;
|
| 1705 |
```
|
| 1706 |
|
| 1707 |
*Returns:* An *implementation-defined* NTBS.
|
| 1708 |
|
| 1709 |
+
*Remarks:* The message may be a null-terminated multibyte
|
| 1710 |
+
string ([[multibyte.strings]]), suitable for conversion and display as
|
| 1711 |
+
a `wstring` ([[string.classes]], [[locale.codecvt]]).
|
| 1712 |
+
|
| 1713 |
#### Class `bad_array_new_length` <a id="new.badlength">[[new.badlength]]</a>
|
| 1714 |
|
| 1715 |
``` cpp
|
| 1716 |
namespace std {
|
| 1717 |
class bad_array_new_length : public bad_alloc {
|
| 1718 |
public:
|
| 1719 |
bad_array_new_length() noexcept;
|
| 1720 |
+
const char* what() const noexcept override;
|
| 1721 |
};
|
| 1722 |
}
|
| 1723 |
```
|
| 1724 |
|
| 1725 |
The class `bad_array_new_length` defines the type of objects thrown as
|
| 1726 |
exceptions by the implementation to report an attempt to allocate an
|
| 1727 |
+
array of size less than zero or greater than an *implementation-defined*
|
| 1728 |
limit ([[expr.new]]).
|
| 1729 |
|
| 1730 |
``` cpp
|
| 1731 |
bad_array_new_length() noexcept;
|
| 1732 |
```
|
| 1733 |
|
| 1734 |
*Effects:* constructs an object of class `bad_array_new_length`.
|
| 1735 |
|
| 1736 |
+
``` cpp
|
| 1737 |
+
const char* what() const noexcept override;
|
| 1738 |
+
```
|
| 1739 |
+
|
| 1740 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 1741 |
+
|
| 1742 |
+
*Remarks:* The message may be a null-terminated multibyte
|
| 1743 |
+
string ([[multibyte.strings]]), suitable for conversion and display as
|
| 1744 |
+
a `wstring` ([[string.classes]], [[locale.codecvt]]).
|
| 1745 |
|
| 1746 |
#### Type `new_handler` <a id="new.handler">[[new.handler]]</a>
|
| 1747 |
|
| 1748 |
``` cpp
|
| 1749 |
+
using new_handler = void (*)();
|
| 1750 |
```
|
| 1751 |
|
| 1752 |
The type of a *handler function* to be called by `operator new()` or
|
| 1753 |
`operator new[]()` ([[new.delete]]) when they cannot satisfy a request
|
| 1754 |
for additional storage.
|
|
|
|
| 1756 |
*Required behavior:* A `new_handler` shall perform one of the following:
|
| 1757 |
|
| 1758 |
- make more storage available for allocation and then return;
|
| 1759 |
- throw an exception of type `bad_alloc` or a class derived from
|
| 1760 |
`bad_alloc`;
|
| 1761 |
+
- terminate execution of the program without returning to the caller.
|
| 1762 |
|
| 1763 |
#### `set_new_handler` <a id="set.new.handler">[[set.new.handler]]</a>
|
| 1764 |
|
| 1765 |
``` cpp
|
| 1766 |
new_handler set_new_handler(new_handler new_p) noexcept;
|
|
|
|
| 1777 |
|
| 1778 |
``` cpp
|
| 1779 |
new_handler get_new_handler() noexcept;
|
| 1780 |
```
|
| 1781 |
|
| 1782 |
+
*Returns:* The current `new_handler`.
|
| 1783 |
+
|
| 1784 |
+
[*Note 1*: This may be a null pointer value. — *end note*]
|
| 1785 |
+
|
| 1786 |
+
### Pointer optimization barrier <a id="ptr.launder">[[ptr.launder]]</a>
|
| 1787 |
+
|
| 1788 |
+
``` cpp
|
| 1789 |
+
template <class T> constexpr T* launder(T* p) noexcept;
|
| 1790 |
+
```
|
| 1791 |
+
|
| 1792 |
+
*Requires:* `p` represents the address *A* of a byte in memory. An
|
| 1793 |
+
object *X* that is within its lifetime ([[basic.life]]) and whose type
|
| 1794 |
+
is similar ([[conv.qual]]) to `T` is located at the address *A*. All
|
| 1795 |
+
bytes of storage that would be reachable through the result are
|
| 1796 |
+
reachable through `p` (see below).
|
| 1797 |
+
|
| 1798 |
+
*Returns:* A value of type `T *` that points to `X`.
|
| 1799 |
+
|
| 1800 |
+
*Remarks:* An invocation of this function may be used in a core constant
|
| 1801 |
+
expression whenever the value of its argument may be used in a core
|
| 1802 |
+
constant expression. A byte of storage is reachable through a pointer
|
| 1803 |
+
value that points to an object *Y* if it is within the storage occupied
|
| 1804 |
+
by *Y*, an object that is pointer-interconvertible with *Y*, or the
|
| 1805 |
+
immediately-enclosing array object if *Y* is an array element. The
|
| 1806 |
+
program is ill-formed if `T` is a function type or cv `void`.
|
| 1807 |
+
|
| 1808 |
+
[*Note 1*: If a new object is created in storage occupied by an
|
| 1809 |
+
existing object of the same type, a pointer to the original object can
|
| 1810 |
+
be used to refer to the new object unless the type contains `const` or
|
| 1811 |
+
reference members; in the latter cases, this function can be used to
|
| 1812 |
+
obtain a usable pointer to the new object.
|
| 1813 |
+
See [[basic.life]]. — *end note*]
|
| 1814 |
+
|
| 1815 |
+
[*Example 1*:
|
| 1816 |
+
|
| 1817 |
+
``` cpp
|
| 1818 |
+
struct X { const int n; };
|
| 1819 |
+
X *p = new X{3};
|
| 1820 |
+
const int a = p->n;
|
| 1821 |
+
new (p) X{5}; // p does not point to new object ([basic.life]) because X::n is const
|
| 1822 |
+
const int b = p->n; // undefined behavior
|
| 1823 |
+
const int c = std::launder(p)->n; // OK
|
| 1824 |
+
```
|
| 1825 |
+
|
| 1826 |
+
— *end example*]
|
| 1827 |
+
|
| 1828 |
+
### Hardware interference size <a id="hardware.interference">[[hardware.interference]]</a>
|
| 1829 |
+
|
| 1830 |
+
``` cpp
|
| 1831 |
+
inline constexpr size_t hardware_destructive_interference_size = implementation-defined{};
|
| 1832 |
+
```
|
| 1833 |
+
|
| 1834 |
+
This number is the minimum recommended offset between two
|
| 1835 |
+
concurrently-accessed objects to avoid additional performance
|
| 1836 |
+
degradation due to contention introduced by the implementation. It shall
|
| 1837 |
+
be at least `alignof(max_align_t)`.
|
| 1838 |
+
|
| 1839 |
+
[*Example 1*:
|
| 1840 |
+
|
| 1841 |
+
``` cpp
|
| 1842 |
+
struct keep_apart {
|
| 1843 |
+
alignas(hardware_destructive_interference_size) atomic<int> cat;
|
| 1844 |
+
alignas(hardware_destructive_interference_size) atomic<int> dog;
|
| 1845 |
+
};
|
| 1846 |
+
```
|
| 1847 |
+
|
| 1848 |
+
— *end example*]
|
| 1849 |
+
|
| 1850 |
+
``` cpp
|
| 1851 |
+
inline constexpr size_t hardware_constructive_interference_size = implementation-defined{};
|
| 1852 |
+
```
|
| 1853 |
+
|
| 1854 |
+
This number is the maximum recommended size of contiguous memory
|
| 1855 |
+
occupied by two objects accessed with temporal locality by concurrent
|
| 1856 |
+
threads. It shall be at least `alignof(max_align_t)`.
|
| 1857 |
+
|
| 1858 |
+
[*Example 2*:
|
| 1859 |
+
|
| 1860 |
+
``` cpp
|
| 1861 |
+
struct together {
|
| 1862 |
+
atomic<int> dog;
|
| 1863 |
+
int puppy;
|
| 1864 |
+
};
|
| 1865 |
+
struct kennel {
|
| 1866 |
+
// Other data members...
|
| 1867 |
+
alignas(sizeof(together)) together pack;
|
| 1868 |
+
// Other data members...
|
| 1869 |
+
};
|
| 1870 |
+
static_assert(sizeof(together) <= hardware_constructive_interference_size);
|
| 1871 |
+
```
|
| 1872 |
+
|
| 1873 |
+
— *end example*]
|
| 1874 |
|
| 1875 |
## Type identification <a id="support.rtti">[[support.rtti]]</a>
|
| 1876 |
|
| 1877 |
The header `<typeinfo>` defines a type associated with type information
|
| 1878 |
generated by the implementation. It also defines two types for reporting
|
| 1879 |
dynamic type identification errors.
|
| 1880 |
|
| 1881 |
+
### Header `<typeinfo>` synopsis <a id="typeinfo.syn">[[typeinfo.syn]]</a>
|
| 1882 |
|
| 1883 |
``` cpp
|
| 1884 |
namespace std {
|
| 1885 |
class type_info;
|
| 1886 |
class bad_cast;
|
|
|
|
| 1944 |
|
| 1945 |
*Returns:* An unspecified value, except that within a single execution
|
| 1946 |
of the program, it shall return the same value for any two `type_info`
|
| 1947 |
objects which compare equal.
|
| 1948 |
|
| 1949 |
+
*Remarks:* An implementation should return different values for two
|
| 1950 |
+
`type_info` objects which do not compare equal.
|
| 1951 |
|
| 1952 |
``` cpp
|
| 1953 |
const char* name() const noexcept;
|
| 1954 |
```
|
| 1955 |
|
|
|
|
| 1966 |
class bad_cast : public exception {
|
| 1967 |
public:
|
| 1968 |
bad_cast() noexcept;
|
| 1969 |
bad_cast(const bad_cast&) noexcept;
|
| 1970 |
bad_cast& operator=(const bad_cast&) noexcept;
|
| 1971 |
+
const char* what() const noexcept override;
|
| 1972 |
};
|
| 1973 |
}
|
| 1974 |
```
|
| 1975 |
|
| 1976 |
The class `bad_cast` defines the type of objects thrown as exceptions by
|
| 1977 |
+
the implementation to report the execution of an invalid `dynamic_cast`
|
| 1978 |
expression ([[expr.dynamic.cast]]).
|
| 1979 |
|
| 1980 |
``` cpp
|
| 1981 |
bad_cast() noexcept;
|
| 1982 |
```
|
| 1983 |
|
| 1984 |
*Effects:* Constructs an object of class `bad_cast`.
|
| 1985 |
|
|
|
|
|
|
|
|
|
|
| 1986 |
``` cpp
|
| 1987 |
bad_cast(const bad_cast&) noexcept;
|
| 1988 |
bad_cast& operator=(const bad_cast&) noexcept;
|
| 1989 |
```
|
| 1990 |
|
| 1991 |
*Effects:* Copies an object of class `bad_cast`.
|
| 1992 |
|
| 1993 |
``` cpp
|
| 1994 |
+
const char* what() const noexcept override;
|
| 1995 |
```
|
| 1996 |
|
| 1997 |
*Returns:* An *implementation-defined* NTBS.
|
| 1998 |
|
| 1999 |
*Remarks:* The message may be a null-terminated multibyte
|
|
|
|
| 2007 |
class bad_typeid : public exception {
|
| 2008 |
public:
|
| 2009 |
bad_typeid() noexcept;
|
| 2010 |
bad_typeid(const bad_typeid&) noexcept;
|
| 2011 |
bad_typeid& operator=(const bad_typeid&) noexcept;
|
| 2012 |
+
const char* what() const noexcept override;
|
| 2013 |
};
|
| 2014 |
}
|
| 2015 |
```
|
| 2016 |
|
| 2017 |
The class `bad_typeid` defines the type of objects thrown as exceptions
|
| 2018 |
+
by the implementation to report a null pointer in a `typeid`
|
| 2019 |
expression ([[expr.typeid]]).
|
| 2020 |
|
| 2021 |
``` cpp
|
| 2022 |
bad_typeid() noexcept;
|
| 2023 |
```
|
| 2024 |
|
| 2025 |
*Effects:* Constructs an object of class `bad_typeid`.
|
| 2026 |
|
|
|
|
|
|
|
|
|
|
| 2027 |
``` cpp
|
| 2028 |
bad_typeid(const bad_typeid&) noexcept;
|
| 2029 |
bad_typeid& operator=(const bad_typeid&) noexcept;
|
| 2030 |
```
|
| 2031 |
|
| 2032 |
*Effects:* Copies an object of class `bad_typeid`.
|
| 2033 |
|
| 2034 |
``` cpp
|
| 2035 |
+
const char* what() const noexcept override;
|
| 2036 |
```
|
| 2037 |
|
| 2038 |
*Returns:* An *implementation-defined* NTBS.
|
| 2039 |
|
| 2040 |
*Remarks:* The message may be a null-terminated multibyte
|
|
|
|
| 2044 |
## Exception handling <a id="support.exception">[[support.exception]]</a>
|
| 2045 |
|
| 2046 |
The header `<exception>` defines several types and functions related to
|
| 2047 |
the handling of exceptions in a C++program.
|
| 2048 |
|
| 2049 |
+
### Header `<exception>` synopsis <a id="exception.syn">[[exception.syn]]</a>
|
| 2050 |
+
|
| 2051 |
``` cpp
|
| 2052 |
namespace std {
|
| 2053 |
class exception;
|
| 2054 |
class bad_exception;
|
| 2055 |
class nested_exception;
|
| 2056 |
|
| 2057 |
+
using terminate_handler = void (*)();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2058 |
terminate_handler get_terminate() noexcept;
|
| 2059 |
terminate_handler set_terminate(terminate_handler f) noexcept;
|
| 2060 |
[[noreturn]] void terminate() noexcept;
|
| 2061 |
|
| 2062 |
+
int uncaught_exceptions() noexcept;
|
| 2063 |
|
| 2064 |
+
using exception_ptr = unspecified;
|
| 2065 |
|
| 2066 |
exception_ptr current_exception() noexcept;
|
| 2067 |
[[noreturn]] void rethrow_exception(exception_ptr p);
|
| 2068 |
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 2069 |
|
|
|
|
| 2111 |
exception& operator=(const exception& rhs) noexcept;
|
| 2112 |
```
|
| 2113 |
|
| 2114 |
*Effects:* Copies an `exception` object.
|
| 2115 |
|
| 2116 |
+
*Postconditions:* If `*this` and `rhs` both have dynamic type
|
| 2117 |
+
`exception` then the value of the expression
|
| 2118 |
`strcmp(what(), rhs.what())` shall equal 0.
|
| 2119 |
|
| 2120 |
``` cpp
|
| 2121 |
virtual ~exception();
|
| 2122 |
```
|
|
|
|
| 2143 |
class bad_exception : public exception {
|
| 2144 |
public:
|
| 2145 |
bad_exception() noexcept;
|
| 2146 |
bad_exception(const bad_exception&) noexcept;
|
| 2147 |
bad_exception& operator=(const bad_exception&) noexcept;
|
| 2148 |
+
const char* what() const noexcept override;
|
| 2149 |
};
|
| 2150 |
}
|
| 2151 |
```
|
| 2152 |
|
| 2153 |
+
The class `bad_exception` defines the type of the object referenced by
|
| 2154 |
+
the `exception_ptr` returned from a call to `current_exception` (
|
| 2155 |
+
[[propagation]]) when the currently active exception object fails to
|
| 2156 |
+
copy.
|
| 2157 |
|
| 2158 |
``` cpp
|
| 2159 |
bad_exception() noexcept;
|
| 2160 |
```
|
| 2161 |
|
| 2162 |
*Effects:* Constructs an object of class `bad_exception`.
|
| 2163 |
|
|
|
|
|
|
|
|
|
|
| 2164 |
``` cpp
|
| 2165 |
bad_exception(const bad_exception&) noexcept;
|
| 2166 |
bad_exception& operator=(const bad_exception&) noexcept;
|
| 2167 |
```
|
| 2168 |
|
| 2169 |
*Effects:* Copies an object of class `bad_exception`.
|
| 2170 |
|
| 2171 |
``` cpp
|
| 2172 |
+
const char* what() const noexcept override;
|
| 2173 |
```
|
| 2174 |
|
| 2175 |
*Returns:* An *implementation-defined* NTBS.
|
| 2176 |
|
| 2177 |
*Remarks:* The message may be a null-terminated multibyte
|
|
|
|
| 2181 |
### Abnormal termination <a id="exception.terminate">[[exception.terminate]]</a>
|
| 2182 |
|
| 2183 |
#### Type `terminate_handler` <a id="terminate.handler">[[terminate.handler]]</a>
|
| 2184 |
|
| 2185 |
``` cpp
|
| 2186 |
+
using terminate_handler = void (*)();
|
| 2187 |
```
|
| 2188 |
|
| 2189 |
The type of a *handler function* to be called by `std::terminate()` when
|
| 2190 |
terminating exception processing.
|
| 2191 |
|
|
|
|
| 2213 |
|
| 2214 |
``` cpp
|
| 2215 |
terminate_handler get_terminate() noexcept;
|
| 2216 |
```
|
| 2217 |
|
| 2218 |
+
*Returns:* The current `terminate_handler`.
|
| 2219 |
+
|
| 2220 |
+
[*Note 1*: This may be a null pointer value. — *end note*]
|
| 2221 |
|
| 2222 |
#### `terminate` <a id="terminate">[[terminate]]</a>
|
| 2223 |
|
| 2224 |
``` cpp
|
| 2225 |
[[noreturn]] void terminate() noexcept;
|
| 2226 |
```
|
| 2227 |
|
| 2228 |
*Remarks:* Called by the implementation when exception handling must be
|
| 2229 |
+
abandoned for any of several reasons ([[except.terminate]]). May also
|
| 2230 |
+
be called directly by the program.
|
|
|
|
| 2231 |
|
| 2232 |
+
*Effects:* Calls a `terminate_handler` function. It is unspecified which
|
| 2233 |
+
`terminate_handler` function will be called if an exception is active
|
| 2234 |
+
during a call to `set_terminate`. Otherwise calls the current
|
| 2235 |
+
`terminate_handler` function.
|
| 2236 |
|
| 2237 |
+
[*Note 1*: A default `terminate_handler` is always considered a
|
| 2238 |
+
callable handler in this context. — *end note*]
|
| 2239 |
+
|
| 2240 |
+
### `uncaught_exceptions` <a id="uncaught.exceptions">[[uncaught.exceptions]]</a>
|
| 2241 |
|
| 2242 |
``` cpp
|
| 2243 |
+
int uncaught_exceptions() noexcept;
|
| 2244 |
```
|
| 2245 |
|
| 2246 |
+
*Returns:* The number of uncaught exceptions ([[except.uncaught]]).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2247 |
|
| 2248 |
+
*Remarks:* When `uncaught_exceptions() > 0`, throwing an exception can
|
| 2249 |
+
result in a call of
|
| 2250 |
`std::terminate()` ([[except.terminate]]).
|
| 2251 |
|
| 2252 |
### Exception propagation <a id="propagation">[[propagation]]</a>
|
| 2253 |
|
| 2254 |
``` cpp
|
| 2255 |
+
using exception_ptr = unspecified;
|
| 2256 |
```
|
| 2257 |
|
| 2258 |
+
The type `exception_ptr` can be used to refer to an exception object.
|
| 2259 |
|
| 2260 |
`exception_ptr` shall satisfy the requirements of
|
| 2261 |
`NullablePointer` ([[nullablepointer.requirements]]).
|
| 2262 |
|
| 2263 |
Two non-null values of type `exception_ptr` are equivalent and compare
|
|
|
|
| 2267 |
the type.
|
| 2268 |
|
| 2269 |
`exception_ptr` shall not be implicitly convertible to any arithmetic,
|
| 2270 |
enumeration, or pointer type.
|
| 2271 |
|
| 2272 |
+
[*Note 1*: An implementation might use a reference-counted smart
|
| 2273 |
+
pointer as `exception_ptr`. — *end note*]
|
| 2274 |
|
| 2275 |
For purposes of determining the presence of a data race, operations on
|
| 2276 |
`exception_ptr` objects shall access and modify only the `exception_ptr`
|
| 2277 |
objects themselves and not the exceptions they refer to. Use of
|
| 2278 |
`rethrow_exception` on `exception_ptr` objects that refer to the same
|
| 2279 |
+
exception object shall not introduce a data race.
|
| 2280 |
+
|
| 2281 |
+
[*Note 2*: If `rethrow_exception` rethrows the same exception object
|
| 2282 |
+
(rather than a copy), concurrent access to that rethrown exception
|
| 2283 |
+
object may introduce a data race. Changes in the number of
|
| 2284 |
+
`exception_ptr` objects that refer to a particular exception do not
|
| 2285 |
+
introduce a data race. — *end note*]
|
| 2286 |
|
| 2287 |
``` cpp
|
| 2288 |
exception_ptr current_exception() noexcept;
|
| 2289 |
```
|
| 2290 |
|
|
|
|
| 2294 |
being handled. The referenced object shall remain valid at least as long
|
| 2295 |
as there is an `exception_ptr` object that refers to it. If the function
|
| 2296 |
needs to allocate memory and the attempt fails, it returns an
|
| 2297 |
`exception_ptr` object that refers to an instance of `bad_alloc`. It is
|
| 2298 |
unspecified whether the return values of two successive calls to
|
| 2299 |
+
`current_exception` refer to the same exception object.
|
| 2300 |
+
|
| 2301 |
+
[*Note 3*: That is, it is unspecified whether `current_exception`
|
| 2302 |
+
creates a new copy each time it is called. — *end note*]
|
| 2303 |
+
|
| 2304 |
+
If the attempt to copy the current exception object throws an exception,
|
| 2305 |
+
the function returns an `exception_ptr` object that refers to the thrown
|
| 2306 |
+
exception or, if this is not possible, to an instance of
|
| 2307 |
+
`bad_exception`.
|
| 2308 |
+
|
| 2309 |
+
[*Note 4*: The copy constructor of the thrown exception may also fail,
|
| 2310 |
+
so the implementation is allowed to substitute a `bad_exception` object
|
| 2311 |
+
to avoid infinite recursion. — *end note*]
|
| 2312 |
|
| 2313 |
``` cpp
|
| 2314 |
[[noreturn]] void rethrow_exception(exception_ptr p);
|
| 2315 |
```
|
| 2316 |
|
| 2317 |
*Requires:* `p` shall not be a null pointer.
|
| 2318 |
|
| 2319 |
+
*Throws:* The exception object to which `p` refers.
|
| 2320 |
|
| 2321 |
``` cpp
|
| 2322 |
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 2323 |
```
|
| 2324 |
|
| 2325 |
*Effects:* Creates an `exception_ptr` object that refers to a copy of
|
| 2326 |
+
`e`, as if:
|
| 2327 |
|
| 2328 |
``` cpp
|
| 2329 |
try {
|
| 2330 |
throw e;
|
| 2331 |
} catch(...) {
|
| 2332 |
return current_exception();
|
| 2333 |
}
|
| 2334 |
```
|
| 2335 |
|
| 2336 |
+
[*Note 5*: This function is provided for convenience and efficiency
|
| 2337 |
+
reasons. — *end note*]
|
| 2338 |
|
| 2339 |
### `nested_exception` <a id="except.nested">[[except.nested]]</a>
|
| 2340 |
|
| 2341 |
``` cpp
|
| 2342 |
namespace std {
|
|
|
|
| 2359 |
|
| 2360 |
The class `nested_exception` is designed for use as a mixin through
|
| 2361 |
multiple inheritance. It captures the currently handled exception and
|
| 2362 |
stores it for later use.
|
| 2363 |
|
| 2364 |
+
[*Note 1*: `nested_exception` has a virtual destructor to make it a
|
| 2365 |
+
polymorphic class. Its presence can be tested for with
|
| 2366 |
+
`dynamic_cast`. — *end note*]
|
| 2367 |
|
| 2368 |
``` cpp
|
| 2369 |
nested_exception() noexcept;
|
| 2370 |
```
|
| 2371 |
|
|
|
|
| 2389 |
|
| 2390 |
``` cpp
|
| 2391 |
template <class T> [[noreturn]] void throw_with_nested(T&& t);
|
| 2392 |
```
|
| 2393 |
|
| 2394 |
+
Let `U` be `decay_t<T>`.
|
| 2395 |
|
| 2396 |
*Requires:* `U` shall be `CopyConstructible`.
|
| 2397 |
|
| 2398 |
+
*Throws:* If
|
| 2399 |
+
`is_class_v<U> && !is_final_v<U> && !is_base_of_v<nested_exception, U>`
|
| 2400 |
+
is `true`, an exception of unspecified type that is publicly derived
|
| 2401 |
+
from both `U` and `nested_exception` and constructed from
|
| 2402 |
`std::forward<T>(t)`, otherwise `std::forward<T>(t)`.
|
| 2403 |
|
| 2404 |
``` cpp
|
| 2405 |
template <class E> void rethrow_if_nested(const E& e);
|
| 2406 |
```
|
| 2407 |
|
| 2408 |
+
*Effects:* If `E` is not a polymorphic class type, or if
|
| 2409 |
+
`nested_exception` is an inaccessible or ambiguous base class of `E`,
|
| 2410 |
+
there is no effect. Otherwise, performs:
|
| 2411 |
+
|
| 2412 |
+
``` cpp
|
| 2413 |
+
if (auto p = dynamic_cast<const nested_exception*>(addressof(e)))
|
| 2414 |
+
p->rethrow_nested();
|
| 2415 |
+
```
|
| 2416 |
|
| 2417 |
## Initializer lists <a id="support.initlist">[[support.initlist]]</a>
|
| 2418 |
|
| 2419 |
The header `<initializer_list>` defines a class template and several
|
| 2420 |
support functions related to list-initialization (see
|
| 2421 |
+
[[dcl.init.list]]). All functions specified in this subclause are
|
| 2422 |
+
signal-safe ([[csignal.syn]]).
|
| 2423 |
+
|
| 2424 |
+
### Header `<initializer_list>` synopsis <a id="initializer_list.syn">[[initializer_list.syn]]</a>
|
| 2425 |
|
| 2426 |
``` cpp
|
| 2427 |
namespace std {
|
| 2428 |
template<class E> class initializer_list {
|
| 2429 |
public:
|
| 2430 |
+
using value_type = E;
|
| 2431 |
+
using reference = const E&;
|
| 2432 |
+
using const_reference = const E&;
|
| 2433 |
+
using size_type = size_t;
|
| 2434 |
|
| 2435 |
+
using iterator = const E*;
|
| 2436 |
+
using const_iterator = const E*;
|
| 2437 |
|
| 2438 |
constexpr initializer_list() noexcept;
|
| 2439 |
|
| 2440 |
constexpr size_t size() const noexcept; // number of elements
|
| 2441 |
constexpr const E* begin() const noexcept; // first element
|
| 2442 |
constexpr const E* end() const noexcept; // one past the last element
|
| 2443 |
};
|
| 2444 |
|
| 2445 |
+
// [support.initlist.range], initializer list range access
|
| 2446 |
template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
|
| 2447 |
template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
| 2448 |
}
|
| 2449 |
```
|
| 2450 |
|
| 2451 |
An object of type `initializer_list<E>` provides access to an array of
|
| 2452 |
+
objects of type `const E`.
|
| 2453 |
+
|
| 2454 |
+
[*Note 1*: A pair of pointers or a pointer plus a length would be
|
| 2455 |
+
obvious representations for `initializer_list`. `initializer_list` is
|
| 2456 |
+
used to implement initializer lists as specified in [[dcl.init.list]].
|
| 2457 |
+
Copying an initializer list does not copy the underlying
|
| 2458 |
+
elements. — *end note*]
|
| 2459 |
+
|
| 2460 |
+
If an explicit specialization or partial specialization of
|
| 2461 |
+
`initializer_list` is declared, the program is ill-formed.
|
| 2462 |
|
| 2463 |
### Initializer list constructors <a id="support.initlist.cons">[[support.initlist.cons]]</a>
|
| 2464 |
|
| 2465 |
``` cpp
|
| 2466 |
constexpr initializer_list() noexcept;
|
| 2467 |
```
|
| 2468 |
|
| 2469 |
+
*Effects:* Constructs an empty `initializer_list` object.
|
| 2470 |
|
| 2471 |
+
*Postconditions:* `size() == 0`.
|
| 2472 |
|
| 2473 |
### Initializer list access <a id="support.initlist.access">[[support.initlist.access]]</a>
|
| 2474 |
|
| 2475 |
``` cpp
|
| 2476 |
constexpr const E* begin() const noexcept;
|
|
|
|
| 2482 |
|
| 2483 |
``` cpp
|
| 2484 |
constexpr const E* end() const noexcept;
|
| 2485 |
```
|
| 2486 |
|
| 2487 |
+
*Returns:* `begin() + size()`.
|
| 2488 |
|
| 2489 |
``` cpp
|
| 2490 |
constexpr size_t size() const noexcept;
|
| 2491 |
```
|
| 2492 |
|
|
|
|
| 2509 |
*Returns:* `il.end()`.
|
| 2510 |
|
| 2511 |
## Other runtime support <a id="support.runtime">[[support.runtime]]</a>
|
| 2512 |
|
| 2513 |
Headers `<csetjmp>` (nonlocal jumps), `<csignal>` (signal handling),
|
| 2514 |
+
`<cstdarg>` (variable arguments), and `<cstdlib>` (runtime environment
|
| 2515 |
+
`getenv, system`), provide further compatibility with C code.
|
| 2516 |
+
|
| 2517 |
+
Calls to the function `getenv` ([[cstdlib.syn]]) shall not introduce a
|
| 2518 |
+
data race ([[res.on.data.races]]) provided that nothing modifies the
|
| 2519 |
+
environment.
|
| 2520 |
+
|
| 2521 |
+
[*Note 1*: Calls to the POSIX functions `setenv` and `putenv` modify
|
| 2522 |
+
the environment. — *end note*]
|
| 2523 |
+
|
| 2524 |
+
A call to the `setlocale` function ([[c.locales]]) may introduce a data
|
| 2525 |
+
race with other calls to the `setlocale` function or with calls to
|
| 2526 |
+
functions that are affected by the current C locale. The implementation
|
| 2527 |
+
shall behave as if no library function other than `locale::global` calls
|
| 2528 |
+
the `setlocale` function.
|
| 2529 |
+
|
| 2530 |
+
### Header `<cstdarg>` synopsis <a id="cstdarg.syn">[[cstdarg.syn]]</a>
|
| 2531 |
+
|
| 2532 |
+
``` cpp
|
| 2533 |
+
namespace std {
|
| 2534 |
+
using va_list = see below;
|
| 2535 |
+
}
|
| 2536 |
+
|
| 2537 |
+
#define va_arg(V, P) see below
|
| 2538 |
+
#define va_copy(VDST, VSRC) see below
|
| 2539 |
+
#define va_end(V) see below
|
| 2540 |
+
#define va_start(V, P) see below
|
| 2541 |
+
```
|
| 2542 |
+
|
| 2543 |
+
The contents of the header `<cstdarg>` are the same as the C standard
|
| 2544 |
+
library header `<stdarg.h>`, with the following changes: The
|
| 2545 |
+
restrictions that ISO C places on the second parameter to the `va_start`
|
| 2546 |
+
macro in header `<stdarg.h>` are different in this International
|
| 2547 |
+
Standard. The parameter `parmN` is the rightmost parameter in the
|
| 2548 |
+
variable parameter list of the function definition (the one just before
|
| 2549 |
+
the `...`).[^34] If the parameter `parmN` is a pack expansion (
|
| 2550 |
+
[[temp.variadic]]) or an entity resulting from a lambda capture (
|
| 2551 |
+
[[expr.prim.lambda]]), the program is ill-formed, no diagnostic
|
| 2552 |
+
required. If the parameter `parmN` is of a reference type, or of a type
|
| 2553 |
+
that is not compatible with the type that results when passing an
|
| 2554 |
+
argument for which there is no parameter, the behavior is undefined.
|
| 2555 |
+
|
| 2556 |
+
ISO C 7.16.1.1.
|
| 2557 |
+
|
| 2558 |
+
### Header `<csetjmp>` synopsis <a id="csetjmp.syn">[[csetjmp.syn]]</a>
|
| 2559 |
+
|
| 2560 |
+
``` cpp
|
| 2561 |
+
namespace std {
|
| 2562 |
+
using jmp_buf = see below;
|
| 2563 |
+
[[noreturn]] void longjmp(jmp_buf env, int val);
|
| 2564 |
+
}
|
| 2565 |
+
|
| 2566 |
+
#define setjmp(env) see below
|
| 2567 |
+
```
|
| 2568 |
+
|
| 2569 |
+
The contents of the header `<csetjmp>` are the same as the C standard
|
| 2570 |
+
library header `<setjmp.h>`.
|
| 2571 |
|
| 2572 |
The function signature `longjmp(jmp_buf jbuf, int val)` has more
|
| 2573 |
restricted behavior in this International Standard. A `setjmp`/`longjmp`
|
| 2574 |
call pair has undefined behavior if replacing the `setjmp` and `longjmp`
|
| 2575 |
by `catch` and `throw` would invoke any non-trivial destructors for any
|
| 2576 |
automatic objects.
|
| 2577 |
|
| 2578 |
+
ISO C 7.13.
|
| 2579 |
|
| 2580 |
+
### Header `<csignal>` synopsis <a id="csignal.syn">[[csignal.syn]]</a>
|
|
|
|
|
|
|
|
|
|
| 2581 |
|
| 2582 |
+
``` cpp
|
| 2583 |
+
namespace std {
|
| 2584 |
+
using sig_atomic_t = see below;
|
|
|
|
|
|
|
| 2585 |
|
| 2586 |
+
// [support.signal], signal handlers
|
| 2587 |
+
extern "C" using signal-handler = void(int); // exposition only
|
| 2588 |
+
signal-handler* signal(int sig, signal-handler* func);
|
| 2589 |
|
| 2590 |
+
int raise(int sig);
|
| 2591 |
+
}
|
| 2592 |
+
|
| 2593 |
+
#define SIG_DFL see below
|
| 2594 |
+
#define SIG_ERR see below
|
| 2595 |
+
#define SIG_IGN see below
|
| 2596 |
+
#define SIGABRT see below
|
| 2597 |
+
#define SIGFPE see below
|
| 2598 |
+
#define SIGILL see below
|
| 2599 |
+
#define SIGINT see below
|
| 2600 |
+
#define SIGSEGV see below
|
| 2601 |
+
#define SIGTERM see below
|
| 2602 |
+
```
|
| 2603 |
+
|
| 2604 |
+
The contents of the header `<csignal>` are the same as the C standard
|
| 2605 |
+
library header `<signal.h>`.
|
| 2606 |
+
|
| 2607 |
+
### Signal handlers <a id="support.signal">[[support.signal]]</a>
|
| 2608 |
|
| 2609 |
A call to the function `signal` synchronizes with any resulting
|
| 2610 |
invocation of the signal handler so installed.
|
| 2611 |
|
| 2612 |
+
A *plain lock-free atomic operation* is an invocation of a function `f`
|
| 2613 |
+
from Clause [[atomics]], such that:
|
| 2614 |
+
|
| 2615 |
+
- `f` is the function `atomic_is_lock_free()`, or
|
| 2616 |
+
- `f` is the member function `is_lock_free()`, or
|
| 2617 |
+
- `f` is a non-static member function invoked on an object `A`, such
|
| 2618 |
+
that `A.is_lock_free()` yields `true`, or
|
| 2619 |
+
- `f` is a non-member function, and for every pointer-to-atomic argument
|
| 2620 |
+
`A` passed to `f`, `atomic_is_lock_free(A)` yields `true`.
|
| 2621 |
+
|
| 2622 |
+
An evaluation is *signal-safe* unless it includes one of the following:
|
| 2623 |
+
|
| 2624 |
+
- a call to any standard library function, except for plain lock-free
|
| 2625 |
+
atomic operations and functions explicitly identified as signal-safe.
|
| 2626 |
+
\[*Note 1*: This implicitly excludes the use of `new` and `delete`
|
| 2627 |
+
expressions that rely on a library-provided memory
|
| 2628 |
+
allocator. — *end note*]
|
| 2629 |
+
- an access to an object with thread storage duration;
|
| 2630 |
+
- a `dynamic_cast` expression;
|
| 2631 |
+
- throwing of an exception;
|
| 2632 |
+
- control entering a *try-block* or *function-try-block*;
|
| 2633 |
+
- initialization of a variable with static storage duration requiring
|
| 2634 |
+
dynamic initialization ([[basic.start.dynamic]], [[stmt.dcl]]) [^35];
|
| 2635 |
+
or
|
| 2636 |
+
- waiting for the completion of the initialization of a variable with
|
| 2637 |
+
static storage duration ([[stmt.dcl]]).
|
| 2638 |
+
|
| 2639 |
+
A signal handler invocation has undefined behavior if it includes an
|
| 2640 |
+
evaluation that is not signal-safe.
|
| 2641 |
+
|
| 2642 |
+
The function `signal` is signal-safe if it is invoked with the first
|
| 2643 |
+
argument equal to the signal number corresponding to the signal that
|
| 2644 |
+
caused the invocation of the handler.
|
| 2645 |
+
|
| 2646 |
+
ISO C 7.14.
|
| 2647 |
|
| 2648 |
<!-- Link reference definitions -->
|
| 2649 |
+
[alg.c.library]: algorithms.md#alg.c.library
|
| 2650 |
[alloc.errors]: #alloc.errors
|
| 2651 |
[atomics]: atomics.md#atomics
|
| 2652 |
[bad.alloc]: #bad.alloc
|
| 2653 |
[bad.cast]: #bad.cast
|
| 2654 |
[bad.exception]: #bad.exception
|
| 2655 |
[bad.typeid]: #bad.typeid
|
| 2656 |
[basic.align]: basic.md#basic.align
|
| 2657 |
+
[basic.def.odr]: basic.md#basic.def.odr
|
| 2658 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 2659 |
+
[basic.life]: basic.md#basic.life
|
| 2660 |
[basic.start]: basic.md#basic.start
|
| 2661 |
+
[basic.start.dynamic]: basic.md#basic.start.dynamic
|
| 2662 |
[basic.start.term]: basic.md#basic.start.term
|
| 2663 |
[basic.stc.dynamic]: basic.md#basic.stc.dynamic
|
| 2664 |
[basic.stc.dynamic.allocation]: basic.md#basic.stc.dynamic.allocation
|
| 2665 |
[basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
|
| 2666 |
[basic.stc.dynamic.safety]: basic.md#basic.stc.dynamic.safety
|
| 2667 |
+
[c.locales]: localization.md#c.locales
|
| 2668 |
+
[c.malloc]: utilities.md#c.malloc
|
| 2669 |
+
[c.math.abs]: numerics.md#c.math.abs
|
| 2670 |
+
[c.math.rand]: numerics.md#c.math.rand
|
| 2671 |
+
[c.mb.wcs]: strings.md#c.mb.wcs
|
| 2672 |
+
[cfloat.syn]: #cfloat.syn
|
| 2673 |
[class]: class.md#class
|
| 2674 |
[class.free]: special.md#class.free
|
| 2675 |
+
[climits.syn]: #climits.syn
|
| 2676 |
[complex]: numerics.md#complex
|
| 2677 |
[constraints]: library.md#constraints
|
| 2678 |
[conv.ptr]: conv.md#conv.ptr
|
| 2679 |
+
[conv.qual]: conv.md#conv.qual
|
| 2680 |
[conv.rank]: conv.md#conv.rank
|
| 2681 |
+
[csetjmp.syn]: #csetjmp.syn
|
| 2682 |
+
[csignal.syn]: #csignal.syn
|
| 2683 |
+
[cstdarg.syn]: #cstdarg.syn
|
| 2684 |
+
[cstddef.syn]: #cstddef.syn
|
| 2685 |
[cstdint]: #cstdint
|
| 2686 |
[cstdint.syn]: #cstdint.syn
|
| 2687 |
+
[cstdlib.syn]: #cstdlib.syn
|
| 2688 |
[dcl.init.list]: dcl.md#dcl.init.list
|
| 2689 |
[denorm.style]: #denorm.style
|
|
|
|
| 2690 |
[except.handle]: except.md#except.handle
|
| 2691 |
[except.nested]: #except.nested
|
| 2692 |
[except.special]: except.md#except.special
|
| 2693 |
[except.terminate]: except.md#except.terminate
|
| 2694 |
+
[except.uncaught]: except.md#except.uncaught
|
|
|
|
| 2695 |
[exception]: #exception
|
| 2696 |
+
[exception.syn]: #exception.syn
|
| 2697 |
[exception.terminate]: #exception.terminate
|
| 2698 |
[expr.add]: expr.md#expr.add
|
| 2699 |
[expr.delete]: expr.md#expr.delete
|
| 2700 |
[expr.dynamic.cast]: expr.md#expr.dynamic.cast
|
| 2701 |
[expr.new]: expr.md#expr.new
|
| 2702 |
+
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 2703 |
[expr.sizeof]: expr.md#expr.sizeof
|
| 2704 |
[expr.typeid]: expr.md#expr.typeid
|
| 2705 |
+
[fp.style]: #fp.style
|
| 2706 |
[get.new.handler]: #get.new.handler
|
| 2707 |
[get.terminate]: #get.terminate
|
| 2708 |
+
[hardware.interference]: #hardware.interference
|
| 2709 |
+
[initializer_list.syn]: #initializer_list.syn
|
| 2710 |
[intro.memory]: intro.md#intro.memory
|
| 2711 |
[intro.multithread]: intro.md#intro.multithread
|
| 2712 |
[language.support]: #language.support
|
| 2713 |
+
[library.c]: library.md#library.c
|
|
|
|
| 2714 |
[limits.syn]: #limits.syn
|
| 2715 |
[locale.codecvt]: localization.md#locale.codecvt
|
| 2716 |
[memory]: utilities.md#memory
|
| 2717 |
[multibyte.strings]: library.md#multibyte.strings
|
| 2718 |
[new.badlength]: #new.badlength
|
|
|
|
| 2720 |
[new.delete.array]: #new.delete.array
|
| 2721 |
[new.delete.dataraces]: #new.delete.dataraces
|
| 2722 |
[new.delete.placement]: #new.delete.placement
|
| 2723 |
[new.delete.single]: #new.delete.single
|
| 2724 |
[new.handler]: #new.handler
|
| 2725 |
+
[new.syn]: #new.syn
|
| 2726 |
[nullablepointer.requirements]: library.md#nullablepointer.requirements
|
| 2727 |
[numeric.limits]: #numeric.limits
|
| 2728 |
[numeric.limits.members]: #numeric.limits.members
|
| 2729 |
[numeric.special]: #numeric.special
|
| 2730 |
[propagation]: #propagation
|
| 2731 |
+
[ptr.launder]: #ptr.launder
|
| 2732 |
[res.on.data.races]: library.md#res.on.data.races
|
| 2733 |
[round.style]: #round.style
|
| 2734 |
[set.new.handler]: #set.new.handler
|
| 2735 |
[set.terminate]: #set.terminate
|
| 2736 |
+
[stmt.dcl]: stmt.md#stmt.dcl
|
| 2737 |
[string.classes]: strings.md#string.classes
|
| 2738 |
[support.dynamic]: #support.dynamic
|
| 2739 |
[support.exception]: #support.exception
|
| 2740 |
[support.general]: #support.general
|
| 2741 |
[support.initlist]: #support.initlist
|
|
|
|
| 2744 |
[support.initlist.range]: #support.initlist.range
|
| 2745 |
[support.limits]: #support.limits
|
| 2746 |
[support.limits.general]: #support.limits.general
|
| 2747 |
[support.rtti]: #support.rtti
|
| 2748 |
[support.runtime]: #support.runtime
|
| 2749 |
+
[support.signal]: #support.signal
|
| 2750 |
[support.start.term]: #support.start.term
|
| 2751 |
[support.types]: #support.types
|
| 2752 |
+
[support.types.byteops]: #support.types.byteops
|
| 2753 |
+
[support.types.layout]: #support.types.layout
|
| 2754 |
+
[support.types.nullptr]: #support.types.nullptr
|
| 2755 |
[tab:lang.sup.lib.summary]: #tab:lang.sup.lib.summary
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2756 |
[temp.dep.constexpr]: temp.md#temp.dep.constexpr
|
| 2757 |
[temp.dep.expr]: temp.md#temp.dep.expr
|
| 2758 |
+
[temp.variadic]: temp.md#temp.variadic
|
| 2759 |
[terminate]: #terminate
|
| 2760 |
[terminate.handler]: #terminate.handler
|
| 2761 |
[type.info]: #type.info
|
| 2762 |
+
[typeinfo.syn]: #typeinfo.syn
|
| 2763 |
+
[uncaught.exceptions]: #uncaught.exceptions
|
| 2764 |
|
| 2765 |
[^1]: Possible definitions include `0` and `0L`, but not `(void*)0`.
|
| 2766 |
|
| 2767 |
[^2]: Note that `offsetof` is required to work as specified even if
|
| 2768 |
unary `operator&` is overloaded for any of the types involved.
|
|
|
|
| 2783 |
|
| 2784 |
[^9]: Distinguishes types with bases other than 2 (e.g. BCD).
|
| 2785 |
|
| 2786 |
[^10]: Equivalent to `FLT_EPSILON`, `DBL_EPSILON`, `LDBL_EPSILON`.
|
| 2787 |
|
| 2788 |
+
[^11]: Rounding error is described in LIA-1 Section 5.2.4 and Annex C
|
| 2789 |
+
Rationale Section C.5.2.4 — Rounding and rounding constants.
|
|
|
|
| 2790 |
|
| 2791 |
[^12]: Equivalent to `FLT_MIN_EXP`, `DBL_MIN_EXP`, `LDBL_MIN_EXP`.
|
| 2792 |
|
| 2793 |
[^13]: Equivalent to `FLT_MIN_10_EXP`, `DBL_MIN_10_EXP`,
|
| 2794 |
`LDBL_MIN_10_EXP`.
|
|
|
|
| 2802 |
|
| 2803 |
[^17]: Required by LIA-1.
|
| 2804 |
|
| 2805 |
[^18]: Required by LIA-1.
|
| 2806 |
|
| 2807 |
+
[^19]: See ISO/IEC/IEEE 60559.
|
| 2808 |
|
| 2809 |
[^20]: Required by LIA-1.
|
| 2810 |
|
| 2811 |
[^21]: Required by LIA-1.
|
| 2812 |
|
| 2813 |
[^22]: Required by LIA-1.
|
| 2814 |
|
| 2815 |
[^23]: Required by LIA-1.
|
| 2816 |
|
| 2817 |
+
[^24]: ISO/IEC/IEEE 60559:2011 is the same as IEEE 754-2008.
|
|
|
|
| 2818 |
|
| 2819 |
[^25]: Required by LIA-1.
|
| 2820 |
|
| 2821 |
[^26]: Required by LIA-1.
|
| 2822 |
|
| 2823 |
[^27]: Required by LIA-1.
|
| 2824 |
|
| 2825 |
+
[^28]: Refer to ISO/IEC/IEEE 60559. Required by LIA-1.
|
| 2826 |
|
| 2827 |
[^29]: Equivalent to `FLT_ROUNDS`. Required by LIA-1.
|
| 2828 |
|
| 2829 |
[^30]: A function is called for every time it is registered.
|
| 2830 |
|
| 2831 |
[^31]: Objects with automatic storage duration are all destroyed in a
|
| 2832 |
+
program whose `main` function ([[basic.start.main]]) contains no
|
| 2833 |
+
automatic objects and executes the call to `exit()`. Control can be
|
| 2834 |
+
transferred directly to such a `main` function by throwing an
|
| 2835 |
+
exception that is caught in `main`.
|
| 2836 |
|
| 2837 |
[^32]: The macros `EXIT_FAILURE` and `EXIT_SUCCESS` are defined in
|
| 2838 |
`<cstdlib>`.
|
| 2839 |
|
| 2840 |
+
[^33]: It is not the direct responsibility of `operator new[]` or
|
| 2841 |
+
`operator delete[]` to note the repetition count or element size of
|
| 2842 |
+
the array. Those operations are performed elsewhere in the array
|
| 2843 |
+
`new` and `delete` expressions. The array `new` expression, may,
|
| 2844 |
+
however, increase the `size` argument to `operator new[]` to obtain
|
| 2845 |
+
space to store supplemental information.
|
|
|
|
| 2846 |
|
| 2847 |
[^34]: Note that `va_start` is required to work as specified even if
|
| 2848 |
unary `operator&` is overloaded for the type of `parmN`.
|
| 2849 |
|
| 2850 |
+
[^35]: Such initialization might occur because it is the first odr-use (
|
| 2851 |
+
[[basic.def.odr]]) of that variable.
|
|
|
|
|
|
|
|
|