Is it possible to return a standard container from a function without making a copy?
Example code:
std::vector MyFunc();
...
std::vector&l
Rvalues ("temporaries") bound to const
references will have their lifetime extended to the end of the reference's lifetime. So if you don't need to modify that vector, the following will do:
const std::vector& b = MyFunc();
if you need to modify the vector, just code it the way that's easiest to read until your have proof (obtained through profiling) that this line even matters performance-wise.
Otherwise rely on C++1x with its rvalue references and move semantics coming along "real soon now" and optimizing that copy out without you having to do anything.