Fixes #1220: lexical_cast requires RTTI

[SVN r50124]
This commit is contained in:
Alexander Nasonov
2008-12-04 23:18:50 +00:00
parent 0c54d6a037
commit 98a67d93f3

View File

@@ -60,15 +60,21 @@ namespace boost
{ {
public: public:
bad_lexical_cast() : 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( bad_lexical_cast(
const std::type_info &source_type_arg, const std::type_info &source_type_arg,
const std::type_info &target_type_arg) : const std::type_info &target_type_arg) :
source(&source_type_arg), target(&target_type_arg) source(&source_type_arg), target(&target_type_arg)
{ {
} }
const std::type_info &source_type() const const std::type_info &source_type() const
{ {
return *source; return *source;
@@ -77,6 +83,7 @@ namespace boost
{ {
return *target; return *target;
} }
virtual const char *what() const throw() virtual const char *what() const throw()
{ {
return "bad lexical cast: " return "bad lexical cast: "
@@ -1144,7 +1151,11 @@ namespace boost
if (interpreter >> result) if (interpreter >> result)
return result; return result;
} }
#ifndef BOOST_NO_TYPEID
throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); throw_exception(bad_lexical_cast(typeid(Source), typeid(Target)));
#else
throw_exception(bad_lexical_cast());
#endif
return Target(); // normally never reached (throw_exception) return Target(); // normally never reached (throw_exception)
} }
} }
@@ -1183,7 +1194,11 @@ namespace boost
Target result; Target result;
if(!(interpreter << arg && interpreter >> result)) if(!(interpreter << arg && interpreter >> result))
#ifndef BOOST_NO_TYPEID
throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); throw_exception(bad_lexical_cast(typeid(Source), typeid(Target)));
#else
throw_exception(bad_lexical_cast());
#endif
return result; return result;
} }