Other than the preprocessor, how can I conditionally enable/disable explicit template instantiations?
Consider:
template <typename T> struct TheTemplate{ /* blah */ };
template struct TheTemplate<Type1>;
template struct TheTemplate<Type2>;
template struct TheTemplate<Type3>;
template struct TheTemplate<Type4>;
Under some compilation conditions, Type3 is the same as Type1 and Type4 is the same as Type2. When this happens, I get an error. I'd like to detect that the types are the same and not instantiate on Type3 and Type4 as in
// this does not work
template struct TheTemplate<Type1>;
template struct TheTemplate<Type2>;
template struct TheTemplate<enable_if<!is_same<Type1, Type3>::value, Type3>::type>;
template struct TheTemplate<enable_if<!is_same<Type2, Type4>::value, Type4>::type>;
I've diverted myself trying enable_if and SFINAE (and I believe I know why they fail), but only the preprocessor has worked (ugh). I'm thinking about putting the types in a tuple or variadic, removing duplicates, and then use the remainder for instantiation.
Is there a way to conditionally enable/disable explicit template instantiation based on template argument types?