名前空間
変種

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

提供: cppreference.com
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
std::pair
メンバ関数
非メンバ関数
(C++20未満)(C++20未満)(C++20未満)(C++20未満)(C++20未満)(C++20)
(C++11)
推定ガイド(C++17)
ヘルパークラス
(C++11)
 
<tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody>
(1)
pair& operator=( const pair& other );
(C++20未満)
constexpr pair& operator=( const pair& other );
(C++20以上)
(2)
template< class U1, class U2 > pair& operator=( const pair<U1,U2>& other );
(C++20未満)
template< class U1, class U2 > constexpr pair& operator=( const pair<U1,U2>& other );
(C++20以上)
(3)
pair& operator=( pair&& other ) noexcept(/* see below */);
(C++11以上)
(C++20未満)
constexpr pair& operator=( pair&& other ) noexcept(/* see below */);
(C++20以上)
(4)
template< class U1, class U2 > pair& operator=( pair<U1,U2>&& other );
(C++11以上)
(C++20未満)
template< class U1, class U2 > constexpr pair& operator=( pair<U1,U2>&& other );
(C++20以上)

ペアの内容を置き換えます。

1) コピー代入演算子。 内容を別のペアの内容のコピーで置き換えます。
2) other.firstfirst に、 other.secondsecond に代入します。
3) ムーブ代入演算子。 内容をムーブセマンティクスを用いて other の内容で置き換えます。
4) std::forward<U1>(p.first)first に、 std::forward<U2>(p.second)second に代入します。

以下の条件を満たさない場合、これらの関数の動作は未定義です。

  • (1) に対しては、 std::is_copy_assignable<first_type>::value および std::is_copy_assignable<second_type>::value がどちらも true である。
  • (2) に対しては、 std::is_assignable<first_type&, const U1&>::value および std::is_assignable<second_type&, const U2&>::value がどちらも true である。
  • (3) に対しては、 std::is_move_assignable<first_type>::value および std::is_move_assignable<second_type>::value がどちらも true である。
  • (4) に対しては、 std::is_assignable<first_type&, U1&&>::value および std::is_assignable<second_type&, U2&&>::value がどちらも true である。
(C++17未満)

これらの関数は、要求される代入演算子が無効な場合、オーバーロード解決に参加しません (または、コピー代入演算子の場合、削除されたものとして定義されます)。 特に、

  • (1) は、 std::is_copy_assignable_v<first_type> および std::is_copy_assignable_v<second_type> がどちらも true でなければ、削除されたものとして定義されます。
  • (2) は、 std::is_assignable_v<first_type&, const U1&> および std::is_assignable_v<second_type&, const U2&> がどちらも true でなければ、オーバーロード解決に参加しません。
  • (3) は、 std::is_move_assignable_v<first_type> および std::is_move_assignable_v<second_type> がどちらも true でなければ、オーバーロード解決に参加しません。
  • (4) は、 std::is_assignable_v<first_type&, U1&&> および std::is_assignable_v<second_type&, U2&&> がどちらも true でなければ、オーバーロード解決に参加しません。
(C++17以上)

引数

other - このペアの内容を置き換える値のペア

戻り値

*this

例外

1-2) (なし)
3)
noexcept 指定:  
noexcept( is_nothrow_move_assignable<T1>::value && is_nothrow_move_assignable<T2>::value )
4) (なし)

関連項目