ptree_helpers: ensure proper return type upon exception (TODO: needs larger cleanup)

This commit is contained in:
Dane Springmeyer 2012-03-05 12:34:10 -08:00
parent f81108d5b3
commit 87da7c2e3e

View file

@ -211,7 +211,15 @@ struct name_trait< mapnik::enumeration<ENUM, MAX> >
template <typename T>
inline boost::optional<T> fast_cast(std::string const& value)
{
return boost::lexical_cast<T>( value );
try
{
return boost::lexical_cast<T>( value );
}
catch (boost::bad_lexical_cast const& ex)
{
return boost::optional<T>();
}
}
template <>