libcoro  1.0
Coroutine support library for C++20
Public Types | Public Member Functions | List of all members
coro::generator< T, Alloc > Class Template Reference

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...
 

Detailed Description

template<typename T, coro_allocator Alloc = std_allocator>
class coro::generator< T, Alloc >

COROUTINE: Generator.

Implements generator coroutine, supporting co_yield operation.

Template Parameters
Ttype 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.
AllocA 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.

Note
The object is movable and move assignable. ,

Definition at line 94 of file generator.h.


The documentation for this class was generated from the following file: