libcoro
1.0
Coroutine support library for C++20
|
COROUTINE: Generator. More...
#include <generator.h>
Public Types | |
using | value_type = T |
value type More... | |
using | reference = std::add_lvalue_reference_t< T > |
reference type More... | |
Public Member Functions | |
deferred_future< T > | operator() () |
call the generator More... | |
operator bool () const | |
Determines state of generator. More... | |
generator ()=default | |
object can be default constructed More... | |
template<typename A > | |
generator (generator< T, A > &&other) | |
convert from different allocator More... | |
auto | begin () |
retrieve begin iterator More... | |
auto | end () |
retrieve end iterator More... | |
COROUTINE: Generator.
Implements generator coroutine, supporting co_yield operation.
T | type of yielded value. This argument can be T or T & (reference). In case that T is reference, the behaviour is same, however, the internal part of the generator just carries a reference to the result which is always avaiable as temporary value when coroutine is suspended on co_yield. This helps to reduce necessery copying. |
Alloc | A class which is responsible to allocate generator's frame. It must implement coro_allocator concept |
The coroutine always returns void.
The generator IS NOT MT SAFE! Only one thread can call the generator and one must avoid to call the generator again before the result is available.
The generator can be destroyed when it is suspended on co_yield.
Definition at line 94 of file generator.h.