Another option is to use a helper class template, where you can do partial specialization, and hide it using a wrapper function which doesn't need to be partially specialized itself:
#include <iostream>
template<typename S, typename T>
struct foo_helper {
void foo() {
std::cout << "general func" << std::endl;
}
};
struct MyType {};
template <typename T>
struct foo_helper <MyType,T> {
void foo() {
std::cout << "partially specialized code - for any kind of T, but when S is MyType" << std::endl;
}
};
template<typename S, typename T>
void foo() {
foo_helper<S, T>().foo();
}
int main () {
foo<int, int>();
foo<int, double>();
foo<MyType, long>();
}
This is valid C++98/03 as well.