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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Language support library <a id="support">[[support]]</a>
|
| 2 |
+
|
| 3 |
+
## General <a id="support.general">[[support.general]]</a>
|
| 4 |
+
|
| 5 |
+
This Clause describes the function signatures that are called
|
| 6 |
+
implicitly, and the types of objects generated implicitly, during the
|
| 7 |
+
execution of some C++ programs. It also describes the headers that
|
| 8 |
+
declare these function signatures and define any related types.
|
| 9 |
+
|
| 10 |
+
The following subclauses describe common type definitions used
|
| 11 |
+
throughout the library, characteristics of the predefined types,
|
| 12 |
+
functions supporting start and termination of a C++ program, support for
|
| 13 |
+
dynamic memory management, support for dynamic type identification,
|
| 14 |
+
support for exception processing, support for initializer lists, and
|
| 15 |
+
other runtime support, as summarized in [[support.summary]].
|
| 16 |
+
|
| 17 |
+
**Table: Language support library summary** <a id="support.summary">[support.summary]</a>
|
| 18 |
+
|
| 19 |
+
| Subclause | | Header |
|
| 20 |
+
| ---------------------- | ------------------------- | -------------------------------------------------- |
|
| 21 |
+
| [[support.types]] | Common definitions | `<cstddef>`, `<cstdlib>` |
|
| 22 |
+
| [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, `<version>` |
|
| 23 |
+
| [[cstdint]] | Integer types | `<cstdint>` |
|
| 24 |
+
| [[support.start.term]] | Start and termination | `<cstdlib>` |
|
| 25 |
+
| [[support.dynamic]] | Dynamic memory management | `<new>` |
|
| 26 |
+
| [[support.rtti]] | Type identification | `<typeinfo>` |
|
| 27 |
+
| [[support.srcloc]] | Source location | `<source_location>` |
|
| 28 |
+
| [[support.exception]] | Exception handling | `<exception>` |
|
| 29 |
+
| [[support.initlist]] | Initializer lists | `<initializer_list>` |
|
| 30 |
+
| [[cmp]] | Comparisons | `<compare>` |
|
| 31 |
+
| [[support.coroutine]] | Coroutines | `<coroutine>` |
|
| 32 |
+
| [[support.runtime]] | Other runtime support | `<csetjmp>`, `<csignal>`, `<cstdarg>`, `<cstdlib>` |
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
## Common definitions <a id="support.types">[[support.types]]</a>
|
| 36 |
+
|
| 37 |
+
### Header `<cstddef>` synopsis <a id="cstddef.syn">[[cstddef.syn]]</a>
|
| 38 |
+
|
| 39 |
+
``` cpp
|
| 40 |
+
namespace std {
|
| 41 |
+
using ptrdiff_t = see below;
|
| 42 |
+
using size_t = see below;
|
| 43 |
+
using max_align_t = see below;
|
| 44 |
+
using nullptr_t = decltype(nullptr);
|
| 45 |
+
|
| 46 |
+
enum class byte : unsigned char {};
|
| 47 |
+
|
| 48 |
+
// [support.types.byteops], byte type operations
|
| 49 |
+
template<class IntType>
|
| 50 |
+
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
|
| 51 |
+
template<class IntType>
|
| 52 |
+
constexpr byte operator<<(byte b, IntType shift) noexcept;
|
| 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 |
+
constexpr byte& operator|=(byte& l, byte r) noexcept;
|
| 58 |
+
constexpr byte operator|(byte l, byte r) noexcept;
|
| 59 |
+
constexpr byte& operator&=(byte& l, byte r) noexcept;
|
| 60 |
+
constexpr byte operator&(byte l, byte r) noexcept;
|
| 61 |
+
constexpr byte& operator^=(byte& l, byte r) noexcept;
|
| 62 |
+
constexpr byte operator^(byte l, byte r) noexcept;
|
| 63 |
+
constexpr byte operator~(byte b) noexcept;
|
| 64 |
+
template<class IntType>
|
| 65 |
+
constexpr IntType to_integer(byte b) noexcept;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
#define NULL see below
|
| 69 |
+
#define offsetof(P, D) see below
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
The contents and meaning of the header `<cstddef>` are the same as the C
|
| 73 |
+
standard library header `<stddef.h>`, except that it does not declare
|
| 74 |
+
the type `wchar_t`, that it also declares the type `byte` and its
|
| 75 |
+
associated operations [[support.types.byteops]], and as noted in
|
| 76 |
+
[[support.types.nullptr]] and [[support.types.layout]].
|
| 77 |
+
|
| 78 |
+
See also: ISO C 7.19
|
| 79 |
+
|
| 80 |
+
### Header `<cstdlib>` synopsis <a id="cstdlib.syn">[[cstdlib.syn]]</a>
|
| 81 |
+
|
| 82 |
+
``` cpp
|
| 83 |
+
namespace std {
|
| 84 |
+
using size_t = see below;
|
| 85 |
+
using div_t = see below;
|
| 86 |
+
using ldiv_t = see below;
|
| 87 |
+
using lldiv_t = see below;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
#define NULL see below
|
| 91 |
+
#define EXIT_FAILURE see below
|
| 92 |
+
#define EXIT_SUCCESS see below
|
| 93 |
+
#define RAND_MAX see below
|
| 94 |
+
#define MB_CUR_MAX see below
|
| 95 |
+
|
| 96 |
+
namespace std {
|
| 97 |
+
// Exposition-only function type aliases
|
| 98 |
+
extern "C" using c-atexit-handler = void(); // exposition only
|
| 99 |
+
extern "C++" using atexit-handler = void(); // exposition only
|
| 100 |
+
extern "C" using c-compare-pred = int(const void*, const void*); // exposition only
|
| 101 |
+
extern "C++" using compare-pred = int(const void*, const void*); // exposition only
|
| 102 |
+
|
| 103 |
+
// [support.start.term], start and termination
|
| 104 |
+
[[noreturn]] void abort() noexcept;
|
| 105 |
+
int atexit(c-atexit-handler* func) noexcept;
|
| 106 |
+
int atexit(atexit-handler* func) noexcept;
|
| 107 |
+
int at_quick_exit(c-atexit-handler* func) noexcept;
|
| 108 |
+
int at_quick_exit(atexit-handler* func) noexcept;
|
| 109 |
+
[[noreturn]] void exit(int status);
|
| 110 |
+
[[noreturn]] void _Exit(int status) noexcept;
|
| 111 |
+
[[noreturn]] void quick_exit(int status) noexcept;
|
| 112 |
+
|
| 113 |
+
char* getenv(const char* name);
|
| 114 |
+
int system(const char* string);
|
| 115 |
+
|
| 116 |
+
// [c.malloc], C library memory allocation
|
| 117 |
+
void* aligned_alloc(size_t alignment, size_t size);
|
| 118 |
+
void* calloc(size_t nmemb, size_t size);
|
| 119 |
+
void free(void* ptr);
|
| 120 |
+
void* malloc(size_t size);
|
| 121 |
+
void* realloc(void* ptr, size_t size);
|
| 122 |
+
|
| 123 |
+
double atof(const char* nptr);
|
| 124 |
+
int atoi(const char* nptr);
|
| 125 |
+
long int atol(const char* nptr);
|
| 126 |
+
long long int atoll(const char* nptr);
|
| 127 |
+
double strtod(const char* nptr, char** endptr);
|
| 128 |
+
float strtof(const char* nptr, char** endptr);
|
| 129 |
+
long double strtold(const char* nptr, char** endptr);
|
| 130 |
+
long int strtol(const char* nptr, char** endptr, int base);
|
| 131 |
+
long long int strtoll(const char* nptr, char** endptr, int base);
|
| 132 |
+
unsigned long int strtoul(const char* nptr, char** endptr, int base);
|
| 133 |
+
unsigned long long int strtoull(const char* nptr, char** endptr, int base);
|
| 134 |
+
|
| 135 |
+
// [c.mb.wcs], multibyte / wide string and character conversion functions
|
| 136 |
+
int mblen(const char* s, size_t n);
|
| 137 |
+
int mbtowc(wchar_t* pwc, const char* s, size_t n);
|
| 138 |
+
int wctomb(char* s, wchar_t wchar);
|
| 139 |
+
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
|
| 140 |
+
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
|
| 141 |
+
|
| 142 |
+
// [alg.c.library], C standard library algorithms
|
| 143 |
+
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
| 144 |
+
c-compare-pred* compar);
|
| 145 |
+
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
| 146 |
+
compare-pred* compar);
|
| 147 |
+
void qsort(void* base, size_t nmemb, size_t size, c-compare-pred* compar);
|
| 148 |
+
void qsort(void* base, size_t nmemb, size_t size, compare-pred* compar);
|
| 149 |
+
|
| 150 |
+
// [c.math.rand], low-quality random number generation
|
| 151 |
+
int rand();
|
| 152 |
+
void srand(unsigned int seed);
|
| 153 |
+
|
| 154 |
+
// [c.math.abs], absolute values
|
| 155 |
+
int abs(int j);
|
| 156 |
+
long int abs(long int j);
|
| 157 |
+
long long int abs(long long int j);
|
| 158 |
+
float abs(float j);
|
| 159 |
+
double abs(double j);
|
| 160 |
+
long double abs(long double j);
|
| 161 |
+
|
| 162 |
+
long int labs(long int j);
|
| 163 |
+
long long int llabs(long long int j);
|
| 164 |
+
|
| 165 |
+
div_t div(int numer, int denom);
|
| 166 |
+
ldiv_t div(long int numer, long int denom); // see [library.c]
|
| 167 |
+
lldiv_t div(long long int numer, long long int denom); // see [library.c]
|
| 168 |
+
ldiv_t ldiv(long int numer, long int denom);
|
| 169 |
+
lldiv_t lldiv(long long int numer, long long int denom);
|
| 170 |
+
}
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
The contents and meaning of the header `<cstdlib>` are the same as the C
|
| 174 |
+
standard library header `<stdlib.h>`, except that it does not declare
|
| 175 |
+
the type `wchar_t`, and except as noted in [[support.types.nullptr]],
|
| 176 |
+
[[support.types.layout]], [[support.start.term]], [[c.malloc]],
|
| 177 |
+
[[c.mb.wcs]], [[alg.c.library]], [[c.math.rand]], and [[c.math.abs]].
|
| 178 |
+
|
| 179 |
+
[*Note 1*: Several functions have additional overloads in this
|
| 180 |
+
document, but they have the same behavior as in the C standard library
|
| 181 |
+
[[library.c]]. — *end note*]
|
| 182 |
+
|
| 183 |
+
See also: ISO C 7.22
|
| 184 |
+
|
| 185 |
+
### Null pointers <a id="support.types.nullptr">[[support.types.nullptr]]</a>
|
| 186 |
+
|
| 187 |
+
The type `nullptr_t` is a synonym for the type of a `nullptr`
|
| 188 |
+
expression, and it has the characteristics described in
|
| 189 |
+
[[basic.fundamental]] and [[conv.ptr]].
|
| 190 |
+
|
| 191 |
+
[*Note 1*: Although `nullptr`’s address cannot be taken, the address of
|
| 192 |
+
another `nullptr_t` object that is an lvalue can be
|
| 193 |
+
taken. — *end note*]
|
| 194 |
+
|
| 195 |
+
The macro `NULL` is an *implementation-defined* null pointer constant.
|
| 196 |
+
[^1]
|
| 197 |
+
|
| 198 |
+
See also: ISO C 7.19
|
| 199 |
+
|
| 200 |
+
### Sizes, alignments, and offsets <a id="support.types.layout">[[support.types.layout]]</a>
|
| 201 |
+
|
| 202 |
+
The macro `offsetof(type, member-designator)` has the same semantics as
|
| 203 |
+
the corresponding macro in the C standard library header `<stddef.h>`,
|
| 204 |
+
but accepts a restricted set of `type` arguments in this document. Use
|
| 205 |
+
of the `offsetof` macro with a `type` other than a standard-layout class
|
| 206 |
+
[[class.prop]] is conditionally-supported.[^2] The expression
|
| 207 |
+
`offsetof(type, member-designator)` is never type-dependent
|
| 208 |
+
[[temp.dep.expr]] and it is value-dependent [[temp.dep.constexpr]] if
|
| 209 |
+
and only if `type` is dependent. The result of applying the `offsetof`
|
| 210 |
+
macro to a static data member or a function member is undefined. No
|
| 211 |
+
operation invoked by the `offsetof` macro shall throw an exception and
|
| 212 |
+
`noexcept(offsetof(type, member-designator))` shall be `true`.
|
| 213 |
+
|
| 214 |
+
The type `ptrdiff_t` is an *implementation-defined* signed integer type
|
| 215 |
+
that can hold the difference of two subscripts in an array object, as
|
| 216 |
+
described in [[expr.add]].
|
| 217 |
+
|
| 218 |
+
The type `size_t` is an *implementation-defined* unsigned integer type
|
| 219 |
+
that is large enough to contain the size in bytes of any object
|
| 220 |
+
[[expr.sizeof]].
|
| 221 |
+
|
| 222 |
+
[*Note 1*: It is recommended that implementations choose types for
|
| 223 |
+
`ptrdiff_t` and `size_t` whose integer conversion ranks [[conv.rank]]
|
| 224 |
+
are no greater than that of `signed long int` unless a larger size is
|
| 225 |
+
necessary to contain all the possible values. — *end note*]
|
| 226 |
+
|
| 227 |
+
The type `max_align_t` is a trivial standard-layout type whose alignment
|
| 228 |
+
requirement is at least as great as that of every scalar type, and whose
|
| 229 |
+
alignment requirement is supported in every context [[basic.align]].
|
| 230 |
+
|
| 231 |
+
See also: ISO C 7.19
|
| 232 |
+
|
| 233 |
+
### `byte` type operations <a id="support.types.byteops">[[support.types.byteops]]</a>
|
| 234 |
+
|
| 235 |
+
``` cpp
|
| 236 |
+
template<class IntType>
|
| 237 |
+
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
+
*Constraints:* `is_integral_v<IntType>` is `true`.
|
| 241 |
+
|
| 242 |
+
*Effects:* Equivalent to: `return b = b << shift;`
|
| 243 |
+
|
| 244 |
+
``` cpp
|
| 245 |
+
template<class IntType>
|
| 246 |
+
constexpr byte operator<<(byte b, IntType shift) noexcept;
|
| 247 |
+
```
|
| 248 |
+
|
| 249 |
+
*Constraints:* `is_integral_v<IntType>` is `true`.
|
| 250 |
+
|
| 251 |
+
*Effects:* Equivalent to:
|
| 252 |
+
|
| 253 |
+
``` cpp
|
| 254 |
+
return static_cast<byte>(static_cast<unsigned int>(b) << shift);
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
``` cpp
|
| 258 |
+
template<class IntType>
|
| 259 |
+
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
|
| 260 |
+
```
|
| 261 |
+
|
| 262 |
+
*Constraints:* `is_integral_v<IntType>` is `true`.
|
| 263 |
+
|
| 264 |
+
*Effects:* Equivalent to: `return b = b >> shift;`
|
| 265 |
+
|
| 266 |
+
``` cpp
|
| 267 |
+
template<class IntType>
|
| 268 |
+
constexpr byte operator>>(byte b, IntType shift) noexcept;
|
| 269 |
+
```
|
| 270 |
+
|
| 271 |
+
*Constraints:* `is_integral_v<IntType>` is `true`.
|
| 272 |
+
|
| 273 |
+
*Effects:* Equivalent to:
|
| 274 |
+
|
| 275 |
+
``` cpp
|
| 276 |
+
return static_cast<byte>(static_cast<unsigned int>(b) >> shift);
|
| 277 |
+
```
|
| 278 |
+
|
| 279 |
+
``` cpp
|
| 280 |
+
constexpr byte& operator|=(byte& l, byte r) noexcept;
|
| 281 |
+
```
|
| 282 |
+
|
| 283 |
+
*Effects:* Equivalent to: `return l = l | r;`
|
| 284 |
+
|
| 285 |
+
``` cpp
|
| 286 |
+
constexpr byte operator|(byte l, byte r) noexcept;
|
| 287 |
+
```
|
| 288 |
+
|
| 289 |
+
*Effects:* Equivalent to:
|
| 290 |
+
|
| 291 |
+
``` cpp
|
| 292 |
+
return static_cast<byte>(static_cast<unsigned int>(l) | static_cast<unsigned int>(r));
|
| 293 |
+
```
|
| 294 |
+
|
| 295 |
+
``` cpp
|
| 296 |
+
constexpr byte& operator&=(byte& l, byte r) noexcept;
|
| 297 |
+
```
|
| 298 |
+
|
| 299 |
+
*Effects:* Equivalent to: `return l = l & r;`
|
| 300 |
+
|
| 301 |
+
``` cpp
|
| 302 |
+
constexpr byte operator&(byte l, byte r) noexcept;
|
| 303 |
+
```
|
| 304 |
+
|
| 305 |
+
*Effects:* Equivalent to:
|
| 306 |
+
|
| 307 |
+
``` cpp
|
| 308 |
+
return static_cast<byte>(static_cast<unsigned int>(l) & static_cast<unsigned int>(r));
|
| 309 |
+
```
|
| 310 |
+
|
| 311 |
+
``` cpp
|
| 312 |
+
constexpr byte& operator^=(byte& l, byte r) noexcept;
|
| 313 |
+
```
|
| 314 |
+
|
| 315 |
+
*Effects:* Equivalent to: `return l = l ^ r;`
|
| 316 |
+
|
| 317 |
+
``` cpp
|
| 318 |
+
constexpr byte operator^(byte l, byte r) noexcept;
|
| 319 |
+
```
|
| 320 |
+
|
| 321 |
+
*Effects:* Equivalent to:
|
| 322 |
+
|
| 323 |
+
``` cpp
|
| 324 |
+
return static_cast<byte>(static_cast<unsigned int>(l) ^ static_cast<unsigned int>(r));
|
| 325 |
+
```
|
| 326 |
+
|
| 327 |
+
``` cpp
|
| 328 |
+
constexpr byte operator~(byte b) noexcept;
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
*Effects:* Equivalent to:
|
| 332 |
+
|
| 333 |
+
``` cpp
|
| 334 |
+
return static_cast<byte>(~static_cast<unsigned int>(b));
|
| 335 |
+
```
|
| 336 |
+
|
| 337 |
+
``` cpp
|
| 338 |
+
template<class IntType>
|
| 339 |
+
constexpr IntType to_integer(byte b) noexcept;
|
| 340 |
+
```
|
| 341 |
+
|
| 342 |
+
*Constraints:* `is_integral_v<IntType>` is `true`.
|
| 343 |
+
|
| 344 |
+
*Effects:* Equivalent to: `return static_cast<IntType>(b);`
|
| 345 |
+
|
| 346 |
+
## Implementation properties <a id="support.limits">[[support.limits]]</a>
|
| 347 |
+
|
| 348 |
+
### General <a id="support.limits.general">[[support.limits.general]]</a>
|
| 349 |
+
|
| 350 |
+
The headers `<limits>`, `<climits>`, and `<cfloat>` supply
|
| 351 |
+
characteristics of implementation-dependent arithmetic types
|
| 352 |
+
[[basic.fundamental]].
|
| 353 |
+
|
| 354 |
+
### Header `<version>` synopsis <a id="version.syn">[[version.syn]]</a>
|
| 355 |
+
|
| 356 |
+
The header `<version>` supplies implementation-dependent information
|
| 357 |
+
about the C++ standard library (e.g., version number and release date).
|
| 358 |
+
|
| 359 |
+
Each of the macros defined in `<version>` is also defined after
|
| 360 |
+
inclusion of any member of the set of library headers indicated in the
|
| 361 |
+
corresponding comment in this synopsis.
|
| 362 |
+
|
| 363 |
+
[*Note 1*: Future versions of this International Standard might replace
|
| 364 |
+
the values of these macros with greater values. — *end note*]
|
| 365 |
+
|
| 366 |
+
``` cpp
|
| 367 |
+
#define __cpp_lib_addressof_constexpr 201603L // also in <memory>
|
| 368 |
+
#define __cpp_lib_allocator_traits_is_always_equal 201411L
|
| 369 |
+
// also in <memory>, <scoped_allocator>, <string>, <deque>, <forward_list>, <list>, <vector>,
|
| 370 |
+
// <map>, <set>, <unordered_map>, <unordered_set>
|
| 371 |
+
#define __cpp_lib_any 201606L // also in <any>
|
| 372 |
+
#define __cpp_lib_apply 201603L // also in <tuple>
|
| 373 |
+
#define __cpp_lib_array_constexpr 201811L // also in <iterator>, <array>
|
| 374 |
+
#define __cpp_lib_as_const 201510L // also in <utility>
|
| 375 |
+
#define __cpp_lib_assume_aligned 201811L // also in <memory>
|
| 376 |
+
#define __cpp_lib_atomic_flag_test 201907L // also in <atomic>
|
| 377 |
+
#define __cpp_lib_atomic_float 201711L // also in <atomic>
|
| 378 |
+
#define __cpp_lib_atomic_is_always_lock_free 201603L // also in <atomic>
|
| 379 |
+
#define __cpp_lib_atomic_lock_free_type_aliases 201907L // also in <atomic>
|
| 380 |
+
#define __cpp_lib_atomic_ref 201806L // also in <atomic>
|
| 381 |
+
#define __cpp_lib_atomic_shared_ptr 201711L // also in <memory>
|
| 382 |
+
#define __cpp_lib_atomic_value_initialization 201911L // also in <atomic>, <memory>
|
| 383 |
+
#define __cpp_lib_atomic_wait 201907L // also in <atomic>
|
| 384 |
+
#define __cpp_lib_barrier 201907L // also in <barrier>
|
| 385 |
+
#define __cpp_lib_bind_front 201907L // also in <functional>
|
| 386 |
+
#define __cpp_lib_bit_cast 201806L // also in <bit>
|
| 387 |
+
#define __cpp_lib_bitops 201907L // also in <bit>
|
| 388 |
+
#define __cpp_lib_bool_constant 201505L // also in <type_traits>
|
| 389 |
+
#define __cpp_lib_bounded_array_traits 201902L // also in <type_traits>
|
| 390 |
+
#define __cpp_lib_boyer_moore_searcher 201603L // also in <functional>
|
| 391 |
+
#define __cpp_lib_byte 201603L // also in <cstddef>
|
| 392 |
+
#define __cpp_lib_char8_t 201907L
|
| 393 |
+
// also in <atomic>, <filesystem>, <istream>, <limits>, <locale>, <ostream>, <string>, <string_view>
|
| 394 |
+
#define __cpp_lib_chrono 201907L // also in <chrono>
|
| 395 |
+
#define __cpp_lib_chrono_udls 201304L // also in <chrono>
|
| 396 |
+
#define __cpp_lib_clamp 201603L // also in <algorithm>
|
| 397 |
+
#define __cpp_lib_complex_udls 201309L // also in <complex>
|
| 398 |
+
#define __cpp_lib_concepts 202002L // also in <concepts>
|
| 399 |
+
#define __cpp_lib_constexpr_algorithms 201806L // also in <algorithm>
|
| 400 |
+
#define __cpp_lib_constexpr_complex 201711L // also in <complex>
|
| 401 |
+
#define __cpp_lib_constexpr_dynamic_alloc 201907L // also in <memory>
|
| 402 |
+
#define __cpp_lib_constexpr_functional 201907L // also in <functional>
|
| 403 |
+
#define __cpp_lib_constexpr_iterator 201811L // also in <iterator>
|
| 404 |
+
#define __cpp_lib_constexpr_memory 201811L // also in <memory>
|
| 405 |
+
#define __cpp_lib_constexpr_numeric 201911L // also in <numeric>
|
| 406 |
+
#define __cpp_lib_constexpr_string 201907L // also in <string>
|
| 407 |
+
#define __cpp_lib_constexpr_string_view 201811L // also in <string_view>
|
| 408 |
+
#define __cpp_lib_constexpr_tuple 201811L // also in <tuple>
|
| 409 |
+
#define __cpp_lib_constexpr_utility 201811L // also in <utility>
|
| 410 |
+
#define __cpp_lib_constexpr_vector 201907L // also in <vector>
|
| 411 |
+
#define __cpp_lib_coroutine 201902L // also in <coroutine>
|
| 412 |
+
#define __cpp_lib_destroying_delete 201806L // also in <new>
|
| 413 |
+
#define __cpp_lib_enable_shared_from_this 201603L // also in <memory>
|
| 414 |
+
#define __cpp_lib_endian 201907L // also in <bit>
|
| 415 |
+
#define __cpp_lib_erase_if 202002L
|
| 416 |
+
// also in <string>, <deque>, <forward_list>, <list>, <vector>, <map>, <set>, <unordered_map>,
|
| 417 |
+
// <unordered_set>
|
| 418 |
+
#define __cpp_lib_exchange_function 201304L // also in <utility>
|
| 419 |
+
#define __cpp_lib_execution 201902L // also in <execution>
|
| 420 |
+
#define __cpp_lib_filesystem 201703L // also in <filesystem>
|
| 421 |
+
#define __cpp_lib_format 201907L // also in <format>
|
| 422 |
+
#define __cpp_lib_gcd_lcm 201606L // also in <numeric>
|
| 423 |
+
#define __cpp_lib_generic_associative_lookup 201304L // also in <map>, <set>
|
| 424 |
+
#define __cpp_lib_generic_unordered_lookup 201811L
|
| 425 |
+
// also in <unordered_map>, <unordered_set>
|
| 426 |
+
#define __cpp_lib_hardware_interference_size 201703L // also in <new>
|
| 427 |
+
#define __cpp_lib_has_unique_object_representations 201606L // also in <type_traits>
|
| 428 |
+
#define __cpp_lib_hypot 201603L // also in <cmath>
|
| 429 |
+
#define __cpp_lib_incomplete_container_elements 201505L
|
| 430 |
+
// also in <forward_list>, <list>, <vector>
|
| 431 |
+
#define __cpp_lib_int_pow2 202002L // also in <bit>
|
| 432 |
+
#define __cpp_lib_integer_comparison_functions 202002L // also in <utility>
|
| 433 |
+
#define __cpp_lib_integer_sequence 201304L // also in <utility>
|
| 434 |
+
#define __cpp_lib_integral_constant_callable 201304L // also in <type_traits>
|
| 435 |
+
#define __cpp_lib_interpolate 201902L // also in <cmath>, <numeric>
|
| 436 |
+
#define __cpp_lib_invoke 201411L // also in <functional>
|
| 437 |
+
#define __cpp_lib_is_aggregate 201703L // also in <type_traits>
|
| 438 |
+
#define __cpp_lib_is_constant_evaluated 201811L // also in <type_traits>
|
| 439 |
+
#define __cpp_lib_is_final 201402L // also in <type_traits>
|
| 440 |
+
#define __cpp_lib_is_invocable 201703L // also in <type_traits>
|
| 441 |
+
#define __cpp_lib_is_layout_compatible 201907L // also in <type_traits>
|
| 442 |
+
#define __cpp_lib_is_nothrow_convertible 201806L // also in <type_traits>
|
| 443 |
+
#define __cpp_lib_is_null_pointer 201309L // also in <type_traits>
|
| 444 |
+
#define __cpp_lib_is_pointer_interconvertible 201907L // also in <type_traits>
|
| 445 |
+
#define __cpp_lib_is_swappable 201603L // also in <type_traits>
|
| 446 |
+
#define __cpp_lib_jthread 201911L // also in <stop_token>, <thread>
|
| 447 |
+
#define __cpp_lib_latch 201907L // also in <latch>
|
| 448 |
+
#define __cpp_lib_launder 201606L // also in <new>
|
| 449 |
+
#define __cpp_lib_list_remove_return_type 201806L // also in <forward_list>, <list>
|
| 450 |
+
#define __cpp_lib_logical_traits 201510L // also in <type_traits>
|
| 451 |
+
#define __cpp_lib_make_from_tuple 201606L // also in <tuple>
|
| 452 |
+
#define __cpp_lib_make_reverse_iterator 201402L // also in <iterator>
|
| 453 |
+
#define __cpp_lib_make_unique 201304L // also in <memory>
|
| 454 |
+
#define __cpp_lib_map_try_emplace 201411L // also in <map>
|
| 455 |
+
#define __cpp_lib_math_constants 201907L // also in <numbers>
|
| 456 |
+
#define __cpp_lib_math_special_functions 201603L // also in <cmath>
|
| 457 |
+
#define __cpp_lib_memory_resource 201603L // also in <memory_resource>
|
| 458 |
+
#define __cpp_lib_node_extract 201606L
|
| 459 |
+
// also in <map>, <set>, <unordered_map>, <unordered_set>
|
| 460 |
+
#define __cpp_lib_nonmember_container_access 201411L
|
| 461 |
+
// also in <array>, <deque>, <forward_list>, <iterator>, <list>, <map>, <regex>, <set>, <string>,
|
| 462 |
+
// <unordered_map>, <unordered_set>, <vector>
|
| 463 |
+
#define __cpp_lib_not_fn 201603L // also in <functional>
|
| 464 |
+
#define __cpp_lib_null_iterators 201304L // also in <iterator>
|
| 465 |
+
#define __cpp_lib_optional 201606L // also in <optional>
|
| 466 |
+
#define __cpp_lib_parallel_algorithm 201603L // also in <algorithm>, <numeric>
|
| 467 |
+
#define __cpp_lib_polymorphic_allocator 201902L // also in <memory>
|
| 468 |
+
#define __cpp_lib_quoted_string_io 201304L // also in <iomanip>
|
| 469 |
+
#define __cpp_lib_ranges 201911L
|
| 470 |
+
// also in <algorithm>, <functional>, <iterator>, <memory>, <ranges>
|
| 471 |
+
#define __cpp_lib_raw_memory_algorithms 201606L // also in <memory>
|
| 472 |
+
#define __cpp_lib_remove_cvref 201711L // also in <type_traits>
|
| 473 |
+
#define __cpp_lib_result_of_sfinae 201210L // also in <functional>, <type_traits>
|
| 474 |
+
#define __cpp_lib_robust_nonmodifying_seq_ops 201304L // also in <algorithm>
|
| 475 |
+
#define __cpp_lib_sample 201603L // also in <algorithm>
|
| 476 |
+
#define __cpp_lib_scoped_lock 201703L // also in <mutex>
|
| 477 |
+
#define __cpp_lib_semaphore 201907L // also in <semaphore>
|
| 478 |
+
#define __cpp_lib_shared_mutex 201505L // also in <shared_mutex>
|
| 479 |
+
#define __cpp_lib_shared_ptr_arrays 201707L // also in <memory>
|
| 480 |
+
#define __cpp_lib_shared_ptr_weak_type 201606L // also in <memory>
|
| 481 |
+
#define __cpp_lib_shared_timed_mutex 201402L // also in <shared_mutex>
|
| 482 |
+
#define __cpp_lib_shift 201806L // also in <algorithm>
|
| 483 |
+
#define __cpp_lib_smart_ptr_for_overwrite 202002L // also in <memory>
|
| 484 |
+
#define __cpp_lib_source_location 201907L // also in <source_location>
|
| 485 |
+
#define __cpp_lib_span 202002L // also in <span>
|
| 486 |
+
#define __cpp_lib_ssize 201902L // also in <iterator>
|
| 487 |
+
#define __cpp_lib_starts_ends_with 201711L // also in <string>, <string_view>
|
| 488 |
+
#define __cpp_lib_string_udls 201304L // also in <string>
|
| 489 |
+
#define __cpp_lib_string_view 201803L // also in <string>, <string_view>
|
| 490 |
+
#define __cpp_lib_syncbuf 201803L // also in <syncstream>
|
| 491 |
+
#define __cpp_lib_three_way_comparison 201907L // also in <compare>
|
| 492 |
+
#define __cpp_lib_to_address 201711L // also in <memory>
|
| 493 |
+
#define __cpp_lib_to_array 201907L // also in <array>
|
| 494 |
+
#define __cpp_lib_to_chars 201611L // also in <charconv>
|
| 495 |
+
#define __cpp_lib_transformation_trait_aliases 201304L // also in <type_traits>
|
| 496 |
+
#define __cpp_lib_transparent_operators 201510L // also in <memory>, <functional>
|
| 497 |
+
#define __cpp_lib_tuple_element_t 201402L // also in <tuple>
|
| 498 |
+
#define __cpp_lib_tuples_by_type 201304L // also in <utility>, <tuple>
|
| 499 |
+
#define __cpp_lib_type_identity 201806L // also in <type_traits>
|
| 500 |
+
#define __cpp_lib_type_trait_variable_templates 201510L // also in <type_traits>
|
| 501 |
+
#define __cpp_lib_uncaught_exceptions 201411L // also in <exception>
|
| 502 |
+
#define __cpp_lib_unordered_map_try_emplace 201411L // also in <unordered_map>
|
| 503 |
+
#define __cpp_lib_unwrap_ref 201811L // also in <type_traits>
|
| 504 |
+
#define __cpp_lib_variant 201606L // also in <variant>
|
| 505 |
+
#define __cpp_lib_void_t 201411L // also in <type_traits>
|
| 506 |
+
```
|
| 507 |
+
|
| 508 |
+
### Header `<limits>` synopsis <a id="limits.syn">[[limits.syn]]</a>
|
| 509 |
+
|
| 510 |
+
``` cpp
|
| 511 |
+
namespace std {
|
| 512 |
+
// [fp.style], floating-point type properties
|
| 513 |
+
enum float_round_style;
|
| 514 |
+
enum float_denorm_style;
|
| 515 |
+
|
| 516 |
+
// [numeric.limits], class template numeric_limits
|
| 517 |
+
template<class T> class numeric_limits;
|
| 518 |
+
|
| 519 |
+
template<class T> class numeric_limits<const T>;
|
| 520 |
+
template<class T> class numeric_limits<volatile T>;
|
| 521 |
+
template<class T> class numeric_limits<const volatile T>;
|
| 522 |
+
|
| 523 |
+
template<> class numeric_limits<bool>;
|
| 524 |
+
|
| 525 |
+
template<> class numeric_limits<char>;
|
| 526 |
+
template<> class numeric_limits<signed char>;
|
| 527 |
+
template<> class numeric_limits<unsigned char>;
|
| 528 |
+
template<> class numeric_limits<char8_t>;
|
| 529 |
+
template<> class numeric_limits<char16_t>;
|
| 530 |
+
template<> class numeric_limits<char32_t>;
|
| 531 |
+
template<> class numeric_limits<wchar_t>;
|
| 532 |
+
|
| 533 |
+
template<> class numeric_limits<short>;
|
| 534 |
+
template<> class numeric_limits<int>;
|
| 535 |
+
template<> class numeric_limits<long>;
|
| 536 |
+
template<> class numeric_limits<long long>;
|
| 537 |
+
template<> class numeric_limits<unsigned short>;
|
| 538 |
+
template<> class numeric_limits<unsigned int>;
|
| 539 |
+
template<> class numeric_limits<unsigned long>;
|
| 540 |
+
template<> class numeric_limits<unsigned long long>;
|
| 541 |
+
|
| 542 |
+
template<> class numeric_limits<float>;
|
| 543 |
+
template<> class numeric_limits<double>;
|
| 544 |
+
template<> class numeric_limits<long double>;
|
| 545 |
+
}
|
| 546 |
+
```
|
| 547 |
+
|
| 548 |
+
### Floating-point type properties <a id="fp.style">[[fp.style]]</a>
|
| 549 |
+
|
| 550 |
+
#### Type `float_round_style` <a id="round.style">[[round.style]]</a>
|
| 551 |
+
|
| 552 |
+
``` cpp
|
| 553 |
+
namespace std {
|
| 554 |
+
enum float_round_style {
|
| 555 |
+
round_indeterminate = -1,
|
| 556 |
+
round_toward_zero = 0,
|
| 557 |
+
round_to_nearest = 1,
|
| 558 |
+
round_toward_infinity = 2,
|
| 559 |
+
round_toward_neg_infinity = 3
|
| 560 |
+
};
|
| 561 |
+
}
|
| 562 |
+
```
|
| 563 |
+
|
| 564 |
+
The rounding mode for floating-point arithmetic is characterized by the
|
| 565 |
+
values:
|
| 566 |
+
|
| 567 |
+
- `round_indeterminate` if the rounding style is indeterminable
|
| 568 |
+
- `round_toward_zero` if the rounding style is toward zero
|
| 569 |
+
- `round_to_nearest` if the rounding style is to the nearest
|
| 570 |
+
representable value
|
| 571 |
+
- `round_toward_infinity` if the rounding style is toward infinity
|
| 572 |
+
- `round_toward_neg_infinity` if the rounding style is toward negative
|
| 573 |
+
infinity
|
| 574 |
+
|
| 575 |
+
#### Type `float_denorm_style` <a id="denorm.style">[[denorm.style]]</a>
|
| 576 |
+
|
| 577 |
+
``` cpp
|
| 578 |
+
namespace std {
|
| 579 |
+
enum float_denorm_style {
|
| 580 |
+
denorm_indeterminate = -1,
|
| 581 |
+
denorm_absent = 0,
|
| 582 |
+
denorm_present = 1
|
| 583 |
+
};
|
| 584 |
+
}
|
| 585 |
+
```
|
| 586 |
+
|
| 587 |
+
The presence or absence of subnormal numbers (variable number of
|
| 588 |
+
exponent bits) is characterized by the values:
|
| 589 |
+
|
| 590 |
+
- `denorm_indeterminate` if it cannot be determined whether or not the
|
| 591 |
+
type allows subnormal values
|
| 592 |
+
- `denorm_absent` if the type does not allow subnormal values
|
| 593 |
+
- `denorm_present` if the type does allow subnormal values
|
| 594 |
+
|
| 595 |
+
### Class template `numeric_limits` <a id="numeric.limits">[[numeric.limits]]</a>
|
| 596 |
+
|
| 597 |
+
The `numeric_limits` class template provides a C++ program with
|
| 598 |
+
information about various properties of the implementation’s
|
| 599 |
+
representation of the arithmetic types.
|
| 600 |
+
|
| 601 |
+
``` cpp
|
| 602 |
+
namespace std {
|
| 603 |
+
template<class T> class numeric_limits {
|
| 604 |
+
public:
|
| 605 |
+
static constexpr bool is_specialized = false;
|
| 606 |
+
static constexpr T min() noexcept { return T(); }
|
| 607 |
+
static constexpr T max() noexcept { return T(); }
|
| 608 |
+
static constexpr T lowest() noexcept { return T(); }
|
| 609 |
+
|
| 610 |
+
static constexpr int digits = 0;
|
| 611 |
+
static constexpr int digits10 = 0;
|
| 612 |
+
static constexpr int max_digits10 = 0;
|
| 613 |
+
static constexpr bool is_signed = false;
|
| 614 |
+
static constexpr bool is_integer = false;
|
| 615 |
+
static constexpr bool is_exact = false;
|
| 616 |
+
static constexpr int radix = 0;
|
| 617 |
+
static constexpr T epsilon() noexcept { return T(); }
|
| 618 |
+
static constexpr T round_error() noexcept { return T(); }
|
| 619 |
+
|
| 620 |
+
static constexpr int min_exponent = 0;
|
| 621 |
+
static constexpr int min_exponent10 = 0;
|
| 622 |
+
static constexpr int max_exponent = 0;
|
| 623 |
+
static constexpr int max_exponent10 = 0;
|
| 624 |
+
|
| 625 |
+
static constexpr bool has_infinity = false;
|
| 626 |
+
static constexpr bool has_quiet_NaN = false;
|
| 627 |
+
static constexpr bool has_signaling_NaN = false;
|
| 628 |
+
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 629 |
+
static constexpr bool has_denorm_loss = false;
|
| 630 |
+
static constexpr T infinity() noexcept { return T(); }
|
| 631 |
+
static constexpr T quiet_NaN() noexcept { return T(); }
|
| 632 |
+
static constexpr T signaling_NaN() noexcept { return T(); }
|
| 633 |
+
static constexpr T denorm_min() noexcept { return T(); }
|
| 634 |
+
|
| 635 |
+
static constexpr bool is_iec559 = false;
|
| 636 |
+
static constexpr bool is_bounded = false;
|
| 637 |
+
static constexpr bool is_modulo = false;
|
| 638 |
+
|
| 639 |
+
static constexpr bool traps = false;
|
| 640 |
+
static constexpr bool tinyness_before = false;
|
| 641 |
+
static constexpr float_round_style round_style = round_toward_zero;
|
| 642 |
+
};
|
| 643 |
+
}
|
| 644 |
+
```
|
| 645 |
+
|
| 646 |
+
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 647 |
+
template, specializations shall define these values in such a way that
|
| 648 |
+
they are usable as constant expressions.
|
| 649 |
+
|
| 650 |
+
The default `numeric_limits<T>` template shall have all members, but
|
| 651 |
+
with 0 or `false` values.
|
| 652 |
+
|
| 653 |
+
Specializations shall be provided for each arithmetic type, both
|
| 654 |
+
floating-point and integer, including `bool`. The member
|
| 655 |
+
`is_specialized` shall be `true` for all such specializations of
|
| 656 |
+
`numeric_limits`.
|
| 657 |
+
|
| 658 |
+
The value of each member of a specialization of `numeric_limits` on a
|
| 659 |
+
cv-qualified type `cv T` shall be equal to the value of the
|
| 660 |
+
corresponding member of the specialization on the unqualified type `T`.
|
| 661 |
+
|
| 662 |
+
Non-arithmetic standard types, such as `complex<T>` [[complex]], shall
|
| 663 |
+
not have specializations.
|
| 664 |
+
|
| 665 |
+
#### `numeric_limits` members <a id="numeric.limits.members">[[numeric.limits.members]]</a>
|
| 666 |
+
|
| 667 |
+
Each member function defined in this subclause is signal-safe
|
| 668 |
+
[[support.signal]].
|
| 669 |
+
|
| 670 |
+
``` cpp
|
| 671 |
+
static constexpr T min() noexcept;
|
| 672 |
+
```
|
| 673 |
+
|
| 674 |
+
Minimum finite value.[^3]
|
| 675 |
+
|
| 676 |
+
For floating-point types with subnormal numbers, returns the minimum
|
| 677 |
+
positive normalized value.
|
| 678 |
+
|
| 679 |
+
Meaningful for all specializations in which `is_bounded != false`, or
|
| 680 |
+
`is_bounded == false && is_signed == false`.
|
| 681 |
+
|
| 682 |
+
``` cpp
|
| 683 |
+
static constexpr T max() noexcept;
|
| 684 |
+
```
|
| 685 |
+
|
| 686 |
+
Maximum finite value.[^4]
|
| 687 |
+
|
| 688 |
+
Meaningful for all specializations in which `is_bounded != false`.
|
| 689 |
+
|
| 690 |
+
``` cpp
|
| 691 |
+
static constexpr T lowest() noexcept;
|
| 692 |
+
```
|
| 693 |
+
|
| 694 |
+
A finite value `x` such that there is no other finite value `y` where
|
| 695 |
+
`y < x`.[^5]
|
| 696 |
+
|
| 697 |
+
Meaningful for all specializations in which `is_bounded != false`.
|
| 698 |
+
|
| 699 |
+
``` cpp
|
| 700 |
+
static constexpr int digits;
|
| 701 |
+
```
|
| 702 |
+
|
| 703 |
+
Number of `radix` digits that can be represented without change.
|
| 704 |
+
|
| 705 |
+
For integer types, the number of non-sign bits in the representation.
|
| 706 |
+
|
| 707 |
+
For floating-point types, the number of `radix` digits in the
|
| 708 |
+
mantissa.[^6]
|
| 709 |
+
|
| 710 |
+
``` cpp
|
| 711 |
+
static constexpr int digits10;
|
| 712 |
+
```
|
| 713 |
+
|
| 714 |
+
Number of base 10 digits that can be represented without change.[^7]
|
| 715 |
+
|
| 716 |
+
Meaningful for all specializations in which `is_bounded != false`.
|
| 717 |
+
|
| 718 |
+
``` cpp
|
| 719 |
+
static constexpr int max_digits10;
|
| 720 |
+
```
|
| 721 |
+
|
| 722 |
+
Number of base 10 digits required to ensure that values which differ are
|
| 723 |
+
always differentiated.
|
| 724 |
+
|
| 725 |
+
Meaningful for all floating-point types.
|
| 726 |
+
|
| 727 |
+
``` cpp
|
| 728 |
+
static constexpr bool is_signed;
|
| 729 |
+
```
|
| 730 |
+
|
| 731 |
+
`true` if the type is signed.
|
| 732 |
+
|
| 733 |
+
Meaningful for all specializations.
|
| 734 |
+
|
| 735 |
+
``` cpp
|
| 736 |
+
static constexpr bool is_integer;
|
| 737 |
+
```
|
| 738 |
+
|
| 739 |
+
`true` if the type is integer.
|
| 740 |
+
|
| 741 |
+
Meaningful for all specializations.
|
| 742 |
+
|
| 743 |
+
``` cpp
|
| 744 |
+
static constexpr bool is_exact;
|
| 745 |
+
```
|
| 746 |
+
|
| 747 |
+
`true` if the type uses an exact representation. All integer types are
|
| 748 |
+
exact, but not all exact types are integer. For example, rational and
|
| 749 |
+
fixed-exponent representations are exact but not integer.
|
| 750 |
+
|
| 751 |
+
Meaningful for all specializations.
|
| 752 |
+
|
| 753 |
+
``` cpp
|
| 754 |
+
static constexpr int radix;
|
| 755 |
+
```
|
| 756 |
+
|
| 757 |
+
For floating-point types, specifies the base or radix of the exponent
|
| 758 |
+
representation (often 2).[^8]
|
| 759 |
+
|
| 760 |
+
For integer types, specifies the base of the representation.[^9]
|
| 761 |
+
|
| 762 |
+
Meaningful for all specializations.
|
| 763 |
+
|
| 764 |
+
``` cpp
|
| 765 |
+
static constexpr T epsilon() noexcept;
|
| 766 |
+
```
|
| 767 |
+
|
| 768 |
+
Machine epsilon: the difference between 1 and the least value greater
|
| 769 |
+
than 1 that is representable.[^10]
|
| 770 |
+
|
| 771 |
+
Meaningful for all floating-point types.
|
| 772 |
+
|
| 773 |
+
``` cpp
|
| 774 |
+
static constexpr T round_error() noexcept;
|
| 775 |
+
```
|
| 776 |
+
|
| 777 |
+
Measure of the maximum rounding error.[^11]
|
| 778 |
+
|
| 779 |
+
``` cpp
|
| 780 |
+
static constexpr int min_exponent;
|
| 781 |
+
```
|
| 782 |
+
|
| 783 |
+
Minimum negative integer such that `radix` raised to the power of one
|
| 784 |
+
less than that integer is a normalized floating-point number.[^12]
|
| 785 |
+
|
| 786 |
+
Meaningful for all floating-point types.
|
| 787 |
+
|
| 788 |
+
``` cpp
|
| 789 |
+
static constexpr int min_exponent10;
|
| 790 |
+
```
|
| 791 |
+
|
| 792 |
+
Minimum negative integer such that 10 raised to that power is in the
|
| 793 |
+
range of normalized floating-point numbers.[^13]
|
| 794 |
+
|
| 795 |
+
Meaningful for all floating-point types.
|
| 796 |
+
|
| 797 |
+
``` cpp
|
| 798 |
+
static constexpr int max_exponent;
|
| 799 |
+
```
|
| 800 |
+
|
| 801 |
+
Maximum positive integer such that `radix` raised to the power one less
|
| 802 |
+
than that integer is a representable finite floating-point number.[^14]
|
| 803 |
+
|
| 804 |
+
Meaningful for all floating-point types.
|
| 805 |
+
|
| 806 |
+
``` cpp
|
| 807 |
+
static constexpr int max_exponent10;
|
| 808 |
+
```
|
| 809 |
+
|
| 810 |
+
Maximum positive integer such that 10 raised to that power is in the
|
| 811 |
+
range of representable finite floating-point numbers.[^15]
|
| 812 |
+
|
| 813 |
+
Meaningful for all floating-point types.
|
| 814 |
+
|
| 815 |
+
``` cpp
|
| 816 |
+
static constexpr bool has_infinity;
|
| 817 |
+
```
|
| 818 |
+
|
| 819 |
+
`true` if the type has a representation for positive infinity.
|
| 820 |
+
|
| 821 |
+
Meaningful for all floating-point types.
|
| 822 |
+
|
| 823 |
+
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 824 |
+
|
| 825 |
+
``` cpp
|
| 826 |
+
static constexpr bool has_quiet_NaN;
|
| 827 |
+
```
|
| 828 |
+
|
| 829 |
+
`true` if the type has a representation for a quiet (non-signaling) “Not
|
| 830 |
+
a Number”.[^16]
|
| 831 |
+
|
| 832 |
+
Meaningful for all floating-point types.
|
| 833 |
+
|
| 834 |
+
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 835 |
+
|
| 836 |
+
``` cpp
|
| 837 |
+
static constexpr bool has_signaling_NaN;
|
| 838 |
+
```
|
| 839 |
+
|
| 840 |
+
`true` if the type has a representation for a signaling “Not a
|
| 841 |
+
Number”.[^17]
|
| 842 |
+
|
| 843 |
+
Meaningful for all floating-point types.
|
| 844 |
+
|
| 845 |
+
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 846 |
+
|
| 847 |
+
``` cpp
|
| 848 |
+
static constexpr float_denorm_style has_denorm;
|
| 849 |
+
```
|
| 850 |
+
|
| 851 |
+
`denorm_present` if the type allows subnormal values (variable number of
|
| 852 |
+
exponent bits)[^18], `denorm_absent` if the type does not allow
|
| 853 |
+
subnormal values, and `denorm_indeterminate` if it is indeterminate at
|
| 854 |
+
compile time whether the type allows subnormal values.
|
| 855 |
+
|
| 856 |
+
Meaningful for all floating-point types.
|
| 857 |
+
|
| 858 |
+
``` cpp
|
| 859 |
+
static constexpr bool has_denorm_loss;
|
| 860 |
+
```
|
| 861 |
+
|
| 862 |
+
`true` if loss of accuracy is detected as a denormalization loss, rather
|
| 863 |
+
than as an inexact result.[^19]
|
| 864 |
+
|
| 865 |
+
``` cpp
|
| 866 |
+
static constexpr T infinity() noexcept;
|
| 867 |
+
```
|
| 868 |
+
|
| 869 |
+
Representation of positive infinity, if available.[^20]
|
| 870 |
+
|
| 871 |
+
Meaningful for all specializations for which `has_infinity != false`.
|
| 872 |
+
Required in specializations for which `is_iec559 != false`.
|
| 873 |
+
|
| 874 |
+
``` cpp
|
| 875 |
+
static constexpr T quiet_NaN() noexcept;
|
| 876 |
+
```
|
| 877 |
+
|
| 878 |
+
Representation of a quiet “Not a Number”, if available.[^21]
|
| 879 |
+
|
| 880 |
+
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 881 |
+
Required in specializations for which `is_iec559 != false`.
|
| 882 |
+
|
| 883 |
+
``` cpp
|
| 884 |
+
static constexpr T signaling_NaN() noexcept;
|
| 885 |
+
```
|
| 886 |
+
|
| 887 |
+
Representation of a signaling “Not a Number”, if available.[^22]
|
| 888 |
+
|
| 889 |
+
Meaningful for all specializations for which
|
| 890 |
+
`has_signaling_NaN != false`. Required in specializations for which
|
| 891 |
+
`is_iec559 != false`.
|
| 892 |
+
|
| 893 |
+
``` cpp
|
| 894 |
+
static constexpr T denorm_min() noexcept;
|
| 895 |
+
```
|
| 896 |
+
|
| 897 |
+
Minimum positive subnormal value.[^23]
|
| 898 |
+
|
| 899 |
+
Meaningful for all floating-point types.
|
| 900 |
+
|
| 901 |
+
In specializations for which `has_denorm == false`, returns the minimum
|
| 902 |
+
positive normalized value.
|
| 903 |
+
|
| 904 |
+
``` cpp
|
| 905 |
+
static constexpr bool is_iec559;
|
| 906 |
+
```
|
| 907 |
+
|
| 908 |
+
`true` if and only if the type adheres to ISO/IEC/IEEE 60559.[^24]
|
| 909 |
+
|
| 910 |
+
Meaningful for all floating-point types.
|
| 911 |
+
|
| 912 |
+
``` cpp
|
| 913 |
+
static constexpr bool is_bounded;
|
| 914 |
+
```
|
| 915 |
+
|
| 916 |
+
`true` if the set of values representable by the type is finite.[^25]
|
| 917 |
+
|
| 918 |
+
[*Note 1*: All fundamental types [[basic.fundamental]] are bounded.
|
| 919 |
+
This member would be `false` for arbitrary precision
|
| 920 |
+
types. — *end note*]
|
| 921 |
+
|
| 922 |
+
Meaningful for all specializations.
|
| 923 |
+
|
| 924 |
+
``` cpp
|
| 925 |
+
static constexpr bool is_modulo;
|
| 926 |
+
```
|
| 927 |
+
|
| 928 |
+
`true` if the type is modulo.[^26] A type is modulo if, for any
|
| 929 |
+
operation involving `+`, `-`, or `*` on values of that type whose result
|
| 930 |
+
would fall outside the range \[`min()`, `max()`\], the value returned
|
| 931 |
+
differs from the true value by an integer multiple of
|
| 932 |
+
`max() - min() + 1`.
|
| 933 |
+
|
| 934 |
+
[*Example 1*: `is_modulo` is `false` for signed integer
|
| 935 |
+
types [[basic.fundamental]] unless an implementation, as an extension to
|
| 936 |
+
this document, defines signed integer overflow to
|
| 937 |
+
wrap. — *end example*]
|
| 938 |
+
|
| 939 |
+
Meaningful for all specializations.
|
| 940 |
+
|
| 941 |
+
``` cpp
|
| 942 |
+
static constexpr bool traps;
|
| 943 |
+
```
|
| 944 |
+
|
| 945 |
+
`true` if, at the start of the program, there exists a value of the type
|
| 946 |
+
that would cause an arithmetic operation using that value to trap.[^27]
|
| 947 |
+
|
| 948 |
+
Meaningful for all specializations.
|
| 949 |
+
|
| 950 |
+
``` cpp
|
| 951 |
+
static constexpr bool tinyness_before;
|
| 952 |
+
```
|
| 953 |
+
|
| 954 |
+
`true` if tinyness is detected before rounding.[^28]
|
| 955 |
+
|
| 956 |
+
Meaningful for all floating-point types.
|
| 957 |
+
|
| 958 |
+
``` cpp
|
| 959 |
+
static constexpr float_round_style round_style;
|
| 960 |
+
```
|
| 961 |
+
|
| 962 |
+
The rounding style for the type.[^29]
|
| 963 |
+
|
| 964 |
+
Meaningful for all floating-point types. Specializations for integer
|
| 965 |
+
types shall return `round_toward_zero`.
|
| 966 |
+
|
| 967 |
+
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
| 968 |
+
|
| 969 |
+
All members shall be provided for all specializations. However, many
|
| 970 |
+
values are only required to be meaningful under certain conditions (for
|
| 971 |
+
example, `epsilon()` is only meaningful if `is_integer` is `false`). Any
|
| 972 |
+
value that is not “meaningful” shall be set to 0 or `false`.
|
| 973 |
+
|
| 974 |
+
[*Example 1*:
|
| 975 |
+
|
| 976 |
+
``` cpp
|
| 977 |
+
namespace std {
|
| 978 |
+
template<> class numeric_limits<float> {
|
| 979 |
+
public:
|
| 980 |
+
static constexpr bool is_specialized = true;
|
| 981 |
+
|
| 982 |
+
static constexpr float min() noexcept { return 1.17549435E-38F; }
|
| 983 |
+
static constexpr float max() noexcept { return 3.40282347E+38F; }
|
| 984 |
+
static constexpr float lowest() noexcept { return -3.40282347E+38F; }
|
| 985 |
+
|
| 986 |
+
static constexpr int digits = 24;
|
| 987 |
+
static constexpr int digits10 = 6;
|
| 988 |
+
static constexpr int max_digits10 = 9;
|
| 989 |
+
|
| 990 |
+
static constexpr bool is_signed = true;
|
| 991 |
+
static constexpr bool is_integer = false;
|
| 992 |
+
static constexpr bool is_exact = false;
|
| 993 |
+
|
| 994 |
+
static constexpr int radix = 2;
|
| 995 |
+
static constexpr float epsilon() noexcept { return 1.19209290E-07F; }
|
| 996 |
+
static constexpr float round_error() noexcept { return 0.5F; }
|
| 997 |
+
|
| 998 |
+
static constexpr int min_exponent = -125;
|
| 999 |
+
static constexpr int min_exponent10 = - 37;
|
| 1000 |
+
static constexpr int max_exponent = +128;
|
| 1001 |
+
static constexpr int max_exponent10 = + 38;
|
| 1002 |
+
|
| 1003 |
+
static constexpr bool has_infinity = true;
|
| 1004 |
+
static constexpr bool has_quiet_NaN = true;
|
| 1005 |
+
static constexpr bool has_signaling_NaN = true;
|
| 1006 |
+
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 1007 |
+
static constexpr bool has_denorm_loss = false;
|
| 1008 |
+
|
| 1009 |
+
static constexpr float infinity() noexcept { return value; }
|
| 1010 |
+
static constexpr float quiet_NaN() noexcept { return value; }
|
| 1011 |
+
static constexpr float signaling_NaN() noexcept { return value; }
|
| 1012 |
+
static constexpr float denorm_min() noexcept { return min(); }
|
| 1013 |
+
|
| 1014 |
+
static constexpr bool is_iec559 = true;
|
| 1015 |
+
static constexpr bool is_bounded = true;
|
| 1016 |
+
static constexpr bool is_modulo = false;
|
| 1017 |
+
static constexpr bool traps = true;
|
| 1018 |
+
static constexpr bool tinyness_before = true;
|
| 1019 |
+
|
| 1020 |
+
static constexpr float_round_style round_style = round_to_nearest;
|
| 1021 |
+
};
|
| 1022 |
+
}
|
| 1023 |
+
```
|
| 1024 |
+
|
| 1025 |
+
— *end example*]
|
| 1026 |
+
|
| 1027 |
+
The specialization for `bool` shall be provided as follows:
|
| 1028 |
+
|
| 1029 |
+
``` cpp
|
| 1030 |
+
namespace std {
|
| 1031 |
+
template<> class numeric_limits<bool> {
|
| 1032 |
+
public:
|
| 1033 |
+
static constexpr bool is_specialized = true;
|
| 1034 |
+
static constexpr bool min() noexcept { return false; }
|
| 1035 |
+
static constexpr bool max() noexcept { return true; }
|
| 1036 |
+
static constexpr bool lowest() noexcept { return false; }
|
| 1037 |
+
|
| 1038 |
+
static constexpr int digits = 1;
|
| 1039 |
+
static constexpr int digits10 = 0;
|
| 1040 |
+
static constexpr int max_digits10 = 0;
|
| 1041 |
+
|
| 1042 |
+
static constexpr bool is_signed = false;
|
| 1043 |
+
static constexpr bool is_integer = true;
|
| 1044 |
+
static constexpr bool is_exact = true;
|
| 1045 |
+
static constexpr int radix = 2;
|
| 1046 |
+
static constexpr bool epsilon() noexcept { return 0; }
|
| 1047 |
+
static constexpr bool round_error() noexcept { return 0; }
|
| 1048 |
+
|
| 1049 |
+
static constexpr int min_exponent = 0;
|
| 1050 |
+
static constexpr int min_exponent10 = 0;
|
| 1051 |
+
static constexpr int max_exponent = 0;
|
| 1052 |
+
static constexpr int max_exponent10 = 0;
|
| 1053 |
+
|
| 1054 |
+
static constexpr bool has_infinity = false;
|
| 1055 |
+
static constexpr bool has_quiet_NaN = false;
|
| 1056 |
+
static constexpr bool has_signaling_NaN = false;
|
| 1057 |
+
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 1058 |
+
static constexpr bool has_denorm_loss = false;
|
| 1059 |
+
static constexpr bool infinity() noexcept { return 0; }
|
| 1060 |
+
static constexpr bool quiet_NaN() noexcept { return 0; }
|
| 1061 |
+
static constexpr bool signaling_NaN() noexcept { return 0; }
|
| 1062 |
+
static constexpr bool denorm_min() noexcept { return 0; }
|
| 1063 |
+
|
| 1064 |
+
static constexpr bool is_iec559 = false;
|
| 1065 |
+
static constexpr bool is_bounded = true;
|
| 1066 |
+
static constexpr bool is_modulo = false;
|
| 1067 |
+
|
| 1068 |
+
static constexpr bool traps = false;
|
| 1069 |
+
static constexpr bool tinyness_before = false;
|
| 1070 |
+
static constexpr float_round_style round_style = round_toward_zero;
|
| 1071 |
+
};
|
| 1072 |
+
}
|
| 1073 |
+
```
|
| 1074 |
+
|
| 1075 |
+
### Header `<climits>` synopsis <a id="climits.syn">[[climits.syn]]</a>
|
| 1076 |
+
|
| 1077 |
+
``` cpp
|
| 1078 |
+
#define CHAR_BIT see below
|
| 1079 |
+
#define SCHAR_MIN see below
|
| 1080 |
+
#define SCHAR_MAX see below
|
| 1081 |
+
#define UCHAR_MAX see below
|
| 1082 |
+
#define CHAR_MIN see below
|
| 1083 |
+
#define CHAR_MAX see below
|
| 1084 |
+
#define MB_LEN_MAX see below
|
| 1085 |
+
#define SHRT_MIN see below
|
| 1086 |
+
#define SHRT_MAX see below
|
| 1087 |
+
#define USHRT_MAX see below
|
| 1088 |
+
#define INT_MIN see below
|
| 1089 |
+
#define INT_MAX see below
|
| 1090 |
+
#define UINT_MAX see below
|
| 1091 |
+
#define LONG_MIN see below
|
| 1092 |
+
#define LONG_MAX see below
|
| 1093 |
+
#define ULONG_MAX see below
|
| 1094 |
+
#define LLONG_MIN see below
|
| 1095 |
+
#define LLONG_MAX see below
|
| 1096 |
+
#define ULLONG_MAX see below
|
| 1097 |
+
```
|
| 1098 |
+
|
| 1099 |
+
The header `<climits>` defines all macros the same as the C standard
|
| 1100 |
+
library header `<limits.h>`.
|
| 1101 |
+
|
| 1102 |
+
[*Note 1*: The types of the constants defined by macros in `<climits>`
|
| 1103 |
+
are not required to match the types to which the macros
|
| 1104 |
+
refer. — *end note*]
|
| 1105 |
+
|
| 1106 |
+
See also: ISO C 5.2.4.2.1
|
| 1107 |
+
|
| 1108 |
+
### Header `<cfloat>` synopsis <a id="cfloat.syn">[[cfloat.syn]]</a>
|
| 1109 |
+
|
| 1110 |
+
``` cpp
|
| 1111 |
+
#define FLT_ROUNDS see below
|
| 1112 |
+
#define FLT_EVAL_METHOD see below
|
| 1113 |
+
#define FLT_HAS_SUBNORM see below
|
| 1114 |
+
#define DBL_HAS_SUBNORM see below
|
| 1115 |
+
#define LDBL_HAS_SUBNORM see below
|
| 1116 |
+
#define FLT_RADIX see below
|
| 1117 |
+
#define FLT_MANT_DIG see below
|
| 1118 |
+
#define DBL_MANT_DIG see below
|
| 1119 |
+
#define LDBL_MANT_DIG see below
|
| 1120 |
+
#define FLT_DECIMAL_DIG see below
|
| 1121 |
+
#define DBL_DECIMAL_DIG see below
|
| 1122 |
+
#define LDBL_DECIMAL_DIG see below
|
| 1123 |
+
#define DECIMAL_DIG see below
|
| 1124 |
+
#define FLT_DIG see below
|
| 1125 |
+
#define DBL_DIG see below
|
| 1126 |
+
#define LDBL_DIG see below
|
| 1127 |
+
#define FLT_MIN_EXP see below
|
| 1128 |
+
#define DBL_MIN_EXP see below
|
| 1129 |
+
#define LDBL_MIN_EXP see below
|
| 1130 |
+
#define FLT_MIN_10_EXP see below
|
| 1131 |
+
#define DBL_MIN_10_EXP see below
|
| 1132 |
+
#define LDBL_MIN_10_EXP see below
|
| 1133 |
+
#define FLT_MAX_EXP see below
|
| 1134 |
+
#define DBL_MAX_EXP see below
|
| 1135 |
+
#define LDBL_MAX_EXP see below
|
| 1136 |
+
#define FLT_MAX_10_EXP see below
|
| 1137 |
+
#define DBL_MAX_10_EXP see below
|
| 1138 |
+
#define LDBL_MAX_10_EXP see below
|
| 1139 |
+
#define FLT_MAX see below
|
| 1140 |
+
#define DBL_MAX see below
|
| 1141 |
+
#define LDBL_MAX see below
|
| 1142 |
+
#define FLT_EPSILON see below
|
| 1143 |
+
#define DBL_EPSILON see below
|
| 1144 |
+
#define LDBL_EPSILON see below
|
| 1145 |
+
#define FLT_MIN see below
|
| 1146 |
+
#define DBL_MIN see below
|
| 1147 |
+
#define LDBL_MIN see below
|
| 1148 |
+
#define FLT_TRUE_MIN see below
|
| 1149 |
+
#define DBL_TRUE_MIN see below
|
| 1150 |
+
#define LDBL_TRUE_MIN see below
|
| 1151 |
+
```
|
| 1152 |
+
|
| 1153 |
+
The header `<cfloat>` defines all macros the same as the C standard
|
| 1154 |
+
library header `<float.h>`.
|
| 1155 |
+
|
| 1156 |
+
See also: ISO C 5.2.4.2.2
|
| 1157 |
+
|
| 1158 |
+
## Integer types <a id="cstdint">[[cstdint]]</a>
|
| 1159 |
+
|
| 1160 |
+
### Header `<cstdint>` synopsis <a id="cstdint.syn">[[cstdint.syn]]</a>
|
| 1161 |
+
|
| 1162 |
+
``` cpp
|
| 1163 |
+
namespace std {
|
| 1164 |
+
using int8_t = signed integer type; // optional
|
| 1165 |
+
using int16_t = signed integer type; // optional
|
| 1166 |
+
using int32_t = signed integer type; // optional
|
| 1167 |
+
using int64_t = signed integer type; // optional
|
| 1168 |
+
|
| 1169 |
+
using int_fast8_t = signed integer type;
|
| 1170 |
+
using int_fast16_t = signed integer type;
|
| 1171 |
+
using int_fast32_t = signed integer type;
|
| 1172 |
+
using int_fast64_t = signed integer type;
|
| 1173 |
+
|
| 1174 |
+
using int_least8_t = signed integer type;
|
| 1175 |
+
using int_least16_t = signed integer type;
|
| 1176 |
+
using int_least32_t = signed integer type;
|
| 1177 |
+
using int_least64_t = signed integer type;
|
| 1178 |
+
|
| 1179 |
+
using intmax_t = signed integer type;
|
| 1180 |
+
using intptr_t = signed integer type; // optional
|
| 1181 |
+
|
| 1182 |
+
using uint8_t = unsigned integer type; // optional
|
| 1183 |
+
using uint16_t = unsigned integer type; // optional
|
| 1184 |
+
using uint32_t = unsigned integer type; // optional
|
| 1185 |
+
using uint64_t = unsigned integer type; // optional
|
| 1186 |
+
|
| 1187 |
+
using uint_fast8_t = unsigned integer type;
|
| 1188 |
+
using uint_fast16_t = unsigned integer type;
|
| 1189 |
+
using uint_fast32_t = unsigned integer type;
|
| 1190 |
+
using uint_fast64_t = unsigned integer type;
|
| 1191 |
+
|
| 1192 |
+
using uint_least8_t = unsigned integer type;
|
| 1193 |
+
using uint_least16_t = unsigned integer type;
|
| 1194 |
+
using uint_least32_t = unsigned integer type;
|
| 1195 |
+
using uint_least64_t = unsigned integer type;
|
| 1196 |
+
|
| 1197 |
+
using uintmax_t = unsigned integer type;
|
| 1198 |
+
using uintptr_t = unsigned integer type; // optional
|
| 1199 |
+
}
|
| 1200 |
+
```
|
| 1201 |
+
|
| 1202 |
+
The header also defines numerous macros of the form:
|
| 1203 |
+
|
| 1204 |
+
``` cpp
|
| 1205 |
+
INT_[FAST LEAST]{8 16 32 64}_MIN
|
| 1206 |
+
[U]INT_[FAST LEAST]{8 16 32 64}_MAX
|
| 1207 |
+
INT{MAX PTR}_MIN
|
| 1208 |
+
[U]INT{MAX PTR}_MAX
|
| 1209 |
+
{PTRDIFF SIG_ATOMIC WCHAR WINT}{_MAX _MIN}
|
| 1210 |
+
SIZE_MAX
|
| 1211 |
+
```
|
| 1212 |
+
|
| 1213 |
+
plus function macros of the form:
|
| 1214 |
+
|
| 1215 |
+
``` cpp
|
| 1216 |
+
[U]INT{8 16 32 64 MAX}_C
|
| 1217 |
+
```
|
| 1218 |
+
|
| 1219 |
+
The header defines all types and macros the same as the C standard
|
| 1220 |
+
library header `<stdint.h>`.
|
| 1221 |
+
|
| 1222 |
+
See also: ISO C 7.20
|
| 1223 |
+
|
| 1224 |
+
## Startup and termination <a id="support.start.term">[[support.start.term]]</a>
|
| 1225 |
+
|
| 1226 |
+
[*Note 1*: The header `<cstdlib>` declares the functions described in
|
| 1227 |
+
this subclause. — *end note*]
|
| 1228 |
+
|
| 1229 |
+
``` cpp
|
| 1230 |
+
[[noreturn]] void _Exit(int status) noexcept;
|
| 1231 |
+
```
|
| 1232 |
+
|
| 1233 |
+
*Effects:* This function has the semantics specified in the C standard
|
| 1234 |
+
library.
|
| 1235 |
+
|
| 1236 |
+
*Remarks:* The program is terminated without executing destructors for
|
| 1237 |
+
objects of automatic, thread, or static storage duration and without
|
| 1238 |
+
calling functions passed to `atexit()` [[basic.start.term]]. The
|
| 1239 |
+
function `_Exit` is signal-safe [[support.signal]].
|
| 1240 |
+
|
| 1241 |
+
``` cpp
|
| 1242 |
+
[[noreturn]] void abort() noexcept;
|
| 1243 |
+
```
|
| 1244 |
+
|
| 1245 |
+
*Effects:* This function has the semantics specified in the C standard
|
| 1246 |
+
library.
|
| 1247 |
+
|
| 1248 |
+
*Remarks:* The program is terminated without executing destructors for
|
| 1249 |
+
objects of automatic, thread, or static storage duration and without
|
| 1250 |
+
calling functions passed to `atexit()` [[basic.start.term]]. The
|
| 1251 |
+
function `abort` is signal-safe [[support.signal]].
|
| 1252 |
+
|
| 1253 |
+
``` cpp
|
| 1254 |
+
int atexit(c-atexit-handler* f) noexcept;
|
| 1255 |
+
int atexit(atexit-handler* f) noexcept;
|
| 1256 |
+
```
|
| 1257 |
+
|
| 1258 |
+
*Effects:* The `atexit()` functions register the function pointed to by
|
| 1259 |
+
`f` to be called without arguments at normal program termination. It is
|
| 1260 |
+
unspecified whether a call to `atexit()` that does not happen
|
| 1261 |
+
before [[intro.multithread]] a call to `exit()` will succeed.
|
| 1262 |
+
|
| 1263 |
+
[*Note 1*: The `atexit()` functions do not introduce a data
|
| 1264 |
+
race [[res.on.data.races]]. — *end note*]
|
| 1265 |
+
|
| 1266 |
+
*Implementation limits:* The implementation shall support the
|
| 1267 |
+
registration of at least 32 functions.
|
| 1268 |
+
|
| 1269 |
+
*Returns:* The `atexit()` function returns zero if the registration
|
| 1270 |
+
succeeds, nonzero if it fails.
|
| 1271 |
+
|
| 1272 |
+
``` cpp
|
| 1273 |
+
[[noreturn]] void exit(int status);
|
| 1274 |
+
```
|
| 1275 |
+
|
| 1276 |
+
*Effects:*
|
| 1277 |
+
|
| 1278 |
+
- First, objects with thread storage duration and associated with the
|
| 1279 |
+
current thread are destroyed. Next, objects with static storage
|
| 1280 |
+
duration are destroyed and functions registered by calling `atexit`
|
| 1281 |
+
are called.[^30] See [[basic.start.term]] for the order of
|
| 1282 |
+
destructions and calls. (Objects with automatic storage duration are
|
| 1283 |
+
not destroyed as a result of calling `exit()`.)[^31] If control leaves
|
| 1284 |
+
a registered function called by `exit` because the function does not
|
| 1285 |
+
provide a handler for a thrown exception, the function
|
| 1286 |
+
`std::terminate` shall be called [[except.terminate]].
|
| 1287 |
+
- Next, all open C streams (as mediated by the function signatures
|
| 1288 |
+
declared in `<cstdio>`) with unwritten buffered data are flushed, all
|
| 1289 |
+
open C streams are closed, and all files created by calling
|
| 1290 |
+
`tmpfile()` are removed.
|
| 1291 |
+
- Finally, control is returned to the host environment. If `status` is
|
| 1292 |
+
zero or `EXIT_SUCCESS`, an *implementation-defined* form of the status
|
| 1293 |
+
*successful termination* is returned. If `status` is `EXIT_FAILURE`,
|
| 1294 |
+
an *implementation-defined* form of the status *unsuccessful
|
| 1295 |
+
termination* is returned. Otherwise the status returned is
|
| 1296 |
+
*implementation-defined*. [^32]
|
| 1297 |
+
|
| 1298 |
+
``` cpp
|
| 1299 |
+
int at_quick_exit(c-atexit-handler* f) noexcept;
|
| 1300 |
+
int at_quick_exit(atexit-handler* f) noexcept;
|
| 1301 |
+
```
|
| 1302 |
+
|
| 1303 |
+
*Effects:* The `at_quick_exit()` functions register the function pointed
|
| 1304 |
+
to by `f` to be called without arguments when `quick_exit` is called. It
|
| 1305 |
+
is unspecified whether a call to `at_quick_exit()` that does not happen
|
| 1306 |
+
before [[intro.multithread]] all calls to `quick_exit` will succeed.
|
| 1307 |
+
|
| 1308 |
+
[*Note 2*: The `at_quick_exit()` functions do not introduce a data
|
| 1309 |
+
race [[res.on.data.races]]. — *end note*]
|
| 1310 |
+
|
| 1311 |
+
[*Note 3*: The order of registration may be indeterminate if
|
| 1312 |
+
`at_quick_exit` was called from more than one thread. — *end note*]
|
| 1313 |
+
|
| 1314 |
+
[*Note 4*: The `at_quick_exit` registrations are distinct from the
|
| 1315 |
+
`atexit` registrations, and applications may need to call both
|
| 1316 |
+
registration functions with the same argument. — *end note*]
|
| 1317 |
+
|
| 1318 |
+
*Implementation limits:* The implementation shall support the
|
| 1319 |
+
registration of at least 32 functions.
|
| 1320 |
+
|
| 1321 |
+
*Returns:* Zero if the registration succeeds, nonzero if it fails.
|
| 1322 |
+
|
| 1323 |
+
``` cpp
|
| 1324 |
+
[[noreturn]] void quick_exit(int status) noexcept;
|
| 1325 |
+
```
|
| 1326 |
+
|
| 1327 |
+
*Effects:* Functions registered by calls to `at_quick_exit` are called
|
| 1328 |
+
in the reverse order of their registration, except that a function shall
|
| 1329 |
+
be called after any previously registered functions that had already
|
| 1330 |
+
been called at the time it was registered. Objects shall not be
|
| 1331 |
+
destroyed as a result of calling `quick_exit`. If control leaves a
|
| 1332 |
+
registered function called by `quick_exit` because the function does not
|
| 1333 |
+
provide a handler for a thrown exception, the function `std::terminate`
|
| 1334 |
+
shall be called.
|
| 1335 |
+
|
| 1336 |
+
[*Note 5*: A function registered via `at_quick_exit` is invoked by the
|
| 1337 |
+
thread that calls `quick_exit`, which can be a different thread than the
|
| 1338 |
+
one that registered it, so registered functions should not rely on the
|
| 1339 |
+
identity of objects with thread storage duration. — *end note*]
|
| 1340 |
+
|
| 1341 |
+
After calling registered functions, `quick_exit` shall call
|
| 1342 |
+
`_Exit(status)`.
|
| 1343 |
+
|
| 1344 |
+
*Remarks:* The function `quick_exit` is signal-safe [[support.signal]]
|
| 1345 |
+
when the functions registered with `at_quick_exit` are.
|
| 1346 |
+
|
| 1347 |
+
See also: ISO C 7.22.4
|
| 1348 |
+
|
| 1349 |
+
## Dynamic memory management <a id="support.dynamic">[[support.dynamic]]</a>
|
| 1350 |
+
|
| 1351 |
+
The header `<new>` defines several functions that manage the allocation
|
| 1352 |
+
of dynamic storage in a program. It also defines components for
|
| 1353 |
+
reporting storage management errors.
|
| 1354 |
+
|
| 1355 |
+
### Header `<new>` synopsis <a id="new.syn">[[new.syn]]</a>
|
| 1356 |
+
|
| 1357 |
+
``` cpp
|
| 1358 |
+
namespace std {
|
| 1359 |
+
// [alloc.errors], storage allocation errors
|
| 1360 |
+
class bad_alloc;
|
| 1361 |
+
class bad_array_new_length;
|
| 1362 |
+
|
| 1363 |
+
struct destroying_delete_t {
|
| 1364 |
+
explicit destroying_delete_t() = default;
|
| 1365 |
+
};
|
| 1366 |
+
inline constexpr destroying_delete_t destroying_delete{};
|
| 1367 |
+
|
| 1368 |
+
// global operator new control%
|
| 1369 |
+
%
|
| 1370 |
+
%
|
| 1371 |
+
%
|
| 1372 |
+
%
|
| 1373 |
+
|
| 1374 |
+
enum class align_val_t : size_t {};
|
| 1375 |
+
|
| 1376 |
+
struct nothrow_t { explicit nothrow_t() = default; };
|
| 1377 |
+
extern const nothrow_t nothrow;
|
| 1378 |
+
|
| 1379 |
+
using new_handler = void (*)();
|
| 1380 |
+
new_handler get_new_handler() noexcept;
|
| 1381 |
+
new_handler set_new_handler(new_handler new_p) noexcept;
|
| 1382 |
+
|
| 1383 |
+
// [ptr.launder], pointer optimization barrier
|
| 1384 |
+
template<class T> [[nodiscard]] constexpr T* launder(T* p) noexcept;
|
| 1385 |
+
|
| 1386 |
+
// [hardware.interference], hardware interference size
|
| 1387 |
+
inline constexpr size_t hardware_destructive_interference_size = implementation-defined{};
|
| 1388 |
+
inline constexpr size_t hardware_constructive_interference_size = implementation-defined{};
|
| 1389 |
+
}
|
| 1390 |
+
|
| 1391 |
+
// [new.delete], storage allocation and deallocation
|
| 1392 |
+
[[nodiscard]] void* operator new(std::size_t size);
|
| 1393 |
+
[[nodiscard]] void* operator new(std::size_t size, std::align_val_t alignment);
|
| 1394 |
+
[[nodiscard]] void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
| 1395 |
+
[[nodiscard]] void* operator new(std::size_t size, std::align_val_t alignment,
|
| 1396 |
+
const std::nothrow_t&) noexcept;
|
| 1397 |
+
|
| 1398 |
+
void operator delete(void* ptr) noexcept;
|
| 1399 |
+
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 1400 |
+
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 1401 |
+
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1402 |
+
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 1403 |
+
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1404 |
+
|
| 1405 |
+
[[nodiscard]] void* operator new[](std::size_t size);
|
| 1406 |
+
[[nodiscard]] void* operator new[](std::size_t size, std::align_val_t alignment);
|
| 1407 |
+
[[nodiscard]] void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
| 1408 |
+
[[nodiscard]] void* operator new[](std::size_t size, std::align_val_t alignment,
|
| 1409 |
+
const std::nothrow_t&) noexcept;
|
| 1410 |
+
|
| 1411 |
+
void operator delete[](void* ptr) noexcept;
|
| 1412 |
+
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 1413 |
+
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 1414 |
+
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1415 |
+
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 1416 |
+
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1417 |
+
|
| 1418 |
+
[[nodiscard]] void* operator new (std::size_t size, void* ptr) noexcept;
|
| 1419 |
+
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 1420 |
+
void operator delete (void* ptr, void*) noexcept;
|
| 1421 |
+
void operator delete[](void* ptr, void*) noexcept;
|
| 1422 |
+
```
|
| 1423 |
+
|
| 1424 |
+
### Storage allocation and deallocation <a id="new.delete">[[new.delete]]</a>
|
| 1425 |
+
|
| 1426 |
+
Except where otherwise specified, the provisions of
|
| 1427 |
+
[[basic.stc.dynamic]] apply to the library versions of `operator new`
|
| 1428 |
+
and `operator
|
| 1429 |
+
delete`. If the value of an alignment argument passed to any of these
|
| 1430 |
+
functions is not a valid alignment value, the behavior is undefined.
|
| 1431 |
+
|
| 1432 |
+
#### Single-object forms <a id="new.delete.single">[[new.delete.single]]</a>
|
| 1433 |
+
|
| 1434 |
+
``` cpp
|
| 1435 |
+
[[nodiscard]] void* operator new(std::size_t size);
|
| 1436 |
+
[[nodiscard]] void* operator new(std::size_t size, std::align_val_t alignment);
|
| 1437 |
+
```
|
| 1438 |
+
|
| 1439 |
+
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 1440 |
+
called by a *new-expression*[[expr.new]] to allocate `size` bytes of
|
| 1441 |
+
storage. The second form is called for a type with new-extended
|
| 1442 |
+
alignment, and the first form is called otherwise.
|
| 1443 |
+
|
| 1444 |
+
*Replaceable:* A C++ program may define functions with either of these
|
| 1445 |
+
function signatures, and thereby displace the default versions defined
|
| 1446 |
+
by the C++ standard library.
|
| 1447 |
+
|
| 1448 |
+
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 1449 |
+
storage [[basic.stc.dynamic]], or else throw a `bad_alloc` exception.
|
| 1450 |
+
This requirement is binding on any replacement versions of these
|
| 1451 |
+
functions.
|
| 1452 |
+
|
| 1453 |
+
*Default behavior:*
|
| 1454 |
+
|
| 1455 |
+
- Executes a loop: Within the loop, the function first attempts to
|
| 1456 |
+
allocate the requested storage. Whether the attempt involves a call to
|
| 1457 |
+
the C standard library functions `malloc` or `aligned_alloc` is
|
| 1458 |
+
unspecified.
|
| 1459 |
+
- Returns a pointer to the allocated storage if the attempt is
|
| 1460 |
+
successful. Otherwise, if the current `new_handler`
|
| 1461 |
+
[[get.new.handler]] is a null pointer value, throws `bad_alloc`.
|
| 1462 |
+
- Otherwise, the function calls the current `new_handler`
|
| 1463 |
+
function [[new.handler]]. If the called function returns, the loop
|
| 1464 |
+
repeats.
|
| 1465 |
+
- The loop terminates when an attempt to allocate the requested storage
|
| 1466 |
+
is successful or when a called `new_handler` function does not return.
|
| 1467 |
+
|
| 1468 |
+
``` cpp
|
| 1469 |
+
[[nodiscard]] void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
| 1470 |
+
[[nodiscard]] void* operator new(std::size_t size, std::align_val_t alignment,
|
| 1471 |
+
const std::nothrow_t&) noexcept;
|
| 1472 |
+
```
|
| 1473 |
+
|
| 1474 |
+
*Effects:* Same as above, except that these are called by a placement
|
| 1475 |
+
version of a *new-expression* when a C++ program prefers a null pointer
|
| 1476 |
+
result as an error indication, instead of a `bad_alloc` exception.
|
| 1477 |
+
|
| 1478 |
+
*Replaceable:* A C++ program may define functions with either of these
|
| 1479 |
+
function signatures, and thereby displace the default versions defined
|
| 1480 |
+
by the C++ standard library.
|
| 1481 |
+
|
| 1482 |
+
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 1483 |
+
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 1484 |
+
these nothrow versions of `operator new` returns a pointer obtained as
|
| 1485 |
+
if acquired from the (possibly replaced) corresponding non-placement
|
| 1486 |
+
function. This requirement is binding on any replacement versions of
|
| 1487 |
+
these functions.
|
| 1488 |
+
|
| 1489 |
+
*Default behavior:* Calls `operator new(size)`, or
|
| 1490 |
+
`operator new(size, alignment)`, respectively. If the call returns
|
| 1491 |
+
normally, returns the result of that call. Otherwise, returns a null
|
| 1492 |
+
pointer.
|
| 1493 |
+
|
| 1494 |
+
[*Example 1*:
|
| 1495 |
+
|
| 1496 |
+
``` cpp
|
| 1497 |
+
T* p1 = new T; // throws bad_alloc if it fails
|
| 1498 |
+
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 1499 |
+
```
|
| 1500 |
+
|
| 1501 |
+
— *end example*]
|
| 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 functions [[basic.stc.dynamic.deallocation]]
|
| 1511 |
+
called by a *delete-expression*[[expr.delete]] to render the value of
|
| 1512 |
+
`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 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1528 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1529 |
+
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 |
+
*Preconditions:* If an implementation has strict pointer
|
| 1534 |
+
safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
|
| 1535 |
+
pointer.
|
| 1536 |
+
|
| 1537 |
+
*Preconditions:* If the `alignment` parameter is not present, `ptr` was
|
| 1538 |
+
returned by an allocation function without an `alignment` parameter. If
|
| 1539 |
+
present, the `alignment` argument is equal to the `alignment` argument
|
| 1540 |
+
passed to the allocation function that returned `ptr`. If present, the
|
| 1541 |
+
`size` argument is equal to the `size` argument passed to the allocation
|
| 1542 |
+
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.
|
| 1556 |
+
|
| 1557 |
+
[*Note 3*: See the note in the above *Replaceable:*
|
| 1558 |
+
paragraph. — *end note*]
|
| 1559 |
+
|
| 1560 |
+
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 1561 |
+
the storage allocated by the earlier call to `operator new`.
|
| 1562 |
+
|
| 1563 |
+
*Remarks:* It is unspecified under what conditions part or all of such
|
| 1564 |
+
reclaimed storage will be allocated by subsequent calls to
|
| 1565 |
+
`operator new` or any of `aligned_alloc`, `calloc`, `malloc`, or
|
| 1566 |
+
`realloc`, declared in `<cstdlib>`.
|
| 1567 |
+
|
| 1568 |
+
``` cpp
|
| 1569 |
+
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 1570 |
+
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1571 |
+
```
|
| 1572 |
+
|
| 1573 |
+
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 1574 |
+
called by the implementation to render the value of `ptr` invalid when
|
| 1575 |
+
the constructor invoked from a nothrow placement version of the
|
| 1576 |
+
*new-expression* throws an exception.
|
| 1577 |
+
|
| 1578 |
+
*Replaceable:* A C++ program may define functions with either of these
|
| 1579 |
+
function signatures, and thereby displace the default versions defined
|
| 1580 |
+
by the C++ standard library.
|
| 1581 |
+
|
| 1582 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1583 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1584 |
+
replaced) `operator new(std::size_t)` or
|
| 1585 |
+
`operator new(std::size_t, std::align_val_t)` which has not been
|
| 1586 |
+
invalidated by an intervening call to `operator delete`.
|
| 1587 |
+
|
| 1588 |
+
*Preconditions:* If an implementation has strict pointer
|
| 1589 |
+
safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
|
| 1590 |
+
pointer.
|
| 1591 |
+
|
| 1592 |
+
*Preconditions:* If the `alignment` parameter is not present, `ptr` was
|
| 1593 |
+
returned by an allocation function without an `alignment` parameter. If
|
| 1594 |
+
present, the `alignment` argument is equal to the `alignment` argument
|
| 1595 |
+
passed to the allocation function that returned `ptr`.
|
| 1596 |
+
|
| 1597 |
+
*Default behavior:* Calls `operator delete(ptr)`, or
|
| 1598 |
+
`operator delete(ptr, alignment)`, respectively.
|
| 1599 |
+
|
| 1600 |
+
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 1601 |
+
|
| 1602 |
+
``` cpp
|
| 1603 |
+
[[nodiscard]] void* operator new[](std::size_t size);
|
| 1604 |
+
[[nodiscard]] void* operator new[](std::size_t size, std::align_val_t alignment);
|
| 1605 |
+
```
|
| 1606 |
+
|
| 1607 |
+
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 1608 |
+
called by the array form of a *new-expression*[[expr.new]] to allocate
|
| 1609 |
+
`size` bytes of storage. The second form is called for a type with
|
| 1610 |
+
new-extended alignment, and the first form is called otherwise. [^33]
|
| 1611 |
+
|
| 1612 |
+
*Replaceable:* A C++ program may define functions with either of these
|
| 1613 |
+
function signatures, and thereby displace the default versions defined
|
| 1614 |
+
by the C++ standard library.
|
| 1615 |
+
|
| 1616 |
+
*Required behavior:* Same as for the corresponding single-object forms.
|
| 1617 |
+
This requirement is binding on any replacement versions of these
|
| 1618 |
+
functions.
|
| 1619 |
+
|
| 1620 |
+
*Default behavior:* Returns `operator new(size)`, or
|
| 1621 |
+
`operator new(size, alignment)`, respectively.
|
| 1622 |
+
|
| 1623 |
+
``` cpp
|
| 1624 |
+
[[nodiscard]] void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
| 1625 |
+
[[nodiscard]] void* operator new[](std::size_t size, std::align_val_t alignment,
|
| 1626 |
+
const std::nothrow_t&) noexcept;
|
| 1627 |
+
```
|
| 1628 |
+
|
| 1629 |
+
*Effects:* Same as above, except that these are called by a placement
|
| 1630 |
+
version of a *new-expression* when a C++ program prefers a null pointer
|
| 1631 |
+
result as an error indication, instead of a `bad_alloc` exception.
|
| 1632 |
+
|
| 1633 |
+
*Replaceable:* A C++ program may define functions with either of these
|
| 1634 |
+
function signatures, and thereby displace the default versions defined
|
| 1635 |
+
by the C++ standard library.
|
| 1636 |
+
|
| 1637 |
+
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 1638 |
+
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 1639 |
+
these nothrow versions of `operator new[]` returns a pointer obtained as
|
| 1640 |
+
if acquired from the (possibly replaced) corresponding non-placement
|
| 1641 |
+
function. This requirement is binding on any replacement versions of
|
| 1642 |
+
these functions.
|
| 1643 |
+
|
| 1644 |
+
*Default behavior:* Calls `operator new[](size)`, or
|
| 1645 |
+
`operator new[](size, alignment)`, respectively. If the call returns
|
| 1646 |
+
normally, returns the result of that call. Otherwise, returns a null
|
| 1647 |
+
pointer.
|
| 1648 |
+
|
| 1649 |
+
``` cpp
|
| 1650 |
+
void operator delete[](void* ptr) noexcept;
|
| 1651 |
+
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 1652 |
+
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 1653 |
+
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1654 |
+
```
|
| 1655 |
+
|
| 1656 |
+
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 1657 |
+
called by the array form of a *delete-expression* to render the value of
|
| 1658 |
+
`ptr` invalid.
|
| 1659 |
+
|
| 1660 |
+
*Replaceable:* A C++ program may define functions with any of these
|
| 1661 |
+
function signatures, and thereby displace the default versions defined
|
| 1662 |
+
by the C++ standard library.
|
| 1663 |
+
|
| 1664 |
+
If a function without a `size` parameter is defined, the program should
|
| 1665 |
+
also define the corresponding function with a `size` parameter. If a
|
| 1666 |
+
function with a `size` parameter is defined, the program shall also
|
| 1667 |
+
define the corresponding version without the `size` parameter.
|
| 1668 |
+
|
| 1669 |
+
[*Note 1*: The default behavior below may change in the future, which
|
| 1670 |
+
will require replacing both deallocation functions when replacing the
|
| 1671 |
+
allocation function. — *end note*]
|
| 1672 |
+
|
| 1673 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1674 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1675 |
+
replaced) `operator new[](std::size_t)` or
|
| 1676 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 1677 |
+
invalidated by an intervening call to `operator delete[]`.
|
| 1678 |
+
|
| 1679 |
+
*Preconditions:* If an implementation has strict pointer
|
| 1680 |
+
safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
|
| 1681 |
+
pointer.
|
| 1682 |
+
|
| 1683 |
+
*Preconditions:* If the `alignment` parameter is not present, `ptr` was
|
| 1684 |
+
returned by an allocation function without an `alignment` parameter. If
|
| 1685 |
+
present, the `alignment` argument is equal to the `alignment` argument
|
| 1686 |
+
passed to the allocation function that returned `ptr`. If present, the
|
| 1687 |
+
`size` argument is equal to the `size` argument passed to the allocation
|
| 1688 |
+
function that returned `ptr`.
|
| 1689 |
+
|
| 1690 |
+
*Required behavior:* A call to an `operator delete[]` with a `size`
|
| 1691 |
+
parameter may be changed to a call to the corresponding
|
| 1692 |
+
`operator delete[]` without a `size` parameter, without affecting memory
|
| 1693 |
+
allocation.
|
| 1694 |
+
|
| 1695 |
+
[*Note 2*: A conforming implementation is for
|
| 1696 |
+
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 1697 |
+
`operator delete[](ptr)`. — *end note*]
|
| 1698 |
+
|
| 1699 |
+
*Default behavior:* The functions that have a `size` parameter forward
|
| 1700 |
+
their other parameters to the corresponding function without a `size`
|
| 1701 |
+
parameter. The functions that do not have a `size` parameter forward
|
| 1702 |
+
their parameters to the corresponding `operator delete` (single-object)
|
| 1703 |
+
function.
|
| 1704 |
+
|
| 1705 |
+
``` cpp
|
| 1706 |
+
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 1707 |
+
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1708 |
+
```
|
| 1709 |
+
|
| 1710 |
+
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 1711 |
+
called by the implementation to render the value of `ptr` invalid when
|
| 1712 |
+
the constructor invoked from a nothrow placement version of the array
|
| 1713 |
+
*new-expression* throws an exception.
|
| 1714 |
+
|
| 1715 |
+
*Replaceable:* A C++ program may define functions with either of these
|
| 1716 |
+
function signatures, and thereby displace the default versions defined
|
| 1717 |
+
by the C++ standard library.
|
| 1718 |
+
|
| 1719 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1720 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1721 |
+
replaced) `operator new[](std::size_t)` or
|
| 1722 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 1723 |
+
invalidated by an intervening call to `operator delete[]`.
|
| 1724 |
+
|
| 1725 |
+
*Preconditions:* If an implementation has strict pointer
|
| 1726 |
+
safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
|
| 1727 |
+
pointer.
|
| 1728 |
+
|
| 1729 |
+
*Preconditions:* If the `alignment` parameter is not present, `ptr` was
|
| 1730 |
+
returned by an allocation function without an `alignment` parameter. If
|
| 1731 |
+
present, the `alignment` argument is equal to the `alignment` argument
|
| 1732 |
+
passed to the allocation function that returned `ptr`.
|
| 1733 |
+
|
| 1734 |
+
*Default behavior:* Calls `operator delete[](ptr)`, or
|
| 1735 |
+
`operator delete[](ptr, alignment)`, respectively.
|
| 1736 |
+
|
| 1737 |
+
#### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
| 1738 |
+
|
| 1739 |
+
These functions are reserved; a C++ program may not define functions
|
| 1740 |
+
that displace the versions in the C++ standard library [[constraints]].
|
| 1741 |
+
The provisions of [[basic.stc.dynamic]] do not apply to these reserved
|
| 1742 |
+
placement forms of `operator new` and `operator delete`.
|
| 1743 |
+
|
| 1744 |
+
``` cpp
|
| 1745 |
+
[[nodiscard]] void* operator new(std::size_t size, void* ptr) noexcept;
|
| 1746 |
+
```
|
| 1747 |
+
|
| 1748 |
+
*Returns:* `ptr`.
|
| 1749 |
+
|
| 1750 |
+
*Remarks:* Intentionally performs no other action.
|
| 1751 |
+
|
| 1752 |
+
[*Example 1*:
|
| 1753 |
+
|
| 1754 |
+
This can be useful for constructing an object at a known address:
|
| 1755 |
+
|
| 1756 |
+
``` cpp
|
| 1757 |
+
void* place = operator new(sizeof(Something));
|
| 1758 |
+
Something* p = new (place) Something();
|
| 1759 |
+
```
|
| 1760 |
+
|
| 1761 |
+
— *end example*]
|
| 1762 |
+
|
| 1763 |
+
``` cpp
|
| 1764 |
+
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 1765 |
+
```
|
| 1766 |
+
|
| 1767 |
+
*Returns:* `ptr`.
|
| 1768 |
+
|
| 1769 |
+
*Remarks:* Intentionally performs no other action.
|
| 1770 |
+
|
| 1771 |
+
``` cpp
|
| 1772 |
+
void operator delete(void* ptr, void*) noexcept;
|
| 1773 |
+
```
|
| 1774 |
+
|
| 1775 |
+
*Effects:* Intentionally performs no action.
|
| 1776 |
+
|
| 1777 |
+
*Preconditions:* If an implementation has strict pointer
|
| 1778 |
+
safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
|
| 1779 |
+
pointer.
|
| 1780 |
+
|
| 1781 |
+
*Remarks:* Default function called when any part of the initialization
|
| 1782 |
+
in a placement *new-expression* that invokes the library’s non-array
|
| 1783 |
+
placement operator new terminates by throwing an exception [[expr.new]].
|
| 1784 |
+
|
| 1785 |
+
``` cpp
|
| 1786 |
+
void operator delete[](void* ptr, void*) noexcept;
|
| 1787 |
+
```
|
| 1788 |
+
|
| 1789 |
+
*Effects:* Intentionally performs no action.
|
| 1790 |
+
|
| 1791 |
+
*Preconditions:* If an implementation has strict pointer
|
| 1792 |
+
safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
|
| 1793 |
+
pointer.
|
| 1794 |
+
|
| 1795 |
+
*Remarks:* Default function called when any part of the initialization
|
| 1796 |
+
in a placement *new-expression* that invokes the library’s array
|
| 1797 |
+
placement operator new terminates by throwing an exception [[expr.new]].
|
| 1798 |
+
|
| 1799 |
+
#### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
|
| 1800 |
+
|
| 1801 |
+
For purposes of determining the existence of data races, the library
|
| 1802 |
+
versions of `operator new`, user replacement versions of global
|
| 1803 |
+
`operator new`, the C standard library functions `aligned_alloc`,
|
| 1804 |
+
`calloc`, and `malloc`, the library versions of `operator delete`, user
|
| 1805 |
+
replacement versions of `operator delete`, the C standard library
|
| 1806 |
+
function `free`, and the C standard library function `realloc` shall not
|
| 1807 |
+
introduce a data race [[res.on.data.races]]. Calls to these functions
|
| 1808 |
+
that allocate or deallocate a particular unit of storage shall occur in
|
| 1809 |
+
a single total order, and each such deallocation call shall happen
|
| 1810 |
+
before [[intro.multithread]] the next allocation (if any) in this order.
|
| 1811 |
+
|
| 1812 |
+
### Storage allocation errors <a id="alloc.errors">[[alloc.errors]]</a>
|
| 1813 |
+
|
| 1814 |
+
#### Class `bad_alloc` <a id="bad.alloc">[[bad.alloc]]</a>
|
| 1815 |
+
|
| 1816 |
+
``` cpp
|
| 1817 |
+
namespace std {
|
| 1818 |
+
class bad_alloc : public exception {
|
| 1819 |
+
public:
|
| 1820 |
+
// see [exception] for the specification of the special member functions
|
| 1821 |
+
const char* what() const noexcept override;
|
| 1822 |
+
};
|
| 1823 |
+
}
|
| 1824 |
+
```
|
| 1825 |
+
|
| 1826 |
+
The class `bad_alloc` defines the type of objects thrown as exceptions
|
| 1827 |
+
by the implementation to report a failure to allocate storage.
|
| 1828 |
+
|
| 1829 |
+
``` cpp
|
| 1830 |
+
const char* what() const noexcept override;
|
| 1831 |
+
```
|
| 1832 |
+
|
| 1833 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 1834 |
+
|
| 1835 |
+
#### Class `bad_array_new_length` <a id="new.badlength">[[new.badlength]]</a>
|
| 1836 |
+
|
| 1837 |
+
``` cpp
|
| 1838 |
+
namespace std {
|
| 1839 |
+
class bad_array_new_length : public bad_alloc {
|
| 1840 |
+
public:
|
| 1841 |
+
// see [exception] for the specification of the special member functions
|
| 1842 |
+
const char* what() const noexcept override;
|
| 1843 |
+
};
|
| 1844 |
+
}
|
| 1845 |
+
```
|
| 1846 |
+
|
| 1847 |
+
The class `bad_array_new_length` defines the type of objects thrown as
|
| 1848 |
+
exceptions by the implementation to report an attempt to allocate an
|
| 1849 |
+
array of size less than zero or greater than an *implementation-defined*
|
| 1850 |
+
limit [[expr.new]].
|
| 1851 |
+
|
| 1852 |
+
``` cpp
|
| 1853 |
+
const char* what() const noexcept override;
|
| 1854 |
+
```
|
| 1855 |
+
|
| 1856 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 1857 |
+
|
| 1858 |
+
#### Type `new_handler` <a id="new.handler">[[new.handler]]</a>
|
| 1859 |
+
|
| 1860 |
+
``` cpp
|
| 1861 |
+
using new_handler = void (*)();
|
| 1862 |
+
```
|
| 1863 |
+
|
| 1864 |
+
The type of a *handler function* to be called by `operator new()` or
|
| 1865 |
+
`operator new[]()` [[new.delete]] when they cannot satisfy a request for
|
| 1866 |
+
additional storage.
|
| 1867 |
+
|
| 1868 |
+
*Required behavior:* A `new_handler` shall perform one of the following:
|
| 1869 |
+
|
| 1870 |
+
- make more storage available for allocation and then return;
|
| 1871 |
+
- throw an exception of type `bad_alloc` or a class derived from
|
| 1872 |
+
`bad_alloc`;
|
| 1873 |
+
- terminate execution of the program without returning to the caller.
|
| 1874 |
+
|
| 1875 |
+
#### `set_new_handler` <a id="set.new.handler">[[set.new.handler]]</a>
|
| 1876 |
+
|
| 1877 |
+
``` cpp
|
| 1878 |
+
new_handler set_new_handler(new_handler new_p) noexcept;
|
| 1879 |
+
```
|
| 1880 |
+
|
| 1881 |
+
*Effects:* Establishes the function designated by `new_p` as the current
|
| 1882 |
+
`new_handler`.
|
| 1883 |
+
|
| 1884 |
+
*Returns:* The previous `new_handler`.
|
| 1885 |
+
|
| 1886 |
+
*Remarks:* The initial `new_handler` is a null pointer.
|
| 1887 |
+
|
| 1888 |
+
#### `get_new_handler` <a id="get.new.handler">[[get.new.handler]]</a>
|
| 1889 |
+
|
| 1890 |
+
``` cpp
|
| 1891 |
+
new_handler get_new_handler() noexcept;
|
| 1892 |
+
```
|
| 1893 |
+
|
| 1894 |
+
*Returns:* The current `new_handler`.
|
| 1895 |
+
|
| 1896 |
+
[*Note 1*: This may be a null pointer value. — *end note*]
|
| 1897 |
+
|
| 1898 |
+
### Pointer optimization barrier <a id="ptr.launder">[[ptr.launder]]</a>
|
| 1899 |
+
|
| 1900 |
+
``` cpp
|
| 1901 |
+
template<class T> [[nodiscard]] constexpr T* launder(T* p) noexcept;
|
| 1902 |
+
```
|
| 1903 |
+
|
| 1904 |
+
*Mandates:* `!is_function_v<T> && !is_void_v<T>` is `true`.
|
| 1905 |
+
|
| 1906 |
+
*Preconditions:* `p` represents the address *A* of a byte in memory. An
|
| 1907 |
+
object *X* that is within its lifetime [[basic.life]] and whose type is
|
| 1908 |
+
similar [[conv.qual]] to `T` is located at the address *A*. All bytes of
|
| 1909 |
+
storage that would be reachable through the result are reachable through
|
| 1910 |
+
`p` (see below).
|
| 1911 |
+
|
| 1912 |
+
*Returns:* A value of type `T*` that points to `X`.
|
| 1913 |
+
|
| 1914 |
+
*Remarks:* An invocation of this function may be used in a core constant
|
| 1915 |
+
expression whenever the value of its argument may be used in a core
|
| 1916 |
+
constant expression. A byte of storage *b* is reachable through a
|
| 1917 |
+
pointer value that points to an object *Y* if there is an object *Z*,
|
| 1918 |
+
pointer-interconvertible with *Y*, such that *b* is within the storage
|
| 1919 |
+
occupied by *Z*, or the immediately-enclosing array object if *Z* is an
|
| 1920 |
+
array element.
|
| 1921 |
+
|
| 1922 |
+
[*Note 1*: If a new object is created in storage occupied by an
|
| 1923 |
+
existing object of the same type, a pointer to the original object can
|
| 1924 |
+
be used to refer to the new object unless its complete object is a const
|
| 1925 |
+
object or it is a base class subobject; in the latter cases, this
|
| 1926 |
+
function can be used to obtain a usable pointer to the new object.
|
| 1927 |
+
See [[basic.life]]. — *end note*]
|
| 1928 |
+
|
| 1929 |
+
[*Example 1*:
|
| 1930 |
+
|
| 1931 |
+
``` cpp
|
| 1932 |
+
struct X { int n; };
|
| 1933 |
+
const X *p = new const X{3};
|
| 1934 |
+
const int a = p->n;
|
| 1935 |
+
new (const_cast<X*>(p)) const X{5}; // p does not point to new object [basic.life] because its type is const
|
| 1936 |
+
const int b = p->n; // undefined behavior
|
| 1937 |
+
const int c = std::launder(p)->n; // OK
|
| 1938 |
+
```
|
| 1939 |
+
|
| 1940 |
+
— *end example*]
|
| 1941 |
+
|
| 1942 |
+
### Hardware interference size <a id="hardware.interference">[[hardware.interference]]</a>
|
| 1943 |
+
|
| 1944 |
+
``` cpp
|
| 1945 |
+
inline constexpr size_t hardware_destructive_interference_size = implementation-defined{};
|
| 1946 |
+
```
|
| 1947 |
+
|
| 1948 |
+
This number is the minimum recommended offset between two
|
| 1949 |
+
concurrently-accessed objects to avoid additional performance
|
| 1950 |
+
degradation due to contention introduced by the implementation. It shall
|
| 1951 |
+
be at least `alignof(max_align_t)`.
|
| 1952 |
+
|
| 1953 |
+
[*Example 1*:
|
| 1954 |
+
|
| 1955 |
+
``` cpp
|
| 1956 |
+
struct keep_apart {
|
| 1957 |
+
alignas(hardware_destructive_interference_size) atomic<int> cat;
|
| 1958 |
+
alignas(hardware_destructive_interference_size) atomic<int> dog;
|
| 1959 |
+
};
|
| 1960 |
+
```
|
| 1961 |
+
|
| 1962 |
+
— *end example*]
|
| 1963 |
+
|
| 1964 |
+
``` cpp
|
| 1965 |
+
inline constexpr size_t hardware_constructive_interference_size = implementation-defined{};
|
| 1966 |
+
```
|
| 1967 |
+
|
| 1968 |
+
This number is the maximum recommended size of contiguous memory
|
| 1969 |
+
occupied by two objects accessed with temporal locality by concurrent
|
| 1970 |
+
threads. It shall be at least `alignof(max_align_t)`.
|
| 1971 |
+
|
| 1972 |
+
[*Example 2*:
|
| 1973 |
+
|
| 1974 |
+
``` cpp
|
| 1975 |
+
struct together {
|
| 1976 |
+
atomic<int> dog;
|
| 1977 |
+
int puppy;
|
| 1978 |
+
};
|
| 1979 |
+
struct kennel {
|
| 1980 |
+
// Other data members...
|
| 1981 |
+
alignas(sizeof(together)) together pack;
|
| 1982 |
+
// Other data members...
|
| 1983 |
+
};
|
| 1984 |
+
static_assert(sizeof(together) <= hardware_constructive_interference_size);
|
| 1985 |
+
```
|
| 1986 |
+
|
| 1987 |
+
— *end example*]
|
| 1988 |
+
|
| 1989 |
+
## Type identification <a id="support.rtti">[[support.rtti]]</a>
|
| 1990 |
+
|
| 1991 |
+
The header `<typeinfo>` defines a type associated with type information
|
| 1992 |
+
generated by the implementation. It also defines two types for reporting
|
| 1993 |
+
dynamic type identification errors.
|
| 1994 |
+
|
| 1995 |
+
### Header `<typeinfo>` synopsis <a id="typeinfo.syn">[[typeinfo.syn]]</a>
|
| 1996 |
+
|
| 1997 |
+
``` cpp
|
| 1998 |
+
namespace std {
|
| 1999 |
+
class type_info;
|
| 2000 |
+
class bad_cast;
|
| 2001 |
+
class bad_typeid;
|
| 2002 |
+
}
|
| 2003 |
+
```
|
| 2004 |
+
|
| 2005 |
+
### Class `type_info` <a id="type.info">[[type.info]]</a>
|
| 2006 |
+
|
| 2007 |
+
``` cpp
|
| 2008 |
+
namespace std {
|
| 2009 |
+
class type_info {
|
| 2010 |
+
public:
|
| 2011 |
+
virtual ~type_info();
|
| 2012 |
+
bool operator==(const type_info& rhs) const noexcept;
|
| 2013 |
+
bool before(const type_info& rhs) const noexcept;
|
| 2014 |
+
size_t hash_code() const noexcept;
|
| 2015 |
+
const char* name() const noexcept;
|
| 2016 |
+
|
| 2017 |
+
type_info(const type_info&) = delete; // cannot be copied
|
| 2018 |
+
type_info& operator=(const type_info&) = delete; // cannot be copied
|
| 2019 |
+
};
|
| 2020 |
+
}
|
| 2021 |
+
```
|
| 2022 |
+
|
| 2023 |
+
The class `type_info` describes type information generated by the
|
| 2024 |
+
implementation [[expr.typeid]]. Objects of this class effectively store
|
| 2025 |
+
a pointer to a name for the type, and an encoded value suitable for
|
| 2026 |
+
comparing two types for equality or collating order. The names, encoding
|
| 2027 |
+
rule, and collating sequence for types are all unspecified and may
|
| 2028 |
+
differ between programs.
|
| 2029 |
+
|
| 2030 |
+
``` cpp
|
| 2031 |
+
bool operator==(const type_info& rhs) const noexcept;
|
| 2032 |
+
```
|
| 2033 |
+
|
| 2034 |
+
*Effects:* Compares the current object with `rhs`.
|
| 2035 |
+
|
| 2036 |
+
*Returns:* `true` if the two values describe the same type.
|
| 2037 |
+
|
| 2038 |
+
``` cpp
|
| 2039 |
+
bool before(const type_info& rhs) const noexcept;
|
| 2040 |
+
```
|
| 2041 |
+
|
| 2042 |
+
*Effects:* Compares the current object with `rhs`.
|
| 2043 |
+
|
| 2044 |
+
*Returns:* `true` if `*this` precedes `rhs` in the implementation’s
|
| 2045 |
+
collation order.
|
| 2046 |
+
|
| 2047 |
+
``` cpp
|
| 2048 |
+
size_t hash_code() const noexcept;
|
| 2049 |
+
```
|
| 2050 |
+
|
| 2051 |
+
*Returns:* An unspecified value, except that within a single execution
|
| 2052 |
+
of the program, it shall return the same value for any two `type_info`
|
| 2053 |
+
objects which compare equal.
|
| 2054 |
+
|
| 2055 |
+
*Remarks:* An implementation should return different values for two
|
| 2056 |
+
`type_info` objects which do not compare equal.
|
| 2057 |
+
|
| 2058 |
+
``` cpp
|
| 2059 |
+
const char* name() const noexcept;
|
| 2060 |
+
```
|
| 2061 |
+
|
| 2062 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 2063 |
+
|
| 2064 |
+
*Remarks:* The message may be a null-terminated multibyte
|
| 2065 |
+
string [[multibyte.strings]], suitable for conversion and display as a
|
| 2066 |
+
`wstring` ([[string.classes]], [[locale.codecvt]]).
|
| 2067 |
+
|
| 2068 |
+
### Class `bad_cast` <a id="bad.cast">[[bad.cast]]</a>
|
| 2069 |
+
|
| 2070 |
+
``` cpp
|
| 2071 |
+
namespace std {
|
| 2072 |
+
class bad_cast : public exception {
|
| 2073 |
+
public:
|
| 2074 |
+
// see [exception] for the specification of the special member functions
|
| 2075 |
+
const char* what() const noexcept override;
|
| 2076 |
+
};
|
| 2077 |
+
}
|
| 2078 |
+
```
|
| 2079 |
+
|
| 2080 |
+
The class `bad_cast` defines the type of objects thrown as exceptions by
|
| 2081 |
+
the implementation to report the execution of an invalid `dynamic_cast`
|
| 2082 |
+
expression [[expr.dynamic.cast]].
|
| 2083 |
+
|
| 2084 |
+
``` cpp
|
| 2085 |
+
const char* what() const noexcept override;
|
| 2086 |
+
```
|
| 2087 |
+
|
| 2088 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 2089 |
+
|
| 2090 |
+
### Class `bad_typeid` <a id="bad.typeid">[[bad.typeid]]</a>
|
| 2091 |
+
|
| 2092 |
+
``` cpp
|
| 2093 |
+
namespace std {
|
| 2094 |
+
class bad_typeid : public exception {
|
| 2095 |
+
public:
|
| 2096 |
+
// see [exception] for the specification of the special member functions
|
| 2097 |
+
const char* what() const noexcept override;
|
| 2098 |
+
};
|
| 2099 |
+
}
|
| 2100 |
+
```
|
| 2101 |
+
|
| 2102 |
+
The class `bad_typeid` defines the type of objects thrown as exceptions
|
| 2103 |
+
by the implementation to report a null pointer in a `typeid` expression
|
| 2104 |
+
[[expr.typeid]].
|
| 2105 |
+
|
| 2106 |
+
``` cpp
|
| 2107 |
+
const char* what() const noexcept override;
|
| 2108 |
+
```
|
| 2109 |
+
|
| 2110 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 2111 |
+
|
| 2112 |
+
## Source location <a id="support.srcloc">[[support.srcloc]]</a>
|
| 2113 |
+
|
| 2114 |
+
### Header `<source_location>` synopsis <a id="source.location.syn">[[source.location.syn]]</a>
|
| 2115 |
+
|
| 2116 |
+
The header `<source_location>` defines the class `source_location` that
|
| 2117 |
+
provides a means to obtain source location information.
|
| 2118 |
+
|
| 2119 |
+
``` cpp
|
| 2120 |
+
namespace std {
|
| 2121 |
+
struct source_location;
|
| 2122 |
+
}
|
| 2123 |
+
```
|
| 2124 |
+
|
| 2125 |
+
### Class `source_location` <a id="support.srcloc.class">[[support.srcloc.class]]</a>
|
| 2126 |
+
|
| 2127 |
+
``` cpp
|
| 2128 |
+
namespace std {
|
| 2129 |
+
struct source_location {
|
| 2130 |
+
// source location construction
|
| 2131 |
+
static consteval source_location current() noexcept;
|
| 2132 |
+
constexpr source_location() noexcept;
|
| 2133 |
+
|
| 2134 |
+
// source location field access
|
| 2135 |
+
constexpr uint_least32_t line() const noexcept;
|
| 2136 |
+
constexpr uint_least32_t column() const noexcept;
|
| 2137 |
+
constexpr const char* file_name() const noexcept;
|
| 2138 |
+
constexpr const char* function_name() const noexcept;
|
| 2139 |
+
|
| 2140 |
+
private:
|
| 2141 |
+
uint_least32_t line_; // exposition only
|
| 2142 |
+
uint_least32_t column_; // exposition only
|
| 2143 |
+
const char* file_name_; // exposition only
|
| 2144 |
+
const char* function_name_; // exposition only
|
| 2145 |
+
};
|
| 2146 |
+
}
|
| 2147 |
+
```
|
| 2148 |
+
|
| 2149 |
+
The type `source_location` meets the *Cpp17DefaultConstructible*,
|
| 2150 |
+
*Cpp17CopyConstructible*, *Cpp17CopyAssignable*, and *Cpp17Destructible*
|
| 2151 |
+
requirements [[utility.arg.requirements]]. Lvalues of type
|
| 2152 |
+
`source_location` are swappable [[swappable.requirements]]. All of the
|
| 2153 |
+
following conditions are `true`:
|
| 2154 |
+
|
| 2155 |
+
- `is_nothrow_move_constructible_v<source_location>`
|
| 2156 |
+
- `is_nothrow_move_assignable_v<source_location>`
|
| 2157 |
+
- `is_nothrow_swappable_v<source_location>`
|
| 2158 |
+
|
| 2159 |
+
[*Note 1*: The intent of `source_location` is to have a small size and
|
| 2160 |
+
efficient copying. It is unspecified whether the copy/move constructors
|
| 2161 |
+
and the copy/move assignment operators are trivial and/or
|
| 2162 |
+
constexpr. — *end note*]
|
| 2163 |
+
|
| 2164 |
+
The data members `file_name_` and `function_name_` always each refer to
|
| 2165 |
+
an NTBS.
|
| 2166 |
+
|
| 2167 |
+
The copy/move constructors and the copy/move assignment operators of
|
| 2168 |
+
`source_location` meet the following postconditions: Given two objects
|
| 2169 |
+
`lhs` and `rhs` of type `source_location`, where `lhs` is a copy/move
|
| 2170 |
+
result of `rhs`, and where `rhs_p` is a value denoting the state of
|
| 2171 |
+
`rhs` before the corresponding copy/move operation, then each of the
|
| 2172 |
+
following conditions is `true`:
|
| 2173 |
+
|
| 2174 |
+
- `strcmp(lhs.file_name(), rhs_p.file_name()) == 0`
|
| 2175 |
+
- `strcmp(lhs.function_name(), rhs_p.function_name()) == 0`
|
| 2176 |
+
- `lhs.line() == rhs_p.line()`
|
| 2177 |
+
- `lhs.column() == rhs_p.column()`
|
| 2178 |
+
|
| 2179 |
+
#### Creation <a id="support.srcloc.cons">[[support.srcloc.cons]]</a>
|
| 2180 |
+
|
| 2181 |
+
``` cpp
|
| 2182 |
+
static consteval source_location current() noexcept;
|
| 2183 |
+
```
|
| 2184 |
+
|
| 2185 |
+
*Returns:*
|
| 2186 |
+
|
| 2187 |
+
- When invoked by a function call whose *postfix-expression* is a
|
| 2188 |
+
(possibly parenthesized) *id-expression* naming `current`, returns a
|
| 2189 |
+
`source_location` with an implementation-defined value. The value
|
| 2190 |
+
should be affected by `#line` [[cpp.line]] in the same manner as for
|
| 2191 |
+
\_\_LINE\_\_ and \_\_FILE\_\_. The values of the exposition-only data
|
| 2192 |
+
members of the returned `source_location` object are indicated in
|
| 2193 |
+
[[support.srcloc.current]].
|
| 2194 |
+
- Otherwise, when invoked in some other way, returns a `source_location`
|
| 2195 |
+
whose data members are initialized with valid but unspecified values.
|
| 2196 |
+
|
| 2197 |
+
*Remarks:* Any call to `current` that appears as a default member
|
| 2198 |
+
initializer [[class.mem]], or as a subexpression thereof, should
|
| 2199 |
+
correspond to the location of the constructor definition or aggregate
|
| 2200 |
+
initialization that uses the default member initializer. Any call to
|
| 2201 |
+
`current` that appears as a default argument [[dcl.fct.default]], or as
|
| 2202 |
+
a subexpression thereof, should correspond to the location of the
|
| 2203 |
+
invocation of the function that uses the default argument [[expr.call]].
|
| 2204 |
+
|
| 2205 |
+
[*Example 1*:
|
| 2206 |
+
|
| 2207 |
+
``` cpp
|
| 2208 |
+
struct s {
|
| 2209 |
+
source_location member = source_location::current();
|
| 2210 |
+
int other_member;
|
| 2211 |
+
s(source_location loc = source_location::current())
|
| 2212 |
+
: member(loc) // values of member refer to the location of the calling function[dcl.fct.default]
|
| 2213 |
+
{}
|
| 2214 |
+
s(int blather) : // values of member refer to this location
|
| 2215 |
+
other_member(blather)
|
| 2216 |
+
{}
|
| 2217 |
+
s(double) // values of member refer to this location
|
| 2218 |
+
{}
|
| 2219 |
+
};
|
| 2220 |
+
void f(source_location a = source_location::current()) {
|
| 2221 |
+
source_location b = source_location::current(); // values in b refer to this line
|
| 2222 |
+
}
|
| 2223 |
+
|
| 2224 |
+
void g() {
|
| 2225 |
+
f(); // f's first argument corresponds to this line of code
|
| 2226 |
+
|
| 2227 |
+
source_location c = source_location::current();
|
| 2228 |
+
f(c); // f's first argument gets the same values as c, above
|
| 2229 |
+
}
|
| 2230 |
+
```
|
| 2231 |
+
|
| 2232 |
+
— *end example*]
|
| 2233 |
+
|
| 2234 |
+
``` cpp
|
| 2235 |
+
constexpr source_location() noexcept;
|
| 2236 |
+
```
|
| 2237 |
+
|
| 2238 |
+
The data members are initialized with valid but unspecified values.
|
| 2239 |
+
|
| 2240 |
+
#### Observers <a id="support.srcloc.obs">[[support.srcloc.obs]]</a>
|
| 2241 |
+
|
| 2242 |
+
``` cpp
|
| 2243 |
+
constexpr uint_least32_t line() const noexcept;
|
| 2244 |
+
```
|
| 2245 |
+
|
| 2246 |
+
*Returns:* `line_`.
|
| 2247 |
+
|
| 2248 |
+
``` cpp
|
| 2249 |
+
constexpr uint_least32_t column() const noexcept;
|
| 2250 |
+
```
|
| 2251 |
+
|
| 2252 |
+
*Returns:* `column_`.
|
| 2253 |
+
|
| 2254 |
+
``` cpp
|
| 2255 |
+
constexpr const char* file_name() const noexcept;
|
| 2256 |
+
```
|
| 2257 |
+
|
| 2258 |
+
*Returns:* `file_name_`.
|
| 2259 |
+
|
| 2260 |
+
``` cpp
|
| 2261 |
+
constexpr const char* function_name() const noexcept;
|
| 2262 |
+
```
|
| 2263 |
+
|
| 2264 |
+
*Returns:* `function_name_`.
|
| 2265 |
+
|
| 2266 |
+
## Exception handling <a id="support.exception">[[support.exception]]</a>
|
| 2267 |
+
|
| 2268 |
+
The header `<exception>` defines several types and functions related to
|
| 2269 |
+
the handling of exceptions in a C++ program.
|
| 2270 |
+
|
| 2271 |
+
### Header `<exception>` synopsis <a id="exception.syn">[[exception.syn]]</a>
|
| 2272 |
+
|
| 2273 |
+
``` cpp
|
| 2274 |
+
namespace std {
|
| 2275 |
+
class exception;
|
| 2276 |
+
class bad_exception;
|
| 2277 |
+
class nested_exception;
|
| 2278 |
+
|
| 2279 |
+
using terminate_handler = void (*)();
|
| 2280 |
+
terminate_handler get_terminate() noexcept;
|
| 2281 |
+
terminate_handler set_terminate(terminate_handler f) noexcept;
|
| 2282 |
+
[[noreturn]] void terminate() noexcept;
|
| 2283 |
+
|
| 2284 |
+
int uncaught_exceptions() noexcept;
|
| 2285 |
+
|
| 2286 |
+
using exception_ptr = unspecified;
|
| 2287 |
+
|
| 2288 |
+
exception_ptr current_exception() noexcept;
|
| 2289 |
+
[[noreturn]] void rethrow_exception(exception_ptr p);
|
| 2290 |
+
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 2291 |
+
|
| 2292 |
+
template<class T> [[noreturn]] void throw_with_nested(T&& t);
|
| 2293 |
+
template<class E> void rethrow_if_nested(const E& e);
|
| 2294 |
+
}
|
| 2295 |
+
```
|
| 2296 |
+
|
| 2297 |
+
### Class `exception` <a id="exception">[[exception]]</a>
|
| 2298 |
+
|
| 2299 |
+
``` cpp
|
| 2300 |
+
namespace std {
|
| 2301 |
+
class exception {
|
| 2302 |
+
public:
|
| 2303 |
+
exception() noexcept;
|
| 2304 |
+
exception(const exception&) noexcept;
|
| 2305 |
+
exception& operator=(const exception&) noexcept;
|
| 2306 |
+
virtual ~exception();
|
| 2307 |
+
virtual const char* what() const noexcept;
|
| 2308 |
+
};
|
| 2309 |
+
}
|
| 2310 |
+
```
|
| 2311 |
+
|
| 2312 |
+
The class `exception` defines the base class for the types of objects
|
| 2313 |
+
thrown as exceptions by C++ standard library components, and certain
|
| 2314 |
+
expressions, to report errors detected during program execution.
|
| 2315 |
+
|
| 2316 |
+
Each standard library class `T` that derives from class `exception` has
|
| 2317 |
+
the following publicly accessible member functions, each of them having
|
| 2318 |
+
a non-throwing exception specification [[except.spec]]:
|
| 2319 |
+
|
| 2320 |
+
- default constructor (unless the class synopsis shows other
|
| 2321 |
+
constructors)
|
| 2322 |
+
- copy constructor
|
| 2323 |
+
- copy assignment operator
|
| 2324 |
+
|
| 2325 |
+
The copy constructor and the copy assignment operator meet the following
|
| 2326 |
+
postcondition: If two objects `lhs` and `rhs` both have dynamic type `T`
|
| 2327 |
+
and `lhs` is a copy of `rhs`, then `strcmp(lhs.what(), rhs.what())` is
|
| 2328 |
+
equal to `0`. The `what()` member function of each such `T` satisfies
|
| 2329 |
+
the constraints specified for `exception::what()` (see below).
|
| 2330 |
+
|
| 2331 |
+
``` cpp
|
| 2332 |
+
exception(const exception& rhs) noexcept;
|
| 2333 |
+
exception& operator=(const exception& rhs) noexcept;
|
| 2334 |
+
```
|
| 2335 |
+
|
| 2336 |
+
*Ensures:* If `*this` and `rhs` both have dynamic type `exception` then
|
| 2337 |
+
the value of the expression `strcmp(what(), rhs.what())` shall equal 0.
|
| 2338 |
+
|
| 2339 |
+
``` cpp
|
| 2340 |
+
virtual ~exception();
|
| 2341 |
+
```
|
| 2342 |
+
|
| 2343 |
+
*Effects:* Destroys an object of class `exception`.
|
| 2344 |
+
|
| 2345 |
+
``` cpp
|
| 2346 |
+
virtual const char* what() const noexcept;
|
| 2347 |
+
```
|
| 2348 |
+
|
| 2349 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 2350 |
+
|
| 2351 |
+
*Remarks:* The message may be a null-terminated multibyte
|
| 2352 |
+
string [[multibyte.strings]], suitable for conversion and display as a
|
| 2353 |
+
`wstring` ([[string.classes]], [[locale.codecvt]]). The return value
|
| 2354 |
+
remains valid until the exception object from which it is obtained is
|
| 2355 |
+
destroyed or a non-`const` member function of the exception object is
|
| 2356 |
+
called.
|
| 2357 |
+
|
| 2358 |
+
### Class `bad_exception` <a id="bad.exception">[[bad.exception]]</a>
|
| 2359 |
+
|
| 2360 |
+
``` cpp
|
| 2361 |
+
namespace std {
|
| 2362 |
+
class bad_exception : public exception {
|
| 2363 |
+
public:
|
| 2364 |
+
// see [exception] for the specification of the special member functions
|
| 2365 |
+
const char* what() const noexcept override;
|
| 2366 |
+
};
|
| 2367 |
+
}
|
| 2368 |
+
```
|
| 2369 |
+
|
| 2370 |
+
The class `bad_exception` defines the type of the object referenced by
|
| 2371 |
+
the `exception_ptr` returned from a call to `current_exception`
|
| 2372 |
+
[[propagation]] when the currently active exception object fails to
|
| 2373 |
+
copy.
|
| 2374 |
+
|
| 2375 |
+
``` cpp
|
| 2376 |
+
const char* what() const noexcept override;
|
| 2377 |
+
```
|
| 2378 |
+
|
| 2379 |
+
*Returns:* An *implementation-defined* NTBS.
|
| 2380 |
+
|
| 2381 |
+
### Abnormal termination <a id="exception.terminate">[[exception.terminate]]</a>
|
| 2382 |
+
|
| 2383 |
+
#### Type `terminate_handler` <a id="terminate.handler">[[terminate.handler]]</a>
|
| 2384 |
+
|
| 2385 |
+
``` cpp
|
| 2386 |
+
using terminate_handler = void (*)();
|
| 2387 |
+
```
|
| 2388 |
+
|
| 2389 |
+
The type of a *handler function* to be called by `std::terminate()` when
|
| 2390 |
+
terminating exception processing.
|
| 2391 |
+
|
| 2392 |
+
*Required behavior:* A `terminate_handler` shall terminate execution of
|
| 2393 |
+
the program without returning to the caller.
|
| 2394 |
+
|
| 2395 |
+
*Default behavior:* The implementation’s default `terminate_handler`
|
| 2396 |
+
calls `abort()`.
|
| 2397 |
+
|
| 2398 |
+
#### `set_terminate` <a id="set.terminate">[[set.terminate]]</a>
|
| 2399 |
+
|
| 2400 |
+
``` cpp
|
| 2401 |
+
terminate_handler set_terminate(terminate_handler f) noexcept;
|
| 2402 |
+
```
|
| 2403 |
+
|
| 2404 |
+
*Effects:* Establishes the function designated by `f` as the current
|
| 2405 |
+
handler function for terminating exception processing.
|
| 2406 |
+
|
| 2407 |
+
*Remarks:* It is unspecified whether a null pointer value designates the
|
| 2408 |
+
default `terminate_handler`.
|
| 2409 |
+
|
| 2410 |
+
*Returns:* The previous `terminate_handler`.
|
| 2411 |
+
|
| 2412 |
+
#### `get_terminate` <a id="get.terminate">[[get.terminate]]</a>
|
| 2413 |
+
|
| 2414 |
+
``` cpp
|
| 2415 |
+
terminate_handler get_terminate() noexcept;
|
| 2416 |
+
```
|
| 2417 |
+
|
| 2418 |
+
*Returns:* The current `terminate_handler`.
|
| 2419 |
+
|
| 2420 |
+
[*Note 1*: This may be a null pointer value. — *end note*]
|
| 2421 |
+
|
| 2422 |
+
#### `terminate` <a id="terminate">[[terminate]]</a>
|
| 2423 |
+
|
| 2424 |
+
``` cpp
|
| 2425 |
+
[[noreturn]] void terminate() noexcept;
|
| 2426 |
+
```
|
| 2427 |
+
|
| 2428 |
+
*Remarks:* Called by the implementation when exception handling must be
|
| 2429 |
+
abandoned for any of several reasons [[except.terminate]]. May also be
|
| 2430 |
+
called directly by the program.
|
| 2431 |
+
|
| 2432 |
+
*Effects:* Calls a `terminate_handler` function. It is unspecified which
|
| 2433 |
+
`terminate_handler` function will be called if an exception is active
|
| 2434 |
+
during a call to `set_terminate`. Otherwise calls the current
|
| 2435 |
+
`terminate_handler` function.
|
| 2436 |
+
|
| 2437 |
+
[*Note 1*: A default `terminate_handler` is always considered a
|
| 2438 |
+
callable handler in this context. — *end note*]
|
| 2439 |
+
|
| 2440 |
+
### `uncaught_exceptions` <a id="uncaught.exceptions">[[uncaught.exceptions]]</a>
|
| 2441 |
+
|
| 2442 |
+
``` cpp
|
| 2443 |
+
int uncaught_exceptions() noexcept;
|
| 2444 |
+
```
|
| 2445 |
+
|
| 2446 |
+
*Returns:* The number of uncaught exceptions [[except.uncaught]].
|
| 2447 |
+
|
| 2448 |
+
*Remarks:* When `uncaught_exceptions() > 0`, throwing an exception can
|
| 2449 |
+
result in a call of the function `std::terminate` [[except.terminate]].
|
| 2450 |
+
|
| 2451 |
+
### Exception propagation <a id="propagation">[[propagation]]</a>
|
| 2452 |
+
|
| 2453 |
+
``` cpp
|
| 2454 |
+
using exception_ptr = unspecified;
|
| 2455 |
+
```
|
| 2456 |
+
|
| 2457 |
+
The type `exception_ptr` can be used to refer to an exception object.
|
| 2458 |
+
|
| 2459 |
+
`exception_ptr` meets the requirements of *Cpp17NullablePointer*
|
| 2460 |
+
([[cpp17.nullablepointer]]).
|
| 2461 |
+
|
| 2462 |
+
Two non-null values of type `exception_ptr` are equivalent and compare
|
| 2463 |
+
equal if and only if they refer to the same exception.
|
| 2464 |
+
|
| 2465 |
+
The default constructor of `exception_ptr` produces the null value of
|
| 2466 |
+
the type.
|
| 2467 |
+
|
| 2468 |
+
`exception_ptr` shall not be implicitly convertible to any arithmetic,
|
| 2469 |
+
enumeration, or pointer type.
|
| 2470 |
+
|
| 2471 |
+
[*Note 1*: An implementation might use a reference-counted smart
|
| 2472 |
+
pointer as `exception_ptr`. — *end note*]
|
| 2473 |
+
|
| 2474 |
+
For purposes of determining the presence of a data race, operations on
|
| 2475 |
+
`exception_ptr` objects shall access and modify only the `exception_ptr`
|
| 2476 |
+
objects themselves and not the exceptions they refer to. Use of
|
| 2477 |
+
`rethrow_exception` on `exception_ptr` objects that refer to the same
|
| 2478 |
+
exception object shall not introduce a data race.
|
| 2479 |
+
|
| 2480 |
+
[*Note 2*: If `rethrow_exception` rethrows the same exception object
|
| 2481 |
+
(rather than a copy), concurrent access to that rethrown exception
|
| 2482 |
+
object may introduce a data race. Changes in the number of
|
| 2483 |
+
`exception_ptr` objects that refer to a particular exception do not
|
| 2484 |
+
introduce a data race. — *end note*]
|
| 2485 |
+
|
| 2486 |
+
``` cpp
|
| 2487 |
+
exception_ptr current_exception() noexcept;
|
| 2488 |
+
```
|
| 2489 |
+
|
| 2490 |
+
*Returns:* An `exception_ptr` object that refers to the currently
|
| 2491 |
+
handled exception [[except.handle]] or a copy of the currently handled
|
| 2492 |
+
exception, or a null `exception_ptr` object if no exception is being
|
| 2493 |
+
handled. The referenced object shall remain valid at least as long as
|
| 2494 |
+
there is an `exception_ptr` object that refers to it. If the function
|
| 2495 |
+
needs to allocate memory and the attempt fails, it returns an
|
| 2496 |
+
`exception_ptr` object that refers to an instance of `bad_alloc`. It is
|
| 2497 |
+
unspecified whether the return values of two successive calls to
|
| 2498 |
+
`current_exception` refer to the same exception object.
|
| 2499 |
+
|
| 2500 |
+
[*Note 3*: That is, it is unspecified whether `current_exception`
|
| 2501 |
+
creates a new copy each time it is called. — *end note*]
|
| 2502 |
+
|
| 2503 |
+
If the attempt to copy the current exception object throws an exception,
|
| 2504 |
+
the function returns an `exception_ptr` object that refers to the thrown
|
| 2505 |
+
exception or, if this is not possible, to an instance of
|
| 2506 |
+
`bad_exception`.
|
| 2507 |
+
|
| 2508 |
+
[*Note 4*: The copy constructor of the thrown exception may also fail,
|
| 2509 |
+
so the implementation is allowed to substitute a `bad_exception` object
|
| 2510 |
+
to avoid infinite recursion. — *end note*]
|
| 2511 |
+
|
| 2512 |
+
``` cpp
|
| 2513 |
+
[[noreturn]] void rethrow_exception(exception_ptr p);
|
| 2514 |
+
```
|
| 2515 |
+
|
| 2516 |
+
*Preconditions:* `p` is not a null pointer.
|
| 2517 |
+
|
| 2518 |
+
*Throws:* The exception object to which `p` refers.
|
| 2519 |
+
|
| 2520 |
+
``` cpp
|
| 2521 |
+
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 2522 |
+
```
|
| 2523 |
+
|
| 2524 |
+
*Effects:* Creates an `exception_ptr` object that refers to a copy of
|
| 2525 |
+
`e`, as if:
|
| 2526 |
+
|
| 2527 |
+
``` cpp
|
| 2528 |
+
try {
|
| 2529 |
+
throw e;
|
| 2530 |
+
} catch(...) {
|
| 2531 |
+
return current_exception();
|
| 2532 |
+
}
|
| 2533 |
+
```
|
| 2534 |
+
|
| 2535 |
+
[*Note 5*: This function is provided for convenience and efficiency
|
| 2536 |
+
reasons. — *end note*]
|
| 2537 |
+
|
| 2538 |
+
### `nested_exception` <a id="except.nested">[[except.nested]]</a>
|
| 2539 |
+
|
| 2540 |
+
``` cpp
|
| 2541 |
+
namespace std {
|
| 2542 |
+
class nested_exception {
|
| 2543 |
+
public:
|
| 2544 |
+
nested_exception() noexcept;
|
| 2545 |
+
nested_exception(const nested_exception&) noexcept = default;
|
| 2546 |
+
nested_exception& operator=(const nested_exception&) noexcept = default;
|
| 2547 |
+
virtual ~nested_exception() = default;
|
| 2548 |
+
|
| 2549 |
+
// access functions
|
| 2550 |
+
[[noreturn]] void rethrow_nested() const;
|
| 2551 |
+
exception_ptr nested_ptr() const noexcept;
|
| 2552 |
+
};
|
| 2553 |
+
|
| 2554 |
+
template<class T> [[noreturn]] void throw_with_nested(T&& t);
|
| 2555 |
+
template<class E> void rethrow_if_nested(const E& e);
|
| 2556 |
+
}
|
| 2557 |
+
```
|
| 2558 |
+
|
| 2559 |
+
The class `nested_exception` is designed for use as a mixin through
|
| 2560 |
+
multiple inheritance. It captures the currently handled exception and
|
| 2561 |
+
stores it for later use.
|
| 2562 |
+
|
| 2563 |
+
[*Note 1*: `nested_exception` has a virtual destructor to make it a
|
| 2564 |
+
polymorphic class. Its presence can be tested for with
|
| 2565 |
+
`dynamic_cast`. — *end note*]
|
| 2566 |
+
|
| 2567 |
+
``` cpp
|
| 2568 |
+
nested_exception() noexcept;
|
| 2569 |
+
```
|
| 2570 |
+
|
| 2571 |
+
*Effects:* The constructor calls `current_exception()` and stores the
|
| 2572 |
+
returned value.
|
| 2573 |
+
|
| 2574 |
+
``` cpp
|
| 2575 |
+
[[noreturn]] void rethrow_nested() const;
|
| 2576 |
+
```
|
| 2577 |
+
|
| 2578 |
+
*Effects:* If `nested_ptr()` returns a null pointer, the function calls
|
| 2579 |
+
the function `std::terminate`. Otherwise, it throws the stored exception
|
| 2580 |
+
captured by `*this`.
|
| 2581 |
+
|
| 2582 |
+
``` cpp
|
| 2583 |
+
exception_ptr nested_ptr() const noexcept;
|
| 2584 |
+
```
|
| 2585 |
+
|
| 2586 |
+
*Returns:* The stored exception captured by this `nested_exception`
|
| 2587 |
+
object.
|
| 2588 |
+
|
| 2589 |
+
``` cpp
|
| 2590 |
+
template<class T> [[noreturn]] void throw_with_nested(T&& t);
|
| 2591 |
+
```
|
| 2592 |
+
|
| 2593 |
+
Let `U` be `decay_t<T>`.
|
| 2594 |
+
|
| 2595 |
+
*Preconditions:* `U` meets the *Cpp17CopyConstructible* requirements.
|
| 2596 |
+
|
| 2597 |
+
*Throws:* If
|
| 2598 |
+
`is_class_v<U> && !is_final_v<U> && !is_base_of_v<nested_exception, U>`
|
| 2599 |
+
is `true`, an exception of unspecified type that is publicly derived
|
| 2600 |
+
from both `U` and `nested_exception` and constructed from
|
| 2601 |
+
`std::forward<T>(t)`, otherwise `std::forward<T>(t)`.
|
| 2602 |
+
|
| 2603 |
+
``` cpp
|
| 2604 |
+
template<class E> void rethrow_if_nested(const E& e);
|
| 2605 |
+
```
|
| 2606 |
+
|
| 2607 |
+
*Effects:* If `E` is not a polymorphic class type, or if
|
| 2608 |
+
`nested_exception` is an inaccessible or ambiguous base class of `E`,
|
| 2609 |
+
there is no effect. Otherwise, performs:
|
| 2610 |
+
|
| 2611 |
+
``` cpp
|
| 2612 |
+
if (auto p = dynamic_cast<const nested_exception*>(addressof(e)))
|
| 2613 |
+
p->rethrow_nested();
|
| 2614 |
+
```
|
| 2615 |
+
|
| 2616 |
+
## Initializer lists <a id="support.initlist">[[support.initlist]]</a>
|
| 2617 |
+
|
| 2618 |
+
The header `<initializer_list>` defines a class template and several
|
| 2619 |
+
support functions related to list-initialization (see
|
| 2620 |
+
[[dcl.init.list]]). All functions specified in this subclause are
|
| 2621 |
+
signal-safe [[support.signal]].
|
| 2622 |
+
|
| 2623 |
+
### Header `<initializer_list>` synopsis <a id="initializer.list.syn">[[initializer.list.syn]]</a>
|
| 2624 |
+
|
| 2625 |
+
``` cpp
|
| 2626 |
+
namespace std {
|
| 2627 |
+
template<class E> class initializer_list {
|
| 2628 |
+
public:
|
| 2629 |
+
using value_type = E;
|
| 2630 |
+
using reference = const E&;
|
| 2631 |
+
using const_reference = const E&;
|
| 2632 |
+
using size_type = size_t;
|
| 2633 |
+
|
| 2634 |
+
using iterator = const E*;
|
| 2635 |
+
using const_iterator = const E*;
|
| 2636 |
+
|
| 2637 |
+
constexpr initializer_list() noexcept;
|
| 2638 |
+
|
| 2639 |
+
constexpr size_t size() const noexcept; // number of elements
|
| 2640 |
+
constexpr const E* begin() const noexcept; // first element
|
| 2641 |
+
constexpr const E* end() const noexcept; // one past the last element
|
| 2642 |
+
};
|
| 2643 |
+
|
| 2644 |
+
// [support.initlist.range], initializer list range access
|
| 2645 |
+
template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
|
| 2646 |
+
template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
| 2647 |
+
}
|
| 2648 |
+
```
|
| 2649 |
+
|
| 2650 |
+
An object of type `initializer_list<E>` provides access to an array of
|
| 2651 |
+
objects of type `const E`.
|
| 2652 |
+
|
| 2653 |
+
[*Note 1*: A pair of pointers or a pointer plus a length would be
|
| 2654 |
+
obvious representations for `initializer_list`. `initializer_list` is
|
| 2655 |
+
used to implement initializer lists as specified in [[dcl.init.list]].
|
| 2656 |
+
Copying an initializer list does not copy the underlying
|
| 2657 |
+
elements. — *end note*]
|
| 2658 |
+
|
| 2659 |
+
If an explicit specialization or partial specialization of
|
| 2660 |
+
`initializer_list` is declared, the program is ill-formed.
|
| 2661 |
+
|
| 2662 |
+
### Initializer list constructors <a id="support.initlist.cons">[[support.initlist.cons]]</a>
|
| 2663 |
+
|
| 2664 |
+
``` cpp
|
| 2665 |
+
constexpr initializer_list() noexcept;
|
| 2666 |
+
```
|
| 2667 |
+
|
| 2668 |
+
*Ensures:* `size() == 0`.
|
| 2669 |
+
|
| 2670 |
+
### Initializer list access <a id="support.initlist.access">[[support.initlist.access]]</a>
|
| 2671 |
+
|
| 2672 |
+
``` cpp
|
| 2673 |
+
constexpr const E* begin() const noexcept;
|
| 2674 |
+
```
|
| 2675 |
+
|
| 2676 |
+
*Returns:* A pointer to the beginning of the array. If `size() == 0` the
|
| 2677 |
+
values of `begin()` and `end()` are unspecified but they shall be
|
| 2678 |
+
identical.
|
| 2679 |
+
|
| 2680 |
+
``` cpp
|
| 2681 |
+
constexpr const E* end() const noexcept;
|
| 2682 |
+
```
|
| 2683 |
+
|
| 2684 |
+
*Returns:* `begin() + size()`.
|
| 2685 |
+
|
| 2686 |
+
``` cpp
|
| 2687 |
+
constexpr size_t size() const noexcept;
|
| 2688 |
+
```
|
| 2689 |
+
|
| 2690 |
+
*Returns:* The number of elements in the array.
|
| 2691 |
+
|
| 2692 |
+
*Complexity:* Constant time.
|
| 2693 |
+
|
| 2694 |
+
### Initializer list range access <a id="support.initlist.range">[[support.initlist.range]]</a>
|
| 2695 |
+
|
| 2696 |
+
``` cpp
|
| 2697 |
+
template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
|
| 2698 |
+
```
|
| 2699 |
+
|
| 2700 |
+
*Returns:* `il.begin()`.
|
| 2701 |
+
|
| 2702 |
+
``` cpp
|
| 2703 |
+
template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
| 2704 |
+
```
|
| 2705 |
+
|
| 2706 |
+
*Returns:* `il.end()`.
|
| 2707 |
+
|
| 2708 |
+
## Comparisons <a id="cmp">[[cmp]]</a>
|
| 2709 |
+
|
| 2710 |
+
### Header `<compare>` synopsis <a id="compare.syn">[[compare.syn]]</a>
|
| 2711 |
+
|
| 2712 |
+
The header `<compare>` specifies types, objects, and functions for use
|
| 2713 |
+
primarily in connection with the three-way comparison operator
|
| 2714 |
+
[[expr.spaceship]].
|
| 2715 |
+
|
| 2716 |
+
``` cpp
|
| 2717 |
+
namespace std {
|
| 2718 |
+
// [cmp.categories], comparison category types
|
| 2719 |
+
class partial_ordering;
|
| 2720 |
+
class weak_ordering;
|
| 2721 |
+
class strong_ordering;
|
| 2722 |
+
|
| 2723 |
+
// named comparison functions
|
| 2724 |
+
constexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; }
|
| 2725 |
+
constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; }
|
| 2726 |
+
constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; }
|
| 2727 |
+
constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
|
| 2728 |
+
constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; }
|
| 2729 |
+
constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
|
| 2730 |
+
|
| 2731 |
+
// [cmp.common], common comparison category type
|
| 2732 |
+
template<class... Ts>
|
| 2733 |
+
struct common_comparison_category {
|
| 2734 |
+
using type = see below;
|
| 2735 |
+
};
|
| 2736 |
+
template<class... Ts>
|
| 2737 |
+
using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
|
| 2738 |
+
|
| 2739 |
+
// [cmp.concept], concept three_way_comparable
|
| 2740 |
+
template<class T, class Cat = partial_ordering>
|
| 2741 |
+
concept three_way_comparable = see below;
|
| 2742 |
+
template<class T, class U, class Cat = partial_ordering>
|
| 2743 |
+
concept three_way_comparable_with = see below;
|
| 2744 |
+
|
| 2745 |
+
// [cmp.result], result of three-way comparison
|
| 2746 |
+
template<class T, class U = T> struct compare_three_way_result;
|
| 2747 |
+
|
| 2748 |
+
template<class T, class U = T>
|
| 2749 |
+
using compare_three_way_result_t = typename compare_three_way_result<T, U>::type;
|
| 2750 |
+
|
| 2751 |
+
// [comparisons.three.way], class compare_three_way
|
| 2752 |
+
struct compare_three_way;
|
| 2753 |
+
|
| 2754 |
+
// [cmp.alg], comparison algorithms
|
| 2755 |
+
inline namespace unspecified {
|
| 2756 |
+
inline constexpr unspecified strong_order = unspecified;
|
| 2757 |
+
inline constexpr unspecified weak_order = unspecified;
|
| 2758 |
+
inline constexpr unspecified partial_order = unspecified;
|
| 2759 |
+
inline constexpr unspecified compare_strong_order_fallback = unspecified;
|
| 2760 |
+
inline constexpr unspecified compare_weak_order_fallback = unspecified;
|
| 2761 |
+
inline constexpr unspecified compare_partial_order_fallback = unspecified;
|
| 2762 |
+
}
|
| 2763 |
+
}
|
| 2764 |
+
```
|
| 2765 |
+
|
| 2766 |
+
### Comparison category types <a id="cmp.categories">[[cmp.categories]]</a>
|
| 2767 |
+
|
| 2768 |
+
#### Preamble <a id="cmp.categories.pre">[[cmp.categories.pre]]</a>
|
| 2769 |
+
|
| 2770 |
+
The types `partial_ordering`, `weak_ordering`, and `strong_ordering` are
|
| 2771 |
+
collectively termed the *comparison category types*. Each is specified
|
| 2772 |
+
in terms of an exposition-only data member named `value` whose value
|
| 2773 |
+
typically corresponds to that of an enumerator from one of the following
|
| 2774 |
+
exposition-only enumerations:
|
| 2775 |
+
|
| 2776 |
+
``` cpp
|
| 2777 |
+
enum class eq { equal = 0, equivalent = equal,
|
| 2778 |
+
nonequal = 1, nonequivalent = nonequal }; // exposition only
|
| 2779 |
+
enum class ord { less = -1, greater = 1 }; // exposition only
|
| 2780 |
+
enum class ncmp { unordered = -127 }; // exposition only
|
| 2781 |
+
```
|
| 2782 |
+
|
| 2783 |
+
[*Note 1*: The type `strong_ordering` corresponds to the term total
|
| 2784 |
+
ordering in mathematics. — *end note*]
|
| 2785 |
+
|
| 2786 |
+
The relational and equality operators for the comparison category types
|
| 2787 |
+
are specified with an anonymous parameter of unspecified type. This type
|
| 2788 |
+
shall be selected by the implementation such that these parameters can
|
| 2789 |
+
accept literal `0` as a corresponding argument.
|
| 2790 |
+
|
| 2791 |
+
[*Example 1*:
|
| 2792 |
+
|
| 2793 |
+
`nullptr_t`
|
| 2794 |
+
|
| 2795 |
+
meets this requirement.
|
| 2796 |
+
|
| 2797 |
+
— *end example*]
|
| 2798 |
+
|
| 2799 |
+
In this context, the behavior of a program that supplies an argument
|
| 2800 |
+
other than a literal `0` is undefined.
|
| 2801 |
+
|
| 2802 |
+
For the purposes of subclause [[cmp.categories]], *substitutability* is
|
| 2803 |
+
the property that `f(a) == f(b)` is `true` whenever `a == b` is `true`,
|
| 2804 |
+
where `f` denotes a function that reads only comparison-salient state
|
| 2805 |
+
that is accessible via the argument’s public const members.
|
| 2806 |
+
|
| 2807 |
+
#### Class `partial_ordering` <a id="cmp.partialord">[[cmp.partialord]]</a>
|
| 2808 |
+
|
| 2809 |
+
The `partial_ordering` type is typically used as the result type of a
|
| 2810 |
+
three-way comparison operator [[expr.spaceship]] that (a) admits all of
|
| 2811 |
+
the six two-way comparison operators ([[expr.rel]], [[expr.eq]]), (b)
|
| 2812 |
+
does not imply substitutability, and (c) permits two values to be
|
| 2813 |
+
incomparable. [^34]
|
| 2814 |
+
|
| 2815 |
+
``` cpp
|
| 2816 |
+
namespace std {
|
| 2817 |
+
class partial_ordering {
|
| 2818 |
+
int value; // exposition only
|
| 2819 |
+
bool is_ordered; // exposition only
|
| 2820 |
+
|
| 2821 |
+
// exposition-only constructors
|
| 2822 |
+
constexpr explicit
|
| 2823 |
+
partial_ordering(eq v) noexcept : value(int(v)), is_ordered(true) {} // exposition only
|
| 2824 |
+
constexpr explicit
|
| 2825 |
+
partial_ordering(ord v) noexcept : value(int(v)), is_ordered(true) {} // exposition only
|
| 2826 |
+
constexpr explicit
|
| 2827 |
+
partial_ordering(ncmp v) noexcept : value(int(v)), is_ordered(false) {} // exposition only
|
| 2828 |
+
|
| 2829 |
+
public:
|
| 2830 |
+
// valid values
|
| 2831 |
+
static const partial_ordering less;
|
| 2832 |
+
static const partial_ordering equivalent;
|
| 2833 |
+
static const partial_ordering greater;
|
| 2834 |
+
static const partial_ordering unordered;
|
| 2835 |
+
|
| 2836 |
+
// comparisons
|
| 2837 |
+
friend constexpr bool operator==(partial_ordering v, unspecified) noexcept;
|
| 2838 |
+
friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default;
|
| 2839 |
+
friend constexpr bool operator< (partial_ordering v, unspecified) noexcept;
|
| 2840 |
+
friend constexpr bool operator> (partial_ordering v, unspecified) noexcept;
|
| 2841 |
+
friend constexpr bool operator<=(partial_ordering v, unspecified) noexcept;
|
| 2842 |
+
friend constexpr bool operator>=(partial_ordering v, unspecified) noexcept;
|
| 2843 |
+
friend constexpr bool operator< (unspecified, partial_ordering v) noexcept;
|
| 2844 |
+
friend constexpr bool operator> (unspecified, partial_ordering v) noexcept;
|
| 2845 |
+
friend constexpr bool operator<=(unspecified, partial_ordering v) noexcept;
|
| 2846 |
+
friend constexpr bool operator>=(unspecified, partial_ordering v) noexcept;
|
| 2847 |
+
friend constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept;
|
| 2848 |
+
friend constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
|
| 2849 |
+
};
|
| 2850 |
+
|
| 2851 |
+
// valid values' definitions
|
| 2852 |
+
inline constexpr partial_ordering partial_ordering::less(ord::less);
|
| 2853 |
+
inline constexpr partial_ordering partial_ordering::equivalent(eq::equivalent);
|
| 2854 |
+
inline constexpr partial_ordering partial_ordering::greater(ord::greater);
|
| 2855 |
+
inline constexpr partial_ordering partial_ordering::unordered(ncmp::unordered);
|
| 2856 |
+
}
|
| 2857 |
+
```
|
| 2858 |
+
|
| 2859 |
+
``` cpp
|
| 2860 |
+
constexpr bool operator==(partial_ordering v, unspecified) noexcept;
|
| 2861 |
+
constexpr bool operator< (partial_ordering v, unspecified) noexcept;
|
| 2862 |
+
constexpr bool operator> (partial_ordering v, unspecified) noexcept;
|
| 2863 |
+
constexpr bool operator<=(partial_ordering v, unspecified) noexcept;
|
| 2864 |
+
constexpr bool operator>=(partial_ordering v, unspecified) noexcept;
|
| 2865 |
+
```
|
| 2866 |
+
|
| 2867 |
+
*Returns:* For `operator`, `v.is_ordered && v.value 0`.
|
| 2868 |
+
|
| 2869 |
+
``` cpp
|
| 2870 |
+
constexpr bool operator< (unspecified, partial_ordering v) noexcept;
|
| 2871 |
+
constexpr bool operator> (unspecified, partial_ordering v) noexcept;
|
| 2872 |
+
constexpr bool operator<=(unspecified, partial_ordering v) noexcept;
|
| 2873 |
+
constexpr bool operator>=(unspecified, partial_ordering v) noexcept;
|
| 2874 |
+
```
|
| 2875 |
+
|
| 2876 |
+
*Returns:* For `operator`, `v.is_ordered && 0 v.value`.
|
| 2877 |
+
|
| 2878 |
+
``` cpp
|
| 2879 |
+
constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept;
|
| 2880 |
+
```
|
| 2881 |
+
|
| 2882 |
+
*Returns:* `v`.
|
| 2883 |
+
|
| 2884 |
+
``` cpp
|
| 2885 |
+
constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
|
| 2886 |
+
```
|
| 2887 |
+
|
| 2888 |
+
*Returns:*
|
| 2889 |
+
`v < 0 ? partial_ordering::greater : v > 0 ? partial_ordering::less : v`.
|
| 2890 |
+
|
| 2891 |
+
#### Class `weak_ordering` <a id="cmp.weakord">[[cmp.weakord]]</a>
|
| 2892 |
+
|
| 2893 |
+
The `weak_ordering` type is typically used as the result type of a
|
| 2894 |
+
three-way comparison operator [[expr.spaceship]] that (a) admits all of
|
| 2895 |
+
the six two-way comparison operators ([[expr.rel]], [[expr.eq]]), and
|
| 2896 |
+
(b) does not imply substitutability.
|
| 2897 |
+
|
| 2898 |
+
``` cpp
|
| 2899 |
+
namespace std {
|
| 2900 |
+
class weak_ordering {
|
| 2901 |
+
int value; // exposition only
|
| 2902 |
+
|
| 2903 |
+
// exposition-only constructors
|
| 2904 |
+
constexpr explicit weak_ordering(eq v) noexcept : value(int(v)) {} // exposition only
|
| 2905 |
+
constexpr explicit weak_ordering(ord v) noexcept : value(int(v)) {} // exposition only
|
| 2906 |
+
|
| 2907 |
+
public:
|
| 2908 |
+
// valid values
|
| 2909 |
+
static const weak_ordering less;
|
| 2910 |
+
static const weak_ordering equivalent;
|
| 2911 |
+
static const weak_ordering greater;
|
| 2912 |
+
|
| 2913 |
+
// conversions
|
| 2914 |
+
constexpr operator partial_ordering() const noexcept;
|
| 2915 |
+
|
| 2916 |
+
// comparisons
|
| 2917 |
+
friend constexpr bool operator==(weak_ordering v, unspecified) noexcept;
|
| 2918 |
+
friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default;
|
| 2919 |
+
friend constexpr bool operator< (weak_ordering v, unspecified) noexcept;
|
| 2920 |
+
friend constexpr bool operator> (weak_ordering v, unspecified) noexcept;
|
| 2921 |
+
friend constexpr bool operator<=(weak_ordering v, unspecified) noexcept;
|
| 2922 |
+
friend constexpr bool operator>=(weak_ordering v, unspecified) noexcept;
|
| 2923 |
+
friend constexpr bool operator< (unspecified, weak_ordering v) noexcept;
|
| 2924 |
+
friend constexpr bool operator> (unspecified, weak_ordering v) noexcept;
|
| 2925 |
+
friend constexpr bool operator<=(unspecified, weak_ordering v) noexcept;
|
| 2926 |
+
friend constexpr bool operator>=(unspecified, weak_ordering v) noexcept;
|
| 2927 |
+
friend constexpr weak_ordering operator<=>(weak_ordering v, unspecified) noexcept;
|
| 2928 |
+
friend constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
|
| 2929 |
+
};
|
| 2930 |
+
|
| 2931 |
+
// valid values' definitions
|
| 2932 |
+
inline constexpr weak_ordering weak_ordering::less(ord::less);
|
| 2933 |
+
inline constexpr weak_ordering weak_ordering::equivalent(eq::equivalent);
|
| 2934 |
+
inline constexpr weak_ordering weak_ordering::greater(ord::greater);
|
| 2935 |
+
}
|
| 2936 |
+
```
|
| 2937 |
+
|
| 2938 |
+
``` cpp
|
| 2939 |
+
constexpr operator partial_ordering() const noexcept;
|
| 2940 |
+
```
|
| 2941 |
+
|
| 2942 |
+
*Returns:*
|
| 2943 |
+
|
| 2944 |
+
``` cpp
|
| 2945 |
+
value == 0 ? partial_ordering::equivalent :
|
| 2946 |
+
value < 0 ? partial_ordering::less :
|
| 2947 |
+
partial_ordering::greater
|
| 2948 |
+
```
|
| 2949 |
+
|
| 2950 |
+
``` cpp
|
| 2951 |
+
constexpr bool operator==(weak_ordering v, unspecified) noexcept;
|
| 2952 |
+
constexpr bool operator< (weak_ordering v, unspecified) noexcept;
|
| 2953 |
+
constexpr bool operator> (weak_ordering v, unspecified) noexcept;
|
| 2954 |
+
constexpr bool operator<=(weak_ordering v, unspecified) noexcept;
|
| 2955 |
+
constexpr bool operator>=(weak_ordering v, unspecified) noexcept;
|
| 2956 |
+
```
|
| 2957 |
+
|
| 2958 |
+
*Returns:* `v.value 0` for `operator`.
|
| 2959 |
+
|
| 2960 |
+
``` cpp
|
| 2961 |
+
constexpr bool operator< (unspecified, weak_ordering v) noexcept;
|
| 2962 |
+
constexpr bool operator> (unspecified, weak_ordering v) noexcept;
|
| 2963 |
+
constexpr bool operator<=(unspecified, weak_ordering v) noexcept;
|
| 2964 |
+
constexpr bool operator>=(unspecified, weak_ordering v) noexcept;
|
| 2965 |
+
```
|
| 2966 |
+
|
| 2967 |
+
*Returns:* `0 v.value` for `operator`.
|
| 2968 |
+
|
| 2969 |
+
``` cpp
|
| 2970 |
+
constexpr weak_ordering operator<=>(weak_ordering v, unspecified) noexcept;
|
| 2971 |
+
```
|
| 2972 |
+
|
| 2973 |
+
*Returns:* `v`.
|
| 2974 |
+
|
| 2975 |
+
``` cpp
|
| 2976 |
+
constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
|
| 2977 |
+
```
|
| 2978 |
+
|
| 2979 |
+
*Returns:*
|
| 2980 |
+
`v < 0 ? weak_ordering::greater : v > 0 ? weak_ordering::less : v`.
|
| 2981 |
+
|
| 2982 |
+
#### Class `strong_ordering` <a id="cmp.strongord">[[cmp.strongord]]</a>
|
| 2983 |
+
|
| 2984 |
+
The `strong_ordering` type is typically used as the result type of a
|
| 2985 |
+
three-way comparison operator [[expr.spaceship]] that (a) admits all of
|
| 2986 |
+
the six two-way comparison operators ([[expr.rel]], [[expr.eq]]), and
|
| 2987 |
+
(b) does imply substitutability.
|
| 2988 |
+
|
| 2989 |
+
``` cpp
|
| 2990 |
+
namespace std {
|
| 2991 |
+
class strong_ordering {
|
| 2992 |
+
int value; // exposition only
|
| 2993 |
+
|
| 2994 |
+
// exposition-only constructors
|
| 2995 |
+
constexpr explicit strong_ordering(eq v) noexcept : value(int(v)) {} // exposition only
|
| 2996 |
+
constexpr explicit strong_ordering(ord v) noexcept : value(int(v)) {} // exposition only
|
| 2997 |
+
|
| 2998 |
+
public:
|
| 2999 |
+
// valid values
|
| 3000 |
+
static const strong_ordering less;
|
| 3001 |
+
static const strong_ordering equal;
|
| 3002 |
+
static const strong_ordering equivalent;
|
| 3003 |
+
static const strong_ordering greater;
|
| 3004 |
+
|
| 3005 |
+
// conversions
|
| 3006 |
+
constexpr operator partial_ordering() const noexcept;
|
| 3007 |
+
constexpr operator weak_ordering() const noexcept;
|
| 3008 |
+
|
| 3009 |
+
// comparisons
|
| 3010 |
+
friend constexpr bool operator==(strong_ordering v, unspecified) noexcept;
|
| 3011 |
+
friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default;
|
| 3012 |
+
friend constexpr bool operator< (strong_ordering v, unspecified) noexcept;
|
| 3013 |
+
friend constexpr bool operator> (strong_ordering v, unspecified) noexcept;
|
| 3014 |
+
friend constexpr bool operator<=(strong_ordering v, unspecified) noexcept;
|
| 3015 |
+
friend constexpr bool operator>=(strong_ordering v, unspecified) noexcept;
|
| 3016 |
+
friend constexpr bool operator< (unspecified, strong_ordering v) noexcept;
|
| 3017 |
+
friend constexpr bool operator> (unspecified, strong_ordering v) noexcept;
|
| 3018 |
+
friend constexpr bool operator<=(unspecified, strong_ordering v) noexcept;
|
| 3019 |
+
friend constexpr bool operator>=(unspecified, strong_ordering v) noexcept;
|
| 3020 |
+
friend constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept;
|
| 3021 |
+
friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;
|
| 3022 |
+
};
|
| 3023 |
+
|
| 3024 |
+
// valid values' definitions
|
| 3025 |
+
inline constexpr strong_ordering strong_ordering::less(ord::less);
|
| 3026 |
+
inline constexpr strong_ordering strong_ordering::equal(eq::equal);
|
| 3027 |
+
inline constexpr strong_ordering strong_ordering::equivalent(eq::equivalent);
|
| 3028 |
+
inline constexpr strong_ordering strong_ordering::greater(ord::greater);
|
| 3029 |
+
}
|
| 3030 |
+
```
|
| 3031 |
+
|
| 3032 |
+
``` cpp
|
| 3033 |
+
constexpr operator partial_ordering() const noexcept;
|
| 3034 |
+
```
|
| 3035 |
+
|
| 3036 |
+
*Returns:*
|
| 3037 |
+
|
| 3038 |
+
``` cpp
|
| 3039 |
+
value == 0 ? partial_ordering::equivalent :
|
| 3040 |
+
value < 0 ? partial_ordering::less :
|
| 3041 |
+
partial_ordering::greater
|
| 3042 |
+
```
|
| 3043 |
+
|
| 3044 |
+
``` cpp
|
| 3045 |
+
constexpr operator weak_ordering() const noexcept;
|
| 3046 |
+
```
|
| 3047 |
+
|
| 3048 |
+
*Returns:*
|
| 3049 |
+
|
| 3050 |
+
``` cpp
|
| 3051 |
+
value == 0 ? weak_ordering::equivalent :
|
| 3052 |
+
value < 0 ? weak_ordering::less :
|
| 3053 |
+
weak_ordering::greater
|
| 3054 |
+
```
|
| 3055 |
+
|
| 3056 |
+
``` cpp
|
| 3057 |
+
constexpr bool operator==(strong_ordering v, unspecified) noexcept;
|
| 3058 |
+
constexpr bool operator< (strong_ordering v, unspecified) noexcept;
|
| 3059 |
+
constexpr bool operator> (strong_ordering v, unspecified) noexcept;
|
| 3060 |
+
constexpr bool operator<=(strong_ordering v, unspecified) noexcept;
|
| 3061 |
+
constexpr bool operator>=(strong_ordering v, unspecified) noexcept;
|
| 3062 |
+
```
|
| 3063 |
+
|
| 3064 |
+
*Returns:* `v.value 0` for `operator`.
|
| 3065 |
+
|
| 3066 |
+
``` cpp
|
| 3067 |
+
constexpr bool operator< (unspecified, strong_ordering v) noexcept;
|
| 3068 |
+
constexpr bool operator> (unspecified, strong_ordering v) noexcept;
|
| 3069 |
+
constexpr bool operator<=(unspecified, strong_ordering v) noexcept;
|
| 3070 |
+
constexpr bool operator>=(unspecified, strong_ordering v) noexcept;
|
| 3071 |
+
```
|
| 3072 |
+
|
| 3073 |
+
*Returns:* `0 v.value` for `operator`.
|
| 3074 |
+
|
| 3075 |
+
``` cpp
|
| 3076 |
+
constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept;
|
| 3077 |
+
```
|
| 3078 |
+
|
| 3079 |
+
*Returns:* `v`.
|
| 3080 |
+
|
| 3081 |
+
``` cpp
|
| 3082 |
+
constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;
|
| 3083 |
+
```
|
| 3084 |
+
|
| 3085 |
+
*Returns:*
|
| 3086 |
+
`v < 0 ? strong_ordering::greater : v > 0 ? strong_ordering::less : v`.
|
| 3087 |
+
|
| 3088 |
+
### Class template `common_comparison_category` <a id="cmp.common">[[cmp.common]]</a>
|
| 3089 |
+
|
| 3090 |
+
The type `common_comparison_category` provides an alias for the
|
| 3091 |
+
strongest comparison category to which all of the template arguments can
|
| 3092 |
+
be converted.
|
| 3093 |
+
|
| 3094 |
+
[*Note 1*: A comparison category type is stronger than another if they
|
| 3095 |
+
are distinct types and an instance of the former can be converted to an
|
| 3096 |
+
instance of the latter. — *end note*]
|
| 3097 |
+
|
| 3098 |
+
``` cpp
|
| 3099 |
+
template<class... Ts>
|
| 3100 |
+
struct common_comparison_category {
|
| 3101 |
+
using type = see below;
|
| 3102 |
+
};
|
| 3103 |
+
```
|
| 3104 |
+
|
| 3105 |
+
*Remarks:* The member *typedef-name* `type` denotes the common
|
| 3106 |
+
comparison type [[class.spaceship]] of `Ts...`, the expanded parameter
|
| 3107 |
+
pack, or `void` if any element of `Ts` is not a comparison category
|
| 3108 |
+
type.
|
| 3109 |
+
|
| 3110 |
+
[*Note 1*: This is `std::strong_ordering` if the expansion is
|
| 3111 |
+
empty. — *end note*]
|
| 3112 |
+
|
| 3113 |
+
### Concept `three_way_comparable` <a id="cmp.concept">[[cmp.concept]]</a>
|
| 3114 |
+
|
| 3115 |
+
``` cpp
|
| 3116 |
+
template<class T, class Cat>
|
| 3117 |
+
concept compares-as = // exposition only
|
| 3118 |
+
same_as<common_comparison_category_t<T, Cat>, Cat>;
|
| 3119 |
+
|
| 3120 |
+
template<class T, class U>
|
| 3121 |
+
concept partially-ordered-with = // exposition only
|
| 3122 |
+
requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) {
|
| 3123 |
+
{ t < u } -> boolean-testable;
|
| 3124 |
+
{ t > u } -> boolean-testable;
|
| 3125 |
+
{ t <= u } -> boolean-testable;
|
| 3126 |
+
{ t >= u } -> boolean-testable;
|
| 3127 |
+
{ u < t } -> boolean-testable;
|
| 3128 |
+
{ u > t } -> boolean-testable;
|
| 3129 |
+
{ u <= t } -> boolean-testable;
|
| 3130 |
+
{ u >= t } -> boolean-testable;
|
| 3131 |
+
};
|
| 3132 |
+
```
|
| 3133 |
+
|
| 3134 |
+
Let `t` and `u` be lvalues of types `const remove_reference_t<T>` and
|
| 3135 |
+
`const remove_reference_t<U>`, respectively. `T` and `U` model
|
| 3136 |
+
`partially-ordered-with<T, U>` only if:
|
| 3137 |
+
|
| 3138 |
+
- `t < u`, `t <= u`, `t > u`, `t >= u`, `u < t`, `u <= t`, `u > t`, and
|
| 3139 |
+
`u >= t` have the same domain.
|
| 3140 |
+
- `bool(t < u) == bool(u > t)` is `true`,
|
| 3141 |
+
- `bool(u < t) == bool(t > u)` is `true`,
|
| 3142 |
+
- `bool(t <= u) == bool(u >= t)` is `true`, and
|
| 3143 |
+
- `bool(u <= t) == bool(t >= u)` is `true`.
|
| 3144 |
+
|
| 3145 |
+
``` cpp
|
| 3146 |
+
template<class T, class Cat = partial_ordering>
|
| 3147 |
+
concept three_way_comparable =
|
| 3148 |
+
weakly-equality-comparable-with<T, T> &&
|
| 3149 |
+
partially-ordered-with<T, T> &&
|
| 3150 |
+
requires(const remove_reference_t<T>& a, const remove_reference_t<T>& b) {
|
| 3151 |
+
{ a <=> b } -> compares-as<Cat>;
|
| 3152 |
+
};
|
| 3153 |
+
```
|
| 3154 |
+
|
| 3155 |
+
Let `a` and `b` be lvalues of type `const remove_reference_t<T>`. `T`
|
| 3156 |
+
and `Cat` model `three_way_comparable<T, Cat>` only if:
|
| 3157 |
+
|
| 3158 |
+
- `(a <=> b == 0) == bool(a == b)` is `true`,
|
| 3159 |
+
- `(a <=> b != 0) == bool(a != b)` is `true`,
|
| 3160 |
+
- `((a <=> b) <=> 0)` and `(0 <=> (b <=> a))` are equal,
|
| 3161 |
+
- `(a <=> b < 0) == bool(a < b)` is `true`,
|
| 3162 |
+
- `(a <=> b > 0) == bool(a > b)` is `true`,
|
| 3163 |
+
- `(a <=> b <= 0) == bool(a <= b)` is `true`,
|
| 3164 |
+
- `(a <=> b >= 0) == bool(a >= b)` is `true`, and
|
| 3165 |
+
- if `Cat` is convertible to `strong_ordering`, `T` models
|
| 3166 |
+
`totally_ordered` [[concept.totallyordered]].
|
| 3167 |
+
|
| 3168 |
+
``` cpp
|
| 3169 |
+
template<class T, class U, class Cat = partial_ordering>
|
| 3170 |
+
concept three_way_comparable_with =
|
| 3171 |
+
three_way_comparable<T, Cat> &&
|
| 3172 |
+
three_way_comparable<U, Cat> &&
|
| 3173 |
+
common_reference_with<const remove_reference_t<T>&, const remove_reference_t<U>&> &&
|
| 3174 |
+
three_way_comparable<
|
| 3175 |
+
common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>, Cat> &&
|
| 3176 |
+
weakly-equality-comparable-with<T, U> &&
|
| 3177 |
+
partially-ordered-with<T, U> &&
|
| 3178 |
+
requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) {
|
| 3179 |
+
{ t <=> u } -> compares-as<Cat>;
|
| 3180 |
+
{ u <=> t } -> compares-as<Cat>;
|
| 3181 |
+
};
|
| 3182 |
+
```
|
| 3183 |
+
|
| 3184 |
+
Let `t` and `u` be lvalues of types `const remove_reference_t<T>` and
|
| 3185 |
+
`const remove_reference_t<U>`, respectively. Let `C` be
|
| 3186 |
+
`common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>`.
|
| 3187 |
+
`T`, `U`, and `Cat` model `three_way_comparable_with<T, U, Cat>` only
|
| 3188 |
+
if:
|
| 3189 |
+
|
| 3190 |
+
- `t <=> u` and `u <=> t` have the same domain,
|
| 3191 |
+
- `((t <=> u) <=> 0)` and `(0 <=> (u <=> t))` are equal,
|
| 3192 |
+
- `(t <=> u == 0) == bool(t == u)` is `true`,
|
| 3193 |
+
- `(t <=> u != 0) == bool(t != u)` is `true`,
|
| 3194 |
+
- `Cat(t <=> u) == Cat(C(t) <=> C(u))` is `true`,
|
| 3195 |
+
- `(t <=> u < 0) == bool(t < u)` is `true`,
|
| 3196 |
+
- `(t <=> u > 0) == bool(t > u)` is `true`,
|
| 3197 |
+
- `(t <=> u <= 0) == bool(t <= u)` is `true`,
|
| 3198 |
+
- `(t <=> u >= 0) == bool(t >= u)` is `true`, and
|
| 3199 |
+
- if `Cat` is convertible to `strong_ordering`, `T` and `U` model
|
| 3200 |
+
`totally_ordered_with<T, U>` [[concept.totallyordered]].
|
| 3201 |
+
|
| 3202 |
+
### Result of three-way comparison <a id="cmp.result">[[cmp.result]]</a>
|
| 3203 |
+
|
| 3204 |
+
The behavior of a program that adds specializations for the
|
| 3205 |
+
`compare_three_way_result` template defined in this subclause is
|
| 3206 |
+
undefined.
|
| 3207 |
+
|
| 3208 |
+
For the `compare_three_way_result` type trait applied to the types `T`
|
| 3209 |
+
and `U`, let `t` and `u` denote lvalues of types
|
| 3210 |
+
`const remove_reference_t<T>` and `const remove_reference_t<U>`,
|
| 3211 |
+
respectively. If the expression `t <=> u` is well-formed when treated as
|
| 3212 |
+
an unevaluated operand [[expr.context]], the member *typedef-name*
|
| 3213 |
+
`type` denotes the type `decltype(t <=> u)`. Otherwise, there is no
|
| 3214 |
+
member `type`.
|
| 3215 |
+
|
| 3216 |
+
### Comparison algorithms <a id="cmp.alg">[[cmp.alg]]</a>
|
| 3217 |
+
|
| 3218 |
+
The name `strong_order` denotes a customization point object
|
| 3219 |
+
[[customization.point.object]]. Given subexpressions `E` and `F`, the
|
| 3220 |
+
expression `strong_order(E, F)` is expression-equivalent
|
| 3221 |
+
[[defns.expression-equivalent]] to the following:
|
| 3222 |
+
|
| 3223 |
+
- If the decayed types of `E` and `F` differ, `strong_order(E, F)` is
|
| 3224 |
+
ill-formed.
|
| 3225 |
+
- Otherwise, `strong_ordering(strong_order(E, F))` if it is a
|
| 3226 |
+
well-formed expression with overload resolution performed in a context
|
| 3227 |
+
that does not include a declaration of `std::strong_order`.
|
| 3228 |
+
- Otherwise, if the decayed type `T` of `E` is a floating-point type,
|
| 3229 |
+
yields a value of type `strong_ordering` that is consistent with the
|
| 3230 |
+
ordering observed by `T`’s comparison operators, and if
|
| 3231 |
+
`numeric_limits<T>::is_iec559` is `true`, is additionally consistent
|
| 3232 |
+
with the `totalOrder` operation as specified in ISO/IEC/IEEE 60559.
|
| 3233 |
+
- Otherwise, `strong_ordering(compare_three_way()(E, F))` if it is a
|
| 3234 |
+
well-formed expression.
|
| 3235 |
+
- Otherwise, `strong_order(E, F)` is ill-formed. \[*Note 1*: This case
|
| 3236 |
+
can result in substitution failure when `strong_order(E, F)` appears
|
| 3237 |
+
in the immediate context of a template instantiation. — *end note*]
|
| 3238 |
+
|
| 3239 |
+
The name `weak_order` denotes a customization point object
|
| 3240 |
+
[[customization.point.object]]. Given subexpressions `E` and `F`, the
|
| 3241 |
+
expression `weak_order(E, F)` is expression-equivalent
|
| 3242 |
+
[[defns.expression-equivalent]] to the following:
|
| 3243 |
+
|
| 3244 |
+
- If the decayed types of `E` and `F` differ, `weak_order(E, F)` is
|
| 3245 |
+
ill-formed.
|
| 3246 |
+
- Otherwise, `weak_ordering(weak_order(E, F))` if it is a well-formed
|
| 3247 |
+
expression with overload resolution performed in a context that does
|
| 3248 |
+
not include a declaration of `std::weak_order`.
|
| 3249 |
+
- Otherwise, if the decayed type `T` of `E` is a floating-point type,
|
| 3250 |
+
yields a value of type `weak_ordering` that is consistent with the
|
| 3251 |
+
ordering observed by `T`’s comparison operators and `strong_order`,
|
| 3252 |
+
and if `numeric_limits<T>::is_iec559` is `true`, is additionally
|
| 3253 |
+
consistent with the following equivalence classes, ordered from lesser
|
| 3254 |
+
to greater:
|
| 3255 |
+
- together, all negative NaN values;
|
| 3256 |
+
- negative infinity;
|
| 3257 |
+
- each normal negative value;
|
| 3258 |
+
- each subnormal negative value;
|
| 3259 |
+
- together, both zero values;
|
| 3260 |
+
- each subnormal positive value;
|
| 3261 |
+
- each normal positive value;
|
| 3262 |
+
- positive infinity;
|
| 3263 |
+
- together, all positive NaN values.
|
| 3264 |
+
- Otherwise, `weak_ordering(compare_three_way()(E, F))` if it is a
|
| 3265 |
+
well-formed expression.
|
| 3266 |
+
- Otherwise, `weak_ordering(strong_order(E, F))` if it is a well-formed
|
| 3267 |
+
expression.
|
| 3268 |
+
- Otherwise, `weak_order(E, F)` is ill-formed. \[*Note 2*: This case can
|
| 3269 |
+
result in substitution failure when `std::weak_order(E, F)` appears in
|
| 3270 |
+
the immediate context of a template instantiation. — *end note*]
|
| 3271 |
+
|
| 3272 |
+
The name `partial_order` denotes a customization point object
|
| 3273 |
+
[[customization.point.object]]. Given subexpressions `E` and `F`, the
|
| 3274 |
+
expression `partial_order(E, F)` is expression-equivalent
|
| 3275 |
+
[[defns.expression-equivalent]] to the following:
|
| 3276 |
+
|
| 3277 |
+
- If the decayed types of `E` and `F` differ, `partial_order(E, F)` is
|
| 3278 |
+
ill-formed.
|
| 3279 |
+
- Otherwise, `partial_ordering(partial_order(E, F))` if it is a
|
| 3280 |
+
well-formed expression with overload resolution performed in a context
|
| 3281 |
+
that does not include a declaration of `std::partial_order`.
|
| 3282 |
+
- Otherwise, `partial_ordering(compare_three_way()(E, F))` if it is a
|
| 3283 |
+
well-formed expression.
|
| 3284 |
+
- Otherwise, `partial_ordering(weak_order(E, F))` if it is a well-formed
|
| 3285 |
+
expression.
|
| 3286 |
+
- Otherwise, `partial_order(E, F)` is ill-formed. \[*Note 3*: This case
|
| 3287 |
+
can result in substitution failure when `std::partial_order(E, F)`
|
| 3288 |
+
appears in the immediate context of a template
|
| 3289 |
+
instantiation. — *end note*]
|
| 3290 |
+
|
| 3291 |
+
The name `compare_strong_order_fallback` denotes a customization point
|
| 3292 |
+
object [[customization.point.object]]. Given subexpressions `E` and F,
|
| 3293 |
+
the expression `compare_strong_order_fallback(E, F)` is
|
| 3294 |
+
expression-equivalent [[defns.expression-equivalent]] to:
|
| 3295 |
+
|
| 3296 |
+
- If the decayed types of `E` and `F` differ,
|
| 3297 |
+
`compare_strong_order_fallback(E, F)` is ill-formed.
|
| 3298 |
+
- Otherwise, `strong_order(E, F)` if it is a well-formed expression.
|
| 3299 |
+
- Otherwise, if the expressions `E == F` and `E < F` are both
|
| 3300 |
+
well-formed and convertible to `bool`,
|
| 3301 |
+
``` cpp
|
| 3302 |
+
E == F ? strong_ordering::equal :
|
| 3303 |
+
E < F ? strong_ordering::less :
|
| 3304 |
+
strong_ordering::greater
|
| 3305 |
+
```
|
| 3306 |
+
|
| 3307 |
+
except that `E` and `F` are evaluated only once.
|
| 3308 |
+
- Otherwise, `compare_strong_order_fallback(E, F)` is ill-formed.
|
| 3309 |
+
|
| 3310 |
+
The name `compare_weak_order_fallback` denotes a customization point
|
| 3311 |
+
object [[customization.point.object]]. Given subexpressions `E` and `F`,
|
| 3312 |
+
the expression `compare_weak_order_fallback(E, F)` is
|
| 3313 |
+
expression-equivalent [[defns.expression-equivalent]] to:
|
| 3314 |
+
|
| 3315 |
+
- If the decayed types of `E` and `F` differ,
|
| 3316 |
+
`compare_weak_order_fallback(E, F)` is ill-formed.
|
| 3317 |
+
- Otherwise, `weak_order(E, F)` if it is a well-formed expression.
|
| 3318 |
+
- Otherwise, if the expressions `E == F` and `E < F` are both
|
| 3319 |
+
well-formed and convertible to `bool`,
|
| 3320 |
+
``` cpp
|
| 3321 |
+
E == F ? weak_ordering::equivalent :
|
| 3322 |
+
E < F ? weak_ordering::less :
|
| 3323 |
+
weak_ordering::greater
|
| 3324 |
+
```
|
| 3325 |
+
|
| 3326 |
+
except that `E` and `F` are evaluated only once.
|
| 3327 |
+
- Otherwise, `compare_weak_order_fallback(E, F)` is ill-formed.
|
| 3328 |
+
|
| 3329 |
+
The name `compare_partial_order_fallback` denotes a customization point
|
| 3330 |
+
object [[customization.point.object]]. Given subexpressions `E` and `F`,
|
| 3331 |
+
the expression `compare_partial_order_fallback(E, F)` is
|
| 3332 |
+
expression-equivalent [[defns.expression-equivalent]] to:
|
| 3333 |
+
|
| 3334 |
+
- If the decayed types of `E` and `F` differ,
|
| 3335 |
+
`compare_partial_order_fallback(E, F)` is ill-formed.
|
| 3336 |
+
- Otherwise, `partial_order(E, F)` if it is a well-formed expression.
|
| 3337 |
+
- Otherwise, if the expressions `E == F` and `E < F` are both
|
| 3338 |
+
well-formed and convertible to `bool`,
|
| 3339 |
+
``` cpp
|
| 3340 |
+
E == F ? partial_ordering::equivalent :
|
| 3341 |
+
E < F ? partial_ordering::less :
|
| 3342 |
+
F < E ? partial_ordering::greater :
|
| 3343 |
+
partial_ordering::unordered
|
| 3344 |
+
```
|
| 3345 |
+
|
| 3346 |
+
except that `E` and `F` are evaluated only once.
|
| 3347 |
+
- Otherwise, `compare_partial_order_fallback(E, F)` is ill-formed.
|
| 3348 |
+
|
| 3349 |
+
## Coroutines <a id="support.coroutine">[[support.coroutine]]</a>
|
| 3350 |
+
|
| 3351 |
+
The header `<coroutine>` defines several types providing compile and
|
| 3352 |
+
run-time support for coroutines in a C++ program.
|
| 3353 |
+
|
| 3354 |
+
### Header `<coroutine>` synopsis <a id="coroutine.syn">[[coroutine.syn]]</a>
|
| 3355 |
+
|
| 3356 |
+
``` cpp
|
| 3357 |
+
#include <compare> // see [compare.syn]
|
| 3358 |
+
|
| 3359 |
+
namespace std {
|
| 3360 |
+
// [coroutine.traits], coroutine traits
|
| 3361 |
+
template<class R, class... ArgTypes>
|
| 3362 |
+
struct coroutine_traits;
|
| 3363 |
+
|
| 3364 |
+
// [coroutine.handle], coroutine handle
|
| 3365 |
+
template<class Promise = void>
|
| 3366 |
+
struct coroutine_handle;
|
| 3367 |
+
|
| 3368 |
+
// [coroutine.handle.compare], comparison operators
|
| 3369 |
+
constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
|
| 3370 |
+
constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
|
| 3371 |
+
|
| 3372 |
+
// [coroutine.handle.hash], hash support
|
| 3373 |
+
template<class T> struct hash;
|
| 3374 |
+
template<class P> struct hash<coroutine_handle<P>>;
|
| 3375 |
+
|
| 3376 |
+
// [coroutine.noop], no-op coroutines
|
| 3377 |
+
struct noop_coroutine_promise;
|
| 3378 |
+
|
| 3379 |
+
template<> struct coroutine_handle<noop_coroutine_promise>;
|
| 3380 |
+
using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
|
| 3381 |
+
|
| 3382 |
+
noop_coroutine_handle noop_coroutine() noexcept;
|
| 3383 |
+
|
| 3384 |
+
// [coroutine.trivial.awaitables], trivial awaitables
|
| 3385 |
+
struct suspend_never;
|
| 3386 |
+
struct suspend_always;
|
| 3387 |
+
}
|
| 3388 |
+
```
|
| 3389 |
+
|
| 3390 |
+
### Coroutine traits <a id="coroutine.traits">[[coroutine.traits]]</a>
|
| 3391 |
+
|
| 3392 |
+
This subclause defines requirements on classes representing *coroutine
|
| 3393 |
+
traits*, and defines the class template `coroutine_traits` that meets
|
| 3394 |
+
those requirements.
|
| 3395 |
+
|
| 3396 |
+
#### Class template `coroutine_traits` <a id="coroutine.traits.primary">[[coroutine.traits.primary]]</a>
|
| 3397 |
+
|
| 3398 |
+
The header `<coroutine>` defines the primary template `coroutine_traits`
|
| 3399 |
+
such that if `ArgTypes` is a parameter pack of types and if the
|
| 3400 |
+
*qualified-id* `R::promise_type` is valid and denotes a type
|
| 3401 |
+
[[temp.deduct]], then `coroutine_traits<R,ArgTypes...>` has the
|
| 3402 |
+
following publicly accessible member:
|
| 3403 |
+
|
| 3404 |
+
``` cpp
|
| 3405 |
+
using promise_type = typename R::promise_type;
|
| 3406 |
+
```
|
| 3407 |
+
|
| 3408 |
+
Otherwise, `coroutine_traits<R,ArgTypes...>` has no members.
|
| 3409 |
+
|
| 3410 |
+
Program-defined specializations of this template shall define a publicly
|
| 3411 |
+
accessible nested type named `promise_type`.
|
| 3412 |
+
|
| 3413 |
+
### Class template `coroutine_handle` <a id="coroutine.handle">[[coroutine.handle]]</a>
|
| 3414 |
+
|
| 3415 |
+
``` cpp
|
| 3416 |
+
namespace std {
|
| 3417 |
+
template<>
|
| 3418 |
+
struct coroutine_handle<void>
|
| 3419 |
+
{
|
| 3420 |
+
// [coroutine.handle.con], construct/reset
|
| 3421 |
+
constexpr coroutine_handle() noexcept;
|
| 3422 |
+
constexpr coroutine_handle(nullptr_t) noexcept;
|
| 3423 |
+
coroutine_handle& operator=(nullptr_t) noexcept;
|
| 3424 |
+
|
| 3425 |
+
// [coroutine.handle.export.import], export/import
|
| 3426 |
+
constexpr void* address() const noexcept;
|
| 3427 |
+
static constexpr coroutine_handle from_address(void* addr);
|
| 3428 |
+
|
| 3429 |
+
// [coroutine.handle.observers], observers
|
| 3430 |
+
constexpr explicit operator bool() const noexcept;
|
| 3431 |
+
bool done() const;
|
| 3432 |
+
|
| 3433 |
+
// [coroutine.handle.resumption], resumption
|
| 3434 |
+
void operator()() const;
|
| 3435 |
+
void resume() const;
|
| 3436 |
+
void destroy() const;
|
| 3437 |
+
|
| 3438 |
+
private:
|
| 3439 |
+
void* ptr; // exposition only
|
| 3440 |
+
};
|
| 3441 |
+
|
| 3442 |
+
template<class Promise>
|
| 3443 |
+
struct coroutine_handle : coroutine_handle<>
|
| 3444 |
+
{
|
| 3445 |
+
// [coroutine.handle.con], construct/reset
|
| 3446 |
+
using coroutine_handle<>::coroutine_handle;
|
| 3447 |
+
static coroutine_handle from_promise(Promise&);
|
| 3448 |
+
coroutine_handle& operator=(nullptr_t) noexcept;
|
| 3449 |
+
|
| 3450 |
+
// [coroutine.handle.export.import], export/import
|
| 3451 |
+
static constexpr coroutine_handle from_address(void* addr);
|
| 3452 |
+
|
| 3453 |
+
// [coroutine.handle.promise], promise access
|
| 3454 |
+
Promise& promise() const;
|
| 3455 |
+
};
|
| 3456 |
+
}
|
| 3457 |
+
```
|
| 3458 |
+
|
| 3459 |
+
An object of type `coroutine_handle<T>` is called a *coroutine handle*
|
| 3460 |
+
and can be used to refer to a suspended or executing coroutine. A
|
| 3461 |
+
default-constructed `coroutine_handle` object does not refer to any
|
| 3462 |
+
coroutine.
|
| 3463 |
+
|
| 3464 |
+
If a program declares an explicit or partial specialization of
|
| 3465 |
+
`coroutine_handle`, the behavior is undefined.
|
| 3466 |
+
|
| 3467 |
+
#### Construct/reset <a id="coroutine.handle.con">[[coroutine.handle.con]]</a>
|
| 3468 |
+
|
| 3469 |
+
``` cpp
|
| 3470 |
+
constexpr coroutine_handle() noexcept;
|
| 3471 |
+
constexpr coroutine_handle(nullptr_t) noexcept;
|
| 3472 |
+
```
|
| 3473 |
+
|
| 3474 |
+
*Ensures:* `address() == nullptr`.
|
| 3475 |
+
|
| 3476 |
+
``` cpp
|
| 3477 |
+
static coroutine_handle from_promise(Promise& p);
|
| 3478 |
+
```
|
| 3479 |
+
|
| 3480 |
+
*Preconditions:* `p` is a reference to a promise object of a coroutine.
|
| 3481 |
+
|
| 3482 |
+
*Returns:* A coroutine handle `h` referring to the coroutine.
|
| 3483 |
+
|
| 3484 |
+
*Ensures:* `addressof(h.promise()) == addressof(p)`.
|
| 3485 |
+
|
| 3486 |
+
``` cpp
|
| 3487 |
+
coroutine_handle& operator=(nullptr_t) noexcept;
|
| 3488 |
+
```
|
| 3489 |
+
|
| 3490 |
+
*Ensures:* `address() == nullptr`.
|
| 3491 |
+
|
| 3492 |
+
*Returns:* `*this`.
|
| 3493 |
+
|
| 3494 |
+
#### Export/import <a id="coroutine.handle.export.import">[[coroutine.handle.export.import]]</a>
|
| 3495 |
+
|
| 3496 |
+
``` cpp
|
| 3497 |
+
constexpr void* address() const noexcept;
|
| 3498 |
+
```
|
| 3499 |
+
|
| 3500 |
+
*Returns:* `ptr`.
|
| 3501 |
+
|
| 3502 |
+
``` cpp
|
| 3503 |
+
static constexpr coroutine_handle<> coroutine_handle<>::from_address(void* addr);
|
| 3504 |
+
static constexpr coroutine_handle<Promise> coroutine_handle<Promise>::from_address(void* addr);
|
| 3505 |
+
```
|
| 3506 |
+
|
| 3507 |
+
*Preconditions:* `addr` was obtained via a prior call to `address`.
|
| 3508 |
+
|
| 3509 |
+
*Ensures:* `from_address(address()) == *this`.
|
| 3510 |
+
|
| 3511 |
+
#### Observers <a id="coroutine.handle.observers">[[coroutine.handle.observers]]</a>
|
| 3512 |
+
|
| 3513 |
+
``` cpp
|
| 3514 |
+
constexpr explicit operator bool() const noexcept;
|
| 3515 |
+
```
|
| 3516 |
+
|
| 3517 |
+
*Returns:* `address() != nullptr`.
|
| 3518 |
+
|
| 3519 |
+
``` cpp
|
| 3520 |
+
bool done() const;
|
| 3521 |
+
```
|
| 3522 |
+
|
| 3523 |
+
*Preconditions:* `*this` refers to a suspended coroutine.
|
| 3524 |
+
|
| 3525 |
+
*Returns:* `true` if the coroutine is suspended at its final suspend
|
| 3526 |
+
point, otherwise `false`.
|
| 3527 |
+
|
| 3528 |
+
#### Resumption <a id="coroutine.handle.resumption">[[coroutine.handle.resumption]]</a>
|
| 3529 |
+
|
| 3530 |
+
Resuming a coroutine via `resume`, `operator()`, or `destroy` on an
|
| 3531 |
+
execution agent other than the one on which it was suspended has
|
| 3532 |
+
implementation-defined behavior unless each execution agent either is an
|
| 3533 |
+
instance of `std::thread` or `std::jthread`, or is the thread that
|
| 3534 |
+
executes `main`.
|
| 3535 |
+
|
| 3536 |
+
[*Note 1*: A coroutine that is resumed on a different execution agent
|
| 3537 |
+
should avoid relying on consistent thread identity throughout, such as
|
| 3538 |
+
holding a mutex object across a suspend point. — *end note*]
|
| 3539 |
+
|
| 3540 |
+
[*Note 2*: A concurrent resumption of the coroutine may result in a
|
| 3541 |
+
data race. — *end note*]
|
| 3542 |
+
|
| 3543 |
+
``` cpp
|
| 3544 |
+
void operator()() const;
|
| 3545 |
+
void resume() const;
|
| 3546 |
+
```
|
| 3547 |
+
|
| 3548 |
+
*Preconditions:* `*this` refers to a suspended coroutine. The coroutine
|
| 3549 |
+
is not suspended at its final suspend point.
|
| 3550 |
+
|
| 3551 |
+
*Effects:* Resumes the execution of the coroutine.
|
| 3552 |
+
|
| 3553 |
+
``` cpp
|
| 3554 |
+
void destroy() const;
|
| 3555 |
+
```
|
| 3556 |
+
|
| 3557 |
+
*Preconditions:* `*this` refers to a suspended coroutine.
|
| 3558 |
+
|
| 3559 |
+
*Effects:* Destroys the coroutine [[dcl.fct.def.coroutine]].
|
| 3560 |
+
|
| 3561 |
+
#### Promise access <a id="coroutine.handle.promise">[[coroutine.handle.promise]]</a>
|
| 3562 |
+
|
| 3563 |
+
``` cpp
|
| 3564 |
+
Promise& promise() const;
|
| 3565 |
+
```
|
| 3566 |
+
|
| 3567 |
+
*Preconditions:* `*this` refers to a coroutine.
|
| 3568 |
+
|
| 3569 |
+
*Returns:* A reference to the promise of the coroutine.
|
| 3570 |
+
|
| 3571 |
+
#### Comparison operators <a id="coroutine.handle.compare">[[coroutine.handle.compare]]</a>
|
| 3572 |
+
|
| 3573 |
+
``` cpp
|
| 3574 |
+
constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
|
| 3575 |
+
```
|
| 3576 |
+
|
| 3577 |
+
*Returns:* `x.address() == y.address()`.
|
| 3578 |
+
|
| 3579 |
+
``` cpp
|
| 3580 |
+
constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
|
| 3581 |
+
```
|
| 3582 |
+
|
| 3583 |
+
*Returns:* `compare_three_way()(x.address(), y.address())`.
|
| 3584 |
+
|
| 3585 |
+
#### Hash support <a id="coroutine.handle.hash">[[coroutine.handle.hash]]</a>
|
| 3586 |
+
|
| 3587 |
+
``` cpp
|
| 3588 |
+
template<class P> struct hash<coroutine_handle<P>>;
|
| 3589 |
+
```
|
| 3590 |
+
|
| 3591 |
+
The specialization is enabled [[unord.hash]].
|
| 3592 |
+
|
| 3593 |
+
### No-op coroutines <a id="coroutine.noop">[[coroutine.noop]]</a>
|
| 3594 |
+
|
| 3595 |
+
#### Class `noop_coroutine_promise` <a id="coroutine.promise.noop">[[coroutine.promise.noop]]</a>
|
| 3596 |
+
|
| 3597 |
+
``` cpp
|
| 3598 |
+
struct noop_coroutine_promise {};
|
| 3599 |
+
```
|
| 3600 |
+
|
| 3601 |
+
The class `noop_coroutine_promise` defines the promise type for the
|
| 3602 |
+
coroutine referred to by `noop_coroutine_handle` [[coroutine.syn]].
|
| 3603 |
+
|
| 3604 |
+
#### Class `coroutine_handle<noop_coroutine_promise>` <a id="coroutine.handle.noop">[[coroutine.handle.noop]]</a>
|
| 3605 |
+
|
| 3606 |
+
``` cpp
|
| 3607 |
+
namespace std {
|
| 3608 |
+
template<>
|
| 3609 |
+
struct coroutine_handle<noop_coroutine_promise> : coroutine_handle<>
|
| 3610 |
+
{
|
| 3611 |
+
// [coroutine.handle.noop.observers], observers
|
| 3612 |
+
constexpr explicit operator bool() const noexcept;
|
| 3613 |
+
constexpr bool done() const noexcept;
|
| 3614 |
+
|
| 3615 |
+
// [coroutine.handle.noop.resumption], resumption
|
| 3616 |
+
constexpr void operator()() const noexcept;
|
| 3617 |
+
constexpr void resume() const noexcept;
|
| 3618 |
+
constexpr void destroy() const noexcept;
|
| 3619 |
+
|
| 3620 |
+
// [coroutine.handle.noop.promise], promise access
|
| 3621 |
+
noop_coroutine_promise& promise() const noexcept;
|
| 3622 |
+
|
| 3623 |
+
// [coroutine.handle.noop.address], address
|
| 3624 |
+
constexpr void* address() const noexcept;
|
| 3625 |
+
private:
|
| 3626 |
+
coroutine_handle(unspecified);
|
| 3627 |
+
};
|
| 3628 |
+
}
|
| 3629 |
+
```
|
| 3630 |
+
|
| 3631 |
+
##### Observers <a id="coroutine.handle.noop.observers">[[coroutine.handle.noop.observers]]</a>
|
| 3632 |
+
|
| 3633 |
+
``` cpp
|
| 3634 |
+
constexpr explicit operator bool() const noexcept;
|
| 3635 |
+
```
|
| 3636 |
+
|
| 3637 |
+
*Returns:* `true`.
|
| 3638 |
+
|
| 3639 |
+
``` cpp
|
| 3640 |
+
constexpr bool done() const noexcept;
|
| 3641 |
+
```
|
| 3642 |
+
|
| 3643 |
+
*Returns:* `false`.
|
| 3644 |
+
|
| 3645 |
+
##### Resumption <a id="coroutine.handle.noop.resumption">[[coroutine.handle.noop.resumption]]</a>
|
| 3646 |
+
|
| 3647 |
+
``` cpp
|
| 3648 |
+
constexpr void operator()() const noexcept;
|
| 3649 |
+
constexpr void resume() const noexcept;
|
| 3650 |
+
constexpr void destroy() const noexcept;
|
| 3651 |
+
```
|
| 3652 |
+
|
| 3653 |
+
*Effects:* None.
|
| 3654 |
+
|
| 3655 |
+
*Remarks:* If `noop_coroutine_handle` is converted to
|
| 3656 |
+
`coroutine_handle<>`, calls to `operator()`, `resume` and `destroy` on
|
| 3657 |
+
that handle will also have no observable effects.
|
| 3658 |
+
|
| 3659 |
+
##### Promise access <a id="coroutine.handle.noop.promise">[[coroutine.handle.noop.promise]]</a>
|
| 3660 |
+
|
| 3661 |
+
``` cpp
|
| 3662 |
+
noop_coroutine_promise& promise() const noexcept;
|
| 3663 |
+
```
|
| 3664 |
+
|
| 3665 |
+
*Returns:* A reference to the promise object associated with this
|
| 3666 |
+
coroutine handle.
|
| 3667 |
+
|
| 3668 |
+
##### Address <a id="coroutine.handle.noop.address">[[coroutine.handle.noop.address]]</a>
|
| 3669 |
+
|
| 3670 |
+
``` cpp
|
| 3671 |
+
constexpr void* address() const noexcept;
|
| 3672 |
+
```
|
| 3673 |
+
|
| 3674 |
+
*Returns:* `ptr`.
|
| 3675 |
+
|
| 3676 |
+
*Remarks:* A `noop_coroutine_handle`’s `ptr` is always a non-null
|
| 3677 |
+
pointer value.
|
| 3678 |
+
|
| 3679 |
+
#### Function `noop_coroutine` <a id="coroutine.noop.coroutine">[[coroutine.noop.coroutine]]</a>
|
| 3680 |
+
|
| 3681 |
+
``` cpp
|
| 3682 |
+
noop_coroutine_handle noop_coroutine() noexcept;
|
| 3683 |
+
```
|
| 3684 |
+
|
| 3685 |
+
*Returns:* A handle to a coroutine that has no observable effects when
|
| 3686 |
+
resumed or destroyed.
|
| 3687 |
+
|
| 3688 |
+
*Remarks:* A handle returned from `noop_coroutine` may or may not
|
| 3689 |
+
compare equal to a handle returned from another invocation of
|
| 3690 |
+
`noop_coroutine`.
|
| 3691 |
+
|
| 3692 |
+
### Trivial awaitables <a id="coroutine.trivial.awaitables">[[coroutine.trivial.awaitables]]</a>
|
| 3693 |
+
|
| 3694 |
+
``` cpp
|
| 3695 |
+
namespace std {
|
| 3696 |
+
struct suspend_never {
|
| 3697 |
+
constexpr bool await_ready() const noexcept { return true; }
|
| 3698 |
+
constexpr void await_suspend(coroutine_handle<>) const noexcept {}
|
| 3699 |
+
constexpr void await_resume() const noexcept {}
|
| 3700 |
+
};
|
| 3701 |
+
struct suspend_always {
|
| 3702 |
+
constexpr bool await_ready() const noexcept { return false; }
|
| 3703 |
+
constexpr void await_suspend(coroutine_handle<>) const noexcept {}
|
| 3704 |
+
constexpr void await_resume() const noexcept {}
|
| 3705 |
+
};
|
| 3706 |
+
}
|
| 3707 |
+
```
|
| 3708 |
+
|
| 3709 |
+
[*Note 1*: The types `suspend_never` and `suspend_always` can be used
|
| 3710 |
+
to indicate that an *await-expression* should either never suspend or
|
| 3711 |
+
always suspend, and in either case not produce a value. — *end note*]
|
| 3712 |
+
|
| 3713 |
+
## Other runtime support <a id="support.runtime">[[support.runtime]]</a>
|
| 3714 |
+
|
| 3715 |
+
Headers `<csetjmp>` (nonlocal jumps), `<csignal>` (signal handling),
|
| 3716 |
+
`<cstdarg>` (variable arguments), and `<cstdlib>` (runtime environment
|
| 3717 |
+
`getenv`, `system`), provide further compatibility with C code.
|
| 3718 |
+
|
| 3719 |
+
Calls to the function `getenv` [[cstdlib.syn]] shall not introduce a
|
| 3720 |
+
data race [[res.on.data.races]] provided that nothing modifies the
|
| 3721 |
+
environment.
|
| 3722 |
+
|
| 3723 |
+
[*Note 1*: Calls to the POSIX functions `setenv` and `putenv` modify
|
| 3724 |
+
the environment. — *end note*]
|
| 3725 |
+
|
| 3726 |
+
A call to the `setlocale` function [[c.locales]] may introduce a data
|
| 3727 |
+
race with other calls to the `setlocale` function or with calls to
|
| 3728 |
+
functions that are affected by the current C locale. The implementation
|
| 3729 |
+
shall behave as if no library function other than `locale::global` calls
|
| 3730 |
+
the `setlocale` function.
|
| 3731 |
+
|
| 3732 |
+
### Header `<cstdarg>` synopsis <a id="cstdarg.syn">[[cstdarg.syn]]</a>
|
| 3733 |
+
|
| 3734 |
+
``` cpp
|
| 3735 |
+
namespace std {
|
| 3736 |
+
using va_list = see below;
|
| 3737 |
+
}
|
| 3738 |
+
|
| 3739 |
+
#define va_arg(V, P) see below
|
| 3740 |
+
#define va_copy(VDST, VSRC) see below
|
| 3741 |
+
#define va_end(V) see below
|
| 3742 |
+
#define va_start(V, P) see below
|
| 3743 |
+
```
|
| 3744 |
+
|
| 3745 |
+
The contents of the header `<cstdarg>` are the same as the C standard
|
| 3746 |
+
library header `<stdarg.h>`, with the following changes: The
|
| 3747 |
+
restrictions that ISO C places on the second parameter to the `va_start`
|
| 3748 |
+
macro in header `<stdarg.h>` are different in this document. The
|
| 3749 |
+
parameter `parmN` is the rightmost parameter in the variable parameter
|
| 3750 |
+
list of the function definition (the one just before the `...`).[^35] If
|
| 3751 |
+
the parameter `parmN` is a pack expansion [[temp.variadic]] or an entity
|
| 3752 |
+
resulting from a lambda capture [[expr.prim.lambda]], the program is
|
| 3753 |
+
ill-formed, no diagnostic required. If the parameter `parmN` is of a
|
| 3754 |
+
reference type, or of a type that is not compatible with the type that
|
| 3755 |
+
results when passing an argument for which there is no parameter, the
|
| 3756 |
+
behavior is undefined.
|
| 3757 |
+
|
| 3758 |
+
See also: ISO C 7.16.1.1
|
| 3759 |
+
|
| 3760 |
+
### Header `<csetjmp>` synopsis <a id="csetjmp.syn">[[csetjmp.syn]]</a>
|
| 3761 |
+
|
| 3762 |
+
``` cpp
|
| 3763 |
+
namespace std {
|
| 3764 |
+
using jmp_buf = see below;
|
| 3765 |
+
[[noreturn]] void longjmp(jmp_buf env, int val);
|
| 3766 |
+
}
|
| 3767 |
+
|
| 3768 |
+
#define setjmp(env) see below
|
| 3769 |
+
```
|
| 3770 |
+
|
| 3771 |
+
The contents of the header `<csetjmp>` are the same as the C standard
|
| 3772 |
+
library header `<setjmp.h>`.
|
| 3773 |
+
|
| 3774 |
+
The function signature `longjmp(jmp_buf jbuf, int val)` has more
|
| 3775 |
+
restricted behavior in this document. A `setjmp`/`longjmp` call pair has
|
| 3776 |
+
undefined behavior if replacing the `setjmp` and `longjmp` by `catch`
|
| 3777 |
+
and `throw` would invoke any non-trivial destructors for any objects
|
| 3778 |
+
with automatic storage duration. A call to `setjmp` or `longjmp` has
|
| 3779 |
+
undefined behavior if invoked in a suspension context of a coroutine
|
| 3780 |
+
[[expr.await]].
|
| 3781 |
+
|
| 3782 |
+
See also: ISO C 7.13
|
| 3783 |
+
|
| 3784 |
+
### Header `<csignal>` synopsis <a id="csignal.syn">[[csignal.syn]]</a>
|
| 3785 |
+
|
| 3786 |
+
``` cpp
|
| 3787 |
+
namespace std {
|
| 3788 |
+
using sig_atomic_t = see below;
|
| 3789 |
+
|
| 3790 |
+
// [support.signal], signal handlers
|
| 3791 |
+
extern "C" using signal-handler = void(int); // exposition only
|
| 3792 |
+
signal-handler* signal(int sig, signal-handler* func);
|
| 3793 |
+
|
| 3794 |
+
int raise(int sig);
|
| 3795 |
+
}
|
| 3796 |
+
|
| 3797 |
+
#define SIG_DFL see below
|
| 3798 |
+
#define SIG_ERR see below
|
| 3799 |
+
#define SIG_IGN see below
|
| 3800 |
+
#define SIGABRT see below
|
| 3801 |
+
#define SIGFPE see below
|
| 3802 |
+
#define SIGILL see below
|
| 3803 |
+
#define SIGINT see below
|
| 3804 |
+
#define SIGSEGV see below
|
| 3805 |
+
#define SIGTERM see below
|
| 3806 |
+
```
|
| 3807 |
+
|
| 3808 |
+
The contents of the header `<csignal>` are the same as the C standard
|
| 3809 |
+
library header `<signal.h>`.
|
| 3810 |
+
|
| 3811 |
+
### Signal handlers <a id="support.signal">[[support.signal]]</a>
|
| 3812 |
+
|
| 3813 |
+
A call to the function `signal` synchronizes with any resulting
|
| 3814 |
+
invocation of the signal handler so installed.
|
| 3815 |
+
|
| 3816 |
+
A *plain lock-free atomic operation* is an invocation of a function `f`
|
| 3817 |
+
from [[atomics]], such that:
|
| 3818 |
+
|
| 3819 |
+
- `f` is the function `atomic_is_lock_free()`, or
|
| 3820 |
+
- `f` is the member function `is_lock_free()`, or
|
| 3821 |
+
- `f` is a non-static member function invoked on an object `A`, such
|
| 3822 |
+
that `A.is_lock_free()` yields `true`, or
|
| 3823 |
+
- `f` is a non-member function, and for every pointer-to-atomic argument
|
| 3824 |
+
`A` passed to `f`, `atomic_is_lock_free(A)` yields `true`.
|
| 3825 |
+
|
| 3826 |
+
An evaluation is *signal-safe* unless it includes one of the following:
|
| 3827 |
+
|
| 3828 |
+
- a call to any standard library function, except for plain lock-free
|
| 3829 |
+
atomic operations and functions explicitly identified as signal-safe;
|
| 3830 |
+
\[*Note 1*: This implicitly excludes the use of `new` and `delete`
|
| 3831 |
+
expressions that rely on a library-provided memory
|
| 3832 |
+
allocator. — *end note*]
|
| 3833 |
+
- an access to an object with thread storage duration;
|
| 3834 |
+
- a `dynamic_cast` expression;
|
| 3835 |
+
- throwing of an exception;
|
| 3836 |
+
- control entering a *try-block* or *function-try-block*;
|
| 3837 |
+
- initialization of a variable with static storage duration requiring
|
| 3838 |
+
dynamic initialization ([[basic.start.dynamic]], [[stmt.dcl]]) [^36];
|
| 3839 |
+
or
|
| 3840 |
+
- waiting for the completion of the initialization of a variable with
|
| 3841 |
+
static storage duration [[stmt.dcl]].
|
| 3842 |
+
|
| 3843 |
+
A signal handler invocation has undefined behavior if it includes an
|
| 3844 |
+
evaluation that is not signal-safe.
|
| 3845 |
+
|
| 3846 |
+
The function `signal` is signal-safe if it is invoked with the first
|
| 3847 |
+
argument equal to the signal number corresponding to the signal that
|
| 3848 |
+
caused the invocation of the handler.
|
| 3849 |
+
|
| 3850 |
+
See also: ISO C 7.14
|
| 3851 |
+
|
| 3852 |
+
<!-- Link reference definitions -->
|
| 3853 |
+
[alg.c.library]: algorithms.md#alg.c.library
|
| 3854 |
+
[alloc.errors]: #alloc.errors
|
| 3855 |
+
[atomics]: atomics.md#atomics
|
| 3856 |
+
[bad.alloc]: #bad.alloc
|
| 3857 |
+
[bad.cast]: #bad.cast
|
| 3858 |
+
[bad.exception]: #bad.exception
|
| 3859 |
+
[bad.typeid]: #bad.typeid
|
| 3860 |
+
[basic.align]: basic.md#basic.align
|
| 3861 |
+
[basic.def.odr]: basic.md#basic.def.odr
|
| 3862 |
+
[basic.fundamental]: basic.md#basic.fundamental
|
| 3863 |
+
[basic.life]: basic.md#basic.life
|
| 3864 |
+
[basic.start.dynamic]: basic.md#basic.start.dynamic
|
| 3865 |
+
[basic.start.term]: basic.md#basic.start.term
|
| 3866 |
+
[basic.stc.dynamic]: basic.md#basic.stc.dynamic
|
| 3867 |
+
[basic.stc.dynamic.allocation]: basic.md#basic.stc.dynamic.allocation
|
| 3868 |
+
[basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
|
| 3869 |
+
[basic.stc.dynamic.safety]: basic.md#basic.stc.dynamic.safety
|
| 3870 |
+
[c.locales]: localization.md#c.locales
|
| 3871 |
+
[c.malloc]: utilities.md#c.malloc
|
| 3872 |
+
[c.math.abs]: numerics.md#c.math.abs
|
| 3873 |
+
[c.math.rand]: numerics.md#c.math.rand
|
| 3874 |
+
[c.mb.wcs]: strings.md#c.mb.wcs
|
| 3875 |
+
[cfloat.syn]: #cfloat.syn
|
| 3876 |
+
[class.mem]: class.md#class.mem
|
| 3877 |
+
[class.prop]: class.md#class.prop
|
| 3878 |
+
[class.spaceship]: class.md#class.spaceship
|
| 3879 |
+
[climits.syn]: #climits.syn
|
| 3880 |
+
[cmp]: #cmp
|
| 3881 |
+
[cmp.alg]: #cmp.alg
|
| 3882 |
+
[cmp.categories]: #cmp.categories
|
| 3883 |
+
[cmp.categories.pre]: #cmp.categories.pre
|
| 3884 |
+
[cmp.common]: #cmp.common
|
| 3885 |
+
[cmp.concept]: #cmp.concept
|
| 3886 |
+
[cmp.partialord]: #cmp.partialord
|
| 3887 |
+
[cmp.result]: #cmp.result
|
| 3888 |
+
[cmp.strongord]: #cmp.strongord
|
| 3889 |
+
[cmp.weakord]: #cmp.weakord
|
| 3890 |
+
[compare.syn]: #compare.syn
|
| 3891 |
+
[complex]: numerics.md#complex
|
| 3892 |
+
[concept.totallyordered]: concepts.md#concept.totallyordered
|
| 3893 |
+
[constraints]: library.md#constraints
|
| 3894 |
+
[conv.ptr]: expr.md#conv.ptr
|
| 3895 |
+
[conv.qual]: expr.md#conv.qual
|
| 3896 |
+
[conv.rank]: basic.md#conv.rank
|
| 3897 |
+
[coroutine.handle]: #coroutine.handle
|
| 3898 |
+
[coroutine.handle.compare]: #coroutine.handle.compare
|
| 3899 |
+
[coroutine.handle.con]: #coroutine.handle.con
|
| 3900 |
+
[coroutine.handle.export.import]: #coroutine.handle.export.import
|
| 3901 |
+
[coroutine.handle.hash]: #coroutine.handle.hash
|
| 3902 |
+
[coroutine.handle.noop]: #coroutine.handle.noop
|
| 3903 |
+
[coroutine.handle.noop.address]: #coroutine.handle.noop.address
|
| 3904 |
+
[coroutine.handle.noop.observers]: #coroutine.handle.noop.observers
|
| 3905 |
+
[coroutine.handle.noop.promise]: #coroutine.handle.noop.promise
|
| 3906 |
+
[coroutine.handle.noop.resumption]: #coroutine.handle.noop.resumption
|
| 3907 |
+
[coroutine.handle.observers]: #coroutine.handle.observers
|
| 3908 |
+
[coroutine.handle.promise]: #coroutine.handle.promise
|
| 3909 |
+
[coroutine.handle.resumption]: #coroutine.handle.resumption
|
| 3910 |
+
[coroutine.noop]: #coroutine.noop
|
| 3911 |
+
[coroutine.noop.coroutine]: #coroutine.noop.coroutine
|
| 3912 |
+
[coroutine.promise.noop]: #coroutine.promise.noop
|
| 3913 |
+
[coroutine.syn]: #coroutine.syn
|
| 3914 |
+
[coroutine.traits]: #coroutine.traits
|
| 3915 |
+
[coroutine.traits.primary]: #coroutine.traits.primary
|
| 3916 |
+
[coroutine.trivial.awaitables]: #coroutine.trivial.awaitables
|
| 3917 |
+
[cpp.line]: cpp.md#cpp.line
|
| 3918 |
+
[cpp17.nullablepointer]: #cpp17.nullablepointer
|
| 3919 |
+
[csetjmp.syn]: #csetjmp.syn
|
| 3920 |
+
[csignal.syn]: #csignal.syn
|
| 3921 |
+
[cstdarg.syn]: #cstdarg.syn
|
| 3922 |
+
[cstddef.syn]: #cstddef.syn
|
| 3923 |
+
[cstdint]: #cstdint
|
| 3924 |
+
[cstdint.syn]: #cstdint.syn
|
| 3925 |
+
[cstdlib.syn]: #cstdlib.syn
|
| 3926 |
+
[customization.point.object]: library.md#customization.point.object
|
| 3927 |
+
[dcl.fct.def.coroutine]: dcl.md#dcl.fct.def.coroutine
|
| 3928 |
+
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 3929 |
+
[dcl.init.list]: dcl.md#dcl.init.list
|
| 3930 |
+
[defns.expression-equivalent]: library.md#defns.expression-equivalent
|
| 3931 |
+
[denorm.style]: #denorm.style
|
| 3932 |
+
[except.handle]: except.md#except.handle
|
| 3933 |
+
[except.nested]: #except.nested
|
| 3934 |
+
[except.spec]: except.md#except.spec
|
| 3935 |
+
[except.terminate]: except.md#except.terminate
|
| 3936 |
+
[except.uncaught]: except.md#except.uncaught
|
| 3937 |
+
[exception]: #exception
|
| 3938 |
+
[exception.syn]: #exception.syn
|
| 3939 |
+
[exception.terminate]: #exception.terminate
|
| 3940 |
+
[expr.add]: expr.md#expr.add
|
| 3941 |
+
[expr.await]: expr.md#expr.await
|
| 3942 |
+
[expr.call]: expr.md#expr.call
|
| 3943 |
+
[expr.context]: expr.md#expr.context
|
| 3944 |
+
[expr.delete]: expr.md#expr.delete
|
| 3945 |
+
[expr.dynamic.cast]: expr.md#expr.dynamic.cast
|
| 3946 |
+
[expr.eq]: expr.md#expr.eq
|
| 3947 |
+
[expr.new]: expr.md#expr.new
|
| 3948 |
+
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 3949 |
+
[expr.rel]: expr.md#expr.rel
|
| 3950 |
+
[expr.sizeof]: expr.md#expr.sizeof
|
| 3951 |
+
[expr.spaceship]: expr.md#expr.spaceship
|
| 3952 |
+
[expr.typeid]: expr.md#expr.typeid
|
| 3953 |
+
[fp.style]: #fp.style
|
| 3954 |
+
[get.new.handler]: #get.new.handler
|
| 3955 |
+
[get.terminate]: #get.terminate
|
| 3956 |
+
[hardware.interference]: #hardware.interference
|
| 3957 |
+
[initializer.list.syn]: #initializer.list.syn
|
| 3958 |
+
[intro.multithread]: basic.md#intro.multithread
|
| 3959 |
+
[library.c]: library.md#library.c
|
| 3960 |
+
[limits.syn]: #limits.syn
|
| 3961 |
+
[locale.codecvt]: localization.md#locale.codecvt
|
| 3962 |
+
[multibyte.strings]: library.md#multibyte.strings
|
| 3963 |
+
[new.badlength]: #new.badlength
|
| 3964 |
+
[new.delete]: #new.delete
|
| 3965 |
+
[new.delete.array]: #new.delete.array
|
| 3966 |
+
[new.delete.dataraces]: #new.delete.dataraces
|
| 3967 |
+
[new.delete.placement]: #new.delete.placement
|
| 3968 |
+
[new.delete.single]: #new.delete.single
|
| 3969 |
+
[new.handler]: #new.handler
|
| 3970 |
+
[new.syn]: #new.syn
|
| 3971 |
+
[numeric.limits]: #numeric.limits
|
| 3972 |
+
[numeric.limits.members]: #numeric.limits.members
|
| 3973 |
+
[numeric.special]: #numeric.special
|
| 3974 |
+
[propagation]: #propagation
|
| 3975 |
+
[ptr.launder]: #ptr.launder
|
| 3976 |
+
[res.on.data.races]: library.md#res.on.data.races
|
| 3977 |
+
[round.style]: #round.style
|
| 3978 |
+
[set.new.handler]: #set.new.handler
|
| 3979 |
+
[set.terminate]: #set.terminate
|
| 3980 |
+
[source.location.syn]: #source.location.syn
|
| 3981 |
+
[stmt.dcl]: stmt.md#stmt.dcl
|
| 3982 |
+
[string.classes]: strings.md#string.classes
|
| 3983 |
+
[support]: #support
|
| 3984 |
+
[support.coroutine]: #support.coroutine
|
| 3985 |
+
[support.dynamic]: #support.dynamic
|
| 3986 |
+
[support.exception]: #support.exception
|
| 3987 |
+
[support.general]: #support.general
|
| 3988 |
+
[support.initlist]: #support.initlist
|
| 3989 |
+
[support.initlist.access]: #support.initlist.access
|
| 3990 |
+
[support.initlist.cons]: #support.initlist.cons
|
| 3991 |
+
[support.initlist.range]: #support.initlist.range
|
| 3992 |
+
[support.limits]: #support.limits
|
| 3993 |
+
[support.limits.general]: #support.limits.general
|
| 3994 |
+
[support.rtti]: #support.rtti
|
| 3995 |
+
[support.runtime]: #support.runtime
|
| 3996 |
+
[support.signal]: #support.signal
|
| 3997 |
+
[support.srcloc]: #support.srcloc
|
| 3998 |
+
[support.srcloc.class]: #support.srcloc.class
|
| 3999 |
+
[support.srcloc.cons]: #support.srcloc.cons
|
| 4000 |
+
[support.srcloc.current]: #support.srcloc.current
|
| 4001 |
+
[support.srcloc.obs]: #support.srcloc.obs
|
| 4002 |
+
[support.start.term]: #support.start.term
|
| 4003 |
+
[support.summary]: #support.summary
|
| 4004 |
+
[support.types]: #support.types
|
| 4005 |
+
[support.types.byteops]: #support.types.byteops
|
| 4006 |
+
[support.types.layout]: #support.types.layout
|
| 4007 |
+
[support.types.nullptr]: #support.types.nullptr
|
| 4008 |
+
[swappable.requirements]: library.md#swappable.requirements
|
| 4009 |
+
[temp.deduct]: temp.md#temp.deduct
|
| 4010 |
+
[temp.dep.constexpr]: temp.md#temp.dep.constexpr
|
| 4011 |
+
[temp.dep.expr]: temp.md#temp.dep.expr
|
| 4012 |
+
[temp.variadic]: temp.md#temp.variadic
|
| 4013 |
+
[terminate]: #terminate
|
| 4014 |
+
[terminate.handler]: #terminate.handler
|
| 4015 |
+
[type.info]: #type.info
|
| 4016 |
+
[typeinfo.syn]: #typeinfo.syn
|
| 4017 |
+
[uncaught.exceptions]: #uncaught.exceptions
|
| 4018 |
+
[unord.hash]: utilities.md#unord.hash
|
| 4019 |
+
[utility.arg.requirements]: library.md#utility.arg.requirements
|
| 4020 |
+
[version.syn]: #version.syn
|
| 4021 |
+
|
| 4022 |
+
[^1]: Possible definitions include `0` and `0L`, but not `(void*)0`.
|
| 4023 |
+
|
| 4024 |
+
[^2]: Note that `offsetof` is required to work as specified even if
|
| 4025 |
+
unary `operator&` is overloaded for any of the types involved.
|
| 4026 |
+
|
| 4027 |
+
[^3]: Equivalent to `CHAR_MIN`, `SHRT_MIN`, `FLT_MIN`, `DBL_MIN`, etc.
|
| 4028 |
+
|
| 4029 |
+
[^4]: Equivalent to `CHAR_MAX`, `SHRT_MAX`, `FLT_MAX`, `DBL_MAX`, etc.
|
| 4030 |
+
|
| 4031 |
+
[^5]: `lowest()` is necessary because not all floating-point
|
| 4032 |
+
representations have a smallest (most negative) value that is the
|
| 4033 |
+
negative of the largest (most positive) finite value.
|
| 4034 |
+
|
| 4035 |
+
[^6]: Equivalent to `FLT_MANT_DIG`, `DBL_MANT_DIG`, `LDBL_MANT_DIG`.
|
| 4036 |
+
|
| 4037 |
+
[^7]: Equivalent to `FLT_DIG`, `DBL_DIG`, `LDBL_DIG`.
|
| 4038 |
+
|
| 4039 |
+
[^8]: Equivalent to `FLT_RADIX`.
|
| 4040 |
+
|
| 4041 |
+
[^9]: Distinguishes types with bases other than 2 (e.g. BCD).
|
| 4042 |
+
|
| 4043 |
+
[^10]: Equivalent to `FLT_EPSILON`, `DBL_EPSILON`, `LDBL_EPSILON`.
|
| 4044 |
+
|
| 4045 |
+
[^11]: Rounding error is described in LIA-1 Section 5.2.4 and Annex C
|
| 4046 |
+
Rationale Section C.5.2.4 — Rounding and rounding constants.
|
| 4047 |
+
|
| 4048 |
+
[^12]: Equivalent to `FLT_MIN_EXP`, `DBL_MIN_EXP`, `LDBL_MIN_EXP`.
|
| 4049 |
+
|
| 4050 |
+
[^13]: Equivalent to `FLT_MIN_10_EXP`, `DBL_MIN_10_EXP`,
|
| 4051 |
+
`LDBL_MIN_10_EXP`.
|
| 4052 |
+
|
| 4053 |
+
[^14]: Equivalent to `FLT_MAX_EXP`, `DBL_MAX_EXP`, `LDBL_MAX_EXP`.
|
| 4054 |
+
|
| 4055 |
+
[^15]: Equivalent to `FLT_MAX_10_EXP`, `DBL_MAX_10_EXP`,
|
| 4056 |
+
`LDBL_MAX_10_EXP`.
|
| 4057 |
+
|
| 4058 |
+
[^16]: Required by LIA-1.
|
| 4059 |
+
|
| 4060 |
+
[^17]: Required by LIA-1.
|
| 4061 |
+
|
| 4062 |
+
[^18]: Required by LIA-1.
|
| 4063 |
+
|
| 4064 |
+
[^19]: See ISO/IEC/IEEE 60559.
|
| 4065 |
+
|
| 4066 |
+
[^20]: Required by LIA-1.
|
| 4067 |
+
|
| 4068 |
+
[^21]: Required by LIA-1.
|
| 4069 |
+
|
| 4070 |
+
[^22]: Required by LIA-1.
|
| 4071 |
+
|
| 4072 |
+
[^23]: Required by LIA-1.
|
| 4073 |
+
|
| 4074 |
+
[^24]: ISO/IEC/IEEE 60559:2011 is the same as IEEE 754-2008.
|
| 4075 |
+
|
| 4076 |
+
[^25]: Required by LIA-1.
|
| 4077 |
+
|
| 4078 |
+
[^26]: Required by LIA-1.
|
| 4079 |
+
|
| 4080 |
+
[^27]: Required by LIA-1.
|
| 4081 |
+
|
| 4082 |
+
[^28]: Refer to ISO/IEC/IEEE 60559. Required by LIA-1.
|
| 4083 |
+
|
| 4084 |
+
[^29]: Equivalent to `FLT_ROUNDS`. Required by LIA-1.
|
| 4085 |
+
|
| 4086 |
+
[^30]: A function is called for every time it is registered.
|
| 4087 |
+
|
| 4088 |
+
[^31]: Objects with automatic storage duration are all destroyed in a
|
| 4089 |
+
program whose `main` function [[basic.start.main]] contains no
|
| 4090 |
+
objects with automatic storage duration and executes the call to
|
| 4091 |
+
`exit()`. Control can be transferred directly to such a `main`
|
| 4092 |
+
function by throwing an exception that is caught in `main`.
|
| 4093 |
+
|
| 4094 |
+
[^32]: The macros `EXIT_FAILURE` and `EXIT_SUCCESS` are defined in
|
| 4095 |
+
`<cstdlib>`.
|
| 4096 |
+
|
| 4097 |
+
[^33]: It is not the direct responsibility of `operator new[]` or
|
| 4098 |
+
`operator delete[]` to note the repetition count or element size of
|
| 4099 |
+
the array. Those operations are performed elsewhere in the array
|
| 4100 |
+
`new` and `delete` expressions. The array `new` expression, may,
|
| 4101 |
+
however, increase the `size` argument to `operator new[]` to obtain
|
| 4102 |
+
space to store supplemental information.
|
| 4103 |
+
|
| 4104 |
+
[^34]: That is, `a < b`, `a == b`, and `a > b` might all be `false`.
|
| 4105 |
+
|
| 4106 |
+
[^35]: Note that `va_start` is required to work as specified even if
|
| 4107 |
+
unary `operator&` is overloaded for the type of `parmN`.
|
| 4108 |
+
|
| 4109 |
+
[^36]: Such initialization might occur because it is the first odr-use
|
| 4110 |
+
[[basic.def.odr]] of that variable.
|