I have a template class:
template<typename T>
class A {
public:
virtual void func(T t);
virtual void func2(T t);
.
.
.
virtual void funcN(T t);
}
Basically a lot of classes inherit form A, but T is always one of the 2 types B or C.
Currently every change that i make in the class causes a very long build.
Since T can be either B or C i want to turn the class into a regular class.
Any ideas how to do this change in a smart and clean way, without copying each function twice?
Thanks
The easiest solution is probably to use explicit specialisations. You keep the template, but you tell the compiler explicitly for which classes to instantiate it.
Change your header file containing
class Ato contain only the declaration of the class and its members (like you would do for a regular class). Then create a fileA.cppwith the implementation of the member-functions ofAand the explicit specialisations, like thisand add this file to your project.