| 608 | |
| 609 | template <class TryBlock, class... H> |
| 610 | inline |
| 611 | typename std::decay<decltype(std::declval<TryBlock>()().value())>::type |
| 612 | try_handle_all( TryBlock && try_block, H && ... h ) |
| 613 | { |
| 614 | static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to try_handle_all must be registered with leaf::is_result_type"); |
| 615 | context_type_from_handlers<H...> ctx; |
| 616 | auto active_context = activate_context(ctx); |
| 617 | if( auto r = detail::try_catch_(ctx, std::forward<TryBlock>(try_block), std::forward<H>(h)...) ) |
| 618 | return std::move(r).value(); |
| 619 | else |
| 620 | { |
| 621 | BOOST_LEAF_ASSERT(ctx.is_active()); |
| 622 | detail::unload_result(&r); |
| 623 | error_id id(r.error()); |
| 624 | ctx.deactivate(); |
| 625 | using R = typename std::decay<decltype(std::declval<TryBlock>()().value())>::type; |
| 626 | return ctx.template handle_error<R>(std::move(id), std::forward<H>(h)...); |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | template <class TryBlock, class... H> |
| 631 | BOOST_LEAF_ATTRIBUTE_NODISCARD inline |