I have a template class that is valid only for a pair of template parameters:
doIt.h:
I want to hide the implementation inside the .cpp file (for faster compilation, and also because of its proprietary):
doIt.cpp:
template <> void doer<T>::doIt() { }
... and use it like this: use.cpp:
int main( int, char** ) { doer<int>::doIt() }
The above is not related, because the void doer :: doIt (void) implementation has never been in scope at the place where it was called.
I can get the code to be generated in doItv2.obj as follows:
doIt_v2.cpp:
template <> void doer<T>::doIt() { } doer<int> a; doer<real> b;
but it causes a lot of headaches (dynamic memory allocation before entering the main one), and I really do not want to make an instance - I just want object code to be created to instantiate the template.
Any ideas?
source share