Paolo M
Paolo M

Reputation: 12777

Are all rvalue-references lvalues?

Given the code:

void foo( int&& i )
{
    int* p = &i;
}

i is an lvalue. In fact, I can take it's address through the & operator.

Is this statement correct?

Upvotes: 2

Views: 169

Answers (1)

TartanLlama
TartanLlama

Reputation: 65770

An expression's value category is completely removed from its type.

In your case, the expression i is an lvalue, but std::move(i) is an rvalue. An expression of rvalue reference type can be an lvalue or rvalue.

Upvotes: 4

Related Questions