We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 防止编译器优化 A return_rvalue(bool test) { A a,b; if(test) return a; else return b; }
a,b是左值,不是右值,上面的代码会调用拷贝构造函数,不是移动构造函数,如果 要掉用移动构造,需要调用std::move()将左值转成右值
// 防止编译器优化 A return_rvalue(bool test) { A a,b; if(test) return std::move(a); else return std::move(b); }
必要时,请附上相关截图
The text was updated successfully, but these errors were encountered:
你好,此处为隐式右值转换,等价于 static_cast<A&&>(a),参见 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm#Moving%20from%20local%20values
static_cast<A&&>(a)
补充相关说明:5c37806
Sorry, something went wrong.
感谢你的解答
No branches or pull requests
实际描述
预期描述
a,b是左值,不是右值,上面的代码会调用拷贝构造函数,不是移动构造函数,如果
要掉用移动构造,需要调用std::move()将左值转成右值
附图
必要时,请附上相关截图
The text was updated successfully, but these errors were encountered: