std::function<R(Args...)>::operator=
提供: cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num ">
</tbody><tbody>
</tbody>
function& operator=( const function& other ); |
(1) | (C++11以上) |
function& operator=( function&& other ); |
(2) | (C++11以上) |
| (3) | ||
function& operator=( std::nullptr_t ); |
(C++11以上) (C++17未満) |
|
function& operator=( std::nullptr_t ) noexcept; |
(C++17以上) | |
template< class F > function& operator=( F&& f ); |
(4) | (C++11以上) |
template< class F > function& operator=( std::reference_wrapper<F> f ) noexcept; |
(5) | (C++11以上) |
新しいターゲットを std::function に代入します。
1)
function(other).swap(*this); を実行したかのように、 other のターゲットのコピーを代入します。2)
other のターゲットを *this にムーブします。 other は未規定な値を持つ有効な状態になります。3) 現在のターゲットを捨てます。
*this は空になります。4)
function(std::forward<F>(f)).swap(*this); を実行したかのように、 *this のターゲットを f に設定します。 この演算子は、 f が引数型 Args... および戻り値型 R に対して Callable でなければ、オーバーロード解決に参加しません。 (C++14以上)5)
function(f).swap(*this); を実行したかのように、 *this のターゲットを f のコピーに設定します。引数
| other | - | ターゲットをコピーする別の std::function オブジェクト
|
| f | - | ターゲットを初期化する callable |
| 型の要件 | ||
-F は Callable の要件を満たさなければなりません。
| ||
戻り値
*this。
ノート
C++17 でアロケータのサポートが std::function から削除される前でも、これらの代入演算子は *this のアロケータや other のアロケータではなく、デフォルトのアロケータを使用します (LWG #2386 を参照してください)。
関連項目
(C++17で削除) |
新しいターゲットを代入します (パブリックメンバ関数) |