4#include "../detail/task_adapters/result_helpers.hpp"
18template <
typename Task>
26 noexcept(std::is_nothrow_move_constructible_v<Task>)
27 :
task(std::move(stored_task)) {}
30 noexcept(std::is_nothrow_copy_constructible_v<Task>)
31 :
task(stored_task) {}
42 template <
typename Ctx,
typename Prev>
48 "Wrapped task raw_result_type must match invoke_raw(exec_context<...>&) return type");
50 "Default catch_as_failure only supports tasks returning void or step_result");
53 if constexpr (std::is_void_v<raw_result_t>) {
57 return task.invoke_raw(ec);
64 template <
typename Ctx,
typename Prev,
typename U = Task>
70 return task.invoke_into(ec, out);
90template <
typename Task,
typename Policy>
99 noexcept(std::is_nothrow_move_constructible_v<Task> &&
100 std::is_nothrow_move_constructible_v<Policy>)
101 :
task(std::move(stored_task)),
102 policy(std::move(stored_policy)) {}
105 noexcept(std::is_nothrow_copy_constructible_v<Task> &&
106 std::is_nothrow_copy_constructible_v<Policy>)
120 template <
typename Ctx,
typename Prev>
126 "Wrapped task raw_result_type must match invoke_raw(exec_context<...>&) return type");
128 "catch_as_failure(task, policy) requires a noexcept fallback taking std::exception_ptr and returning a compatible result");
131 if constexpr (std::is_void_v<raw_result_t>) {
135 return task.invoke_raw(ec);
142 template <
typename Ctx,
typename Prev,
typename U = Task>
148 return task.invoke_into(ec, out);
150 return std::invoke(
policy, std::current_exception());
174template <
typename Task>
177 std::forward<Task>(
task)
202template <
typename Task,
typename Policy>
208 std::forward<Task>(
task),
209 std::forward<Policy>(policy)
Reports whether catch_as_failure(task, policy) can wrap Task using the provided fallback Policy.
Reports whether catch_as_failure(task) can wrap Task for a concrete execution context without a custo...
typename declared_task_output< Task >::type declared_task_output_t
decltype(std::declval< Task >().invoke_raw(std::declval< exec_context< Ctx, Prev > & >())) raw_task_result_t
constexpr bool is_adapter_descriptor_v
constexpr auto catch_as_failure(Task &&task)
Wraps a task so thrown exceptions become default failure results.
constexpr auto task(F &&f)
Exception-catching adapter for tasks that rely on the default failure mapping.
constexpr step_result invoke_into(exec_context< Ctx, Prev > &ec, direct_out< detail::declared_task_output_t< U > > out) noexcept
constexpr catch_failure_task(Task &&stored_task) noexcept(std::is_nothrow_move_constructible_v< Task >)
constexpr auto invoke_raw(exec_context< Ctx, Prev > &ec) noexcept
Executes the wrapped task and maps thrown exceptions to failure.
constexpr catch_failure_task(const Task &stored_task) noexcept(std::is_nothrow_copy_constructible_v< Task >)
Exception-catching adapter for tasks with a user-supplied fallback policy.
constexpr catch_failure_with_policy_task(const Task &stored_task, const Policy &stored_policy) noexcept(std::is_nothrow_copy_constructible_v< Task > &&std::is_nothrow_copy_constructible_v< Policy >)
constexpr catch_failure_with_policy_task(Task &&stored_task, Policy &&stored_policy) noexcept(std::is_nothrow_move_constructible_v< Task > &&std::is_nothrow_move_constructible_v< Policy >)
constexpr auto invoke_raw(exec_context< Ctx, Prev > &ec) noexcept
Executes the wrapped task and delegates exception handling to the stored fallback policy.
constexpr step_result invoke_into(exec_context< Ctx, Prev > &ec, direct_out< detail::declared_task_output_t< U > > out) noexcept
Output sink passed to direct-output tasks.
Lightweight borrowed view used during execution.
Represents the basic outcome of a task step.
static constexpr step_result failure() noexcept
Creates a failed result.
static constexpr step_result success() noexcept
Creates a successful result.