template < class T > struct FooIntConversion
{
static int doIt( const T &m ) {
return static_cast< int >( m );
}
};
template < > struct FooIntConversion< float >
{
static int doIt( float m ) {
// Do here your special case for converting float to int
return static_cast< int >( m );
}
};
template < class T > struct Foo
{
T m;
operator int() const
{
return FooIntConversion< T >::doIt( m );
}
};
But I'm sure someone with more experience would do better than me =)