struct A ; struct B ; struct C ; struct D ;
struct base
{
virtual ~base() = default ;
virtualvoid write_to_file( const A& a ) { write_to_file_impl(a) ; }
virtualvoid write_to_file( const B& b ) { write_to_file_impl(b) ; }
virtualvoid write_to_file( const C& c ) { write_to_file_impl(c) ; }
virtualvoid write_to_file( const D& d ) { write_to_file_impl(d) ; }
private :
template < typename T > void write_to_file_impl( const T& )
{ /* base class has the same implementation for A, B, C, D */ }
};