
27 Sep
2004
27 Sep
'04
8:03 p.m.
In generic code lexical_cast<> is sometimes used as a cast to the same type. I would like to shortcut this rather then going all the way by writing it to a stream and reading back. In my code I use the following workaround: template<class U, class T> inline typename boost::disable_if<boost::is_same<T, U>, U>::type lexical_cast(T const& t) { return boost::lexical_cast<U>(t); } template<class T> inline T const& lexical_cast(T const& t) { return t; } Does it make any sense to put it in lexical_cast.hpp? -- Maxim Yegorushkin