Is std::move
necessary in the following snippet?
std::function<void(int)> my_std_function;
void call(std::function<void(int)>&& other_function)
{
my_std_function.swap(std::move(other_function));
}
As far as I know call()
accepts a rvalue reference.. but since the rvalue reference is itself an lvalue, in order to call swap(std::function<void(int)>&&)
I have to re-cast this to an rvalue reference with std::move
Is my reasoning correct or std::move
can be omitted in this case (and if it can, why?)
Aucun commentaire:
Enregistrer un commentaire