3.2 KiB
[coroutine.handle.general]
17 Language support library [support]
17.13 Coroutines [support.coroutine]
17.13.4 Class template coroutine_handle [coroutine.handle]
17.13.4.1 General [coroutine.handle.general]
namespace std {template<>struct coroutine_handle{// [coroutine.handle.con], construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept; coroutine_handle& operator=(nullptr_t) noexcept; // [coroutine.handle.export.import], export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [coroutine.handle.observers], observersconstexpr explicit operator bool() const noexcept; bool done() const; // [coroutine.handle.resumption], resumptionvoid operator()() const; void resume() const; void destroy() const; private:void* ptr; // exposition only}; templatestruct coroutine_handle {// [coroutine.handle.con], construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept; static coroutine_handle from_promise(Promise&); coroutine_handle& operator=(nullptr_t) noexcept; // [coroutine.handle.export.import], export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [coroutine.handle.conv], conversionconstexpr operator coroutine_handle<>() const noexcept; // [coroutine.handle.observers], observersconstexpr explicit operator bool() const noexcept; bool done() const; // [coroutine.handle.resumption], resumptionvoid operator()() const; void resume() const; void destroy() const; // [coroutine.handle.promise], promise access Promise& promise() const; private:void* ptr; // exposition only};}
An object of typecoroutine_handle is called a coroutine handle and can be used to refer to a suspended or executing coroutine.
A coroutine_handle object whose member address() returns a null pointer value does not refer to any coroutine.
Two coroutine_handle objects refer to the same coroutine if and only if their member address() returns the same non-null value.
If a program declares an explicit or partial specialization ofcoroutine_handle, the behavior is undefined.