Generator< T >::NextAwaiter Class Reference

#include <Pt/Generator.h>

Provides the awaitable returned by Generator::next(). More...

Inherits AwaiterBase.

Public Member Functions

 NextAwaiter (Generator &generator)
 Constructs a next-awaiter for generator.
 
 ~NextAwaiter ()
 Detaches from the generator if still pending.
 
void cancel () override
 Cancels the generator's pending operation.
 
bool await_ready () const noexcept
 Returns true if the generator has already finished.
 
template<typename FormP >
std::coroutine_handle await_suspend (std::coroutine_handle< FormP > outer)
 Suspends the consumer and resumes the generator. More...
 
bool await_resume ()
 Returns true if a yielded value is available. More...
 

Detailed Description

template<typename T>
class Pt::Generator< T >::NextAwaiter

co_await resumes when the generator yields a value or finishes. The resume value is true if Generator::value() is valid. Cancelling the generator cancels a pending next() await.

Member Function Documentation

◆ await_suspend()

std::coroutine_handle await_suspend ( std::coroutine_handle< FormP >  outer)
Exceptions
%std::logic_errorif the generator is already pending.

◆ await_resume()

bool await_resume ( )

Rethrows if the generator body exited with an exception.