Returning a local variable is an implicit move in C++11, so you don't need to do it.
O_o
This is true, but there is even more to the situation.
Most C++ compilers, even C++98, implement "RVO" which will, somehow, eliminate the copy.
With C++11, compilers will default to move semantics if available, but may even eliminate the call to the move constructor.
Code:
/* semantically */
void make_point(float x, float y, float z, point * hidden_rvo_this) {
point::point(hidden_rvo_this, x, y, z);
}
[Edit]
Code:
/* extending the original example */
int main()
{
point s(make_point(0.0f, 0.0f, 0.0f));
}
Code:
/* may result in something more like this with rvo */
iint main()
{
char s_hidden[sizeof(point)];
make_point(0.0f, 0.0f, 0.0f, s);
point & s(s_hidden);
}
[/Edit]
The example, mutated for explanation from post #27, shows the sort of thing a compiler may do instead of an actual "return" value.
Most compilers will very likely eliminate the copy if you don't specify `std::move' so don't use it for such cases; you may even force a constructor call using `std::move' in such a case depending on the compiler.
Soma