Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Yes 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: