In C++, a named rvalue reference is lvalue. Why the below code yields "error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'"?
int & unmove(int && t)
{
return t;
}
And this code works:
int & unmove(int && t)
{
int & r = t;
return r;
}
Since C++23,
xvalue expressions include now move-eligible expressions.
So in return t;
, t
is now a xvalue expression,
but int& r = t;
, t
is still a lvalue expression.