First of all, you have already successfully defined a partial specialistation:
AClass<int, int>
will instantiate class AClass<T, T>
with T=int
AClass<int,float>
will instantiate class AClass<T1, T2>
with T1=int and T2=float
You can easily check this by adding a public test method and invoking it for aClassIntFloat
and aClassIntInt
(online demo). You'll find out that the partial specialization defined for two identical types will be used.
You can also make another partial specialization, for example:
template<class T2>
class AClass<double, T2> { public: void test(){cout<<"ADT2"<<endl;}};
AClass<double, int> aClassDoubleInt; // works also fine
A partial specialization lets you fix some parameters but not all. But in the end, your template requires two parameters, and you'll have to provide two parameters. The only question is which specialization if any gets instantiated (online demo).