Possible Duplicate:
Template partial specialization with multiple template argument error
Is is possible to specialize e template class as function level?
I’ll give you and example with what I want to achieve, but I get compilation errors:
template<typename T1, typename T2>
class C
{
public:
void f();
};
template<typename T1, typename T2>
void C<T1, T2>::f()
{
}
template<typename T1, int>
void C<T1, int>::f()
{
}
Errors:
template argument list following class template name must list parameters in the order used in template parameter list
'void C<T1,T2>::f(void)' : function template has already been defined
'C<T1,T2>': template parameter 'T2' is incompatible with the declaration
If you want to make the behaviour of
C::fdependent onT2you can try to put its implementation into a separate class like the following:Depending on the details of your needs
C_aux::fhas to take extra parameters. Or you can letclass Cinherit fromclass C_auxor vice versa.