Suppose that I have two template functions declared in a header file:
template void func1(const T& value);
template
Since the user of your code needs to see the full definition of the func1
function, it's implementation, nor it's helper function implementation, can be hidden.
But if you move the implementation into another file, the user will only have to be confronted with the template declaration:
//templates.h
template< typename T > void f1( T& );
#include // post-inclusion
And the definition:
// templates_impl.h
template< typename T > void f1_helper( T& ) {
}
template< typename T > void f1( T& ) {
// the function body
}