c++11 Return value optimization or move? [duplicate]

This question already has answers here: C++11 rvalues and move semantics confusion (return statement) (6 answers) Closed 4 years ago. I don’t understand when I should use std::move and when I should let the compiler optimize… for example: using SerialBuffer = vector< unsigned char >; // let compiler optimize it SerialBuffer read( size_t size ) … Read more

What are copy elision and return value optimization?

What is copy elision? What is (named) return value optimization? What do they imply? In what situations can they occur? What are limitations? If you were referenced to this question, you’re probably looking for the introduction. For a technical overview, see the standard reference. See common cases here. 5 Answers 5 Introduction For a technical … Read more