Commit 3dfbb30d authored by Tiago Peixoto's avatar Tiago Peixoto

nested_for_each(): isolate boost::any_cast<>

parent 4fa837b9
......@@ -77,6 +77,8 @@ struct all_any_cast
dispatch(std::make_index_sequence<sizeof...(Ts)>(), vs...);
}
struct fail_cast {};
template <class T>
T& try_any_cast(boost::any& a) const
{
......@@ -84,9 +86,16 @@ struct all_any_cast
{
return any_cast<T&>(a);
}
catch (bad_any_cast)
catch (bad_any_cast&)
{
return any_cast<std::reference_wrapper<T>>(a);
try
{
return any_cast<std::reference_wrapper<T>>(a);
}
catch (bad_any_cast&)
{
throw fail_cast();
}
}
}
......@@ -99,7 +108,7 @@ struct all_any_cast
_a(try_any_cast<Ts>(*_args[Idx])...);
throw stop_iteration();
}
catch (bad_any_cast) {}
catch (fail_cast) {}
}
Action _a;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment