#include <iostream>
class A
{
public:
A() {};
};
template <class T>
class Test
{
public:
void func1(T&& t)
{
}
};
int main()
{
A a;
Test<A> o1;
o1.func1(a);
return 0;
}
Following errors are seen on compilation
error C2664: 'void Test<A>::func1(T &&)': cannot convert argument 1 from 'A' to 'T &&'
note: You cannot bind an lvalue to an rvalue reference
o1 is obtained by instantiating template class Test with "A". So the call o1.func1(a) should know that void func1(T&& t) should resolve to void func1(A&& t)
I thought T&& in void func1(T&& t) should be deduced as a universal reference or a forwarding reference because its from a template type parameter. Then why in the error above it says "You cannot bind an lvalue to an rvalue reference"?
Am i missing some template magic here?