I want to know if there is essentially a difference between:
template <typename T>
class foo{
foo<T>(){};
};
template<typename T>
class foo{
foo(){};
};
Both seem to work, but I don't understand the difference between the two. The first one is confusing me, I don't understand what's the role of the < T > here.
According to the rule of injected-class-name, they're exalctly the same thing.
$14.6.1/1 Locally declared names [temp.local]:
So
foo
andfoo<T>
refer to the same thing here. More specifically,You're using the inject-class-name
foo
with its template parameterT
(i.e.foo<T>
), which refers to the template class itself.