From 98a67d93f3f1b253e22c743f82bd48df5107e1d1 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Thu, 4 Dec 2008 23:18:50 +0000 Subject: [PATCH] Fixes #1220: lexical_cast requires RTTI [SVN r50124] --- include/boost/lexical_cast.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index bc678fa..0da0d3d 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -60,15 +60,21 @@ namespace boost { public: bad_lexical_cast() : - source(&typeid(void)), target(&typeid(void)) +#ifndef BOOST_NO_TYPEID + source(&typeid(void)), target(&typeid(void)) +#else + source(0), target(0) // this breaks getters +#endif { } + bad_lexical_cast( const std::type_info &source_type_arg, const std::type_info &target_type_arg) : source(&source_type_arg), target(&target_type_arg) { } + const std::type_info &source_type() const { return *source; @@ -77,6 +83,7 @@ namespace boost { return *target; } + virtual const char *what() const throw() { return "bad lexical cast: " @@ -1144,7 +1151,11 @@ namespace boost if (interpreter >> result) return result; } +#ifndef BOOST_NO_TYPEID throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); +#else + throw_exception(bad_lexical_cast()); +#endif return Target(); // normally never reached (throw_exception) } } @@ -1183,7 +1194,11 @@ namespace boost Target result; if(!(interpreter << arg && interpreter >> result)) +#ifndef BOOST_NO_TYPEID throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); +#else + throw_exception(bad_lexical_cast()); +#endif return result; }