This question already has an answer here:
- Rvalue Reference is Treated as an Lvalue? 4 answers
- Lvalue reference constructor is called instead of rvalue reference constructor 1 answer
Say I have the following function
void doWork(Widget && param) // param is an LVALUE of RRef type
{
Widget store = std::move(param);
}
Why do I need to cast param
back to an rvalue with std::move()
? Shouldn't it be obvious that the type of param
is rvalue since it was declared in the function signature as an rvalue reference? Shouldn't the move constructor be automatically invoked here on this principle alone?
Why doesn't this happen by default?