Do compilers automatically use move semantics when a movable object is used for the last time?
问题 I've been studying rvalue references lately and came to a conclusion that it's quite advantageous to use pass-by-value everywhere where complete copy of an object will be made (for complete justification see e.g. How to reduce redundant code when adding rvalue reference operator overloads? and Want speed? Pass by value!), because the compiler can automatically optimize a copy away in cases such as f(std::move(a)); , where f is defined as void f(A a); . One negative consequence of pass-by