I've had some bad experiences with RTTI when using it with derived classes... so I try to avoid it whenever possible.
I had a case where I needed a template to do one thing for signed numbers and another for unsigned. After some searching I came up with this non-RTTI solution:
Code:
template <typename E,
typename T,
typename A,
typename N>
void StringToNum( const std::basic_string<E, T, A>& str,
N& num )
{
if ( std::numeric_limits<N>::is_signed == true )
{
signed long lnum = 0;
StringToNumHelper( str, lnum, num );
}
else
{
unsigned long lnum = 0;
StringToNumHelper( str, lnum, num );
}
}
Most of the time, you'll probably be able to find an equally simple non-RTTI solution if you search hard enough.