[英]C++ std move document error?
Here is the document I am referring to. 这是我要参考的文档 。 Both form has r-value reference as input ( T&& t
). 两种形式都有r值参考作为输入( T&& t
)。
But we can put l-value as parameter of move
, in my below example, a is a l-value, which is identifiable and memory-addressable. 但是我们可以将l值作为move
参数,在我的下面的示例中,a是一个l值,它是可识别且可寻址的。
Any thought is document is wrong? 有没有想到文件是错误的?
#include <iostream>
int main() {
string a = "hello";
string b(std::move(a));
std::cout << "a is: " << a << endl;
std::cout << "b is: " << b << endl;
}
output, 输出,
a is:
b is: hello
T&& t
is not r-value reference. T&& t
不是r值参考。 It is the forward reference, previously known as universal reference, the special case when used with template or auto parameters. 它是前向引用,以前称为通用引用,是与模板或自动参数一起使用时的特殊情况。 Read this good explanation here https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers 在这里阅读这个很好的解释https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.