From d436099477357c94d04a4338480e60eee23d61fb Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Thu, 13 Apr 2006 20:52:28 +0000 Subject: [PATCH] Code size optimization [SVN r33694] --- include/boost/lexical_cast.hpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 926b95e..ce6668b 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef BOOST_NO_STRINGSTREAM #include @@ -209,19 +210,25 @@ namespace boost { typedef const T * type; }; + + template + Target lexical_cast( + BOOST_DEDUCED_TYPENAME boost::call_traits::value_type arg) + { + detail::lexical_stream interpreter; + Target result; + + if(!(interpreter << arg && interpreter >> result)) + throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); + return result; + } } template - Target lexical_cast(const Source &arg) + inline Target lexical_cast(const Source &arg) { typedef typename detail::array_to_pointer_decay::type NewSource; - - detail::lexical_stream interpreter; - Target result; - - if(!(interpreter << arg && interpreter >> result)) - throw_exception(bad_lexical_cast(typeid(NewSource), typeid(Target))); - return result; + return detail::lexical_cast(arg); } #else