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

53
cppdraft/tuple/apply.md Normal file
View File

@@ -0,0 +1,53 @@
[tuple.apply]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#apply)
### 22.4.6 Calling a function with a tuple of arguments [tuple.apply]
[🔗](#lib:apply)
`template<class F, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") Tuple>
constexpr apply_result_t<F, Tuple> apply(F&& f, Tuple&& t)
noexcept(is_nothrow_applicable_v<F, Tuple>);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2695)
*Effects*: Given the exposition-only function template:namespace std {template<class F, [*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") Tuple, size_t... I>constexpr decltype(auto) *apply-impl*(F&& f, Tuple&& t, index_sequence<I...>) {// *exposition only*return *INVOKE*(std::forward<F>(f), get<I>(std::forward<Tuple>(t))...); // see [[func.require]](func.require "22.10.4Requirements")}}
Equivalent to:return *apply-impl*(std::forward<F>(f), std::forward<Tuple>(t),
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
[🔗](#lib:make_from_tuple)
`template<class T, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") Tuple>
constexpr T make_from_tuple(Tuple&& t);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2721)
*Mandates*: If tuple_size_v<remove_reference_t<Tuple>> is 1,
thenreference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))> is false[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2728)
*Effects*: Given the exposition-only function template:namespace std {template<class T, [*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") Tuple, size_t... I>requires is_constructible_v<T, decltype(get<I>(declval<Tuple>()))...>constexpr T *make-from-tuple-impl*(Tuple&& t, index_sequence<I...>) { // *exposition only*return T(get<I>(std::forward<Tuple>(t))...); }}
Equivalent to:return *make-from-tuple-impl*<T>( std::forward<Tuple>(t),
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
[*Note [1](#note-1)*:
The type of T must be supplied
as an explicit template parameter,
as it cannot be deduced from the argument list[.](#3.sentence-2)
— *end note*]

476
cppdraft/tuple/assign.md Normal file
View File

@@ -0,0 +1,476 @@
[tuple.assign]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#assign)
### 22.4.4 Class template tuple [[tuple.tuple]](tuple.tuple#tuple.assign)
#### 22.4.4.3 Assignment [tuple.assign]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2152)
For each tuple assignment operator, an exception is thrown only if the
assignment of one of the types in Types throws an exception[.](#1.sentence-1)
In the function descriptions that follow, let i be in the range [0, sizeof...(Types))
in order, Ti be the ith type in Types,
and Ui be the ith type in a
template parameter pack named UTypes, where indexing is zero-based[.](#1.sentence-2)
[🔗](#lib:operator=,tuple)
`constexpr tuple& operator=(const tuple& u);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2166)
*Effects*: Assigns each element of u to the corresponding
element of *this[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2171)
*Returns*: *this[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2175)
*Remarks*: This operator is defined as deleted unlessis_copy_assignable_v<Ti> is true for all i[.](#4.sentence-1)
[🔗](#lib:operator=,tuple_)
`constexpr const tuple& operator=(const tuple& u) const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2187)
*Constraints*: (is_copy_assignable_v<const Types> && ...) is true[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2191)
*Effects*: Assigns each element of u to the corresponding element of *this[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2195)
*Returns*: *this[.](#7.sentence-1)
[🔗](#lib:operator=,tuple__)
`constexpr tuple& operator=(tuple&& u) noexcept(see below);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2206)
*Constraints*: is_move_assignable_v<Ti> is true for all i[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2210)
*Effects*: For all i, assigns std::forward<Ti>(get<i>(u)) toget<i>(*this)[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2215)
*Returns*: *this[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2219)
*Remarks*: The exception specification is equivalent to the logical and of the
following expressions:is_nothrow_move_assignable_v<Ti> where Ti is the ith type in Types[.](#11.sentence-1)
[🔗](#lib:operator=,tuple___)
`constexpr const tuple& operator=(tuple&& u) const;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2235)
*Constraints*: (is_assignable_v<const Types&, Types> && ...) is true[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2239)
*Effects*: For all i,
assigns std::forward<Ti>(get<i>(u)) to get<i>(*this)[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2244)
*Returns*: *this[.](#14.sentence-1)
[🔗](#lib:operator=,tuple____)
`template<class... UTypes> constexpr tuple& operator=(const tuple<UTypes...>& u);
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2255)
*Constraints*:
- [(15.1)](#15.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(15.2)](#15.2)
is_assignable_v<Ti&, const Ui&> is true for all i[.](#15.sentence-1)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2262)
*Effects*: Assigns each element of u to the corresponding element
of *this[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2267)
*Returns*: *this[.](#17.sentence-1)
[🔗](#lib:operator=,tuple_____)
`template<class... UTypes> constexpr const tuple& operator=(const tuple<UTypes...>& u) const;
`
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2278)
*Constraints*:
- [(18.1)](#18.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(18.2)](#18.2)
(is_assignable_v<const Types&, const UTypes&> && ...) is true[.](#18.sentence-1)
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2287)
*Effects*: Assigns each element of u to the corresponding element of *this[.](#19.sentence-1)
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2291)
*Returns*: *this[.](#20.sentence-1)
[🔗](#lib:operator=,tuple______)
`template<class... UTypes> constexpr tuple& operator=(tuple<UTypes...>&& u);
`
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2302)
*Constraints*:
- [(21.1)](#21.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(21.2)](#21.2)
is_assignable_v<Ti&, Ui> is true for all i[.](#21.sentence-1)
[22](#22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2309)
*Effects*: For all i, assigns std::forward<Ui>(get<i>(u)) toget<i>(*this)[.](#22.sentence-1)
[23](#23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2314)
*Returns*: *this[.](#23.sentence-1)
[🔗](#lib:operator=,tuple_______)
`template<class... UTypes> constexpr const tuple& operator=(tuple<UTypes...>&& u) const;
`
[24](#24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2325)
*Constraints*:
- [(24.1)](#24.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(24.2)](#24.2)
(is_assignable_v<const Types&, UTypes> && ...) is true[.](#24.sentence-1)
[25](#25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2334)
*Effects*: For all i,
assigns std::forward<Ui>(get<i>(u)) to get<i>(*this)[.](#25.sentence-1)
[26](#26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2339)
*Returns*: *this[.](#26.sentence-1)
[🔗](#lib:operator=,tuple________)
`template<class U1, class U2> constexpr tuple& operator=(const pair<U1, U2>& u);
`
[27](#27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2351)
*Constraints*:
- [(27.1)](#27.1)
sizeof...(Types) is 2 and
- [(27.2)](#27.2)
is_assignable_v<T0&, const U1&> is true, and
- [(27.3)](#27.3)
is_assignable_v<T1&, const U2&> is true[.](#27.sentence-1)
[28](#28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2359)
*Effects*: Assigns u.first to the first element of *this and u.second to the second element of *this[.](#28.sentence-1)
[29](#29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2364)
*Returns*: *this[.](#29.sentence-1)
[🔗](#lib:operator=,tuple_________)
`template<class U1, class U2> constexpr const tuple& operator=(const pair<U1, U2>& u) const;
`
[30](#30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2375)
*Constraints*:
- [(30.1)](#30.1)
sizeof...(Types) is 2,
- [(30.2)](#30.2)
is_assignable_v<const T0&, const U1&> is true, and
- [(30.3)](#30.3)
is_assignable_v<const T1&, const U2&> is true[.](#30.sentence-1)
[31](#31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2386)
*Effects*: Assigns u.first to the first element andu.second to the second element[.](#31.sentence-1)
[32](#32)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2391)
*Returns*: *this[.](#32.sentence-1)
[🔗](#lib:operator=,tuple__________)
`template<class U1, class U2> constexpr tuple& operator=(pair<U1, U2>&& u);
`
[33](#33)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2403)
*Constraints*:
- [(33.1)](#33.1)
sizeof...(Types) is 2 and
- [(33.2)](#33.2)
is_assignable_v<T0&, U1> is true, and
- [(33.3)](#33.3)
is_assignable_v<T1&, U2> is true[.](#33.sentence-1)
[34](#34)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2411)
*Effects*: Assigns std::forward<U1>(u.first) to the first
element of *this and
std::forward<U2>(u.second) to the
second element of *this[.](#34.sentence-2)
[35](#35)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2417)
*Returns*: *this[.](#35.sentence-1)
[🔗](#lib:operator=,tuple___________)
`template<class U1, class U2> constexpr const tuple& operator=(pair<U1, U2>&& u) const;
`
[36](#36)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2428)
*Constraints*:
- [(36.1)](#36.1)
sizeof...(Types) is 2,
- [(36.2)](#36.2)
is_assignable_v<const T0&, U1> is true, and
- [(36.3)](#36.3)
is_assignable_v<const T1&, U2> is true[.](#36.sentence-1)
[37](#37)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2439)
*Effects*: Assigns std::forward<U1>(u.first) to the first element and
std::forward<U2>(u.second) to the second element[.](#37.sentence-2)
[38](#38)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2444)
*Returns*: *this[.](#38.sentence-1)
[🔗](#lib:operator=,tuple____________)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr tuple& operator=(UTuple&& u);
`
[39](#39)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2456)
*Constraints*:
- [(39.1)](#39.1)
[*different-from*](range.utility.helpers#concept:different-from "25.5.2Helper concepts[range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2Helper concepts"))
is true,
- [(39.2)](#39.2)
remove_cvref_t<UTuple> is not a specialization of ranges::subrange,
- [(39.3)](#39.3)
sizeof...(Types) equals tuple_size_v<remove_cvref_t<UTuple>>, and
- [(39.4)](#39.4)
is_assignable_v<Ti&, decltype(get<i>(std::forward<UTuple>(u)))> is true for all i[.](#39.sentence-1)
[40](#40)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2476)
*Effects*: For all i, assigns get<i>(std::forward<UTuple>(u)) to get<i>(*this)[.](#40.sentence-1)
[41](#41)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2481)
*Returns*: *this[.](#41.sentence-1)
[🔗](#lib:operator=,tuple_____________)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr const tuple& operator=(UTuple&& u) const;
`
[42](#42)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2493)
*Constraints*:
- [(42.1)](#42.1)
[*different-from*](range.utility.helpers#concept:different-from "25.5.2Helper concepts[range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2Helper concepts"))
is true,
- [(42.2)](#42.2)
remove_cvref_t<UTuple> is not a specialization of ranges::subrange,
- [(42.3)](#42.3)
sizeof...(Types) equals tuple_size_v<remove_cvref_t<UTuple>>, and
- [(42.4)](#42.4)
is_assignable_v<const Ti&, decltype(get<i>(std::forward<UTuple>(u)))> is true for all i[.](#42.sentence-1)
[43](#43)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2513)
*Effects*: For all i, assignsget<i>(std::forward<UTuple>(u)) to get<i>(*this)[.](#43.sentence-1)
[44](#44)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2518)
*Returns*: *this[.](#44.sentence-1)

406
cppdraft/tuple/cnstr.md Normal file
View File

@@ -0,0 +1,406 @@
[tuple.cnstr]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#cnstr)
### 22.4.4 Class template tuple [[tuple.tuple]](tuple.tuple#tuple.cnstr)
#### 22.4.4.2 Construction [tuple.cnstr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1788)
In the descriptions that follow, let i be in the range
[0, sizeof...(Types)) in order, Ti be the ith type in Types, andUi be the ith type in a template parameter pack named UTypes, where indexing
is zero-based[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1795)
For each tuple constructor, an exception is thrown only if the construction of
one of the types in Types throws an exception[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1799)
The defaulted move and copy constructor, respectively, oftuple is a constexpr function if and only if all
required element-wise initializations for move and copy, respectively,
would be constexpr-suitable ([[dcl.constexpr]](dcl.constexpr "9.2.6The constexpr and consteval specifiers"))[.](#3.sentence-1)
The defaulted move and copy constructor of tuple<> are
constexpr functions[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1807)
If is_trivially_destructible_v<Ti> is true for all Ti,
then the destructor of tuple is trivial[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1811)
The default constructor of tuple<> is trivial[.](#5.sentence-1)
[🔗](#lib:tuple,constructor)
`constexpr explicit(see below) tuple();
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1820)
*Constraints*: is_default_constructible_v<Ti> is true for all i[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1824)
*Effects*: Value-initializes each element[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1828)
*Remarks*: The expression inside explicit evaluates to true if and only if Ti is not
copy-list-initializable from an empty list
for at least one i[.](#8.sentence-1)
[*Note [1](#note-1)*:
This behavior can be implemented with a trait that checks whether
a const Ti& can be initialized with {}[.](#8.sentence-2)
— *end note*]
[🔗](#lib:tuple,constructor_)
`constexpr explicit(see below) tuple(const Types&...);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1846)
*Constraints*: sizeof...(Types) ≥ 1 andis_copy_constructible_v<Ti> is true for all i[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1851)
*Effects*: Initializes each element with the value of the
corresponding parameter[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1856)
*Remarks*: The expression inside explicit is equivalent to:!conjunction_v<is_convertible<const Types&, Types>...>
[🔗](#lib:tuple,constructor__)
`template<class... UTypes> constexpr explicit(see below) tuple(UTypes&&... u);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1870)
Let *disambiguating-constraint* be:
- [(12.1)](#12.1)
negation<is_same<remove_cvref_t<U0>, tuple>> if sizeof...(Types) is 1;
- [(12.2)](#12.2)
otherwise,bool_constant<!is_same_v<remove_cvref_t<U0>, allocator_arg_t> || is_-
same_v<remove_cvref_t<T0>, allocator_arg_t>> if sizeof...(Types) is 2 or 3;
- [(12.3)](#12.3)
otherwise, true_type[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1885)
*Constraints*:
- [(13.1)](#13.1)
sizeof...(Types) equals sizeof...(UTypes),
- [(13.2)](#13.2)
sizeof...(Types) ≥ 1, and
- [(13.3)](#13.3)
conjunction_v<*disambiguating-constraint*,
is_constructible<Types, UTypes>...> is
true[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1897)
*Effects*: Initializes the elements in the tuple with the
corresponding value in std::forward<UTypes>(u)[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1902)
*Remarks*: The expression inside explicit is equivalent to:!conjunction_v<is_convertible<UTypes, Types>...>
This constructor is defined as deleted if(reference_constructs_from_temporary_v<Types, UTypes&&> || ...) is true[.](#15.sentence-2)
[🔗](#lib:tuple,constructor___)
`tuple(const tuple& u) = default;
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1921)
*Mandates*: is_copy_constructible_v<Ti> is true for all i[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1925)
*Effects*: Initializes each element of *this with the
corresponding element of u[.](#17.sentence-1)
[🔗](#lib:tuple,constructor____)
`tuple(tuple&& u) = default;
`
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1937)
*Constraints*: is_move_constructible_v<Ti> is true for all i[.](#18.sentence-1)
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1941)
*Effects*: For all i, initializes the ith element of *this withstd::forward<Ti>(get<i>(u))[.](#19.sentence-1)
[🔗](#lib:tuple,constructor_____)
`template<class... UTypes> constexpr explicit(see below) tuple(tuple<UTypes...>& u);
template<class... UTypes> constexpr explicit(see below) tuple(const tuple<UTypes...>& u);
template<class... UTypes> constexpr explicit(see below) tuple(tuple<UTypes...>&& u);
template<class... UTypes> constexpr explicit(see below) tuple(const tuple<UTypes...>&& u);
`
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1956)
Let I be the pack 0, 1, …, (sizeof...(Types) - 1)[.](#20.sentence-1)
Let *FWD*(u) be static_cast<decltype(u)>(u)[.](#20.sentence-2)
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1960)
*Constraints*:
- [(21.1)](#21.1)
sizeof...(Types) equals sizeof...(UTypes), and
- [(21.2)](#21.2)
(is_constructible_v<Types, decltype(get<I>(*FWD*(u)))> && ...) is true, and
- [(21.3)](#21.3)
either sizeof...(Types) is not 1, or
(when Types... expands to T andUTypes... expands to U)is_convertible_v<decltype(u), T>,is_constructible_v<T, decltype(u)>, andis_same_v<T, U> are all false[.](#21.sentence-1)
[22](#22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1977)
*Effects*: For all i, initializes the ith element of *this with get<i>(*FWD*(u))[.](#22.sentence-1)
[23](#23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1982)
*Remarks*: The expression inside explicit is equivalent to:!(is_convertible_v<decltype(get<I>(*FWD*(u))), Types> && ...)
The constructor is defined as deleted if(reference_constructs_from_temporary_v<Types, decltype(get<I>(*FWD*(u)))> || ...) is true[.](#23.sentence-2)
[🔗](#lib:tuple,constructor______)
`template<class U1, class U2> constexpr explicit(see below) tuple(pair<U1, U2>& u);
template<class U1, class U2> constexpr explicit(see below) tuple(const pair<U1, U2>& u);
template<class U1, class U2> constexpr explicit(see below) tuple(pair<U1, U2>&& u);
template<class U1, class U2> constexpr explicit(see below) tuple(const pair<U1, U2>&& u);
`
[24](#24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2004)
Let *FWD*(u) be static_cast<decltype(u)>(u)[.](#24.sentence-1)
[25](#25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2007)
*Constraints*:
- [(25.1)](#25.1)
sizeof...(Types) is 2,
- [(25.2)](#25.2)
is_constructible_v<T0, decltype(get<0>(*FWD*(u)))> is true, and
- [(25.3)](#25.3)
is_constructible_v<T1, decltype(get<1>(*FWD*(u)))> is true[.](#25.sentence-1)
[26](#26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2018)
*Effects*: Initializes the first element with get<0>(*FWD*(u)) and
the second element with get<1>(*FWD*(u))[.](#26.sentence-1)
[27](#27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2023)
*Remarks*: The expression inside explicit is equivalent to:!is_convertible_v<decltype(get<0>(*FWD*(u))), T0> ||!is_convertible_v<decltype(get<1>(*FWD*(u))), T1>
The constructor is defined as deleted ifreference_constructs_from_temporary_v<T0, decltype(get<0>(*FWD*(u)))> || reference_constructs_from_temporary_v<T1, decltype(get<1>(*FWD*(u)))> is true[.](#27.sentence-2)
[🔗](#lib:tuple,constructor_______)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr explicit(see below) tuple(UTuple&& u);
`
[28](#28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2045)
Let I be the pack 0, 1, …, (sizeof...(Types) - 1)[.](#28.sentence-1)
[29](#29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2048)
*Constraints*:
- [(29.1)](#29.1)
[*different-from*](range.utility.helpers#concept:different-from "25.5.2Helper concepts[range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2Helper concepts"))
is true,
- [(29.2)](#29.2)
remove_cvref_t<UTuple> is not a specialization of ranges::subrange,
- [(29.3)](#29.3)
sizeof...(Types) equals tuple_size_v<remove_cvref_t<UTuple>>,
- [(29.4)](#29.4)
(is_constructible_v<Types, decltype(get<I>(std::forward<UTuple>(u)))> && ...) istrue, and
- [(29.5)](#29.5)
either sizeof...(Types) is not 1, or
(when Types... expands to T)is_convertible_v<UTuple, T> andis_constructible_v<T, UTuple> are both false[.](#29.sentence-1)
[30](#30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2075)
*Effects*: For all i, initializes the ith element of *this withget<i>(std::forward<UTuple>(u))[.](#30.sentence-1)
[31](#31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2080)
*Remarks*: The expression inside explicit is equivalent to:!(is_convertible_v<decltype(get<I>(std::forward<UTuple>(u))), Types> && ...)
The constructor is defined as deleted if(reference_constructs_from_temporary_v<Types, decltype(get<I>(std::forward<UTuple>(u)))>|| ...) is true[.](#31.sentence-2)
[🔗](#lib:tuple,constructor________)
`template<class Alloc>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a);
template<class Alloc>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const Types&...);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
template<class Alloc>
constexpr tuple(allocator_arg_t, const Alloc& a, const tuple&);
template<class Alloc>
constexpr tuple(allocator_arg_t, const Alloc& a, tuple&&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&);
template<class Alloc, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, UTuple&&);
`
[32](#32)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2139)
*Preconditions*: Alloc meets
the [*Cpp17Allocator*](allocator.requirements.general#:Cpp17Allocator "16.4.4.6.1General[allocator.requirements.general]") requirements ([[allocator.requirements.general]](allocator.requirements.general "16.4.4.6.1General"))[.](#32.sentence-1)
[33](#33)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2144)
*Effects*: Equivalent to the preceding constructors except that each element is constructed with[uses-allocator construction](allocator.uses.construction#def:uses-allocator_construction "20.2.8.2Uses-allocator construction[allocator.uses.construction]")[.](#33.sentence-1)

View File

@@ -0,0 +1,96 @@
[tuple.common.ref]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#common.ref)
### 22.4.10 common_reference related specializations [tuple.common.ref]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3037)
In the descriptions that follow:
- [(1.1)](#1.1)
Let TTypes be a pack formed by
the sequence of tuple_element_t<i, TTuple> for every integer 0≤i<tuple_size_v<TTuple>[.](#1.1.sentence-1)
- [(1.2)](#1.2)
Let UTypes be a pack formed by
the sequence of tuple_element_t<i, UTuple> for every integer 0≤i<tuple_size_v<UTuple>[.](#1.2.sentence-1)
[🔗](#lib:basic_common_reference,tuple)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") TTuple, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple,
template<class> class TQual, template<class> class UQual>
struct basic_common_reference<TTuple, UTuple, TQual, UQual> {
using type = see below;
};
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3061)
*Constraints*:
- [(2.1)](#2.1)
TTuple is a specialization of tuple orUTuple is a specialization of tuple[.](#2.1.sentence-1)
- [(2.2)](#2.2)
is_same_v<TTuple, decay_t<TTuple>> is true[.](#2.2.sentence-1)
- [(2.3)](#2.3)
is_same_v<UTuple, decay_t<UTuple>> is true[.](#2.3.sentence-1)
- [(2.4)](#2.4)
tuple_size_v<TTuple> equals tuple_size_v<UTuple>[.](#2.4.sentence-1)
- [(2.5)](#2.5)
tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...> denotes a type[.](#2.5.sentence-1)
The member [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") type denotes the typetuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>[.](#2.sentence-2)
[🔗](#lib:common_type,tuple)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") TTuple, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
struct common_type<TTuple, UTuple> {
using type = see below;
};
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3090)
*Constraints*:
- [(3.1)](#3.1)
TTuple is a specialization of tuple orUTuple is a specialization of tuple[.](#3.1.sentence-1)
- [(3.2)](#3.2)
is_same_v<TTuple, decay_t<TTuple>> is true[.](#3.2.sentence-1)
- [(3.3)](#3.3)
is_same_v<UTuple, decay_t<UTuple>> is true[.](#3.3.sentence-1)
- [(3.4)](#3.4)
tuple_size_v<TTuple> equals tuple_size_v<UTuple>[.](#3.4.sentence-1)
- [(3.5)](#3.5)
tuple<common_type_t<TTypes, UTypes>...> denotes a type[.](#3.5.sentence-1)
The member [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") type denotes the typetuple<common_type_t<TTypes, UTypes>...>[.](#3.sentence-2)

146
cppdraft/tuple/creation.md Normal file
View File

@@ -0,0 +1,146 @@
[tuple.creation]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#creation)
### 22.4.5 Tuple creation functions [tuple.creation]
[🔗](#lib:make_tuple)
`template<class... TTypes>
constexpr tuple<unwrap_ref_decay_t<TTypes>...> make_tuple(TTypes&&... t);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2579)
*Returns*: tuple<unwrap_ref_decay_t<TTypes>...>(std::forward<TTypes>(t)...)[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2583)
[*Example [1](#example-1)*:
int i; float j;
make_tuple(1, ref(i), cref(j)); creates a tuple of type tuple<int, int&, const float&>[.](#2.sentence-1)
— *end example*]
[🔗](#lib:forward_as_tuple)
`template<class... TTypes>
constexpr tuple<TTypes&&...> forward_as_tuple(TTypes&&... t) noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2601)
*Effects*: Constructs a tuple of references to the arguments in t suitable
for forwarding as arguments to a function[.](#3.sentence-1)
Because the result may contain references
to temporary objects, a program shall ensure that the return value of this
function does not outlive any of its arguments (e.g., the program should typically
not store the result in a named variable)[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2609)
*Returns*: tuple<TTypes&&...>(std::forward<TTypes>(t)...)[.](#4.sentence-1)
[🔗](#lib:tie)
`template<class... TTypes>
constexpr tuple<TTypes&...> tie(TTypes&... t) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2623)
*Returns*: tuple<TTypes&...>(t...)[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2627)
[*Example [2](#example-2)*:
tie functions allow one to create tuples that unpack
tuples into variables[.](#6.sentence-1)
ignore can be used for elements that
are not needed:int i; std::string s;
tie(i, ignore, s) = make_tuple(42, 3.14, "C++");// i == 42, s == "C++"
— *end example*]
[🔗](#lib:tuple_cat)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]")... Tuples>
constexpr tuple<CTypes...> tuple_cat(Tuples&&... tpls);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2647)
Let n be sizeof...(Tuples)[.](#7.sentence-1)
For every integer 0≤i<n:
- [(7.1)](#7.1)
Let Ti be the ith type in Tuples[.](#7.1.sentence-1)
- [(7.2)](#7.2)
Let Ui be remove_cvref_t<Ti>[.](#7.2.sentence-1)
- [(7.3)](#7.3)
Let tpi be the ith element
in the function parameter pack tpls[.](#7.3.sentence-1)
- [(7.4)](#7.4)
Let Si be tuple_size_v<Ui>[.](#7.4.sentence-1)
- [(7.5)](#7.5)
Let Eki be tuple_element_t<k, Ui>[.](#7.5.sentence-1)
- [(7.6)](#7.6)
Let eki be get<k>(std::forward<Ti>(tpi))[.](#7.6.sentence-1)
- [(7.7)](#7.7)
Let Elemsi be a pack of the types E0i,…,ESi−1i[.](#7.7.sentence-1)
- [(7.8)](#7.8)
Let elemsi be a pack of the expressions e0i,…,eSi−1i[.](#7.8.sentence-1)
The types in CTypes are equal to the ordered sequence of
the expanded packs of typesElems0..., Elems1..., …, Elemsn−1...[.](#7.sentence-3)
Let celems be the ordered sequence of
the expanded packs of expressionselems0..., …, elemsn−1...[.](#7.sentence-4)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2676)
*Mandates*: (is_constructible_v<CTypes, decltype(celems)> && ...) is true[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2680)
*Returns*: tuple<CTypes...>(celems...)[.](#9.sentence-1)

114
cppdraft/tuple/elem.md Normal file
View File

@@ -0,0 +1,114 @@
[tuple.elem]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#elem)
### 22.4.8 Element access [tuple.elem]
[🔗](#lib:get,tuple)
`template<size_t I, class... Types>
constexpr tuple_element_t<I, tuple<Types...>>&
get(tuple<Types...>& t) noexcept;
template<size_t I, class... Types>
constexpr tuple_element_t<I, tuple<Types...>>&&
get(tuple<Types...>&& t) noexcept; // #1
template<size_t I, class... Types>
constexpr const tuple_element_t<I, tuple<Types...>>&
get(const tuple<Types...>& t) noexcept; // #2
template<size_t I, class... Types>
constexpr const tuple_element_t<I, tuple<Types...>>&& get(const tuple<Types...>&& t) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2873)
*Mandates*: I < sizeof...(Types)[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2877)
*Returns*: A reference to the Ith element of t, where
indexing is zero-based[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2882)
[*Note [1](#note-1)*:
For the overload marked #1,
if a type T in Types is some reference type X&,
the return type is X&, not X&&[.](#3.sentence-1)
However, if the element type is a non-reference type T,
the return type is T&&[.](#3.sentence-2)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2891)
[*Note [2](#note-2)*:
Constness is shallow[.](#4.sentence-1)
For the overload marked #2,
if a type T in Types is some reference type X&,
the return type is X&, not const X&[.](#4.sentence-2)
However, if the element type is a non-reference type T,
the return type is const T&[.](#4.sentence-3)
This is consistent with how constness is defined to work
for non-static data members of reference type[.](#4.sentence-4)
— *end note*]
[🔗](#lib:get,tuple_)
`template<class T, class... Types>
constexpr T& get(tuple<Types...>& t) noexcept;
template<class T, class... Types>
constexpr T&& get(tuple<Types...>&& t) noexcept;
template<class T, class... Types>
constexpr const T& get(const tuple<Types...>& t) noexcept;
template<class T, class... Types>
constexpr const T&& get(const tuple<Types...>&& t) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2917)
*Mandates*: The type T occurs exactly once in Types[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2921)
*Returns*: A reference to the element of t corresponding to the typeT in Types[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2926)
[*Example [1](#example-1)*: const tuple<int, const int, double, double> t(1, 2, 3.4, 5.6);const int& i1 = get<int>(t); // OK, i1 has value 1const int& i2 = get<const int>(t); // OK, i2 has value 2const double& d = get<double>(t); // error: type double is not unique within t — *end example*]
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2937)
[*Note [3](#note-3)*:
The reason get is a
non-member function is that if this functionality had been
provided as a member function, code where the type
depended on a template parameter would have required using
the template keyword[.](#8.sentence-1)
— *end note*]

32
cppdraft/tuple/general.md Normal file
View File

@@ -0,0 +1,32 @@
[tuple.general]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#general)
### 22.4.1 General [tuple.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1508)
Subclause [[tuple]](tuple "22.4Tuples") describes the tuple library that provides a tuple type as
the class template tuple that can be instantiated with any number
of arguments[.](#1.sentence-1)
Each template argument specifies
the type of an element in the tuple[.](#1.sentence-2)
Consequently, tuples are
heterogeneous, fixed-size collections of values[.](#1.sentence-3)
An instantiation of tuple with
two arguments is similar to an instantiation of pair with the same two arguments[.](#1.sentence-4)
See [[pairs]](pairs "22.3Pairs")[.](#1.sentence-5)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1518)
In addition to being available via inclusion of the [<tuple>](tuple.syn#header:%3ctuple%3e "22.4.2Header <tuple> synopsis[tuple.syn]") header,ignore ([[tuple.syn]](tuple.syn "22.4.2Header <tuple> synopsis")) is available when[<utility>](utility.syn#header:%3cutility%3e "22.2.1Header <utility> synopsis[utility.syn]") ([[utility]](utility "22.2Utility components")) is included[.](#2.sentence-1)

117
cppdraft/tuple/helper.md Normal file
View File

@@ -0,0 +1,117 @@
[tuple.helper]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#helper)
### 22.4.7 Tuple helper classes [tuple.helper]
[🔗](#lib:tuple_size,in_general)
`template<class T> struct tuple_size;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2761)
Except where specified otherwise,
all specializations of tuple_size meet the[*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2Requirements[meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2Requirements")) with a
base characteristic of integral_constant<size_t, N> for some N[.](#1.sentence-1)
[🔗](#lib:tuple_size)
`template<class... Types>
struct tuple_size<tuple<Types...>> : integral_constant<size_t, sizeof...(Types)> { };
`
[🔗](#lib:tuple_element)
`template<size_t I, class... Types>
struct tuple_element<I, tuple<Types...>> {
using type = TI;
};
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2784)
*Mandates*: I < sizeof...(Types)[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2788)
*Type*: TI is the
type of the Ith element of Types,
where indexing is zero-based[.](#3.sentence-1)
[🔗](#lib:tuple_size_)
`template<class T> struct tuple_size<const T>;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2801)
Let TS denote tuple_size<T> of the cv-unqualified type T[.](#4.sentence-1)
If the expression TS::value is well-formed
when treated as an [unevaluated operand](expr.context#def:unevaluated_operand "7.2.3Context dependence[expr.context]"), then
each specialization of the template meets the [*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2Requirements[meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2Requirements"))
with a base characteristic ofintegral_constant<size_t, TS::value>
Otherwise, it has no member value[.](#4.sentence-3)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2812)
Access checking is performed as if in a context
unrelated to TS and T[.](#5.sentence-1)
Only the validity of the immediate context of the expression is considered[.](#5.sentence-2)
[*Note [1](#note-1)*:
The compilation of the expression can result in side effects
such as the instantiation of class template specializations and
function template specializations, the generation of implicitly-defined functions, and so on[.](#5.sentence-3)
Such side effects are not in the “immediate context” and
can result in the program being ill-formed[.](#5.sentence-4)
— *end note*]
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2824)
In addition to being available via inclusion of the [<tuple>](tuple.syn#header:%3ctuple%3e "22.4.2Header <tuple> synopsis[tuple.syn]") header,
the template is available
when any of the headers[<array>](array.syn#header:%3carray%3e "23.3.2Header <array> synopsis[array.syn]"),[<ranges>](ranges.syn#header:%3cranges%3e "25.2Header <ranges> synopsis[ranges.syn]"), or[<utility>](utility.syn#header:%3cutility%3e "22.2.1Header <utility> synopsis[utility.syn]") are included[.](#6.sentence-1)
[🔗](#lib:tuple_element_)
`template<size_t I, class T> struct tuple_element<I, const T>;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2840)
Let TE denote tuple_element_t<I, T> of the cv-unqualified type T[.](#7.sentence-1)
Then
each specialization of the template meets the [*Cpp17TransformationTrait*](meta.rqmts#:Cpp17TransformationTrait "21.3.2Requirements[meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2Requirements"))
with a member typedef type that names the type add_const_t<TE>[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2845)
In addition to being available via inclusion of the [<tuple>](tuple.syn#header:%3ctuple%3e "22.4.2Header <tuple> synopsis[tuple.syn]") header,
the template is available
when any of the headers[<array>](array.syn#header:%3carray%3e "23.3.2Header <array> synopsis[array.syn]"),[<ranges>](ranges.syn#header:%3cranges%3e "25.2Header <ranges> synopsis[ranges.syn]"), or[<utility>](utility.syn#header:%3cutility%3e "22.2.1Header <utility> synopsis[utility.syn]") are included[.](#8.sentence-1)

20
cppdraft/tuple/like.md Normal file
View File

@@ -0,0 +1,20 @@
[tuple.like]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#like)
### 22.4.3 Concept *tuple-like* [tuple.like]
[🔗](#concept:tuple-like)
`template<class T>
concept [tuple-like](#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") = see below; // exposition only
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1645)
A type T models and satisfies
the exposition-only concept [*tuple-like*](#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") if remove_cvref_t<T> is a specialization ofarray, complex, pair, tuple, or ranges::subrange[.](#1.sentence-1)

110
cppdraft/tuple/rel.md Normal file
View File

@@ -0,0 +1,110 @@
[tuple.rel]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#rel)
### 22.4.9 Relational operators [tuple.rel]
[🔗](#lib:operator==,tuple)
`template<class... TTypes, class... UTypes>
constexpr bool operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
template<class... TTypes, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr bool operator==(const tuple<TTypes...>& t, const UTuple& u);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2957)
For the first overload let UTuple be tuple<UTypes...>[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2960)
*Constraints*: For all i,
where 0 ≤ i < sizeof...(TTypes),get<i>(t) == get<i>(u) is a valid expression anddecltype(get<i>(t) == get<i>(u)) models [*boolean-testable*](concept.booleantestable#concept:boolean-testable "18.5.2Boolean testability[concept.booleantestable]")[.](#2.sentence-1)
sizeof...(TTypes) equalstuple_size_v<UTuple>[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2969)
*Returns*: true if get<i>(t) == get<i>(u) for alli, otherwise false[.](#3.sentence-1)
[*Note [1](#note-1)*:
If sizeof...(TTypes) equals zero, returns true[.](#3.sentence-2)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2977)
*Remarks*:
- [(4.1)](#4.1)
The elementary comparisons are performed in order from the
zeroth index upwards[.](#4.1.sentence-1)
No comparisons or element accesses are
performed after the first equality comparison that evaluates tofalse[.](#4.1.sentence-2)
- [(4.2)](#4.2)
The second overload is to be found via argument-dependent lookup ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4Argument-dependent name lookup")) only[.](#4.2.sentence-1)
[🔗](#lib:operator%3c=%3e,tuple)
`template<class... TTypes, class... UTypes>
constexpr common_comparison_category_t<synth-three-way-result<TTypes, UTypes>...>
operator<=>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
template<class... TTypes, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr common_comparison_category_t<synth-three-way-result<TTypes, Elems>...>
operator<=>(const tuple<TTypes...>& t, const UTuple& u);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3001)
For the second overload, Elems denotes the pack of typestuple_element_t<0, UTuple>,tuple_element_t<1, UTuple>, …,tuple_element_t<tuple_size_v<UTuple> - 1, UTuple>[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3007)
*Effects*: Performs a lexicographical comparison between t and u[.](#6.sentence-1)
If sizeof...(TTypes) equals zero,
returns strong_ordering::equal[.](#6.sentence-2)
Otherwise, equivalent to:if (auto c = *synth-three-way*(get<0>(t), get<0>(u)); c != 0) return c;return ttail <=> utail; where rtail for some r is a tuple containing all but the first element of r[.](#6.sentence-3)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3020)
*Remarks*: The second overload is to be found via argument-dependent lookup ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4Argument-dependent name lookup")) only[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3025)
[*Note [2](#note-2)*:
The above definition does not require ttail (or utail) to be constructed[.](#8.sentence-1)
It might not
even be possible, as t and u are not required to be copy
constructible[.](#8.sentence-2)
Also, all comparison operator functions are short circuited;
they do not perform element accesses beyond what is needed to determine the
result of the comparison[.](#8.sentence-3)
— *end note*]

41
cppdraft/tuple/special.md Normal file
View File

@@ -0,0 +1,41 @@
[tuple.special]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#special)
### 22.4.12 Tuple specialized algorithms [tuple.special]
[🔗](#lib:swap,tuple)
`template<class... Types>
constexpr void swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(see below);
template<class... Types>
constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see below);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3142)
*Constraints*:
- [(1.1)](#1.1)
For the first overload,(is_swappable_v<Types> && ...) is true[.](#1.1.sentence-1)
- [(1.2)](#1.2)
For the second overload,(is_swappable_v<const Types> && ...) is true[.](#1.2.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3153)
*Effects*: As if by x.swap(y)[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3157)
*Remarks*: The exception specification is equivalent to:noexcept(x.swap(y))

67
cppdraft/tuple/swap.md Normal file
View File

@@ -0,0 +1,67 @@
[tuple.swap]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#swap)
### 22.4.4 Class template tuple [[tuple.tuple]](tuple.tuple#tuple.swap)
#### 22.4.4.4 swap [tuple.swap]
[🔗](#lib:swap,tuple)
`constexpr void swap(tuple& rhs) noexcept(see below);
constexpr void swap(const tuple& rhs) const noexcept(see below);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2532)
Let i be in the range [0, sizeof...(Types)) in order[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2535)
*Mandates*:
- [(2.1)](#2.1)
For the first overload,(is_swappable_v<Types> && ...) is true[.](#2.1.sentence-1)
- [(2.2)](#2.2)
For the second overload,(is_swappable_v<const Types> && ...) is true[.](#2.2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2546)
*Preconditions*: For all i, get<i>(*this) is swappable with ([[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements")) get<i>(rhs)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2550)
*Effects*: For each i, calls swap for get<i>(*this) and get<i>(rhs)[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2554)
*Throws*: Nothing unless one of the element-wise swap calls throws an exception[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2558)
*Remarks*: The exception specification is equivalent to
- [(6.1)](#6.1)
(is_nothrow_swappable_v<Types> && ...) for the first overload and
- [(6.2)](#6.2)
(is_nothrow_swappable_v<const Types> && ...) for the second overload[.](#6.sentence-1)

11
cppdraft/tuple/syn.md Normal file

File diff suppressed because one or more lines are too long

31
cppdraft/tuple/traits.md Normal file
View File

@@ -0,0 +1,31 @@
[tuple.traits]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#traits)
### 22.4.11 Tuple traits [tuple.traits]
[🔗](#lib:uses_allocator%3ctuple%3e)
`template<class... Types, class Alloc>
struct uses_allocator<tuple<Types...>, Alloc> : true_type { };
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3118)
*Preconditions*: Alloc meets
the [*Cpp17Allocator*](allocator.requirements.general#:Cpp17Allocator "16.4.4.6.1General[allocator.requirements.general]") requirements ([[allocator.requirements.general]](allocator.requirements.general "16.4.4.6.1General"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3123)
[*Note [1](#note-1)*:
Specialization of this trait informs other library components thattuple can be constructed with an allocator, even though it does not have
a nested allocator_type[.](#2.sentence-1)
— *end note*]

949
cppdraft/tuple/tuple.md Normal file
View File

@@ -0,0 +1,949 @@
[tuple.tuple]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#tuple)
### 22.4.4 Class template tuple [tuple.tuple]
#### [22.4.4.1](#general) General [[tuple.tuple.general]](tuple.tuple.general)
[🔗](#lib:tuple)
namespace std {template<class... Types>class tuple {public:// [[tuple.cnstr]](#tuple.cnstr "22.4.4.2Construction"), tuple constructionconstexpr explicit(*see below*) tuple(); constexpr explicit(*see below*) tuple(const Types&...); // only if sizeof...(Types) >= 1template<class... UTypes>constexpr explicit(*see below*) tuple(UTypes&&...); // only if sizeof...(Types) >= 1 tuple(const tuple&) = default;
tuple(tuple&&) = default; template<class... UTypes>constexpr explicit(*see below*) tuple(tuple<UTypes...>&); template<class... UTypes>constexpr explicit(*see below*) tuple(const tuple<UTypes...>&); template<class... UTypes>constexpr explicit(*see below*) tuple(tuple<UTypes...>&&); template<class... UTypes>constexpr explicit(*see below*) tuple(const tuple<UTypes...>&&); template<class U1, class U2>constexpr explicit(*see below*) tuple(pair<U1, U2>&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr explicit(*see below*) tuple(const pair<U1, U2>&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr explicit(*see below*) tuple(pair<U1, U2>&&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr explicit(*see below*) tuple(const pair<U1, U2>&&); // only if sizeof...(Types) == 2template<[*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr explicit(*see below*) tuple(UTuple&&); // allocator-extended constructorstemplate<class Alloc>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a); template<class Alloc>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const Types&...); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, UTypes&&...); template<class Alloc>constexpr tuple(allocator_arg_t, const Alloc& a, const tuple&); template<class Alloc>constexpr tuple(allocator_arg_t, const Alloc& a, tuple&&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&); template<class Alloc, [*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, UTuple&&); // [[tuple.assign]](#tuple.assign "22.4.4.3Assignment"), tuple assignmentconstexpr tuple& operator=(const tuple&); constexpr const tuple& operator=(const tuple&) const; constexpr tuple& operator=(tuple&&) noexcept(*see below*); constexpr const tuple& operator=(tuple&&) const; template<class... UTypes>constexpr tuple& operator=(const tuple<UTypes...>&); template<class... UTypes>constexpr const tuple& operator=(const tuple<UTypes...>&) const; template<class... UTypes>constexpr tuple& operator=(tuple<UTypes...>&&); template<class... UTypes>constexpr const tuple& operator=(tuple<UTypes...>&&) const; template<class U1, class U2>constexpr tuple& operator=(const pair<U1, U2>&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr const tuple& operator=(const pair<U1, U2>&) const; // only if sizeof...(Types) == 2template<class U1, class U2>constexpr tuple& operator=(pair<U1, U2>&&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr const tuple& operator=(pair<U1, U2>&&) const; // only if sizeof...(Types) == 2template<[*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr tuple& operator=(UTuple&&); template<[*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr const tuple& operator=(UTuple&&) const; // [[tuple.swap]](#tuple.swap "22.4.4.4swap"), tuple swapconstexpr void swap(tuple&) noexcept(*see below*); constexpr void swap(const tuple&) const noexcept(*see below*); }; template<class... UTypes> tuple(UTypes...) -> tuple<UTypes...>; template<class T1, class T2> tuple(pair<T1, T2>) -> tuple<T1, T2>; template<class Alloc, class... UTypes> tuple(allocator_arg_t, Alloc, UTypes...) -> tuple<UTypes...>; template<class Alloc, class T1, class T2> tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; template<class Alloc, class... UTypes> tuple(allocator_arg_t, Alloc, tuple<UTypes...>) -> tuple<UTypes...>;}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1782)
If a program declares an explicit or partial specialization of tuple,
the program is ill-formed, no diagnostic required[.](#general-1.sentence-1)
#### [22.4.4.2](#tuple.cnstr) Construction [[tuple.cnstr]](tuple.cnstr)
[1](#tuple.cnstr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1788)
In the descriptions that follow, let i be in the range
[0, sizeof...(Types)) in order, Ti be the ith type in Types, andUi be the ith type in a template parameter pack named UTypes, where indexing
is zero-based[.](#tuple.cnstr-1.sentence-1)
[2](#tuple.cnstr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1795)
For each tuple constructor, an exception is thrown only if the construction of
one of the types in Types throws an exception[.](#tuple.cnstr-2.sentence-1)
[3](#tuple.cnstr-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1799)
The defaulted move and copy constructor, respectively, oftuple is a constexpr function if and only if all
required element-wise initializations for move and copy, respectively,
would be constexpr-suitable ([[dcl.constexpr]](dcl.constexpr "9.2.6The constexpr and consteval specifiers"))[.](#tuple.cnstr-3.sentence-1)
The defaulted move and copy constructor of tuple<> are
constexpr functions[.](#tuple.cnstr-3.sentence-2)
[4](#tuple.cnstr-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1807)
If is_trivially_destructible_v<Ti> is true for all Ti,
then the destructor of tuple is trivial[.](#tuple.cnstr-4.sentence-1)
[5](#tuple.cnstr-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1811)
The default constructor of tuple<> is trivial[.](#tuple.cnstr-5.sentence-1)
[🔗](#lib:tuple,constructor)
`constexpr explicit(see below) tuple();
`
[6](#tuple.cnstr-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1820)
*Constraints*: is_default_constructible_v<Ti> is true for all i[.](#tuple.cnstr-6.sentence-1)
[7](#tuple.cnstr-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1824)
*Effects*: Value-initializes each element[.](#tuple.cnstr-7.sentence-1)
[8](#tuple.cnstr-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1828)
*Remarks*: The expression inside explicit evaluates to true if and only if Ti is not
copy-list-initializable from an empty list
for at least one i[.](#tuple.cnstr-8.sentence-1)
[*Note [1](#tuple.cnstr-note-1)*:
This behavior can be implemented with a trait that checks whether
a const Ti& can be initialized with {}[.](#tuple.cnstr-8.sentence-2)
— *end note*]
[🔗](#lib:tuple,constructor_)
`constexpr explicit(see below) tuple(const Types&...);
`
[9](#tuple.cnstr-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1846)
*Constraints*: sizeof...(Types) ≥ 1 andis_copy_constructible_v<Ti> is true for all i[.](#tuple.cnstr-9.sentence-1)
[10](#tuple.cnstr-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1851)
*Effects*: Initializes each element with the value of the
corresponding parameter[.](#tuple.cnstr-10.sentence-1)
[11](#tuple.cnstr-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1856)
*Remarks*: The expression inside explicit is equivalent to:!conjunction_v<is_convertible<const Types&, Types>...>
[🔗](#lib:tuple,constructor__)
`template<class... UTypes> constexpr explicit(see below) tuple(UTypes&&... u);
`
[12](#tuple.cnstr-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1870)
Let *disambiguating-constraint* be:
- [(12.1)](#tuple.cnstr-12.1)
negation<is_same<remove_cvref_t<U0>, tuple>> if sizeof...(Types) is 1;
- [(12.2)](#tuple.cnstr-12.2)
otherwise,bool_constant<!is_same_v<remove_cvref_t<U0>, allocator_arg_t> || is_-
same_v<remove_cvref_t<T0>, allocator_arg_t>> if sizeof...(Types) is 2 or 3;
- [(12.3)](#tuple.cnstr-12.3)
otherwise, true_type[.](#tuple.cnstr-12.sentence-1)
[13](#tuple.cnstr-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1885)
*Constraints*:
- [(13.1)](#tuple.cnstr-13.1)
sizeof...(Types) equals sizeof...(UTypes),
- [(13.2)](#tuple.cnstr-13.2)
sizeof...(Types) ≥ 1, and
- [(13.3)](#tuple.cnstr-13.3)
conjunction_v<*disambiguating-constraint*,
is_constructible<Types, UTypes>...> is
true[.](#tuple.cnstr-13.sentence-1)
[14](#tuple.cnstr-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1897)
*Effects*: Initializes the elements in the tuple with the
corresponding value in std::forward<UTypes>(u)[.](#tuple.cnstr-14.sentence-1)
[15](#tuple.cnstr-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1902)
*Remarks*: The expression inside explicit is equivalent to:!conjunction_v<is_convertible<UTypes, Types>...>
This constructor is defined as deleted if(reference_constructs_from_temporary_v<Types, UTypes&&> || ...) is true[.](#tuple.cnstr-15.sentence-2)
[🔗](#lib:tuple,constructor___)
`tuple(const tuple& u) = default;
`
[16](#tuple.cnstr-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1921)
*Mandates*: is_copy_constructible_v<Ti> is true for all i[.](#tuple.cnstr-16.sentence-1)
[17](#tuple.cnstr-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1925)
*Effects*: Initializes each element of *this with the
corresponding element of u[.](#tuple.cnstr-17.sentence-1)
[🔗](#lib:tuple,constructor____)
`tuple(tuple&& u) = default;
`
[18](#tuple.cnstr-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1937)
*Constraints*: is_move_constructible_v<Ti> is true for all i[.](#tuple.cnstr-18.sentence-1)
[19](#tuple.cnstr-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1941)
*Effects*: For all i, initializes the ith element of *this withstd::forward<Ti>(get<i>(u))[.](#tuple.cnstr-19.sentence-1)
[🔗](#lib:tuple,constructor_____)
`template<class... UTypes> constexpr explicit(see below) tuple(tuple<UTypes...>& u);
template<class... UTypes> constexpr explicit(see below) tuple(const tuple<UTypes...>& u);
template<class... UTypes> constexpr explicit(see below) tuple(tuple<UTypes...>&& u);
template<class... UTypes> constexpr explicit(see below) tuple(const tuple<UTypes...>&& u);
`
[20](#tuple.cnstr-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1956)
Let I be the pack 0, 1, …, (sizeof...(Types) - 1)[.](#tuple.cnstr-20.sentence-1)
Let *FWD*(u) be static_cast<decltype(u)>(u)[.](#tuple.cnstr-20.sentence-2)
[21](#tuple.cnstr-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1960)
*Constraints*:
- [(21.1)](#tuple.cnstr-21.1)
sizeof...(Types) equals sizeof...(UTypes), and
- [(21.2)](#tuple.cnstr-21.2)
(is_constructible_v<Types, decltype(get<I>(*FWD*(u)))> && ...) is true, and
- [(21.3)](#tuple.cnstr-21.3)
either sizeof...(Types) is not 1, or
(when Types... expands to T andUTypes... expands to U)is_convertible_v<decltype(u), T>,is_constructible_v<T, decltype(u)>, andis_same_v<T, U> are all false[.](#tuple.cnstr-21.sentence-1)
[22](#tuple.cnstr-22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1977)
*Effects*: For all i, initializes the ith element of *this with get<i>(*FWD*(u))[.](#tuple.cnstr-22.sentence-1)
[23](#tuple.cnstr-23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1982)
*Remarks*: The expression inside explicit is equivalent to:!(is_convertible_v<decltype(get<I>(*FWD*(u))), Types> && ...)
The constructor is defined as deleted if(reference_constructs_from_temporary_v<Types, decltype(get<I>(*FWD*(u)))> || ...) is true[.](#tuple.cnstr-23.sentence-2)
[🔗](#lib:tuple,constructor______)
`template<class U1, class U2> constexpr explicit(see below) tuple(pair<U1, U2>& u);
template<class U1, class U2> constexpr explicit(see below) tuple(const pair<U1, U2>& u);
template<class U1, class U2> constexpr explicit(see below) tuple(pair<U1, U2>&& u);
template<class U1, class U2> constexpr explicit(see below) tuple(const pair<U1, U2>&& u);
`
[24](#tuple.cnstr-24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2004)
Let *FWD*(u) be static_cast<decltype(u)>(u)[.](#tuple.cnstr-24.sentence-1)
[25](#tuple.cnstr-25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2007)
*Constraints*:
- [(25.1)](#tuple.cnstr-25.1)
sizeof...(Types) is 2,
- [(25.2)](#tuple.cnstr-25.2)
is_constructible_v<T0, decltype(get<0>(*FWD*(u)))> is true, and
- [(25.3)](#tuple.cnstr-25.3)
is_constructible_v<T1, decltype(get<1>(*FWD*(u)))> is true[.](#tuple.cnstr-25.sentence-1)
[26](#tuple.cnstr-26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2018)
*Effects*: Initializes the first element with get<0>(*FWD*(u)) and
the second element with get<1>(*FWD*(u))[.](#tuple.cnstr-26.sentence-1)
[27](#tuple.cnstr-27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2023)
*Remarks*: The expression inside explicit is equivalent to:!is_convertible_v<decltype(get<0>(*FWD*(u))), T0> ||!is_convertible_v<decltype(get<1>(*FWD*(u))), T1>
The constructor is defined as deleted ifreference_constructs_from_temporary_v<T0, decltype(get<0>(*FWD*(u)))> || reference_constructs_from_temporary_v<T1, decltype(get<1>(*FWD*(u)))> is true[.](#tuple.cnstr-27.sentence-2)
[🔗](#lib:tuple,constructor_______)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr explicit(see below) tuple(UTuple&& u);
`
[28](#tuple.cnstr-28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2045)
Let I be the pack 0, 1, …, (sizeof...(Types) - 1)[.](#tuple.cnstr-28.sentence-1)
[29](#tuple.cnstr-29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2048)
*Constraints*:
- [(29.1)](#tuple.cnstr-29.1)
[*different-from*](range.utility.helpers#concept:different-from "25.5.2Helper concepts[range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2Helper concepts"))
is true,
- [(29.2)](#tuple.cnstr-29.2)
remove_cvref_t<UTuple> is not a specialization of ranges::subrange,
- [(29.3)](#tuple.cnstr-29.3)
sizeof...(Types) equals tuple_size_v<remove_cvref_t<UTuple>>,
- [(29.4)](#tuple.cnstr-29.4)
(is_constructible_v<Types, decltype(get<I>(std::forward<UTuple>(u)))> && ...) istrue, and
- [(29.5)](#tuple.cnstr-29.5)
either sizeof...(Types) is not 1, or
(when Types... expands to T)is_convertible_v<UTuple, T> andis_constructible_v<T, UTuple> are both false[.](#tuple.cnstr-29.sentence-1)
[30](#tuple.cnstr-30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2075)
*Effects*: For all i, initializes the ith element of *this withget<i>(std::forward<UTuple>(u))[.](#tuple.cnstr-30.sentence-1)
[31](#tuple.cnstr-31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2080)
*Remarks*: The expression inside explicit is equivalent to:!(is_convertible_v<decltype(get<I>(std::forward<UTuple>(u))), Types> && ...)
The constructor is defined as deleted if(reference_constructs_from_temporary_v<Types, decltype(get<I>(std::forward<UTuple>(u)))>|| ...) is true[.](#tuple.cnstr-31.sentence-2)
[🔗](#lib:tuple,constructor________)
`template<class Alloc>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a);
template<class Alloc>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const Types&...);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
template<class Alloc>
constexpr tuple(allocator_arg_t, const Alloc& a, const tuple&);
template<class Alloc>
constexpr tuple(allocator_arg_t, const Alloc& a, tuple&&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
template<class Alloc, class... UTypes>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
template<class Alloc, class U1, class U2>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&);
template<class Alloc, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr explicit(see below)
tuple(allocator_arg_t, const Alloc& a, UTuple&&);
`
[32](#tuple.cnstr-32)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2139)
*Preconditions*: Alloc meets
the [*Cpp17Allocator*](allocator.requirements.general#:Cpp17Allocator "16.4.4.6.1General[allocator.requirements.general]") requirements ([[allocator.requirements.general]](allocator.requirements.general "16.4.4.6.1General"))[.](#tuple.cnstr-32.sentence-1)
[33](#tuple.cnstr-33)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2144)
*Effects*: Equivalent to the preceding constructors except that each element is constructed with[uses-allocator construction](allocator.uses.construction#def:uses-allocator_construction "20.2.8.2Uses-allocator construction[allocator.uses.construction]")[.](#tuple.cnstr-33.sentence-1)
#### [22.4.4.3](#tuple.assign) Assignment [[tuple.assign]](tuple.assign)
[1](#tuple.assign-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2152)
For each tuple assignment operator, an exception is thrown only if the
assignment of one of the types in Types throws an exception[.](#tuple.assign-1.sentence-1)
In the function descriptions that follow, let i be in the range [0, sizeof...(Types))
in order, Ti be the ith type in Types,
and Ui be the ith type in a
template parameter pack named UTypes, where indexing is zero-based[.](#tuple.assign-1.sentence-2)
[🔗](#lib:operator=,tuple)
`constexpr tuple& operator=(const tuple& u);
`
[2](#tuple.assign-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2166)
*Effects*: Assigns each element of u to the corresponding
element of *this[.](#tuple.assign-2.sentence-1)
[3](#tuple.assign-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2171)
*Returns*: *this[.](#tuple.assign-3.sentence-1)
[4](#tuple.assign-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2175)
*Remarks*: This operator is defined as deleted unlessis_copy_assignable_v<Ti> is true for all i[.](#tuple.assign-4.sentence-1)
[🔗](#lib:operator=,tuple_)
`constexpr const tuple& operator=(const tuple& u) const;
`
[5](#tuple.assign-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2187)
*Constraints*: (is_copy_assignable_v<const Types> && ...) is true[.](#tuple.assign-5.sentence-1)
[6](#tuple.assign-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2191)
*Effects*: Assigns each element of u to the corresponding element of *this[.](#tuple.assign-6.sentence-1)
[7](#tuple.assign-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2195)
*Returns*: *this[.](#tuple.assign-7.sentence-1)
[🔗](#lib:operator=,tuple__)
`constexpr tuple& operator=(tuple&& u) noexcept(see below);
`
[8](#tuple.assign-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2206)
*Constraints*: is_move_assignable_v<Ti> is true for all i[.](#tuple.assign-8.sentence-1)
[9](#tuple.assign-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2210)
*Effects*: For all i, assigns std::forward<Ti>(get<i>(u)) toget<i>(*this)[.](#tuple.assign-9.sentence-1)
[10](#tuple.assign-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2215)
*Returns*: *this[.](#tuple.assign-10.sentence-1)
[11](#tuple.assign-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2219)
*Remarks*: The exception specification is equivalent to the logical and of the
following expressions:is_nothrow_move_assignable_v<Ti> where Ti is the ith type in Types[.](#tuple.assign-11.sentence-1)
[🔗](#lib:operator=,tuple___)
`constexpr const tuple& operator=(tuple&& u) const;
`
[12](#tuple.assign-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2235)
*Constraints*: (is_assignable_v<const Types&, Types> && ...) is true[.](#tuple.assign-12.sentence-1)
[13](#tuple.assign-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2239)
*Effects*: For all i,
assigns std::forward<Ti>(get<i>(u)) to get<i>(*this)[.](#tuple.assign-13.sentence-1)
[14](#tuple.assign-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2244)
*Returns*: *this[.](#tuple.assign-14.sentence-1)
[🔗](#lib:operator=,tuple____)
`template<class... UTypes> constexpr tuple& operator=(const tuple<UTypes...>& u);
`
[15](#tuple.assign-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2255)
*Constraints*:
- [(15.1)](#tuple.assign-15.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(15.2)](#tuple.assign-15.2)
is_assignable_v<Ti&, const Ui&> is true for all i[.](#tuple.assign-15.sentence-1)
[16](#tuple.assign-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2262)
*Effects*: Assigns each element of u to the corresponding element
of *this[.](#tuple.assign-16.sentence-1)
[17](#tuple.assign-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2267)
*Returns*: *this[.](#tuple.assign-17.sentence-1)
[🔗](#lib:operator=,tuple_____)
`template<class... UTypes> constexpr const tuple& operator=(const tuple<UTypes...>& u) const;
`
[18](#tuple.assign-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2278)
*Constraints*:
- [(18.1)](#tuple.assign-18.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(18.2)](#tuple.assign-18.2)
(is_assignable_v<const Types&, const UTypes&> && ...) is true[.](#tuple.assign-18.sentence-1)
[19](#tuple.assign-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2287)
*Effects*: Assigns each element of u to the corresponding element of *this[.](#tuple.assign-19.sentence-1)
[20](#tuple.assign-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2291)
*Returns*: *this[.](#tuple.assign-20.sentence-1)
[🔗](#lib:operator=,tuple______)
`template<class... UTypes> constexpr tuple& operator=(tuple<UTypes...>&& u);
`
[21](#tuple.assign-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2302)
*Constraints*:
- [(21.1)](#tuple.assign-21.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(21.2)](#tuple.assign-21.2)
is_assignable_v<Ti&, Ui> is true for all i[.](#tuple.assign-21.sentence-1)
[22](#tuple.assign-22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2309)
*Effects*: For all i, assigns std::forward<Ui>(get<i>(u)) toget<i>(*this)[.](#tuple.assign-22.sentence-1)
[23](#tuple.assign-23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2314)
*Returns*: *this[.](#tuple.assign-23.sentence-1)
[🔗](#lib:operator=,tuple_______)
`template<class... UTypes> constexpr const tuple& operator=(tuple<UTypes...>&& u) const;
`
[24](#tuple.assign-24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2325)
*Constraints*:
- [(24.1)](#tuple.assign-24.1)
sizeof...(Types) equals sizeof...(UTypes) and
- [(24.2)](#tuple.assign-24.2)
(is_assignable_v<const Types&, UTypes> && ...) is true[.](#tuple.assign-24.sentence-1)
[25](#tuple.assign-25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2334)
*Effects*: For all i,
assigns std::forward<Ui>(get<i>(u)) to get<i>(*this)[.](#tuple.assign-25.sentence-1)
[26](#tuple.assign-26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2339)
*Returns*: *this[.](#tuple.assign-26.sentence-1)
[🔗](#lib:operator=,tuple________)
`template<class U1, class U2> constexpr tuple& operator=(const pair<U1, U2>& u);
`
[27](#tuple.assign-27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2351)
*Constraints*:
- [(27.1)](#tuple.assign-27.1)
sizeof...(Types) is 2 and
- [(27.2)](#tuple.assign-27.2)
is_assignable_v<T0&, const U1&> is true, and
- [(27.3)](#tuple.assign-27.3)
is_assignable_v<T1&, const U2&> is true[.](#tuple.assign-27.sentence-1)
[28](#tuple.assign-28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2359)
*Effects*: Assigns u.first to the first element of *this and u.second to the second element of *this[.](#tuple.assign-28.sentence-1)
[29](#tuple.assign-29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2364)
*Returns*: *this[.](#tuple.assign-29.sentence-1)
[🔗](#lib:operator=,tuple_________)
`template<class U1, class U2> constexpr const tuple& operator=(const pair<U1, U2>& u) const;
`
[30](#tuple.assign-30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2375)
*Constraints*:
- [(30.1)](#tuple.assign-30.1)
sizeof...(Types) is 2,
- [(30.2)](#tuple.assign-30.2)
is_assignable_v<const T0&, const U1&> is true, and
- [(30.3)](#tuple.assign-30.3)
is_assignable_v<const T1&, const U2&> is true[.](#tuple.assign-30.sentence-1)
[31](#tuple.assign-31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2386)
*Effects*: Assigns u.first to the first element andu.second to the second element[.](#tuple.assign-31.sentence-1)
[32](#tuple.assign-32)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2391)
*Returns*: *this[.](#tuple.assign-32.sentence-1)
[🔗](#lib:operator=,tuple__________)
`template<class U1, class U2> constexpr tuple& operator=(pair<U1, U2>&& u);
`
[33](#tuple.assign-33)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2403)
*Constraints*:
- [(33.1)](#tuple.assign-33.1)
sizeof...(Types) is 2 and
- [(33.2)](#tuple.assign-33.2)
is_assignable_v<T0&, U1> is true, and
- [(33.3)](#tuple.assign-33.3)
is_assignable_v<T1&, U2> is true[.](#tuple.assign-33.sentence-1)
[34](#tuple.assign-34)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2411)
*Effects*: Assigns std::forward<U1>(u.first) to the first
element of *this and
std::forward<U2>(u.second) to the
second element of *this[.](#tuple.assign-34.sentence-2)
[35](#tuple.assign-35)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2417)
*Returns*: *this[.](#tuple.assign-35.sentence-1)
[🔗](#lib:operator=,tuple___________)
`template<class U1, class U2> constexpr const tuple& operator=(pair<U1, U2>&& u) const;
`
[36](#tuple.assign-36)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2428)
*Constraints*:
- [(36.1)](#tuple.assign-36.1)
sizeof...(Types) is 2,
- [(36.2)](#tuple.assign-36.2)
is_assignable_v<const T0&, U1> is true, and
- [(36.3)](#tuple.assign-36.3)
is_assignable_v<const T1&, U2> is true[.](#tuple.assign-36.sentence-1)
[37](#tuple.assign-37)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2439)
*Effects*: Assigns std::forward<U1>(u.first) to the first element and
std::forward<U2>(u.second) to the second element[.](#tuple.assign-37.sentence-2)
[38](#tuple.assign-38)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2444)
*Returns*: *this[.](#tuple.assign-38.sentence-1)
[🔗](#lib:operator=,tuple____________)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr tuple& operator=(UTuple&& u);
`
[39](#tuple.assign-39)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2456)
*Constraints*:
- [(39.1)](#tuple.assign-39.1)
[*different-from*](range.utility.helpers#concept:different-from "25.5.2Helper concepts[range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2Helper concepts"))
is true,
- [(39.2)](#tuple.assign-39.2)
remove_cvref_t<UTuple> is not a specialization of ranges::subrange,
- [(39.3)](#tuple.assign-39.3)
sizeof...(Types) equals tuple_size_v<remove_cvref_t<UTuple>>, and
- [(39.4)](#tuple.assign-39.4)
is_assignable_v<Ti&, decltype(get<i>(std::forward<UTuple>(u)))> is true for all i[.](#tuple.assign-39.sentence-1)
[40](#tuple.assign-40)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2476)
*Effects*: For all i, assigns get<i>(std::forward<UTuple>(u)) to get<i>(*this)[.](#tuple.assign-40.sentence-1)
[41](#tuple.assign-41)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2481)
*Returns*: *this[.](#tuple.assign-41.sentence-1)
[🔗](#lib:operator=,tuple_____________)
`template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr const tuple& operator=(UTuple&& u) const;
`
[42](#tuple.assign-42)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2493)
*Constraints*:
- [(42.1)](#tuple.assign-42.1)
[*different-from*](range.utility.helpers#concept:different-from "25.5.2Helper concepts[range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2Helper concepts"))
is true,
- [(42.2)](#tuple.assign-42.2)
remove_cvref_t<UTuple> is not a specialization of ranges::subrange,
- [(42.3)](#tuple.assign-42.3)
sizeof...(Types) equals tuple_size_v<remove_cvref_t<UTuple>>, and
- [(42.4)](#tuple.assign-42.4)
is_assignable_v<const Ti&, decltype(get<i>(std::forward<UTuple>(u)))> is true for all i[.](#tuple.assign-42.sentence-1)
[43](#tuple.assign-43)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2513)
*Effects*: For all i, assignsget<i>(std::forward<UTuple>(u)) to get<i>(*this)[.](#tuple.assign-43.sentence-1)
[44](#tuple.assign-44)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2518)
*Returns*: *this[.](#tuple.assign-44.sentence-1)
#### [22.4.4.4](#tuple.swap) swap [[tuple.swap]](tuple.swap)
[🔗](#lib:swap,tuple)
`constexpr void swap(tuple& rhs) noexcept(see below);
constexpr void swap(const tuple& rhs) const noexcept(see below);
`
[1](#tuple.swap-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2532)
Let i be in the range [0, sizeof...(Types)) in order[.](#tuple.swap-1.sentence-1)
[2](#tuple.swap-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2535)
*Mandates*:
- [(2.1)](#tuple.swap-2.1)
For the first overload,(is_swappable_v<Types> && ...) is true[.](#tuple.swap-2.1.sentence-1)
- [(2.2)](#tuple.swap-2.2)
For the second overload,(is_swappable_v<const Types> && ...) is true[.](#tuple.swap-2.2.sentence-1)
[3](#tuple.swap-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2546)
*Preconditions*: For all i, get<i>(*this) is swappable with ([[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements")) get<i>(rhs)[.](#tuple.swap-3.sentence-1)
[4](#tuple.swap-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2550)
*Effects*: For each i, calls swap for get<i>(*this) and get<i>(rhs)[.](#tuple.swap-4.sentence-1)
[5](#tuple.swap-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2554)
*Throws*: Nothing unless one of the element-wise swap calls throws an exception[.](#tuple.swap-5.sentence-1)
[6](#tuple.swap-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2558)
*Remarks*: The exception specification is equivalent to
- [(6.1)](#tuple.swap-6.1)
(is_nothrow_swappable_v<Types> && ...) for the first overload and
- [(6.2)](#tuple.swap-6.2)
(is_nothrow_swappable_v<const Types> && ...) for the second overload[.](#tuple.swap-6.sentence-1)

View File

@@ -0,0 +1,21 @@
[tuple.tuple.general]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#tuple.general)
### 22.4.4 Class template tuple [[tuple.tuple]](tuple.tuple#general)
#### 22.4.4.1 General [tuple.tuple.general]
[🔗](#lib:tuple)
namespace std {template<class... Types>class tuple {public:// [[tuple.cnstr]](tuple.cnstr "22.4.4.2Construction"), tuple constructionconstexpr explicit(*see below*) tuple(); constexpr explicit(*see below*) tuple(const Types&...); // only if sizeof...(Types) >= 1template<class... UTypes>constexpr explicit(*see below*) tuple(UTypes&&...); // only if sizeof...(Types) >= 1 tuple(const tuple&) = default;
tuple(tuple&&) = default; template<class... UTypes>constexpr explicit(*see below*) tuple(tuple<UTypes...>&); template<class... UTypes>constexpr explicit(*see below*) tuple(const tuple<UTypes...>&); template<class... UTypes>constexpr explicit(*see below*) tuple(tuple<UTypes...>&&); template<class... UTypes>constexpr explicit(*see below*) tuple(const tuple<UTypes...>&&); template<class U1, class U2>constexpr explicit(*see below*) tuple(pair<U1, U2>&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr explicit(*see below*) tuple(const pair<U1, U2>&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr explicit(*see below*) tuple(pair<U1, U2>&&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr explicit(*see below*) tuple(const pair<U1, U2>&&); // only if sizeof...(Types) == 2template<[*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr explicit(*see below*) tuple(UTuple&&); // allocator-extended constructorstemplate<class Alloc>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a); template<class Alloc>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const Types&...); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, UTypes&&...); template<class Alloc>constexpr tuple(allocator_arg_t, const Alloc& a, const tuple&); template<class Alloc>constexpr tuple(allocator_arg_t, const Alloc& a, tuple&&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&); template<class Alloc, class... UTypes>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); template<class Alloc, class U1, class U2>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&); template<class Alloc, [*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, UTuple&&); // [[tuple.assign]](tuple.assign "22.4.4.3Assignment"), tuple assignmentconstexpr tuple& operator=(const tuple&); constexpr const tuple& operator=(const tuple&) const; constexpr tuple& operator=(tuple&&) noexcept(*see below*); constexpr const tuple& operator=(tuple&&) const; template<class... UTypes>constexpr tuple& operator=(const tuple<UTypes...>&); template<class... UTypes>constexpr const tuple& operator=(const tuple<UTypes...>&) const; template<class... UTypes>constexpr tuple& operator=(tuple<UTypes...>&&); template<class... UTypes>constexpr const tuple& operator=(tuple<UTypes...>&&) const; template<class U1, class U2>constexpr tuple& operator=(const pair<U1, U2>&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr const tuple& operator=(const pair<U1, U2>&) const; // only if sizeof...(Types) == 2template<class U1, class U2>constexpr tuple& operator=(pair<U1, U2>&&); // only if sizeof...(Types) == 2template<class U1, class U2>constexpr const tuple& operator=(pair<U1, U2>&&) const; // only if sizeof...(Types) == 2template<[*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr tuple& operator=(UTuple&&); template<[*tuple-like*](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>constexpr const tuple& operator=(UTuple&&) const; // [[tuple.swap]](tuple.swap "22.4.4.4swap"), tuple swapconstexpr void swap(tuple&) noexcept(*see below*); constexpr void swap(const tuple&) const noexcept(*see below*); }; template<class... UTypes> tuple(UTypes...) -> tuple<UTypes...>; template<class T1, class T2> tuple(pair<T1, T2>) -> tuple<T1, T2>; template<class Alloc, class... UTypes> tuple(allocator_arg_t, Alloc, UTypes...) -> tuple<UTypes...>; template<class Alloc, class T1, class T2> tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; template<class Alloc, class... UTypes> tuple(allocator_arg_t, Alloc, tuple<UTypes...>) -> tuple<UTypes...>;}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L1782)
If a program declares an explicit or partial specialization of tuple,
the program is ill-formed, no diagnostic required[.](#1.sentence-1)