- tmp/tmpkc5dc9ki/{from.md → to.md} +682 -365
tmp/tmpkc5dc9ki/{from.md → to.md}
RENAMED
|
@@ -15,14 +15,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 |
-
| [[
|
| 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>` |
|
|
@@ -35,10 +35,11 @@ other runtime support, as summarized in [[support.summary]].
|
|
| 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);
|
|
@@ -79,17 +80,17 @@ 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 |
|
|
@@ -99,18 +100,18 @@ namespace std {
|
|
| 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
|
|
@@ -150,25 +151,23 @@ namespace std {
|
|
| 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 |
-
|
| 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);
|
| 167 |
-
lldiv_t div(long long int numer, long long int denom);
|
| 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
|
|
@@ -190,41 +189,43 @@ expression, and it has the characteristics described in
|
|
| 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
|
| 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]
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 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.
|
| 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 |
|
|
@@ -358,70 +359,94 @@ 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
|
| 364 |
-
|
| 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
|
|
|
|
| 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
|
| 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
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>
|
|
@@ -432,18 +457,22 @@ the values of these macros with greater values. — *end note*]
|
|
| 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>
|
|
@@ -452,68 +481,102 @@ the values of these macros with greater values. — *end note*]
|
|
| 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
|
|
|
|
| 466 |
#define __cpp_lib_parallel_algorithm 201603L // also in <algorithm>, <numeric>
|
| 467 |
-
#define __cpp_lib_polymorphic_allocator 201902L // also in <
|
|
|
|
| 468 |
#define __cpp_lib_quoted_string_io 201304L // also in <iomanip>
|
| 469 |
-
#define __cpp_lib_ranges
|
| 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
|
| 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
|
| 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 |
-
// [
|
| 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>;
|
|
@@ -543,13 +606,11 @@ namespace std {
|
|
| 543 |
template<> class numeric_limits<double>;
|
| 544 |
template<> class numeric_limits<long double>;
|
| 545 |
}
|
| 546 |
```
|
| 547 |
|
| 548 |
-
###
|
| 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,
|
|
@@ -570,32 +631,14 @@ values:
|
|
| 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
|
|
@@ -623,12 +666,10 @@ namespace std {
|
|
| 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 |
|
|
@@ -645,12 +686,16 @@ namespace std {
|
|
| 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 |
-
|
| 651 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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`.
|
|
@@ -842,96 +887,82 @@ 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.[^
|
| 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.[^
|
| 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.[^
|
| 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.[^
|
|
|
|
|
|
|
| 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.[^
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.[^
|
| 917 |
|
| 918 |
-
[*Note
|
| 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.[^
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
`max()
|
|
|
|
| 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*]
|
|
@@ -941,27 +972,27 @@ Meaningful for all specializations.
|
|
| 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.[^
|
| 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.[^
|
| 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.[^
|
| 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>
|
|
@@ -1001,12 +1032,10 @@ namespace std {
|
|
| 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(); }
|
|
@@ -1052,12 +1081,10 @@ namespace std {
|
|
| 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 |
|
|
@@ -1073,10 +1100,11 @@ namespace std {
|
|
| 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
|
|
@@ -1097,19 +1125,20 @@ namespace std {
|
|
| 1097 |
```
|
| 1098 |
|
| 1099 |
The header `<climits>` defines all macros the same as the C standard
|
| 1100 |
library header `<limits.h>`.
|
| 1101 |
|
| 1102 |
-
[*Note 1*:
|
| 1103 |
-
|
| 1104 |
-
|
| 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
|
|
@@ -1153,76 +1182,144 @@ See also: ISO C 5.2.4.2.1
|
|
| 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 |
-
##
|
| 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 |
-
|
|
|
|
|
|
|
| 1203 |
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
|
| 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 |
-
|
|
|
|
|
|
|
| 1214 |
|
| 1215 |
-
|
| 1216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|
|
@@ -1276,26 +1373,25 @@ succeeds, nonzero if it fails.
|
|
| 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.[^
|
| 1282 |
destructions and calls. (Objects with automatic storage duration are
|
| 1283 |
-
not destroyed as a result of calling `exit()`.)[^
|
| 1284 |
-
|
| 1285 |
-
|
| 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*.
|
| 1297 |
|
| 1298 |
``` cpp
|
| 1299 |
int at_quick_exit(c-atexit-handler* f) noexcept;
|
| 1300 |
int at_quick_exit(atexit-handler* f) noexcept;
|
| 1301 |
```
|
|
@@ -1306,15 +1402,15 @@ 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
|
| 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
|
| 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 |
|
|
@@ -1326,18 +1422,17 @@ registration of at least 32 functions.
|
|
| 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
|
| 1332 |
-
|
| 1333 |
-
|
| 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
|
| 1339 |
identity of objects with thread storage duration. — *end note*]
|
| 1340 |
|
| 1341 |
After calling registered functions, `quick_exit` shall call
|
| 1342 |
`_Exit(status)`.
|
| 1343 |
|
|
@@ -1346,17 +1441,20 @@ 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 |
|
|
@@ -1421,10 +1519,12 @@ 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.
|
|
@@ -1505,10 +1605,23 @@ 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
|
|
@@ -1518,31 +1631,14 @@ by the C++ standard library.
|
|
| 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
|
| 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 |
|
|
@@ -1568,34 +1664,30 @@ reclaimed storage will be allocated by subsequent calls to
|
|
| 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 |
|
|
@@ -1605,11 +1697,11 @@ passed to the allocation function that returned `ptr`.
|
|
| 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.
|
| 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 |
|
|
@@ -1651,10 +1743,23 @@ 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
|
|
@@ -1664,31 +1769,14 @@ by the C++ standard library.
|
|
| 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
|
| 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 |
|
|
@@ -1705,34 +1793,30 @@ function.
|
|
| 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 |
|
|
@@ -1772,28 +1856,20 @@ Something* p = new (place) Something();
|
|
| 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>
|
|
@@ -1891,11 +1967,11 @@ new_handler set_new_handler(new_handler new_p) noexcept;
|
|
| 1891 |
new_handler get_new_handler() noexcept;
|
| 1892 |
```
|
| 1893 |
|
| 1894 |
*Returns:* The current `new_handler`.
|
| 1895 |
|
| 1896 |
-
[*Note 1*: This
|
| 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;
|
|
@@ -1904,22 +1980,18 @@ template<class T> [[nodiscard]] constexpr T* launder(T* p) noexcept;
|
|
| 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
|
| 1910 |
-
`p`
|
| 1911 |
|
| 1912 |
-
*Returns:* A value of type `T*` that points to
|
| 1913 |
|
| 1914 |
*Remarks:* An invocation of this function may be used in a core constant
|
| 1915 |
-
expression
|
| 1916 |
-
|
| 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
|
|
@@ -1986,17 +2058,20 @@ static_assert(sizeof(together) <= hardware_constructive_interference_size);
|
|
| 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 |
}
|
|
@@ -2007,11 +2082,11 @@ namespace std {
|
|
| 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
|
|
@@ -2026,11 +2101,11 @@ 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.
|
|
@@ -2061,11 +2136,11 @@ const char* name() const noexcept;
|
|
| 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`
|
| 2067 |
|
| 2068 |
### Class `bad_cast` <a id="bad.cast">[[bad.cast]]</a>
|
| 2069 |
|
| 2070 |
``` cpp
|
| 2071 |
namespace std {
|
|
@@ -2115,17 +2190,20 @@ const char* what() const noexcept override;
|
|
| 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;
|
|
@@ -2145,13 +2223,13 @@ namespace std {
|
|
| 2145 |
};
|
| 2146 |
}
|
| 2147 |
```
|
| 2148 |
|
| 2149 |
The type `source_location` meets the *Cpp17DefaultConstructible*,
|
| 2150 |
-
*Cpp17CopyConstructible*, *Cpp17CopyAssignable*,
|
| 2151 |
-
|
| 2152 |
-
|
| 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>`
|
|
@@ -2184,11 +2262,11 @@ static consteval source_location current() noexcept;
|
|
| 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`
|
|
@@ -2233,11 +2311,12 @@ void g() {
|
|
| 2233 |
|
| 2234 |
``` cpp
|
| 2235 |
constexpr source_location() noexcept;
|
| 2236 |
```
|
| 2237 |
|
| 2238 |
-
The data members are initialized with valid but unspecified
|
|
|
|
| 2239 |
|
| 2240 |
#### Observers <a id="support.srcloc.obs">[[support.srcloc.obs]]</a>
|
| 2241 |
|
| 2242 |
``` cpp
|
| 2243 |
constexpr uint_least32_t line() const noexcept;
|
|
@@ -2263,16 +2342,19 @@ constexpr const char* function_name() const noexcept;
|
|
| 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 |
|
|
@@ -2348,11 +2430,11 @@ virtual const char* what() const noexcept;
|
|
| 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`
|
| 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>
|
|
@@ -2384,11 +2466,11 @@ const char* what() const noexcept override;
|
|
| 2384 |
|
| 2385 |
``` cpp
|
| 2386 |
using terminate_handler = void (*)();
|
| 2387 |
```
|
| 2388 |
|
| 2389 |
-
The type of a *handler function* to be
|
| 2390 |
terminating exception processing.
|
| 2391 |
|
| 2392 |
*Required behavior:* A `terminate_handler` shall terminate execution of
|
| 2393 |
the program without returning to the caller.
|
| 2394 |
|
|
@@ -2402,43 +2484,43 @@ 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
|
| 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 |
```
|
|
@@ -2466,22 +2548,22 @@ 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
|
| 2472 |
-
|
| 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
|
| 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;
|
|
@@ -2503,21 +2585,29 @@ creates a new copy each time it is called. — *end note*]
|
|
| 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
|
| 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 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2519 |
|
| 2520 |
``` cpp
|
| 2521 |
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 2522 |
```
|
| 2523 |
|
|
@@ -2613,18 +2703,21 @@ 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
|
| 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&;
|
|
@@ -2712,10 +2805,11 @@ template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
|
| 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;
|
|
@@ -2772,13 +2866,11 @@ 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
|
| 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*]
|
|
@@ -2805,24 +2897,22 @@ 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]]
|
| 2811 |
-
the six two-way comparison operators
|
| 2812 |
-
|
| 2813 |
-
incomparable.
|
| 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 |
|
|
@@ -2848,11 +2938,11 @@ namespace std {
|
|
| 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(
|
| 2854 |
inline constexpr partial_ordering partial_ordering::greater(ord::greater);
|
| 2855 |
inline constexpr partial_ordering partial_ordering::unordered(ncmp::unordered);
|
| 2856 |
}
|
| 2857 |
```
|
| 2858 |
|
|
@@ -2889,21 +2979,20 @@ constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept
|
|
| 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]]
|
| 2895 |
-
the six two-way comparison operators
|
| 2896 |
-
|
| 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;
|
|
@@ -2928,11 +3017,11 @@ namespace std {
|
|
| 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(
|
| 2934 |
inline constexpr weak_ordering weak_ordering::greater(ord::greater);
|
| 2935 |
}
|
| 2936 |
```
|
| 2937 |
|
| 2938 |
``` cpp
|
|
@@ -2980,21 +3069,20 @@ constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
|
|
| 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]]
|
| 2986 |
-
the six two-way comparison operators
|
| 2987 |
-
|
| 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;
|
|
@@ -3021,12 +3109,12 @@ namespace std {
|
|
| 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(
|
| 3027 |
-
inline constexpr strong_ordering strong_ordering::equivalent(
|
| 3028 |
inline constexpr strong_ordering strong_ordering::greater(ord::greater);
|
| 3029 |
}
|
| 3030 |
```
|
| 3031 |
|
| 3032 |
``` cpp
|
|
@@ -3108,11 +3196,11 @@ 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
|
| 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>;
|
|
@@ -3168,32 +3256,37 @@ and `Cat` model `three_way_comparable<T, Cat>` only if:
|
|
| 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 |
-
|
| 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 `
|
| 3185 |
-
`const remove_reference_t<
|
|
|
|
|
|
|
|
|
|
| 3186 |
`common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>`.
|
| 3187 |
-
|
| 3188 |
-
|
|
|
|
| 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(
|
|
|
|
| 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
|
|
@@ -3216,38 +3309,41 @@ member `type`.
|
|
| 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
|
| 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
|
| 3227 |
-
|
|
|
|
| 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.
|
| 3236 |
-
|
| 3237 |
-
|
|
|
|
|
|
|
| 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
|
| 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
|
| 3248 |
-
|
| 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
|
|
@@ -3263,99 +3359,121 @@ expression `weak_order(E, F)` is expression-equivalent
|
|
| 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.
|
| 3269 |
-
|
| 3270 |
-
|
|
|
|
|
|
|
| 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
|
| 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
|
| 3281 |
-
|
|
|
|
| 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.
|
| 3287 |
-
|
| 3288 |
-
|
|
|
|
| 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
|
| 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
|
|
|
|
| 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
|
| 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
|
|
|
|
| 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
|
| 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`
|
| 3338 |
-
well-formed and
|
|
|
|
| 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>
|
|
@@ -3387,13 +3505,15 @@ namespace std {
|
|
| 3387 |
}
|
| 3388 |
```
|
| 3389 |
|
| 3390 |
### Coroutine traits <a id="coroutine.traits">[[coroutine.traits]]</a>
|
| 3391 |
|
| 3392 |
-
|
| 3393 |
-
|
| 3394 |
-
|
|
|
|
|
|
|
| 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
|
|
@@ -3410,10 +3530,12 @@ Otherwise, `coroutine_traits<R,ArgTypes...>` has no members.
|
|
| 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 |
{
|
|
@@ -3438,30 +3560,49 @@ namespace std {
|
|
| 3438 |
private:
|
| 3439 |
void* ptr; // exposition only
|
| 3440 |
};
|
| 3441 |
|
| 3442 |
template<class Promise>
|
| 3443 |
-
struct coroutine_handle
|
| 3444 |
{
|
| 3445 |
// [coroutine.handle.con], construct/reset
|
| 3446 |
-
|
|
|
|
| 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 |
-
|
| 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>
|
|
@@ -3477,36 +3618,54 @@ constexpr coroutine_handle(nullptr_t) noexcept;
|
|
| 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 |
|
|
@@ -3527,19 +3686,19 @@ 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
|
| 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
|
| 3541 |
data race. — *end note*]
|
| 3542 |
|
| 3543 |
``` cpp
|
| 3544 |
void operator()() const;
|
| 3545 |
void resume() const;
|
|
@@ -3604,12 +3763,15 @@ coroutine referred to by `noop_coroutine_handle` [[coroutine.syn]].
|
|
| 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>
|
| 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
|
|
@@ -3622,14 +3784,24 @@ namespace std {
|
|
| 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 |
```
|
|
@@ -3705,15 +3877,17 @@ namespace std {
|
|
| 3705 |
};
|
| 3706 |
}
|
| 3707 |
```
|
| 3708 |
|
| 3709 |
[*Note 1*: The types `suspend_never` and `suspend_always` can be used
|
| 3710 |
-
to indicate that an *await-expression*
|
| 3711 |
-
|
| 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
|
|
@@ -3730,10 +3904,11 @@ 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
|
|
@@ -3741,21 +3916,24 @@ namespace std {
|
|
| 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:
|
| 3747 |
-
|
| 3748 |
-
|
| 3749 |
-
|
| 3750 |
-
|
| 3751 |
-
|
| 3752 |
-
|
| 3753 |
-
|
| 3754 |
-
|
| 3755 |
-
|
| 3756 |
-
|
|
|
|
|
|
|
|
|
|
| 3757 |
|
| 3758 |
See also: ISO C 7.16.1.1
|
| 3759 |
|
| 3760 |
### Header `<csetjmp>` synopsis <a id="csetjmp.syn">[[csetjmp.syn]]</a>
|
| 3761 |
|
|
@@ -3816,10 +3994,13 @@ invocation of the signal handler so installed.
|
|
| 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 |
|
|
@@ -3833,12 +4014,11 @@ An evaluation is *signal-safe* unless it includes one of the following:
|
|
| 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
|
| 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.
|
|
@@ -3847,31 +4027,146 @@ 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]:
|
| 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.
|
|
|
|
| 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 |
-
[
|
| 3870 |
[c.locales]: localization.md#c.locales
|
| 3871 |
-
[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
|
|
@@ -3887,22 +4182,28 @@ See also: ISO C 7.14
|
|
| 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
|
|
@@ -3910,27 +4211,26 @@ See also: ISO C 7.14
|
|
| 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
|
| 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
|
|
@@ -3948,56 +4248,75 @@ See also: ISO C 7.14
|
|
| 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
|
|
@@ -4008,12 +4327,14 @@ See also: ISO C 7.14
|
|
| 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
|
|
@@ -4036,11 +4357,11 @@ See also: ISO C 7.14
|
|
| 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.
|
|
@@ -4059,52 +4380,48 @@ See also: ISO C 7.14
|
|
| 4059 |
|
| 4060 |
[^17]: Required by LIA-1.
|
| 4061 |
|
| 4062 |
[^18]: Required by LIA-1.
|
| 4063 |
|
| 4064 |
-
[^19]:
|
| 4065 |
|
| 4066 |
[^20]: Required by LIA-1.
|
| 4067 |
|
| 4068 |
[^21]: Required by LIA-1.
|
| 4069 |
|
| 4070 |
-
[^22]:
|
| 4071 |
|
| 4072 |
[^23]: Required by LIA-1.
|
| 4073 |
|
| 4074 |
-
[^24]:
|
| 4075 |
|
| 4076 |
[^25]: Required by LIA-1.
|
| 4077 |
|
| 4078 |
-
[^26]: Required by LIA-1.
|
| 4079 |
|
| 4080 |
-
[^27]: Required by LIA-1.
|
| 4081 |
|
| 4082 |
-
[^28]:
|
| 4083 |
|
| 4084 |
-
[^29]:
|
| 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 |
-
[^
|
| 4095 |
`<cstdlib>`.
|
| 4096 |
|
| 4097 |
-
[^
|
| 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,
|
| 4101 |
however, increase the `size` argument to `operator new[]` to obtain
|
| 4102 |
space to store supplemental information.
|
| 4103 |
|
| 4104 |
-
[^
|
| 4105 |
|
| 4106 |
-
[^
|
| 4107 |
unary `operator&` is overloaded for the type of `parmN`.
|
| 4108 |
|
| 4109 |
-
[^
|
| 4110 |
-
[[
|
|
|
|
| 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 |
+
| [[support.arith.types]] | Arithmetic types | `<cstdint>`, `<stdfloat>` |
|
| 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>` |
|
|
|
|
| 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 |
+
// all freestanding
|
| 41 |
namespace std {
|
| 42 |
using ptrdiff_t = see below;
|
| 43 |
using size_t = see below;
|
| 44 |
using max_align_t = see below;
|
| 45 |
using nullptr_t = decltype(nullptr);
|
|
|
|
| 80 |
|
| 81 |
### Header `<cstdlib>` synopsis <a id="cstdlib.syn">[[cstdlib.syn]]</a>
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
namespace std {
|
| 85 |
+
using size_t = see below; // freestanding
|
| 86 |
using div_t = see below;
|
| 87 |
using ldiv_t = see below;
|
| 88 |
using lldiv_t = see below;
|
| 89 |
}
|
| 90 |
|
| 91 |
+
#define NULL see below // freestanding
|
| 92 |
#define EXIT_FAILURE see below
|
| 93 |
#define EXIT_SUCCESS see below
|
| 94 |
#define RAND_MAX see below
|
| 95 |
#define MB_CUR_MAX see below
|
| 96 |
|
|
|
|
| 100 |
extern "C++" using atexit-handler = void(); // exposition only
|
| 101 |
extern "C" using c-compare-pred = int(const void*, const void*); // exposition only
|
| 102 |
extern "C++" using compare-pred = int(const void*, const void*); // exposition only
|
| 103 |
|
| 104 |
// [support.start.term], start and termination
|
| 105 |
+
[[noreturn]] void abort() noexcept; // freestanding
|
| 106 |
+
int atexit(c-atexit-handler* func) noexcept; // freestanding
|
| 107 |
+
int atexit(atexit-handler* func) noexcept; // freestanding
|
| 108 |
+
int at_quick_exit(c-atexit-handler* func) noexcept; // freestanding
|
| 109 |
+
int at_quick_exit(atexit-handler* func) noexcept; // freestanding
|
| 110 |
+
[[noreturn]] void exit(int status); // freestanding
|
| 111 |
+
[[noreturn]] void _Exit(int status) noexcept; // freestanding
|
| 112 |
+
[[noreturn]] void quick_exit(int status) noexcept; // freestanding
|
| 113 |
|
| 114 |
char* getenv(const char* name);
|
| 115 |
int system(const char* string);
|
| 116 |
|
| 117 |
// [c.malloc], C library memory allocation
|
|
|
|
| 151 |
// [c.math.rand], low-quality random number generation
|
| 152 |
int rand();
|
| 153 |
void srand(unsigned int seed);
|
| 154 |
|
| 155 |
// [c.math.abs], absolute values
|
| 156 |
+
constexpr int abs(int j);
|
| 157 |
+
constexpr long int abs(long int j);
|
| 158 |
+
constexpr long long int abs(long long int j);
|
| 159 |
+
constexpr floating-point-type abs(floating-point-type j);
|
|
|
|
|
|
|
| 160 |
|
| 161 |
+
constexpr long int labs(long int j);
|
| 162 |
+
constexpr long long int llabs(long long int j);
|
| 163 |
|
| 164 |
+
constexpr div_t div(int numer, int denom);
|
| 165 |
+
constexpr ldiv_t div(long int numer, long int denom); // see [library.c]
|
| 166 |
+
constexpr lldiv_t div(long long int numer, long long int denom); // see [library.c]
|
| 167 |
+
constexpr ldiv_t ldiv(long int numer, long int denom);
|
| 168 |
+
constexpr lldiv_t lldiv(long long int numer, long long int denom);
|
| 169 |
}
|
| 170 |
```
|
| 171 |
|
| 172 |
The contents and meaning of the header `<cstdlib>` are the same as the C
|
| 173 |
standard library header `<stdlib.h>`, except that it does not declare
|
|
|
|
| 189 |
|
| 190 |
[*Note 1*: Although `nullptr`’s address cannot be taken, the address of
|
| 191 |
another `nullptr_t` object that is an lvalue can be
|
| 192 |
taken. — *end note*]
|
| 193 |
|
| 194 |
+
The macro `NULL` is an *implementation-defined* null pointer
|
| 195 |
+
constant.[^1]
|
| 196 |
|
| 197 |
See also: ISO C 7.19
|
| 198 |
|
| 199 |
### Sizes, alignments, and offsets <a id="support.types.layout">[[support.types.layout]]</a>
|
| 200 |
|
| 201 |
The macro `offsetof(type, member-designator)` has the same semantics as
|
| 202 |
the corresponding macro in the C standard library header `<stddef.h>`,
|
| 203 |
but accepts a restricted set of `type` arguments in this document. Use
|
| 204 |
of the `offsetof` macro with a `type` other than a standard-layout class
|
| 205 |
+
[[class.prop]] is conditionally-supported.[^2]
|
| 206 |
+
|
| 207 |
+
The expression `offsetof(type, member-designator)` is never
|
| 208 |
+
type-dependent [[temp.dep.expr]] and it is value-dependent
|
| 209 |
+
[[temp.dep.constexpr]] if and only if `type` is dependent. The result of
|
| 210 |
+
applying the `offsetof` macro to a static data member or a function
|
| 211 |
+
member is undefined. No operation invoked by the `offsetof` macro shall
|
| 212 |
+
throw an exception and `noexcept(offsetof(type, member-designator))`
|
| 213 |
+
shall be `true`.
|
| 214 |
|
| 215 |
The type `ptrdiff_t` is an *implementation-defined* signed integer type
|
| 216 |
that can hold the difference of two subscripts in an array object, as
|
| 217 |
described in [[expr.add]].
|
| 218 |
|
| 219 |
The type `size_t` is an *implementation-defined* unsigned integer type
|
| 220 |
that is large enough to contain the size in bytes of any object
|
| 221 |
[[expr.sizeof]].
|
| 222 |
|
| 223 |
+
*Recommended practice:* An implementation should choose types for
|
| 224 |
`ptrdiff_t` and `size_t` whose integer conversion ranks [[conv.rank]]
|
| 225 |
are no greater than that of `signed long int` unless a larger size is
|
| 226 |
+
necessary to contain all the possible values.
|
| 227 |
|
| 228 |
The type `max_align_t` is a trivial standard-layout type whose alignment
|
| 229 |
requirement is at least as great as that of every scalar type, and whose
|
| 230 |
alignment requirement is supported in every context [[basic.align]].
|
| 231 |
|
|
|
|
| 359 |
|
| 360 |
Each of the macros defined in `<version>` is also defined after
|
| 361 |
inclusion of any member of the set of library headers indicated in the
|
| 362 |
corresponding comment in this synopsis.
|
| 363 |
|
| 364 |
+
[*Note 1*: Future revisions of C++ might replace the values of these
|
| 365 |
+
macros with greater values. — *end note*]
|
| 366 |
|
| 367 |
``` cpp
|
| 368 |
#define __cpp_lib_addressof_constexpr 201603L // also in <memory>
|
| 369 |
+
#define __cpp_lib_algorithm_iterator_requirements 202207L
|
| 370 |
+
// also in <algorithm>, <numeric>, <memory>
|
| 371 |
+
#define __cpp_lib_allocate_at_least 202302L // also in <memory>
|
| 372 |
#define __cpp_lib_allocator_traits_is_always_equal 201411L
|
| 373 |
// also in <memory>, <scoped_allocator>, <string>, <deque>, <forward_list>, <list>, <vector>,
|
| 374 |
// <map>, <set>, <unordered_map>, <unordered_set>
|
| 375 |
+
#define __cpp_lib_adaptor_iterator_pair_constructor 202106L // also in <stack>, <queue>
|
| 376 |
#define __cpp_lib_any 201606L // also in <any>
|
| 377 |
#define __cpp_lib_apply 201603L // also in <tuple>
|
| 378 |
#define __cpp_lib_array_constexpr 201811L // also in <iterator>, <array>
|
| 379 |
#define __cpp_lib_as_const 201510L // also in <utility>
|
| 380 |
+
#define __cpp_lib_associative_heterogeneous_erasure 202110L
|
| 381 |
+
// also in <map>, <set>, <unordered_map>, <unordered_set>
|
| 382 |
#define __cpp_lib_assume_aligned 201811L // also in <memory>
|
| 383 |
#define __cpp_lib_atomic_flag_test 201907L // also in <atomic>
|
| 384 |
#define __cpp_lib_atomic_float 201711L // also in <atomic>
|
| 385 |
#define __cpp_lib_atomic_is_always_lock_free 201603L // also in <atomic>
|
| 386 |
#define __cpp_lib_atomic_lock_free_type_aliases 201907L // also in <atomic>
|
| 387 |
#define __cpp_lib_atomic_ref 201806L // also in <atomic>
|
| 388 |
#define __cpp_lib_atomic_shared_ptr 201711L // also in <memory>
|
| 389 |
#define __cpp_lib_atomic_value_initialization 201911L // also in <atomic>, <memory>
|
| 390 |
#define __cpp_lib_atomic_wait 201907L // also in <atomic>
|
| 391 |
+
#define __cpp_lib_barrier 202302L // also in <barrier>
|
| 392 |
+
#define __cpp_lib_bind_back 202202L // also in <functional>
|
| 393 |
#define __cpp_lib_bind_front 201907L // also in <functional>
|
| 394 |
#define __cpp_lib_bit_cast 201806L // also in <bit>
|
| 395 |
#define __cpp_lib_bitops 201907L // also in <bit>
|
| 396 |
#define __cpp_lib_bool_constant 201505L // also in <type_traits>
|
| 397 |
#define __cpp_lib_bounded_array_traits 201902L // also in <type_traits>
|
| 398 |
#define __cpp_lib_boyer_moore_searcher 201603L // also in <functional>
|
| 399 |
#define __cpp_lib_byte 201603L // also in <cstddef>
|
| 400 |
+
#define __cpp_lib_byteswap 202110L // also in <bit>
|
| 401 |
#define __cpp_lib_char8_t 201907L
|
| 402 |
// also in <atomic>, <filesystem>, <istream>, <limits>, <locale>, <ostream>, <string>, <string_view>
|
| 403 |
#define __cpp_lib_chrono 201907L // also in <chrono>
|
| 404 |
#define __cpp_lib_chrono_udls 201304L // also in <chrono>
|
| 405 |
#define __cpp_lib_clamp 201603L // also in <algorithm>
|
| 406 |
+
#define __cpp_lib_common_reference 202302L // also in <type_traits>
|
| 407 |
+
#define __cpp_lib_common_reference_wrapper 202302L // also in <functional>
|
| 408 |
#define __cpp_lib_complex_udls 201309L // also in <complex>
|
| 409 |
+
#define __cpp_lib_concepts 202207L // also in <concepts>, <compare>
|
| 410 |
+
#define __cpp_lib_constexpr_algorithms 201806L // also in <algorithm>, <utility>
|
| 411 |
+
#define __cpp_lib_constexpr_bitset 202207L // also in <bitset>
|
| 412 |
+
#define __cpp_lib_constexpr_charconv 202207L // also in <charconv>
|
| 413 |
+
#define __cpp_lib_constexpr_cmath 202202L // also in <cmath>, <cstdlib>
|
| 414 |
#define __cpp_lib_constexpr_complex 201711L // also in <complex>
|
| 415 |
#define __cpp_lib_constexpr_dynamic_alloc 201907L // also in <memory>
|
| 416 |
#define __cpp_lib_constexpr_functional 201907L // also in <functional>
|
| 417 |
#define __cpp_lib_constexpr_iterator 201811L // also in <iterator>
|
| 418 |
+
#define __cpp_lib_constexpr_memory 202202L // also in <memory>
|
| 419 |
#define __cpp_lib_constexpr_numeric 201911L // also in <numeric>
|
| 420 |
#define __cpp_lib_constexpr_string 201907L // also in <string>
|
| 421 |
#define __cpp_lib_constexpr_string_view 201811L // also in <string_view>
|
| 422 |
#define __cpp_lib_constexpr_tuple 201811L // also in <tuple>
|
| 423 |
+
#define __cpp_lib_constexpr_typeinfo 202106L // also in <typeinfo>
|
| 424 |
#define __cpp_lib_constexpr_utility 201811L // also in <utility>
|
| 425 |
#define __cpp_lib_constexpr_vector 201907L // also in <vector>
|
| 426 |
+
#define __cpp_lib_containers_ranges 202202L
|
| 427 |
+
// also in <vector>, <list>, <forward_list>, <map>, <set>, <unordered_map>, <unordered_set>,
|
| 428 |
+
// <deque>, <queue>, <stack>, <string>
|
| 429 |
#define __cpp_lib_coroutine 201902L // also in <coroutine>
|
| 430 |
#define __cpp_lib_destroying_delete 201806L // also in <new>
|
| 431 |
#define __cpp_lib_enable_shared_from_this 201603L // also in <memory>
|
| 432 |
#define __cpp_lib_endian 201907L // also in <bit>
|
| 433 |
#define __cpp_lib_erase_if 202002L
|
| 434 |
// also in <string>, <deque>, <forward_list>, <list>, <vector>, <map>, <set>, <unordered_map>,
|
| 435 |
// <unordered_set>
|
| 436 |
#define __cpp_lib_exchange_function 201304L // also in <utility>
|
| 437 |
#define __cpp_lib_execution 201902L // also in <execution>
|
| 438 |
+
#define __cpp_lib_expected 202211L // also in <expected>
|
| 439 |
#define __cpp_lib_filesystem 201703L // also in <filesystem>
|
| 440 |
+
#define __cpp_lib_flat_map 202207L // also in <flat_map>
|
| 441 |
+
#define __cpp_lib_flat_set 202207L // also in <flat_set>
|
| 442 |
+
#define __cpp_lib_format 202207L // also in <format>
|
| 443 |
+
#define __cpp_lib_format_ranges 202207L // also in <format>
|
| 444 |
+
#define __cpp_lib_formatters 202302L // also in <stacktrace>, <thread>
|
| 445 |
+
#define __cpp_lib_forward_like 202207L // also in <utility>
|
| 446 |
#define __cpp_lib_gcd_lcm 201606L // also in <numeric>
|
| 447 |
+
#define __cpp_lib_generator 202207L // also in <generator>
|
| 448 |
#define __cpp_lib_generic_associative_lookup 201304L // also in <map>, <set>
|
| 449 |
#define __cpp_lib_generic_unordered_lookup 201811L
|
| 450 |
// also in <unordered_map>, <unordered_set>
|
| 451 |
#define __cpp_lib_hardware_interference_size 201703L // also in <new>
|
| 452 |
#define __cpp_lib_has_unique_object_representations 201606L // also in <type_traits>
|
|
|
|
| 457 |
#define __cpp_lib_integer_comparison_functions 202002L // also in <utility>
|
| 458 |
#define __cpp_lib_integer_sequence 201304L // also in <utility>
|
| 459 |
#define __cpp_lib_integral_constant_callable 201304L // also in <type_traits>
|
| 460 |
#define __cpp_lib_interpolate 201902L // also in <cmath>, <numeric>
|
| 461 |
#define __cpp_lib_invoke 201411L // also in <functional>
|
| 462 |
+
#define __cpp_lib_invoke_r 202106L // also in <functional>
|
| 463 |
+
#define __cpp_lib_ios_noreplace 202207L // also in <ios>
|
| 464 |
#define __cpp_lib_is_aggregate 201703L // also in <type_traits>
|
| 465 |
#define __cpp_lib_is_constant_evaluated 201811L // also in <type_traits>
|
| 466 |
#define __cpp_lib_is_final 201402L // also in <type_traits>
|
| 467 |
+
#define __cpp_lib_is_implicit_lifetime 202302L // also in <type_traits>
|
| 468 |
#define __cpp_lib_is_invocable 201703L // also in <type_traits>
|
| 469 |
#define __cpp_lib_is_layout_compatible 201907L // also in <type_traits>
|
| 470 |
#define __cpp_lib_is_nothrow_convertible 201806L // also in <type_traits>
|
| 471 |
#define __cpp_lib_is_null_pointer 201309L // also in <type_traits>
|
| 472 |
#define __cpp_lib_is_pointer_interconvertible 201907L // also in <type_traits>
|
| 473 |
+
#define __cpp_lib_is_scoped_enum 202011L // also in <type_traits>
|
| 474 |
#define __cpp_lib_is_swappable 201603L // also in <type_traits>
|
| 475 |
#define __cpp_lib_jthread 201911L // also in <stop_token>, <thread>
|
| 476 |
#define __cpp_lib_latch 201907L // also in <latch>
|
| 477 |
#define __cpp_lib_launder 201606L // also in <new>
|
| 478 |
#define __cpp_lib_list_remove_return_type 201806L // also in <forward_list>, <list>
|
|
|
|
| 481 |
#define __cpp_lib_make_reverse_iterator 201402L // also in <iterator>
|
| 482 |
#define __cpp_lib_make_unique 201304L // also in <memory>
|
| 483 |
#define __cpp_lib_map_try_emplace 201411L // also in <map>
|
| 484 |
#define __cpp_lib_math_constants 201907L // also in <numbers>
|
| 485 |
#define __cpp_lib_math_special_functions 201603L // also in <cmath>
|
| 486 |
+
#define __cpp_lib_mdspan 202207L // also in <mdspan>
|
| 487 |
#define __cpp_lib_memory_resource 201603L // also in <memory_resource>
|
| 488 |
+
#define __cpp_lib_modules 202207L
|
| 489 |
+
#define __cpp_lib_move_iterator_concept 202207L // also in <iterator>
|
| 490 |
+
#define __cpp_lib_move_only_function 202110L // also in <functional>
|
| 491 |
#define __cpp_lib_node_extract 201606L
|
| 492 |
// also in <map>, <set>, <unordered_map>, <unordered_set>
|
| 493 |
#define __cpp_lib_nonmember_container_access 201411L
|
| 494 |
// also in <array>, <deque>, <forward_list>, <iterator>, <list>, <map>, <regex>, <set>, <string>,
|
| 495 |
// <unordered_map>, <unordered_set>, <vector>
|
| 496 |
#define __cpp_lib_not_fn 201603L // also in <functional>
|
| 497 |
#define __cpp_lib_null_iterators 201304L // also in <iterator>
|
| 498 |
+
#define __cpp_lib_optional 202110L // also in <optional>
|
| 499 |
+
#define __cpp_lib_out_ptr 202106L // also in <memory>
|
| 500 |
#define __cpp_lib_parallel_algorithm 201603L // also in <algorithm>, <numeric>
|
| 501 |
+
#define __cpp_lib_polymorphic_allocator 201902L // also in <memory_resource>
|
| 502 |
+
#define __cpp_lib_print 202207L // also in <print>, <ostream>
|
| 503 |
#define __cpp_lib_quoted_string_io 201304L // also in <iomanip>
|
| 504 |
+
#define __cpp_lib_ranges 202302L
|
| 505 |
// also in <algorithm>, <functional>, <iterator>, <memory>, <ranges>
|
| 506 |
+
#define __cpp_lib_ranges_as_const 202207L // also in <ranges>
|
| 507 |
+
#define __cpp_lib_ranges_as_rvalue 202207L // also in <ranges>
|
| 508 |
+
#define __cpp_lib_ranges_cartesian_product 202207L // also in <ranges>
|
| 509 |
+
#define __cpp_lib_ranges_chunk 202202L // also in <ranges>
|
| 510 |
+
#define __cpp_lib_ranges_chunk_by 202202L // also in <ranges>
|
| 511 |
+
#define __cpp_lib_ranges_contains 202207L // also in <algorithm>
|
| 512 |
+
#define __cpp_lib_ranges_enumerate 202302L // also in <ranges>, <version>
|
| 513 |
+
#define __cpp_lib_ranges_find_last 202207L // also in <algorithm>
|
| 514 |
+
#define __cpp_lib_ranges_fold 202207L // also in <algorithm>
|
| 515 |
+
#define __cpp_lib_ranges_iota 202202L // also in <numeric>
|
| 516 |
+
#define __cpp_lib_ranges_join_with 202202L // also in <ranges>
|
| 517 |
+
#define __cpp_lib_ranges_repeat 202207L // also in <ranges>
|
| 518 |
+
#define __cpp_lib_ranges_slide 202202L // also in <ranges>
|
| 519 |
+
#define __cpp_lib_ranges_starts_ends_with 202106L // also in <algorithm>
|
| 520 |
+
#define __cpp_lib_ranges_stride 202207L // also in <ranges>
|
| 521 |
+
#define __cpp_lib_ranges_to_container 202202L // also in <ranges>
|
| 522 |
+
#define __cpp_lib_ranges_zip 202110L // also in <ranges>, <tuple>, <utility>
|
| 523 |
#define __cpp_lib_raw_memory_algorithms 201606L // also in <memory>
|
| 524 |
+
#define __cpp_lib_reference_from_temporary 202202L // also in <type_traits>
|
| 525 |
#define __cpp_lib_remove_cvref 201711L // also in <type_traits>
|
| 526 |
#define __cpp_lib_result_of_sfinae 201210L // also in <functional>, <type_traits>
|
| 527 |
#define __cpp_lib_robust_nonmodifying_seq_ops 201304L // also in <algorithm>
|
| 528 |
#define __cpp_lib_sample 201603L // also in <algorithm>
|
| 529 |
#define __cpp_lib_scoped_lock 201703L // also in <mutex>
|
| 530 |
#define __cpp_lib_semaphore 201907L // also in <semaphore>
|
| 531 |
#define __cpp_lib_shared_mutex 201505L // also in <shared_mutex>
|
| 532 |
#define __cpp_lib_shared_ptr_arrays 201707L // also in <memory>
|
| 533 |
#define __cpp_lib_shared_ptr_weak_type 201606L // also in <memory>
|
| 534 |
#define __cpp_lib_shared_timed_mutex 201402L // also in <shared_mutex>
|
| 535 |
+
#define __cpp_lib_shift 202202L // also in <algorithm>
|
| 536 |
#define __cpp_lib_smart_ptr_for_overwrite 202002L // also in <memory>
|
| 537 |
#define __cpp_lib_source_location 201907L // also in <source_location>
|
| 538 |
#define __cpp_lib_span 202002L // also in <span>
|
| 539 |
+
#define __cpp_lib_spanstream 202106L // also in <spanstream>
|
| 540 |
#define __cpp_lib_ssize 201902L // also in <iterator>
|
| 541 |
+
#define __cpp_lib_stacktrace 202011L // also in <stacktrace>
|
| 542 |
+
#define __cpp_lib_start_lifetime_as 202207L // also in <memory>
|
| 543 |
#define __cpp_lib_starts_ends_with 201711L // also in <string>, <string_view>
|
| 544 |
+
#define __cpp_lib_stdatomic_h 202011L // also in <stdatomic.h>
|
| 545 |
+
#define __cpp_lib_string_contains 202011L // also in <string>, <string_view>
|
| 546 |
+
#define __cpp_lib_string_resize_and_overwrite 202110L // also in <string>
|
| 547 |
#define __cpp_lib_string_udls 201304L // also in <string>
|
| 548 |
#define __cpp_lib_string_view 201803L // also in <string>, <string_view>
|
| 549 |
#define __cpp_lib_syncbuf 201803L // also in <syncstream>
|
| 550 |
#define __cpp_lib_three_way_comparison 201907L // also in <compare>
|
| 551 |
#define __cpp_lib_to_address 201711L // also in <memory>
|
| 552 |
#define __cpp_lib_to_array 201907L // also in <array>
|
| 553 |
#define __cpp_lib_to_chars 201611L // also in <charconv>
|
| 554 |
+
#define __cpp_lib_to_underlying 202102L // also in <utility>
|
| 555 |
#define __cpp_lib_transformation_trait_aliases 201304L // also in <type_traits>
|
| 556 |
#define __cpp_lib_transparent_operators 201510L // also in <memory>, <functional>
|
| 557 |
+
#define __cpp_lib_tuple_like 202207L
|
| 558 |
+
// also in <utility>, <tuple>, <map>, <unordered_map>
|
| 559 |
#define __cpp_lib_tuple_element_t 201402L // also in <tuple>
|
| 560 |
#define __cpp_lib_tuples_by_type 201304L // also in <utility>, <tuple>
|
| 561 |
#define __cpp_lib_type_identity 201806L // also in <type_traits>
|
| 562 |
#define __cpp_lib_type_trait_variable_templates 201510L // also in <type_traits>
|
| 563 |
#define __cpp_lib_uncaught_exceptions 201411L // also in <exception>
|
| 564 |
#define __cpp_lib_unordered_map_try_emplace 201411L // also in <unordered_map>
|
| 565 |
+
#define __cpp_lib_unreachable 202202L // also in <utility>
|
| 566 |
#define __cpp_lib_unwrap_ref 201811L // also in <type_traits>
|
| 567 |
+
#define __cpp_lib_variant 202106L // also in <variant>
|
| 568 |
#define __cpp_lib_void_t 201411L // also in <type_traits>
|
| 569 |
```
|
| 570 |
|
| 571 |
### Header `<limits>` synopsis <a id="limits.syn">[[limits.syn]]</a>
|
| 572 |
|
| 573 |
``` cpp
|
| 574 |
+
// all freestanding
|
| 575 |
namespace std {
|
| 576 |
+
// [round.style], enumeration float_round_style
|
| 577 |
enum float_round_style;
|
|
|
|
| 578 |
|
| 579 |
// [numeric.limits], class template numeric_limits
|
| 580 |
template<class T> class numeric_limits;
|
| 581 |
|
| 582 |
template<class T> class numeric_limits<const T>;
|
|
|
|
| 606 |
template<> class numeric_limits<double>;
|
| 607 |
template<> class numeric_limits<long double>;
|
| 608 |
}
|
| 609 |
```
|
| 610 |
|
| 611 |
+
### Enum `float_round_style` <a id="round.style">[[round.style]]</a>
|
|
|
|
|
|
|
| 612 |
|
| 613 |
``` cpp
|
| 614 |
namespace std {
|
| 615 |
enum float_round_style {
|
| 616 |
round_indeterminate = -1,
|
|
|
|
| 631 |
representable value
|
| 632 |
- `round_toward_infinity` if the rounding style is toward infinity
|
| 633 |
- `round_toward_neg_infinity` if the rounding style is toward negative
|
| 634 |
infinity
|
| 635 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
### Class template `numeric_limits` <a id="numeric.limits">[[numeric.limits]]</a>
|
| 637 |
|
| 638 |
+
#### General <a id="numeric.limits.general">[[numeric.limits.general]]</a>
|
| 639 |
+
|
| 640 |
The `numeric_limits` class template provides a C++ program with
|
| 641 |
information about various properties of the implementation’s
|
| 642 |
representation of the arithmetic types.
|
| 643 |
|
| 644 |
``` cpp
|
|
|
|
| 666 |
static constexpr int max_exponent10 = 0;
|
| 667 |
|
| 668 |
static constexpr bool has_infinity = false;
|
| 669 |
static constexpr bool has_quiet_NaN = false;
|
| 670 |
static constexpr bool has_signaling_NaN = false;
|
|
|
|
|
|
|
| 671 |
static constexpr T infinity() noexcept { return T(); }
|
| 672 |
static constexpr T quiet_NaN() noexcept { return T(); }
|
| 673 |
static constexpr T signaling_NaN() noexcept { return T(); }
|
| 674 |
static constexpr T denorm_min() noexcept { return T(); }
|
| 675 |
|
|
|
|
| 686 |
|
| 687 |
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 688 |
template, specializations shall define these values in such a way that
|
| 689 |
they are usable as constant expressions.
|
| 690 |
|
| 691 |
+
For the `numeric_limits` primary template, all data members are
|
| 692 |
+
value-initialized and all member functions return a value-initialized
|
| 693 |
+
object.
|
| 694 |
+
|
| 695 |
+
[*Note 1*: This means all members have zero or `false` values unless
|
| 696 |
+
`numeric_limits` is specialized for a type. — *end note*]
|
| 697 |
|
| 698 |
Specializations shall be provided for each arithmetic type, both
|
| 699 |
floating-point and integer, including `bool`. The member
|
| 700 |
`is_specialized` shall be `true` for all such specializations of
|
| 701 |
`numeric_limits`.
|
|
|
|
| 887 |
|
| 888 |
Meaningful for all floating-point types.
|
| 889 |
|
| 890 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 891 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 892 |
``` cpp
|
| 893 |
static constexpr T infinity() noexcept;
|
| 894 |
```
|
| 895 |
|
| 896 |
+
Representation of positive infinity, if available.[^18]
|
| 897 |
|
| 898 |
Meaningful for all specializations for which `has_infinity != false`.
|
| 899 |
Required in specializations for which `is_iec559 != false`.
|
| 900 |
|
| 901 |
``` cpp
|
| 902 |
static constexpr T quiet_NaN() noexcept;
|
| 903 |
```
|
| 904 |
|
| 905 |
+
Representation of a quiet “Not a Number”, if available.[^19]
|
| 906 |
|
| 907 |
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 908 |
Required in specializations for which `is_iec559 != false`.
|
| 909 |
|
| 910 |
``` cpp
|
| 911 |
static constexpr T signaling_NaN() noexcept;
|
| 912 |
```
|
| 913 |
|
| 914 |
+
Representation of a signaling “Not a Number”, if available.[^20]
|
| 915 |
|
| 916 |
Meaningful for all specializations for which
|
| 917 |
`has_signaling_NaN != false`. Required in specializations for which
|
| 918 |
`is_iec559 != false`.
|
| 919 |
|
| 920 |
``` cpp
|
| 921 |
static constexpr T denorm_min() noexcept;
|
| 922 |
```
|
| 923 |
|
| 924 |
+
Minimum positive subnormal value, if available.[^21]
|
| 925 |
+
|
| 926 |
+
Otherwise, minimum positive normalized value.
|
| 927 |
|
| 928 |
Meaningful for all floating-point types.
|
| 929 |
|
|
|
|
|
|
|
|
|
|
| 930 |
``` cpp
|
| 931 |
static constexpr bool is_iec559;
|
| 932 |
```
|
| 933 |
|
| 934 |
+
`true` if and only if the type adheres to ISO/IEC/IEEE 60559.[^22]
|
| 935 |
+
|
| 936 |
+
[*Note 1*: The value is `true` for any of the types `float16_t`,
|
| 937 |
+
`float32_t`, `float64_t`, or `float128_t`, if
|
| 938 |
+
present [[basic.extended.fp]]. — *end note*]
|
| 939 |
|
| 940 |
Meaningful for all floating-point types.
|
| 941 |
|
| 942 |
``` cpp
|
| 943 |
static constexpr bool is_bounded;
|
| 944 |
```
|
| 945 |
|
| 946 |
+
`true` if the set of values representable by the type is finite.[^23]
|
| 947 |
|
| 948 |
+
[*Note 2*: All fundamental types [[basic.fundamental]] are bounded.
|
| 949 |
This member would be `false` for arbitrary precision
|
| 950 |
types. — *end note*]
|
| 951 |
|
| 952 |
Meaningful for all specializations.
|
| 953 |
|
| 954 |
``` cpp
|
| 955 |
static constexpr bool is_modulo;
|
| 956 |
```
|
| 957 |
|
| 958 |
+
`true` if the type is modulo.[^24]
|
| 959 |
+
|
| 960 |
+
A type is modulo if, for any operation involving `+`, `-`, or `*` on
|
| 961 |
+
values of that type whose result would fall outside the range \[`min()`,
|
| 962 |
+
`max()`\], the value returned differs from the true value by an integer
|
| 963 |
+
multiple of `max() - min() + 1`.
|
| 964 |
|
| 965 |
[*Example 1*: `is_modulo` is `false` for signed integer
|
| 966 |
types [[basic.fundamental]] unless an implementation, as an extension to
|
| 967 |
this document, defines signed integer overflow to
|
| 968 |
wrap. — *end example*]
|
|
|
|
| 972 |
``` cpp
|
| 973 |
static constexpr bool traps;
|
| 974 |
```
|
| 975 |
|
| 976 |
`true` if, at the start of the program, there exists a value of the type
|
| 977 |
+
that would cause an arithmetic operation using that value to trap.[^25]
|
| 978 |
|
| 979 |
Meaningful for all specializations.
|
| 980 |
|
| 981 |
``` cpp
|
| 982 |
static constexpr bool tinyness_before;
|
| 983 |
```
|
| 984 |
|
| 985 |
+
`true` if tinyness is detected before rounding.[^26]
|
| 986 |
|
| 987 |
Meaningful for all floating-point types.
|
| 988 |
|
| 989 |
``` cpp
|
| 990 |
static constexpr float_round_style round_style;
|
| 991 |
```
|
| 992 |
|
| 993 |
+
The rounding style for the type.[^27]
|
| 994 |
|
| 995 |
Meaningful for all floating-point types. Specializations for integer
|
| 996 |
types shall return `round_toward_zero`.
|
| 997 |
|
| 998 |
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
|
|
|
| 1032 |
static constexpr int max_exponent10 = + 38;
|
| 1033 |
|
| 1034 |
static constexpr bool has_infinity = true;
|
| 1035 |
static constexpr bool has_quiet_NaN = true;
|
| 1036 |
static constexpr bool has_signaling_NaN = true;
|
|
|
|
|
|
|
| 1037 |
|
| 1038 |
static constexpr float infinity() noexcept { return value; }
|
| 1039 |
static constexpr float quiet_NaN() noexcept { return value; }
|
| 1040 |
static constexpr float signaling_NaN() noexcept { return value; }
|
| 1041 |
static constexpr float denorm_min() noexcept { return min(); }
|
|
|
|
| 1081 |
static constexpr int max_exponent10 = 0;
|
| 1082 |
|
| 1083 |
static constexpr bool has_infinity = false;
|
| 1084 |
static constexpr bool has_quiet_NaN = false;
|
| 1085 |
static constexpr bool has_signaling_NaN = false;
|
|
|
|
|
|
|
| 1086 |
static constexpr bool infinity() noexcept { return 0; }
|
| 1087 |
static constexpr bool quiet_NaN() noexcept { return 0; }
|
| 1088 |
static constexpr bool signaling_NaN() noexcept { return 0; }
|
| 1089 |
static constexpr bool denorm_min() noexcept { return 0; }
|
| 1090 |
|
|
|
|
| 1100 |
```
|
| 1101 |
|
| 1102 |
### Header `<climits>` synopsis <a id="climits.syn">[[climits.syn]]</a>
|
| 1103 |
|
| 1104 |
``` cpp
|
| 1105 |
+
// all freestanding
|
| 1106 |
#define CHAR_BIT see below
|
| 1107 |
#define SCHAR_MIN see below
|
| 1108 |
#define SCHAR_MAX see below
|
| 1109 |
#define UCHAR_MAX see below
|
| 1110 |
#define CHAR_MIN see below
|
|
|
|
| 1125 |
```
|
| 1126 |
|
| 1127 |
The header `<climits>` defines all macros the same as the C standard
|
| 1128 |
library header `<limits.h>`.
|
| 1129 |
|
| 1130 |
+
[*Note 1*: Except for `CHAR_BIT` and `MB_LEN_MAX`, a macro referring to
|
| 1131 |
+
an integer type `T` defines a constant whose type is the promoted type
|
| 1132 |
+
of `T` [[conv.prom]]. — *end note*]
|
| 1133 |
|
| 1134 |
See also: ISO C 5.2.4.2.1
|
| 1135 |
|
| 1136 |
### Header `<cfloat>` synopsis <a id="cfloat.syn">[[cfloat.syn]]</a>
|
| 1137 |
|
| 1138 |
``` cpp
|
| 1139 |
+
// all freestanding
|
| 1140 |
#define FLT_ROUNDS see below
|
| 1141 |
#define FLT_EVAL_METHOD see below
|
| 1142 |
#define FLT_HAS_SUBNORM see below
|
| 1143 |
#define DBL_HAS_SUBNORM see below
|
| 1144 |
#define LDBL_HAS_SUBNORM see below
|
|
|
|
| 1182 |
The header `<cfloat>` defines all macros the same as the C standard
|
| 1183 |
library header `<float.h>`.
|
| 1184 |
|
| 1185 |
See also: ISO C 5.2.4.2.2
|
| 1186 |
|
| 1187 |
+
## Arithmetic types <a id="support.arith.types">[[support.arith.types]]</a>
|
| 1188 |
|
| 1189 |
### Header `<cstdint>` synopsis <a id="cstdint.syn">[[cstdint.syn]]</a>
|
| 1190 |
|
| 1191 |
+
The header `<cstdint>` supplies integer types having specified widths,
|
| 1192 |
+
and macros that specify limits of integer types.
|
| 1193 |
+
|
| 1194 |
``` cpp
|
| 1195 |
+
// all freestanding
|
| 1196 |
namespace std {
|
| 1197 |
using int8_t = signed integer type; // optional
|
| 1198 |
using int16_t = signed integer type; // optional
|
| 1199 |
using int32_t = signed integer type; // optional
|
| 1200 |
using int64_t = signed integer type; // optional
|
| 1201 |
+
using intN_t = see below; // optional
|
| 1202 |
|
| 1203 |
using int_fast8_t = signed integer type;
|
| 1204 |
using int_fast16_t = signed integer type;
|
| 1205 |
using int_fast32_t = signed integer type;
|
| 1206 |
using int_fast64_t = signed integer type;
|
| 1207 |
+
using int_fastN_t = see below; // optional
|
| 1208 |
|
| 1209 |
using int_least8_t = signed integer type;
|
| 1210 |
using int_least16_t = signed integer type;
|
| 1211 |
using int_least32_t = signed integer type;
|
| 1212 |
using int_least64_t = signed integer type;
|
| 1213 |
+
using int_leastN_t = see below; // optional
|
| 1214 |
|
| 1215 |
using intmax_t = signed integer type;
|
| 1216 |
using intptr_t = signed integer type; // optional
|
| 1217 |
|
| 1218 |
using uint8_t = unsigned integer type; // optional
|
| 1219 |
using uint16_t = unsigned integer type; // optional
|
| 1220 |
using uint32_t = unsigned integer type; // optional
|
| 1221 |
using uint64_t = unsigned integer type; // optional
|
| 1222 |
+
using uintN_t = see below; // optional
|
| 1223 |
|
| 1224 |
using uint_fast8_t = unsigned integer type;
|
| 1225 |
using uint_fast16_t = unsigned integer type;
|
| 1226 |
using uint_fast32_t = unsigned integer type;
|
| 1227 |
using uint_fast64_t = unsigned integer type;
|
| 1228 |
+
using uint_fastN_t = see below; // optional
|
| 1229 |
|
| 1230 |
using uint_least8_t = unsigned integer type;
|
| 1231 |
using uint_least16_t = unsigned integer type;
|
| 1232 |
using uint_least32_t = unsigned integer type;
|
| 1233 |
using uint_least64_t = unsigned integer type;
|
| 1234 |
+
using uint_leastN_t = see below; // optional
|
| 1235 |
|
| 1236 |
using uintmax_t = unsigned integer type;
|
| 1237 |
using uintptr_t = unsigned integer type; // optional
|
| 1238 |
}
|
|
|
|
| 1239 |
|
| 1240 |
+
#define INTN_MIN see below
|
| 1241 |
+
#define INTN_MAX see below
|
| 1242 |
+
#define UINTN_MAX see below
|
| 1243 |
|
| 1244 |
+
#define INT_FASTN_MIN see below
|
| 1245 |
+
#define INT_FASTN_MAX see below
|
| 1246 |
+
#define UINT_FASTN_MAX see below
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1247 |
|
| 1248 |
+
#define INT_LEASTN_MIN see below
|
| 1249 |
+
#define INT_LEASTN_MAX see below
|
| 1250 |
+
#define UINT_LEASTN_MAX see below
|
| 1251 |
|
| 1252 |
+
#define INTMAX_MIN see below
|
| 1253 |
+
#define INTMAX_MAX see below
|
| 1254 |
+
#define UINTMAX_MAX see below
|
| 1255 |
+
|
| 1256 |
+
#define INTPTR_MIN see below // optional
|
| 1257 |
+
#define INTPTR_MAX see below // optional
|
| 1258 |
+
#define UINTPTR_MAX see below // optional
|
| 1259 |
+
|
| 1260 |
+
#define PTRDIFF_MIN see below
|
| 1261 |
+
#define PTRDIFF_MAX see below
|
| 1262 |
+
#define SIZE_MAX see below
|
| 1263 |
+
|
| 1264 |
+
#define SIG_ATOMIC_MIN see below
|
| 1265 |
+
#define SIG_ATOMIC_MAX see below
|
| 1266 |
+
|
| 1267 |
+
#define WCHAR_MIN see below
|
| 1268 |
+
#define WCHAR_MAX see below
|
| 1269 |
+
|
| 1270 |
+
#define WINT_MIN see below
|
| 1271 |
+
#define WINT_MAX see below
|
| 1272 |
+
|
| 1273 |
+
#define INTN_C(value) see below
|
| 1274 |
+
#define UINTN_C(value) see below
|
| 1275 |
+
#define INTMAX_C(value) see below
|
| 1276 |
+
#define UINTMAX_C(value) see below
|
| 1277 |
```
|
| 1278 |
|
| 1279 |
The header defines all types and macros the same as the C standard
|
| 1280 |
library header `<stdint.h>`.
|
| 1281 |
|
| 1282 |
See also: ISO C 7.20
|
| 1283 |
|
| 1284 |
+
All types that use the placeholder *N* are optional when *N* is not `8`,
|
| 1285 |
+
`16`, `32`, or `64`. The exact-width types `intN_t` and `uintN_t` for
|
| 1286 |
+
*N* = `8`, `16`, `32`, and `64` are also optional; however, if an
|
| 1287 |
+
implementation defines integer types with the corresponding width and no
|
| 1288 |
+
padding bits, it defines the corresponding *typedef-name*s. Each of the
|
| 1289 |
+
macros listed in this subclause is defined if and only if the
|
| 1290 |
+
implementation defines the corresponding *typedef-name*.
|
| 1291 |
+
|
| 1292 |
+
[*Note 1*: The macros `INTN_C` and `UINTN_C` correspond to the
|
| 1293 |
+
*typedef-name*s `int_leastN_t` and `uint_leastN_t`,
|
| 1294 |
+
respectively. — *end note*]
|
| 1295 |
+
|
| 1296 |
+
### Header `<stdfloat>` synopsis <a id="stdfloat.syn">[[stdfloat.syn]]</a>
|
| 1297 |
+
|
| 1298 |
+
The header `<stdfloat>` defines type aliases for the optional extended
|
| 1299 |
+
floating-point types that are specified in [[basic.extended.fp]].
|
| 1300 |
+
|
| 1301 |
+
``` cpp
|
| 1302 |
+
namespace std {
|
| 1303 |
+
#if defined(__STDCPP_FLOAT16_T__)
|
| 1304 |
+
using float16_t = implementation-defined; // see [basic.extended.fp]
|
| 1305 |
+
#endif
|
| 1306 |
+
#if defined(__STDCPP_FLOAT32_T__)
|
| 1307 |
+
using float32_t = implementation-defined; // see [basic.extended.fp]
|
| 1308 |
+
#endif
|
| 1309 |
+
#if defined(__STDCPP_FLOAT64_T__)
|
| 1310 |
+
using float64_t = implementation-defined; // see [basic.extended.fp]
|
| 1311 |
+
#endif
|
| 1312 |
+
#if defined(__STDCPP_FLOAT128_T__)
|
| 1313 |
+
using float128_t = implementation-defined; // see [basic.extended.fp]
|
| 1314 |
+
#endif
|
| 1315 |
+
#if defined(__STDCPP_BFLOAT16_T__)
|
| 1316 |
+
using bfloat16_t = implementation-defined; // see [basic.extended.fp]
|
| 1317 |
+
#endif
|
| 1318 |
+
}
|
| 1319 |
+
```
|
| 1320 |
+
|
| 1321 |
## Startup and termination <a id="support.start.term">[[support.start.term]]</a>
|
| 1322 |
|
| 1323 |
[*Note 1*: The header `<cstdlib>` declares the functions described in
|
| 1324 |
this subclause. — *end note*]
|
| 1325 |
|
|
|
|
| 1373 |
*Effects:*
|
| 1374 |
|
| 1375 |
- First, objects with thread storage duration and associated with the
|
| 1376 |
current thread are destroyed. Next, objects with static storage
|
| 1377 |
duration are destroyed and functions registered by calling `atexit`
|
| 1378 |
+
are called.[^28] See [[basic.start.term]] for the order of
|
| 1379 |
destructions and calls. (Objects with automatic storage duration are
|
| 1380 |
+
not destroyed as a result of calling `exit()`.)[^29] If a registered
|
| 1381 |
+
function invoked by `exit` exits via an exception, the function
|
| 1382 |
+
`std::terminate` is invoked [[except.terminate]].
|
|
|
|
| 1383 |
- Next, all open C streams (as mediated by the function signatures
|
| 1384 |
declared in `<cstdio>`) with unwritten buffered data are flushed, all
|
| 1385 |
open C streams are closed, and all files created by calling
|
| 1386 |
`tmpfile()` are removed.
|
| 1387 |
- Finally, control is returned to the host environment. If `status` is
|
| 1388 |
zero or `EXIT_SUCCESS`, an *implementation-defined* form of the status
|
| 1389 |
*successful termination* is returned. If `status` is `EXIT_FAILURE`,
|
| 1390 |
an *implementation-defined* form of the status *unsuccessful
|
| 1391 |
termination* is returned. Otherwise the status returned is
|
| 1392 |
+
*implementation-defined*.[^30]
|
| 1393 |
|
| 1394 |
``` cpp
|
| 1395 |
int at_quick_exit(c-atexit-handler* f) noexcept;
|
| 1396 |
int at_quick_exit(atexit-handler* f) noexcept;
|
| 1397 |
```
|
|
|
|
| 1402 |
before [[intro.multithread]] all calls to `quick_exit` will succeed.
|
| 1403 |
|
| 1404 |
[*Note 2*: The `at_quick_exit()` functions do not introduce a data
|
| 1405 |
race [[res.on.data.races]]. — *end note*]
|
| 1406 |
|
| 1407 |
+
[*Note 3*: The order of registration could be indeterminate if
|
| 1408 |
`at_quick_exit` was called from more than one thread. — *end note*]
|
| 1409 |
|
| 1410 |
[*Note 4*: The `at_quick_exit` registrations are distinct from the
|
| 1411 |
+
`atexit` registrations, and applications might need to call both
|
| 1412 |
registration functions with the same argument. — *end note*]
|
| 1413 |
|
| 1414 |
*Implementation limits:* The implementation shall support the
|
| 1415 |
registration of at least 32 functions.
|
| 1416 |
|
|
|
|
| 1422 |
|
| 1423 |
*Effects:* Functions registered by calls to `at_quick_exit` are called
|
| 1424 |
in the reverse order of their registration, except that a function shall
|
| 1425 |
be called after any previously registered functions that had already
|
| 1426 |
been called at the time it was registered. Objects shall not be
|
| 1427 |
+
destroyed as a result of calling `quick_exit`. If a registered function
|
| 1428 |
+
invoked by `quick_exit` exits via an exception, the function
|
| 1429 |
+
`std::terminate` is invoked [[except.terminate]].
|
|
|
|
| 1430 |
|
| 1431 |
[*Note 5*: A function registered via `at_quick_exit` is invoked by the
|
| 1432 |
thread that calls `quick_exit`, which can be a different thread than the
|
| 1433 |
+
one that registered it, so registered functions cannot rely on the
|
| 1434 |
identity of objects with thread storage duration. — *end note*]
|
| 1435 |
|
| 1436 |
After calling registered functions, `quick_exit` shall call
|
| 1437 |
`_Exit(status)`.
|
| 1438 |
|
|
|
|
| 1441 |
|
| 1442 |
See also: ISO C 7.22.4
|
| 1443 |
|
| 1444 |
## Dynamic memory management <a id="support.dynamic">[[support.dynamic]]</a>
|
| 1445 |
|
| 1446 |
+
### General <a id="support.dynamic.general">[[support.dynamic.general]]</a>
|
| 1447 |
+
|
| 1448 |
The header `<new>` defines several functions that manage the allocation
|
| 1449 |
of dynamic storage in a program. It also defines components for
|
| 1450 |
reporting storage management errors.
|
| 1451 |
|
| 1452 |
### Header `<new>` synopsis <a id="new.syn">[[new.syn]]</a>
|
| 1453 |
|
| 1454 |
``` cpp
|
| 1455 |
+
// all freestanding
|
| 1456 |
namespace std {
|
| 1457 |
// [alloc.errors], storage allocation errors
|
| 1458 |
class bad_alloc;
|
| 1459 |
class bad_array_new_length;
|
| 1460 |
|
|
|
|
| 1519 |
void operator delete[](void* ptr, void*) noexcept;
|
| 1520 |
```
|
| 1521 |
|
| 1522 |
### Storage allocation and deallocation <a id="new.delete">[[new.delete]]</a>
|
| 1523 |
|
| 1524 |
+
#### General <a id="new.delete.general">[[new.delete.general]]</a>
|
| 1525 |
+
|
| 1526 |
Except where otherwise specified, the provisions of
|
| 1527 |
[[basic.stc.dynamic]] apply to the library versions of `operator new`
|
| 1528 |
and `operator
|
| 1529 |
delete`. If the value of an alignment argument passed to any of these
|
| 1530 |
functions is not a valid alignment value, the behavior is undefined.
|
|
|
|
| 1605 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 1606 |
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 1607 |
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1608 |
```
|
| 1609 |
|
| 1610 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1611 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1612 |
+
replaced) `operator new(std::size_t)` or
|
| 1613 |
+
`operator new(std::size_t, std::align_val_t)` which has not been
|
| 1614 |
+
invalidated by an intervening call to `operator delete`.
|
| 1615 |
+
|
| 1616 |
+
If the `alignment` parameter is not present, `ptr` was returned by an
|
| 1617 |
+
allocation function without an `alignment` parameter. If present, the
|
| 1618 |
+
`alignment` argument is equal to the `alignment` argument passed to the
|
| 1619 |
+
allocation function that returned `ptr`. If present, the `size` argument
|
| 1620 |
+
is equal to the `size` argument passed to the allocation function that
|
| 1621 |
+
returned `ptr`.
|
| 1622 |
+
|
| 1623 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 1624 |
called by a *delete-expression*[[expr.delete]] to render the value of
|
| 1625 |
`ptr` invalid.
|
| 1626 |
|
| 1627 |
*Replaceable:* A C++ program may define functions with any of these
|
|
|
|
| 1631 |
If a function without a `size` parameter is defined, the program should
|
| 1632 |
also define the corresponding function with a `size` parameter. If a
|
| 1633 |
function with a `size` parameter is defined, the program shall also
|
| 1634 |
define the corresponding version without the `size` parameter.
|
| 1635 |
|
| 1636 |
+
[*Note 1*: The default behavior below might change in the future, which
|
| 1637 |
will require replacing both deallocation functions when replacing the
|
| 1638 |
allocation function. — *end note*]
|
| 1639 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1640 |
*Required behavior:* A call to an `operator delete` with a `size`
|
| 1641 |
parameter may be changed to a call to the corresponding
|
| 1642 |
`operator delete` without a `size` parameter, without affecting memory
|
| 1643 |
allocation.
|
| 1644 |
|
|
|
|
| 1664 |
``` cpp
|
| 1665 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 1666 |
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1667 |
```
|
| 1668 |
|
| 1669 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1670 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1671 |
+
replaced) `operator new(std::size_t)` or
|
| 1672 |
+
`operator new(std::size_t, std::align_val_t)` which has not been
|
| 1673 |
+
invalidated by an intervening call to `operator delete`.
|
| 1674 |
+
|
| 1675 |
+
If the `alignment` parameter is not present, `ptr` was returned by an
|
| 1676 |
+
allocation function without an `alignment` parameter. If present, the
|
| 1677 |
+
`alignment` argument is equal to the `alignment` argument passed to the
|
| 1678 |
+
allocation function that returned `ptr`.
|
| 1679 |
+
|
| 1680 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 1681 |
called by the implementation to render the value of `ptr` invalid when
|
| 1682 |
the constructor invoked from a nothrow placement version of the
|
| 1683 |
*new-expression* throws an exception.
|
| 1684 |
|
| 1685 |
*Replaceable:* A C++ program may define functions with either of these
|
| 1686 |
function signatures, and thereby displace the default versions defined
|
| 1687 |
by the C++ standard library.
|
| 1688 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1689 |
*Default behavior:* Calls `operator delete(ptr)`, or
|
| 1690 |
`operator delete(ptr, alignment)`, respectively.
|
| 1691 |
|
| 1692 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 1693 |
|
|
|
|
| 1697 |
```
|
| 1698 |
|
| 1699 |
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 1700 |
called by the array form of a *new-expression*[[expr.new]] to allocate
|
| 1701 |
`size` bytes of storage. The second form is called for a type with
|
| 1702 |
+
new-extended alignment, and the first form is called otherwise.[^31]
|
| 1703 |
|
| 1704 |
*Replaceable:* A C++ program may define functions with either of these
|
| 1705 |
function signatures, and thereby displace the default versions defined
|
| 1706 |
by the C++ standard library.
|
| 1707 |
|
|
|
|
| 1743 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 1744 |
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 1745 |
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 1746 |
```
|
| 1747 |
|
| 1748 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1749 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1750 |
+
replaced) `operator new[](std::size_t)` or
|
| 1751 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 1752 |
+
invalidated by an intervening call to `operator delete[]`.
|
| 1753 |
+
|
| 1754 |
+
If the `alignment` parameter is not present, `ptr` was returned by an
|
| 1755 |
+
allocation function without an `alignment` parameter. If present, the
|
| 1756 |
+
`alignment` argument is equal to the `alignment` argument passed to the
|
| 1757 |
+
allocation function that returned `ptr`. If present, the `size` argument
|
| 1758 |
+
is equal to the `size` argument passed to the allocation function that
|
| 1759 |
+
returned `ptr`.
|
| 1760 |
+
|
| 1761 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 1762 |
called by the array form of a *delete-expression* to render the value of
|
| 1763 |
`ptr` invalid.
|
| 1764 |
|
| 1765 |
*Replaceable:* A C++ program may define functions with any of these
|
|
|
|
| 1769 |
If a function without a `size` parameter is defined, the program should
|
| 1770 |
also define the corresponding function with a `size` parameter. If a
|
| 1771 |
function with a `size` parameter is defined, the program shall also
|
| 1772 |
define the corresponding version without the `size` parameter.
|
| 1773 |
|
| 1774 |
+
[*Note 1*: The default behavior below might change in the future, which
|
| 1775 |
will require replacing both deallocation functions when replacing the
|
| 1776 |
allocation function. — *end note*]
|
| 1777 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1778 |
*Required behavior:* A call to an `operator delete[]` with a `size`
|
| 1779 |
parameter may be changed to a call to the corresponding
|
| 1780 |
`operator delete[]` without a `size` parameter, without affecting memory
|
| 1781 |
allocation.
|
| 1782 |
|
|
|
|
| 1793 |
``` cpp
|
| 1794 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 1795 |
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 1796 |
```
|
| 1797 |
|
| 1798 |
+
*Preconditions:* `ptr` is a null pointer or its value represents the
|
| 1799 |
+
address of a block of memory allocated by an earlier call to a (possibly
|
| 1800 |
+
replaced) `operator new[](std::size_t)` or
|
| 1801 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 1802 |
+
invalidated by an intervening call to `operator delete[]`.
|
| 1803 |
+
|
| 1804 |
+
If the `alignment` parameter is not present, `ptr` was returned by an
|
| 1805 |
+
allocation function without an `alignment` parameter. If present, the
|
| 1806 |
+
`alignment` argument is equal to the `alignment` argument passed to the
|
| 1807 |
+
allocation function that returned `ptr`.
|
| 1808 |
+
|
| 1809 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 1810 |
called by the implementation to render the value of `ptr` invalid when
|
| 1811 |
the constructor invoked from a nothrow placement version of the array
|
| 1812 |
*new-expression* throws an exception.
|
| 1813 |
|
| 1814 |
*Replaceable:* A C++ program may define functions with either of these
|
| 1815 |
function signatures, and thereby displace the default versions defined
|
| 1816 |
by the C++ standard library.
|
| 1817 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1818 |
*Default behavior:* Calls `operator delete[](ptr)`, or
|
| 1819 |
`operator delete[](ptr, alignment)`, respectively.
|
| 1820 |
|
| 1821 |
#### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
| 1822 |
|
|
|
|
| 1856 |
void operator delete(void* ptr, void*) noexcept;
|
| 1857 |
```
|
| 1858 |
|
| 1859 |
*Effects:* Intentionally performs no action.
|
| 1860 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1861 |
*Remarks:* Default function called when any part of the initialization
|
| 1862 |
in a placement *new-expression* that invokes the library’s non-array
|
| 1863 |
placement operator new terminates by throwing an exception [[expr.new]].
|
| 1864 |
|
| 1865 |
``` cpp
|
| 1866 |
void operator delete[](void* ptr, void*) noexcept;
|
| 1867 |
```
|
| 1868 |
|
| 1869 |
*Effects:* Intentionally performs no action.
|
| 1870 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1871 |
*Remarks:* Default function called when any part of the initialization
|
| 1872 |
in a placement *new-expression* that invokes the library’s array
|
| 1873 |
placement operator new terminates by throwing an exception [[expr.new]].
|
| 1874 |
|
| 1875 |
#### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
|
|
|
|
| 1967 |
new_handler get_new_handler() noexcept;
|
| 1968 |
```
|
| 1969 |
|
| 1970 |
*Returns:* The current `new_handler`.
|
| 1971 |
|
| 1972 |
+
[*Note 1*: This can be a null pointer value. — *end note*]
|
| 1973 |
|
| 1974 |
### Pointer optimization barrier <a id="ptr.launder">[[ptr.launder]]</a>
|
| 1975 |
|
| 1976 |
``` cpp
|
| 1977 |
template<class T> [[nodiscard]] constexpr T* launder(T* p) noexcept;
|
|
|
|
| 1980 |
*Mandates:* `!is_function_v<T> && !is_void_v<T>` is `true`.
|
| 1981 |
|
| 1982 |
*Preconditions:* `p` represents the address *A* of a byte in memory. An
|
| 1983 |
object *X* that is within its lifetime [[basic.life]] and whose type is
|
| 1984 |
similar [[conv.qual]] to `T` is located at the address *A*. All bytes of
|
| 1985 |
+
storage that would be reachable through [[basic.compound]] the result
|
| 1986 |
+
are reachable through `p`.
|
| 1987 |
|
| 1988 |
+
*Returns:* A value of type `T*` that points to *X*.
|
| 1989 |
|
| 1990 |
*Remarks:* An invocation of this function may be used in a core constant
|
| 1991 |
+
expression if and only if the (converted) value of its argument may be
|
| 1992 |
+
used in place of the function invocation.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1993 |
|
| 1994 |
[*Note 1*: If a new object is created in storage occupied by an
|
| 1995 |
existing object of the same type, a pointer to the original object can
|
| 1996 |
be used to refer to the new object unless its complete object is a const
|
| 1997 |
object or it is a base class subobject; in the latter cases, this
|
|
|
|
| 2058 |
|
| 2059 |
— *end example*]
|
| 2060 |
|
| 2061 |
## Type identification <a id="support.rtti">[[support.rtti]]</a>
|
| 2062 |
|
| 2063 |
+
### General <a id="support.rtti.general">[[support.rtti.general]]</a>
|
| 2064 |
+
|
| 2065 |
The header `<typeinfo>` defines a type associated with type information
|
| 2066 |
generated by the implementation. It also defines two types for reporting
|
| 2067 |
dynamic type identification errors.
|
| 2068 |
|
| 2069 |
### Header `<typeinfo>` synopsis <a id="typeinfo.syn">[[typeinfo.syn]]</a>
|
| 2070 |
|
| 2071 |
``` cpp
|
| 2072 |
+
// all freestanding
|
| 2073 |
namespace std {
|
| 2074 |
class type_info;
|
| 2075 |
class bad_cast;
|
| 2076 |
class bad_typeid;
|
| 2077 |
}
|
|
|
|
| 2082 |
``` cpp
|
| 2083 |
namespace std {
|
| 2084 |
class type_info {
|
| 2085 |
public:
|
| 2086 |
virtual ~type_info();
|
| 2087 |
+
constexpr bool operator==(const type_info& rhs) const noexcept;
|
| 2088 |
bool before(const type_info& rhs) const noexcept;
|
| 2089 |
size_t hash_code() const noexcept;
|
| 2090 |
const char* name() const noexcept;
|
| 2091 |
|
| 2092 |
type_info(const type_info&) = delete; // cannot be copied
|
|
|
|
| 2101 |
comparing two types for equality or collating order. The names, encoding
|
| 2102 |
rule, and collating sequence for types are all unspecified and may
|
| 2103 |
differ between programs.
|
| 2104 |
|
| 2105 |
``` cpp
|
| 2106 |
+
constexpr bool operator==(const type_info& rhs) const noexcept;
|
| 2107 |
```
|
| 2108 |
|
| 2109 |
*Effects:* Compares the current object with `rhs`.
|
| 2110 |
|
| 2111 |
*Returns:* `true` if the two values describe the same type.
|
|
|
|
| 2136 |
|
| 2137 |
*Returns:* An *implementation-defined* NTBS.
|
| 2138 |
|
| 2139 |
*Remarks:* The message may be a null-terminated multibyte
|
| 2140 |
string [[multibyte.strings]], suitable for conversion and display as a
|
| 2141 |
+
`wstring` [[string.classes]], [[locale.codecvt]].
|
| 2142 |
|
| 2143 |
### Class `bad_cast` <a id="bad.cast">[[bad.cast]]</a>
|
| 2144 |
|
| 2145 |
``` cpp
|
| 2146 |
namespace std {
|
|
|
|
| 2190 |
|
| 2191 |
The header `<source_location>` defines the class `source_location` that
|
| 2192 |
provides a means to obtain source location information.
|
| 2193 |
|
| 2194 |
``` cpp
|
| 2195 |
+
// all freestanding
|
| 2196 |
namespace std {
|
| 2197 |
struct source_location;
|
| 2198 |
}
|
| 2199 |
```
|
| 2200 |
|
| 2201 |
### Class `source_location` <a id="support.srcloc.class">[[support.srcloc.class]]</a>
|
| 2202 |
|
| 2203 |
+
#### General <a id="support.srcloc.class.general">[[support.srcloc.class.general]]</a>
|
| 2204 |
+
|
| 2205 |
``` cpp
|
| 2206 |
namespace std {
|
| 2207 |
struct source_location {
|
| 2208 |
// source location construction
|
| 2209 |
static consteval source_location current() noexcept;
|
|
|
|
| 2223 |
};
|
| 2224 |
}
|
| 2225 |
```
|
| 2226 |
|
| 2227 |
The type `source_location` meets the *Cpp17DefaultConstructible*,
|
| 2228 |
+
*Cpp17CopyConstructible*, *Cpp17CopyAssignable*, *Cpp17Swappable*, and
|
| 2229 |
+
*Cpp17Destructible* requirements
|
| 2230 |
+
[[utility.arg.requirements]], [[swappable.requirements]]. All of the
|
| 2231 |
following conditions are `true`:
|
| 2232 |
|
| 2233 |
- `is_nothrow_move_constructible_v<source_location>`
|
| 2234 |
- `is_nothrow_move_assignable_v<source_location>`
|
| 2235 |
- `is_nothrow_swappable_v<source_location>`
|
|
|
|
| 2262 |
|
| 2263 |
*Returns:*
|
| 2264 |
|
| 2265 |
- When invoked by a function call whose *postfix-expression* is a
|
| 2266 |
(possibly parenthesized) *id-expression* naming `current`, returns a
|
| 2267 |
+
`source_location` with an *implementation-defined* value. The value
|
| 2268 |
should be affected by `#line` [[cpp.line]] in the same manner as for
|
| 2269 |
\_\_LINE\_\_ and \_\_FILE\_\_. The values of the exposition-only data
|
| 2270 |
members of the returned `source_location` object are indicated in
|
| 2271 |
[[support.srcloc.current]].
|
| 2272 |
- Otherwise, when invoked in some other way, returns a `source_location`
|
|
|
|
| 2311 |
|
| 2312 |
``` cpp
|
| 2313 |
constexpr source_location() noexcept;
|
| 2314 |
```
|
| 2315 |
|
| 2316 |
+
*Effects:* The data members are initialized with valid but unspecified
|
| 2317 |
+
values.
|
| 2318 |
|
| 2319 |
#### Observers <a id="support.srcloc.obs">[[support.srcloc.obs]]</a>
|
| 2320 |
|
| 2321 |
``` cpp
|
| 2322 |
constexpr uint_least32_t line() const noexcept;
|
|
|
|
| 2342 |
|
| 2343 |
*Returns:* `function_name_`.
|
| 2344 |
|
| 2345 |
## Exception handling <a id="support.exception">[[support.exception]]</a>
|
| 2346 |
|
| 2347 |
+
### General <a id="support.exception.general">[[support.exception.general]]</a>
|
| 2348 |
+
|
| 2349 |
The header `<exception>` defines several types and functions related to
|
| 2350 |
the handling of exceptions in a C++ program.
|
| 2351 |
|
| 2352 |
### Header `<exception>` synopsis <a id="exception.syn">[[exception.syn]]</a>
|
| 2353 |
|
| 2354 |
``` cpp
|
| 2355 |
+
// all freestanding
|
| 2356 |
namespace std {
|
| 2357 |
class exception;
|
| 2358 |
class bad_exception;
|
| 2359 |
class nested_exception;
|
| 2360 |
|
|
|
|
| 2430 |
|
| 2431 |
*Returns:* An *implementation-defined* NTBS.
|
| 2432 |
|
| 2433 |
*Remarks:* The message may be a null-terminated multibyte
|
| 2434 |
string [[multibyte.strings]], suitable for conversion and display as a
|
| 2435 |
+
`wstring` [[string.classes]], [[locale.codecvt]]. The return value
|
| 2436 |
remains valid until the exception object from which it is obtained is
|
| 2437 |
destroyed or a non-`const` member function of the exception object is
|
| 2438 |
called.
|
| 2439 |
|
| 2440 |
### Class `bad_exception` <a id="bad.exception">[[bad.exception]]</a>
|
|
|
|
| 2466 |
|
| 2467 |
``` cpp
|
| 2468 |
using terminate_handler = void (*)();
|
| 2469 |
```
|
| 2470 |
|
| 2471 |
+
The type of a *handler function* to be invoked by `terminate` when
|
| 2472 |
terminating exception processing.
|
| 2473 |
|
| 2474 |
*Required behavior:* A `terminate_handler` shall terminate execution of
|
| 2475 |
the program without returning to the caller.
|
| 2476 |
|
|
|
|
| 2484 |
```
|
| 2485 |
|
| 2486 |
*Effects:* Establishes the function designated by `f` as the current
|
| 2487 |
handler function for terminating exception processing.
|
| 2488 |
|
| 2489 |
+
*Returns:* The previous `terminate_handler`.
|
| 2490 |
+
|
| 2491 |
*Remarks:* It is unspecified whether a null pointer value designates the
|
| 2492 |
default `terminate_handler`.
|
| 2493 |
|
|
|
|
|
|
|
| 2494 |
#### `get_terminate` <a id="get.terminate">[[get.terminate]]</a>
|
| 2495 |
|
| 2496 |
``` cpp
|
| 2497 |
terminate_handler get_terminate() noexcept;
|
| 2498 |
```
|
| 2499 |
|
| 2500 |
*Returns:* The current `terminate_handler`.
|
| 2501 |
|
| 2502 |
+
[*Note 1*: This can be a null pointer value. — *end note*]
|
| 2503 |
|
| 2504 |
#### `terminate` <a id="terminate">[[terminate]]</a>
|
| 2505 |
|
| 2506 |
``` cpp
|
| 2507 |
[[noreturn]] void terminate() noexcept;
|
| 2508 |
```
|
| 2509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2510 |
*Effects:* Calls a `terminate_handler` function. It is unspecified which
|
| 2511 |
`terminate_handler` function will be called if an exception is active
|
| 2512 |
during a call to `set_terminate`. Otherwise calls the current
|
| 2513 |
`terminate_handler` function.
|
| 2514 |
|
| 2515 |
[*Note 1*: A default `terminate_handler` is always considered a
|
| 2516 |
callable handler in this context. — *end note*]
|
| 2517 |
|
| 2518 |
+
*Remarks:* Called by the implementation when exception handling must be
|
| 2519 |
+
abandoned for any of several reasons [[except.terminate]]. May also be
|
| 2520 |
+
called directly by the program.
|
| 2521 |
+
|
| 2522 |
### `uncaught_exceptions` <a id="uncaught.exceptions">[[uncaught.exceptions]]</a>
|
| 2523 |
|
| 2524 |
``` cpp
|
| 2525 |
int uncaught_exceptions() noexcept;
|
| 2526 |
```
|
|
|
|
| 2548 |
the type.
|
| 2549 |
|
| 2550 |
`exception_ptr` shall not be implicitly convertible to any arithmetic,
|
| 2551 |
enumeration, or pointer type.
|
| 2552 |
|
| 2553 |
+
[*Note 1*: An implementation can use a reference-counted smart pointer
|
| 2554 |
+
as `exception_ptr`. — *end note*]
|
| 2555 |
|
| 2556 |
For purposes of determining the presence of a data race, operations on
|
| 2557 |
`exception_ptr` objects shall access and modify only the `exception_ptr`
|
| 2558 |
objects themselves and not the exceptions they refer to. Use of
|
| 2559 |
`rethrow_exception` on `exception_ptr` objects that refer to the same
|
| 2560 |
exception object shall not introduce a data race.
|
| 2561 |
|
| 2562 |
[*Note 2*: If `rethrow_exception` rethrows the same exception object
|
| 2563 |
(rather than a copy), concurrent access to that rethrown exception
|
| 2564 |
+
object can introduce a data race. Changes in the number of
|
| 2565 |
`exception_ptr` objects that refer to a particular exception do not
|
| 2566 |
introduce a data race. — *end note*]
|
| 2567 |
|
| 2568 |
``` cpp
|
| 2569 |
exception_ptr current_exception() noexcept;
|
|
|
|
| 2585 |
If the attempt to copy the current exception object throws an exception,
|
| 2586 |
the function returns an `exception_ptr` object that refers to the thrown
|
| 2587 |
exception or, if this is not possible, to an instance of
|
| 2588 |
`bad_exception`.
|
| 2589 |
|
| 2590 |
+
[*Note 4*: The copy constructor of the thrown exception can also fail,
|
| 2591 |
so the implementation is allowed to substitute a `bad_exception` object
|
| 2592 |
to avoid infinite recursion. — *end note*]
|
| 2593 |
|
| 2594 |
``` cpp
|
| 2595 |
[[noreturn]] void rethrow_exception(exception_ptr p);
|
| 2596 |
```
|
| 2597 |
|
| 2598 |
*Preconditions:* `p` is not a null pointer.
|
| 2599 |
|
| 2600 |
+
*Effects:* Let u be the exception object to which `p` refers, or a copy
|
| 2601 |
+
of that exception object. It is unspecified whether a copy is made, and
|
| 2602 |
+
memory for the copy is allocated in an unspecified way.
|
| 2603 |
+
|
| 2604 |
+
- If allocating memory to form u fails, throws an instance of
|
| 2605 |
+
`bad_alloc`;
|
| 2606 |
+
- otherwise, if copying the exception to which `p` refers to form u
|
| 2607 |
+
throws an exception, throws that exception;
|
| 2608 |
+
- otherwise, throws u.
|
| 2609 |
|
| 2610 |
``` cpp
|
| 2611 |
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
| 2612 |
```
|
| 2613 |
|
|
|
|
| 2703 |
p->rethrow_nested();
|
| 2704 |
```
|
| 2705 |
|
| 2706 |
## Initializer lists <a id="support.initlist">[[support.initlist]]</a>
|
| 2707 |
|
| 2708 |
+
### General <a id="support.initlist.general">[[support.initlist.general]]</a>
|
| 2709 |
+
|
| 2710 |
The header `<initializer_list>` defines a class template and several
|
| 2711 |
support functions related to list-initialization (see
|
| 2712 |
+
[[dcl.init.list]]). All functions specified in [[support.initlist]] are
|
| 2713 |
signal-safe [[support.signal]].
|
| 2714 |
|
| 2715 |
### Header `<initializer_list>` synopsis <a id="initializer.list.syn">[[initializer.list.syn]]</a>
|
| 2716 |
|
| 2717 |
``` cpp
|
| 2718 |
+
// all freestanding
|
| 2719 |
namespace std {
|
| 2720 |
template<class E> class initializer_list {
|
| 2721 |
public:
|
| 2722 |
using value_type = E;
|
| 2723 |
using reference = const E&;
|
|
|
|
| 2805 |
The header `<compare>` specifies types, objects, and functions for use
|
| 2806 |
primarily in connection with the three-way comparison operator
|
| 2807 |
[[expr.spaceship]].
|
| 2808 |
|
| 2809 |
``` cpp
|
| 2810 |
+
// all freestanding
|
| 2811 |
namespace std {
|
| 2812 |
// [cmp.categories], comparison category types
|
| 2813 |
class partial_ordering;
|
| 2814 |
class weak_ordering;
|
| 2815 |
class strong_ordering;
|
|
|
|
| 2866 |
in terms of an exposition-only data member named `value` whose value
|
| 2867 |
typically corresponds to that of an enumerator from one of the following
|
| 2868 |
exposition-only enumerations:
|
| 2869 |
|
| 2870 |
``` cpp
|
| 2871 |
+
enum class ord { equal = 0, equivalent = equal, less = -1, greater = 1 }; // exposition only
|
|
|
|
|
|
|
| 2872 |
enum class ncmp { unordered = -127 }; // exposition only
|
| 2873 |
```
|
| 2874 |
|
| 2875 |
[*Note 1*: The type `strong_ordering` corresponds to the term total
|
| 2876 |
ordering in mathematics. — *end note*]
|
|
|
|
| 2897 |
that is accessible via the argument’s public const members.
|
| 2898 |
|
| 2899 |
#### Class `partial_ordering` <a id="cmp.partialord">[[cmp.partialord]]</a>
|
| 2900 |
|
| 2901 |
The `partial_ordering` type is typically used as the result type of a
|
| 2902 |
+
three-way comparison operator [[expr.spaceship]] for a type that admits
|
| 2903 |
+
all of the six two-way comparison operators [[expr.rel]], [[expr.eq]],
|
| 2904 |
+
for which equality need not imply substitutability, and that permits two
|
| 2905 |
+
values to be incomparable.[^32]
|
| 2906 |
|
| 2907 |
``` cpp
|
| 2908 |
namespace std {
|
| 2909 |
class partial_ordering {
|
| 2910 |
int value; // exposition only
|
| 2911 |
bool is_ordered; // exposition only
|
| 2912 |
|
| 2913 |
// exposition-only constructors
|
|
|
|
|
|
|
| 2914 |
constexpr explicit
|
| 2915 |
partial_ordering(ord v) noexcept : value(int(v)), is_ordered(true) {} // exposition only
|
| 2916 |
constexpr explicit
|
| 2917 |
partial_ordering(ncmp v) noexcept : value(int(v)), is_ordered(false) {} // exposition only
|
| 2918 |
|
|
|
|
| 2938 |
friend constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
|
| 2939 |
};
|
| 2940 |
|
| 2941 |
// valid values' definitions
|
| 2942 |
inline constexpr partial_ordering partial_ordering::less(ord::less);
|
| 2943 |
+
inline constexpr partial_ordering partial_ordering::equivalent(ord::equivalent);
|
| 2944 |
inline constexpr partial_ordering partial_ordering::greater(ord::greater);
|
| 2945 |
inline constexpr partial_ordering partial_ordering::unordered(ncmp::unordered);
|
| 2946 |
}
|
| 2947 |
```
|
| 2948 |
|
|
|
|
| 2979 |
`v < 0 ? partial_ordering::greater : v > 0 ? partial_ordering::less : v`.
|
| 2980 |
|
| 2981 |
#### Class `weak_ordering` <a id="cmp.weakord">[[cmp.weakord]]</a>
|
| 2982 |
|
| 2983 |
The `weak_ordering` type is typically used as the result type of a
|
| 2984 |
+
three-way comparison operator [[expr.spaceship]] for a type that admits
|
| 2985 |
+
all of the six two-way comparison operators [[expr.rel]], [[expr.eq]]
|
| 2986 |
+
and for which equality need not imply substitutability.
|
| 2987 |
|
| 2988 |
``` cpp
|
| 2989 |
namespace std {
|
| 2990 |
class weak_ordering {
|
| 2991 |
int value; // exposition only
|
| 2992 |
|
| 2993 |
// exposition-only constructors
|
|
|
|
| 2994 |
constexpr explicit weak_ordering(ord v) noexcept : value(int(v)) {} // exposition only
|
| 2995 |
|
| 2996 |
public:
|
| 2997 |
// valid values
|
| 2998 |
static const weak_ordering less;
|
|
|
|
| 3017 |
friend constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
|
| 3018 |
};
|
| 3019 |
|
| 3020 |
// valid values' definitions
|
| 3021 |
inline constexpr weak_ordering weak_ordering::less(ord::less);
|
| 3022 |
+
inline constexpr weak_ordering weak_ordering::equivalent(ord::equivalent);
|
| 3023 |
inline constexpr weak_ordering weak_ordering::greater(ord::greater);
|
| 3024 |
}
|
| 3025 |
```
|
| 3026 |
|
| 3027 |
``` cpp
|
|
|
|
| 3069 |
`v < 0 ? weak_ordering::greater : v > 0 ? weak_ordering::less : v`.
|
| 3070 |
|
| 3071 |
#### Class `strong_ordering` <a id="cmp.strongord">[[cmp.strongord]]</a>
|
| 3072 |
|
| 3073 |
The `strong_ordering` type is typically used as the result type of a
|
| 3074 |
+
three-way comparison operator [[expr.spaceship]] for a type that admits
|
| 3075 |
+
all of the six two-way comparison operators [[expr.rel]], [[expr.eq]]
|
| 3076 |
+
and for which equality does imply substitutability.
|
| 3077 |
|
| 3078 |
``` cpp
|
| 3079 |
namespace std {
|
| 3080 |
class strong_ordering {
|
| 3081 |
int value; // exposition only
|
| 3082 |
|
| 3083 |
// exposition-only constructors
|
|
|
|
| 3084 |
constexpr explicit strong_ordering(ord v) noexcept : value(int(v)) {} // exposition only
|
| 3085 |
|
| 3086 |
public:
|
| 3087 |
// valid values
|
| 3088 |
static const strong_ordering less;
|
|
|
|
| 3109 |
friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;
|
| 3110 |
};
|
| 3111 |
|
| 3112 |
// valid values' definitions
|
| 3113 |
inline constexpr strong_ordering strong_ordering::less(ord::less);
|
| 3114 |
+
inline constexpr strong_ordering strong_ordering::equal(ord::equal);
|
| 3115 |
+
inline constexpr strong_ordering strong_ordering::equivalent(ord::equivalent);
|
| 3116 |
inline constexpr strong_ordering strong_ordering::greater(ord::greater);
|
| 3117 |
}
|
| 3118 |
```
|
| 3119 |
|
| 3120 |
``` cpp
|
|
|
|
| 3196 |
type.
|
| 3197 |
|
| 3198 |
[*Note 1*: This is `std::strong_ordering` if the expansion is
|
| 3199 |
empty. — *end note*]
|
| 3200 |
|
| 3201 |
+
### Concept <a id="cmp.concept">[[cmp.concept]]</a>
|
| 3202 |
|
| 3203 |
``` cpp
|
| 3204 |
template<class T, class Cat>
|
| 3205 |
concept compares-as = // exposition only
|
| 3206 |
same_as<common_comparison_category_t<T, Cat>, Cat>;
|
|
|
|
| 3256 |
``` cpp
|
| 3257 |
template<class T, class U, class Cat = partial_ordering>
|
| 3258 |
concept three_way_comparable_with =
|
| 3259 |
three_way_comparable<T, Cat> &&
|
| 3260 |
three_way_comparable<U, Cat> &&
|
| 3261 |
+
comparison-common-type-with<T, U> &&
|
| 3262 |
three_way_comparable<
|
| 3263 |
common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>, Cat> &&
|
| 3264 |
weakly-equality-comparable-with<T, U> &&
|
| 3265 |
partially-ordered-with<T, U> &&
|
| 3266 |
requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) {
|
| 3267 |
{ t <=> u } -> compares-as<Cat>;
|
| 3268 |
{ u <=> t } -> compares-as<Cat>;
|
| 3269 |
};
|
| 3270 |
```
|
| 3271 |
|
| 3272 |
+
Let `t` and `t2` be lvalues denoting distinct equal objects of types
|
| 3273 |
+
`const remove_reference_t<T>` and `remove_cvref_t<T>`, respectively, and
|
| 3274 |
+
let `u` and `u2` be lvalues denoting distinct equal objects of types
|
| 3275 |
+
`const remove_reference_t<U>` and `remove_cvref_t<U>`, respectively. Let
|
| 3276 |
+
`C` be
|
| 3277 |
`common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>`.
|
| 3278 |
+
Let `CONVERT_TO_LVALUE<C>(E)` be defined as in
|
| 3279 |
+
[[concepts.compare.general]]. `T`, `U`, and `Cat` model
|
| 3280 |
+
`three_way_comparable_with<T, U, Cat>` only if:
|
| 3281 |
|
| 3282 |
- `t <=> u` and `u <=> t` have the same domain,
|
| 3283 |
- `((t <=> u) <=> 0)` and `(0 <=> (u <=> t))` are equal,
|
| 3284 |
- `(t <=> u == 0) == bool(t == u)` is `true`,
|
| 3285 |
- `(t <=> u != 0) == bool(t != u)` is `true`,
|
| 3286 |
+
- `Cat(t <=> u) == Cat(CONVERT_TO_LVALUE<C>(t2) <=>
|
| 3287 |
+
CONVERT_TO_LVALUE<C>(u2))` is `true`,
|
| 3288 |
- `(t <=> u < 0) == bool(t < u)` is `true`,
|
| 3289 |
- `(t <=> u > 0) == bool(t > u)` is `true`,
|
| 3290 |
- `(t <=> u <= 0) == bool(t <= u)` is `true`,
|
| 3291 |
- `(t <=> u >= 0) == bool(t >= u)` is `true`, and
|
| 3292 |
- if `Cat` is convertible to `strong_ordering`, `T` and `U` model
|
|
|
|
| 3309 |
### Comparison algorithms <a id="cmp.alg">[[cmp.alg]]</a>
|
| 3310 |
|
| 3311 |
The name `strong_order` denotes a customization point object
|
| 3312 |
[[customization.point.object]]. Given subexpressions `E` and `F`, the
|
| 3313 |
expression `strong_order(E, F)` is expression-equivalent
|
| 3314 |
+
[[defns.expression.equivalent]] to the following:
|
| 3315 |
|
| 3316 |
- If the decayed types of `E` and `F` differ, `strong_order(E, F)` is
|
| 3317 |
ill-formed.
|
| 3318 |
- Otherwise, `strong_ordering(strong_order(E, F))` if it is a
|
| 3319 |
+
well-formed expression where the meaning of `strong_order` is
|
| 3320 |
+
established as-if by performing argument-dependent lookup only
|
| 3321 |
+
[[basic.lookup.argdep]].
|
| 3322 |
- Otherwise, if the decayed type `T` of `E` is a floating-point type,
|
| 3323 |
yields a value of type `strong_ordering` that is consistent with the
|
| 3324 |
ordering observed by `T`’s comparison operators, and if
|
| 3325 |
`numeric_limits<T>::is_iec559` is `true`, is additionally consistent
|
| 3326 |
with the `totalOrder` operation as specified in ISO/IEC/IEEE 60559.
|
| 3327 |
- Otherwise, `strong_ordering(compare_three_way()(E, F))` if it is a
|
| 3328 |
well-formed expression.
|
| 3329 |
+
- Otherwise, `strong_order(E, F)` is ill-formed.
|
| 3330 |
+
|
| 3331 |
+
[*Note 1*: Ill-formed cases above result in substitution failure when
|
| 3332 |
+
`strong_order(E, F)` appears in the immediate context of a template
|
| 3333 |
+
instantiation. — *end note*]
|
| 3334 |
|
| 3335 |
The name `weak_order` denotes a customization point object
|
| 3336 |
[[customization.point.object]]. Given subexpressions `E` and `F`, the
|
| 3337 |
expression `weak_order(E, F)` is expression-equivalent
|
| 3338 |
+
[[defns.expression.equivalent]] to the following:
|
| 3339 |
|
| 3340 |
- If the decayed types of `E` and `F` differ, `weak_order(E, F)` is
|
| 3341 |
ill-formed.
|
| 3342 |
- Otherwise, `weak_ordering(weak_order(E, F))` if it is a well-formed
|
| 3343 |
+
expression where the meaning of `weak_order` is established as-if by
|
| 3344 |
+
performing argument-dependent lookup only [[basic.lookup.argdep]].
|
| 3345 |
- Otherwise, if the decayed type `T` of `E` is a floating-point type,
|
| 3346 |
yields a value of type `weak_ordering` that is consistent with the
|
| 3347 |
ordering observed by `T`’s comparison operators and `strong_order`,
|
| 3348 |
and if `numeric_limits<T>::is_iec559` is `true`, is additionally
|
| 3349 |
consistent with the following equivalence classes, ordered from lesser
|
|
|
|
| 3359 |
- together, all positive NaN values.
|
| 3360 |
- Otherwise, `weak_ordering(compare_three_way()(E, F))` if it is a
|
| 3361 |
well-formed expression.
|
| 3362 |
- Otherwise, `weak_ordering(strong_order(E, F))` if it is a well-formed
|
| 3363 |
expression.
|
| 3364 |
+
- Otherwise, `weak_order(E, F)` is ill-formed.
|
| 3365 |
+
|
| 3366 |
+
[*Note 2*: Ill-formed cases above result in substitution failure when
|
| 3367 |
+
`weak_order(E, F)` appears in the immediate context of a template
|
| 3368 |
+
instantiation. — *end note*]
|
| 3369 |
|
| 3370 |
The name `partial_order` denotes a customization point object
|
| 3371 |
[[customization.point.object]]. Given subexpressions `E` and `F`, the
|
| 3372 |
expression `partial_order(E, F)` is expression-equivalent
|
| 3373 |
+
[[defns.expression.equivalent]] to the following:
|
| 3374 |
|
| 3375 |
- If the decayed types of `E` and `F` differ, `partial_order(E, F)` is
|
| 3376 |
ill-formed.
|
| 3377 |
- Otherwise, `partial_ordering(partial_order(E, F))` if it is a
|
| 3378 |
+
well-formed expression where the meaning of `partial_order` is
|
| 3379 |
+
established as-if by performing argument-dependent lookup only
|
| 3380 |
+
[[basic.lookup.argdep]].
|
| 3381 |
- Otherwise, `partial_ordering(compare_three_way()(E, F))` if it is a
|
| 3382 |
well-formed expression.
|
| 3383 |
- Otherwise, `partial_ordering(weak_order(E, F))` if it is a well-formed
|
| 3384 |
expression.
|
| 3385 |
+
- Otherwise, `partial_order(E, F)` is ill-formed.
|
| 3386 |
+
|
| 3387 |
+
[*Note 3*: Ill-formed cases above result in substitution failure when
|
| 3388 |
+
`partial_order(E, F)` appears in the immediate context of a template
|
| 3389 |
instantiation. — *end note*]
|
| 3390 |
|
| 3391 |
The name `compare_strong_order_fallback` denotes a customization point
|
| 3392 |
+
object [[customization.point.object]]. Given subexpressions `E` and `F`,
|
| 3393 |
the expression `compare_strong_order_fallback(E, F)` is
|
| 3394 |
+
expression-equivalent [[defns.expression.equivalent]] to:
|
| 3395 |
|
| 3396 |
- If the decayed types of `E` and `F` differ,
|
| 3397 |
`compare_strong_order_fallback(E, F)` is ill-formed.
|
| 3398 |
- Otherwise, `strong_order(E, F)` if it is a well-formed expression.
|
| 3399 |
- Otherwise, if the expressions `E == F` and `E < F` are both
|
| 3400 |
+
well-formed and each of `decltype(E == F)` and `decltype(E < F)`
|
| 3401 |
+
models `boolean-testable`,
|
| 3402 |
``` cpp
|
| 3403 |
E == F ? strong_ordering::equal :
|
| 3404 |
E < F ? strong_ordering::less :
|
| 3405 |
strong_ordering::greater
|
| 3406 |
```
|
| 3407 |
|
| 3408 |
except that `E` and `F` are evaluated only once.
|
| 3409 |
- Otherwise, `compare_strong_order_fallback(E, F)` is ill-formed.
|
| 3410 |
|
| 3411 |
+
[*Note 4*: Ill-formed cases above result in substitution failure when
|
| 3412 |
+
`compare_strong_order_fallback(E, F)` appears in the immediate context
|
| 3413 |
+
of a template instantiation. — *end note*]
|
| 3414 |
+
|
| 3415 |
The name `compare_weak_order_fallback` denotes a customization point
|
| 3416 |
object [[customization.point.object]]. Given subexpressions `E` and `F`,
|
| 3417 |
the expression `compare_weak_order_fallback(E, F)` is
|
| 3418 |
+
expression-equivalent [[defns.expression.equivalent]] to:
|
| 3419 |
|
| 3420 |
- If the decayed types of `E` and `F` differ,
|
| 3421 |
`compare_weak_order_fallback(E, F)` is ill-formed.
|
| 3422 |
- Otherwise, `weak_order(E, F)` if it is a well-formed expression.
|
| 3423 |
- Otherwise, if the expressions `E == F` and `E < F` are both
|
| 3424 |
+
well-formed and each of `decltype(E == F)` and `decltype(E < F)`
|
| 3425 |
+
models `boolean-testable`,
|
| 3426 |
``` cpp
|
| 3427 |
E == F ? weak_ordering::equivalent :
|
| 3428 |
E < F ? weak_ordering::less :
|
| 3429 |
weak_ordering::greater
|
| 3430 |
```
|
| 3431 |
|
| 3432 |
except that `E` and `F` are evaluated only once.
|
| 3433 |
- Otherwise, `compare_weak_order_fallback(E, F)` is ill-formed.
|
| 3434 |
|
| 3435 |
+
[*Note 5*: Ill-formed cases above result in substitution failure when
|
| 3436 |
+
`compare_weak_order_fallback(E, F)` appears in the immediate context of
|
| 3437 |
+
a template instantiation. — *end note*]
|
| 3438 |
+
|
| 3439 |
The name `compare_partial_order_fallback` denotes a customization point
|
| 3440 |
object [[customization.point.object]]. Given subexpressions `E` and `F`,
|
| 3441 |
the expression `compare_partial_order_fallback(E, F)` is
|
| 3442 |
+
expression-equivalent [[defns.expression.equivalent]] to:
|
| 3443 |
|
| 3444 |
- If the decayed types of `E` and `F` differ,
|
| 3445 |
`compare_partial_order_fallback(E, F)` is ill-formed.
|
| 3446 |
- Otherwise, `partial_order(E, F)` if it is a well-formed expression.
|
| 3447 |
+
- Otherwise, if the expressions `E == F`, `E < F`, and `F < E` are all
|
| 3448 |
+
well-formed and each of `decltype(E == F)` and `decltype(E < F)`
|
| 3449 |
+
models `boolean-testable`,
|
| 3450 |
``` cpp
|
| 3451 |
E == F ? partial_ordering::equivalent :
|
| 3452 |
E < F ? partial_ordering::less :
|
| 3453 |
F < E ? partial_ordering::greater :
|
| 3454 |
partial_ordering::unordered
|
| 3455 |
```
|
| 3456 |
|
| 3457 |
except that `E` and `F` are evaluated only once.
|
| 3458 |
- Otherwise, `compare_partial_order_fallback(E, F)` is ill-formed.
|
| 3459 |
|
| 3460 |
+
[*Note 6*: Ill-formed cases above result in substitution failure when
|
| 3461 |
+
`compare_partial_order_fallback(E, F)` appears in the immediate context
|
| 3462 |
+
of a template instantiation. — *end note*]
|
| 3463 |
+
|
| 3464 |
## Coroutines <a id="support.coroutine">[[support.coroutine]]</a>
|
| 3465 |
|
| 3466 |
+
### General <a id="support.coroutine.general">[[support.coroutine.general]]</a>
|
| 3467 |
+
|
| 3468 |
The header `<coroutine>` defines several types providing compile and
|
| 3469 |
run-time support for coroutines in a C++ program.
|
| 3470 |
|
| 3471 |
### Header `<coroutine>` synopsis <a id="coroutine.syn">[[coroutine.syn]]</a>
|
| 3472 |
|
| 3473 |
``` cpp
|
| 3474 |
+
// all freestanding
|
| 3475 |
#include <compare> // see [compare.syn]
|
| 3476 |
|
| 3477 |
namespace std {
|
| 3478 |
// [coroutine.traits], coroutine traits
|
| 3479 |
template<class R, class... ArgTypes>
|
|
|
|
| 3505 |
}
|
| 3506 |
```
|
| 3507 |
|
| 3508 |
### Coroutine traits <a id="coroutine.traits">[[coroutine.traits]]</a>
|
| 3509 |
|
| 3510 |
+
#### General <a id="coroutine.traits.general">[[coroutine.traits.general]]</a>
|
| 3511 |
+
|
| 3512 |
+
Subclause [[coroutine.traits]] defines requirements on classes
|
| 3513 |
+
representing *coroutine traits*, and defines the class template
|
| 3514 |
+
`coroutine_traits` that meets those requirements.
|
| 3515 |
|
| 3516 |
#### Class template `coroutine_traits` <a id="coroutine.traits.primary">[[coroutine.traits.primary]]</a>
|
| 3517 |
|
| 3518 |
The header `<coroutine>` defines the primary template `coroutine_traits`
|
| 3519 |
such that if `ArgTypes` is a parameter pack of types and if the
|
|
|
|
| 3530 |
Program-defined specializations of this template shall define a publicly
|
| 3531 |
accessible nested type named `promise_type`.
|
| 3532 |
|
| 3533 |
### Class template `coroutine_handle` <a id="coroutine.handle">[[coroutine.handle]]</a>
|
| 3534 |
|
| 3535 |
+
#### General <a id="coroutine.handle.general">[[coroutine.handle.general]]</a>
|
| 3536 |
+
|
| 3537 |
``` cpp
|
| 3538 |
namespace std {
|
| 3539 |
template<>
|
| 3540 |
struct coroutine_handle<void>
|
| 3541 |
{
|
|
|
|
| 3560 |
private:
|
| 3561 |
void* ptr; // exposition only
|
| 3562 |
};
|
| 3563 |
|
| 3564 |
template<class Promise>
|
| 3565 |
+
struct coroutine_handle
|
| 3566 |
{
|
| 3567 |
// [coroutine.handle.con], construct/reset
|
| 3568 |
+
constexpr coroutine_handle() noexcept;
|
| 3569 |
+
constexpr coroutine_handle(nullptr_t) noexcept;
|
| 3570 |
static coroutine_handle from_promise(Promise&);
|
| 3571 |
coroutine_handle& operator=(nullptr_t) noexcept;
|
| 3572 |
|
| 3573 |
// [coroutine.handle.export.import], export/import
|
| 3574 |
+
constexpr void* address() const noexcept;
|
| 3575 |
static constexpr coroutine_handle from_address(void* addr);
|
| 3576 |
|
| 3577 |
+
// [coroutine.handle.conv], conversion
|
| 3578 |
+
constexpr operator coroutine_handle<>() const noexcept;
|
| 3579 |
+
|
| 3580 |
+
// [coroutine.handle.observers], observers
|
| 3581 |
+
constexpr explicit operator bool() const noexcept;
|
| 3582 |
+
bool done() const;
|
| 3583 |
+
|
| 3584 |
+
// [coroutine.handle.resumption], resumption
|
| 3585 |
+
void operator()() const;
|
| 3586 |
+
void resume() const;
|
| 3587 |
+
void destroy() const;
|
| 3588 |
+
|
| 3589 |
// [coroutine.handle.promise], promise access
|
| 3590 |
Promise& promise() const;
|
| 3591 |
+
|
| 3592 |
+
private:
|
| 3593 |
+
void* ptr; // exposition only
|
| 3594 |
};
|
| 3595 |
}
|
| 3596 |
```
|
| 3597 |
|
| 3598 |
An object of type `coroutine_handle<T>` is called a *coroutine handle*
|
| 3599 |
and can be used to refer to a suspended or executing coroutine. A
|
| 3600 |
+
`coroutine_handle` object whose member `address()` returns a null
|
| 3601 |
+
pointer value does not refer to any coroutine. Two `coroutine_handle`
|
| 3602 |
+
objects refer to the same coroutine if and only if their member
|
| 3603 |
+
`address()` returns the same non-null value.
|
| 3604 |
|
| 3605 |
If a program declares an explicit or partial specialization of
|
| 3606 |
`coroutine_handle`, the behavior is undefined.
|
| 3607 |
|
| 3608 |
#### Construct/reset <a id="coroutine.handle.con">[[coroutine.handle.con]]</a>
|
|
|
|
| 3618 |
static coroutine_handle from_promise(Promise& p);
|
| 3619 |
```
|
| 3620 |
|
| 3621 |
*Preconditions:* `p` is a reference to a promise object of a coroutine.
|
| 3622 |
|
|
|
|
|
|
|
| 3623 |
*Ensures:* `addressof(h.promise()) == addressof(p)`.
|
| 3624 |
|
| 3625 |
+
*Returns:* A coroutine handle `h` referring to the coroutine.
|
| 3626 |
+
|
| 3627 |
``` cpp
|
| 3628 |
coroutine_handle& operator=(nullptr_t) noexcept;
|
| 3629 |
```
|
| 3630 |
|
| 3631 |
*Ensures:* `address() == nullptr`.
|
| 3632 |
|
| 3633 |
*Returns:* `*this`.
|
| 3634 |
|
| 3635 |
+
#### Conversion <a id="coroutine.handle.conv">[[coroutine.handle.conv]]</a>
|
| 3636 |
+
|
| 3637 |
+
``` cpp
|
| 3638 |
+
constexpr operator coroutine_handle<>() const noexcept;
|
| 3639 |
+
```
|
| 3640 |
+
|
| 3641 |
+
*Effects:* Equivalent to:
|
| 3642 |
+
`return coroutine_handle<>::from_address(address());`
|
| 3643 |
+
|
| 3644 |
#### Export/import <a id="coroutine.handle.export.import">[[coroutine.handle.export.import]]</a>
|
| 3645 |
|
| 3646 |
``` cpp
|
| 3647 |
constexpr void* address() const noexcept;
|
| 3648 |
```
|
| 3649 |
|
| 3650 |
*Returns:* `ptr`.
|
| 3651 |
|
| 3652 |
``` cpp
|
| 3653 |
static constexpr coroutine_handle<> coroutine_handle<>::from_address(void* addr);
|
| 3654 |
+
```
|
| 3655 |
+
|
| 3656 |
+
*Preconditions:* `addr` was obtained via a prior call to `address` on an
|
| 3657 |
+
object whose type is a specialization of `coroutine_handle`.
|
| 3658 |
+
|
| 3659 |
+
*Ensures:* `from_address(address()) == *this`.
|
| 3660 |
+
|
| 3661 |
+
``` cpp
|
| 3662 |
static constexpr coroutine_handle<Promise> coroutine_handle<Promise>::from_address(void* addr);
|
| 3663 |
```
|
| 3664 |
|
| 3665 |
+
*Preconditions:* `addr` was obtained via a prior call to `address` on an
|
| 3666 |
+
object of type cv `coroutine_handle<Promise>`.
|
| 3667 |
|
| 3668 |
*Ensures:* `from_address(address()) == *this`.
|
| 3669 |
|
| 3670 |
#### Observers <a id="coroutine.handle.observers">[[coroutine.handle.observers]]</a>
|
| 3671 |
|
|
|
|
| 3686 |
|
| 3687 |
#### Resumption <a id="coroutine.handle.resumption">[[coroutine.handle.resumption]]</a>
|
| 3688 |
|
| 3689 |
Resuming a coroutine via `resume`, `operator()`, or `destroy` on an
|
| 3690 |
execution agent other than the one on which it was suspended has
|
| 3691 |
+
*implementation-defined* behavior unless each execution agent either is
|
| 3692 |
+
an instance of `std::thread` or `std::jthread`, or is the thread that
|
| 3693 |
executes `main`.
|
| 3694 |
|
| 3695 |
[*Note 1*: A coroutine that is resumed on a different execution agent
|
| 3696 |
should avoid relying on consistent thread identity throughout, such as
|
| 3697 |
holding a mutex object across a suspend point. — *end note*]
|
| 3698 |
|
| 3699 |
+
[*Note 2*: A concurrent resumption of the coroutine can result in a
|
| 3700 |
data race. — *end note*]
|
| 3701 |
|
| 3702 |
``` cpp
|
| 3703 |
void operator()() const;
|
| 3704 |
void resume() const;
|
|
|
|
| 3763 |
#### Class `coroutine_handle<noop_coroutine_promise>` <a id="coroutine.handle.noop">[[coroutine.handle.noop]]</a>
|
| 3764 |
|
| 3765 |
``` cpp
|
| 3766 |
namespace std {
|
| 3767 |
template<>
|
| 3768 |
+
struct coroutine_handle<noop_coroutine_promise>
|
| 3769 |
{
|
| 3770 |
+
// [coroutine.handle.noop.conv], conversion
|
| 3771 |
+
constexpr operator coroutine_handle<>() const noexcept;
|
| 3772 |
+
|
| 3773 |
// [coroutine.handle.noop.observers], observers
|
| 3774 |
constexpr explicit operator bool() const noexcept;
|
| 3775 |
constexpr bool done() const noexcept;
|
| 3776 |
|
| 3777 |
// [coroutine.handle.noop.resumption], resumption
|
|
|
|
| 3784 |
|
| 3785 |
// [coroutine.handle.noop.address], address
|
| 3786 |
constexpr void* address() const noexcept;
|
| 3787 |
private:
|
| 3788 |
coroutine_handle(unspecified);
|
| 3789 |
+
void* ptr; // exposition only
|
| 3790 |
};
|
| 3791 |
}
|
| 3792 |
```
|
| 3793 |
|
| 3794 |
+
##### Conversion <a id="coroutine.handle.noop.conv">[[coroutine.handle.noop.conv]]</a>
|
| 3795 |
+
|
| 3796 |
+
``` cpp
|
| 3797 |
+
constexpr operator coroutine_handle<>() const noexcept;
|
| 3798 |
+
```
|
| 3799 |
+
|
| 3800 |
+
*Effects:* Equivalent to:
|
| 3801 |
+
`return coroutine_handle<>::from_address(address());`
|
| 3802 |
+
|
| 3803 |
##### Observers <a id="coroutine.handle.noop.observers">[[coroutine.handle.noop.observers]]</a>
|
| 3804 |
|
| 3805 |
``` cpp
|
| 3806 |
constexpr explicit operator bool() const noexcept;
|
| 3807 |
```
|
|
|
|
| 3877 |
};
|
| 3878 |
}
|
| 3879 |
```
|
| 3880 |
|
| 3881 |
[*Note 1*: The types `suspend_never` and `suspend_always` can be used
|
| 3882 |
+
to indicate that an *await-expression* either never suspends or always
|
| 3883 |
+
suspends, and in either case does not produce a value. — *end note*]
|
| 3884 |
|
| 3885 |
## Other runtime support <a id="support.runtime">[[support.runtime]]</a>
|
| 3886 |
|
| 3887 |
+
### General <a id="support.runtime.general">[[support.runtime.general]]</a>
|
| 3888 |
+
|
| 3889 |
Headers `<csetjmp>` (nonlocal jumps), `<csignal>` (signal handling),
|
| 3890 |
`<cstdarg>` (variable arguments), and `<cstdlib>` (runtime environment
|
| 3891 |
`getenv`, `system`), provide further compatibility with C code.
|
| 3892 |
|
| 3893 |
Calls to the function `getenv` [[cstdlib.syn]] shall not introduce a
|
|
|
|
| 3904 |
the `setlocale` function.
|
| 3905 |
|
| 3906 |
### Header `<cstdarg>` synopsis <a id="cstdarg.syn">[[cstdarg.syn]]</a>
|
| 3907 |
|
| 3908 |
``` cpp
|
| 3909 |
+
// all freestanding
|
| 3910 |
namespace std {
|
| 3911 |
using va_list = see below;
|
| 3912 |
}
|
| 3913 |
|
| 3914 |
#define va_arg(V, P) see below
|
|
|
|
| 3916 |
#define va_end(V) see below
|
| 3917 |
#define va_start(V, P) see below
|
| 3918 |
```
|
| 3919 |
|
| 3920 |
The contents of the header `<cstdarg>` are the same as the C standard
|
| 3921 |
+
library header `<stdarg.h>`, with the following changes:
|
| 3922 |
+
|
| 3923 |
+
- In lieu of the default argument promotions specified in ISO C 6.5.2.2,
|
| 3924 |
+
the definition in [[expr.call]] applies.
|
| 3925 |
+
- The restrictions that ISO C places on the second parameter to the
|
| 3926 |
+
`va_start` macro in header `<stdarg.h>` are different in this
|
| 3927 |
+
document. The parameter `parmN` is the rightmost parameter in the
|
| 3928 |
+
variable parameter list of the function definition (the one just
|
| 3929 |
+
before the `...`).[^33] If the parameter `parmN` is a pack expansion
|
| 3930 |
+
[[temp.variadic]] or an entity resulting from a lambda capture
|
| 3931 |
+
[[expr.prim.lambda]], the program is ill-formed, no diagnostic
|
| 3932 |
+
required. If the parameter `parmN` is of a reference type, or of a
|
| 3933 |
+
type that is not compatible with the type that results when passing an
|
| 3934 |
+
argument for which there is no parameter, the behavior is undefined.
|
| 3935 |
|
| 3936 |
See also: ISO C 7.16.1.1
|
| 3937 |
|
| 3938 |
### Header `<csetjmp>` synopsis <a id="csetjmp.syn">[[csetjmp.syn]]</a>
|
| 3939 |
|
|
|
|
| 3994 |
A *plain lock-free atomic operation* is an invocation of a function `f`
|
| 3995 |
from [[atomics]], such that:
|
| 3996 |
|
| 3997 |
- `f` is the function `atomic_is_lock_free()`, or
|
| 3998 |
- `f` is the member function `is_lock_free()`, or
|
| 3999 |
+
- `f` is a non-static member function of class `atomic_flag`, or
|
| 4000 |
+
- `f` is a non-member function, and the first parameter of `f` has type
|
| 4001 |
+
cv `atomic_flag*`, or
|
| 4002 |
- `f` is a non-static member function invoked on an object `A`, such
|
| 4003 |
that `A.is_lock_free()` yields `true`, or
|
| 4004 |
- `f` is a non-member function, and for every pointer-to-atomic argument
|
| 4005 |
`A` passed to `f`, `atomic_is_lock_free(A)` yields `true`.
|
| 4006 |
|
|
|
|
| 4014 |
- an access to an object with thread storage duration;
|
| 4015 |
- a `dynamic_cast` expression;
|
| 4016 |
- throwing of an exception;
|
| 4017 |
- control entering a *try-block* or *function-try-block*;
|
| 4018 |
- initialization of a variable with static storage duration requiring
|
| 4019 |
+
dynamic initialization [[basic.start.dynamic]], [[stmt.dcl]][^34] ; or
|
|
|
|
| 4020 |
- waiting for the completion of the initialization of a variable with
|
| 4021 |
static storage duration [[stmt.dcl]].
|
| 4022 |
|
| 4023 |
A signal handler invocation has undefined behavior if it includes an
|
| 4024 |
evaluation that is not signal-safe.
|
|
|
|
| 4027 |
argument equal to the signal number corresponding to the signal that
|
| 4028 |
caused the invocation of the handler.
|
| 4029 |
|
| 4030 |
See also: ISO C 7.14
|
| 4031 |
|
| 4032 |
+
## C headers <a id="support.c.headers">[[support.c.headers]]</a>
|
| 4033 |
+
|
| 4034 |
+
### General <a id="support.c.headers.general">[[support.c.headers.general]]</a>
|
| 4035 |
+
|
| 4036 |
+
For compatibility with the C standard library, the C++ standard library
|
| 4037 |
+
provides the *C headers* shown in [[c.headers]]. The intended use of
|
| 4038 |
+
these headers is for interoperability only. It is possible that C++
|
| 4039 |
+
source files need to include one of these headers in order to be valid
|
| 4040 |
+
ISO C. Source files that are not intended to also be valid ISO C should
|
| 4041 |
+
not use any of the C headers.
|
| 4042 |
+
|
| 4043 |
+
[*Note 1*: The C headers either have no effect, such as `<stdbool.h>`
|
| 4044 |
+
and `<stdalign.h>`, or otherwise the corresponding header of the form
|
| 4045 |
+
`<cname>` provides the same facilities and assuredly defines them in
|
| 4046 |
+
namespace `std`. — *end note*]
|
| 4047 |
+
|
| 4048 |
+
[*Example 1*:
|
| 4049 |
+
|
| 4050 |
+
The following source file is both valid C++ and valid ISO C. Viewed as
|
| 4051 |
+
C++, it declares a function with C language linkage; viewed as C it
|
| 4052 |
+
simply declares a function (and provides a prototype).
|
| 4053 |
+
|
| 4054 |
+
``` cpp
|
| 4055 |
+
#include <stdbool.h> // for bool in C, no effect in C++{}
|
| 4056 |
+
#include <stddef.h> // for size_t
|
| 4057 |
+
|
| 4058 |
+
#ifdef __cplusplus // see [cpp.predefined]
|
| 4059 |
+
extern "C" // see [dcl.link]
|
| 4060 |
+
#endif
|
| 4061 |
+
void f(bool b[], size_t n);
|
| 4062 |
+
```
|
| 4063 |
+
|
| 4064 |
+
— *end example*]
|
| 4065 |
+
|
| 4066 |
+
### Header `<complex.h>` synopsis <a id="complex.h.syn">[[complex.h.syn]]</a>
|
| 4067 |
+
|
| 4068 |
+
``` cpp
|
| 4069 |
+
#include <complex>
|
| 4070 |
+
```
|
| 4071 |
+
|
| 4072 |
+
The header `<complex.h>` behaves as if it simply includes the header
|
| 4073 |
+
`<complex>`.
|
| 4074 |
+
|
| 4075 |
+
[*Note 1*: Names introduced by `<complex>` in namespace `std` are not
|
| 4076 |
+
placed into the global namespace scope by `<complex.h>`. — *end note*]
|
| 4077 |
+
|
| 4078 |
+
### Header `<iso646.h>` synopsis <a id="iso646.h.syn">[[iso646.h.syn]]</a>
|
| 4079 |
+
|
| 4080 |
+
The C++ header `<iso646.h>` is empty.
|
| 4081 |
+
|
| 4082 |
+
[*Note 1*: `and`, `and_eq`, `bitand`, `bitor`, `compl`, `not_eq`,
|
| 4083 |
+
`not`, `or`, `or_eq`, `xor`, and `xor_eq` are keywords in C++
|
| 4084 |
+
[[lex.key]]. — *end note*]
|
| 4085 |
+
|
| 4086 |
+
### Header `<stdalign.h>` synopsis <a id="stdalign.h.syn">[[stdalign.h.syn]]</a>
|
| 4087 |
+
|
| 4088 |
+
The contents of the C++ header `<stdalign.h>` are the same as the C
|
| 4089 |
+
standard library header `<stdalign.h>`, with the following changes: The
|
| 4090 |
+
header `<stdalign.h>` does not define a macro named `alignas`.
|
| 4091 |
+
|
| 4092 |
+
See also: ISO C 7.15
|
| 4093 |
+
|
| 4094 |
+
### Header `<stdbool.h>` synopsis <a id="stdbool.h.syn">[[stdbool.h.syn]]</a>
|
| 4095 |
+
|
| 4096 |
+
The contents of the C++ header `<stdbool.h>` are the same as the C
|
| 4097 |
+
standard library header `<stdbool.h>`, with the following changes: The
|
| 4098 |
+
header `<stdbool.h>` does not define macros named `bool`, `true`, or
|
| 4099 |
+
`false`.
|
| 4100 |
+
|
| 4101 |
+
See also: ISO C 7.18
|
| 4102 |
+
|
| 4103 |
+
### Header `<tgmath.h>` synopsis <a id="tgmath.h.syn">[[tgmath.h.syn]]</a>
|
| 4104 |
+
|
| 4105 |
+
``` cpp
|
| 4106 |
+
#include <cmath>
|
| 4107 |
+
#include <complex>
|
| 4108 |
+
```
|
| 4109 |
+
|
| 4110 |
+
The header `<tgmath.h>` behaves as if it simply includes the headers
|
| 4111 |
+
`<cmath>` and `<complex>`.
|
| 4112 |
+
|
| 4113 |
+
[*Note 1*: The overloads provided in C by type-generic macros are
|
| 4114 |
+
already provided in `<complex>` and `<cmath>` by “sufficient” additional
|
| 4115 |
+
overloads. — *end note*]
|
| 4116 |
+
|
| 4117 |
+
[*Note 2*: Names introduced by `<cmath>` or `<complex>` in namespace
|
| 4118 |
+
`std` are not placed into the global namespace scope by
|
| 4119 |
+
`<tgmath.h>`. — *end note*]
|
| 4120 |
+
|
| 4121 |
+
### Other C headers <a id="support.c.headers.other">[[support.c.headers.other]]</a>
|
| 4122 |
+
|
| 4123 |
+
Every C header other than `<complex.h>`, `<iso646.h>`, `<stdalign.h>`,
|
| 4124 |
+
`<stdatomic.h>`, `<stdbool.h>`, and `<tgmath.h>`, each of which has a
|
| 4125 |
+
name of the form `<name.h>`, behaves as if each name placed in the
|
| 4126 |
+
standard library namespace by the corresponding `<cname>` header is
|
| 4127 |
+
placed within the global namespace scope, except for the functions
|
| 4128 |
+
described in [[sf.cmath]], the `std::lerp` function overloads
|
| 4129 |
+
[[c.math.lerp]], the declaration of `std::byte` [[cstddef.syn]], and the
|
| 4130 |
+
functions and function templates described in [[support.types.byteops]].
|
| 4131 |
+
It is unspecified whether these names are first declared or defined
|
| 4132 |
+
within namespace scope [[basic.scope.namespace]] of the namespace `std`
|
| 4133 |
+
and are then injected into the global namespace scope by explicit
|
| 4134 |
+
*using-declaration*s [[namespace.udecl]].
|
| 4135 |
+
|
| 4136 |
+
[*Example 1*: The header `<cstdlib>` assuredly provides its
|
| 4137 |
+
declarations and definitions within the namespace `std`. It may also
|
| 4138 |
+
provide these names within the global namespace. The header `<stdlib.h>`
|
| 4139 |
+
assuredly provides the same declarations and definitions within the
|
| 4140 |
+
global namespace, much as in the C Standard. It may also provide these
|
| 4141 |
+
names within the namespace `std`. — *end example*]
|
| 4142 |
+
|
| 4143 |
<!-- Link reference definitions -->
|
| 4144 |
[alg.c.library]: algorithms.md#alg.c.library
|
| 4145 |
[alloc.errors]: #alloc.errors
|
| 4146 |
+
[atomics]: thread.md#atomics
|
| 4147 |
[bad.alloc]: #bad.alloc
|
| 4148 |
[bad.cast]: #bad.cast
|
| 4149 |
[bad.exception]: #bad.exception
|
| 4150 |
[bad.typeid]: #bad.typeid
|
| 4151 |
[basic.align]: basic.md#basic.align
|
| 4152 |
+
[basic.compound]: basic.md#basic.compound
|
| 4153 |
+
[basic.extended.fp]: basic.md#basic.extended.fp
|
| 4154 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 4155 |
[basic.life]: basic.md#basic.life
|
| 4156 |
+
[basic.lookup.argdep]: basic.md#basic.lookup.argdep
|
| 4157 |
+
[basic.scope.namespace]: basic.md#basic.scope.namespace
|
| 4158 |
[basic.start.dynamic]: basic.md#basic.start.dynamic
|
| 4159 |
[basic.start.term]: basic.md#basic.start.term
|
| 4160 |
[basic.stc.dynamic]: basic.md#basic.stc.dynamic
|
| 4161 |
[basic.stc.dynamic.allocation]: basic.md#basic.stc.dynamic.allocation
|
| 4162 |
[basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
|
| 4163 |
+
[c.headers]: #c.headers
|
| 4164 |
[c.locales]: localization.md#c.locales
|
| 4165 |
+
[c.malloc]: mem.md#c.malloc
|
| 4166 |
[c.math.abs]: numerics.md#c.math.abs
|
| 4167 |
+
[c.math.lerp]: numerics.md#c.math.lerp
|
| 4168 |
[c.math.rand]: numerics.md#c.math.rand
|
| 4169 |
[c.mb.wcs]: strings.md#c.mb.wcs
|
| 4170 |
[cfloat.syn]: #cfloat.syn
|
| 4171 |
[class.mem]: class.md#class.mem
|
| 4172 |
[class.prop]: class.md#class.prop
|
|
|
|
| 4182 |
[cmp.result]: #cmp.result
|
| 4183 |
[cmp.strongord]: #cmp.strongord
|
| 4184 |
[cmp.weakord]: #cmp.weakord
|
| 4185 |
[compare.syn]: #compare.syn
|
| 4186 |
[complex]: numerics.md#complex
|
| 4187 |
+
[complex.h.syn]: #complex.h.syn
|
| 4188 |
[concept.totallyordered]: concepts.md#concept.totallyordered
|
| 4189 |
+
[concepts.compare.general]: concepts.md#concepts.compare.general
|
| 4190 |
[constraints]: library.md#constraints
|
| 4191 |
+
[conv.prom]: expr.md#conv.prom
|
| 4192 |
[conv.ptr]: expr.md#conv.ptr
|
| 4193 |
[conv.qual]: expr.md#conv.qual
|
| 4194 |
[conv.rank]: basic.md#conv.rank
|
| 4195 |
[coroutine.handle]: #coroutine.handle
|
| 4196 |
[coroutine.handle.compare]: #coroutine.handle.compare
|
| 4197 |
[coroutine.handle.con]: #coroutine.handle.con
|
| 4198 |
+
[coroutine.handle.conv]: #coroutine.handle.conv
|
| 4199 |
[coroutine.handle.export.import]: #coroutine.handle.export.import
|
| 4200 |
+
[coroutine.handle.general]: #coroutine.handle.general
|
| 4201 |
[coroutine.handle.hash]: #coroutine.handle.hash
|
| 4202 |
[coroutine.handle.noop]: #coroutine.handle.noop
|
| 4203 |
[coroutine.handle.noop.address]: #coroutine.handle.noop.address
|
| 4204 |
+
[coroutine.handle.noop.conv]: #coroutine.handle.noop.conv
|
| 4205 |
[coroutine.handle.noop.observers]: #coroutine.handle.noop.observers
|
| 4206 |
[coroutine.handle.noop.promise]: #coroutine.handle.noop.promise
|
| 4207 |
[coroutine.handle.noop.resumption]: #coroutine.handle.noop.resumption
|
| 4208 |
[coroutine.handle.observers]: #coroutine.handle.observers
|
| 4209 |
[coroutine.handle.promise]: #coroutine.handle.promise
|
|
|
|
| 4211 |
[coroutine.noop]: #coroutine.noop
|
| 4212 |
[coroutine.noop.coroutine]: #coroutine.noop.coroutine
|
| 4213 |
[coroutine.promise.noop]: #coroutine.promise.noop
|
| 4214 |
[coroutine.syn]: #coroutine.syn
|
| 4215 |
[coroutine.traits]: #coroutine.traits
|
| 4216 |
+
[coroutine.traits.general]: #coroutine.traits.general
|
| 4217 |
[coroutine.traits.primary]: #coroutine.traits.primary
|
| 4218 |
[coroutine.trivial.awaitables]: #coroutine.trivial.awaitables
|
| 4219 |
[cpp.line]: cpp.md#cpp.line
|
| 4220 |
[cpp17.nullablepointer]: #cpp17.nullablepointer
|
| 4221 |
[csetjmp.syn]: #csetjmp.syn
|
| 4222 |
[csignal.syn]: #csignal.syn
|
| 4223 |
[cstdarg.syn]: #cstdarg.syn
|
| 4224 |
[cstddef.syn]: #cstddef.syn
|
|
|
|
| 4225 |
[cstdint.syn]: #cstdint.syn
|
| 4226 |
[cstdlib.syn]: #cstdlib.syn
|
| 4227 |
[customization.point.object]: library.md#customization.point.object
|
| 4228 |
[dcl.fct.def.coroutine]: dcl.md#dcl.fct.def.coroutine
|
| 4229 |
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 4230 |
[dcl.init.list]: dcl.md#dcl.init.list
|
| 4231 |
+
[defns.expression.equivalent]: intro.md#defns.expression.equivalent
|
|
|
|
| 4232 |
[except.handle]: except.md#except.handle
|
| 4233 |
[except.nested]: #except.nested
|
| 4234 |
[except.spec]: except.md#except.spec
|
| 4235 |
[except.terminate]: except.md#except.terminate
|
| 4236 |
[except.uncaught]: except.md#except.uncaught
|
|
|
|
| 4248 |
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 4249 |
[expr.rel]: expr.md#expr.rel
|
| 4250 |
[expr.sizeof]: expr.md#expr.sizeof
|
| 4251 |
[expr.spaceship]: expr.md#expr.spaceship
|
| 4252 |
[expr.typeid]: expr.md#expr.typeid
|
|
|
|
| 4253 |
[get.new.handler]: #get.new.handler
|
| 4254 |
[get.terminate]: #get.terminate
|
| 4255 |
[hardware.interference]: #hardware.interference
|
| 4256 |
[initializer.list.syn]: #initializer.list.syn
|
| 4257 |
[intro.multithread]: basic.md#intro.multithread
|
| 4258 |
+
[iso646.h.syn]: #iso646.h.syn
|
| 4259 |
+
[lex.key]: lex.md#lex.key
|
| 4260 |
[library.c]: library.md#library.c
|
| 4261 |
[limits.syn]: #limits.syn
|
| 4262 |
[locale.codecvt]: localization.md#locale.codecvt
|
| 4263 |
[multibyte.strings]: library.md#multibyte.strings
|
| 4264 |
+
[namespace.udecl]: dcl.md#namespace.udecl
|
| 4265 |
[new.badlength]: #new.badlength
|
| 4266 |
[new.delete]: #new.delete
|
| 4267 |
[new.delete.array]: #new.delete.array
|
| 4268 |
[new.delete.dataraces]: #new.delete.dataraces
|
| 4269 |
+
[new.delete.general]: #new.delete.general
|
| 4270 |
[new.delete.placement]: #new.delete.placement
|
| 4271 |
[new.delete.single]: #new.delete.single
|
| 4272 |
[new.handler]: #new.handler
|
| 4273 |
[new.syn]: #new.syn
|
| 4274 |
[numeric.limits]: #numeric.limits
|
| 4275 |
+
[numeric.limits.general]: #numeric.limits.general
|
| 4276 |
[numeric.limits.members]: #numeric.limits.members
|
| 4277 |
[numeric.special]: #numeric.special
|
| 4278 |
[propagation]: #propagation
|
| 4279 |
[ptr.launder]: #ptr.launder
|
| 4280 |
[res.on.data.races]: library.md#res.on.data.races
|
| 4281 |
[round.style]: #round.style
|
| 4282 |
[set.new.handler]: #set.new.handler
|
| 4283 |
[set.terminate]: #set.terminate
|
| 4284 |
+
[sf.cmath]: numerics.md#sf.cmath
|
| 4285 |
[source.location.syn]: #source.location.syn
|
| 4286 |
+
[stdalign.h.syn]: #stdalign.h.syn
|
| 4287 |
+
[stdbool.h.syn]: #stdbool.h.syn
|
| 4288 |
+
[stdfloat.syn]: #stdfloat.syn
|
| 4289 |
[stmt.dcl]: stmt.md#stmt.dcl
|
| 4290 |
[string.classes]: strings.md#string.classes
|
| 4291 |
[support]: #support
|
| 4292 |
+
[support.arith.types]: #support.arith.types
|
| 4293 |
+
[support.c.headers]: #support.c.headers
|
| 4294 |
+
[support.c.headers.general]: #support.c.headers.general
|
| 4295 |
+
[support.c.headers.other]: #support.c.headers.other
|
| 4296 |
[support.coroutine]: #support.coroutine
|
| 4297 |
+
[support.coroutine.general]: #support.coroutine.general
|
| 4298 |
[support.dynamic]: #support.dynamic
|
| 4299 |
+
[support.dynamic.general]: #support.dynamic.general
|
| 4300 |
[support.exception]: #support.exception
|
| 4301 |
+
[support.exception.general]: #support.exception.general
|
| 4302 |
[support.general]: #support.general
|
| 4303 |
[support.initlist]: #support.initlist
|
| 4304 |
[support.initlist.access]: #support.initlist.access
|
| 4305 |
[support.initlist.cons]: #support.initlist.cons
|
| 4306 |
+
[support.initlist.general]: #support.initlist.general
|
| 4307 |
[support.initlist.range]: #support.initlist.range
|
| 4308 |
[support.limits]: #support.limits
|
| 4309 |
[support.limits.general]: #support.limits.general
|
| 4310 |
[support.rtti]: #support.rtti
|
| 4311 |
+
[support.rtti.general]: #support.rtti.general
|
| 4312 |
[support.runtime]: #support.runtime
|
| 4313 |
+
[support.runtime.general]: #support.runtime.general
|
| 4314 |
[support.signal]: #support.signal
|
| 4315 |
[support.srcloc]: #support.srcloc
|
| 4316 |
[support.srcloc.class]: #support.srcloc.class
|
| 4317 |
+
[support.srcloc.class.general]: #support.srcloc.class.general
|
| 4318 |
[support.srcloc.cons]: #support.srcloc.cons
|
| 4319 |
[support.srcloc.current]: #support.srcloc.current
|
| 4320 |
[support.srcloc.obs]: #support.srcloc.obs
|
| 4321 |
[support.start.term]: #support.start.term
|
| 4322 |
[support.summary]: #support.summary
|
|
|
|
| 4327 |
[swappable.requirements]: library.md#swappable.requirements
|
| 4328 |
[temp.deduct]: temp.md#temp.deduct
|
| 4329 |
[temp.dep.constexpr]: temp.md#temp.dep.constexpr
|
| 4330 |
[temp.dep.expr]: temp.md#temp.dep.expr
|
| 4331 |
[temp.variadic]: temp.md#temp.variadic
|
| 4332 |
+
[term.odr.use]: basic.md#term.odr.use
|
| 4333 |
[terminate]: #terminate
|
| 4334 |
[terminate.handler]: #terminate.handler
|
| 4335 |
+
[tgmath.h.syn]: #tgmath.h.syn
|
| 4336 |
[type.info]: #type.info
|
| 4337 |
[typeinfo.syn]: #typeinfo.syn
|
| 4338 |
[uncaught.exceptions]: #uncaught.exceptions
|
| 4339 |
[unord.hash]: utilities.md#unord.hash
|
| 4340 |
[utility.arg.requirements]: library.md#utility.arg.requirements
|
|
|
|
| 4357 |
|
| 4358 |
[^7]: Equivalent to `FLT_DIG`, `DBL_DIG`, `LDBL_DIG`.
|
| 4359 |
|
| 4360 |
[^8]: Equivalent to `FLT_RADIX`.
|
| 4361 |
|
| 4362 |
+
[^9]: Distinguishes types with bases other than 2 (e.g., BCD).
|
| 4363 |
|
| 4364 |
[^10]: Equivalent to `FLT_EPSILON`, `DBL_EPSILON`, `LDBL_EPSILON`.
|
| 4365 |
|
| 4366 |
[^11]: Rounding error is described in LIA-1 Section 5.2.4 and Annex C
|
| 4367 |
Rationale Section C.5.2.4 — Rounding and rounding constants.
|
|
|
|
| 4380 |
|
| 4381 |
[^17]: Required by LIA-1.
|
| 4382 |
|
| 4383 |
[^18]: Required by LIA-1.
|
| 4384 |
|
| 4385 |
+
[^19]: Required by LIA-1.
|
| 4386 |
|
| 4387 |
[^20]: Required by LIA-1.
|
| 4388 |
|
| 4389 |
[^21]: Required by LIA-1.
|
| 4390 |
|
| 4391 |
+
[^22]: ISO/IEC/IEEE 60559:2020 is the same as IEEE 754-2019.
|
| 4392 |
|
| 4393 |
[^23]: Required by LIA-1.
|
| 4394 |
|
| 4395 |
+
[^24]: Required by LIA-1.
|
| 4396 |
|
| 4397 |
[^25]: Required by LIA-1.
|
| 4398 |
|
| 4399 |
+
[^26]: Refer to ISO/IEC/IEEE 60559. Required by LIA-1.
|
| 4400 |
|
| 4401 |
+
[^27]: Equivalent to `FLT_ROUNDS`. Required by LIA-1.
|
| 4402 |
|
| 4403 |
+
[^28]: A function is called for every time it is registered.
|
| 4404 |
|
| 4405 |
+
[^29]: Objects with automatic storage duration are all destroyed in a
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4406 |
program whose `main` function [[basic.start.main]] contains no
|
| 4407 |
objects with automatic storage duration and executes the call to
|
| 4408 |
`exit()`. Control can be transferred directly to such a `main`
|
| 4409 |
function by throwing an exception that is caught in `main`.
|
| 4410 |
|
| 4411 |
+
[^30]: The macros `EXIT_FAILURE` and `EXIT_SUCCESS` are defined in
|
| 4412 |
`<cstdlib>`.
|
| 4413 |
|
| 4414 |
+
[^31]: It is not the direct responsibility of `operator new[]` or
|
| 4415 |
`operator delete[]` to note the repetition count or element size of
|
| 4416 |
the array. Those operations are performed elsewhere in the array
|
| 4417 |
+
`new` and `delete` expressions. The array `new` expression, can,
|
| 4418 |
however, increase the `size` argument to `operator new[]` to obtain
|
| 4419 |
space to store supplemental information.
|
| 4420 |
|
| 4421 |
+
[^32]: That is, `a < b`, `a == b`, and `a > b` might all be `false`.
|
| 4422 |
|
| 4423 |
+
[^33]: Note that `va_start` is required to work as specified even if
|
| 4424 |
unary `operator&` is overloaded for the type of `parmN`.
|
| 4425 |
|
| 4426 |
+
[^34]: Such initialization can occur because it is the first odr-use
|
| 4427 |
+
[[term.odr.use]] of that variable.
|