template<typename T>
struct Obj
{
template<typename U>
void m(){};
};
template<typename T>
void func()
{
Obj<T> v; // Obj<int> v; is compilable
v.m<int>();
}
This piece of code gives me an error:
test.cpp: In function ‘void f()’:
test.cpp:21:9: error: expected primary-expression before ‘int’
v.m<int>();
^
test.cpp:21:9: error: expected ‘;’ before ‘int’
However, if I change Obj<T> v;
into Obj<int> v;
, it will be compilable.
I don't know why.