This is off the top of my head so I may be remembering wrong, but I think it goes like this:
template <typename T>
void n<float, T>::func(void) { /* ... */ }
tried a couple of things with that thought:
first, as you said:
#include <stdio.h>
template<class t, int x>
class n{
void func(void){
printf("default class t, x: %d\n", x);
}
};
template<typename x>
void n<float,x>::func(void){
printf("float class, x: %d\n", x);
}
int main(int argc, char **argv){
n<int,5> x; x.func();
n<float,10> y; y.func();
return 0;
}
but this gives an error of:
Line 11: error: type/value mismatch at argument 2 in template parameter list for 'template<class t, int x> class n'
then:
#include <stdio.h>
template<class t, int x>
class n{
void func(void){
printf("default class t, x: %d\n", x);
}
};
template<int x>
void n<float,x>::func(void){
printf("float class, x: %d\n", x);
}
int main(int argc, char **argv){
n<int,5> x; x.func();
n<float,10> y; y.func();
return 0;
}
which gives an error of:
Line 11: error: invalid use of undefined type 'class n<float, x>'
@A Brain in a vat, thanks, i didn't realize i had to add that extra bit for class specialization, thanks.