Namespaces
Variants

std::coroutine_handle<Promise>:: coroutine_handle

From cppreference.net
Utilities library
Coroutine support
Coroutine traits
Coroutine handle
No-op coroutines
Trivial awaitables
Range generators
(C++23)
constexpr coroutine_handle ( ) noexcept ;
(1) (C++20 起)
constexpr coroutine_handle ( std:: nullptr_t ) noexcept ;
(2) (C++20 起)
coroutine_handle ( const coroutine_handle & other ) = default ;
(3) (C++20 起)
coroutine_handle ( coroutine_handle && other ) = default ;
(4) (C++20 起)

创建一个不引用协程的 coroutine_handle ,或复制一个 coroutine_handle

1,2) 将底层地址 ptr 初始化为 nullptr 。构造完成后, address() 返回 nullptr ,且该 coroutine_handle 不引用任何协程。这些构造函数未针对特化 std:: coroutine_handle < std:: noop_coroutine_promise > 声明。
3,4) 复制底层地址。复制构造函数和移动构造函数与隐式声明的构造函数等效。

参数

其他 - 待复制的另一个 coroutine_handle

说明

std:: coroutine_handle < std:: noop_coroutine_promise > 既不可默认构造,也无法从 std::nullptr_t 构造。 std::noop_coroutine 可用于创建新的 std:: coroutine_handle < std:: noop_coroutine_promise >

静态成员函数 from_promise from_address 同样可以创建 coroutine_handle

参见

从协程的 promise 对象创建 coroutine_handle
(公开静态成员函数)
从指针导入协程
(公开静态成员函数)
创建一个在恢复或销毁时没有可观察效果的协程句柄
(函数)