Suppose I have this class:
template</*some other parameters here */class toggle>
class Foo
{
void function();
//Lots of other non-parametrized member functions
}
Now, if toggle is of some certain type, I want function to use an alternative implementation, and for all other cases I want it to use the standard implementation. This should be done completely at compile time, since outside users of the class should be able to instantiate this template that (intentionally, in order to save memory and a little performance) lacks some functionality.
The catch: Simply specializing the whole class is not realistic, since Foo will have a lot of other methods which don’t depend on this toggle, which would also have to be implemented again, making everything a huge waste of space.
I think this is what you are asking for:
Output: