std::move_only_function::operator=
From cppreference.com
< cpp | utility | functional | move only function
| move_only_function& operator=( move_only_function&& other ); |
(1) | (C++23から) |
| move_only_function& operator=( const move_only_function& ) = delete; |
(2) | (C++23から) |
| move_only_function& operator=( std::nullptr_t ) noexcept; |
(3) | (C++23から) |
| template< class F > move_only_function& operator=( F&& f ); |
(4) | (C++23から) |
std::move_only_function に新しいターゲットを代入するか、ターゲットを破棄します。
1)
other のターゲットを *this に移動するか、(もしあれば) other が空の場合に *this のターゲットを破棄します。これは auto(std::move(other)).swap(*this); によって行われます。移動代入後、other は未指定の値を持つ有効な状態になります。3) 現在のターゲットが存在する場合は破棄します。呼び出し後、
*this は空になります。4)
*this のターゲットを呼び出し可能オブジェクト f に設定します。または、f がヌル関数ポインタ、ヌルメンバ関数ポインタ、または空の std::move_only_function の場合は、現在のターゲットを破棄します。これは move_only_function(std::forward(f)).swap(*this); を実行するのと同等です。このオーバーロードは、F からの move_only_function のコンストラクタがオーバーロード解決に参加する場合にのみ、オーバーロード解決に参加します。選択されたコンストラクタ呼び出しがill-formedまたは未定義の動作である場合、プログラムはill-formedまたは未定義の動作となります。目次 |
[編集] パラメータ
| その他 | - | ターゲットを移動する別の std::move_only_function オブジェクト |
| f | - | 新しいターゲットを初期化するための呼び出し可能オブジェクト |
[編集] 戻り値
*this
[編集] 注釈
将来のallocator対応の move_only_function のための余地を残すために、移動代入演算子を noexcept にすることを意図的に要求していません。
move_only_function は、その引数から構築できる場合、std::in_place_type<Fn> から代入できます。
[編集] 例
| このセクションは未完成です 理由: 例がありません |
[編集] 関連項目
| 新しいターゲットを代入する ( std::function<R(Args...)> の public メンバ関数) |