I have a class structure which is
template<int T>
class MyClass {
public:
MyClass(){};
~MyClass(){};
template<class K> void foo();
};
Now I want to specialize the foo() method based upon the value of the integer used in MyClass<int>, for instance if int the code we have MyClass<2> I want to use a different version of foo<K>() to if I had MyClass<3>. However I want to still have foo<K>() unspecialized on K.
So that would mean something like this would be okay
MyClass<2> myc2;
MyClass<3> myc3;
myc2.foo<SomeClass>();
myc2.foo<SomeOtherClass>();
myc3.foo<SomeClass>();
myc3.foo<SomeOtherClass>();
Is it possible to specialize in this way but not specialize on K? I’ve tried a few combinations with no success.
If I understood your question correctly, this is what you want: