class template parameters can only be omitted inside the implementation of this class, where they implicitly add the appropriate template qualifier to the class, and when accessing an independent base class (they are not dependent, as in "do not reuse any template arguments"). For instance:
template<typename T, typename U> class C { }; template<typename T> class C<void, T> { }; template<> class C<void, void> { }; template<typename> struct Base { }; struct DerivedA : Base<void> { }; template<typename T> struct DerivedB : Base<T> { };
Function templates can have their template parameters omitted if they can be inferred from their arguments:
template<typename T> void f(T f); f(3);
In addition, there are default template arguments, which leads to something really funky :
template<typename T = void> class D { // Here D is D<T>, but D<> is D<void> instead! };
source share