c++11 Return value optimization or move? [duplicate]
Use exclusively the first method: Foo f() { Foo result; mangle(result); return result; } This will already allow the use of the move constructor, if one is available. In fact, a local variable can bind to an rvalue reference in a return statement precisely when copy elision is allowed. Your second version actively prohibits copy … Read more