ORIGINAL
|
Lazy sequence generator using C++20 coroutines. More...
#include <coroutines.h>
Public Types | |
using | promise_type = promise_type |
Promise type for coroutine protocol. | |
using | iterator = iterator |
Iterator type for range operations. | |
Public Member Functions | |
generator (const generator &)=delete | |
Copy constructor deleted. | |
generator & | operator= (const generator &)=delete |
Copy assignment deleted. | |
generator (generator &&other) noexcept | |
Move constructor transfers coroutine ownership. | |
generator & | operator= (generator &&other) noexcept |
Move assignment operator transfers coroutine ownership. | |
generator ()=default | |
Default constructor creates empty generator. | |
generator (handle h) | |
Constructs generator from coroutine handle. | |
iterator | begin () |
Gets begin iterator for range-based operations. | |
bool | launched () const |
Checks if coroutine has been launched. | |
bool | hasNext () const |
Checks if generator has more values. | |
alternative< TYPE > | peek () const |
Peeks at current value without advancing. | |
alternative< TYPE > | next () |
Advances generator and gets next value. | |
~generator () | |
Destructor cleans up coroutine resources. | |
Static Public Member Functions | |
static iterator | end () |
Gets end iterator for range-based operations. | |
Lazy sequence generator using C++20 coroutines.
TYPE | Type of values generated by the coroutine |
Implements the coroutine promise protocol to create generators that can yield sequences of values. Supports range-based for loops, manual iteration, and exception propagation.
The generator maintains the following states:
|
noexcept |
Move constructor transfers coroutine ownership.
other | Generator to move from |
|
explicit |
Constructs generator from coroutine handle.
h | Coroutine handle to manage |
original::coroutine::generator< TYPE >::~generator | ( | ) |
Destructor cleans up coroutine resources.
original::coroutine::generator< TYPE >::iterator original::coroutine::generator< TYPE >::begin | ( | ) |
Gets begin iterator for range-based operations.
|
static |
Gets end iterator for range-based operations.
bool original::coroutine::generator< TYPE >::hasNext | ( | ) | const |
Checks if generator has more values.
bool original::coroutine::generator< TYPE >::launched | ( | ) | const |
Checks if coroutine has been launched.
original::alternative< TYPE > original::coroutine::generator< TYPE >::next | ( | ) |
Advances generator and gets next value.
|
noexcept |
Move assignment operator transfers coroutine ownership.
other | Generator to move from |
original::alternative< TYPE > original::coroutine::generator< TYPE >::peek | ( | ) | const |
Peeks at current value without advancing.