std::tuple<Types...>::operator= (3) - Linux Manuals
std::tuple<Types...>::operator=: std::tuple<Types...>::operator=
NAME
std::tuple<Types...>::operator= - std::tuple<Types...>::operator=
Synopsis
tuple& operator=( const tuple& other ); (since C++11)
constexpr tuple& operator=( const tuple& other ); (since C++20)
tuple& operator=( tuple&& other ) noexcept(/* see below */); (since C++11)
constexpr tuple& operator=( tuple&& other ) noexcept(/* see below */); (since C++20)
template< class... UTypes > (since C++11)
tuple& operator=( const tuple<UTypes...>& other ); (until C++20)
template< class... UTypes > (since C++20)
constexpr tuple& operator=( const tuple<UTypes...>& other );
template< class... UTypes > (1) (since C++11)
tuple& operator=( tuple<UTypes...>&& other ); (until C++20)
template< class... UTypes > (2) (since C++20)
constexpr tuple& operator=( tuple<UTypes...>&& other ); (3)
template< class U1, class U2 > (since C++11)
tuple& operator=( const pair<U1,U2>& p ); (4) (until C++20)
template< class U1, class U2 > (since C++20)
constexpr tuple& operator=( const pair<U1,U2>& p ); (5)
template< class U1, class U2 > (since C++11)
tuple& operator=( pair<U1,U2>&& p ); (6) (until C++20)
template< class U1, class U2 > (since C++20)
constexpr tuple& operator=( pair<U1,U2>&& p );
Replaces the contents of the tuple with the contents of another tuple or a pair.
1) Copy assignment operator. Assigns each element of other to the corresponding element of *this.
2) Move assignment operator. For all i, assigns std::forward<Ti>(get<i>(other)) to get<i>(*this).
3) For all i, assigns std::get<i>(other) to std::get<i>(*this).
4) For all i, assigns std::forward<Ui>(std::get<i>(other)) to std::get<i>(*this).
5) Assigns p.first to the first element of *this and p.second to the second element of *this.
6) Assigns std::forward<U1>(p.first) to the first element of *this and std::forward<U2>(p.second) to the second element of *this.
The behavior of these functions is undefined unless:
* For (1), std::is_copy_assignable<T_i>::value is true for all T_i in Types.
* For (2), std::is_move_assignable<T_i>::value is true for all T_i in Types.
* For (3), sizeof...(UTypes) == sizeof...(Types) and std::is_assignable<T_i&, const U_i&>::value is true for all corresponding pairs of types T_i in Types and U_i in UTypes. (until C++17)
* For (4), sizeof...(UTypes) == sizeof...(Types) and std::is_assignable<T_i&, U_i&&>::value is true for all corresponding pairs of types T_i in Types and U_i in UTypes.
* For (5), sizeof...(Types) == 2 and std::is_assignable<T_0&, const U1&>::value and std::is_assignable<T_1&, const U2&>::value are both true, where T_0 and T_1 are the two types constituting Types.
* For (6), sizeof...(Types) == 2 and std::is_assignable<T_0&, U1&&>::value and std::is_assignable<T_1&, U2&&>::value are both true, where T_0 and T_1 are the two types constituting Types.
These functions do not participate in overload resolution (or, for the copy assignment operator, is defined as deleted) if any required assignment operation is invalid or if there is a size mismatch. Specifically:
* (1) is defined as deleted unless std::is_copy_assignable<T_i>::value is true for all T_i in Types.
* (2) does not participate in overload resolution unless std::is_move_assignable<T_i>::value is true for all T_i in Types.
* (3) does not participate in overload resolution unless sizeof...(UTypes) == sizeof...(Types) and std::is_assignable<T_i&, const U_i&>::value is true for all corresponding pairs of types T_i in Types and U_i in UTypes. (since C++17)
* (4) does not participate in overload resolution unless sizeof...(UTypes) == sizeof...(Types) and std::is_assignable<T_i&, U_i&&>::value is true for all corresponding pairs of types T_i in Types and U_i in UTypes.
* (5) does not participate in overload resolution unless sizeof...(Types) == 2, std::is_assignable<T_0&, const U1&>::value and std::is_assignable<T_1&, const U2&>::value are both true, where T_0 and T_1 are the two types constituting Types.
* (6) does not participate in overload resolution unless std::is_assignable<T_0&, U1&&>::value and std::is_assignable<T_1&, U2&&>::value are both true, where T_0 and T_1 are the two types constituting Types.
Parameters
other - tuple to replace the contents of this tuple
p - pair to replace the contents of this 2-tuple
Return value
*this
Exceptions
1) (none)
2)
noexcept specification:
noexcept(
is_nothrow_move_assignable<T0>::value &&
is_nothrow_move_assignable<T1>::value &&
is_nothrow_move_assignable<T2>::value &&
...
)
3-6) (none)
Example
This section is incomplete
Reason: no example
See also