ptree_helpers: ensure proper return type upon exception (TODO: needs larger cleanup)
This commit is contained in:
parent
f81108d5b3
commit
87da7c2e3e
1 changed files with 9 additions and 1 deletions
|
@ -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 <>
|
||||
|
|
Loading…
Add table
Reference in a new issue