Consider the following header file:
// Foo.h
class Foo {
public:
template
void read(T& value);
};
I
I am not sure if this is the solution to your problem, but maybe you can do with a template specialization.
New header:
// Foo.h
template < typename T >
struct RealRead;
class Foo {
public:
template
void read(T& value);
};
template
void Foo::read(T& value)
{
RealRead< T >::read( value );
}
New source :
template < >
struct RealRead< int >
{
static void read( int & v )
{
// do read
}
};
template < >
struct RealRead< float >
{
static void read( float & v )
{
// do read
}
};
//etc
// explicitly instantiate templates
template struct RealRead< int >;
template struct RealRead< float >;