Reputation: 10139
Here is the document I am referring to. Both form has r-value reference as input (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.
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
Upvotes: 2
Views: 58
Reputation: 38326
T&& t
is not r-value reference. 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
Upvotes: 3