Reputation: 23
class A
{
B* ptr;
A(B* ptr_) : ptr(std::move(ptr_))
{}
};
A myA(new B);
In this code, is it necessary to call std::move on ptr_? Is it not already an rvalue reference?
Upvotes: 1
Views: 55
Reputation: 12178
ptr_
is not an rvalue reference, because it is a named variablestd::move
, but not because it is a rvalue, but because moving and copying normal pointer is exactly the same operation (std::move(ptr_)
will not clear ptr_
)Upvotes: 4