Question: I got confused by the following perfect forwarding function, where the template parameter `T` can match rvalue or lvalue references:

```
template<typename T>
void foo(T&& t){
    T::A; // intended error to inspect type
}

int main(){
    std::vector<int> a;
    std::vector<int> && b = std::move(a);

    foo(b);             // T is std::vector<int> & 
    foo(std::move(a));  // T is std::vector<int>
}

```

I dont understand why the template argument deduction of `T` in `foo` is so different in these two cases? Whats the fundamental difference and important what is `t`'s type in function `foo`.

`std::move(a)` returns a rvalue reference and `b` is already a rvalue reference (but has a name).

Is that right that, `b` s type is a rvalue reference to `std::vector<int>`, but as far as my understanding goes, it has a name and is thus considered an lvalue in function main?

Can anyone shine some light into this :-)

Answer: 
> 
> Is that right that, `b` s type is a rvalue reference to `std::vector<int>`, but as far as my understanding goes, it has a name and is thus considered an lvalue in function main?
> 
> 
> 

Yes, that's exactly it. It makes more sense if you think about rvalue reference function parameters: the caller is specifying that the function can do whatever it wants with the objects it gets. So from inside the function body, in order to make sure the code really can do whatever it wants with it, the parameter should be treated as an lvalue. That same argument can also be made for other rvalue references, including the `b` in your example, albeit to a lesser extent.
The *expressions* `a` and `b` are both lvalues, and the expression `std::move(a)` is an rvalue.

The deduction for the parameter `T` makes use of special reference collapsing rules so that the type of `t` is either an lvalue or an rvalue reference as needed to bind to the function call argument.