13 #ifndef mitkLexicalCast_h
14 #define mitkLexicalCast_h
16 #include <boost/lexical_cast.hpp>
20 template <
typename Target>
23 Target result = Target();
26 if (!boost::conversion::detail::try_lexical_convert(arg, result))
31 std::istringstream stream(arg);
32 stream.exceptions(std::ios::badbit);
36 stream.unsetf(std::ios::skipws);
37 stream.precision(boost::detail::lcast_get_precision<Target>());
40 catch (
const std::ios_base::failure &)
42 boost::conversion::detail::throw_bad_cast<std::string, Target>();
53 inline float lexical_cast<float, std::string>(
const std::string &arg)
55 return mitk::lexical_cast<float>(arg);
59 inline double lexical_cast<double, std::string>(
const std::string &arg)
61 return mitk::lexical_cast<double>(arg);
65 inline long double lexical_cast<long double, std::string>(
const std::string &arg)
67 return mitk::lexical_cast<long double>(arg);