Returning std::vector by value
- by deft_code
It is oft said that in C++11 it is sane to return std::vector by value.
In C++03 this was mostly true as RVO should optimize away the copy. But that should scared most developers away.
In C++11 will a returned std::vector local variable always be moved?
What if that vector is a member of a local variable instead of a local variable itself?
Obviously returning a global variable will not be moved. What other cases will it not be moved?