Returning std::vector by value
Posted
by
deft_code
on Stack Overflow
See other posts from Stack Overflow
or by deft_code
Published on 2012-06-28T15:14:05Z
Indexed on
2012/06/28
15:15 UTC
Read the original article
Hit count: 173
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?
© Stack Overflow or respective owner