I want to create a template class (let's call it Foo) that only accepts a few specific type parameters (let's say only double and float). Normally templates are implemented in the header file (.h) because it is unknown how it will be instantiated in user code. In this case, it makes more sense to implement the class in the implementation file (.cpp) like so:
// Foo.cpp:
template <class T>
class Foo
{
// Insert members here
};
typedef Foo<double> Foo_d;
typedef Foo<float> Foo_f;
This would instantiate and compile the class when Foo.cpp is compiled. But then how to I declare this in the header file without writing separate declarations for Foo_d and Foo_f?