...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/coroutine2/coroutine.hpp> template< typename R > class coroutine<>::pull_type { public: template< typename Fn > pull_type( Fn && fn); template< typename StackAllocator, typename Fn > pull_type( StackAllocator stack_alloc, Fn && fn); pull_type( pull_type const& other)=delete; pull_type & operator=( pull_type const& other)=delete; ~pull_type(); pull_type( pull_type && other) noexcept; pull_type & operator=( pull_type && other) noexcept; pull_coroutine & operator()(); explicit operator bool() const noexcept; bool operator!() const noexcept; R get() noexcept; }; template< typename R > range_iterator< pull_type< R > >::type begin( pull_type< R > &); template< typename R > range_iterator< pull_type< R > >::type end( pull_type< R > &);
template< typename Fn
> pull_type( Fn && fn)
Creates a coroutine which will execute fn
,
and enters it.
Exceptions thrown inside coroutine-function.
template< typename StackAllocator, typename Fn > pull_type(
StackAllocator const& stack_alloc, Fn && fn)
Creates a coroutine which will execute fn
.
For allocating/deallocating the stack stack_alloc
is used.
Exceptions thrown inside coroutine-function.
~pull_type()
Destroys the context and deallocates the stack.
pull_type(
pull_type &&
other)
Moves the internal data of other
to *this
.
other
becomes not-a-coroutine.
Nothing.
pull_type &
operator=(
pull_type &&
other)
Destroys the internal data of *this
and moves the internal data of
other
to *this
.
other
becomes not-a-coroutine.
Nothing.
explicit operator
bool()
const noexcept
If *this
refers to not-a-coroutine or the coroutine-function
has returned (completed), the function returns false
.
Otherwise true
.
Nothing.
bool operator!() const noexcept
If *this
refers to not-a-coroutine or the coroutine-function
has returned (completed), the function returns true
.
Otherwise false
.
Nothing.
pull_type<>
& operator()()
*this
is not a not-a-coroutine.
Execution control is transferred to coroutine-function (no parameter is passed to the coroutine-function).
Exceptions thrown inside coroutine-function.
R get() noexcept
R coroutine<R,StackAllocator>::pull_type::get(); R& coroutine<R&,StackAllocator>::pull_type::get(); void coroutine<void,StackAllocator>::pull_type::get()=delete;
*this
is not a not-a-coroutine.
Returns data transferred from coroutine-function via coroutine<>::push_type::operator().
invalid_result
If R
is a move-only
type, you may only call get()
once before the next coroutine<>::pull_type::operator()
call.
begin(
pull_type<
R >
&)
template< typename R > range_iterator< pull_type< R > >::type begin( pull_type< R > &);
Returns a range-iterator (input-iterator).
end(
pull_type<
R >
&)
template< typename R > range_iterator< pull_type< R > >::type end( pull_type< R > &);
Returns an end range-iterator (input-iterator).
When first obtained from begin( pull_type< R
> &)
,
or after some number of increment operations, an iterator will compare
equal to the iterator returned by end( pull_type< R
> &)
when the corresponding coroutine<>::pull_type::operator
bool would return false
.