Does guaranteed copy elision work with function parameters?
问题 If I understood correctly, starting from C++17, this code now requires that no copy will be done: Foo myfunc(void) { return Foo(); } auto foo = myfunc(); // no copy Is it also true for function arguments? Will copies be optimized away in the following code? Foo myfunc(Foo foo) { return foo; } auto foo = myfunc(Foo()); // will there be copies? 回答1: In C++17, prvalues ("anonymous temporaries") are no longer objects. Instead, they are instructions on how to construct an object. They can