Przestrzenie nazw
Warianty

std::pair::operator=

Z cppreference.com
<tbody> </tbody>
pair& operator=( const pair& other );
(1)
template< class U1, class U2 > pair& operator=( const pair<U1,U2>& other );
(2)
pair& operator=( pair&& other ) noexcept(/* zobacz niżej */);
(3) (od C++11)
template< class U1, class U2 > pair& operator=( pair<U1,U2>&& other );
(4) (od C++11)

Zamienia zawartość pary.

1) Operator przypisania przez kopiowanie. Zastępuje zawartość pary zawartością other.
2) Przypisuje wartość other.first do first i other.second do second
3) Operator przypisania przez przeniesienie. astępuje zawartość pary zawartością other, używając semantyki move.
4) Przypisuje std::forward<U1>(p.first) do first i std::forward<U2>(p.second) do second.

Zachowanie funkcji jest niezdefiniowane chyba, że:

  • Dla (1), zarówno std::is_copy_assignable<first_type>::value jak i std::is_copy_assignable<second_type>::valuetrue.
  • Dla (2), zarówno std::is_assignable<first_type&, const U1&>::value jak i std::is_assignable<second_type&, const U2&>::valuetrue.
  • Dla (3), zarówno std::is_move_assignable<first_type>::value jak i std::is_move_assignable<second_type>::valuetrue.
  • Dla (4), zarówno std::is_assignable<first_type&, U1&&>::value jak i std::is_assignable<second_type&, U2&&>::valuetrue.

Parametry

other - para wartości, które zastąpią obecną zawartość pary

Zwracana wartość

*this

Wyjątki

1-2) (brak)
3) noexcept specification:  (od C++11)
<tbody> </tbody>
noexcept( is_nothrow_move_assignable<T1>::value && is_nothrow_move_assignable<T2>::value )
4) (brak)

Przykład

Zobacz także

Morty Proxy This is a proxified and sanitized view of the page, visit original site.