Namespaces
Variants

std::move_only_function:: operator=

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
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 はムーブ代入後、未規定の値を持つ有効な状態となる。
2) コピー代入演算子は削除されています。 std::move_only_function CopyAssignable を満たしません。
3) 現在のターゲットが存在する場合、それを破棄します。 * this は呼び出し後に空になります。
4) * this のターゲットを呼び出し可能な f に設定する。または、 f がnull関数ポインタ、nullメンバ関数ポインタ、または空の std::move_only_function である場合、現在のターゲットを破棄する。これは move_only_function ( std:: forward < F > ( f ) ) . swap ( * this ) ; を実行するかのように動作する。このオーバーロードは、 move_only_function F からのコンストラクタがオーバーロード解決に参加する場合にのみ、オーバーロード解決に参加する。選択されたコンストラクタ呼び出しが不適格または未定義動作を持つ場合、プログラムは不適格または未定義動作を持つ。

目次

パラメータ

other - ターゲットを移動する別の std::move_only_function オブジェクト
f - 新しいターゲットを初期化するための呼び出し可能オブジェクト

戻り値

* this

注記

意図的にムーブ代入演算子に noexcept を要求しないのは、将来のアロケータ対応 move_only_function の余地を残すためです。

move_only_function は、その引数から構築可能である場合、 std:: in_place_type < Fn > から代入可能です。

関連項目

新しいターゲットを割り当てる
( std::function<R(Args...)> の公開メンバ関数)