Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/utility/pair/operator="

From cppreference.com
< cpp‎ | utility‎ | pair
(Undo revision 44917 by Cubbi (talk) oops)
m (Shorten template names. Use {{lc}} where appropriate.)
Line 1: Line 1:
 
{{cpp/utility/pair/title | operator{{=}}}}
 
{{cpp/utility/pair/title | operator{{=}}}}
 
{{cpp/utility/pair/navbar}}
 
{{cpp/utility/pair/navbar}}
{{ddcl list begin}}
+
{{dcl begin}}
{{ddcl list item | num=1 | 1=
+
{{dcl | num=1 | 1=
 
pair& operator=( const pair& other );
 
pair& operator=( const pair& other );
 
}}
 
}}
{{ddcl list item | num=2 | 1=
+
{{dcl | num=2 | 1=
 
template< class U1, class U2 >
 
template< class U1, class U2 >
 
pair& operator=( const pair<U1,U2>& other );
 
pair& operator=( const pair<U1,U2>& other );
 
}}
 
}}
{{ddcl list item | num=3 | notes={{mark since c++11}} | 1=
+
{{dcl | num=3 | notes={{mark since c++11}} | 1=
 
pair& operator=( pair&& other );
 
pair& operator=( pair&& other );
 
}}
 
}}
{{ddcl list item | num=4 | notes={{mark since c++11}} | 1=
+
{{dcl | num=4 | notes={{mark since c++11}} | 1=
 
template< class U1, class U2 >
 
template< class U1, class U2 >
 
pair& operator=( pair<U1,U2>&& other );
 
pair& operator=( pair<U1,U2>&& other );
 
}}
 
}}
{{ddcl list end}}
+
{{dcl end}}
  
 
Replaces the contents of the pair.
 
Replaces the contents of the pair.
Line 29: Line 29:
  
 
===Parameters===
 
===Parameters===
{{param list begin}}
+
{{par begin}}
{{param list item | other | pair of values to replace the contents of this pair }}
+
{{par | other | pair of values to replace the contents of this pair }}
{{param list end}}  
+
{{par end}}  
  
 
===Return value===
 
===Return value===
Line 54: Line 54:
 
===See also===
 
===See also===
  
{{dcl list begin}}
+
{{dsc begin}}
{{dcl list end}}
+
{{dsc end}}
  
 
[[de:cpp/utility/pair/operator=]]
 
[[de:cpp/utility/pair/operator=]]

Revision as of 20:16, 31 May 2013

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
 
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.

Contents

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

See also