std::experimental::function<R(Args...)>::operator=
From cppreference.com
< cpp | experimental | function
| function& operator=( const function& other ); |
(1) | (Library Fundamentals TS) |
| function& operator=( function&& other ); |
(2) | (Library Fundamentals TS) |
| function& operator=( std::nullptr_t ) noexcept; |
(3) | (Library Fundamentals TS) |
| template< class F > function& operator=( F&& f ); |
(4) | (Library Fundamentals TS) |
| (5) | ||
template< class F > function& operator=( std::reference_wrapper<F> f ); |
(Library Fundamentals 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<> の値とします。
1)
other のターゲットのコピーを代入します。これは、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)
*this のターゲットを破棄します。呼び出し後、*this は空になります。代入後の get_memory_resource() によって返されるメモリリソースは、代入前のメモリリソースと同等ですが、アドレスは変更される可能性があります。4)
*this のターゲットを呼び出し可能な f に設定します。これは、function(std::allocator_arg, ALLOCATOR_OF(*this), std::forward<F>(f)).swap(*this); を実行するのと同じです。この演算子は、f が引数型 Args... および戻り値型 R に対してCallableの要件を満たさない限り、オーバーロード解決に参加しません。5)
*this のターゲットを f のコピーに設定します。これは、function(std::allocator_arg, ALLOCATOR_OF(*this), f).swap(*this); を実行するのと同じです。目次 |
[編集] パラメータ
| その他 | - | コピーまたは移動元の別の std::experimental::function オブジェクト |
| f | - | ターゲットを初期化するための呼び出し可能なオブジェクト |
| 型要件 | ||
-F はCallableの要件を満たす必要があります。 | ||
[編集] 戻り値
*this
[編集] 例外
1,2,4) 必要に応じたストレージの割り当て、または
*this のターゲットの初期化中に例外がスローされる可能性があります。5) (なし)
[編集] 注意
ムーブ代入演算子は、ストレージを割り当てる必要がある場合があります (ライブラリ基礎 TS v3 まで: get_memory_resource() != other.get_memory_resource()、ライブラリ基礎 TS v3 以降: get_allocator() != other.get_allocator())。