In the following code
A f(A a) {
return a;
}
the object a
is returned via move constructor. And in this one
A f(A&& a) {
return a;
}
by copy constructor.
Does the standard state that the move constructor cannot be used instead? More importantly why is the move constructor not used by default (I know I can return std::move(a)
, but it is not the point)?
Edit: edited to clarify.