std::move在以下片段中是否有必要?
std::function<void(int)> my_std_function;
void call(std::function<void(int)>&& other_function)
{
my_std_function.swap(std::move(other_function));
}
Run Code Online (Sandbox Code Playgroud)
据我所知call()接受一个右值引用..但由于右值引用本身就是一个左值,为了调用swap(std::function<void(int)>&&)我必须将它重新转换为右值引用std::move
我的推理是正确的还是std::move在这种情况下可以省略(如果可以,为什么?)