http://www.boost.org/doc/libs/1_51_0/doc/html/boost_lexical_cast/performance.html
Consider this link, string to string is very fast.
All the tests measure execution speed in milliseconds for 10000 iterations of the following code blocks:
typedef BOOST_DEDUCED_TYPENAME ::boost::type_traits::ice_or<
::boost::detail::is_xchar_to_xchar<Target, src >::value,
::boost::detail::is_char_array_to_stdstring<Target, src >::value,
::boost::type_traits::ice_and<
::boost::is_same<Target, src >::value,
::boost::detail::is_stdstring<Target >::value
>::value
> shall_we_copy_t;
In our case shall_we_copy_t::value will be true, since 3-rd case work for us (Target and src are equal types and Target type is std::basic_string).
typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c<
shall_we_copy_t::value,
::boost::detail::lexical_cast_copy<src >,
BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c<
shall_we_copy_with_dynamic_check_t::value,
::boost::detail::lexical_cast_dynamic_num<Target, src >,
::boost::detail::lexical_cast_do_cast<Target, src >
>::type
>::type caster_type;
Since, shall_we_copy_t::value is true, our caster_type will be lexical_cast_copy
return caster_type::lexical_cast_impl(arg);
So, will be called lexical_cast_copy::lexical_cast_impl, which is very simple
template <typename Source>
struct lexical_cast_copy
{
static inline Source lexical_cast_impl(const Source &arg)
{
return arg;
}
};