The compiler does not know that A<T>::f()
does not use a parameter of type T
Therefore, you must provide the compiler with a type every time you use f
.
But when I develop a template class, and I notice that some members / methods are independent of the template parameters, I often move them to the base class without templates.
class A_Base { public: static void f(); }; template <class T> class A : public A_Base {
Now A_Base::f()
, A<int>::f()
and A<double>::f()
really all the same.
aschepler
source share