|
cortex 0.0.1
|
A stackful generator that yields values of type T. More...
#include <generator.hpp>
Classes | |
| struct | Builder |
| A builder class for creating Generator instances with custom configuration. More... | |
| class | YieldContext |
| Context provided to the generator body to yield values. More... | |
Public Types | |
| using | Body = fu2::unique_function< void(YieldContext &)> |
Public Member Functions | |
| Generator (const Generator &)=delete | |
| Generator (Generator &&) noexcept=default | |
| Generator & | operator= (const Generator &)=delete |
| Generator & | operator= (Generator &&) noexcept=default |
| ~Generator ()=default | |
| bool | IsDone () const noexcept |
| Checks if the generator has finished its execution. | |
| bool | Next () |
| Resumes execution until a value is yielded or the generator completes. | |
| T | DetachValue () |
| Moves out the current value and clears it. | |
Static Public Member Functions | |
| static Generator | Make (Body body, std::size_t stack_size_bytes=262144, MemoryResourceSharedPtr resource=GetDefaultMemoryResource()) |
| Creates a new generator with the specified body and stack size. | |
A stackful generator that yields values of type T.
| using cortex::Generator< T >::Body = fu2::unique_function<void(YieldContext&)> |
|
delete |
|
defaultnoexcept |
|
default |
|
inline |
Moves out the current value and clears it.
| std::logic_error | if no value is available. |
|
inlinenoexcept |
Checks if the generator has finished its execution.
|
inlinestatic |
Creates a new generator with the specified body and stack size.
| body | The function or callable to execute within the generator. |
| stack_size_bytes | The size of the stack to allocate for the coroutine (default: 256KB). |
| resource | The memory resource to use for stack and implementation allocation (default: GetDefaultMemoryResource()). |
| std::invalid_argument | if the body is empty or stack_size_bytes is 0 or resource is null. |
|
inline |
Resumes execution until a value is yielded or the generator completes.
|
delete |
|
defaultnoexcept |