Let's say I have a function:
typedef std::vector<int> VecType; VecType randomVector(); int processing() { VecType v = randomVector(); return std::accumulate(v.begin(), v.end(), 0); }
Does C ++ 0x indicate that a false copy will be prevented from the return value of randomVector? Or should the compiler implement RVO? It seems to me that the value of randomVector() should be considered as an rvalue, and therefore it is necessary to call the v move constructor, but I'm not entirely sure that this is true.
c ++ c ++ 11 rvalue-reference return-value-optimization return-value
rlbond
source share