Namespaces
Variants

std::generator<Ref,V,Allocator>:: ~generator

From cppreference.net
Utilities library
Coroutine support
Coroutine traits
Coroutine handle
No-op coroutines
Trivial awaitables
Range generators
(C++23)
Ranges library
Range adaptors
~generator ( ) ;
(自 C++23 起)

析构生成器对象。

给定 coroutine_ 作为底层协程对象,等价于:

if (coroutine_)
    coroutine_.destroy();

注意,销毁根生成器实际上会销毁整个被yield生成器的调用栈,因为递归yield生成器的所有权由awaitable对象持有,而这些对象位于yield生成器的协程帧中。

复杂度

示例