MCPcopy Create free account
hub / github.com/boostorg/leaf / try_handle_some

Function try_handle_some

include/boost/leaf/handle_errors.hpp:536–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534template <class TryBlock, class... H>
535BOOST_LEAF_ATTRIBUTE_NODISCARD BOOST_LEAF_CONSTEXPR inline
536typename std::decay<decltype(std::declval<TryBlock>()())>::type
537try_handle_some( TryBlock && try_block, H && ... h ) noexcept
538{
539 static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_some function must be registered with leaf::is_result_type");
540 context_type_from_handlers<H...> ctx;
541 auto active_context = activate_context(ctx);
542 if( auto r = std::forward<TryBlock>(try_block)() )
543 return r;
544 else
545 {
546 detail::unload_result(&r);
547 error_id id(r.error());
548 ctx.deactivate();
549 using R = typename std::decay<decltype(std::declval<TryBlock>()())>::type;
550 auto rr = ctx.template handle_error<R>(std::move(id), std::forward<H>(h)..., [&r]()->R { return std::move(r); });
551 if( !rr )
552 ctx.unload(error_id(rr.error()));
553 return rr;
554 }
555}
556
557template <class TryBlock, class... H>
558BOOST_LEAF_CONSTEXPR inline

Callers 15

print_halfFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
test2Function · 0.85
testFunction · 0.85
f2Function · 0.85
f3Function · 0.85
f4Function · 0.85
handle_some_errorsFunction · 0.85
handle_some_errors_floatFunction · 0.85
handle_some_errors_voidFunction · 0.85
mainFunction · 0.85

Calls 5

activate_contextFunction · 0.85
unload_resultFunction · 0.85
error_idClass · 0.70
deactivateMethod · 0.45
unloadMethod · 0.45

Tested by 15

mainFunction · 0.68
mainFunction · 0.68
test2Function · 0.68
testFunction · 0.68
f2Function · 0.68
f3Function · 0.68
f4Function · 0.68
handle_some_errorsFunction · 0.68
handle_some_errors_floatFunction · 0.68
handle_some_errors_voidFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68