I have a templated class foo which has templated member function. I have a problem with the specialization of the templated function.
template<typename T, int x...>
class foo_c
{
...
template<int n>
int foo() { return n; }
};
template<>
template<>
int foo_c<int,1>::foo<0>() { return 0; }
the above code compile but I need foo_c to be generic, when add anything to the template I get a compiler error.
Questions:
- how can I fix this?
- what are the rules that the compiler follow when exposed to specialization?
EDIT:
Trying
template<typename T, int x, int y>
template<>
int foo_c<T,x,y>::foo<0>() { return 0; }
Error
error: invalid explicit specialization before '>' token
error: enclosing class templates are not explicitly specialized
error: expected initializer before '<' token