13 KiB
[tuple.assign]
22 General utilities library [utilities]
22.4 Tuples [tuple]
22.4.4 Class template tuple [tuple.tuple]
22.4.4.3 Assignment [tuple.assign]
For each tuple assignment operator, an exception is thrown only if the assignment of one of the types in Types throws an exception.
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.
constexpr tuple& operator=(const tuple& u);
Effects: Assigns each element of u to the corresponding element of *this.
Returns: *this.
Remarks: This operator is defined as deleted unlessis_copy_assignable_v is true for all i.
constexpr const tuple& operator=(const tuple& u) const;
Constraints: (is_copy_assignable_v && ...) is true.
Effects: Assigns each element of u to the corresponding element of *this.
Returns: *this.
constexpr tuple& operator=(tuple&& u) noexcept(see below);
Constraints: is_move_assignable_v is true for all i.
Effects: For all i, assigns std::forward(get(u)) toget(*this).
Returns: *this.
Remarks: The exception specification is equivalent to the logical and of the following expressions:is_nothrow_move_assignable_v where Ti is the ith type in Types.
constexpr const tuple& operator=(tuple&& u) const;
Constraints: (is_assignable_v<const Types&, Types> && ...) is true.
Effects: For all i, assigns std::forward(get(u)) to get(*this).
Returns: *this.
template<class... UTypes> constexpr tuple& operator=(const tuple<UTypes...>& u);
Constraints:
sizeof...(Types) equals sizeof...(UTypes) and
is_assignable_v<Ti&, const Ui&> is true for all i.
Effects: Assigns each element of u to the corresponding element of *this.
Returns: *this.
template<class... UTypes> constexpr const tuple& operator=(const tuple<UTypes...>& u) const;
Constraints:
sizeof...(Types) equals sizeof...(UTypes) and
(is_assignable_v<const Types&, const UTypes&> && ...) is true.
Effects: Assigns each element of u to the corresponding element of *this.
Returns: *this.
template<class... UTypes> constexpr tuple& operator=(tuple<UTypes...>&& u);
Constraints:
sizeof...(Types) equals sizeof...(UTypes) and
is_assignable_v<Ti&, Ui> is true for all i.
Effects: For all i, assigns std::forward(get(u)) toget(*this).
Returns: *this.
template<class... UTypes> constexpr const tuple& operator=(tuple<UTypes...>&& u) const;
Constraints:
sizeof...(Types) equals sizeof...(UTypes) and
(is_assignable_v<const Types&, UTypes> && ...) is true.
Effects: For all i, assigns std::forward(get(u)) to get(*this).
Returns: *this.
template<class U1, class U2> constexpr tuple& operator=(const pair<U1, U2>& u);
Constraints:
sizeof...(Types) is 2 and
is_assignable_v<T0&, const U1&> is true, and
is_assignable_v<T1&, const U2&> is true.
Effects: Assigns u.first to the first element of *this and u.second to the second element of *this.
Returns: *this.
template<class U1, class U2> constexpr const tuple& operator=(const pair<U1, U2>& u) const;
Constraints:
sizeof...(Types) is 2,
is_assignable_v<const T0&, const U1&> is true, and
is_assignable_v<const T1&, const U2&> is true.
Effects: Assigns u.first to the first element andu.second to the second element.
Returns: *this.
template<class U1, class U2> constexpr tuple& operator=(pair<U1, U2>&& u);
Constraints:
sizeof...(Types) is 2 and
is_assignable_v<T0&, U1> is true, and
is_assignable_v<T1&, U2> is true.
Effects: Assigns std::forward(u.first) to the first element of *this and
std::forward(u.second) to the second element of *this.
Returns: *this.
template<class U1, class U2> constexpr const tuple& operator=(pair<U1, U2>&& u) const;
Constraints:
sizeof...(Types) is 2,
is_assignable_v<const T0&, U1> is true, and
is_assignable_v<const T1&, U2> is true.
Effects: Assigns std::forward(u.first) to the first element and
std::forward(u.second) to the second element.
Returns: *this.
template<[tuple-like](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") UTuple> constexpr tuple& operator=(UTuple&& u);
Constraints:
different-from<UTuple, tuple> ([range.utility.helpers]) is true,
remove_cvref_t is not a specialization of ranges::subrange,
sizeof...(Types) equals tuple_size_v<remove_cvref_t>, and
is_assignable_v<Ti&, decltype(get(std::forward(u)))> is true for all i.
Effects: For all i, assigns get(std::forward(u)) to get(*this).
Returns: *this.
template<[tuple-like](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") UTuple> constexpr const tuple& operator=(UTuple&& u) const;
Constraints:
different-from<UTuple, tuple> ([range.utility.helpers]) is true,
remove_cvref_t is not a specialization of ranges::subrange,
sizeof...(Types) equals tuple_size_v<remove_cvref_t>, and
is_assignable_v<const Ti&, decltype(get(std::forward(u)))> is true for all i.
Effects: For all i, assignsget(std::forward(u)) to get(*this).
Returns: *this.