##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::pair::operator=

From cppreference.com
< cpp‎ | utility‎ | pair

pair& operator=( const pair& other ); | (1) |
template< class U1, class U2 > pair& operator=( const pair<U1,U2>& other ); | (2) |
pair& operator=( pair&& other ); | (3) | (since C++11)
template< class U1, class U2 > pair& operator=( pair<U1,U2>&& other ); | (4) | (since C++11)

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`.

### [edit] Parameters

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

### [edit] Return value

*this

### [edit] Exceptions

1-2) (none)
3)
`noexcept` specification:
noexcept(

is_nothrow_move_assignable<T1>::value &&
is_nothrow_move_assignable<T2>::value

)
4) (none)

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/pair/operator%3D&oldid=72101"
Categories:

- conditionally noexcept
- Todo no example