假设我有一个功能:
typedef std::vector<int> VecType;
VecType randomVector();
int processing()
{
VecType v = randomVector();
return std::accumulate(v.begin(), v.end(), 0);
}
C++0x 是否明确表示将避免 randomVector 的返回值中的虚假副本?或者编译器是否需要实现 RVO?在我看来,该值randomVector()
应该被视为右值,因此应该调用 v 的移动构造函数,但我不完全确定这是真的。