std::move
は次のスニペットで必要ですか?`std :: move`はここで必要ですか?
call()
は右辺値参照を受け入れる知っているよう
std::function<void(int)> my_std_function;
void call(std::function<void(int)>&& other_function)
{
my_std_function.swap(std::move(other_function));
}
..しかし、右辺値参照は左辺値そのものであることから、swap(std::function<void(int)>&&)
を呼び出すために、私はstd::move
が正しい私の推論ですかstd::move
が、この場合には省略することができます(そしてそれができるなら、なぜですか?)
ここでは、スワップの代わりに演算子=を発行したいと思うようです。そして、はい、移動を使用します。 –