Does guaranteed copy elision work with function parameters?

Viewed 1042

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?
2 Answers
Related