950 lines
36 KiB
Markdown
950 lines
36 KiB
Markdown
[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.2 Construction"), 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.3 Concept 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.3 Concept tuple-like [tuple.like]") UTuple>constexpr explicit(*see below*) tuple(allocator_arg_t, const Alloc& a, UTuple&&); // [[tuple.assign]](#tuple.assign "22.4.4.3 Assignment"), 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.3 Concept tuple-like [tuple.like]") UTuple>constexpr tuple& operator=(UTuple&&); template<[*tuple-like*](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") UTuple>constexpr const tuple& operator=(UTuple&&) const; // [[tuple.swap]](#tuple.swap "22.4.4.4 swap"), 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.6 The 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.3 Concept 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.2 Helper concepts [range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2 Helper 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.3 Concept 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.1 General [allocator.requirements.general]") requirements ([[allocator.requirements.general]](allocator.requirements.general "16.4.4.6.1 General"))[.](#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.2 Uses-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.3 Concept 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.2 Helper concepts [range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2 Helper 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.3 Concept 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.2 Helper concepts [range.utility.helpers]")<UTuple, tuple> ([[range.utility.helpers]](range.utility.helpers "25.5.2 Helper 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.3 Swappable 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)
|