diff --git a/include/continuable/detail/base.hpp b/include/continuable/detail/base.hpp index 2a4f663..3da9b66 100644 --- a/include/continuable/detail/base.hpp +++ b/include/continuable/detail/base.hpp @@ -83,7 +83,7 @@ struct attorney { template static auto invoke_continuation(continuable_base&& continuation, - Callback&& callback) { + Callback&& callback) noexcept { auto materialized = std::move(continuation).materialize(); materialized.release(); return materialized.data_(std::forward(callback)); @@ -151,6 +151,13 @@ public: #define CONTINUABLE_BLOCK_TRY_END } #endif // CONTINUABLE_WITH_EXCEPTIONS +/// Invokes the given callable object with the given arguments while +/// marking the operation as non exceptional. +template +constexpr auto invoke_no_except(T&& callable, Args&&... args) noexcept { + return std::forward(callable)(std::forward(args)...); +} + template constexpr auto make_invoker(T&& invoke, hints::signature_hint_tag) { return invoker, hints::signature_hint_tag>( @@ -192,8 +199,8 @@ constexpr auto invoker_of(traits::identity) { util::partial_invoke(std::forward(callback), std::forward(args)...); - std::forward(next_callback)( - std::move(result)); + invoke_no_except(std::forward(next_callback), + std::move(result)); CONTINUABLE_BLOCK_TRY_END }, traits::identity_of()); @@ -206,7 +213,8 @@ inline auto invoker_of(traits::identity) { CONTINUABLE_BLOCK_TRY_BEGIN util::partial_invoke(std::forward(callback), std::forward(args)...); - std::forward(next_callback)(); + invoke_no_except( + std::forward(next_callback)); CONTINUABLE_BLOCK_TRY_END }, traits::identity<>{}); @@ -228,8 +236,8 @@ inline auto sequenced_unpack_invoker() { traits::unpack(std::move(result), [&](auto&&... types) { /// TODO Add inplace resolution here - std::forward(next_callback)( - std::forward(types)...); + invoke_no_except(std::forward(next_callback), + std::forward(types)...); }); CONTINUABLE_BLOCK_TRY_END };