I have a class Foo which is used in a small standalone project. It has a class definition in Foo.h with the implementation for the class\' member functions in an implementat
My default would be to put the definition for the member function templates right in the .h file, like this:
class Foo
{
public:
template void DoSomething(T t);
};
// ... later...
template
void Foo::DoSomething(T t)
{
// ...
}
If this is suboptimal for a particular case, then I'd take more heroic measures. Starting with #include
-ing a .inc file with the definition at the end of the .h file, or possibly even doing explicit instantiations in the .cpp files where I needed the member function templates to be used.