I am reading on type erasure:
Andrzej's C++ blog Type erasure — Part I
Where I come across the following text:
unless you can enumerate all instantiations of your template in advance, you have to include the body of each function template in the header file, you cannot separate the declaration from the implementation
Is enumerating all instantiations of the template the same as explicit instantiation pointed out in answer to the following question?
Why can templates only be implemented in the header file?
Another solution is to keep the implementation separated, and explicitly instantiate all the template instances you'll need:
// Foo.h
// no implementation
template <typename T> struct Foo { ... };
//----------------------------------------
// Foo.cpp
// implementation of Foo's methods
// explicit instantiations
template class Foo<int>;
template class Foo<float>;
// You will only be able to use Foo with int or float