I tried something like this:
foo.h:
template< class T >
class foo
{
public:
void bar();
private:
void bar_impl();
};
foo.cpp:
template< type T >
void foo<T>::bar_impl()
{
// Lengthy implementation here.
}
void foo<int>::bar()
{
foo<int>::bar_impl();
}
void foo<float>::bar()
{
foo<float>::bar_impl();
}
The idea here is to force instantiation of bar_impl()
in foo.cpp
for the possible template types and to keep the header clean.
Unfortunately, this didn't work, and after lengthy compilation I got seemingly unrelated error. Could you suggest what could be wrong here?