Given a function such as:
template< typename T >
void function1( const T &t )
{
function2( boost::lexical_cast<std::string>(t) );
}
What kind of overhead is incurred if the type passed to function1
is already a std::string
?
Does the overhead vary, depending on the type I'm lexical_cast
-ing to?
Is it superfluous to make an overloaded function to bypass the cast? E.g.:
void function1( const std::string &t )
{
function2( t );
}
template< typename T >
void function1( const T &t )
{
function1( boost::lexical_cast<std::string>(t) );
}
The version of boost may be relevent to your answer, as I understand that lexical_cast
has received a few optimizations across revisions.