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

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)