To specialize a class template, one has to redefine all of the member functions in the underlying base template (i.e. the unspecialized class template) even if they are expected to remain mostly unchanged. What are some of the accepted methods and ‘best practices’ to avoid this code duplication?
Thanks.
You can fully specialize a member selectively:
You do a full specialization. Meaning you cannot partial specialize it:
If you need that, you can use enable_if:
An alternative approach is to split your stuff up (common stuff into a base class, and specialized stuff into the derived class) like Nick recommends.
I usually would take the second approach. But i prefer the first one if i don’t need to partial specialize the functions.