...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/coroutine/coroutine.hpp> template< typename Signature > class coroutine; template< typename R, typename ArgTypes... > class coroutine< R ( ArgTypes...) > { public: typedef unspec-type caller_type; typedef unspec-type arguments; coroutine(); template< typename Fn, typename StackAllocator = stack_allocator, typename Allocator = std::allocator< coroutine > > coroutine( Fn fn, attributes const& attr = attributes(), StackAllocator const& stack_alloc = StackAllocator(), Allocator const& alloc = Allocator() ); template< typename Fn, typename StackAllocator = stack_allocator, typename Allocator = std::allocator< coroutine > > coroutine( Fn fn, arguments const& args, attributes const& attr = attributes(), StackAllocator const& stack_alloc = StackAllocator(), Allocator const& alloc = Allocator() ); template< typename Fn, typename StackAllocator = stack_allocator, typename Allocator = std::allocator< coroutine > > coroutine( Fn && fn, attributes const& attr = attributes(), StackAllocator stack_alloc = StackAllocator(), Allocator const& alloc = Allocator() ); template< typename Fn, typename StackAllocator = stack_allocator, typename Allocator = std::allocator< coroutine > > coroutine( Fn && fn arguments const& args, attributes const& attr = attributes(), StackAllocator stack_alloc = StackAllocator(), Allocator const& alloc = Allocator() ); coroutine( coroutine && other); coroutine & operator=( coroutine && other); operator unspecified-bool-type() const; bool operator!() const; void swap( coroutine & other); bool empty() const; coroutine & operator()(A0 a0, ..., A9 a9); R get() const; }; template< typename Signature > void swap( coroutine< Signature > & l, coroutine< Signature > & r); template< typename T > range_iterator< coroutine< T() > >::type begin( coroutine< T() > &); template< typename T > range_iterator< coroutine< void(T) > >::type begin( coroutine< void(T) > &); template< typename T > range_iterator< coroutine< T() > >::type end( coroutine< T() > &); template< typename T > range_iterator< coroutine< void(T) > >::type end( coroutine< void(T) > &);
coroutine()
Creates a coroutine representing not-a-coroutine.
Nothing.
template< typename Fn, typename StackAllocator,
typename Allocator
> coroutine( Fn fn, attributes
const&
attr,
StackAllocator const& stack_alloc, Allocator const& alloc)
size
> minimum_stacksize(),
size
< maximum_stacksize()
when ! is_stack_unbound().
Creates a coroutine which will execute fn
.
Argument attr
determines
stack clean-up and preserving floating-point registers. For allocating/deallocating
the stack stack_alloc
is used and internal data are allocated by Allocator.
template< typename Fn, typename StackAllocator,
typename Allocator
> coroutine( Fn &&
fn, attributes const& attr, StackAllocator
const&
stack_alloc,
Allocator const& alloc)
size
> minimum_stacksize(),
size
< maximum_stacksize()
when ! is_stack_unbound().
Creates a coroutine which will execute fn
.
Argument attr
determines
stack clean-up and preserving floating-point registers. For allocating/deallocating
the stack stack_alloc
is used and internal data are allocated by Allocator.
coroutine( coroutine &&
other)
Moves the internal data of other
to *this
.
other
becomes not-a-coroutine.
Nothing.
coroutine &
operator=(
coroutine &&
other)
Destroys the internal data of *this
and moves the internal data of
other
to *this
.
other
becomes not-a-coroutine.
Nothing.
operator unspecified-bool-type() const
If *this
refers to not-a-coroutine or the coroutine-function
has returned (completed), the function returns false. Otherwise true.
Nothing.
bool operator!() const
If *this
refers to not-a-coroutine or the coroutine-function
has returned (completed), the function returns true. Otherwise false.
Nothing.
bool empty()
If *this
refers to not-a-coroutine, the function returns
true. Otherwise false.
Nothing.
coroutine<>
& operator()(A0 a0, A9
a9)
operator unspecified-bool-type() returns true for *this
.
[Effects:
Execution control is transferred to coroutine-function
and the arguments a0
,...,
are passed to the coroutine-function.
Exceptions thrown inside coroutine-function.
R get()()
*this
is not a not-a-coroutine, !
is_complete()
.
Returns data transferred from coroutine-function via boost::coroutines::coroutine<>::operator() of boost::coroutines::coroutine<>::caller_type.
Nothing.
void swap( coroutine & other)
Swaps the internal data from *this
with the values of other
.
Nothing.
T caller_type::operator()( R)
Gives execution control back to calling context by returning a value of type R. The return type of this function is a boost::tuple<> containing the arguments passed to boost::coroutines::coroutine<>::operator().
Nothing.
swap()
template< typename Signature > void swap( coroutine< Signature > & l, coroutine< Signature > & r);
As if 'l.swap( r)'.
begin(
coroutine<
T() > &)
template< typename T > range_iterator< coroutine< T() > >::type begin( coroutine< T() > &);
Returns a range-iterator (input-iterator).
begin(
coroutine<
void(T) >
&)
template< typename T > range_iterator< coroutine< void(T) > >::type begin( coroutine< void(T) > &);
Returns a range-iterator (output-iterator).
end(
coroutine<
T() > &)
template< typename T > range_iterator< coroutine< T() > >::type end( coroutine< T() > &);
Returns a end range-iterator (input-iterator).
end(
coroutine<
void(T) >
&)
template< typename T > range_iterator< coroutine< void(T) > >::type end( coroutine< void(T) > &);
Returns a end range-iterator (output-iterator).