4 ms·
Yes good point. NRVO doesn't apply here and named parameters are in fact moved or copied depending on if they are passed by value or by reference. In your case
by banachtarski 10y ago
Yes good point. NRVO doesn't apply here and named parameters are in fact moved or copied depending on if they are passed by value or by reference.
In your case a move would happen but if you changed the parameter to a reference I think it would copy.
- nly 10y agoYes it would copy, unless you used an explicit std::move(). This is why most of the time you're better off just passing things around by value, and making your classes cheap to move (by, force example, making use of pointers (smart or otherwise)). This results in less code and more manageable semantics.