33template <std::invocable Func>
38 requires std::same_as<std::remove_cvref_t<F>, Func>
explicit async(F &&func)
39 :
func_ {std::forward<F>(func)} {}
42 operator co_await() & =
delete;
43 decltype(
auto)
operator co_await() && {
51 auto work = [&, handle]() {
54 if constexpr (std::is_void_v<return_type>)
59 awaitable.result_.set_exception(std::current_exception());
65 std::jthread(work).detach();
69 return std::move(
awaitable.result_).get();
std::invoke_result_t< Func > return_type
detail::storage< return_type > result_
Storage class that can either contain a value, an exception, or be empty.
bool await_ready() const noexcept
Returns true if the task's coroutine is already done (suspended at its final suspension point).
decltype(auto) await_resume() const
Return the value of the task's promise.
std::coroutine_handle await_suspend(std::coroutine_handle<> h) const noexcept
Set the current coroutine as this task's continuation, and then resume this task's coroutine.