I'm not sure I'm getting the terminology correct, but I think I have a class template with both a type and non-type template parameter and I want to partially specialize on the non-type parameter alone:
template<class T, int I> struct A
{
void f();
};
template<class T> void A<T, 1>::f() {}
int main()
{
A<int, 1> a1;
a1.f();
}
Using Visual C++ I get error C3860: template argument list following class template name must list parameters in the order used in template parameter list
and error C2976: 'A<T,I>': too few template arguments
.
However if I remove the type parameter then it seems I can specialize on the non-type parameter:
template<int I> struct B
{
void g();
};
void B<1>::g() {}
int main()
{
B<1> b1;
b1.g();
}
So is what I want impossible, or I'm just not doing it the right way? If it's not possible, is there an alternative?