Init
This commit is contained in:
112
cppdraft/utility/arg/requirements.md
Normal file
112
cppdraft/utility/arg/requirements.md
Normal file
@@ -0,0 +1,112 @@
|
||||
[utility.arg.requirements]
|
||||
|
||||
# 16 Library introduction [[library]](./#library)
|
||||
|
||||
## 16.4 Library-wide requirements [[requirements]](requirements#utility.arg.requirements)
|
||||
|
||||
### 16.4.4 Requirements on types and expressions [[utility.requirements]](utility.requirements#utility.arg.requirements)
|
||||
|
||||
#### 16.4.4.2 Template argument requirements [utility.arg.requirements]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L1780)
|
||||
|
||||
The template definitions in the C++ standard library
|
||||
refer to various named requirements whose details are set out in
|
||||
Tables [28](#tab:cpp17.equalitycomparable "Table 28: Cpp17EqualityComparable requirements")â[35](#tab:cpp17.destructible "Table 35: Cpp17Destructible requirements")[.](#1.sentence-1)
|
||||
|
||||
In these tables,
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
T denotes an object or reference type to be
|
||||
supplied by a C++ program instantiating a template,
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
a,b, andc denote values of type (possibly const) T,
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
s and t denote modifiable lvalues of type T,
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
u denotes an identifier,
|
||||
|
||||
- [(1.5)](#1.5)
|
||||
|
||||
rv denotes an rvalue of type T, and
|
||||
|
||||
- [(1.6)](#1.6)
|
||||
|
||||
v denotes an lvalue of type (possibly const) T or an
|
||||
rvalue of type const T[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L1804)
|
||||
|
||||
In general, a default constructor is not required[.](#2.sentence-1)
|
||||
|
||||
Certain container class
|
||||
member function signatures specify T() as a default argument[.](#2.sentence-2)
|
||||
|
||||
T() shall be a well-defined expression ([[dcl.init]](dcl.init "9.5 Initializers")) if one of those
|
||||
signatures is called using the [default argument](dcl.fct.default "9.3.4.7 Default arguments [dcl.fct.default]")[.](#2.sentence-3)
|
||||
|
||||
Table [28](#tab:cpp17.equalitycomparable) — *Cpp17EqualityComparable* requirements [[tab:cpp17.equalitycomparable]](./tab:cpp17.equalitycomparable)
|
||||
|
||||
| [ð](#tab:cpp17.equalitycomparable-row-1)<br>**Expression** | **Return type** | **Requirement** |
|
||||
| --- | --- | --- |
|
||||
| [ð](#tab:cpp17.equalitycomparable-row-2)<br>a == b | decltype(a == b) models *boolean-testable* | == is an equivalence relation, that is, it has the following properties: <br> <br>For all a, a == a[.](#tab:cpp17.equalitycomparable-row-2-column-3-sentence-1)<br> If a == b, then b == a[.](#tab:cpp17.equalitycomparable-row-2-column-3-sentence-1)<br> If a == b and b == c, then a == c[.](#tab:cpp17.equalitycomparable-row-2-column-3-sentence-1) |
|
||||
|
||||
Table [29](#tab:cpp17.lessthancomparable) — *Cpp17LessThanComparable* requirements [[tab:cpp17.lessthancomparable]](./tab:cpp17.lessthancomparable)
|
||||
|
||||
| [ð](#tab:cpp17.lessthancomparable-row-1)<br>**Expression** | **Return type** | **Requirement** |
|
||||
| --- | --- | --- |
|
||||
| [ð](#tab:cpp17.lessthancomparable-row-2)<br>a < b | decltype(a < b) models *boolean-testable* | < is a strict weak ordering relation ([[alg.sorting]](alg.sorting "26.8 Sorting and related operations")) |
|
||||
|
||||
Table [30](#tab:cpp17.defaultconstructible) — *Cpp17DefaultConstructible* requirements [[tab:cpp17.defaultconstructible]](./tab:cpp17.defaultconstructible)
|
||||
|
||||
| [ð](#tab:cpp17.defaultconstructible-row-1)<br>**Expression** | **Post-condition** |
|
||||
| --- | --- |
|
||||
| [ð](#tab:cpp17.defaultconstructible-row-2)<br>T t; | object t is default-initialized |
|
||||
| [ð](#tab:cpp17.defaultconstructible-row-3)<br>T u{}; | object u is value-initialized or aggregate-initialized |
|
||||
| [ð](#tab:cpp17.defaultconstructible-row-4)<br>T() T{} | an object of type T is value-initialized or aggregate-initialized |
|
||||
|
||||
Table [31](#tab:cpp17.moveconstructible) — *Cpp17MoveConstructible* requirements [[tab:cpp17.moveconstructible]](./tab:cpp17.moveconstructible)
|
||||
|
||||
| [ð](#tab:cpp17.moveconstructible-row-1)<br>**Expression** | **Post-condition** |
|
||||
| --- | --- |
|
||||
| [ð](#tab:cpp17.moveconstructible-row-2)<br>T u = rv; | u is equivalent to the value of rv before the construction |
|
||||
| [ð](#tab:cpp17.moveconstructible-row-3)<br>T(rv) | T(rv) is equivalent to the value of rv before the construction |
|
||||
| [ð](#tab:cpp17.moveconstructible-row-4)<br>rv's state is unspecified <br>[*Note [1](#tab:cpp17.moveconstructible-row-4-column-1-note-1)*:<br>rv must still meet the requirements of the library component that is using it[.](#tab:cpp17.moveconstructible-row-4-column-1-sentence-1)<br>The operations listed in those requirements must work as specified whether rv has been moved from or not[.](#tab:cpp17.moveconstructible-row-4-column-1-sentence-2) â *end note*] | |
|
||||
|
||||
Table [32](#tab:cpp17.copyconstructible) — *Cpp17CopyConstructible* requirements (in addition to [*Cpp17MoveConstructible*](#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]")) [[tab:cpp17.copyconstructible]](./tab:cpp17.copyconstructible)
|
||||
|
||||
| [ð](#tab:cpp17.copyconstructible-row-1)<br>**Expression** | **Post-condition** |
|
||||
| --- | --- |
|
||||
| [ð](#tab:cpp17.copyconstructible-row-2)<br>T u = v; | the value of v is unchanged and is equivalent to u |
|
||||
| [ð](#tab:cpp17.copyconstructible-row-3)<br>T(v) | the value of v is unchanged and is equivalent to T(v) |
|
||||
|
||||
Table [33](#tab:cpp17.moveassignable) — *Cpp17MoveAssignable* requirements [[tab:cpp17.moveassignable]](./tab:cpp17.moveassignable)
|
||||
|
||||
| [ð](#tab:cpp17.moveassignable-row-1)<br>**Expression** | **Return type** | **Return value** | **Post-condition** |
|
||||
| --- | --- | --- | --- |
|
||||
| [ð](#tab:cpp17.moveassignable-row-2)<br>t = rv | T& | t | If t and rv do not refer to the same object, t is equivalent to the value of rv before the assignment |
|
||||
| [ð](#tab:cpp17.moveassignable-row-3)<br>rv's state is unspecified[.](#tab:cpp17.moveassignable-row-3-column-1-sentence-1)<br>[*Note [2](#tab:cpp17.moveassignable-row-3-column-1-note-2)*:<br>rv must still meet the requirements of the library component that is using it, whether or not t and rv refer to the same object[.](#tab:cpp17.moveassignable-row-3-column-1-sentence-2)<br>The operations listed in those requirements must work as specified whether rv has been moved from or not[.](#tab:cpp17.moveassignable-row-3-column-1-sentence-3) â *end note*] | | | |
|
||||
|
||||
Table [34](#tab:cpp17.copyassignable) — *Cpp17CopyAssignable* requirements (in addition to [*Cpp17MoveAssignable*](#:Cpp17MoveAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]")) [[tab:cpp17.copyassignable]](./tab:cpp17.copyassignable)
|
||||
|
||||
| [ð](#tab:cpp17.copyassignable-row-1)<br>**Expression** | **Return type** | **Return value** | **Post-condition** |
|
||||
| --- | --- | --- | --- |
|
||||
| [ð](#tab:cpp17.copyassignable-row-2)<br>t = v | T& | t | t is equivalent to v, the value of v is unchanged |
|
||||
|
||||
Table [35](#tab:cpp17.destructible) — *Cpp17Destructible* requirements [[tab:cpp17.destructible]](./tab:cpp17.destructible)
|
||||
|
||||
| [ð](#tab:cpp17.destructible-row-1)<br>**Expression** | **Post-condition** |
|
||||
| --- | --- |
|
||||
| [ð](#tab:cpp17.destructible-row-2)<br>u.~T() | All resources owned by u are reclaimed, no exception is propagated[.](#tab:cpp17.destructible-row-2-column-2-sentence-1) |
|
||||
| [ð](#tab:cpp17.destructible-row-3)<br>[*Note [3](#tab:cpp17.destructible-row-3-column-1-note-3)*:<br>Array types and non-object types are not [*Cpp17Destructible*](#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]")[.](#tab:cpp17.destructible-row-3-column-1-sentence-1) â *end note*] | |
|
||||
18
cppdraft/utility/as/const.md
Normal file
18
cppdraft/utility/as/const.md
Normal file
@@ -0,0 +1,18 @@
|
||||
[utility.as.const]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#as.const)
|
||||
|
||||
### 22.2.5 Function template as_const [utility.as.const]
|
||||
|
||||
[ð](#lib:as_const)
|
||||
|
||||
`template<class T> constexpr add_const_t<T>& as_const(T& t) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L501)
|
||||
|
||||
*Returns*: t[.](#1.sentence-1)
|
||||
26
cppdraft/utility/exchange.md
Normal file
26
cppdraft/utility/exchange.md
Normal file
@@ -0,0 +1,26 @@
|
||||
[utility.exchange]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#exchange)
|
||||
|
||||
### 22.2.3 exchange [utility.exchange]
|
||||
|
||||
[ð](#lib:exchange)
|
||||
|
||||
`template<class T, class U = T>
|
||||
constexpr T exchange(T& obj, U&& new_val) noexcept(see below);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L308)
|
||||
|
||||
*Effects*: Equivalent to:T old_val = std::move(obj);
|
||||
obj = std::forward<U>(new_val);return old_val;
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L317)
|
||||
|
||||
*Remarks*: The exception specification is equivalent to:is_nothrow_move_constructible_v<T> && is_nothrow_assignable_v<T&, U>
|
||||
122
cppdraft/utility/intcmp.md
Normal file
122
cppdraft/utility/intcmp.md
Normal file
@@ -0,0 +1,122 @@
|
||||
[utility.intcmp]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#intcmp)
|
||||
|
||||
### 22.2.7 Integer comparison functions [utility.intcmp]
|
||||
|
||||
[ð](#lib:cmp_equal)
|
||||
|
||||
`template<class T, class U>
|
||||
constexpr bool cmp_equal(T t, U u) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L546)
|
||||
|
||||
*Mandates*: Both T and U are standard integer types or
|
||||
extended integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L551)
|
||||
|
||||
*Effects*: Equivalent to:using UT = make_unsigned_t<T>;using UU = make_unsigned_t<U>;if constexpr (is_signed_v<T> == is_signed_v<U>)return t == u;else if constexpr (is_signed_v<T>)return t < 0 ? false : UT(t) == u;elsereturn u < 0 ? false : t == UU(u);
|
||||
|
||||
[ð](#lib:cmp_not_equal)
|
||||
|
||||
`template<class T, class U>
|
||||
constexpr bool cmp_not_equal(T t, U u) noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L573)
|
||||
|
||||
*Effects*: Equivalent to: return !cmp_equal(t, u);
|
||||
|
||||
[ð](#lib:cmp_less)
|
||||
|
||||
`template<class T, class U>
|
||||
constexpr bool cmp_less(T t, U u) noexcept;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L585)
|
||||
|
||||
*Mandates*: Both T and U are standard integer types or
|
||||
extended integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L590)
|
||||
|
||||
*Effects*: Equivalent to:using UT = make_unsigned_t<T>;using UU = make_unsigned_t<U>;if constexpr (is_signed_v<T> == is_signed_v<U>)return t < u;else if constexpr (is_signed_v<T>)return t < 0 ? true : UT(t) < u;elsereturn u < 0 ? false : t < UU(u);
|
||||
|
||||
[ð](#lib:cmp_greater)
|
||||
|
||||
`template<class T, class U>
|
||||
constexpr bool cmp_greater(T t, U u) noexcept;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L612)
|
||||
|
||||
*Effects*: Equivalent to: return cmp_less(u, t);
|
||||
|
||||
[ð](#lib:cmp_less_equal)
|
||||
|
||||
`template<class T, class U>
|
||||
constexpr bool cmp_less_equal(T t, U u) noexcept;
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L624)
|
||||
|
||||
*Effects*: Equivalent to: return !cmp_greater(t, u);
|
||||
|
||||
[ð](#lib:cmp_greater_equal)
|
||||
|
||||
`template<class T, class U>
|
||||
constexpr bool cmp_greater_equal(T t, U u) noexcept;
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L636)
|
||||
|
||||
*Effects*: Equivalent to: return !cmp_less(t, u);
|
||||
|
||||
[ð](#lib:in_range)
|
||||
|
||||
`template<class R, class T>
|
||||
constexpr bool in_range(T t) noexcept;
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L648)
|
||||
|
||||
*Mandates*: Both T and R are standard integer types or
|
||||
extended integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L653)
|
||||
|
||||
*Effects*: Equivalent to:return cmp_greater_equal(t, numeric_limits<R>::min()) && cmp_less_equal(t, numeric_limits<R>::max());
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L662)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
These function templates cannot be used to comparebyte,char,char8_t,char16_t,char32_t,wchar_t, andbool[.](#11.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
1374
cppdraft/utility/requirements.md
Normal file
1374
cppdraft/utility/requirements.md
Normal file
File diff suppressed because it is too large
Load Diff
27
cppdraft/utility/requirements/general.md
Normal file
27
cppdraft/utility/requirements/general.md
Normal file
@@ -0,0 +1,27 @@
|
||||
[utility.requirements.general]
|
||||
|
||||
# 16 Library introduction [[library]](./#library)
|
||||
|
||||
## 16.4 Library-wide requirements [[requirements]](requirements#utility.requirements.general)
|
||||
|
||||
### 16.4.4 Requirements on types and expressions [[utility.requirements]](utility.requirements#general)
|
||||
|
||||
#### 16.4.4.1 General [utility.requirements.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L1766)
|
||||
|
||||
[[utility.arg.requirements]](utility.arg.requirements "16.4.4.2 Template argument requirements") describes requirements on types and expressions used to instantiate templates
|
||||
defined in the C++ standard library[.](#1.sentence-1)
|
||||
|
||||
[[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements") describes the requirements on swappable types and
|
||||
swappable expressions[.](#1.sentence-2)
|
||||
|
||||
[[nullablepointer.requirements]](nullablepointer.requirements "16.4.4.4 Cpp17NullablePointer requirements") describes the requirements on pointer-like
|
||||
types that support null values[.](#1.sentence-3)
|
||||
|
||||
[[hash.requirements]](hash.requirements "16.4.4.5 Cpp17Hash requirements") describes the requirements on hash function objects[.](#1.sentence-4)
|
||||
|
||||
[[allocator.requirements]](allocator.requirements "16.4.4.6 Cpp17Allocator requirements") describes the requirements on storage
|
||||
allocators[.](#1.sentence-5)
|
||||
63
cppdraft/utility/swap.md
Normal file
63
cppdraft/utility/swap.md
Normal file
@@ -0,0 +1,63 @@
|
||||
[utility.swap]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#swap)
|
||||
|
||||
### 22.2.2 swap [utility.swap]
|
||||
|
||||
[ð](#lib:swap)
|
||||
|
||||
`template<class T>
|
||||
constexpr void swap(T& a, T& b) noexcept(see below);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L251)
|
||||
|
||||
*Constraints*: is_move_constructible_v<T> is true andis_move_assignable_v<T> is true[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L256)
|
||||
|
||||
*Preconditions*: TypeT meets the[*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [31](utility.arg.requirements#tab:cpp17.moveconstructible "Table 31: Cpp17MoveConstructible requirements"))
|
||||
and[*Cpp17MoveAssignable*](utility.arg.requirements#:Cpp17MoveAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [33](utility.arg.requirements#tab:cpp17.moveassignable "Table 33: Cpp17MoveAssignable requirements"))
|
||||
requirements[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L266)
|
||||
|
||||
*Effects*: Exchanges values stored in two locations[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L270)
|
||||
|
||||
*Remarks*: The exception specification is equivalent to:is_nothrow_move_constructible_v<T> && is_nothrow_move_assignable_v<T>
|
||||
|
||||
[ð](#lib:swap_)
|
||||
|
||||
`template<class T, size_t N>
|
||||
constexpr void swap(T (&a)[N], T (&b)[N]) noexcept(is_nothrow_swappable_v<T>);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L285)
|
||||
|
||||
*Constraints*: is_swappable_v<T> is true[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L289)
|
||||
|
||||
*Preconditions*: a[i] is swappable with ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) b[i] for all i in the range [0, N)[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L294)
|
||||
|
||||
*Effects*: As if by swap_ranges(a, a + N, b)[.](#7.sentence-1)
|
||||
18
cppdraft/utility/syn.md
Normal file
18
cppdraft/utility/syn.md
Normal file
@@ -0,0 +1,18 @@
|
||||
[utility.syn]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#syn)
|
||||
|
||||
### 22.2.1 Header <utility> synopsis [utility.syn]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L29)
|
||||
|
||||
The header <utility> contains some basic function and class templates that are used
|
||||
throughout the rest of the library[.](#1.sentence-1)
|
||||
|
||||
// all freestanding#include <compare> // see [[compare.syn]](compare.syn "17.12.1 Header <compare> synopsis")#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header <initializer_list> synopsis")namespace std {// [[utility.swap]](utility.swap "22.2.2 swap"), swaptemplate<class T>constexpr void swap(T& a, T& b) noexcept(*see below*); template<class T, size_t N>constexpr void swap(T (&a)[N], T (&b)[N]) noexcept(is_nothrow_swappable_v<T>); // [[utility.exchange]](utility.exchange "22.2.3 exchange"), exchangetemplate<class T, class U = T>constexpr T exchange(T& obj, U&& new_val) noexcept(*see below*); // [[forward]](forward "22.2.4 Forward/move helpers"), forward/movetemplate<class T>constexpr T&& forward(remove_reference_t<T>& t) noexcept; template<class T>constexpr T&& forward(remove_reference_t<T>&& t) noexcept; template<class T, class U>constexpr auto forward_like(U&& x) noexcept -> *see below*; template<class T>constexpr remove_reference_t<T>&& move(T&&) noexcept; template<class T>constexpr conditional_t<!is_nothrow_move_constructible_v<T> && is_copy_constructible_v<T>, const T&, T&&> move_if_noexcept(T& x) noexcept; // [[utility.as.const]](utility.as.const "22.2.5 Function template as_const"), as_consttemplate<class T>constexpr add_const_t<T>& as_const(T& t) noexcept; template<class T>void as_const(const T&&) = delete; // [[declval]](declval "22.2.6 Function template declval"), declvaltemplate<class T> add_rvalue_reference_t<T> declval() noexcept; // as unevaluated operand// [[utility.intcmp]](utility.intcmp "22.2.7 Integer comparison functions"), integer comparison functionstemplate<class T, class U>constexpr bool cmp_equal(T t, U u) noexcept; template<class T, class U>constexpr bool cmp_not_equal(T t, U u) noexcept; template<class T, class U>constexpr bool cmp_less(T t, U u) noexcept; template<class T, class U>constexpr bool cmp_greater(T t, U u) noexcept; template<class T, class U>constexpr bool cmp_less_equal(T t, U u) noexcept; template<class T, class U>constexpr bool cmp_greater_equal(T t, U u) noexcept; template<class R, class T>constexpr bool in_range(T t) noexcept; // [[utility.underlying]](utility.underlying "22.2.8 Function template to_underlying"), to_underlyingtemplate<class T>constexpr underlying_type_t<T> to_underlying(T value) noexcept; // [[utility.undefined]](utility.undefined "22.2.9 Undefined behavior"), undefined behavior[[noreturn]] void unreachable(); void observable_checkpoint() noexcept; // [[intseq]](intseq "21.2 Compile-time integer sequences"), compile-time integer sequencestemplate<class T, T...>struct integer_sequence; template<size_t... I>using [index_sequence](#lib:index_sequence "22.2.1 Header <utility> synopsis [utility.syn]") = integer_sequence<size_t, I...>; template<class T, T N>using make_integer_sequence = integer_sequence<T, *see below*>; template<size_t N>using [make_index_sequence](#lib:make_index_sequence "22.2.1 Header <utility> synopsis [utility.syn]") = make_integer_sequence<size_t, N>; template<class... T>using [index_sequence_for](#lib:index_sequence_for "22.2.1 Header <utility> synopsis [utility.syn]") = make_index_sequence<sizeof...(T)>; // [[pairs]](pairs "22.3 Pairs"), class template pairtemplate<class T1, class T2>struct pair; template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual>requires requires { typename pair<common_reference_t<TQual<T1>, UQual<U1>>,
|
||||
common_reference_t<TQual<T2>, UQual<U2>>>; }struct basic_common_reference<pair<T1, T2>, pair<U1, U2>, TQual, UQual> {using type = pair<common_reference_t<TQual<T1>, UQual<U1>>,
|
||||
common_reference_t<TQual<T2>, UQual<U2>>>; }; template<class T1, class T2, class U1, class U2>requires requires { typename pair<common_type_t<T1, U1>, common_type_t<T2, U2>>; }struct common_type<pair<T1, T2>, pair<U1, U2>> {using type = pair<common_type_t<T1, U1>, common_type_t<T2, U2>>; }; // [[pairs.spec]](pairs.spec "22.3.3 Specialized algorithms"), pair specialized algorithmstemplate<class T1, class T2, class U1, class U2>constexpr bool operator==(const pair<T1, T2>&, const pair<U1, U2>&); template<class T1, class T2, class U1, class U2>constexpr common_comparison_category_t<*synth-three-way-result*<T1, U1>, *synth-three-way-result*<T2, U2>>operator<=>(const pair<T1, T2>&, const pair<U1, U2>&); template<class T1, class T2>constexpr void swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); template<class T1, class T2>constexpr void swap(const pair<T1, T2>& x, const pair<T1, T2>& y)noexcept(noexcept(x.swap(y))); template<class T1, class T2>constexpr *see below* make_pair(T1&&, T2&&); // [[pair.astuple]](pair.astuple "22.3.4 Tuple-like access to pair"), tuple-like access to pairtemplate<class T> struct tuple_size; template<size_t I, class T> struct tuple_element; template<class T1, class T2> struct tuple_size<pair<T1, T2>>; template<size_t I, class T1, class T2> struct tuple_element<I, pair<T1, T2>>; template<size_t I, class T1, class T2>constexpr tuple_element_t<I, pair<T1, T2>>& get(pair<T1, T2>&) noexcept; template<size_t I, class T1, class T2>constexpr tuple_element_t<I, pair<T1, T2>>&& get(pair<T1, T2>&&) noexcept; template<size_t I, class T1, class T2>constexpr const tuple_element_t<I, pair<T1, T2>>& get(const pair<T1, T2>&) noexcept; template<size_t I, class T1, class T2>constexpr const tuple_element_t<I, pair<T1, T2>>&& get(const pair<T1, T2>&&) noexcept; template<class T1, class T2>constexpr T1& get(pair<T1, T2>& p) noexcept; template<class T1, class T2>constexpr const T1& get(const pair<T1, T2>& p) noexcept; template<class T1, class T2>constexpr T1&& get(pair<T1, T2>&& p) noexcept; template<class T1, class T2>constexpr const T1&& get(const pair<T1, T2>&& p) noexcept; template<class T2, class T1>constexpr T2& get(pair<T1, T2>& p) noexcept; template<class T2, class T1>constexpr const T2& get(const pair<T1, T2>& p) noexcept; template<class T2, class T1>constexpr T2&& get(pair<T1, T2>&& p) noexcept; template<class T2, class T1>constexpr const T2&& get(const pair<T1, T2>&& p) noexcept; // [[pair.piecewise]](pair.piecewise "22.3.5 Piecewise construction"), pair piecewise constructionstruct piecewise_construct_t {explicit piecewise_construct_t() = default; }; inline constexpr piecewise_construct_t piecewise_construct{}; template<class... Types> class tuple; // defined in [<tuple>](tuple.syn#header:%3ctuple%3e "22.4.2 Header <tuple> synopsis [tuple.syn]")// in-place constructionstruct in_place_t {explicit in_place_t() = default; }; inline constexpr in_place_t in_place{}; template<class T>struct in_place_type_t {explicit in_place_type_t() = default; }; template<class T> constexpr in_place_type_t<T> in_place_type{}; template<size_t I>struct in_place_index_t {explicit in_place_index_t() = default; }; template<size_t I> constexpr in_place_index_t<I> in_place_index{}; // nontype argument tagtemplate<auto V>struct nontype_t {explicit nontype_t() = default; }; template<auto V> constexpr nontype_t<V> nontype{}; // [[variant.monostate]](variant.monostate "22.6.8 Class monostate"), class monostatestruct monostate; // [[variant.monostate.relops]](variant.monostate.relops "22.6.9 monostate relational operators"), monostate relational operatorsconstexpr bool operator==(monostate, monostate) noexcept; constexpr strong_ordering operator<=>(monostate, monostate) noexcept; // [[variant.hash]](variant.hash "22.6.12 Hash support"), hash supporttemplate<class T> struct hash; template<> struct hash<monostate>;}
|
||||
42
cppdraft/utility/undefined.md
Normal file
42
cppdraft/utility/undefined.md
Normal file
@@ -0,0 +1,42 @@
|
||||
[utility.undefined]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#undefined)
|
||||
|
||||
### 22.2.9 Undefined behavior [utility.undefined]
|
||||
|
||||
[ð](#lib:unreachable)
|
||||
|
||||
`[[noreturn]] void unreachable();
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L696)
|
||||
|
||||
*Preconditions*: false is true[.](#1.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
This precondition cannot be satisfied, thus the behavior
|
||||
of calling unreachable is undefined[.](#1.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L704)
|
||||
|
||||
[*Example [1](#example-1)*: int f(int x) {switch (x) {case 0:case 1:return x; default: std::unreachable(); }}int a = f(1); // OK, a has value 1int b = f(3); // undefined behavior â *end example*]
|
||||
|
||||
[ð](#lib:observable_checkpoint)
|
||||
|
||||
`void observable_checkpoint() noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L728)
|
||||
|
||||
*Effects*: Establishes an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2 Abstract machine"))[.](#3.sentence-1)
|
||||
19
cppdraft/utility/underlying.md
Normal file
19
cppdraft/utility/underlying.md
Normal file
@@ -0,0 +1,19 @@
|
||||
[utility.underlying]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#underlying)
|
||||
|
||||
### 22.2.8 Function template to_underlying [utility.underlying]
|
||||
|
||||
[ð](#lib:to_underlying)
|
||||
|
||||
`template<class T>
|
||||
constexpr underlying_type_t<T> to_underlying(T value) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L683)
|
||||
|
||||
*Returns*: static_cast<underlying_type_t<T>>(value)[.](#1.sentence-1)
|
||||
Reference in New Issue
Block a user