std::function<R(Args...)>::operator=
提供: cppreference.com
< cpp | utility | functional | function
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で削除) |
新しいターゲットを代入します (パブリックメンバ関数) |