std::pair<T1,T2>::operator= (3) - Linux Manuals

std::pair<T1,T2>::operator=: std::pair<T1,T2>::operator=

NAME

std::pair<T1,T2>::operator= - std::pair<T1,T2>::operator=

Synopsis


pair& operator=( const pair& other ); (until C++20)
constexpr pair& operator=( const pair& other ); (since C++20)
template< class U1, class U2 > (until C++20)
pair& operator=( const pair<U1,U2>& other );
template< class U1, class U2 > (since C++20)
constexpr pair& operator=( const pair<U1,U2>& other );
pair& operator=( pair&& other ) noexcept(/* see below */); (1) (since C++11)
                                                                         (2) (until C++20)
constexpr pair& operator=( pair&& other ) noexcept(/* see below */); (since C++20)
template< class U1, class U2 > (3) (since C++11)
pair& operator=( pair<U1,U2>&& other ); (4) (until C++20)
template< class U1, class U2 > (since C++20)
constexpr pair& operator=( pair<U1,U2>&& other );


Replaces the contents of the pair.
1) Copy assignment operator. Replaces the contents with a copy of the contents of other.
2) Assigns other.first to first and other.second to second
3) Move assignment operator. Replaces the contents with those of other using move semantics.
4) Assigns std::forward<U1>(p.first) to first and std::forward<U2>(p.second) to second.


The behavior of these functions is undefined unless:


* For (1),std::is_copy_assignable<first_type>::value and std::is_copy_assignable<second_type>::value are both true.
* For (2),std::is_assignable<first_type&, const U1&>::value and std::is_assignable<second_type&, const U2&>::value are both true. (until C++17)
* For (3),std::is_move_assignable<first_type>::value and std::is_move_assignable<second_type>::value are both true.
* For (4),std::is_assignable<first_type&, U1&&>::value and std::is_assignable<second_type&, U2&&>::value are both true.


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. Specifically:


* (1) is defined as deleted unless std::is_copy_assignable_v<first_type> and std::is_copy_assignable_v<second_type> are both true.
* (2) does not participate in overload resolution unless std::is_assignable_v<first_type&, const U1&> and std::is_assignable_v<second_type&, const U2&> are both true. (since C++17)
* (3) does not participate in overload resolution unless std::is_move_assignable_v<first_type> and std::is_move_assignable_v<second_type> are both true.
* (4) does not participate in overload resolution unless std::is_assignable_v<first_type&, U1&&> and std::is_assignable_v<second_type&, U2&&> are both true.

Parameters


other - pair of values to replace the contents of this pair

Return value


*this

Exceptions


1-2) (none)
3)
noexcept specification:
noexcept(
is_nothrow_move_assignable<T1>::value &&
is_nothrow_move_assignable<T2>::value
)
4) (none)

Example


 This section is incomplete
 Reason: no example

See also