Class coroutine<>::push_type

| Home | Libraries | People | FAQ | More

#### Class `coroutine<>::push_type`

    #include <boost/coroutine2/coroutine.hpp>

    template< typename Arg >
    class coroutine<>::push_type
    {
    public:
        template< typename Fn >
        push_type( Fn && fn);

        template< typename StackAllocator, typename Fn >
        push_type( StackAllocator stack_alloc, Fn && fn);

        push_type( push_type const& other)=delete;

        push_type & operator=( push_type const& other)=delete;

        ~push_type();

        push_type( push_type && other) noexcept;

        push_type & operator=( push_type && other) noexcept;

        explicit operator bool() const noexcept;

        bool operator!() const noexcept;

        push_type & operator()( Arg arg);
    };

    template< typename Arg >
    range_iterator< push_type< Arg > >::type begin( push_type< Arg > &);

    template< typename Arg >
    range_iterator< push_type< Arg > >::type end( push_type< Arg > &);

###### `template< typename Fn > push_type( Fn && fn)`

Effects:

  Creates a coroutine which will execute `fn`.

###### `template< typename StackAllocator, typename Fn > push_type( StackAllocator const& stack_alloc, Fn && fn)`

Effects:

  Creates a coroutine which will execute `fn`. For allocating/deallocating the stack `stack_alloc` is used.

###### `~push_type()`

Effects:

  Destroys the context and deallocates the stack.

###### `push_type( push_type && other) noexcept`

Effects:

  Moves the internal data of `other` to `*this`. `other` becomes not-a-coroutine.

Throws:

  Nothing.

###### `push_type & operator=( push_type && other) noexcept`

Effects:

  Destroys the internal data of `*this` and moves the internal data of `other` to `*this`. `other` becomes not-a-coroutine.

Throws:

  Nothing.

###### `explicit operator bool() const noexcept`

Returns:

  If `*this` refers to not-a-coroutine or the coroutine-function has returned (completed), the function returns `false`. Otherwise `true`.

Throws:

  Nothing.

###### `bool operator!() const noexcept`

Returns:

  If `*this` refers to not-a-coroutine or the coroutine-function has returned (completed), the function returns `true`. Otherwise `false`.

Throws:

  Nothing.

###### `push_type & operator()(Arg arg)`

    push_type& coroutine<Arg>::push_type::operator()(Arg);
    push_type& coroutine<Arg&>::push_type::operator()(Arg&);
    push_type& coroutine<void>::push_type::operator()();

Preconditions:

  operator unspecified-bool-type() returns `true` for `*this`.

Effects:

  Execution control is transferred to coroutine-function and the argument `arg` is passed to the coroutine-function.

Throws:

  Exceptions thrown inside coroutine-function.

###### Non-member function `begin( push_type< Arg > &)`

    template< typename Arg >
    range_iterator< push_type< Arg > >::type begin( push_type< Arg > &);

Returns:

  Returns a range-iterator (output-iterator).

###### Non-member function `end( push_type< Arg > &)`

    template< typename Arg >
    range_iterator< push_type< Arg > >::type end( push_type< Arg > &);

Returns:

  Returns a end range-iterator (output-iterator).

Note:

  When first obtained from `begin( push_type< R > &)`, or after some number of increment operations, an iterator will compare equal to the iterator returned by `end( push_type< R > &)` when the corresponding coroutine<>::push_type::operator bool would return `false`.