Scott Meyers on Rvalueness

Viewed 1284

I watched Scott Meyers's extremely informative video on Universal References, in which I learned most of what I know about Rvalue references, moving, and forwarding. At one point he was talking about rvalueness as opposed to the type of a variable, and he said something to the effect of "rvalueness is independent of type".

I understand that you can have a method like this:

void func(MyType&& rRef)
{
    // Do domething with rRef...
}

and that here rRef is an lvalue because it can be identified, its address can be taken, etc., even though its type is MyType&&.

But an rvalue cannot be any type, can it? I mean, it can only be a MyType&&, right? In that sense I thought type is not entirely independent of rvalueness. Maybe I'm missing something.

Updated: My point can be made clearer like this. If in func() I call one of two overloaded functions defined as

void gunc(MyType&& rRef)
{
   // ...
}

void gunc(MyType& lRef)
{
   // ...
}

i.e. either by calling gunc(std::move(rRef)) or gunc(rRef), it seems that the type of the resulting expression between parenthesis is not independent of rvalueness.

3 Answers
Related