小编DaE*_*sew的帖子

什么时候对函数参数C ++执行移动操作

举个例子

void f(B b, A&& a) {...}
B g(B b, A a) {...}

int main() {
    B b;
    A a;
    f(g(b, a), std::move(a));
}
Run Code Online (Sandbox Code Playgroud)

我认为这将是有效的代码,因为a std::move()仅仅是a static_cast,从我收集到的所有函数参数首先进行评估(不保证顺序),然​​后再复制/移动(我认为这是函数调用的一部分,而不是参数评估)到函数的上下文。

c++ move-semantics order-of-execution

8
推荐指数
1
解决办法
80
查看次数

标签 统计

c++ ×1

move-semantics ×1

order-of-execution ×1