Home | Libraries | People | FAQ | More |
#include <boost/coroutine/generator.hpp> template< typename Result, typename Allocator = ctx::stack_allocator > class generator { public: class self_t { public: void yield( R); void yield_break(); }; generator(); template< typename Fn > generator( Fn fn, std::size_t size = ctx::default_stacksize(), flag_unwind_t do_unwind = stack_unwind, bool preserve_fpu = true, Allocator alloc = Allocator() ); template< typename Fn > generator( Fn && fn, std::size_t size = ctx::default_stacksize(), flag_unwind_t do_unwind = stack_unwind, bool preserve_fpu = true, Allocator alloc = Allocator() ); generator( generator && other); generator & operator=( generator && other); operator unspecified-bool-type() const; bool operator!() const; void swap( generator & other); Result operator()(); }; void swap( generator & l, generator & r);
generator()
Creates a generator representing a not-a-generator.
Nothing.
template< typename Fn > generator( Fn fn, std::size_t size, flag_unwind_t
do_unwind,
bool preserve_fpu, Allocator alloc)
size
> ctx::minimum_stacksize(),
size
< ctx::maximum_stacksize()
when ! ctx::is_stack_unbound().
Creates a generator which will execute fn
.
If do_unwind
is stack_unwind
the destructor of *this
unwinds the stack before destructing it. If preserve_fpu
is true
the floating-point
registers are preserved between context switches.
invalid_argument if a precondition is not satisfied.
generator( generator &&
other)
Moves the internal data of other
to *this
.
other
becomes not-a-generator.
Nothing.
generator &
operator=(
generator &&
other)
Destroys the internal data of *this
and moves the internal data of
other
to *this
.
other
becomes not-a-generator.
Nothing.
operator unspecified-bool-type() const
If *this
refers to not-a-generator, the function returns
false. Otherwise true.
Nothing.
bool operator!() const
If *this
refers not to not-a-generator, the function returns
true. Otherwise false.
Nothing.
void swap( generator & other)
Swaps the internal data from *this
with the values of other
.
Nothing.
Result operator()()
*this
is not a not-a-generator, !
is_complete()
.
The return value is the argument passed to generator<>::self_t::yield().
Re-throws exceptions exceptions thrown inside generator-function.
void self_t::yield( Result)
Gives execution control back to calling context by returning a value of type Result. The return type of this function is a boost::tuple<> containing the arguments passed to generator<>::operator()().
Nothing.
void self_t::yield_break()
Gives execution control back to calling context and sets the generator to be complete. generator<>::operator()() in the other generator throws exception coroutine_terminated.
*this
is complete, which is operator
unspecified-bool-type()
returns false
.
swap()
void swap( generator & l, generator & r);
As if 'l.swap( r)'.