On 30.03.2017 00:12, Gavin Lambert via Boost-users wrote:
const& parameters should be your default for anything with non-trivial copy/move behaviour anyway, so you'd only run into this issue in already-bad code.
Passing by const& can actually force extra copies to be created that would not be created with pass-by-value. Consider: std::string f(); struct X { void by_value(std::string s) { this->some_member = std::move(s); } void by_const_ref(std::string const& s) { // Cannot move from const& this->some_member = s; } std::string some_member; }; X x; // The following line creates no copies. x.by_value(f()); // The following line must create an extra copy. x.by_const_ref(f()); -- Rainer Deyke - rainerd@eldwood.com