This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
[support.arith.types]
# 17 Language support library [[support]](./#support)
## 17.4 Arithmetic types [support.arith.types]
### [17.4.1](#cstdint.syn) Header <cstdint> synopsis [[cstdint.syn]](cstdint.syn)
[1](#cstdint.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1880)
The header [<cstdint>](#header:%3ccstdint%3e "17.4.1Header <cstdint> synopsis[cstdint.syn]") supplies integer types having specified widths, and
macros that specify limits of integer types[.](#cstdint.syn-1.sentence-1)
[🔗](#header:%3ccstdint%3e)
// all freestanding#define __STDC_VERSION_STDINT_H__ 202311Lnamespace std {using int8_t = *signed integer type*; // optionalusing int16_t = *signed integer type*; // optionalusing int32_t = *signed integer type*; // optionalusing int64_t = *signed integer type*; // optionalusing int*N*_t = *see below*; // optionalusing int_fast8_t = *signed integer type*; using int_fast16_t = *signed integer type*; using int_fast32_t = *signed integer type*; using int_fast64_t = *signed integer type*; using int_fast*N*_t = *see below*; // optionalusing int_least8_t = *signed integer type*; using int_least16_t = *signed integer type*; using int_least32_t = *signed integer type*; using int_least64_t = *signed integer type*; using int_least*N*_t = *see below*; // optionalusing intmax_t = *signed integer type*; using intptr_t = *signed integer type*; // optionalusing uint8_t = *unsigned integer type*; // optionalusing uint16_t = *unsigned integer type*; // optionalusing uint32_t = *unsigned integer type*; // optionalusing uint64_t = *unsigned integer type*; // optionalusing uint*N*_t = *see below*; // optionalusing uint_fast8_t = *unsigned integer type*; using uint_fast16_t = *unsigned integer type*; using uint_fast32_t = *unsigned integer type*; using uint_fast64_t = *unsigned integer type*; using uint_fast*N*_t = *see below*; // optionalusing uint_least8_t = *unsigned integer type*; using uint_least16_t = *unsigned integer type*; using uint_least32_t = *unsigned integer type*; using uint_least64_t = *unsigned integer type*; using uint_least*N*_t = *see below*; // optionalusing uintmax_t = *unsigned integer type*; using uintptr_t = *unsigned integer type*; // optional}#define INT*N*_MIN *see below*#define INT*N*_MAX *see below*#define UINT*N*_MAX *see below*#define INT*N*_WIDTH *see below*#define UINT*N*_WIDTH *see below*#define INT_FAST*N*_MIN *see below*#define INT_FAST*N*_MAX *see below*#define UINT_FAST*N*_MAX *see below*#define INT_FAST*N*_WIDTH *see below*#define UINT_FAST*N*_WIDTH *see below*#define INT_LEAST*N*_MIN *see below*#define INT_LEAST*N*_MAX *see below*#define UINT_LEAST*N*_MAX *see below*#define INT_LEAST*N*_WIDTH *see below*#define UINT_LEAST*N*_WIDTH *see below*#define INTMAX_MIN *see below*#define INTMAX_MAX *see below*#define UINTMAX_MAX *see below*#define INTMAX_WIDTH *see below*#define UINTMAX_WIDTH *see below*#define INTPTR_MIN *see below* // optional#define INTPTR_MAX *see below* // optional#define UINTPTR_MAX *see below* // optional#define INTPTR_WIDTH *see below* // optional#define UINTPTR_WIDTH *see below* // optional#define PTRDIFF_MIN *see below*#define PTRDIFF_MAX *see below*#define PTRDIFF_WIDTH *see below*#define SIZE_MAX *see below*#define SIZE_WIDTH *see below*#define SIG_ATOMIC_MIN *see below*#define SIG_ATOMIC_MAX *see below*#define SIG_ATOMIC_WIDTH *see below*#define WCHAR_MIN *see below*#define WCHAR_MAX *see below*#define WCHAR_WIDTH *see below*#define WINT_MIN *see below*#define WINT_MAX *see below*#define WINT_WIDTH *see below*#define INT*N*_C(value) *see below*#define UINT*N*_C(value) *see below*#define INTMAX_C(value) *see below*#define UINTMAX_C(value) *see below*
[2](#cstdint.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2044)
The header defines all types and macros the same as
the C standard library header [<stdint.h>](support.c.headers.general#header:%3cstdint.h%3e "17.15.1General[support.c.headers.general]")[.](#cstdint.syn-2.sentence-1)
The types denoted by intmax_t and uintmax_t are not required to be able to represent all values of extended integer types
wider than long long and unsigned long long, respectively[.](#cstdint.syn-2.sentence-2)
See also: ISO/IEC 9899:2024, 7.22
[3](#cstdint.syn-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2053)
All types that use the placeholder *N* are optional when *N* is not 8, 16, 32, or 64[.](#cstdint.syn-3.sentence-1)
The exact-width typesint*N*_t and uint*N*_t for *N* = 8, 16, 32, and 64 are also optional;
however, if an implementation defines integer types
with the corresponding width and no padding bits,
it defines the corresponding [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]")*s*[.](#cstdint.syn-3.sentence-2)
Each of the macros listed in this subclause
is defined if and only if
the implementation defines the corresponding [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]")[.](#cstdint.syn-3.sentence-3)
[*Note [1](#cstdint.syn-note-1)*:
The macros INT*N*_C and UINT*N*_C correspond to the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]")*s*int_least*N*_t and uint_least*N*_t,
respectively[.](#cstdint.syn-3.sentence-4)
— *end note*]
### [17.4.2](#stdfloat.syn) Header <stdfloat> synopsis [[stdfloat.syn]](stdfloat.syn)
[1](#stdfloat.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2076)
The header [<stdfloat>](#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]") defines type aliases for
the optional extended floating-point types that are specified in[[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")[.](#stdfloat.syn-1.sentence-1)
[🔗](#header:%3cstdfloat%3e)
namespace std {#if defined(__STDCPP_FLOAT16_T__)using float16_t = *implementation-defined*; // see [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")#endif#if defined(__STDCPP_FLOAT32_T__)using float32_t = *implementation-defined*; // see [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")#endif#if defined(__STDCPP_FLOAT64_T__)using float64_t = *implementation-defined*; // see [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")#endif#if defined(__STDCPP_FLOAT128_T__)using float128_t = *implementation-defined*; // see [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")#endif#if defined(__STDCPP_BFLOAT16_T__)using bfloat16_t = *implementation-defined*; // see [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")#endif}

View File

@@ -0,0 +1,184 @@
[support.c.headers]
# 17 Language support library [[support]](./#support)
## 17.15 C headers [support.c.headers]
### [17.15.1](#general) General [[support.c.headers.general]](support.c.headers.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6575)
For compatibility with theC standard library, the C++ standard library provides
the [*C headers*](#def:headers,C_library "17.15.1General[support.c.headers.general]") shown in Table [47](#tab:c.headers "Table 47: C headers")[.](#general-1.sentence-1)
The intended use of these headers is for interoperability only[.](#general-1.sentence-2)
It is possible that C++ source files need to include
one of these headers in order to be valid C.
Source files that are not intended to also be valid C
should not use any of the C headers[.](#general-1.sentence-3)
[*Note [1](#general-note-1)*:
The C headers either have no effect,
such as [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") and [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]"), or
otherwise the corresponding header of the form <c*name*> provides the same facilities and
assuredly defines them in namespace std[.](#general-1.sentence-4)
— *end note*]
[*Example [1](#general-example-1)*:
The following source file is both valid C++ and valid C.
Viewed as C++, it declares a function with C language linkage;
viewed as C it simply declares a function (and provides a prototype)[.](#general-1.sentence-5)
#include <uchar.h> // for char8_t in C, not necessary in C++#include <stddef.h> // for size_t#ifdef __cplusplus // see [[cpp.predefined]](cpp.predefined "15.12Predefined macro names")extern "C" // see [[dcl.link]](dcl.link "9.12Linkage specifications")#endifvoid f(char8_t s[], size_t n); — *end example*]
Table [47](#tab:c.headers) — C headers [[tab:c.headers]](./tab:c.headers)
| [🔗](#tab:c.headers-row-1)<br><assert.h> | <inttypes.h> | <signal.h> | [<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]") | [<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]") |
| --- | --- | --- | --- | --- |
| [🔗](#tab:c.headers-row-2)<br>[<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]") | [<iso646.h>](#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]") | [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]") | <stddef.h> | <time.h> |
| [🔗](#tab:c.headers-row-3)<br><ctype.h> | <limits.h> | <stdarg.h> | <stdint.h> | <uchar.h> |
| [🔗](#tab:c.headers-row-4)<br><errno.h> | <locale.h> | [<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]") | <stdio.h> | <wchar.h> |
| [🔗](#tab:c.headers-row-5)<br><fenv.h> | <math.h> | [<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]") | <stdlib.h> | <wctype.h> |
| [🔗](#tab:c.headers-row-6)<br><float.h> | <setjmp.h> | [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") | <string.h> | |
### [17.15.2](#complex.h.syn) Header <complex.h> synopsis [[complex.h.syn]](complex.h.syn)
[🔗](#header:%3ccomplex.h%3e)
#include <complex>
[1](#complex.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6652)
The header [<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]") behaves as if it simply includes the header[<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]")[.](#complex.h.syn-1.sentence-1)
[2](#complex.h.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6657)
[*Note [1](#complex.h.syn-note-1)*:
Names introduced by [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]") in namespace std are not placed into the global namespace scope by [<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]")[.](#complex.h.syn-2.sentence-1)
— *end note*]
### [17.15.3](#iso646.h.syn) Header <iso646.h> synopsis [[iso646.h.syn]](iso646.h.syn)
[1](#iso646.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6666)
The C++ header [<iso646.h>](#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]") is empty[.](#iso646.h.syn-1.sentence-1)
[*Note [1](#iso646.h.syn-note-1)*:
and,and_eq,bitand,bitor,compl,not_eq,not,or,or_eq,xor, andxor_eq are keywords in C++ ([[lex.key]](lex.key "5.12Keywords"))[.](#iso646.h.syn-1.sentence-2)
— *end note*]
### [17.15.4](#stdalign.h.syn) Header <stdalign.h> synopsis [[stdalign.h.syn]](stdalign.h.syn)
[1](#stdalign.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6686)
The contents of the C++ header [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]") are the same as the C
standard library header [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]")[.](#stdalign.h.syn-1.sentence-1)
See also: ISO/IEC 9899:2024, 7.15
### [17.15.5](#stdbool.h.syn) Header <stdbool.h> synopsis [[stdbool.h.syn]](stdbool.h.syn)
[1](#stdbool.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6695)
The contents of the C++ header [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") are the same as the C
standard library header [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]")[.](#stdbool.h.syn-1.sentence-1)
See also: ISO/IEC 9899:2024, 7.19
### [17.15.6](#tgmath.h.syn) Header <tgmath.h> synopsis [[tgmath.h.syn]](tgmath.h.syn)
[🔗](#header:%3ctgmath.h%3e)
#include <cmath>#include <complex>
[1](#tgmath.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6709)
The header [<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]") behaves as if it simply includes the headers[<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") and[<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]")[.](#tgmath.h.syn-1.sentence-1)
[2](#tgmath.h.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6715)
[*Note [1](#tgmath.h.syn-note-1)*:
The overloads provided in C by type-generic macros
are already provided in [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]") and [<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") by “sufficient” additional overloads[.](#tgmath.h.syn-2.sentence-1)
— *end note*]
[3](#tgmath.h.syn-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6722)
[*Note [2](#tgmath.h.syn-note-2)*:
Names introduced by [<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") or [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]") in namespace std are not placed into the global namespace scope by [<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]")[.](#tgmath.h.syn-3.sentence-1)
— *end note*]
### [17.15.7](#other) Other C headers [[support.c.headers.other]](support.c.headers.other)
[1](#other-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6731)
Every C header
other than[<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]"),[<iso646.h>](#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]"),[<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]"),
[<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]"),[<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]"),[<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]"),[<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]"), and
[<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]"),
each of
which has a name of the form<*name*.h>,
behaves as if each name placed in the standard library namespace by
the corresponding<c*name*> header is placed within
the global namespace scope,
except for the functions described in [[sf.cmath]](sf.cmath "29.7.6Mathematical special functions"),
the std::lerp function overloads ([[c.math.lerp]](c.math.lerp "29.7.4Linear interpolation")),
the declaration of std::byte ([[cstddef.syn]](cstddef.syn "17.2.1Header <cstddef> synopsis")), and
the functions and function templates described in [[support.types.byteops]](support.types.byteops "17.2.5byte type operations")[.](#other-1.sentence-1)
It is unspecified whether these names are first declared or defined within
namespace scope ([[basic.scope.namespace]](basic.scope.namespace "6.4.6Namespace scope")) of the namespacestd and are then injected into the global namespace scope by
explicit [*using-declaration*](namespace.udecl#nt:using-declaration "9.10The using declaration[namespace.udecl]")*s* ([[namespace.udecl]](namespace.udecl "9.10The using declaration"))[.](#other-1.sentence-2)
[2](#other-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6760)
[*Example [1](#other-example-1)*:
The header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") assuredly
provides its declarations and definitions within the namespacestd[.](#other-2.sentence-1)
It may also provide these names within the
global namespace[.](#other-2.sentence-2)
The header [<stdlib.h>](#header:%3cstdlib.h%3e "17.15.1General[support.c.headers.general]") assuredly provides the same declarations and definitions within
the global namespace,
much as in ISO/IEC 9899[.](#other-2.sentence-3)
It may also provide these names within
the namespace std[.](#other-2.sentence-4)
— *end example*]

View File

@@ -0,0 +1,48 @@
[support.c.headers.general]
# 17 Language support library [[support]](./#support)
## 17.15 C headers [[support.c.headers]](support.c.headers#general)
### 17.15.1 General [support.c.headers.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6575)
For compatibility with theC standard library, the C++ standard library provides
the [*C headers*](#def:headers,C_library "17.15.1General[support.c.headers.general]") shown in Table [47](#tab:c.headers "Table 47: C headers")[.](#1.sentence-1)
The intended use of these headers is for interoperability only[.](#1.sentence-2)
It is possible that C++ source files need to include
one of these headers in order to be valid C.
Source files that are not intended to also be valid C
should not use any of the C headers[.](#1.sentence-3)
[*Note [1](#note-1)*:
The C headers either have no effect,
such as [<stdbool.h>](stdbool.h.syn#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") and [<stdalign.h>](stdalign.h.syn#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]"), or
otherwise the corresponding header of the form <c*name*> provides the same facilities and
assuredly defines them in namespace std[.](#1.sentence-4)
— *end note*]
[*Example [1](#example-1)*:
The following source file is both valid C++ and valid C.
Viewed as C++, it declares a function with C language linkage;
viewed as C it simply declares a function (and provides a prototype)[.](#1.sentence-5)
#include <uchar.h> // for char8_t in C, not necessary in C++#include <stddef.h> // for size_t#ifdef __cplusplus // see [[cpp.predefined]](cpp.predefined "15.12Predefined macro names")extern "C" // see [[dcl.link]](dcl.link "9.12Linkage specifications")#endifvoid f(char8_t s[], size_t n); — *end example*]
Table [47](#tab:c.headers) — C headers [[tab:c.headers]](./tab:c.headers)
| [🔗](#tab:c.headers-row-1)<br><assert.h> | <inttypes.h> | <signal.h> | [<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]") | [<tgmath.h>](tgmath.h.syn#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]") |
| --- | --- | --- | --- | --- |
| [🔗](#tab:c.headers-row-2)<br>[<complex.h>](complex.h.syn#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]") | [<iso646.h>](iso646.h.syn#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]") | [<stdalign.h>](stdalign.h.syn#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]") | <stddef.h> | <time.h> |
| [🔗](#tab:c.headers-row-3)<br><ctype.h> | <limits.h> | <stdarg.h> | <stdint.h> | <uchar.h> |
| [🔗](#tab:c.headers-row-4)<br><errno.h> | <locale.h> | [<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]") | <stdio.h> | <wchar.h> |
| [🔗](#tab:c.headers-row-5)<br><fenv.h> | <math.h> | [<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]") | <stdlib.h> | <wctype.h> |
| [🔗](#tab:c.headers-row-6)<br><float.h> | <setjmp.h> | [<stdbool.h>](stdbool.h.syn#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") | <string.h> | |

View File

@@ -0,0 +1,50 @@
[support.c.headers.other]
# 17 Language support library [[support]](./#support)
## 17.15 C headers [[support.c.headers]](support.c.headers#other)
### 17.15.7 Other C headers [support.c.headers.other]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6731)
Every C header
other than[<complex.h>](complex.h.syn#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]"),[<iso646.h>](iso646.h.syn#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]"),[<stdalign.h>](stdalign.h.syn#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]"),
[<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]"),[<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]"),[<stdbool.h>](stdbool.h.syn#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]"),[<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]"), and
[<tgmath.h>](tgmath.h.syn#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]"),
each of
which has a name of the form<*name*.h>,
behaves as if each name placed in the standard library namespace by
the corresponding<c*name*> header is placed within
the global namespace scope,
except for the functions described in [[sf.cmath]](sf.cmath "29.7.6Mathematical special functions"),
the std::lerp function overloads ([[c.math.lerp]](c.math.lerp "29.7.4Linear interpolation")),
the declaration of std::byte ([[cstddef.syn]](cstddef.syn "17.2.1Header <cstddef> synopsis")), and
the functions and function templates described in [[support.types.byteops]](support.types.byteops "17.2.5byte type operations")[.](#1.sentence-1)
It is unspecified whether these names are first declared or defined within
namespace scope ([[basic.scope.namespace]](basic.scope.namespace "6.4.6Namespace scope")) of the namespacestd and are then injected into the global namespace scope by
explicit [*using-declaration*](namespace.udecl#nt:using-declaration "9.10The using declaration[namespace.udecl]")*s* ([[namespace.udecl]](namespace.udecl "9.10The using declaration"))[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6760)
[*Example [1](#example-1)*:
The header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") assuredly
provides its declarations and definitions within the namespacestd[.](#2.sentence-1)
It may also provide these names within the
global namespace[.](#2.sentence-2)
The header [<stdlib.h>](support.c.headers.general#header:%3cstdlib.h%3e "17.15.1General[support.c.headers.general]") assuredly provides the same declarations and definitions within
the global namespace,
much as in ISO/IEC 9899[.](#2.sentence-3)
It may also provide these names within
the namespace std[.](#2.sentence-4)
— *end example*]

View File

@@ -0,0 +1,253 @@
[support.contract]
# 17 Language support library [[support]](./#support)
## 17.10 Contract-violation handling [support.contract]
### [17.10.1](#contracts.syn) Header <contracts> synopsis [[contracts.syn]](contracts.syn)
[1](#contracts.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4387)
The header [<contracts>](#header:%3ccontracts%3e "17.10.1Header <contracts> synopsis[contracts.syn]") defines types
for reporting information about contract violations ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation"))[.](#contracts.syn-1.sentence-1)
[🔗](#header:%3ccontracts%3e)
// all freestandingnamespace std::contracts {enum class assertion_kind : *unspecified* { pre = 1,
post = 2,
assert = 3}; enum class evaluation_semantic : *unspecified* { ignore = 1,
observe = 2,
enforce = 3,
quick_enforce = 4}; enum class detection_mode : *unspecified* { predicate_false = 1,
evaluation_exception = 2}; class contract_violation {// no user-accessible constructorpublic: contract_violation(const contract_violation&) = delete;
contract_violation& operator=(const contract_violation&) = delete; *see below* ~contract_violation(); const char* comment() const noexcept;
contracts::detection_mode detection_mode() const noexcept;
exception_ptr evaluation_exception() const noexcept; bool is_terminating() const noexcept;
assertion_kind kind() const noexcept;
source_location location() const noexcept;
evaluation_semantic semantic() const noexcept; }; void invoke_default_contract_violation_handler(const contract_violation&);}
### [17.10.2](#enum) Enumerations [[support.contract.enum]](support.contract.enum)
[1](#enum-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4438)
*Recommended practice*: For all enumerations in [[support.contract.enum]](#enum "17.10.2Enumerations"),
if implementation-defined enumerators are provided,
they should have a minimum value of 1000[.](#enum-1.sentence-1)
[2](#enum-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4444)
The enumerators of assertion_kind correspond to
the syntactic forms of a contract assertion ([[basic.contract.general]](basic.contract.general "6.11.1General")),
with meanings listed in Table [44](#tab:support.contract.enum.kind "Table 44: Enum assertion_­kind")[.](#enum-2.sentence-1)
Table [44](#tab:support.contract.enum.kind) — Enum assertion_kind [[tab:support.contract.enum.kind]](./tab:support.contract.enum.kind)
| [🔗](#tab:support.contract.enum.kind-row-1)<br>**Name** | **Meaning** |
| --- | --- |
| [🔗](#tab:support.contract.enum.kind-row-2)<br>pre | A precondition assertion |
| [🔗](#tab:support.contract.enum.kind-row-3)<br>post | A postcondition assertion |
| [🔗](#tab:support.contract.enum.kind-row-4)<br>assert | An [*assertion-statement*](stmt.contract.assert#nt:assertion-statement "8.9Assertion statement[stmt.contract.assert]") |
| [🔗](#tab:support.contract.enum.kind-row-5) |
[3](#enum-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4459)
The enumerators of evaluation_semantic correspond to
the evaluation semantics with which
a contract assertion may be evaluated ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation")),
with meanings listed in Table [45](#tab:support.contract.enum.semantic "Table 45: Enum evaluation_­semantic")[.](#enum-3.sentence-1)
Table [45](#tab:support.contract.enum.semantic) — Enum evaluation_semantic [[tab:support.contract.enum.semantic]](./tab:support.contract.enum.semantic)
| [🔗](#tab:support.contract.enum.semantic-row-1)<br>**Name** | **Meaning** |
| --- | --- |
| [🔗](#tab:support.contract.enum.semantic-row-2)<br>ignore | Ignore evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-3)<br>observe | Observe evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-4)<br>enforce | Enforce evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-5)<br>quick_enforce | Quick-enforce evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-6) |
[4](#enum-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4476)
The enumerators of detection_mode correspond to the manners in which a
contract violation can be identified ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation")), with
meanings listed in Table [46](#tab:support.contract.enum.detection "Table 46: Enum detection_­mode")[.](#enum-4.sentence-1)
Table [46](#tab:support.contract.enum.detection) — Enum detection_mode [[tab:support.contract.enum.detection]](./tab:support.contract.enum.detection)
| [🔗](#tab:support.contract.enum.detection-row-1)<br>**Name** | **Meaning** |
| --- | --- |
| [🔗](#tab:support.contract.enum.detection-row-2)<br>predicate_false | The predicate of the contract assertion evaluated to false or would have evaluated to false[.](#tab:support.contract.enum.detection-row-2-column-2-sentence-1) |
| [🔗](#tab:support.contract.enum.detection-row-3)<br>evaluation_exception | An uncaught exception occurred during evaluation of the contract assertion[.](#tab:support.contract.enum.detection-row-3-column-2-sentence-1) |
| [🔗](#tab:support.contract.enum.detection-row-4) |
### [17.10.3](#violation) Class contract_violation [[support.contract.violation]](support.contract.violation)
[1](#violation-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4491)
The class contract_violation defines the type of objects used to represent
a contract violation that has been detected
during the evaluation of a contract assertion
with a particular evaluation semantic ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation"))[.](#violation-1.sentence-1)
Objects of this type can
be created only by the implementation[.](#violation-1.sentence-2)
It isimplementation-defined
whether the destructor is virtual[.](#violation-1.sentence-3)
[🔗](#violation-itemdecl:1)
`const char* comment() const noexcept;
`
[2](#violation-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4509)
*Returns*: Animplementation-definedntmbs in
the ordinary literal encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))[.](#violation-2.sentence-1)
[3](#violation-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4516)
*Recommended practice*: The string returned
should contain a textual representation
of the predicate of the violated contract assertion
or an empty string if
storing a textual representation is undesired[.](#violation-3.sentence-1)
[*Note [1](#violation-note-1)*:
The string can represent a
truncated, reformatted, or summarized rendering of the
predicate, before or after preprocessing[.](#violation-3.sentence-2)
— *end note*]
[🔗](#violation-itemdecl:2)
`contracts::detection_mode detection_mode() const noexcept;
`
[4](#violation-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4536)
*Returns*: The enumerator value
corresponding to
the manner in which the contract violation was identified[.](#violation-4.sentence-1)
[🔗](#violation-itemdecl:3)
`exception_ptr evaluation_exception() const noexcept;
`
[5](#violation-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4550)
*Returns*: If the contract violation occurred
because the evaluation of the predicate exited via an exception,
an exception_ptr object that refers to
that exception or a copy of that exception;
otherwise, a null exception_ptr object[.](#violation-5.sentence-1)
[🔗](#violation-itemdecl:4)
`bool is_terminating() const noexcept;
`
[6](#violation-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4566)
*Returns*: true if the evaluation semantic is
a terminating semantic ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation"));
otherwise, false[.](#violation-6.sentence-1)
[🔗](#violation-itemdecl:5)
`assertion_kind kind() const noexcept;
`
[7](#violation-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4579)
*Returns*: The enumerator value
corresponding to
the syntactic form of the violated contract assertion[.](#violation-7.sentence-1)
[🔗](#violation-itemdecl:6)
`source_location location() const noexcept;
`
[8](#violation-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4592)
*Returns*: A source_location object
withimplementation-defined
value[.](#violation-8.sentence-1)
[9](#violation-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4599)
*Recommended practice*: The value returned should be
a default constructed source_location object
or a value identifying the violated contract assertion:
- [(9.1)](#violation-9.1)
When possible,
if the violated contract assertion was a precondition,
the source location of the function invocation should be returned[.](#violation-9.1.sentence-1)
- [(9.2)](#violation-9.2)
Otherwise,
the source location of the contract assertion should be returned[.](#violation-9.2.sentence-1)
[🔗](#violation-itemdecl:7)
`evaluation_semantic semantic() const noexcept;
`
[10](#violation-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4622)
*Returns*: The enumerator value
corresponding to
the evaluation semantic with which
the violated contract assertion was evaluated[.](#violation-10.sentence-1)
### [17.10.4](#invoke) Invoke default handler [[support.contract.invoke]](support.contract.invoke)
[🔗](#invoke-itemdecl:1)
`void invoke_default_contract_violation_handler(const contract_violation& v);
`
[1](#invoke-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4638)
*Effects*: Invokes the default contract-violation handler ([[basic.contract.handler]](basic.contract.handler "6.11.3Contract-violation handler"))
with the argument v[.](#invoke-1.sentence-1)

View File

@@ -0,0 +1,67 @@
[support.contract.enum]
# 17 Language support library [[support]](./#support)
## 17.10 Contract-violation handling [[support.contract]](support.contract#enum)
### 17.10.2 Enumerations [support.contract.enum]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4438)
*Recommended practice*: For all enumerations in [support.contract.enum],
if implementation-defined enumerators are provided,
they should have a minimum value of 1000[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4444)
The enumerators of assertion_kind correspond to
the syntactic forms of a contract assertion ([[basic.contract.general]](basic.contract.general "6.11.1General")),
with meanings listed in Table [44](#tab:support.contract.enum.kind "Table 44: Enum assertion_­kind")[.](#2.sentence-1)
Table [44](#tab:support.contract.enum.kind) — Enum assertion_kind [[tab:support.contract.enum.kind]](./tab:support.contract.enum.kind)
| [🔗](#tab:support.contract.enum.kind-row-1)<br>**Name** | **Meaning** |
| --- | --- |
| [🔗](#tab:support.contract.enum.kind-row-2)<br>pre | A precondition assertion |
| [🔗](#tab:support.contract.enum.kind-row-3)<br>post | A postcondition assertion |
| [🔗](#tab:support.contract.enum.kind-row-4)<br>assert | An [*assertion-statement*](stmt.contract.assert#nt:assertion-statement "8.9Assertion statement[stmt.contract.assert]") |
| [🔗](#tab:support.contract.enum.kind-row-5) |
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4459)
The enumerators of evaluation_semantic correspond to
the evaluation semantics with which
a contract assertion may be evaluated ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation")),
with meanings listed in Table [45](#tab:support.contract.enum.semantic "Table 45: Enum evaluation_­semantic")[.](#3.sentence-1)
Table [45](#tab:support.contract.enum.semantic) — Enum evaluation_semantic [[tab:support.contract.enum.semantic]](./tab:support.contract.enum.semantic)
| [🔗](#tab:support.contract.enum.semantic-row-1)<br>**Name** | **Meaning** |
| --- | --- |
| [🔗](#tab:support.contract.enum.semantic-row-2)<br>ignore | Ignore evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-3)<br>observe | Observe evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-4)<br>enforce | Enforce evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-5)<br>quick_enforce | Quick-enforce evaluation semantic |
| [🔗](#tab:support.contract.enum.semantic-row-6) |
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4476)
The enumerators of detection_mode correspond to the manners in which a
contract violation can be identified ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation")), with
meanings listed in Table [46](#tab:support.contract.enum.detection "Table 46: Enum detection_­mode")[.](#4.sentence-1)
Table [46](#tab:support.contract.enum.detection) — Enum detection_mode [[tab:support.contract.enum.detection]](./tab:support.contract.enum.detection)
| [🔗](#tab:support.contract.enum.detection-row-1)<br>**Name** | **Meaning** |
| --- | --- |
| [🔗](#tab:support.contract.enum.detection-row-2)<br>predicate_false | The predicate of the contract assertion evaluated to false or would have evaluated to false[.](#tab:support.contract.enum.detection-row-2-column-2-sentence-1) |
| [🔗](#tab:support.contract.enum.detection-row-3)<br>evaluation_exception | An uncaught exception occurred during evaluation of the contract assertion[.](#tab:support.contract.enum.detection-row-3-column-2-sentence-1) |
| [🔗](#tab:support.contract.enum.detection-row-4) |

View File

@@ -0,0 +1,19 @@
[support.contract.invoke]
# 17 Language support library [[support]](./#support)
## 17.10 Contract-violation handling [[support.contract]](support.contract#invoke)
### 17.10.4 Invoke default handler [support.contract.invoke]
[🔗](#itemdecl:1)
`void invoke_default_contract_violation_handler(const contract_violation& v);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4638)
*Effects*: Invokes the default contract-violation handler ([[basic.contract.handler]](basic.contract.handler "6.11.3Contract-violation handler"))
with the argument v[.](#1.sentence-1)

View File

@@ -0,0 +1,152 @@
[support.contract.violation]
# 17 Language support library [[support]](./#support)
## 17.10 Contract-violation handling [[support.contract]](support.contract#violation)
### 17.10.3 Class contract_violation [support.contract.violation]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4491)
The class contract_violation defines the type of objects used to represent
a contract violation that has been detected
during the evaluation of a contract assertion
with a particular evaluation semantic ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation"))[.](#1.sentence-1)
Objects of this type can
be created only by the implementation[.](#1.sentence-2)
It isimplementation-defined
whether the destructor is virtual[.](#1.sentence-3)
[🔗](#itemdecl:1)
`const char* comment() const noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4509)
*Returns*: Animplementation-definedntmbs in
the ordinary literal encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4516)
*Recommended practice*: The string returned
should contain a textual representation
of the predicate of the violated contract assertion
or an empty string if
storing a textual representation is undesired[.](#3.sentence-1)
[*Note [1](#note-1)*:
The string can represent a
truncated, reformatted, or summarized rendering of the
predicate, before or after preprocessing[.](#3.sentence-2)
— *end note*]
[🔗](#itemdecl:2)
`contracts::detection_mode detection_mode() const noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4536)
*Returns*: The enumerator value
corresponding to
the manner in which the contract violation was identified[.](#4.sentence-1)
[🔗](#itemdecl:3)
`exception_ptr evaluation_exception() const noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4550)
*Returns*: If the contract violation occurred
because the evaluation of the predicate exited via an exception,
an exception_ptr object that refers to
that exception or a copy of that exception;
otherwise, a null exception_ptr object[.](#5.sentence-1)
[🔗](#itemdecl:4)
`bool is_terminating() const noexcept;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4566)
*Returns*: true if the evaluation semantic is
a terminating semantic ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation"));
otherwise, false[.](#6.sentence-1)
[🔗](#itemdecl:5)
`assertion_kind kind() const noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4579)
*Returns*: The enumerator value
corresponding to
the syntactic form of the violated contract assertion[.](#7.sentence-1)
[🔗](#itemdecl:6)
`source_location location() const noexcept;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4592)
*Returns*: A source_location object
withimplementation-defined
value[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4599)
*Recommended practice*: The value returned should be
a default constructed source_location object
or a value identifying the violated contract assertion:
- [(9.1)](#9.1)
When possible,
if the violated contract assertion was a precondition,
the source location of the function invocation should be returned[.](#9.1.sentence-1)
- [(9.2)](#9.2)
Otherwise,
the source location of the contract assertion should be returned[.](#9.2.sentence-1)
[🔗](#itemdecl:7)
`evaluation_semantic semantic() const noexcept;
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4622)
*Returns*: The enumerator value
corresponding to
the evaluation semantic with which
the violated contract assertion was evaluated[.](#10.sentence-1)

View File

@@ -0,0 +1,510 @@
[support.coroutine]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [support.coroutine]
### [17.13.1](#general) General [[support.coroutine.general]](support.coroutine.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5749)
The header <coroutine> defines several types providing
compile and run-time support for
coroutines in a C++ program[.](#general-1.sentence-1)
### [17.13.2](#coroutine.syn) Header <coroutine> synopsis [[coroutine.syn]](coroutine.syn)
[🔗](#header:%3ccoroutine%3e_)
// all freestanding#include <compare> // see [[compare.syn]](compare.syn "17.12.1Header <compare> synopsis")namespace std {// [[coroutine.traits]](#coroutine.traits "17.13.3Coroutine traits"), coroutine traitstemplate<class R, class... ArgTypes>struct coroutine_traits; // [[coroutine.handle]](#coroutine.handle "17.13.4Class template coroutine_­handle"), coroutine handletemplate<class Promise = void>struct coroutine_handle; // [[coroutine.handle.compare]](#coroutine.handle.compare "17.13.4.8Comparison operators"), comparison operatorsconstexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept; constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept; // [[coroutine.handle.hash]](#coroutine.handle.hash "17.13.4.9Hash support"), hash supporttemplate<class T> struct hash; template<class P> struct hash<coroutine_handle<P>>; // [[coroutine.noop]](#coroutine.noop "17.13.5No-op coroutines"), no-op coroutinesstruct noop_coroutine_promise; template<> struct coroutine_handle<noop_coroutine_promise>; using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
noop_coroutine_handle noop_coroutine() noexcept; // [[coroutine.trivial.awaitables]](#coroutine.trivial.awaitables "17.13.6Trivial awaitables"), trivial awaitablesstruct suspend_never; struct suspend_always;}
### [17.13.3](#coroutine.traits) Coroutine traits [[coroutine.traits]](coroutine.traits)
#### [17.13.3.1](#coroutine.traits.general) General [[coroutine.traits.general]](coroutine.traits.general)
[1](#coroutine.traits.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5798)
Subclause [[coroutine.traits]](#coroutine.traits "17.13.3Coroutine traits") defines requirements on classes representing[*coroutine traits*](#def:coroutine_traits),
and defines the class templatecoroutine_traits that meets those requirements[.](#coroutine.traits.general-1.sentence-1)
#### [17.13.3.2](#coroutine.traits.primary) Class template coroutine_traits [[coroutine.traits.primary]](coroutine.traits.primary)
[1](#coroutine.traits.primary-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5808)
The header [<coroutine>](#header:%3ccoroutine%3e "17.13.2Header <coroutine> synopsis[coroutine.syn]") defines the primary templatecoroutine_traits such that
if ArgTypes is a parameter pack of types and
if the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") R::promise_type is valid and
denotes a type ([[temp.deduct]](temp.deduct "13.10.3Template argument deduction")),
then coroutine_traits<R, ArgTypes...> has the following publicly
accessible member:using promise_type = typename R::promise_type;
Otherwise, coroutine_traits<R, ArgTypes...> has no members[.](#coroutine.traits.primary-1.sentence-2)
[2](#coroutine.traits.primary-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5822)
Program-defined specializations of this template shall define a publicly
accessible nested type named promise_type[.](#coroutine.traits.primary-2.sentence-1)
### [17.13.4](#coroutine.handle) Class template coroutine_handle [[coroutine.handle]](coroutine.handle)
#### [17.13.4.1](#coroutine.handle.general) General [[coroutine.handle.general]](coroutine.handle.general)
[🔗](#lib:coroutine_handle)
namespace std {template<>struct coroutine_handle<void>{// [[coroutine.handle.con]](#coroutine.handle.con "17.13.4.2Construct/reset"), construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept;
coroutine_handle& operator=(nullptr_t) noexcept; // [[coroutine.handle.export.import]](#coroutine.handle.export.import "17.13.4.4Export/import"), export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [[coroutine.handle.observers]](#coroutine.handle.observers "17.13.4.5Observers"), observersconstexpr explicit operator bool() const noexcept; bool done() const; // [[coroutine.handle.resumption]](#coroutine.handle.resumption "17.13.4.6Resumption"), resumptionvoid operator()() const; void resume() const; void destroy() const; private:void* ptr; // *exposition only*}; template<class Promise>struct coroutine_handle {// [[coroutine.handle.con]](#coroutine.handle.con "17.13.4.2Construct/reset"), construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept; static coroutine_handle from_promise(Promise&);
coroutine_handle& operator=(nullptr_t) noexcept; // [[coroutine.handle.export.import]](#coroutine.handle.export.import "17.13.4.4Export/import"), export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [[coroutine.handle.conv]](#coroutine.handle.conv "17.13.4.3Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.observers]](#coroutine.handle.observers "17.13.4.5Observers"), observersconstexpr explicit operator bool() const noexcept; bool done() const; // [[coroutine.handle.resumption]](#coroutine.handle.resumption "17.13.4.6Resumption"), resumptionvoid operator()() const; void resume() const; void destroy() const; // [[coroutine.handle.promise]](#coroutine.handle.promise "17.13.4.7Promise access"), promise access Promise& promise() const; private:void* ptr; // *exposition only*};}
[1](#coroutine.handle.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5892)
An object of typecoroutine_handle<T> is called a [*coroutine handle*](#def:coroutine_handle) and can be used to refer to a suspended or executing coroutine[.](#coroutine.handle.general-1.sentence-1)
A coroutine_handle object whose
member address() returns a null pointer value
does not refer to any
coroutine[.](#coroutine.handle.general-1.sentence-2)
Two coroutine_handle objects refer to the same coroutine
if and only if their member address() returns the same non-null value[.](#coroutine.handle.general-1.sentence-3)
[2](#coroutine.handle.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5903)
If a program declares an explicit or partial specialization ofcoroutine_handle, the behavior is undefined[.](#coroutine.handle.general-2.sentence-1)
#### [17.13.4.2](#coroutine.handle.con) Construct/reset [[coroutine.handle.con]](coroutine.handle.con)
[🔗](#lib:coroutine_handle,constructor)
`constexpr coroutine_handle() noexcept;
constexpr coroutine_handle(nullptr_t) noexcept;
`
[1](#coroutine.handle.con-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5916)
*Postconditions*: address() == nullptr[.](#coroutine.handle.con-1.sentence-1)
[🔗](#lib:from_promise,coroutine_handle)
`static coroutine_handle from_promise(Promise& p);
`
[2](#coroutine.handle.con-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5927)
*Preconditions*: p is a reference to a promise object of a coroutine[.](#coroutine.handle.con-2.sentence-1)
[3](#coroutine.handle.con-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5931)
*Postconditions*: addressof(h.promise()) == addressof(p)[.](#coroutine.handle.con-3.sentence-1)
[4](#coroutine.handle.con-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5935)
*Returns*: A coroutine handle h referring to the coroutine[.](#coroutine.handle.con-4.sentence-1)
[🔗](#lib:operator=,coroutine_handle)
`coroutine_handle& operator=(nullptr_t) noexcept;
`
[5](#coroutine.handle.con-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5946)
*Postconditions*: address() == nullptr[.](#coroutine.handle.con-5.sentence-1)
[6](#coroutine.handle.con-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5950)
*Returns*: *this[.](#coroutine.handle.con-6.sentence-1)
#### [17.13.4.3](#coroutine.handle.conv) Conversion [[coroutine.handle.conv]](coroutine.handle.conv)
[🔗](#lib:operator_coroutine_handle%3c%3e,coroutine_handle)
`constexpr operator coroutine_handle<>() const noexcept;
`
[1](#coroutine.handle.conv-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5963)
*Effects*: Equivalent to: return coroutine_handle<>::from_address(address());
#### [17.13.4.4](#coroutine.handle.export.import) Export/import [[coroutine.handle.export.import]](coroutine.handle.export.import)
[🔗](#lib:address,coroutine_handle)
`constexpr void* address() const noexcept;
`
[1](#coroutine.handle.export.import-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5976)
*Returns*: ptr[.](#coroutine.handle.export.import-1.sentence-1)
[🔗](#lib:from_address,coroutine_handle)
`static constexpr coroutine_handle<> coroutine_handle<>::from_address(void* addr);
`
[2](#coroutine.handle.export.import-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5987)
*Preconditions*: addr was obtained via a prior call to address on an object whose type is a specialization of coroutine_handle[.](#coroutine.handle.export.import-2.sentence-1)
[3](#coroutine.handle.export.import-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5992)
*Postconditions*: from_address(address()) == *this[.](#coroutine.handle.export.import-3.sentence-1)
[🔗](#lib:from_address,coroutine_handle_)
`static constexpr coroutine_handle<Promise> coroutine_handle<Promise>::from_address(void* addr);
`
[4](#coroutine.handle.export.import-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6003)
*Preconditions*: addr was obtained via a prior call to address on an object of type cv coroutine_handle<Promise>[.](#coroutine.handle.export.import-4.sentence-1)
[5](#coroutine.handle.export.import-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6008)
*Postconditions*: from_address(address()) == *this[.](#coroutine.handle.export.import-5.sentence-1)
#### [17.13.4.5](#coroutine.handle.observers) Observers [[coroutine.handle.observers]](coroutine.handle.observers)
[🔗](#lib:operator_bool,coroutine_handle)
`constexpr explicit operator bool() const noexcept;
`
[1](#coroutine.handle.observers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6021)
*Returns*: address() != nullptr[.](#coroutine.handle.observers-1.sentence-1)
[🔗](#lib:done,coroutine_handle)
`bool done() const;
`
[2](#coroutine.handle.observers-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6032)
*Preconditions*: *this refers to a suspended coroutine[.](#coroutine.handle.observers-2.sentence-1)
[3](#coroutine.handle.observers-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6036)
*Returns*: true if the coroutine is suspended at its
final suspend point, otherwise false[.](#coroutine.handle.observers-3.sentence-1)
#### [17.13.4.6](#coroutine.handle.resumption) Resumption [[coroutine.handle.resumption]](coroutine.handle.resumption)
[1](#coroutine.handle.resumption-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6044)
Resuming a coroutine via resume, operator(), or destroy on an execution agent other than the one on which it was suspended
has implementation-defined behavior
unless
each execution agent either is
an instance of std::thread or std::jthread,
or is the thread that executes main[.](#coroutine.handle.resumption-1.sentence-1)
[*Note [1](#coroutine.handle.resumption-note-1)*:
A coroutine that is resumed on a different execution agent should
avoid relying on consistent thread identity throughout, such as holding
a mutex object across a suspend point[.](#coroutine.handle.resumption-1.sentence-2)
— *end note*]
[*Note [2](#coroutine.handle.resumption-note-2)*:
A concurrent resumption of the coroutine can result in a data race[.](#coroutine.handle.resumption-1.sentence-3)
— *end note*]
[🔗](#lib:operator(),coroutine_handle)
`void operator()() const;
void resume() const;
`
[2](#coroutine.handle.resumption-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6069)
*Preconditions*: *this refers to a suspended coroutine[.](#coroutine.handle.resumption-2.sentence-1)
The coroutine is not suspended at its final suspend point[.](#coroutine.handle.resumption-2.sentence-2)
[3](#coroutine.handle.resumption-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6074)
*Effects*: Resumes the execution of the coroutine[.](#coroutine.handle.resumption-3.sentence-1)
[🔗](#lib:destroy,coroutine_handle)
`void destroy() const;
`
[4](#coroutine.handle.resumption-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6085)
*Preconditions*: *this refers to a suspended coroutine[.](#coroutine.handle.resumption-4.sentence-1)
[5](#coroutine.handle.resumption-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6089)
*Effects*: Destroys the coroutine ([[dcl.fct.def.coroutine]](dcl.fct.def.coroutine "9.6.4Coroutine definitions"))[.](#coroutine.handle.resumption-5.sentence-1)
#### [17.13.4.7](#coroutine.handle.promise) Promise access [[coroutine.handle.promise]](coroutine.handle.promise)
[🔗](#lib:promise,coroutine_handle)
`Promise& promise() const;
`
[1](#coroutine.handle.promise-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6102)
*Preconditions*: *this refers to a coroutine[.](#coroutine.handle.promise-1.sentence-1)
[2](#coroutine.handle.promise-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6106)
*Returns*: A reference to the promise of the coroutine[.](#coroutine.handle.promise-2.sentence-1)
#### [17.13.4.8](#coroutine.handle.compare) Comparison operators [[coroutine.handle.compare]](coroutine.handle.compare)
[🔗](#lib:operator==,coroutine_handle)
`constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
`
[1](#coroutine.handle.compare-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6120)
*Returns*: x.address() == y.address()[.](#coroutine.handle.compare-1.sentence-1)
[🔗](#lib:operator%3c=%3e,coroutine_handle)
`constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
`
[2](#coroutine.handle.compare-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6131)
*Returns*: compare_three_way()(x.address(), y.address())[.](#coroutine.handle.compare-2.sentence-1)
#### [17.13.4.9](#coroutine.handle.hash) Hash support [[coroutine.handle.hash]](coroutine.handle.hash)
[🔗](#lib:hash,coroutine_handle)
`template<class P> struct hash<coroutine_handle<P>>;
`
[1](#coroutine.handle.hash-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6144)
The specialization is enabled ([[unord.hash]](unord.hash "22.10.19Class template hash"))[.](#coroutine.handle.hash-1.sentence-1)
### [17.13.5](#coroutine.noop) No-op coroutines [[coroutine.noop]](coroutine.noop)
#### [17.13.5.1](#coroutine.promise.noop) Class noop_coroutine_promise [[coroutine.promise.noop]](coroutine.promise.noop)
[🔗](#lib:noop_coroutine_promise)
`struct noop_coroutine_promise {};
`
[1](#coroutine.promise.noop-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6158)
The class noop_coroutine_promise defines the promise type for
the coroutine referred to
by noop_coroutine_handle ([[coroutine.syn]](#coroutine.syn "17.13.2Header <coroutine> synopsis"))[.](#coroutine.promise.noop-1.sentence-1)
#### [17.13.5.2](#coroutine.handle.noop) Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop)
#### [17.13.5.2.1](#coroutine.handle.noop.general) General [[coroutine.handle.noop.general]](coroutine.handle.noop.general)
[🔗](#lib:coroutine_handle%3cnoop_coroutine_promise%3e)
namespace std {template<>struct coroutine_handle<noop_coroutine_promise>{// [[coroutine.handle.noop.conv]](#coroutine.handle.noop.conv "17.13.5.2.2Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.noop.observers]](#coroutine.handle.noop.observers "17.13.5.2.3Observers"), observersconstexpr explicit operator bool() const noexcept; constexpr bool done() const noexcept; // [[coroutine.handle.noop.resumption]](#coroutine.handle.noop.resumption "17.13.5.2.4Resumption"), resumptionconstexpr void operator()() const noexcept; constexpr void resume() const noexcept; constexpr void destroy() const noexcept; // [[coroutine.handle.noop.promise]](#coroutine.handle.noop.promise "17.13.5.2.5Promise access"), promise access noop_coroutine_promise& promise() const noexcept; // [[coroutine.handle.noop.address]](#coroutine.handle.noop.address "17.13.5.2.6Address"), addressconstexpr void* address() const noexcept; private: coroutine_handle(*unspecified*); void* ptr; // *exposition only*};}
#### [17.13.5.2.2](#coroutine.handle.noop.conv) Conversion [[coroutine.handle.noop.conv]](coroutine.handle.noop.conv)
[🔗](#lib:operator_coroutine_handle%3c%3e,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr operator coroutine_handle<>() const noexcept;
`
[1](#coroutine.handle.noop.conv-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6206)
*Effects*: Equivalent to: return coroutine_handle<>::from_address(address());
#### [17.13.5.2.3](#coroutine.handle.noop.observers) Observers [[coroutine.handle.noop.observers]](coroutine.handle.noop.observers)
[🔗](#lib:operator_bool,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr explicit operator bool() const noexcept;
`
[1](#coroutine.handle.noop.observers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6219)
*Returns*: true[.](#coroutine.handle.noop.observers-1.sentence-1)
[🔗](#lib:done,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr bool done() const noexcept;
`
[2](#coroutine.handle.noop.observers-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6230)
*Returns*: false[.](#coroutine.handle.noop.observers-2.sentence-1)
#### [17.13.5.2.4](#coroutine.handle.noop.resumption) Resumption [[coroutine.handle.noop.resumption]](coroutine.handle.noop.resumption)
[🔗](#lib:operator(),coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void operator()() const noexcept;
constexpr void resume() const noexcept;
constexpr void destroy() const noexcept;
`
[1](#coroutine.handle.noop.resumption-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6247)
*Effects*: None[.](#coroutine.handle.noop.resumption-1.sentence-1)
[2](#coroutine.handle.noop.resumption-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6251)
*Remarks*: If noop_coroutine_handle is converted to coroutine_handle<>,
calls to operator(), resume and destroy on that handle
will also have no observable effects[.](#coroutine.handle.noop.resumption-2.sentence-1)
#### [17.13.5.2.5](#coroutine.handle.noop.promise) Promise access [[coroutine.handle.noop.promise]](coroutine.handle.noop.promise)
[🔗](#lib:promise,coroutine_handle%3cnoop_coroutine_promise%3e)
`noop_coroutine_promise& promise() const noexcept;
`
[1](#coroutine.handle.noop.promise-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6266)
*Returns*: A reference to the promise object associated with this
coroutine handle[.](#coroutine.handle.noop.promise-1.sentence-1)
#### [17.13.5.2.6](#coroutine.handle.noop.address) Address [[coroutine.handle.noop.address]](coroutine.handle.noop.address)
[🔗](#lib:address,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void* address() const noexcept;
`
[1](#coroutine.handle.noop.address-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6280)
*Returns*: ptr[.](#coroutine.handle.noop.address-1.sentence-1)
[2](#coroutine.handle.noop.address-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6284)
*Remarks*: A noop_coroutine_handle's ptr is always a
non-null pointer value[.](#coroutine.handle.noop.address-2.sentence-1)
#### [17.13.5.3](#coroutine.noop.coroutine) Function noop_coroutine [[coroutine.noop.coroutine]](coroutine.noop.coroutine)
[🔗](#lib:noop_coroutine)
`noop_coroutine_handle noop_coroutine() noexcept;
`
[1](#coroutine.noop.coroutine-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6298)
*Returns*: A handle to a coroutine that has no observable effects
when resumed or destroyed[.](#coroutine.noop.coroutine-1.sentence-1)
[2](#coroutine.noop.coroutine-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6303)
*Remarks*: A handle returned from noop_coroutine may or may not
compare equal to a handle returned from another invocation
of noop_coroutine[.](#coroutine.noop.coroutine-2.sentence-1)
### [17.13.6](#coroutine.trivial.awaitables) Trivial awaitables [[coroutine.trivial.awaitables]](coroutine.trivial.awaitables)
[🔗](#lib:suspend_never)
namespace std {struct suspend_never {constexpr bool await_ready() const noexcept { return true; }constexpr void await_suspend(coroutine_handle<>) const noexcept {}constexpr void await_resume() const noexcept {}}; struct suspend_always {constexpr bool await_ready() const noexcept { return false; }constexpr void await_suspend(coroutine_handle<>) const noexcept {}constexpr void await_resume() const noexcept {}};}
[1](#coroutine.trivial.awaitables-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6335)
[*Note [1](#coroutine.trivial.awaitables-note-1)*:
The types suspend_never and suspend_always can be used
to indicate that an [*await-expression*](expr.await#nt:await-expression "7.6.2.4Await[expr.await]") either never
suspends or always suspends, and in either case does not produce a value[.](#coroutine.trivial.awaitables-1.sentence-1)
— *end note*]

View File

@@ -0,0 +1,15 @@
[support.coroutine.general]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#general)
### 17.13.1 General [support.coroutine.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5749)
The header <coroutine> defines several types providing
compile and run-time support for
coroutines in a C++ program[.](#1.sentence-1)

922
cppdraft/support/dynamic.md Normal file
View File

@@ -0,0 +1,922 @@
[support.dynamic]
# 17 Language support library [[support]](./#support)
## 17.6 Dynamic memory management [support.dynamic]
### [17.6.1](#general) General [[support.dynamic.general]](support.dynamic.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2326)
The header <new> defines several
functions that manage the allocation of dynamic storage in a program[.](#general-1.sentence-1)
It also defines components for reporting storage management errors[.](#general-1.sentence-2)
### [17.6.2](#new.syn) Header <new> synopsis [[new.syn]](new.syn)
// all freestandingnamespace std {// [[alloc.errors]](#alloc.errors "17.6.4Storage allocation errors"), storage allocation errorsclass bad_alloc; class bad_array_new_length; struct destroying_delete_t {explicit destroying_delete_t() = default; }; inline constexpr destroying_delete_t destroying_delete{}; // global operator new control enum class align_val_t : size_t {}; struct nothrow_t { explicit nothrow_t() = default; }; extern const nothrow_t nothrow; using new_handler = void (*)();
new_handler get_new_handler() noexcept;
new_handler set_new_handler(new_handler new_p) noexcept; // [[ptr.launder]](#ptr.launder "17.6.5Pointer optimization barrier"), pointer optimization barriertemplate<class T> constexpr T* launder(T* p) noexcept; // [[hardware.interference]](#hardware.interference "17.6.6Hardware interference size"), hardware interference sizeinline constexpr size_t hardware_destructive_interference_size = *implementation-defined*; inline constexpr size_t hardware_constructive_interference_size = *implementation-defined*;}// [[new.delete]](#new.delete "17.6.3Storage allocation and deallocation"), storage allocation and deallocationvoid* operator new(std::size_t size);void* operator new(std::size_t size, std::align_val_t alignment);void* operator new(std::size_t size, const std::nothrow_t&) noexcept;void* operator new(std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
void operator delete(void* ptr) noexcept;void operator delete(void* ptr, std::size_t size) noexcept;void operator delete(void* ptr, std::align_val_t alignment) noexcept;void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;void operator delete(void* ptr, const std::nothrow_t&) noexcept;void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t size);void* operator new[](std::size_t size, std::align_val_t alignment);void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
void operator delete[](void* ptr) noexcept;void operator delete[](void* ptr, std::size_t size) noexcept;void operator delete[](void* ptr, std::align_val_t alignment) noexcept;void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;void operator delete[](void* ptr, const std::nothrow_t&) noexcept;void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
constexpr void* operator new (std::size_t size, void* ptr) noexcept;constexpr void* operator new[](std::size_t size, void* ptr) noexcept;void operator delete (void* ptr, void*) noexcept;void operator delete[](void* ptr, void*) noexcept;
### [17.6.3](#new.delete) Storage allocation and deallocation [[new.delete]](new.delete)
#### [17.6.3.1](#new.delete.general) General [[new.delete.general]](new.delete.general)
[1](#new.delete.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2403)
Except where otherwise specified, the provisions of [[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5Dynamic storage duration") apply to the library versions of operator new and operatordelete[.](#new.delete.general-1.sentence-1)
If the value of an alignment argument
passed to any of these functions
is not a valid alignment value,
the behavior is undefined[.](#new.delete.general-1.sentence-2)
[2](#new.delete.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2412)
On freestanding implementations,
it is implementation-defined
whether the default versions of the replaceable global allocation functions
satisfy the required behaviors
described in [[new.delete.single]](#new.delete.single "17.6.3.2Single-object forms") and [[new.delete.array]](#new.delete.array "17.6.3.3Array forms")[.](#new.delete.general-2.sentence-1)
[*Note [1](#new.delete.general-note-1)*:
A freestanding implementation's default versions of
the replaceable global allocation functions
can cause undefined behavior when invoked[.](#new.delete.general-2.sentence-2)
During constant evaluation,
the behaviors of those default versions are irrelevant,
as those calls are omitted ([[expr.new]](expr.new "7.6.2.8New"))[.](#new.delete.general-2.sentence-3)
— *end note*]
*Recommended practice*: If any of the default versions of the replaceable global allocation functions
meet the requirements of a hosted implementation, they all should[.](#new.delete.general-2.sentence-4)
#### [17.6.3.2](#new.delete.single) Single-object forms [[new.delete.single]](new.delete.single)
[🔗](#lib:new,operator)
`void* operator new(std::size_t size);
void* operator new(std::size_t size, std::align_val_t alignment);
`
[1](#new.delete.single-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2440)
*Effects*: The[allocation functions](basic.stc.dynamic.allocation "6.8.6.5.2Allocation functions[basic.stc.dynamic.allocation]") called by a[*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") ([[expr.new]](expr.new "7.6.2.8New"))
to allocatesize bytes of storage[.](#new.delete.single-1.sentence-1)
The second form is called for a type with new-extended alignment, and
the first form is called otherwise[.](#new.delete.single-1.sentence-2)
[2](#new.delete.single-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2451)
*Required behavior*: Return a non-null pointer to suitably aligned storage ([[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5Dynamic storage duration")),
or else throw abad_allocexception[.](#new.delete.single-2.sentence-1)
This requirement is binding on any replacement versions of these functions[.](#new.delete.single-2.sentence-2)
[3](#new.delete.single-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2460)
*Default behavior*:
- [(3.1)](#new.delete.single-3.1)
Executes a loop:
Within the loop, the function first attempts to allocate the requested storage[.](#new.delete.single-3.1.sentence-1)
Whether the attempt involves a call to the C standard library functionsmalloc or aligned_alloc is unspecified[.](#new.delete.single-3.1.sentence-2)
- [(3.2)](#new.delete.single-3.2)
Returns a pointer to the allocated storage if the attempt is successful[.](#new.delete.single-3.2.sentence-1)
Otherwise, if the
current new_handler ([[get.new.handler]](#get.new.handler "17.6.4.5get_­new_­handler")) is
a null pointer value, throwsbad_alloc[.](#new.delete.single-3.2.sentence-2)
- [(3.3)](#new.delete.single-3.3)
Otherwise, the function calls the current[new_handler](#new.handler "17.6.4.3Type new_­handler[new.handler]") function[.](#new.delete.single-3.3.sentence-1)
If the called function returns, the loop repeats[.](#new.delete.single-3.3.sentence-2)
- [(3.4)](#new.delete.single-3.4)
The loop terminates when an attempt to allocate the requested storage is
successful or when a callednew_handler function does not return[.](#new.delete.single-3.4.sentence-1)
[4](#new.delete.single-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2487)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.single-4.sentence-1)
[🔗](#lib:new,operator_)
`void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
void* operator new(std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
`
[5](#new.delete.single-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2499)
*Effects*: Same as above, except that these are called by a placement version of a[*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") when a C++ program prefers a null pointer result as an error indication,
instead of abad_alloc exception[.](#new.delete.single-5.sentence-1)
[6](#new.delete.single-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2508)
*Required behavior*: Return a non-null pointer to suitably aligned storage ([[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5Dynamic storage duration")),
or else return a null pointer[.](#new.delete.single-6.sentence-1)
Each of these nothrow versions ofoperator new returns a pointer obtained as if
acquired from the (possibly replaced)
corresponding non-placement function[.](#new.delete.single-6.sentence-2)
This requirement is binding on any replacement versions of these functions[.](#new.delete.single-6.sentence-3)
[7](#new.delete.single-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2519)
*Default behavior*: Calls operator new(size),
or operator new(size, alignment),
respectively[.](#new.delete.single-7.sentence-1)
If the call returns normally,
returns the result of that call[.](#new.delete.single-7.sentence-2)
Otherwise, returns a null pointer[.](#new.delete.single-7.sentence-3)
[8](#new.delete.single-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2528)
[*Example [1](#new.delete.single-example-1)*: T* p1 = new T; // throws bad_alloc if it fails T* p2 = new(nothrow) T; // returns nullptr if it fails — *end example*]
[9](#new.delete.single-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2536)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.single-9.sentence-1)
[🔗](#lib:delete,operator)
`void operator delete(void* ptr) noexcept;
void operator delete(void* ptr, std::size_t size) noexcept;
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
`
[10](#new.delete.single-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2550)
*Preconditions*: ptr is a null pointer or
its value represents the address of
a block of memory allocated by
an earlier call to a (possibly replaced)operator new(std::size_t) oroperator new(std::size_t, std::align_val_t) which has not been invalidated by an intervening call tooperator delete[.](#new.delete.single-10.sentence-1)
[11](#new.delete.single-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2562)
If the alignment parameter is not present,ptr was returned by an allocation function
without an alignment parameter[.](#new.delete.single-11.sentence-1)
If present, the alignment argument
is equal to the alignment argument
passed to the allocation function that returned ptr[.](#new.delete.single-11.sentence-2)
If present, the size argument
is equal to the size argument
passed to the allocation function that returned ptr[.](#new.delete.single-11.sentence-3)
[12](#new.delete.single-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2573)
*Effects*: The
deallocation functions ([[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation "6.8.6.5.3Deallocation functions"))
called by a[*delete-expression*](expr.delete#nt:delete-expression "7.6.2.9Delete[expr.delete]") ([[expr.delete]](expr.delete "7.6.2.9Delete"))
to render the value of ptr invalid[.](#new.delete.single-12.sentence-1)
[13](#new.delete.single-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2581)
*Required behavior*: A call to an operator delete with a size parameter
may be changed to
a call to the corresponding operator delete without a size parameter,
without affecting memory allocation[.](#new.delete.single-13.sentence-1)
[*Note [1](#new.delete.single-note-1)*:
A conforming implementation is foroperator delete(void* ptr, std::size_t size) to simply calloperator delete(ptr)[.](#new.delete.single-13.sentence-2)
— *end note*]
[14](#new.delete.single-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2595)
*Default behavior*: The functions that have a size parameter
forward their other parameters
to the corresponding function without a size parameter[.](#new.delete.single-14.sentence-1)
[*Note [2](#new.delete.single-note-2)*:
See the note in the below *Remarks*: paragraph[.](#new.delete.single-14.sentence-2)
— *end note*]
[15](#new.delete.single-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2604)
*Default behavior*: If ptr is null, does nothing[.](#new.delete.single-15.sentence-1)
Otherwise, reclaims the
storage allocated by the earlier call to operator new[.](#new.delete.single-15.sentence-2)
[16](#new.delete.single-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2609)
*Remarks*: It is unspecified under what conditions part or all of suchreclaimed storage will be allocated by subsequent
calls tooperator new or any ofaligned_alloc,calloc,malloc,
orrealloc,
declared in [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]")[.](#new.delete.single-16.sentence-1)
This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.single-16.sentence-2)
If a replacement function
without a size parameter
is defined by the program,
the program should also define the corresponding
function with a size parameter[.](#new.delete.single-16.sentence-3)
If a replacement function
with a size parameter
is defined by the program,
the program shall also define the corresponding
version without the size parameter[.](#new.delete.single-16.sentence-4)
[*Note [3](#new.delete.single-note-3)*:
The default behavior above might change in the future,
which will require replacing both deallocation functions
when replacing the allocation function[.](#new.delete.single-16.sentence-5)
— *end note*]
[🔗](#lib:delete,operator_)
`void operator delete(void* ptr, const std::nothrow_t&) noexcept;
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
`
[17](#new.delete.single-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2648)
*Preconditions*: ptr is a null pointer or
its value represents the address of
a block of memory allocated by
an earlier call to a (possibly replaced)operator new(std::size_t) oroperator new(std::size_t, std::align_val_t) which has not been invalidated by an intervening call tooperator delete[.](#new.delete.single-17.sentence-1)
[18](#new.delete.single-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2660)
If the alignment parameter is not present,ptr was returned by an allocation function
without an alignment parameter[.](#new.delete.single-18.sentence-1)
If present, the alignment argument
is equal to the alignment argument
passed to the allocation function that returned ptr[.](#new.delete.single-18.sentence-2)
[19](#new.delete.single-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2668)
*Effects*: The
deallocation functions ([[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation "6.8.6.5.3Deallocation functions"))
called by the implementation
to render the value of ptr invalid
when the constructor invoked from a nothrow
placement version of the [*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") throws an exception[.](#new.delete.single-19.sentence-1)
[20](#new.delete.single-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2677)
*Default behavior*: Calls operator delete(ptr),
or operator delete(ptr, alignment),
respectively[.](#new.delete.single-20.sentence-1)
[21](#new.delete.single-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2683)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.single-21.sentence-1)
#### [17.6.3.3](#new.delete.array) Array forms [[new.delete.array]](new.delete.array)
[🔗](#lib:new,operator__)
`void* operator new[](std::size_t size);
void* operator new[](std::size_t size, std::align_val_t alignment);
`
[1](#new.delete.array-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2697)
*Effects*: The[allocation functions](basic.stc.dynamic.allocation "6.8.6.5.2Allocation functions[basic.stc.dynamic.allocation]") called by the array form of a[*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") ([[expr.new]](expr.new "7.6.2.8New"))
to allocatesize bytes of storage[.](#new.delete.array-1.sentence-1)
The second form is called for a type with new-extended alignment, and
the first form is called otherwise[.](#new.delete.array-1.sentence-2)[189](#footnote-189 "It is not the direct responsibility of operator new[] or operator delete[] to note the repetition count or element size of the array. Those operations are performed elsewhere in the array new and delete expressions. The array new expression, can, however, increase the size argument to operator new[] to obtain space to store supplemental information.")
[2](#new.delete.array-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2725)
*Required behavior*: Same as for
the corresponding single-object forms[.](#new.delete.array-2.sentence-1)
This requirement is binding on any replacement versions of these functions[.](#new.delete.array-2.sentence-2)
[3](#new.delete.array-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2731)
*Default behavior*: Returnsoperator new(size),
oroperator new(size, alignment),
respectively[.](#new.delete.array-3.sentence-1)
[4](#new.delete.array-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2739)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.array-4.sentence-1)
[🔗](#lib:new,operator___)
`void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
`
[5](#new.delete.array-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2751)
*Effects*: Same as above, except that these are called by a placement version of a[*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") when a C++ program prefers a null pointer result as an error indication,
instead of abad_alloc exception[.](#new.delete.array-5.sentence-1)
[6](#new.delete.array-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2760)
*Required behavior*: Return a non-null pointer to suitably aligned storage ([[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5Dynamic storage duration")),
or else return a null pointer[.](#new.delete.array-6.sentence-1)
Each of these nothrow versions ofoperator new[] returns a pointer obtained as if
acquired from the (possibly replaced)
corresponding non-placement function[.](#new.delete.array-6.sentence-2)
This requirement is binding on any replacement versions of these functions[.](#new.delete.array-6.sentence-3)
[7](#new.delete.array-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2771)
*Default behavior*: Calls operator new[](size),
or operator new[](size, alignment),
respectively[.](#new.delete.array-7.sentence-1)
If the call returns normally,
returns the result of that call[.](#new.delete.array-7.sentence-2)
Otherwise, returns a null pointer[.](#new.delete.array-7.sentence-3)
[8](#new.delete.array-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2780)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.array-8.sentence-1)
[🔗](#lib:delete,operator__)
`void operator delete[](void* ptr) noexcept;
void operator delete[](void* ptr, std::size_t size) noexcept;
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
`
[9](#new.delete.array-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2794)
*Preconditions*: ptr is a null pointer or
its value represents the address of
a block of memory allocated by
an earlier call to a (possibly replaced)operator new[](std::size_t) oroperator new[](std::size_t, std::align_val_t) which has not been invalidated by an intervening call tooperator delete[][.](#new.delete.array-9.sentence-1)
[10](#new.delete.array-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2806)
If the alignment parameter is not present,ptr was returned by an allocation function
without an alignment parameter[.](#new.delete.array-10.sentence-1)
If present, the alignment argument
is equal to the alignment argument
passed to the allocation function that returned ptr[.](#new.delete.array-10.sentence-2)
If present, the size argument
is equal to the size argument
passed to the allocation function that returned ptr[.](#new.delete.array-10.sentence-3)
[11](#new.delete.array-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2817)
*Effects*: The
deallocation functions ([[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation "6.8.6.5.3Deallocation functions"))
called by the array form of a[*delete-expression*](expr.delete#nt:delete-expression "7.6.2.9Delete[expr.delete]") to render the value of ptr invalid[.](#new.delete.array-11.sentence-1)
[12](#new.delete.array-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2825)
*Required behavior*: A call to an operator delete[] with a size parameter
may be changed to
a call to the corresponding operator delete[] without a size parameter,
without affecting memory allocation[.](#new.delete.array-12.sentence-1)
[*Note [1](#new.delete.array-note-1)*:
A conforming implementation is foroperator delete[](void* ptr, std::size_t size) to simply calloperator delete[](ptr)[.](#new.delete.array-12.sentence-2)
— *end note*]
[13](#new.delete.array-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2839)
*Default behavior*: The functions that have a size parameter
forward their other parameters
to the corresponding function without a size parameter[.](#new.delete.array-13.sentence-1)
The functions that do not have a size parameter
forward their parameters
to the corresponding operator delete (single-object) function[.](#new.delete.array-13.sentence-2)
[14](#new.delete.array-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2848)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.array-14.sentence-1)
If a replacement function
without a size parameter
is defined by the program,
the program should also define the corresponding
function with a size parameter[.](#new.delete.array-14.sentence-2)
If a replacement function
with a size parameter
is defined by the program,
the program shall also define the corresponding
version without the size parameter[.](#new.delete.array-14.sentence-3)
[*Note [2](#new.delete.array-note-2)*:
The default behavior above might change in the future,
which will require replacing both deallocation functions
when replacing the allocation function[.](#new.delete.array-14.sentence-4)
— *end note*]
[🔗](#lib:delete,operator___)
`void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
`
[15](#new.delete.array-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2875)
*Preconditions*: ptr is a null pointer or
its value represents the address of
a block of memory allocated by
an earlier call to a (possibly replaced)operator new[](std::size_t) oroperator new[](std::size_t, std::align_val_t) which has not been invalidated by an intervening call tooperator delete[][.](#new.delete.array-15.sentence-1)
[16](#new.delete.array-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2887)
If the alignment parameter is not present,ptr was returned by an allocation function
without an alignment parameter[.](#new.delete.array-16.sentence-1)
If present, the alignment argument
is equal to the alignment argument
passed to the allocation function that returned ptr[.](#new.delete.array-16.sentence-2)
[17](#new.delete.array-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2895)
*Effects*: The
deallocation functions ([[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation "6.8.6.5.3Deallocation functions"))
called by the implementation
to render the value of ptr invalid
when the constructor invoked from a nothrow
placement version of the array [*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") throws an exception[.](#new.delete.array-17.sentence-1)
[18](#new.delete.array-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2904)
*Default behavior*: Calls operator delete[](ptr),
or operator delete[](ptr, alignment),
respectively[.](#new.delete.array-18.sentence-1)
[19](#new.delete.array-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2910)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#new.delete.array-19.sentence-1)
[189)](#footnote-189)[189)](#footnoteref-189)
It is not the direct responsibility ofoperator new[] oroperator delete[] to note the repetition count or element size of the array[.](#footnote-189.sentence-1)
Those operations are performed elsewhere in the arraynew anddelete expressions[.](#footnote-189.sentence-2)
The arraynew expression, can, however, increase the size argument tooperator new[] to obtain space to store supplemental information[.](#footnote-189.sentence-3)
#### [17.6.3.4](#new.delete.placement) Non-allocating forms [[new.delete.placement]](new.delete.placement)
[1](#new.delete.placement-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2917)
These functions are reserved; a C++ program may not define functions that displace
the versions in the C++ standard library ([[constraints]](constraints "16.4.5Constraints on programs"))[.](#new.delete.placement-1.sentence-1)
The provisions of [[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5Dynamic storage duration") do not apply to these reserved
placement forms of operator new and operator delete[.](#new.delete.placement-1.sentence-2)
[🔗](#lib:new,operator____)
`constexpr void* operator new(std::size_t size, void* ptr) noexcept;
`
[2](#new.delete.placement-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2929)
*Returns*: ptr[.](#new.delete.placement-2.sentence-1)
[3](#new.delete.placement-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2933)
*Remarks*: Intentionally performs no other action[.](#new.delete.placement-3.sentence-1)
[4](#new.delete.placement-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2937)
[*Example [1](#new.delete.placement-example-1)*:
This can be useful for constructing an object at a known address:void* place = operator new(sizeof(Something));
Something* p = new (place) Something();
— *end example*]
[🔗](#lib:new,operator_____)
`constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
`
[5](#new.delete.placement-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2953)
*Returns*: ptr[.](#new.delete.placement-5.sentence-1)
[6](#new.delete.placement-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2957)
*Remarks*: Intentionally performs no other action[.](#new.delete.placement-6.sentence-1)
[🔗](#lib:delete,operator____)
`void operator delete(void* ptr, void*) noexcept;
`
[7](#new.delete.placement-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2968)
*Effects*: Intentionally performs no action[.](#new.delete.placement-7.sentence-1)
[8](#new.delete.placement-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2972)
*Remarks*: Default function called when any part of the initialization in a
placement [*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") that invokes the library's
non-array placement operator new
terminates by throwing an exception ([[expr.new]](expr.new "7.6.2.8New"))[.](#new.delete.placement-8.sentence-1)
[🔗](#lib:delete,operator_____)
`void operator delete[](void* ptr, void*) noexcept;
`
[9](#new.delete.placement-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2986)
*Effects*: Intentionally performs no action[.](#new.delete.placement-9.sentence-1)
[10](#new.delete.placement-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2990)
*Remarks*: Default function called when any part of the initialization in a
placement [*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") that invokes the library's
array placement operator new
terminates by throwing an exception ([[expr.new]](expr.new "7.6.2.8New"))[.](#new.delete.placement-10.sentence-1)
#### [17.6.3.5](#new.delete.dataraces) Data races [[new.delete.dataraces]](new.delete.dataraces)
[1](#new.delete.dataraces-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3000)
For purposes of determining the existence of data races, the library versions
of operator new, user replacement versions of global operator new,
the C standard library functionsaligned_alloc, calloc, and malloc,
the library
versions of operator delete, user replacement
versions of operator delete, the C standard library functionfree, and the C standard library function realloc shall not
introduce a data race ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance"))[.](#new.delete.dataraces-1.sentence-1)
Calls to these functions that allocate or deallocate a particular unit
of storage shall occur in a single total order, and each such deallocation call
shall [happen before](intro.multithread#def:happens_before "6.10.2Multi-threaded executions and data races[intro.multithread]") the next allocation (if any) in this order[.](#new.delete.dataraces-1.sentence-2)
### [17.6.4](#alloc.errors) Storage allocation errors [[alloc.errors]](alloc.errors)
#### [17.6.4.1](#bad.alloc) Class bad_alloc [[bad.alloc]](bad.alloc)
[🔗](#lib:bad_alloc,constructor)
namespace std {class bad_alloc : public exception {public:// see [[exception]](exception "17.9.3Class exception") for the specification of the special member functionsconstexpr const char* what() const noexcept override; };}
[1](#bad.alloc-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3031)
The classbad_alloc defines the type of objects thrown as
exceptions by the implementation to report a failure to allocate storage[.](#bad.alloc-1.sentence-1)
[🔗](#lib:what,bad_alloc)
`constexpr const char* what() const noexcept override;
`
[2](#bad.alloc-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3043)
*Returns*: An implementation-defined ntbs[.](#bad.alloc-2.sentence-1)
#### [17.6.4.2](#new.badlength) Class bad_array_new_length [[new.badlength]](new.badlength)
namespace std {class bad_array_new_length : public bad_alloc {public:// see [[exception]](exception "17.9.3Class exception") for the specification of the special member functionsconstexpr const char* what() const noexcept override; };}
[1](#new.badlength-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3062)
The class bad_array_new_length defines the type of objects thrown as
exceptions by the implementation to report an attempt to allocate an array of size
less than zero or
greater than an implementation-defined limit ([[expr.new]](expr.new "7.6.2.8New"))[.](#new.badlength-1.sentence-1)
[🔗](#lib:what,bad_array_new_length)
`constexpr const char* what() const noexcept override;
`
[2](#new.badlength-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3074)
*Returns*: An implementation-defined ntbs[.](#new.badlength-2.sentence-1)
#### [17.6.4.3](#new.handler) Type new_handler [[new.handler]](new.handler)
[🔗](#lib:new_handler)
`using new_handler = void (*)();
`
[1](#new.handler-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3087)
The type of a[*handler function*](#def:handler_function) to be called byoperator new() oroperator new[]() ([[new.delete]](#new.delete "17.6.3Storage allocation and deallocation")) when they cannot satisfy a request for additional storage[.](#new.handler-1.sentence-1)
[2](#new.handler-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3095)
*Required behavior*: A new_handler shall perform one of the following:
- [(2.1)](#new.handler-2.1)
make more storage available for allocation and then return;
- [(2.2)](#new.handler-2.2)
throw an exception of typebad_alloc or a class derived frombad_alloc;
- [(2.3)](#new.handler-2.3)
terminate execution of the program without returning to the caller[.](#new.handler-2.sentence-1)
#### [17.6.4.4](#set.new.handler) set_new_handler [[set.new.handler]](set.new.handler)
[🔗](#lib:set_new_handler)
`new_handler set_new_handler(new_handler new_p) noexcept;
`
[1](#set.new.handler-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3122)
*Effects*: Establishes the function designated by new_p as the currentnew_handler[.](#set.new.handler-1.sentence-1)
[2](#set.new.handler-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3127)
*Returns*: The previous new_handler[.](#set.new.handler-2.sentence-1)
[3](#set.new.handler-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3131)
*Remarks*: The initial new_handler is a null pointer[.](#set.new.handler-3.sentence-1)
#### [17.6.4.5](#get.new.handler) get_new_handler [[get.new.handler]](get.new.handler)
[🔗](#lib:get_new_handler)
`new_handler get_new_handler() noexcept;
`
[1](#get.new.handler-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3144)
*Returns*: The current new_handler[.](#get.new.handler-1.sentence-1)
[*Note [1](#get.new.handler-note-1)*:
This can be a null pointer value[.](#get.new.handler-1.sentence-2)
— *end note*]
### [17.6.5](#ptr.launder) Pointer optimization barrier [[ptr.launder]](ptr.launder)
[🔗](#lib:launder)
`template<class T> constexpr T* launder(T* p) noexcept;
`
[1](#ptr.launder-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3160)
*Mandates*: !is_function_v<T> && !is_void_v<T> is true[.](#ptr.launder-1.sentence-1)
[2](#ptr.launder-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3164)
*Preconditions*: p represents the address *A* of a byte in memory[.](#ptr.launder-2.sentence-1)
An object *X* that is within its [lifetime](basic.life#def:lifetime "6.8.4Lifetime[basic.life]") and whose type is [similar](conv.qual#def:similar_types "7.3.6Qualification conversions[conv.qual]") to T is located at the address *A*[.](#ptr.launder-2.sentence-2)
All bytes of storage that would be
reachable through ([[basic.compound]](basic.compound "6.9.4Compound types")) the result
are reachable through p[.](#ptr.launder-2.sentence-3)
[3](#ptr.launder-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3174)
*Returns*: A value of type T* that points to *X*[.](#ptr.launder-3.sentence-1)
[4](#ptr.launder-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3178)
*Remarks*: An invocation of this function
may be used in a core constant expression
if and only if the (converted) value of its argument
may be used in place of the function invocation[.](#ptr.launder-4.sentence-1)
[5](#ptr.launder-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3185)
[*Note [1](#ptr.launder-note-1)*:
If a new object is created
in storage occupied by an existing object of the same type,
a pointer to the original object
can be used to refer to the new object
unless its complete object is a const object or it is a base class subobject;
in the latter cases,
this function can be used to obtain a usable pointer to the new object[.](#ptr.launder-5.sentence-1)
See [[basic.life]](basic.life "6.8.4Lifetime")[.](#ptr.launder-5.sentence-2)
— *end note*]
[6](#ptr.launder-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3197)
[*Example [1](#ptr.launder-example-1)*: struct X { int n; };const X *p = new const X{3};const int a = p->n;new (const_cast<X*>(p)) const X{5}; // p does not point to new object ([[basic.life]](basic.life "6.8.4Lifetime")) because its type is constconst int b = p->n; // undefined behaviorconst int c = std::launder(p)->n; // OK — *end example*]
### [17.6.6](#hardware.interference) Hardware interference size [[hardware.interference]](hardware.interference)
[🔗](#lib:hardware_destructive_interference_size)
`inline constexpr size_t hardware_destructive_interference_size = implementation-defined;
`
[1](#hardware.interference-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3217)
This number is the minimum recommended offset
between two concurrently-accessed objects
to avoid additional performance degradation due to contention
introduced by the implementation[.](#hardware.interference-1.sentence-1)
It shall be at least alignof(max_align_t)[.](#hardware.interference-1.sentence-2)
[*Example [1](#hardware.interference-example-1)*: struct keep_apart {alignas(hardware_destructive_interference_size) atomic<int> cat; alignas(hardware_destructive_interference_size) atomic<int> dog;}; — *end example*]
[🔗](#lib:hardware_constructive_interference_size)
`inline constexpr size_t hardware_constructive_interference_size = implementation-defined;
`
[2](#hardware.interference-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3239)
This number is the maximum recommended size of contiguous memory
occupied by two objects accessed with temporal locality by concurrent threads[.](#hardware.interference-2.sentence-1)
It shall be at least alignof(max_align_t)[.](#hardware.interference-2.sentence-2)
[*Example [2](#hardware.interference-example-2)*: struct together { atomic<int> dog; int puppy;};struct kennel {// Other data members...alignas(sizeof(together)) together pack; // Other data members...};static_assert(sizeof(together) <= hardware_constructive_interference_size); — *end example*]

View File

@@ -0,0 +1,16 @@
[support.dynamic.general]
# 17 Language support library [[support]](./#support)
## 17.6 Dynamic memory management [[support.dynamic]](support.dynamic#general)
### 17.6.1 General [support.dynamic.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2326)
The header <new> defines several
functions that manage the allocation of dynamic storage in a program[.](#1.sentence-1)
It also defines components for reporting storage management errors[.](#1.sentence-2)

View File

@@ -0,0 +1,566 @@
[support.exception]
# 17 Language support library [[support]](./#support)
## 17.9 Exception handling [support.exception]
### [17.9.1](#general) General [[support.exception.general]](support.exception.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3843)
The header <exception> defines several types and functions related to the handling of exceptions in a C++ program[.](#general-1.sentence-1)
### [17.9.2](#exception.syn) Header <exception> synopsis [[exception.syn]](exception.syn)
// all freestandingnamespace std {class exception; class bad_exception; class nested_exception; using terminate_handler = void (*)();
terminate_handler get_terminate() noexcept;
terminate_handler set_terminate(terminate_handler f) noexcept; [[noreturn]] void terminate() noexcept; constexpr int uncaught_exceptions() noexcept; using exception_ptr = *unspecified*; constexpr exception_ptr current_exception() noexcept; [[noreturn]] constexpr void rethrow_exception(exception_ptr p); template<class E> constexpr exception_ptr make_exception_ptr(E e) noexcept; template<class E> constexpr const E* exception_ptr_cast(const exception_ptr& p) noexcept; template<class E> void exception_ptr_cast(const exception_ptr&&) = delete; template<class T> [[noreturn]] constexpr void throw_with_nested(T&& t); template<class E> constexpr void rethrow_if_nested(const E& e);}
### [17.9.3](#exception) Class exception [[exception]](exception)
[🔗](#lib:exception)
namespace std {class exception {public:constexpr exception() noexcept; constexpr exception(const exception&) noexcept; constexpr exception& operator=(const exception&) noexcept; constexpr virtual ~exception(); constexpr virtual const char* what() const noexcept; };}
[1](#exception-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3893)
The classexception defines the base
class for the types of objects thrown as exceptions by
C++ standard library components, and certain
expressions, to report errors detected during program execution[.](#exception-1.sentence-1)
[2](#exception-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3901)
Except where explicitly specified otherwise,
each standard library class T that derives from class exception has the following publicly accessible member functions, each of them having
a non-throwing exception specification ([[except.spec]](except.spec "14.5Exception specifications")):
- [(2.1)](#exception-2.1)
default constructor (unless the class synopsis shows other constructors)
- [(2.2)](#exception-2.2)
copy constructor
- [(2.3)](#exception-2.3)
copy assignment operator
The copy constructor and the copy assignment operator meet
the following postcondition: If two objects lhs and rhs both have
dynamic type T and lhs is a copy of rhs, thenstrcmp(lhs.what(), rhs.what()) is equal to 0[.](#exception-2.sentence-1)
The what() member function of each such T satisfies the
constraints specified for exception::what() (see below)[.](#exception-2.sentence-2)
[🔗](#lib:exception,constructor_)
`constexpr exception(const exception& rhs) noexcept;
constexpr exception& operator=(const exception& rhs) noexcept;
`
[3](#exception-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3926)
*Postconditions*: If *this and rhs both have dynamic type exception then the value of the expression strcmp(what(), rhs.what()) shall equal 0[.](#exception-3.sentence-1)
[🔗](#lib:exception,destructor)
`constexpr virtual ~exception();
`
[4](#exception-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3938)
*Effects*: Destroys an object of classexception[.](#exception-4.sentence-1)
[🔗](#lib:what,exception)
`constexpr virtual const char* what() const noexcept;
`
[5](#exception-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3950)
*Returns*: An implementation-defined ntbs,
which during constant evaluation is encoded with
the ordinary literal encoding ([[lex.ccon]](lex.ccon "5.13.3Character literals"))[.](#exception-5.sentence-1)
[6](#exception-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3956)
*Remarks*: The message may be a[null-terminated multibyte string](multibyte.strings#def:ntmbs "16.3.3.3.4.3Multibyte strings[multibyte.strings]"),
suitable for conversion and display as awstring ([[string.classes]](string.classes "27.4String classes"), [[locale.codecvt]](locale.codecvt "28.3.4.2.5Class template codecvt"))[.](#exception-6.sentence-1)
The return value remains valid until the exception object from which
it is obtained is destroyed or a non-const member function of the exception object is called[.](#exception-6.sentence-2)
### [17.9.4](#bad.exception) Class bad_exception [[bad.exception]](bad.exception)
[🔗](#lib:bad_exception)
namespace std {class bad_exception : public exception {public:// see [[exception]](#exception "17.9.3Class exception") for the specification of the special member functionsconstexpr const char* what() const noexcept override; };}
[1](#bad.exception-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3981)
The classbad_exception defines the type of the object
referenced by the exception_ptr returned from a call to current_exception ([[propagation]](#propagation "17.9.7Exception propagation"))
when the currently active exception object fails to copy[.](#bad.exception-1.sentence-1)
[🔗](#lib:what,bad_exception)
`constexpr const char* what() const noexcept override;
`
[2](#bad.exception-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3995)
*Returns*: An implementation-defined ntbs[.](#bad.exception-2.sentence-1)
### [17.9.5](#exception.terminate) Abnormal termination [[exception.terminate]](exception.terminate)
#### [17.9.5.1](#terminate.handler) Type terminate_handler [[terminate.handler]](terminate.handler)
[🔗](#lib:terminate_handler)
`using terminate_handler = void (*)();
`
[1](#terminate.handler-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4010)
The type of a [*handler function*](#def:handler_function) to be invoked by terminatewhen terminating exception processing[.](#terminate.handler-1.sentence-1)
[2](#terminate.handler-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4016)
*Required behavior*: A terminate_handler shall
terminate execution of the program without returning to the caller[.](#terminate.handler-2.sentence-1)
[3](#terminate.handler-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4021)
*Default behavior*: The implementation's default terminate_handler callsabort()[.](#terminate.handler-3.sentence-1)
#### [17.9.5.2](#set.terminate) set_terminate [[set.terminate]](set.terminate)
[🔗](#lib:set_terminate)
`terminate_handler set_terminate(terminate_handler f) noexcept;
`
[1](#set.terminate-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4036)
*Effects*: Establishes the function designated by f as the current
handler function for terminating exception processing[.](#set.terminate-1.sentence-1)
[2](#set.terminate-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4041)
*Returns*: The previous terminate_handler[.](#set.terminate-2.sentence-1)
[3](#set.terminate-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4045)
*Remarks*: It is unspecified whether a null pointer value designates the defaultterminate_handler[.](#set.terminate-3.sentence-1)
#### [17.9.5.3](#get.terminate) get_terminate [[get.terminate]](get.terminate)
[🔗](#lib:get_terminate)
`terminate_handler get_terminate() noexcept;
`
[1](#get.terminate-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4059)
*Returns*: The current terminate_handler[.](#get.terminate-1.sentence-1)
[*Note [1](#get.terminate-note-1)*:
This can be a null pointer value[.](#get.terminate-1.sentence-2)
— *end note*]
#### [17.9.5.4](#terminate) terminate [[terminate]](terminate)
[🔗](#lib:terminate_)
`[[noreturn]] void terminate() noexcept;
`
[1](#terminate-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4075)
*Effects*: Calls a terminate_handler function[.](#terminate-1.sentence-1)
It is unspecified whichterminate_handler function will be called if an exception is active
during a call to set_terminate[.](#terminate-1.sentence-2)
Otherwise calls the current terminate_handler function[.](#terminate-1.sentence-3)
[*Note [1](#terminate-note-1)*:
A
default terminate_handler is always considered a callable handler in
this context[.](#terminate-1.sentence-4)
— *end note*]
[2](#terminate-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4087)
*Remarks*: Called by the implementation when exception
handling must be abandoned for any of several reasons ([[except.terminate]](except.terminate "14.6.2The std::terminate function"))[.](#terminate-2.sentence-1)
May also be called directly by the program[.](#terminate-2.sentence-2)
### [17.9.6](#uncaught.exceptions) uncaught_exceptions [[uncaught.exceptions]](uncaught.exceptions)
[🔗](#lib:uncaught_exceptions)
`constexpr int uncaught_exceptions() noexcept;
`
[1](#uncaught.exceptions-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4102)
*Returns*: The number of uncaught exceptions ([[except.throw]](except.throw "14.2Throwing an exception")) in the current thread[.](#uncaught.exceptions-1.sentence-1)
[2](#uncaught.exceptions-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4106)
*Remarks*: When uncaught_exceptions() > 0,
throwing an exception can result in a call of the function[std::terminate](except.terminate "14.6.2The std::terminate function[except.terminate]")[.](#uncaught.exceptions-2.sentence-1)
### [17.9.7](#propagation) Exception propagation [[propagation]](propagation)
[🔗](#lib:exception_ptr)
`using exception_ptr = unspecified;
`
[1](#propagation-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4121)
The type exception_ptr can be used to refer to an exception object[.](#propagation-1.sentence-1)
[2](#propagation-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4124)
exception_ptr meets the requirements of[*Cpp17NullablePointer*](nullablepointer.requirements#:Cpp17NullablePointer "16.4.4.4Cpp17NullablePointer requirements[nullablepointer.requirements]") (Table [36](nullablepointer.requirements#tab:cpp17.nullablepointer "Table 36: Cpp17NullablePointer requirements"))[.](#propagation-2.sentence-1)
[3](#propagation-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4128)
Two non-null values of type exception_ptr are equivalent and compare equal if and
only if they refer to the same exception[.](#propagation-3.sentence-1)
[4](#propagation-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4132)
The default constructor of exception_ptr produces the null value of the
type[.](#propagation-4.sentence-1)
[5](#propagation-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4136)
exception_ptr shall not be implicitly convertible to any arithmetic,
enumeration, or pointer type[.](#propagation-5.sentence-1)
[6](#propagation-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4140)
[*Note [1](#propagation-note-1)*:
An implementation can use a reference-counted smart
pointer as exception_ptr[.](#propagation-6.sentence-1)
— *end note*]
[7](#propagation-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4146)
For purposes of determining the presence of a data race, operations onexception_ptr objects shall access and modify only theexception_ptr objects themselves and not the exceptions they refer to[.](#propagation-7.sentence-1)
Use of rethrow_exception or exception_ptr_cast on exception_ptr objects that refer to
the same exception object shall not introduce a data race[.](#propagation-7.sentence-2)
[*Note [2](#propagation-note-2)*:
Ifrethrow_exception rethrows the same exception object (rather than a copy),
concurrent access to that rethrown exception object can introduce a data race[.](#propagation-7.sentence-3)
Changes in the number of exception_ptr objects that refer to a
particular exception do not introduce a data race[.](#propagation-7.sentence-4)
— *end note*]
[8](#propagation-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4161)
All member functions are marked constexpr[.](#propagation-8.sentence-1)
[🔗](#lib:current_exception)
`constexpr exception_ptr current_exception() noexcept;
`
[9](#propagation-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4171)
*Returns*: An exception_ptr object that refers to the[currently handled exception](except.handle#def:exception_handling,currently_handled_exception "14.4Handling an exception[except.handle]") or a copy of the currently
handled exception, or a null exception_ptr object if no exception is being
handled[.](#propagation-9.sentence-1)
The referenced object shall remain valid at least as long as there is anexception_ptr object that refers to it[.](#propagation-9.sentence-2)
If the function needs to allocate memory and the attempt fails, it returns anexception_ptr object that refers to an instance of bad_alloc[.](#propagation-9.sentence-3)
It is unspecified whether the return values of two successive calls tocurrent_exception refer to the same exception object[.](#propagation-9.sentence-4)
[*Note [3](#propagation-note-3)*:
That is, it is unspecified whether current_exception creates a new copy each time it is called[.](#propagation-9.sentence-5)
— *end note*]
If the attempt to copy the current exception object throws an exception, the function
returns an exception_ptr object that refers to the thrown exception or,
if this is not possible, to an instance of bad_exception[.](#propagation-9.sentence-6)
[*Note [4](#propagation-note-4)*:
The copy constructor of the thrown exception can also fail,
so the implementation can substitute a bad_exception object
to avoid infinite recursion[.](#propagation-9.sentence-7)
— *end note*]
[🔗](#lib:rethrow_exception)
`[[noreturn]] constexpr void rethrow_exception(exception_ptr p);
`
[10](#propagation-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4203)
*Preconditions*: p is not a null pointer[.](#propagation-10.sentence-1)
[11](#propagation-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4207)
*Effects*: Let u be the exception object to which p refers, or
a copy of that exception object[.](#propagation-11.sentence-1)
It is unspecified whether a copy is made, and
memory for the copy is allocated in an unspecified way[.](#propagation-11.sentence-2)
- [(11.1)](#propagation-11.1)
If allocating memory to form u fails,
throws an instance of bad_alloc;
- [(11.2)](#propagation-11.2)
otherwise, if copying the exception to which p refers
to form u throws an exception, throws that exception;
- [(11.3)](#propagation-11.3)
otherwise, throws u.
[🔗](#lib:make_exception_ptr)
`template<class E> constexpr exception_ptr make_exception_ptr(E e) noexcept;
`
[12](#propagation-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4231)
*Effects*: Creates an exception_ptr object that refers to a copy of e, as if:try {throw e;} catch(...) {return current_exception();}
[13](#propagation-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4242)
[*Note [5](#propagation-note-5)*:
This function is provided for convenience and
efficiency reasons[.](#propagation-13.sentence-1)
— *end note*]
[🔗](#lib:exception_ptr_cast)
`template<class E> constexpr const E* exception_ptr_cast(const exception_ptr& p) noexcept;
`
[14](#propagation-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4255)
*Mandates*: E is a cv-unqualified complete object type[.](#propagation-14.sentence-1)
E is not an array type[.](#propagation-14.sentence-2)
E is not a pointer or pointer-to-member type[.](#propagation-14.sentence-3)
[*Note [6](#propagation-note-6)*:
When E is a pointer or pointer-to-member type,
a handler of type const E& can match
without binding to the exception object itself[.](#propagation-14.sentence-4)
— *end note*]
[15](#propagation-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4266)
*Returns*: A pointer to the exception object referred to by p,
if p is not null and
a handler of type const E& would be a match ([[except.handle]](except.handle "14.4Handling an exception")) for that exception object[.](#propagation-15.sentence-1)
Otherwise, nullptr[.](#propagation-15.sentence-2)
### [17.9.8](#except.nested) nested_exception [[except.nested]](except.nested)
[🔗](#lib:nested_exception)
namespace std {class nested_exception {public:constexpr nested_exception() noexcept; constexpr nested_exception(const nested_exception&) noexcept = default; constexpr nested_exception& operator=(const nested_exception&) noexcept = default; constexpr virtual ~nested_exception() = default; // access functions[[noreturn]] constexpr void rethrow_nested() const; constexpr exception_ptr nested_ptr() const noexcept; }; template<class T> [[noreturn]] constexpr void throw_with_nested(T&& t); template<class E> constexpr void rethrow_if_nested(const E& e);}
[1](#except.nested-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4297)
The class nested_exception is designed for use as a mixin through
multiple inheritance[.](#except.nested-1.sentence-1)
It captures the currently handled exception and stores it
for later use[.](#except.nested-1.sentence-2)
[2](#except.nested-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4302)
[*Note [1](#except.nested-note-1)*:
nested_exception has a virtual destructor to make it a
polymorphic class[.](#except.nested-2.sentence-1)
Its presence can be tested for with dynamic_cast[.](#except.nested-2.sentence-2)
— *end note*]
[🔗](#lib:nested_exception,constructor)
`constexpr nested_exception() noexcept;
`
[3](#except.nested-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4314)
*Effects*: The constructor calls current_exception() and stores the returned value[.](#except.nested-3.sentence-1)
[🔗](#lib:rethrow_nested,nested_exception)
`[[noreturn]] constexpr void rethrow_nested() const;
`
[4](#except.nested-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4325)
*Effects*: If nested_ptr() returns a null pointer, the function calls the function std::terminate[.](#except.nested-4.sentence-1)
Otherwise, it throws the stored exception captured by *this[.](#except.nested-4.sentence-2)
[🔗](#lib:nested_ptr,nested_exception)
`constexpr exception_ptr nested_ptr() const noexcept;
`
[5](#except.nested-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4337)
*Returns*: The stored exception captured by this nested_exception object[.](#except.nested-5.sentence-1)
[🔗](#lib:throw_with_nested,nested_exception)
`template<class T> [[noreturn]] constexpr void throw_with_nested(T&& t);
`
[6](#except.nested-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4348)
Let U be decay_t<T>[.](#except.nested-6.sentence-1)
[7](#except.nested-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4351)
*Preconditions*: U meets the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]") requirements[.](#except.nested-7.sentence-1)
[8](#except.nested-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4355)
*Throws*: If is_class_v<U> && !is_final_v<U> && !is_base_of_v<nested_exception, U> is true,
an exception of unspecified type that is publicly derived from bothU and nested_exception and constructed from std::forward<T>(t), otherwisestd::forward<T>(t)[.](#except.nested-8.sentence-1)
[🔗](#lib:rethrow_if_nested,nested_exception)
`template<class E> constexpr void rethrow_if_nested(const E& e);
`
[9](#except.nested-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4371)
*Effects*: If E is not a polymorphic class type, or
if nested_exception is an inaccessible or ambiguous base class of E,
there is no effect[.](#except.nested-9.sentence-1)
Otherwise, performs:if (auto p = dynamic_cast<const nested_exception*>(addressof(e))) p->rethrow_nested();

View File

@@ -0,0 +1,13 @@
[support.exception.general]
# 17 Language support library [[support]](./#support)
## 17.9 Exception handling [[support.exception]](support.exception#general)
### 17.9.1 General [support.exception.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3843)
The header <exception> defines several types and functions related to the handling of exceptions in a C++ program[.](#1.sentence-1)

View File

@@ -0,0 +1,49 @@
[support.general]
# 17 Language support library [[support]](./#support)
## 17.1 General [support.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6)
This Clause describes the function signatures that are called
implicitly, and the types of objects generated implicitly, during the execution
of some C++ programs[.](#1.sentence-1)
It also describes the headers that declare these function
signatures and define any related types[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L13)
The following subclauses describe
common type definitions used throughout the library,
characteristics of the predefined types,
functions supporting start and termination of a C++ program,
support for dynamic memory management,
support for dynamic type identification,
support for contract-violation handling,
support for exception processing, support for initializer lists,
and other runtime support,
as summarized in Table [42](#tab:support.summary "Table 42: Language support library summary")[.](#2.sentence-1)
Table [42](#tab:support.summary) — Language support library summary [[tab:support.summary]](./tab:support.summary)
| [🔗](#tab:support.summary-row-1) | **Subclause** | **Header** |
| --- | --- | --- |
| [🔗](#tab:support.summary-row-2)<br>[[support.types]](support.types "17.2Common definitions") | Common definitions | <cstddef>, <cstdlib> |
| [🔗](#tab:support.summary-row-3)<br>[[support.limits]](support.limits "17.3Implementation properties") | Implementation properties | <cfloat>, <climits>, <limits>, <version> |
| [🔗](#tab:support.summary-row-4)<br>[[support.arith.types]](support.arith.types "17.4Arithmetic types") | Arithmetic types | <cstdint>, <stdfloat> |
| [🔗](#tab:support.summary-row-5)<br>[[support.start.term]](support.start.term "17.5Startup and termination") | Start and termination | <cstdlib> |
| [🔗](#tab:support.summary-row-6)<br>[[support.dynamic]](support.dynamic "17.6Dynamic memory management") | Dynamic memory management | <new> |
| [🔗](#tab:support.summary-row-7)<br>[[support.rtti]](support.rtti "17.7Type identification") | Type identification | <typeinfo>, <typeindex> |
| [🔗](#tab:support.summary-row-8)<br>[[support.srcloc]](support.srcloc "17.8Source location") | Source location | <source_location> |
| [🔗](#tab:support.summary-row-9)<br>[[support.exception]](support.exception "17.9Exception handling") | Exception handling | <exception> |
| [🔗](#tab:support.summary-row-10)<br>[[support.contract]](support.contract "17.10Contract-violation handling") | Contract-violation handling | <contracts> |
| [🔗](#tab:support.summary-row-11)<br>[[support.initlist]](support.initlist "17.11Initializer lists") | Initializer lists | <initializer_list> |
| [🔗](#tab:support.summary-row-12)<br>[[cmp]](cmp "17.12Comparisons") | Comparisons | <compare> |
| [🔗](#tab:support.summary-row-13)<br>[[support.coroutine]](support.coroutine "17.13Coroutines") | Coroutines | <coroutine> |
| [🔗](#tab:support.summary-row-14)<br>[[support.runtime]](support.runtime "17.14Other runtime support") | Other runtime support | <csetjmp>, <csignal>, <cstdarg>, <cstdlib> |

View File

@@ -0,0 +1,128 @@
[support.initlist]
# 17 Language support library [[support]](./#support)
## 17.11 Initializer lists [support.initlist]
### [17.11.1](#general) General [[support.initlist.general]](support.initlist.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4649)
The header <initializer_list> defines a class template and several
support functions related to list-initialization (see [[dcl.init.list]](dcl.init.list "9.5.5List-initialization"))[.](#general-1.sentence-1)
All functions specified in [support.initlist] are signal-safe ([[support.signal]](support.signal "17.14.5Signal handlers"))[.](#general-1.sentence-2)
### [17.11.2](#initializer.list.syn) Header <initializer_list> synopsis [[initializer.list.syn]](initializer.list.syn)
// all freestandingnamespace std {template<class E> class initializer_list {public:using value_type = E; using reference = const E&; using const_reference = const E&; using size_type = size_t; using iterator = const E*; using const_iterator = const E*; constexpr initializer_list() noexcept; constexpr size_t size() const noexcept; // number of elementsconstexpr const E* begin() const noexcept; // first elementconstexpr const E* end() const noexcept; // one past the last element}; // [[support.initlist.range]](#range "17.11.5Initializer list range access"), initializer list range accesstemplate<class E> constexpr const E* begin(initializer_list<E> il) noexcept; template<class E> constexpr const E* end(initializer_list<E> il) noexcept;}
[1](#initializer.list.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4686)
An object of type initializer_list<E> provides access to an array of
objects of type const E[.](#initializer.list.syn-1.sentence-1)
[*Note [1](#initializer.list.syn-note-1)*:
A pair of pointers or a pointer plus
a length would be obvious representations for initializer_list[.](#initializer.list.syn-1.sentence-2)
initializer_list is used to implement initializer lists as specified
in [[dcl.init.list]](dcl.init.list "9.5.5List-initialization")[.](#initializer.list.syn-1.sentence-3)
Copying an initializer_list does not copy the underlying
elements[.](#initializer.list.syn-1.sentence-4)
— *end note*]
[2](#initializer.list.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4697)
If an explicit specialization or partial specialization ofinitializer_list is declared, the program is ill-formed[.](#initializer.list.syn-2.sentence-1)
### [17.11.3](#cons) Initializer list constructors [[support.initlist.cons]](support.initlist.cons)
[🔗](#lib:initializer_list,constructor)
`constexpr initializer_list() noexcept;
`
[1](#cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4709)
*Postconditions*: size() == 0[.](#cons-1.sentence-1)
### [17.11.4](#access) Initializer list access [[support.initlist.access]](support.initlist.access)
[🔗](#lib:begin,initializer_list)
`constexpr const E* begin() const noexcept;
`
[1](#access-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4722)
*Returns*: A pointer to the beginning of the array[.](#access-1.sentence-1)
If size() == 0 the
values of begin() and end() are unspecified but they shall be
identical[.](#access-1.sentence-2)
[🔗](#lib:end,initializer_list)
`constexpr const E* end() const noexcept;
`
[2](#access-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4735)
*Returns*: begin() + size()[.](#access-2.sentence-1)
[🔗](#lib:size,initializer_list)
`constexpr size_t size() const noexcept;
`
[3](#access-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4746)
*Returns*: The number of elements in the array[.](#access-3.sentence-1)
[4](#access-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4750)
*Complexity*: Constant time[.](#access-4.sentence-1)
### [17.11.5](#range) Initializer list range access [[support.initlist.range]](support.initlist.range)
[🔗](#lib:begin(initializer_list%3cE%3e))
`template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
`
[1](#range-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4763)
*Returns*: il.begin()[.](#range-1.sentence-1)
[🔗](#lib:end(initializer_list%3cE%3e))
`template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
`
[2](#range-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4774)
*Returns*: il.end()[.](#range-2.sentence-1)

View File

@@ -0,0 +1,50 @@
[support.initlist.access]
# 17 Language support library [[support]](./#support)
## 17.11 Initializer lists [[support.initlist]](support.initlist#access)
### 17.11.4 Initializer list access [support.initlist.access]
[🔗](#lib:begin,initializer_list)
`constexpr const E* begin() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4722)
*Returns*: A pointer to the beginning of the array[.](#1.sentence-1)
If size() == 0 the
values of begin() and end() are unspecified but they shall be
identical[.](#1.sentence-2)
[🔗](#lib:end,initializer_list)
`constexpr const E* end() const noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4735)
*Returns*: begin() + size()[.](#2.sentence-1)
[🔗](#lib:size,initializer_list)
`constexpr size_t size() const noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4746)
*Returns*: The number of elements in the array[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4750)
*Complexity*: Constant time[.](#4.sentence-1)

View File

@@ -0,0 +1,18 @@
[support.initlist.cons]
# 17 Language support library [[support]](./#support)
## 17.11 Initializer lists [[support.initlist]](support.initlist#cons)
### 17.11.3 Initializer list constructors [support.initlist.cons]
[🔗](#lib:initializer_list,constructor)
`constexpr initializer_list() noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4709)
*Postconditions*: size() == 0[.](#1.sentence-1)

View File

@@ -0,0 +1,16 @@
[support.initlist.general]
# 17 Language support library [[support]](./#support)
## 17.11 Initializer lists [[support.initlist]](support.initlist#general)
### 17.11.1 General [support.initlist.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4649)
The header <initializer_list> defines a class template and several
support functions related to list-initialization (see [[dcl.init.list]](dcl.init.list "9.5.5List-initialization"))[.](#1.sentence-1)
All functions specified in [[support.initlist]](support.initlist "17.11Initializer lists") are signal-safe ([[support.signal]](support.signal "17.14.5Signal handlers"))[.](#1.sentence-2)

View File

@@ -0,0 +1,29 @@
[support.initlist.range]
# 17 Language support library [[support]](./#support)
## 17.11 Initializer lists [[support.initlist]](support.initlist#range)
### 17.11.5 Initializer list range access [support.initlist.range]
[🔗](#lib:begin(initializer_list%3cE%3e))
`template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4763)
*Returns*: il.begin()[.](#1.sentence-1)
[🔗](#lib:end(initializer_list%3cE%3e))
`template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4774)
*Returns*: il.end()[.](#2.sentence-1)

947
cppdraft/support/limits.md Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
[support.limits.general]
# 17 Language support library [[support]](./#support)
## 17.3 Implementation properties [[support.limits]](support.limits#general)
### 17.3.1 General [support.limits.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L527)
The headers[<limits>](limits.syn#header:%3climits%3e "17.3.3Header <limits> synopsis[limits.syn]"),[<climits>](climits.syn#header:%3cclimits%3e "17.3.6Header <climits> synopsis[climits.syn]"), and[<cfloat>](cfloat.syn#header:%3ccfloat%3e "17.3.7Header <cfloat> synopsis[cfloat.syn]") supply characteristics ofimplementation-dependent
arithmetic types ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))[.](#1.sentence-1)

298
cppdraft/support/rtti.md Normal file
View File

@@ -0,0 +1,298 @@
[support.rtti]
# 17 Language support library [[support]](./#support)
## 17.7 Type identification [support.rtti]
### [17.7.1](#general) General [[support.rtti.general]](support.rtti.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3264)
The header [<typeinfo>](#header:%3ctypeinfo%3e "17.7.2Header <typeinfo> synopsis[typeinfo.syn]") defines a
type associated with type information generated by the implementation[.](#general-1.sentence-1)
It also defines two types for reporting dynamic type identification errors[.](#general-1.sentence-2)
The header [<typeindex>](#header:%3ctypeindex%3e "17.7.6Header <typeindex> synopsis[type.index.synopsis]") defines
a wrapper type for use as an index type in associative containers ([[associative]](associative "23.4Associative containers"))
and in unordered associative containers ([[unord]](unord "23.5Unordered associative containers"))[.](#general-1.sentence-3)
### [17.7.2](#typeinfo.syn) Header <typeinfo> synopsis [[typeinfo.syn]](typeinfo.syn)
[🔗](#header:%3ctypeinfo%3e)
// all freestandingnamespace std {class type_info; class bad_cast; class bad_typeid;}
### [17.7.3](#type.info) Class type_info [[type.info]](type.info)
[🔗](#lib:type_info_)
namespace std {class type_info {public:virtual ~type_info(); constexpr bool operator==(const type_info& rhs) const noexcept; bool before(const type_info& rhs) const noexcept;
size_t hash_code() const noexcept; const char* name() const noexcept;
type_info(const type_info&) = delete;
type_info& operator=(const type_info&) = delete; };}
[1](#type.info-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3306)
The classtype_info describes type information generated by the implementation ([[expr.typeid]](expr.typeid "7.6.1.8Type identification"))[.](#type.info-1.sentence-1)
Objects of this class effectively store a pointer to a name for the type, and
an encoded value suitable for comparing two types for equality or collating order[.](#type.info-1.sentence-2)
The names, encoding rule, and collating sequence for types are all unspecifiedand may differ between programs[.](#type.info-1.sentence-3)
[🔗](#lib:operator==,type_info)
`constexpr bool operator==(const type_info& rhs) const noexcept;
`
[2](#type.info-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3322)
*Effects*: Compares the current object with rhs[.](#type.info-2.sentence-1)
[3](#type.info-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3326)
*Returns*: true if the two values describe the same type[.](#type.info-3.sentence-1)
[🔗](#lib:before,type_info)
`bool before(const type_info& rhs) const noexcept;
`
[4](#type.info-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3338)
*Effects*: Compares the current object with rhs[.](#type.info-4.sentence-1)
[5](#type.info-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3342)
*Returns*: true if*this precedes rhs in the implementation's collation order[.](#type.info-5.sentence-1)
[🔗](#lib:hash_code,type_info)
`size_t hash_code() const noexcept;
`
[6](#type.info-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3356)
*Returns*: An unspecified value, except that within a single execution of the
program, it shall return the same value for any two type_info objects which compare equal[.](#type.info-6.sentence-1)
[7](#type.info-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3362)
*Remarks*: An implementation should return different values for twotype_info objects which do not compare equal[.](#type.info-7.sentence-1)
[🔗](#lib:name,type_info)
`const char* name() const noexcept;
`
[8](#type.info-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3375)
*Returns*: An implementation-defined ntbs[.](#type.info-8.sentence-1)
[9](#type.info-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3379)
*Remarks*: The message may be a[null-terminated multibyte string](multibyte.strings#def:ntmbs "16.3.3.3.4.3Multibyte strings[multibyte.strings]"),
suitable for conversion and display as awstring ([[string.classes]](string.classes "27.4String classes"), [[locale.codecvt]](locale.codecvt "28.3.4.2.5Class template codecvt"))[.](#type.info-9.sentence-1)
### [17.7.4](#bad.cast) Class bad_cast [[bad.cast]](bad.cast)
[🔗](#lib:bad_cast_)
namespace std {class bad_cast : public exception {public:// see [[exception]](exception "17.9.3Class exception") for the specification of the special member functionsconstexpr const char* what() const noexcept override; };}
[1](#bad.cast-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3401)
The classbad_cast defines the type of objects thrown
as exceptions by the implementation to report the execution of an invaliddynamic_cast expression ([[expr.dynamic.cast]](expr.dynamic.cast "7.6.1.7Dynamic cast"))[.](#bad.cast-1.sentence-1)
[🔗](#lib:what,bad_cast)
`constexpr const char* what() const noexcept override;
`
[2](#bad.cast-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3416)
*Returns*: An implementation-defined ntbs[.](#bad.cast-2.sentence-1)
### [17.7.5](#bad.typeid) Class bad_typeid [[bad.typeid]](bad.typeid)
[🔗](#lib:bad_typeid_)
namespace std {class bad_typeid : public exception {public:// see [[exception]](exception "17.9.3Class exception") for the specification of the special member functionsconstexpr const char* what() const noexcept override; };}
[1](#bad.typeid-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3435)
The classbad_typeid defines the type of objects
thrown as exceptions by the implementation to report a null pointer
in atypeid expression ([[expr.typeid]](expr.typeid "7.6.1.8Type identification"))[.](#bad.typeid-1.sentence-1)
[🔗](#lib:what,bad_typeid)
`constexpr const char* what() const noexcept override;
`
[2](#bad.typeid-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3450)
*Returns*: An implementation-defined ntbs[.](#bad.typeid-2.sentence-1)
### [17.7.6](#type.index.synopsis) Header <typeindex> synopsis [[type.index.synopsis]](type.index.synopsis)
[🔗](#header:%3ctypeindex%3e)
#include <compare> // see [[compare.syn]](compare.syn "17.12.1Header <compare> synopsis")namespace std {class type_index; template<class T> struct hash; template<> struct hash<type_index>;}
### [17.7.7](#type.index) Class type_index [[type.index]](type.index)
[🔗](#lib:type_index)
namespace std {class type_index {public: type_index(const type_info& rhs) noexcept; bool operator==(const type_index& rhs) const noexcept; bool operator< (const type_index& rhs) const noexcept; bool operator> (const type_index& rhs) const noexcept; bool operator<=(const type_index& rhs) const noexcept; bool operator>=(const type_index& rhs) const noexcept;
strong_ordering operator<=>(const type_index& rhs) const noexcept;
size_t hash_code() const noexcept; const char* name() const noexcept; private:const type_info* target; // *exposition only*// Note that the use of a pointer here, rather than a reference,// means that the default copy/move constructor and assignment// operators will be provided and work as expected.};}
[1](#type.index-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3494)
The class type_index provides a simple wrapper fortype_info which can be used as an index type in associative
containers ([[associative]](associative "23.4Associative containers")) and in unordered associative
containers ([[unord]](unord "23.5Unordered associative containers"))[.](#type.index-1.sentence-1)
[🔗](#lib:type_index,constructor)
`type_index(const type_info& rhs) noexcept;
`
[2](#type.index-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3506)
*Effects*: Constructs a type_index object, the equivalent of target = &rhs[.](#type.index-2.sentence-1)
[🔗](#lib:operator==,type_index)
`bool operator==(const type_index& rhs) const noexcept;
`
[3](#type.index-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3517)
*Returns*: *target == *rhs.target[.](#type.index-3.sentence-1)
[🔗](#lib:operator%3c,type_index)
`bool operator<(const type_index& rhs) const noexcept;
`
[4](#type.index-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3528)
*Returns*: target->before(*rhs.target)[.](#type.index-4.sentence-1)
[🔗](#lib:operator%3e,type_index)
`bool operator>(const type_index& rhs) const noexcept;
`
[5](#type.index-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3539)
*Returns*: rhs.target->before(*target)[.](#type.index-5.sentence-1)
[🔗](#lib:operator%3c=,type_index)
`bool operator<=(const type_index& rhs) const noexcept;
`
[6](#type.index-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3550)
*Returns*: !rhs.target->before(*target)[.](#type.index-6.sentence-1)
[🔗](#lib:operator%3e=,type_index)
`bool operator>=(const type_index& rhs) const noexcept;
`
[7](#type.index-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3561)
*Returns*: !target->before(*rhs.target)[.](#type.index-7.sentence-1)
[🔗](#lib:operator%3c=%3e,type_index)
`strong_ordering operator<=>(const type_index& rhs) const noexcept;
`
[8](#type.index-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3572)
*Effects*: Equivalent to:if (*target == *rhs.target) return strong_ordering::equal;if (target->before(*rhs.target)) return strong_ordering::less;return strong_ordering::greater;
[🔗](#lib:hash_code,type_index)
`size_t hash_code() const noexcept;
`
[9](#type.index-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3588)
*Returns*: target->hash_code()[.](#type.index-9.sentence-1)
[🔗](#lib:name,type_index)
`const char* name() const noexcept;
`
[10](#type.index-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3599)
*Returns*: target->name()[.](#type.index-10.sentence-1)
[🔗](#lib:hash,type_index)
`template<> struct hash<type_index>;
`
[11](#type.index-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3610)
For an object index of type type_index,hash<type_index>()(index) shall evaluate to the same result as index.hash_code()[.](#type.index-11.sentence-1)

View File

@@ -0,0 +1,20 @@
[support.rtti.general]
# 17 Language support library [[support]](./#support)
## 17.7 Type identification [[support.rtti]](support.rtti#general)
### 17.7.1 General [support.rtti.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3264)
The header [<typeinfo>](typeinfo.syn#header:%3ctypeinfo%3e "17.7.2Header <typeinfo> synopsis[typeinfo.syn]") defines a
type associated with type information generated by the implementation[.](#1.sentence-1)
It also defines two types for reporting dynamic type identification errors[.](#1.sentence-2)
The header [<typeindex>](type.index.synopsis#header:%3ctypeindex%3e "17.7.6Header <typeindex> synopsis[type.index.synopsis]") defines
a wrapper type for use as an index type in associative containers ([[associative]](associative "23.4Associative containers"))
and in unordered associative containers ([[unord]](unord "23.5Unordered associative containers"))[.](#1.sentence-3)

214
cppdraft/support/runtime.md Normal file
View File

@@ -0,0 +1,214 @@
[support.runtime]
# 17 Language support library [[support]](./#support)
## 17.14 Other runtime support [support.runtime]
### [17.14.1](#general) General [[support.runtime.general]](support.runtime.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6346)
Headers[<csetjmp>](#header:%3ccsetjmp%3e "17.14.3Header <csetjmp> synopsis[csetjmp.syn]") (nonlocal jumps),[<csignal>](#header:%3ccsignal%3e "17.14.4Header <csignal> synopsis[csignal.syn]") (signal handling),[<cstdarg>](#header:%3ccstdarg%3e "17.14.2Header <cstdarg> synopsis[cstdarg.syn]") (variable arguments),
and[<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") (runtime environment getenv, system),
provide further compatibility with C code[.](#general-1.sentence-1)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6357)
Calls to the functiongetenv ([[cstdlib.syn]](cstdlib.syn "17.2.2Header <cstdlib> synopsis")) shall not introduce a data
race ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance")) provided that nothing modifies the environment[.](#general-2.sentence-1)
[*Note [1](#general-note-1)*:
Calls to the POSIX functionssetenv andputenv modify the
environment[.](#general-2.sentence-2)
— *end note*]
[3](#general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6371)
A call to the [setlocale](clocale.syn#lib:setlocale "28.3.5.1Header <clocale> synopsis[clocale.syn]") function
may introduce a data race with other
calls to the setlocale function or with calls to functions that are
affected by the current C locale[.](#general-3.sentence-1)
The implementation shall behave as if no
library function other than locale::global calls the setlocale function[.](#general-3.sentence-2)
### [17.14.2](#cstdarg.syn) Header <cstdarg> synopsis [[cstdarg.syn]](cstdarg.syn)
[🔗](#header:%3ccstdarg%3e)
// all freestanding#define __STDC_VERSION_STDARG_H__ 202311Lnamespace std {using [va_list](#lib:va_list "17.14.2Header <cstdarg> synopsis[cstdarg.syn]") = *see below*;}#define va_arg(V, P) *see below*#define va_copy(VDST, VSRC) *see below*#define va_end(V) *see below*#define va_start(V, ...) *see below*
[1](#cstdarg.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6396)
The contents of the header <cstdarg> are the same as the C
standard library header [<stdarg.h>](support.c.headers.general#header:%3cstdarg.h%3e "17.15.1General[support.c.headers.general]"), with the following changes:
- [(1.1)](#cstdarg.syn-1.1)
In lieu of the default argument promotions specified in ISO/IEC 9899:2024 6.5.2.2,
the definition in [[expr.call]](expr.call "7.6.1.3Function call") applies[.](#cstdarg.syn-1.1.sentence-1)
- [(1.2)](#cstdarg.syn-1.2)
The preprocessing tokens
comprising the second and subsequent arguments to va_start (if any)
are discarded[.](#cstdarg.syn-1.2.sentence-1)
[*Note [1](#cstdarg.syn-note-1)*:
va_start accepts a second argument
for compatibility with prior revisions of C++[.](#cstdarg.syn-1.2.sentence-2)
— *end note*]
See also: ISO/IEC 9899:2024, 7.16
### [17.14.3](#csetjmp.syn) Header <csetjmp> synopsis [[csetjmp.syn]](csetjmp.syn)
[🔗](#lib:jmp_buf)
#define __STDC_VERSION_SETJMP_H__ 202311Lnamespace std {using jmp_buf = *see below*; [[noreturn]] void longjmp(jmp_buf env, int val);}#define setjmp(env) *see below*
[1](#csetjmp.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6431)
The contents of the header <csetjmp> are the same as the C
standard library header [<setjmp.h>](support.c.headers.general#header:%3csetjmp.h%3e "17.15.1General[support.c.headers.general]")[.](#csetjmp.syn-1.sentence-1)
[2](#csetjmp.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6435)
The function signaturelongjmp(jmp_buf jbuf, int val) has more restricted behavior in this document[.](#csetjmp.syn-2.sentence-1)
A setjmp/longjmp call pair has undefined
behavior if replacing the setjmp and longjmp by catch and throw would invoke any non-trivial destructors for any objects
with automatic storage duration[.](#csetjmp.syn-2.sentence-2)
A call to setjmp or longjmp has undefined
behavior if invoked in a suspension context of a coroutine ([[expr.await]](expr.await "7.6.2.4Await"))[.](#csetjmp.syn-2.sentence-3)
See also: ISO/IEC 9899:2024, 7.13
### [17.14.4](#csignal.syn) Header <csignal> synopsis [[csignal.syn]](csignal.syn)
[🔗](#lib:sig_atomic_t)
namespace std {using sig_atomic_t = *see below*; // [[support.signal]](#support.signal "17.14.5Signal handlers"), signal handlersextern "C" using *signal-handler* = void(int); // *exposition only**signal-handler** signal(int sig, *signal-handler** func); int raise(int sig);}#define SIG_DFL *see below*#define SIG_ERR *see below*#define SIG_IGN *see below*#define SIGABRT *see below*#define SIGFPE *see below*#define SIGILL *see below*#define SIGINT *see below*#define SIGSEGV *see below*#define SIGTERM *see below*
[1](#csignal.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6485)
The contents of the header <csignal> are the same as the C
standard library header [<signal.h>](support.c.headers.general#header:%3csignal.h%3e "17.15.1General[support.c.headers.general]")[.](#csignal.syn-1.sentence-1)
### [17.14.5](#support.signal) Signal handlers [[support.signal]](support.signal)
[1](#support.signal-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6491)
A call to the function signal synchronizes with any resulting
invocation of the signal handler so installed[.](#support.signal-1.sentence-1)
[2](#support.signal-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6495)
A [*plain lock-free atomic operation*](#def:plain_lock-free_atomic_operation "17.14.5Signal handlers[support.signal]") is
an invocation of a function f from [[atomics]](atomics "32.5Atomic operations"),
such that:
- [(2.1)](#support.signal-2.1)
f is the function atomic_is_lock_free(), or
- [(2.2)](#support.signal-2.2)
f is the member function is_lock_free(), or
- [(2.3)](#support.signal-2.3)
f is a non-static member function of class atomic_flag, or
- [(2.4)](#support.signal-2.4)
f is a non-member function, and
the first parameter of f has type cv atomic_flag*, or
- [(2.5)](#support.signal-2.5)
f is a non-static member function invoked on an object A,
such that A.is_lock_free() yields true, or
- [(2.6)](#support.signal-2.6)
f is a non-member function, and
for every pointer-to-atomic argument A passed to f,atomic_is_lock_free(A) yields true[.](#support.signal-2.sentence-1)
[3](#support.signal-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6523)
An evaluation is [*signal-safe*](#def:evaluation,signal-safe "17.14.5Signal handlers[support.signal]") unless it includes one of the following:
- [(3.1)](#support.signal-3.1)
a call to any standard library function,
except for plain lock-free atomic operations and
functions explicitly identified as signal-safe;
[*Note [1](#support.signal-note-1)*:
This implicitly excludes the use of new and delete expressions
that rely on a library-provided memory allocator[.](#support.signal-3.1.sentence-1)
— *end note*]
- [(3.2)](#support.signal-3.2)
an access to an object with thread storage duration;
- [(3.3)](#support.signal-3.3)
a dynamic_cast expression;
- [(3.4)](#support.signal-3.4)
throwing of an exception;
- [(3.5)](#support.signal-3.5)
control entering a [*try-block*](except.pre#nt:try-block "14.1Preamble[except.pre]") or [*function-try-block*](except.pre#nt:function-try-block "14.1Preamble[except.pre]");
- [(3.6)](#support.signal-3.6)
initialization of a variable with static storage duration
requiring dynamic initialization ([[basic.start.dynamic]](basic.start.dynamic "6.10.3.3Dynamic initialization of non-block variables"), [[stmt.dcl]](stmt.dcl "8.10Declaration statement"))[191](#footnote-191 "Such initialization can occur because it is the first odr-use ([term.odr.use]) of that variable.") ; or
- [(3.7)](#support.signal-3.7)
waiting for the completion of the initialization of a variable with static storage duration ([[stmt.dcl]](stmt.dcl "8.10Declaration statement"))[.](#support.signal-3.sentence-1)
A signal handler invocation has undefined behavior if it includes
an evaluation that is not signal-safe[.](#support.signal-3.sentence-2)
[4](#support.signal-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6563)
The function signal is signal-safe if it is invoked
with the first argument equal to the signal number
corresponding to the signal that caused the invocation of the handler[.](#support.signal-4.sentence-1)
See also: ISO/IEC 9899:2024, 7.14
[191)](#footnote-191)[191)](#footnoteref-191)
Such initialization can occur because it is the first odr-use ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3One-definition rule")) of that variable[.](#footnote-191.sentence-1)

View File

@@ -0,0 +1,41 @@
[support.runtime.general]
# 17 Language support library [[support]](./#support)
## 17.14 Other runtime support [[support.runtime]](support.runtime#general)
### 17.14.1 General [support.runtime.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6346)
Headers[<csetjmp>](csetjmp.syn#header:%3ccsetjmp%3e "17.14.3Header <csetjmp> synopsis[csetjmp.syn]") (nonlocal jumps),[<csignal>](csignal.syn#header:%3ccsignal%3e "17.14.4Header <csignal> synopsis[csignal.syn]") (signal handling),[<cstdarg>](cstdarg.syn#header:%3ccstdarg%3e "17.14.2Header <cstdarg> synopsis[cstdarg.syn]") (variable arguments),
and[<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") (runtime environment getenv, system),
provide further compatibility with C code[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6357)
Calls to the functiongetenv ([[cstdlib.syn]](cstdlib.syn "17.2.2Header <cstdlib> synopsis")) shall not introduce a data
race ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance")) provided that nothing modifies the environment[.](#2.sentence-1)
[*Note [1](#note-1)*:
Calls to the POSIX functionssetenv andputenv modify the
environment[.](#2.sentence-2)
— *end note*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6371)
A call to the [setlocale](clocale.syn#lib:setlocale "28.3.5.1Header <clocale> synopsis[clocale.syn]") function
may introduce a data race with other
calls to the setlocale function or with calls to functions that are
affected by the current C locale[.](#3.sentence-1)
The implementation shall behave as if no
library function other than locale::global calls the setlocale function[.](#3.sentence-2)

107
cppdraft/support/signal.md Normal file
View File

@@ -0,0 +1,107 @@
[support.signal]
# 17 Language support library [[support]](./#support)
## 17.14 Other runtime support [[support.runtime]](support.runtime#support.signal)
### 17.14.5 Signal handlers [support.signal]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6491)
A call to the function signal synchronizes with any resulting
invocation of the signal handler so installed[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6495)
A [*plain lock-free atomic operation*](#def:plain_lock-free_atomic_operation "17.14.5Signal handlers[support.signal]") is
an invocation of a function f from [[atomics]](atomics "32.5Atomic operations"),
such that:
- [(2.1)](#2.1)
f is the function atomic_is_lock_free(), or
- [(2.2)](#2.2)
f is the member function is_lock_free(), or
- [(2.3)](#2.3)
f is a non-static member function of class atomic_flag, or
- [(2.4)](#2.4)
f is a non-member function, and
the first parameter of f has type cv atomic_flag*, or
- [(2.5)](#2.5)
f is a non-static member function invoked on an object A,
such that A.is_lock_free() yields true, or
- [(2.6)](#2.6)
f is a non-member function, and
for every pointer-to-atomic argument A passed to f,atomic_is_lock_free(A) yields true[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6523)
An evaluation is [*signal-safe*](#def:evaluation,signal-safe "17.14.5Signal handlers[support.signal]") unless it includes one of the following:
- [(3.1)](#3.1)
a call to any standard library function,
except for plain lock-free atomic operations and
functions explicitly identified as signal-safe;
[*Note [1](#note-1)*:
This implicitly excludes the use of new and delete expressions
that rely on a library-provided memory allocator[.](#3.1.sentence-1)
— *end note*]
- [(3.2)](#3.2)
an access to an object with thread storage duration;
- [(3.3)](#3.3)
a dynamic_cast expression;
- [(3.4)](#3.4)
throwing of an exception;
- [(3.5)](#3.5)
control entering a [*try-block*](except.pre#nt:try-block "14.1Preamble[except.pre]") or [*function-try-block*](except.pre#nt:function-try-block "14.1Preamble[except.pre]");
- [(3.6)](#3.6)
initialization of a variable with static storage duration
requiring dynamic initialization ([[basic.start.dynamic]](basic.start.dynamic "6.10.3.3Dynamic initialization of non-block variables"), [[stmt.dcl]](stmt.dcl "8.10Declaration statement"))[191](#footnote-191 "Such initialization can occur because it is the first odr-use ([term.odr.use]) of that variable.") ; or
- [(3.7)](#3.7)
waiting for the completion of the initialization of a variable with static storage duration ([[stmt.dcl]](stmt.dcl "8.10Declaration statement"))[.](#3.sentence-1)
A signal handler invocation has undefined behavior if it includes
an evaluation that is not signal-safe[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6563)
The function signal is signal-safe if it is invoked
with the first argument equal to the signal number
corresponding to the signal that caused the invocation of the handler[.](#4.sentence-1)
See also: ISO/IEC 9899:2024, 7.14
[191)](#footnote-191)[191)](#footnoteref-191)
Such initialization can occur because it is the first odr-use ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3One-definition rule")) of that variable[.](#footnote-191.sentence-1)

207
cppdraft/support/srcloc.md Normal file
View File

@@ -0,0 +1,207 @@
[support.srcloc]
# 17 Language support library [[support]](./#support)
## 17.8 Source location [support.srcloc]
### [17.8.1](#source.location.syn) Header <source_location> synopsis [[source.location.syn]](source.location.syn)
[1](#source.location.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3619)
The header <source_location> defines
the class source_location that provides a means to obtain source location information[.](#source.location.syn-1.sentence-1)
// all freestandingnamespace std {struct source_location;}
### [17.8.2](#class) Class source_location [[support.srcloc.class]](support.srcloc.class)
#### [17.8.2.1](#class.general) General [[support.srcloc.class.general]](support.srcloc.class.general)
[🔗](#lib:source_location)
namespace std {struct source_location {// source location constructionstatic consteval source_location current() noexcept; constexpr source_location() noexcept; // source location field accessconstexpr uint_least32_t line() const noexcept; constexpr uint_least32_t column() const noexcept; constexpr const char* file_name() const noexcept; constexpr const char* function_name() const noexcept; private: uint_least32_t line_; // *exposition only* uint_least32_t column_; // *exposition only*const char* file_name_; // *exposition only*const char* function_name_; // *exposition only*};}
[1](#class.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3658)
The type source_location meets the[*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17Swappable*](swappable.requirements#:Cpp17Swappable "16.4.4.3Swappable requirements[swappable.requirements]"), and[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2Template argument requirements[utility.arg.requirements]") requirements ([[utility.arg.requirements]](utility.arg.requirements "16.4.4.2Template argument requirements"), [[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements"))[.](#class.general-1.sentence-1)
All of the following conditions are true:
- [(1.1)](#class.general-1.1)
is_nothrow_move_constructible_v<source_location>
- [(1.2)](#class.general-1.2)
is_nothrow_move_assignable_v<source_location>
- [(1.3)](#class.general-1.3)
is_nothrow_swappable_v<source_location>
[*Note [1](#class.general-note-1)*:
The intent of source_location is
to have a small size and efficient copying[.](#class.general-1.sentence-2)
It is unspecified
whether the copy/move constructors and the copy/move assignment operators
are trivial and/or constexpr[.](#class.general-1.sentence-3)
— *end note*]
[2](#class.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3680)
The data members file_name_ and function_name_ always each refer to an ntbs[.](#class.general-2.sentence-1)
[3](#class.general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3684)
The copy/move constructors and the copy/move assignment operators ofsource_location meet the following postconditions:
Given two objects lhs and rhs of type source_location,
where lhs is a copy/move result of rhs, and
where rhs_p is a value denoting the state of rhs before the corresponding copy/move operation,
then each of the following conditions is true:
- [(3.1)](#class.general-3.1)
strcmp(lhs.file_name(), rhs_p.file_name()) == 0
- [(3.2)](#class.general-3.2)
strcmp(lhs.function_name(), rhs_p.function_name()) == 0
- [(3.3)](#class.general-3.3)
lhs.line() == rhs_p.line()
- [(3.4)](#class.general-3.4)
lhs.column() == rhs_p.column()
#### [17.8.2.2](#cons) Creation [[support.srcloc.cons]](support.srcloc.cons)
[🔗](#cons-itemdecl:1)
`static consteval source_location current() noexcept;
`
[1](#cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3705)
*Returns*:
- [(1.1)](#cons-1.1)
When invoked by a function call
whose [*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1General[expr.post.general]") is
a (possibly parenthesized) [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]") naming current,
returns a source_location with an implementation-defined value[.](#cons-1.1.sentence-1)
The value should be affected by #line ([[cpp.line]](cpp.line "15.8Line control"))
in the same manner as for __LINE__ and __FILE__[.](#cons-1.1.sentence-2)
The values of the exposition-only data members
of the returned source_location object
are indicated in Table [43](#tab:support.srcloc.current "Table 43: Value of object returned by current")[.](#cons-1.1.sentence-3)
Table [43](#tab:support.srcloc.current) — Value of object returned by current [[tab:support.srcloc.current]](./tab:support.srcloc.current)
| [🔗](#tab:support.srcloc.current-row-1)<br> **Element** | **Value** |
| --- | --- |
| [🔗](#tab:support.srcloc.current-row-2)<br> line_ | A presumed line number ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names"))[.](#tab:support.srcloc.current-row-2-column-2-sentence-1)<br>Line numbers are presumed to be 1-indexed; however, an implementation is encouraged to use 0 when the line number is unknown[.](#tab:support.srcloc.current-row-2-column-2-sentence-2) |
| [🔗](#tab:support.srcloc.current-row-3)<br> column_ | An implementation-defined value denoting some offset from the start of the line denoted by line_[.](#tab:support.srcloc.current-row-3-column-2-sentence-1)<br>Column numbers are presumed to be 1-indexed; however, an implementation is encouraged to use 0 when the column number is unknown[.](#tab:support.srcloc.current-row-3-column-2-sentence-2) |
| [🔗](#tab:support.srcloc.current-row-4)<br> file_name_ | A presumed name of the current source file ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names")) as an ntbs[.](#tab:support.srcloc.current-row-4-column-2-sentence-1) |
| [🔗](#tab:support.srcloc.current-row-5)<br> function_name_ | A name of the current function such as in __func__ ([[dcl.fct.def.general]](dcl.fct.def.general "9.6.1General")) if any, an empty string otherwise[.](#tab:support.srcloc.current-row-5-column-2-sentence-1) |
- [(1.2)](#cons-1.2)
Otherwise, when invoked in some other way, returns a source_location whose data members are initialized
with valid but unspecified values[.](#cons-1.2.sentence-1)
[2](#cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3748)
*Remarks*: Any call to current that appears
as a default member initializer ([[class.mem.general]](class.mem.general "11.4.1General")), or
as a subexpression thereof,
should correspond to the location of
the constructor definition or aggregate initialization
that uses the default member initializer[.](#cons-2.sentence-1)
Any call to current that appears
as a default argument ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments")), or
as a subexpression thereof,
should correspond to the location of the invocation of the function
that uses the default argument ([[expr.call]](expr.call "7.6.1.3Function call"))[.](#cons-2.sentence-2)
[3](#cons-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3763)
[*Example [1](#cons-example-1)*: struct s { source_location member = source_location::current(); int other_member;
s(source_location loc = source_location::current()): member(loc) // values of member refer to the location of the calling function ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments")){} s(int blather) : // values of member refer to this location other_member(blather){} s(double) // values of member refer to this location{}};void f(source_location a = source_location::current()) { source_location b = source_location::current(); // values in b refer to this line}void g() { f(); // f's first argument corresponds to this line of code source_location c = source_location::current();
f(c); // f's first argument gets the same values as c, above} — *end example*]
[🔗](#cons-itemdecl:2)
`constexpr source_location() noexcept;
`
[4](#cons-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3796)
*Effects*: The data members are initialized with valid but unspecified values[.](#cons-4.sentence-1)
#### [17.8.2.3](#obs) Observers [[support.srcloc.obs]](support.srcloc.obs)
[🔗](#obs-itemdecl:1)
`constexpr uint_least32_t line() const noexcept;
`
[1](#obs-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3807)
*Returns*: line_[.](#obs-1.sentence-1)
[🔗](#obs-itemdecl:2)
`constexpr uint_least32_t column() const noexcept;
`
[2](#obs-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3816)
*Returns*: column_[.](#obs-2.sentence-1)
[🔗](#obs-itemdecl:3)
`constexpr const char* file_name() const noexcept;
`
[3](#obs-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3825)
*Returns*: file_name_[.](#obs-3.sentence-1)
[🔗](#obs-itemdecl:4)
`constexpr const char* function_name() const noexcept;
`
[4](#obs-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3834)
*Returns*: function_name_[.](#obs-4.sentence-1)

View File

@@ -0,0 +1,196 @@
[support.srcloc.class]
# 17 Language support library [[support]](./#support)
## 17.8 Source location [[support.srcloc]](support.srcloc#class)
### 17.8.2 Class source_location [support.srcloc.class]
#### [17.8.2.1](#general) General [[support.srcloc.class.general]](support.srcloc.class.general)
[🔗](#lib:source_location)
namespace std {struct source_location {// source location constructionstatic consteval source_location current() noexcept; constexpr source_location() noexcept; // source location field accessconstexpr uint_least32_t line() const noexcept; constexpr uint_least32_t column() const noexcept; constexpr const char* file_name() const noexcept; constexpr const char* function_name() const noexcept; private: uint_least32_t line_; // *exposition only* uint_least32_t column_; // *exposition only*const char* file_name_; // *exposition only*const char* function_name_; // *exposition only*};}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3658)
The type source_location meets the[*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17Swappable*](swappable.requirements#:Cpp17Swappable "16.4.4.3Swappable requirements[swappable.requirements]"), and[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2Template argument requirements[utility.arg.requirements]") requirements ([[utility.arg.requirements]](utility.arg.requirements "16.4.4.2Template argument requirements"), [[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements"))[.](#general-1.sentence-1)
All of the following conditions are true:
- [(1.1)](#general-1.1)
is_nothrow_move_constructible_v<source_location>
- [(1.2)](#general-1.2)
is_nothrow_move_assignable_v<source_location>
- [(1.3)](#general-1.3)
is_nothrow_swappable_v<source_location>
[*Note [1](#general-note-1)*:
The intent of source_location is
to have a small size and efficient copying[.](#general-1.sentence-2)
It is unspecified
whether the copy/move constructors and the copy/move assignment operators
are trivial and/or constexpr[.](#general-1.sentence-3)
— *end note*]
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3680)
The data members file_name_ and function_name_ always each refer to an ntbs[.](#general-2.sentence-1)
[3](#general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3684)
The copy/move constructors and the copy/move assignment operators ofsource_location meet the following postconditions:
Given two objects lhs and rhs of type source_location,
where lhs is a copy/move result of rhs, and
where rhs_p is a value denoting the state of rhs before the corresponding copy/move operation,
then each of the following conditions is true:
- [(3.1)](#general-3.1)
strcmp(lhs.file_name(), rhs_p.file_name()) == 0
- [(3.2)](#general-3.2)
strcmp(lhs.function_name(), rhs_p.function_name()) == 0
- [(3.3)](#general-3.3)
lhs.line() == rhs_p.line()
- [(3.4)](#general-3.4)
lhs.column() == rhs_p.column()
#### [17.8.2.2](#support.srcloc.cons) Creation [[support.srcloc.cons]](support.srcloc.cons)
[🔗](#support.srcloc.cons-itemdecl:1)
`static consteval source_location current() noexcept;
`
[1](#support.srcloc.cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3705)
*Returns*:
- [(1.1)](#support.srcloc.cons-1.1)
When invoked by a function call
whose [*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1General[expr.post.general]") is
a (possibly parenthesized) [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]") naming current,
returns a source_location with an implementation-defined value[.](#support.srcloc.cons-1.1.sentence-1)
The value should be affected by #line ([[cpp.line]](cpp.line "15.8Line control"))
in the same manner as for __LINE__ and __FILE__[.](#support.srcloc.cons-1.1.sentence-2)
The values of the exposition-only data members
of the returned source_location object
are indicated in Table [43](#tab:support.srcloc.current "Table 43: Value of object returned by current")[.](#support.srcloc.cons-1.1.sentence-3)
Table [43](#tab:support.srcloc.current) — Value of object returned by current [[tab:support.srcloc.current]](./tab:support.srcloc.current)
| [🔗](#tab:support.srcloc.current-row-1)<br> **Element** | **Value** |
| --- | --- |
| [🔗](#tab:support.srcloc.current-row-2)<br> line_ | A presumed line number ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names"))[.](#tab:support.srcloc.current-row-2-column-2-sentence-1)<br>Line numbers are presumed to be 1-indexed; however, an implementation is encouraged to use 0 when the line number is unknown[.](#tab:support.srcloc.current-row-2-column-2-sentence-2) |
| [🔗](#tab:support.srcloc.current-row-3)<br> column_ | An implementation-defined value denoting some offset from the start of the line denoted by line_[.](#tab:support.srcloc.current-row-3-column-2-sentence-1)<br>Column numbers are presumed to be 1-indexed; however, an implementation is encouraged to use 0 when the column number is unknown[.](#tab:support.srcloc.current-row-3-column-2-sentence-2) |
| [🔗](#tab:support.srcloc.current-row-4)<br> file_name_ | A presumed name of the current source file ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names")) as an ntbs[.](#tab:support.srcloc.current-row-4-column-2-sentence-1) |
| [🔗](#tab:support.srcloc.current-row-5)<br> function_name_ | A name of the current function such as in __func__ ([[dcl.fct.def.general]](dcl.fct.def.general "9.6.1General")) if any, an empty string otherwise[.](#tab:support.srcloc.current-row-5-column-2-sentence-1) |
- [(1.2)](#support.srcloc.cons-1.2)
Otherwise, when invoked in some other way, returns a source_location whose data members are initialized
with valid but unspecified values[.](#support.srcloc.cons-1.2.sentence-1)
[2](#support.srcloc.cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3748)
*Remarks*: Any call to current that appears
as a default member initializer ([[class.mem.general]](class.mem.general "11.4.1General")), or
as a subexpression thereof,
should correspond to the location of
the constructor definition or aggregate initialization
that uses the default member initializer[.](#support.srcloc.cons-2.sentence-1)
Any call to current that appears
as a default argument ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments")), or
as a subexpression thereof,
should correspond to the location of the invocation of the function
that uses the default argument ([[expr.call]](expr.call "7.6.1.3Function call"))[.](#support.srcloc.cons-2.sentence-2)
[3](#support.srcloc.cons-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3763)
[*Example [1](#support.srcloc.cons-example-1)*: struct s { source_location member = source_location::current(); int other_member;
s(source_location loc = source_location::current()): member(loc) // values of member refer to the location of the calling function ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments")){} s(int blather) : // values of member refer to this location other_member(blather){} s(double) // values of member refer to this location{}};void f(source_location a = source_location::current()) { source_location b = source_location::current(); // values in b refer to this line}void g() { f(); // f's first argument corresponds to this line of code source_location c = source_location::current();
f(c); // f's first argument gets the same values as c, above} — *end example*]
[🔗](#support.srcloc.cons-itemdecl:2)
`constexpr source_location() noexcept;
`
[4](#support.srcloc.cons-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3796)
*Effects*: The data members are initialized with valid but unspecified values[.](#support.srcloc.cons-4.sentence-1)
#### [17.8.2.3](#support.srcloc.obs) Observers [[support.srcloc.obs]](support.srcloc.obs)
[🔗](#support.srcloc.obs-itemdecl:1)
`constexpr uint_least32_t line() const noexcept;
`
[1](#support.srcloc.obs-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3807)
*Returns*: line_[.](#support.srcloc.obs-1.sentence-1)
[🔗](#support.srcloc.obs-itemdecl:2)
`constexpr uint_least32_t column() const noexcept;
`
[2](#support.srcloc.obs-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3816)
*Returns*: column_[.](#support.srcloc.obs-2.sentence-1)
[🔗](#support.srcloc.obs-itemdecl:3)
`constexpr const char* file_name() const noexcept;
`
[3](#support.srcloc.obs-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3825)
*Returns*: file_name_[.](#support.srcloc.obs-3.sentence-1)
[🔗](#support.srcloc.obs-itemdecl:4)
`constexpr const char* function_name() const noexcept;
`
[4](#support.srcloc.obs-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3834)
*Returns*: function_name_[.](#support.srcloc.obs-4.sentence-1)

View File

@@ -0,0 +1,76 @@
[support.srcloc.class.general]
# 17 Language support library [[support]](./#support)
## 17.8 Source location [[support.srcloc]](support.srcloc#class.general)
### 17.8.2 Class source_location [[support.srcloc.class]](support.srcloc.class#general)
#### 17.8.2.1 General [support.srcloc.class.general]
[🔗](#lib:source_location)
namespace std {struct source_location {// source location constructionstatic consteval source_location current() noexcept; constexpr source_location() noexcept; // source location field accessconstexpr uint_least32_t line() const noexcept; constexpr uint_least32_t column() const noexcept; constexpr const char* file_name() const noexcept; constexpr const char* function_name() const noexcept; private: uint_least32_t line_; // *exposition only* uint_least32_t column_; // *exposition only*const char* file_name_; // *exposition only*const char* function_name_; // *exposition only*};}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3658)
The type source_location meets the[*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17Swappable*](swappable.requirements#:Cpp17Swappable "16.4.4.3Swappable requirements[swappable.requirements]"), and[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2Template argument requirements[utility.arg.requirements]") requirements ([[utility.arg.requirements]](utility.arg.requirements "16.4.4.2Template argument requirements"), [[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements"))[.](#1.sentence-1)
All of the following conditions are true:
- [(1.1)](#1.1)
is_nothrow_move_constructible_v<source_location>
- [(1.2)](#1.2)
is_nothrow_move_assignable_v<source_location>
- [(1.3)](#1.3)
is_nothrow_swappable_v<source_location>
[*Note [1](#note-1)*:
The intent of source_location is
to have a small size and efficient copying[.](#1.sentence-2)
It is unspecified
whether the copy/move constructors and the copy/move assignment operators
are trivial and/or constexpr[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3680)
The data members file_name_ and function_name_ always each refer to an ntbs[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3684)
The copy/move constructors and the copy/move assignment operators ofsource_location meet the following postconditions:
Given two objects lhs and rhs of type source_location,
where lhs is a copy/move result of rhs, and
where rhs_p is a value denoting the state of rhs before the corresponding copy/move operation,
then each of the following conditions is true:
- [(3.1)](#3.1)
strcmp(lhs.file_name(), rhs_p.file_name()) == 0
- [(3.2)](#3.2)
strcmp(lhs.function_name(), rhs_p.function_name()) == 0
- [(3.3)](#3.3)
lhs.line() == rhs_p.line()
- [(3.4)](#3.4)
lhs.column() == rhs_p.column()

View File

@@ -0,0 +1,81 @@
[support.srcloc.cons]
# 17 Language support library [[support]](./#support)
## 17.8 Source location [[support.srcloc]](support.srcloc#cons)
### 17.8.2 Class source_location [[support.srcloc.class]](support.srcloc.class#support.srcloc.cons)
#### 17.8.2.2 Creation [support.srcloc.cons]
[🔗](#itemdecl:1)
`static consteval source_location current() noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3705)
*Returns*:
- [(1.1)](#1.1)
When invoked by a function call
whose [*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1General[expr.post.general]") is
a (possibly parenthesized) [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]") naming current,
returns a source_location with an implementation-defined value[.](#1.1.sentence-1)
The value should be affected by #line ([[cpp.line]](cpp.line "15.8Line control"))
in the same manner as for __LINE__ and __FILE__[.](#1.1.sentence-2)
The values of the exposition-only data members
of the returned source_location object
are indicated in Table [43](#tab:support.srcloc.current "Table 43: Value of object returned by current")[.](#1.1.sentence-3)
Table [43](#tab:support.srcloc.current) — Value of object returned by current [[tab:support.srcloc.current]](./tab:support.srcloc.current)
| [🔗](#tab:support.srcloc.current-row-1)<br> **Element** | **Value** |
| --- | --- |
| [🔗](#tab:support.srcloc.current-row-2)<br> line_ | A presumed line number ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names"))[.](#tab:support.srcloc.current-row-2-column-2-sentence-1)<br>Line numbers are presumed to be 1-indexed; however, an implementation is encouraged to use 0 when the line number is unknown[.](#tab:support.srcloc.current-row-2-column-2-sentence-2) |
| [🔗](#tab:support.srcloc.current-row-3)<br> column_ | An implementation-defined value denoting some offset from the start of the line denoted by line_[.](#tab:support.srcloc.current-row-3-column-2-sentence-1)<br>Column numbers are presumed to be 1-indexed; however, an implementation is encouraged to use 0 when the column number is unknown[.](#tab:support.srcloc.current-row-3-column-2-sentence-2) |
| [🔗](#tab:support.srcloc.current-row-4)<br> file_name_ | A presumed name of the current source file ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names")) as an ntbs[.](#tab:support.srcloc.current-row-4-column-2-sentence-1) |
| [🔗](#tab:support.srcloc.current-row-5)<br> function_name_ | A name of the current function such as in __func__ ([[dcl.fct.def.general]](dcl.fct.def.general "9.6.1General")) if any, an empty string otherwise[.](#tab:support.srcloc.current-row-5-column-2-sentence-1) |
- [(1.2)](#1.2)
Otherwise, when invoked in some other way, returns a source_location whose data members are initialized
with valid but unspecified values[.](#1.2.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3748)
*Remarks*: Any call to current that appears
as a default member initializer ([[class.mem.general]](class.mem.general "11.4.1General")), or
as a subexpression thereof,
should correspond to the location of
the constructor definition or aggregate initialization
that uses the default member initializer[.](#2.sentence-1)
Any call to current that appears
as a default argument ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments")), or
as a subexpression thereof,
should correspond to the location of the invocation of the function
that uses the default argument ([[expr.call]](expr.call "7.6.1.3Function call"))[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3763)
[*Example [1](#example-1)*: struct s { source_location member = source_location::current(); int other_member;
s(source_location loc = source_location::current()): member(loc) // values of member refer to the location of the calling function ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments")){} s(int blather) : // values of member refer to this location other_member(blather){} s(double) // values of member refer to this location{}};void f(source_location a = source_location::current()) { source_location b = source_location::current(); // values in b refer to this line}void g() { f(); // f's first argument corresponds to this line of code source_location c = source_location::current();
f(c); // f's first argument gets the same values as c, above} — *end example*]
[🔗](#itemdecl:2)
`constexpr source_location() noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3796)
*Effects*: The data members are initialized with valid but unspecified values[.](#4.sentence-1)

View File

@@ -0,0 +1,53 @@
[support.srcloc.obs]
# 17 Language support library [[support]](./#support)
## 17.8 Source location [[support.srcloc]](support.srcloc#obs)
### 17.8.2 Class source_location [[support.srcloc.class]](support.srcloc.class#support.srcloc.obs)
#### 17.8.2.3 Observers [support.srcloc.obs]
[🔗](#itemdecl:1)
`constexpr uint_least32_t line() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3807)
*Returns*: line_[.](#1.sentence-1)
[🔗](#itemdecl:2)
`constexpr uint_least32_t column() const noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3816)
*Returns*: column_[.](#2.sentence-1)
[🔗](#itemdecl:3)
`constexpr const char* file_name() const noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3825)
*Returns*: file_name_[.](#3.sentence-1)
[🔗](#itemdecl:4)
`constexpr const char* function_name() const noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3834)
*Returns*: function_name_[.](#4.sentence-1)

View File

@@ -0,0 +1,230 @@
[support.start.term]
# 17 Language support library [[support]](./#support)
## 17.5 Startup and termination [support.start.term]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2109)
[*Note [1](#note-1)*:
The header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") declares the functions described in this subclause[.](#1.sentence-1)
— *end note*]
[🔗](#lib:_Exit)
`[[noreturn]] void _Exit(int status) noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2121)
*Effects*: This function has the semantics specified in the C standard library[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2125)
*Remarks*: The program is terminated without executing destructors for objects with automatic,
thread, or static storage duration and without calling functions passed toatexit() ([[basic.start.term]](basic.start.term "6.10.3.4Termination"))[.](#3.sentence-1)
The function _Exit is [signal-safe](support.signal#def:evaluation,signal-safe "17.14.5Signal handlers[support.signal]")[.](#3.sentence-2)
[🔗](#lib:abort)
`[[noreturn]] void abort() noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2140)
*Effects*: This function has the semantics specified in the C standard library[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2144)
*Remarks*: The program is terminated without executing destructors for objects of
automatic, thread, or static storage
duration and without calling functions passed toatexit() ([[basic.start.term]](basic.start.term "6.10.3.4Termination"))[.](#5.sentence-1)
The function abort is [signal-safe](support.signal#def:evaluation,signal-safe "17.14.5Signal handlers[support.signal]")[.](#5.sentence-2)
[🔗](#lib:atexit)
`int atexit(c-atexit-handler* f) noexcept;
int atexit(atexit-handler* f) noexcept;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2161)
*Effects*: Theatexit() functions register the function pointed to by f to be called without arguments at normal program termination[.](#6.sentence-1)
It is unspecified whether a call to atexit() that does not[happen before](intro.multithread#def:happens_before "6.10.2Multi-threaded executions and data races[intro.multithread]") a call to exit() will succeed[.](#6.sentence-2)
[*Note [2](#note-2)*:
The atexit() functions do not introduce a data
race ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance"))[.](#6.sentence-3)
— *end note*]
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2175)
*Implementation limits*: The implementation shall support the registration of at least 32 functions[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2179)
*Returns*: Theatexit() function returns zero if the registration succeeds,
nonzero if it fails[.](#8.sentence-1)
[🔗](#lib:exit)
`[[noreturn]] void exit(int status);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2193)
*Effects*:
- [(9.1)](#9.1)
First, objects with thread storage duration and associated with the current thread
are destroyed[.](#9.1.sentence-1)
Next, objects with static storage duration are destroyed
and functions registered by callingatexit are called[.](#9.1.sentence-2)[186](#footnote-186 "A function is called for every time it is registered.")
See [[basic.start.term]](basic.start.term "6.10.3.4Termination") for the order of destructions and calls[.](#9.1.sentence-3)
(Objects with automatic storage duration are not destroyed as a result of callingexit()[.](#9.1.sentence-4))[187](#footnote-187 "Objects with automatic storage duration are all destroyed in a program whose main function ([basic.start.main]) contains no objects with automatic storage duration and executes the call to exit(). Control can be transferred directly to such a main function by throwing an exception that is caught in main.")
If a registered function invoked by exit exits via an exception,
the function std::terminate is invoked ([[except.terminate]](except.terminate "14.6.2The std::terminate function"))[.](#9.1.sentence-5)
- [(9.2)](#9.2)
Next, all open C streams (as mediated by the function
signatures declared in [<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]"))
with unwritten buffered data are flushed, all open C
streams are closed, and all files created by callingtmpfile() are removed[.](#9.2.sentence-1)
- [(9.3)](#9.3)
Finally, control is returned to the host environment[.](#9.3.sentence-1)
If status is zero orEXIT_SUCCESS,
an implementation-defined
form of the status[*successful termination*](#def:successful_termination) is returned[.](#9.3.sentence-2)
If status isEXIT_FAILURE,
an implementation-defined form of the status[*unsuccessful termination*](#def:unsuccessful_termination) is returned[.](#9.3.sentence-3)
Otherwise the status returned is implementation-defined[.](#9.3.sentence-4)[188](#footnote-188 "The macros EXIT_­FAILURE and EXIT_­SUCCESS are defined in <cstdlib>.")
[🔗](#lib:at_quick_exit)
`int at_quick_exit(c-atexit-handler* f) noexcept;
int at_quick_exit(atexit-handler* f) noexcept;
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2258)
*Effects*: The at_quick_exit() functions register the function pointed to by f to be called without arguments when quick_exit is called[.](#10.sentence-1)
It is unspecified whether a call to at_quick_exit() that does not[happen before](intro.multithread#def:happens_before "6.10.2Multi-threaded executions and data races[intro.multithread]") all calls to quick_exit will succeed[.](#10.sentence-2)
[*Note [3](#note-3)*:
Theat_quick_exit() functions do not introduce a
data race ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance"))[.](#10.sentence-3)
— *end note*]
[*Note [4](#note-4)*:
The order of registration could be indeterminate if at_quick_exit was called from more
than one thread[.](#10.sentence-4)
— *end note*]
[*Note [5](#note-5)*:
Theat_quick_exit registrations are distinct from the atexit registrations,
and applications might need to call both registration functions with the same argument[.](#10.sentence-5)
— *end note*]
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2280)
*Implementation limits*: The implementation shall support the registration of at least 32 functions[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2284)
*Returns*: Zero if the registration succeeds, nonzero if it fails[.](#12.sentence-1)
[🔗](#lib:quick_exit)
`[[noreturn]] void quick_exit(int status) noexcept;
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2295)
*Effects*: Functions registered by calls to at_quick_exit are called in the
reverse order of their registration, except that a function shall be called after any
previously registered functions that had already been called at the time it was
registered[.](#13.sentence-1)
Objects shall not be destroyed as a result of calling quick_exit[.](#13.sentence-2)
If a registered function invoked by quick_exit exits via an exception,
the function std::terminate is invoked ([[except.terminate]](except.terminate "14.6.2The std::terminate function"))[.](#13.sentence-3)
[*Note [6](#note-6)*:
A function registered via at_quick_exit is invoked by the thread that calls quick_exit,
which can be a different thread
than the one that registered it, so registered functions cannot rely on the identity
of objects with thread storage duration[.](#13.sentence-4)
— *end note*]
After calling registered functions, quick_exit shall call _Exit(status)[.](#13.sentence-5)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2313)
*Remarks*: The function quick_exit is [signal-safe](support.signal#def:evaluation,signal-safe "17.14.5Signal handlers[support.signal]") when the functions registered with at_quick_exit are[.](#14.sentence-1)
See also: ISO/IEC 9899:2024, 7.24.4
[186)](#footnote-186)[186)](#footnoteref-186)
A function is called for every time it is registered[.](#footnote-186.sentence-1)
[187)](#footnote-187)[187)](#footnoteref-187)
Objects with automatic storage duration are all destroyed in a program whosemain function ([[basic.start.main]](basic.start.main "6.10.3.1main function"))
contains no objects with automatic storage duration and executes the call toexit()[.](#footnote-187.sentence-1)
Control can be transferred directly to such amain function
by throwing an exception that is caught inmain[.](#footnote-187.sentence-2)
[188)](#footnote-188)[188)](#footnoteref-188)
The macros EXIT_FAILURE and EXIT_SUCCESS are defined in [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]")[.](#footnote-188.sentence-1)

308
cppdraft/support/types.md Normal file
View File

@@ -0,0 +1,308 @@
[support.types]
# 17 Language support library [[support]](./#support)
## 17.2 Common definitions [support.types]
### [17.2.1](#cstddef.syn) Header <cstddef> synopsis [[cstddef.syn]](cstddef.syn)
// all freestandingnamespace std {using [ptrdiff_t](#lib:ptrdiff_t "17.2.1Header <cstddef> synopsis[cstddef.syn]") = *see below*; using [size_t](cstdio.syn#lib:size_t "31.13.1Header <cstdio> synopsis[cstdio.syn]") = *see below*; using [max_align_t](#lib:max_align_t "17.2.4Sizes, alignments, and offsets[support.types.layout]") = *see below*; using [nullptr_t](#lib:nullptr_t "17.2.3Null pointers[support.types.nullptr]") = decltype(nullptr); enum class [byte](#lib:byte "17.2.1Header <cstddef> synopsis[cstddef.syn]") : unsigned char {}; // [[support.types.byteops]](#byteops "17.2.5byte type operations"), byte type operationstemplate<class IntType>constexpr byte& operator<<=(byte& b, IntType shift) noexcept; template<class IntType>constexpr byte operator<<(byte b, IntType shift) noexcept; template<class IntType>constexpr byte& operator>>=(byte& b, IntType shift) noexcept; template<class IntType>constexpr byte operator>>(byte b, IntType shift) noexcept; constexpr byte& operator|=(byte& l, byte r) noexcept; constexpr byte operator|(byte l, byte r) noexcept; constexpr byte& operator&=(byte& l, byte r) noexcept; constexpr byte operator&(byte l, byte r) noexcept; constexpr byte& operator^=(byte& l, byte r) noexcept; constexpr byte operator^(byte l, byte r) noexcept; constexpr byte operator~(byte b) noexcept; template<class IntType>constexpr IntType to_integer(byte b) noexcept;}#define [NULL](cstdio.syn#lib:NULL "31.13.1Header <cstdio> synopsis[cstdio.syn]") *see below*#define [offsetof](diff.offsetof#lib:offsetof "C.8.5.2Macro offsetof(type, member-designator)[diff.offsetof]")(P, D) *see below*
[1](#cstddef.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L82)
The contents and meaning of the header <cstddef> are the same as
the C standard library header [<stddef.h>](support.c.headers.general#header:%3cstddef.h%3e "17.15.1General[support.c.headers.general]"),
except that it does not declare the type wchar_t,
that it does not define the macro unreachable,
that it also declares the type byte and its associated operations ([[support.types.byteops]](#byteops "17.2.5byte type operations")),
and as noted in[[support.types.nullptr]](#nullptr "17.2.3Null pointers") and[[support.types.layout]](#layout "17.2.4Sizes, alignments, and offsets")[.](#cstddef.syn-1.sentence-1)
See also: ISO/IEC 9899:2024, 7.22
### [17.2.2](#cstdlib.syn) Header <cstdlib> synopsis [[cstdlib.syn]](cstdlib.syn)
[🔗](#header:%3ccstdlib%3e)
namespace std {using size_t = *see below*; // freestandingusing div_t = *see below*; // freestandingusing ldiv_t = *see below*; // freestandingusing lldiv_t = *see below*; // freestanding}#define [NULL](cstdio.syn#lib:NULL "31.13.1Header <cstdio> synopsis[cstdio.syn]") *see below* // freestanding#define [EXIT_FAILURE](#lib:EXIT_FAILURE "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") *see below* // freestanding#define [EXIT_SUCCESS](#lib:EXIT_SUCCESS "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") *see below* // freestanding#define [RAND_MAX](#lib:RAND_MAX "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") *see below*#define [MB_CUR_MAX](#lib:MB_CUR_MAX "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") *see below*namespace std {// Exposition-only function type aliasesextern "C" using *c-atexit-handler* = void(); // *exposition only*extern "C++" using *atexit-handler* = void(); // *exposition only*extern "C" using *c-compare-pred* = int(const void*, const void*); // *exposition only*extern "C++" using *compare-pred* = int(const void*, const void*); // *exposition only*// [[support.start.term]](support.start.term "17.5Startup and termination"), start and termination[[noreturn]] void abort() noexcept; // freestandingint atexit(*c-atexit-handler** func) noexcept; // freestandingint atexit(*atexit-handler** func) noexcept; // freestandingint at_quick_exit(*c-atexit-handler** func) noexcept; // freestandingint at_quick_exit(*atexit-handler** func) noexcept; // freestanding[[noreturn]] void exit(int status); // freestanding[[noreturn]] void _Exit(int status) noexcept; // freestanding[[noreturn]] void quick_exit(int status) noexcept; // freestandingchar* [getenv](support.runtime.general#lib:getenv "17.14.1General[support.runtime.general]")(const char* name); int system(const char* string); // [[c.malloc]](c.malloc "20.2.12C library memory allocation"), C library memory allocationvoid* aligned_alloc(size_t alignment, size_t size); void* calloc(size_t nmemb, size_t size); void free(void* ptr); void free_sized(void* ptr, size_t size); void free_aligned_sized(void* ptr, size_t alignment, size_t size); void* malloc(size_t size); void* realloc(void* ptr, size_t size);
size_t memalignment(const void* p); // freestandingdouble atof(const char* nptr); int atoi(const char* nptr); long int atol(const char* nptr); long long int atoll(const char* nptr); double strtod(const char* nptr, char** endptr); int strfromd(char* s, size_t n, const char* format, double fp); int strfromf(char* s, size_t n, const char* format, float fp); int strfroml(char* s, size_t n, const char* format, long double fp); float strtof(const char* nptr, char** endptr); long double strtold(const char* nptr, char** endptr); long int strtol(const char* nptr, char** endptr, int base); long long int strtoll(const char* nptr, char** endptr, int base); unsigned long int strtoul(const char* nptr, char** endptr, int base); unsigned long long int strtoull(const char* nptr, char** endptr, int base); // [[c.mb.wcs]](c.mb.wcs "28.7.5Multibyte / wide string and character conversion functions"), multibyte / wide string and character conversion functionsint mblen(const char* s, size_t n); int mbtowc(wchar_t* pwc, const char* s, size_t n); int wctomb(char* s, wchar_t wchar);
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n); // [[alg.c.library]](alg.c.library "26.13C library algorithms"), C standard library algorithmsvoid* bsearch(const void* key, void* base, size_t nmemb, size_t size, // freestanding*c-compare-pred** compar); void* bsearch(const void* key, void* base, size_t nmemb, size_t size, // freestanding*compare-pred** compar); const void* bsearch(const void* key, const void* base, size_t nmemb, // freestanding size_t size, *c-compare-pred** compar); const void* bsearch(const void* key, const void* base, size_t nmemb, // freestanding size_t size, *compare-pred** compar); void qsort(void* base, size_t nmemb, size_t size, *c-compare-pred** compar); // freestandingvoid qsort(void* base, size_t nmemb, size_t size, *compare-pred** compar); // freestanding// [[c.math.rand]](c.math.rand "29.5.10Low-quality random number generation"), low-quality random number generationint rand(); void srand(unsigned int seed); // [[c.math.abs]](c.math.abs "29.7.2Absolute values"), absolute valuesconstexpr int abs(int j); // freestandingconstexpr long int abs(long int j); // freestandingconstexpr long long int abs(long long int j); // freestandingconstexpr *floating-point-type* abs(*floating-point-type* j); // freestanding-deletedconstexpr long int labs(long int j); // freestandingconstexpr long long int llabs(long long int j); // freestandingconstexpr div_t div(int numer, int denom); // freestandingconstexpr ldiv_t div(long int numer, long int denom); // freestanding; see [[library.c]](library.c "16.2The C standard library")constexpr lldiv_t div(long long int numer, long long int denom); // freestanding; see [[library.c]](library.c "16.2The C standard library")constexpr ldiv_t ldiv(long int numer, long int denom); // freestandingconstexpr lldiv_t lldiv(long long int numer, long long int denom); // freestanding}
[1](#cstdlib.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L239)
The contents and meaning of the header [<cstdlib>](#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") are the same as
the C standard library header [<stdlib.h>](support.c.headers.general#header:%3cstdlib.h%3e "17.15.1General[support.c.headers.general]"),
except that it does not declare the types wchar_t or once_flag,
and does not declare the function call_once,
and except as noted in[[support.types.nullptr]](#nullptr "17.2.3Null pointers"),[[support.types.layout]](#layout "17.2.4Sizes, alignments, and offsets"),[[support.start.term]](support.start.term "17.5Startup and termination"),[[c.malloc]](c.malloc "20.2.12C library memory allocation"),[[c.mb.wcs]](c.mb.wcs "28.7.5Multibyte / wide string and character conversion functions"),[[alg.c.library]](alg.c.library "26.13C library algorithms"),[[c.math.rand]](c.math.rand "29.5.10Low-quality random number generation"), and[[c.math.abs]](c.math.abs "29.7.2Absolute values")[.](#cstdlib.syn-1.sentence-1)
[*Note [1](#cstdlib.syn-note-1)*:
Several functions have additional overloads in this document,
but they have the same behavior as in the [C standard library](library.c "16.2The C standard library[library.c]")[.](#cstdlib.syn-1.sentence-2)
— *end note*]
See also: ISO/IEC 9899:2024, 7.24
### [17.2.3](#nullptr) Null pointers [[support.types.nullptr]](support.types.nullptr)
[1](#nullptr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L262)
The type nullptr_t is a synonym
for the type of a nullptr expression, and it
has the characteristics
described in [[basic.fundamental]](basic.fundamental "6.9.2Fundamental types") and [[conv.ptr]](conv.ptr "7.3.12Pointer conversions")[.](#nullptr-1.sentence-1)
[*Note [1](#nullptr-note-1)*:
Although nullptr's address cannot be taken, the address of anothernullptr_t object that is an lvalue can be taken[.](#nullptr-1.sentence-2)
— *end note*]
[2](#nullptr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L273)
The macroNULL is an implementation-defined null pointer constant[.](#nullptr-2.sentence-1)[159](#footnote-159 "Possible definitions include 0 and 0L, but not (void*)0.")
See also: ISO/IEC 9899:2024, 7.22
[159)](#footnote-159)[159)](#footnoteref-159)
Possible definitions include0 and0L,
but not(void*)0[.](#footnote-159.sentence-1)
### [17.2.4](#layout) Sizes, alignments, and offsets [[support.types.layout]](support.types.layout)
[1](#layout-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L291)
The macrooffsetof(*type*, *member-designator*) has the same semantics as the corresponding macro in
the C standard library header [<stddef.h>](support.c.headers.general#header:%3cstddef.h%3e "17.15.1General[support.c.headers.general]"), but
accepts a restricted set of *type* arguments in this document[.](#layout-1.sentence-1)
Use of the offsetof macro with a *type* other than a standard-layout class ([[class.prop]](class.prop "11.2Properties of classes"))
is conditionally-supported[.](#layout-1.sentence-2)[160](#footnote-160 "Note that offsetof is required to work as specified even if unary operator&amp; is overloaded for any of the types involved.")
The expression offsetof(*type*, *member-designator*) is never [type-dependent](temp.dep.expr "13.8.3.3Type-dependent expressions[temp.dep.expr]") and it is[value-dependent](temp.dep.constexpr "13.8.3.4Value-dependent expressions[temp.dep.constexpr]") if and only if *type* is
dependent[.](#layout-1.sentence-3)
The result of applying the offsetof macro to
a static data member or a function member is undefined[.](#layout-1.sentence-4)
No operation invoked by the offsetof macro shall throw an exception andnoexcept(offsetof(*type*, *member-designator*)) shall be true[.](#layout-1.sentence-5)
[2](#layout-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L316)
The type ptrdiff_t is animplementation-defined
signed integer type that can
hold the difference of two subscripts in an array object, as described in [[expr.add]](expr.add "7.6.6Additive operators")[.](#layout-2.sentence-1)
[3](#layout-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L322)
The type size_t is animplementation-defined
unsigned integer type that is large enough
to contain the size in bytes of any object ([[expr.sizeof]](expr.sizeof "7.6.2.5Sizeof"))[.](#layout-3.sentence-1)
[4](#layout-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L328)
*Recommended practice*: An implementation should choose types for ptrdiff_t and size_t whose integer conversion ranks ([[conv.rank]](conv.rank "6.9.6Conversion ranks")) are no greater than that ofsigned long int unless a larger size is necessary to contain all the possible values[.](#layout-4.sentence-1)
[5](#layout-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L334)
The typemax_align_t is a trivially copyable standard-layout type whose alignment requirement
is at least as great as that of every scalar type, and whose alignment
requirement is supported in every context ([[basic.align]](basic.align "6.8.3Alignment"))[.](#layout-5.sentence-1)
std::is_trivially_default_constructible_v<max_align_t> is true[.](#layout-5.sentence-2)
See also: ISO/IEC 9899:2024, 7.22
[160)](#footnote-160)[160)](#footnoteref-160)
Note that offsetof is required to work as specified even if unaryoperator& is overloaded for any of the types involved[.](#footnote-160.sentence-1)
### [17.2.5](#byteops) byte type operations [[support.types.byteops]](support.types.byteops)
[🔗](#lib:operator%3c%3c=,byte)
`template<class IntType>
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
`
[1](#byteops-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L353)
*Constraints*: is_integral_v<IntType> is true[.](#byteops-1.sentence-1)
[2](#byteops-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L357)
*Effects*: Equivalent to:return b = b << shift;
[🔗](#lib:operator%3c%3c,byte)
`template<class IntType>
constexpr byte operator<<(byte b, IntType shift) noexcept;
`
[3](#byteops-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L370)
*Constraints*: is_integral_v<IntType> is true[.](#byteops-3.sentence-1)
[4](#byteops-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L374)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(b) << shift);
[🔗](#lib:operator%3e%3e=,byte)
`template<class IntType>
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
`
[5](#byteops-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L389)
*Constraints*: is_integral_v<IntType> is true[.](#byteops-5.sentence-1)
[6](#byteops-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L393)
*Effects*: Equivalent to:return b = b >> shift;
[🔗](#lib:operator%3e%3e,byte)
`template<class IntType>
constexpr byte operator>>(byte b, IntType shift) noexcept;
`
[7](#byteops-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L406)
*Constraints*: is_integral_v<IntType> is true[.](#byteops-7.sentence-1)
[8](#byteops-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L410)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(b) >> shift);
[🔗](#lib:operator%7c=,byte)
`constexpr byte& operator|=(byte& l, byte r) noexcept;
`
[9](#byteops-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L424)
*Effects*: Equivalent to: return l = l | r;
[🔗](#lib:operator%7c,byte)
`constexpr byte operator|(byte l, byte r) noexcept;
`
[10](#byteops-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L435)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) | static_cast<unsigned int>(r));
[🔗](#lib:operator&=,byte)
`constexpr byte& operator&=(byte& l, byte r) noexcept;
`
[11](#byteops-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L449)
*Effects*: Equivalent to: return l = l & r;
[🔗](#lib:operator&,byte)
`constexpr byte operator&(byte l, byte r) noexcept;
`
[12](#byteops-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L460)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) & static_cast<unsigned int>(r));
[🔗](#lib:operator%5e=,byte)
`constexpr byte& operator^=(byte& l, byte r) noexcept;
`
[13](#byteops-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L474)
*Effects*: Equivalent to: return l = l ^ r;
[🔗](#lib:operator%5e,byte)
`constexpr byte operator^(byte l, byte r) noexcept;
`
[14](#byteops-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L485)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) ^ static_cast<unsigned int>(r));
[🔗](#lib:operator~,byte)
`constexpr byte operator~(byte b) noexcept;
`
[15](#byteops-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L499)
*Effects*: Equivalent to:return static_cast<byte>(~static_cast<unsigned int>(b));
[🔗](#lib:to_integer,byte)
`template<class IntType>
constexpr IntType to_integer(byte b) noexcept;
`
[16](#byteops-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L514)
*Constraints*: is_integral_v<IntType> is true[.](#byteops-16.sentence-1)
[17](#byteops-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L518)
*Effects*: Equivalent to: return static_cast<IntType>(b);

View File

@@ -0,0 +1,174 @@
[support.types.byteops]
# 17 Language support library [[support]](./#support)
## 17.2 Common definitions [[support.types]](support.types#byteops)
### 17.2.5 byte type operations [support.types.byteops]
[🔗](#lib:operator%3c%3c=,byte)
`template<class IntType>
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L353)
*Constraints*: is_integral_v<IntType> is true[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L357)
*Effects*: Equivalent to:return b = b << shift;
[🔗](#lib:operator%3c%3c,byte)
`template<class IntType>
constexpr byte operator<<(byte b, IntType shift) noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L370)
*Constraints*: is_integral_v<IntType> is true[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L374)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(b) << shift);
[🔗](#lib:operator%3e%3e=,byte)
`template<class IntType>
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L389)
*Constraints*: is_integral_v<IntType> is true[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L393)
*Effects*: Equivalent to:return b = b >> shift;
[🔗](#lib:operator%3e%3e,byte)
`template<class IntType>
constexpr byte operator>>(byte b, IntType shift) noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L406)
*Constraints*: is_integral_v<IntType> is true[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L410)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(b) >> shift);
[🔗](#lib:operator%7c=,byte)
`constexpr byte& operator|=(byte& l, byte r) noexcept;
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L424)
*Effects*: Equivalent to: return l = l | r;
[🔗](#lib:operator%7c,byte)
`constexpr byte operator|(byte l, byte r) noexcept;
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L435)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) | static_cast<unsigned int>(r));
[🔗](#lib:operator&=,byte)
`constexpr byte& operator&=(byte& l, byte r) noexcept;
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L449)
*Effects*: Equivalent to: return l = l & r;
[🔗](#lib:operator&,byte)
`constexpr byte operator&(byte l, byte r) noexcept;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L460)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) & static_cast<unsigned int>(r));
[🔗](#lib:operator%5e=,byte)
`constexpr byte& operator^=(byte& l, byte r) noexcept;
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L474)
*Effects*: Equivalent to: return l = l ^ r;
[🔗](#lib:operator%5e,byte)
`constexpr byte operator^(byte l, byte r) noexcept;
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L485)
*Effects*: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) ^ static_cast<unsigned int>(r));
[🔗](#lib:operator~,byte)
`constexpr byte operator~(byte b) noexcept;
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L499)
*Effects*: Equivalent to:return static_cast<byte>(~static_cast<unsigned int>(b));
[🔗](#lib:to_integer,byte)
`template<class IntType>
constexpr IntType to_integer(byte b) noexcept;
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L514)
*Constraints*: is_integral_v<IntType> is true[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L518)
*Effects*: Equivalent to: return static_cast<IntType>(b);

View File

@@ -0,0 +1,64 @@
[support.types.layout]
# 17 Language support library [[support]](./#support)
## 17.2 Common definitions [[support.types]](support.types#layout)
### 17.2.4 Sizes, alignments, and offsets [support.types.layout]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L291)
The macrooffsetof(*type*, *member-designator*) has the same semantics as the corresponding macro in
the C standard library header [<stddef.h>](support.c.headers.general#header:%3cstddef.h%3e "17.15.1General[support.c.headers.general]"), but
accepts a restricted set of *type* arguments in this document[.](#1.sentence-1)
Use of the offsetof macro with a *type* other than a standard-layout class ([[class.prop]](class.prop "11.2Properties of classes"))
is conditionally-supported[.](#1.sentence-2)[160](#footnote-160 "Note that offsetof is required to work as specified even if unary operator&amp; is overloaded for any of the types involved.")
The expression offsetof(*type*, *member-designator*) is never [type-dependent](temp.dep.expr "13.8.3.3Type-dependent expressions[temp.dep.expr]") and it is[value-dependent](temp.dep.constexpr "13.8.3.4Value-dependent expressions[temp.dep.constexpr]") if and only if *type* is
dependent[.](#1.sentence-3)
The result of applying the offsetof macro to
a static data member or a function member is undefined[.](#1.sentence-4)
No operation invoked by the offsetof macro shall throw an exception andnoexcept(offsetof(*type*, *member-designator*)) shall be true[.](#1.sentence-5)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L316)
The type ptrdiff_t is animplementation-defined
signed integer type that can
hold the difference of two subscripts in an array object, as described in [[expr.add]](expr.add "7.6.6Additive operators")[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L322)
The type size_t is animplementation-defined
unsigned integer type that is large enough
to contain the size in bytes of any object ([[expr.sizeof]](expr.sizeof "7.6.2.5Sizeof"))[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L328)
*Recommended practice*: An implementation should choose types for ptrdiff_t and size_t whose integer conversion ranks ([[conv.rank]](conv.rank "6.9.6Conversion ranks")) are no greater than that ofsigned long int unless a larger size is necessary to contain all the possible values[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L334)
The typemax_align_t is a trivially copyable standard-layout type whose alignment requirement
is at least as great as that of every scalar type, and whose alignment
requirement is supported in every context ([[basic.align]](basic.align "6.8.3Alignment"))[.](#5.sentence-1)
std::is_trivially_default_constructible_v<max_align_t> is true[.](#5.sentence-2)
See also: ISO/IEC 9899:2024, 7.22
[160)](#footnote-160)[160)](#footnoteref-160)
Note that offsetof is required to work as specified even if unaryoperator& is overloaded for any of the types involved[.](#footnote-160.sentence-1)

View File

@@ -0,0 +1,35 @@
[support.types.nullptr]
# 17 Language support library [[support]](./#support)
## 17.2 Common definitions [[support.types]](support.types#nullptr)
### 17.2.3 Null pointers [support.types.nullptr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L262)
The type nullptr_t is a synonym
for the type of a nullptr expression, and it
has the characteristics
described in [[basic.fundamental]](basic.fundamental "6.9.2Fundamental types") and [[conv.ptr]](conv.ptr "7.3.12Pointer conversions")[.](#1.sentence-1)
[*Note [1](#note-1)*:
Although nullptr's address cannot be taken, the address of anothernullptr_t object that is an lvalue can be taken[.](#1.sentence-2)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L273)
The macroNULL is an implementation-defined null pointer constant[.](#2.sentence-1)[159](#footnote-159 "Possible definitions include 0 and 0L, but not (void*)0.")
See also: ISO/IEC 9899:2024, 7.22
[159)](#footnote-159)[159)](#footnoteref-159)
Possible definitions include0 and0L,
but not(void*)0[.](#footnote-159.sentence-1)