Namespaces
Variants

std::experimental::function<R(Args...)>:: operator=

From cppreference.net
function & operator = ( const function & other ) ;
(1) (ライブラリファンダメンタルTS)
function & operator = ( function && other ) ;
(2) (ライブラリファンダメンタルTS)
function & operator = ( std:: nullptr_t ) noexcept ;
(3) (ライブラリファンダメンタルTS)
template < class F >
function & operator = ( F && f ) ;
(4) (ライブラリファンダメンタルTS)
(5)
template < class F >
function & operator = ( std:: reference_wrapper < F > f ) ;
(ライブラリファンダメンタルTS)
template < class F >
function & operator = ( std:: reference_wrapper < F > f ) noexcept ;
(ライブラリファンダメンタルTS v3)

std::experimental::function に新しい ターゲット を割り当てます。以下の説明において、 ALLOCATOR_OF ( f ) を、 f の構築時に指定されたアロケータ、またはアロケータが指定されなかった場合の構築時点での std:: experimental :: pmr :: get_default_resource ( ) (ライブラリ基盤TS v3まで) std:: pmr :: polymorphic_allocator <> のデフォルト構築値 (ライブラリ基盤TS v3) とします。

1) other target のコピーを割り当てます。これは function ( std:: allocator_arg , ALLOCATOR_OF ( * this ) , other ) . swap ( * this ) ; を実行するかのように動作します。
2) other のターゲットを * this に移動する。これは function ( std:: allocator_arg , ALLOCATOR_OF ( * this ) , std :: move ( other ) ) . swap ( * this ) ; を実行したかのようである。 other は有効な状態であるが、値は不定である。
3) target を破棄する。 * this * this は呼び出し後に empty となる。代入後の get_memory_resource() によって返されるメモリリソースは代入前のメモリリソースと同等であるが、アドレスは変更される可能性がある。
4) *this ターゲット を呼び出し可能オブジェクト f に設定する。これは function ( std:: allocator_arg , ALLOCATOR_OF ( * this ) , std:: forward < F > ( f ) ) . swap ( * this ) ; を実行するのと同等である。この演算子は、 f が引数型 Args... と戻り値型 R に対して Callable でない限り、オーバーロード解決に参加しない。
5) target * this のコピーとして設定します。これは function ( std:: allocator_arg , ALLOCATOR_OF ( * this ) , f ) . swap ( * this ) ; を実行したかのように行われます。

目次

パラメータ

other - コピーまたはムーブ元の別の std::experimental::function オブジェクト
f - target を初期化するための呼び出し可能オブジェクト
型要件
-
F Callable の要件を満たさなければならない

戻り値

* this

例外

1,2,4) ストレージの必要な割り当て、または * this のターゲットの初期化時に例外がスローされた場合。
5) (なし)

注記

ムーブ代入演算子は、以下の場合にストレージの割り当てが必要になる可能性があります: get_memory_resource ( ) ! = other. get_memory_resource ( ) (ライブラリファンダメンタルTS v3まで) get_allocator ( ) ! = other. get_allocator ( ) (ライブラリファンダメンタルTS v3)