I am confused by the rvalue type of variables in C++. The code below gives me the following compiler error
error: cannot bind rvalue reference of type ‘int&&’ to lvalue of type ‘int’ f1(b);
void f1(int&& a)
{
std::cout << "f1 called." << std::endl;
}
int main()
{
int a = 7;
int&& b = std::move(a);
f1(b);
}
moving b into f solves the problem
f1(std::move(b));
The type of b is clearly int&&. How is b in this context considered to be an lvalue?