Given the following:
Foo getFoo()
{
Foo result = doSomeWork();
return result;
}
Does C++ guarantee that
result
will be moved, instead of copied? Or to put it another way, is writingreturn std::move(result)
superfluous?Are there any (other) situations where the standard specifies that a lvalue will be silently moved instead of copied, in the absence of an explicit
std::move
cast?
Notes:
Assume
Foo
is move-constructible.Disregarding copy/move elision, which may apply in addition.