[exec.with.awaitable.senders] (original) (raw)

with_awaitable_senders, when used as the base class of a coroutine promise type, makes senders awaitable in that coroutine type.

In addition, it provides a default implementation of unhandled_stoppedsuch that if a sender completes by calling set_stopped, it is treated as if an uncatchable "stopped" exception were thrown from the await-expression.

[Note 1:

The coroutine is never resumed, and the unhandled_stopped of the coroutine caller's promise type is called.

— _end note_]

namespace std::execution { template<class-type Promise> struct with_awaitable_senders { template<class OtherPromise> requires (same\_as<OtherPromise, void>) void set_continuation(coroutine_handle<OtherPromise> h) noexcept; coroutine_handle<> continuation() const noexcept { return continuation; } coroutine_handle<> unhandled_stopped() noexcept { return stopped-handler(continuation.address());} template<class Value> see below await_transform(Value&& value);private: [[noreturn]] static coroutine_handle<> default-unhandled-stopped(void*) noexcept { terminate();} coroutine_handle<> continuation{}; coroutine_handle<> (*stopped-handler)(void*) noexcept = &default-unhandled-stopped;};}