Boost logo

Boost Users :

Subject: Re: [Boost-users] [Coroutine 1.54] Compile error with bool return from coroutine-function
From: Lukas Cz (lukas70000_at_[hidden])
Date: 2014-04-27 15:41:36


Coroutine library has changed a lot in boost 1.55.
Now corotine<T> defines *push_type* which is output coroutine type and
*pull_type
*which is input coroutine type.
It determines one directional data transfer.

Try code below:

typedef boost::coroutines::coroutine< int > coro_t;

void get_a_bool( coro_t::push_type& yield )
{
  while (1)
     yield(1);
}

int main(int argc, char *argv[])
{

    coro_t::pull_type producer( boost::bind(&get_a_bool, _1) );

2014-04-24 18:56 GMT+02:00 Rob Desbois <rob.desbois_at_[hidden]>:

> (Caveat: I've been unable to find anything about this; hopefully
> haven't missed anything obvious.)
> (Apology: I'm aware Coroutine has a new interface as of 1.55; I
> haven't determined whether it is also affected.)
>
> Given the following code:
> #include <cassert>
> #include <boost/bind.hpp>
> #include <boost/coroutine/coroutine.hpp>
>
> using coro_t = boost::coroutines::coroutine< bool() >;
>
> void get_a_bool( coro_t::caller_type& yield )
> {
> while (true)
> yield(true);
> }
>
> int main()
> {
> coro_t producer( boost::bind(&get_a_bool, _1) );
> assert( producer );
> }
>
>
> I get this error on compilation (g++ 4.8.2, Boost 1.54):
> rob{code 0} 839# clear && g++ boost-coroutine-bool-return.cpp -g -W
> -Wall --std=c++11 -L. -lboost_context -lboost_coroutine -o
> boost-coroutine-bool-return
> In file included from
> /usr/include/boost/coroutine/v1/detail/coroutine_base_resume.hpp:26:0,
> from
> /usr/include/boost/coroutine/v1/detail/coroutine_base.hpp:21,
> from /usr/include/boost/coroutine/v1/coroutine.hpp:30,
> from /usr/include/boost/coroutine/coroutine.hpp:13,
> from boost-coroutine-bool-return.cpp:11:
> /usr/include/boost/coroutine/detail/holder.hpp: In instantiation of
> ‘struct boost::coroutines::detail::holder<bool>’:
> /usr/include/boost/coroutine/v1/detail/coroutine_base_resume.hpp:103:28:
> required from ‘void
> boost::coroutines::detail::coroutine_base_resume<Signature, D, void,
> 1>::resume(boost::coroutines::detail::coroutine_base_resume<Signature,
> D, void, 1>::arg_type) [with Signature = void(bool); D =
> boost::coroutines::detail::coroutine_base<void(bool)>;
> boost::coroutines::detail::coroutine_base_resume<Signature, D, void,
> 1>::arg_type = bool]’
> /usr/include/boost/coroutine/v1/detail/coroutine_op.hpp:268:9:
> required from ‘D& boost::coroutines::detail::coroutine_op<Signature,
> D, void, 1>::operator()(boost::coroutines::detail::coroutine_op<Signature,
> D, void, 1>::arg_type) [with Signature = void(bool); D =
> boost::coroutines::coroutine<void(bool), 1>;
> boost::coroutines::detail::coroutine_op<Signature, D, void,
> 1>::arg_type = bool]’
> boost-coroutine-bool-return.cpp:29:13: required from here
> /usr/include/boost/coroutine/detail/holder.hpp:39:14: error:
>
> ‘boost::coroutines::detail::holder<Data>::holder(boost::coroutines::detail::coroutine_context*,
> bool) [with Data = bool]’ cannot be overloaded
> explicit holder( coroutine_context * ctx_, bool force_unwind_) :
> ^
> /usr/include/boost/coroutine/detail/holder.hpp:35:14: error: with
>
> ‘boost::coroutines::detail::holder<Data>::holder(boost::coroutines::detail::coroutine_context*,
> Data) [with Data = bool]’
> explicit holder( coroutine_context * ctx_, Data data_) :
>
>
> At a glance it looks like there's no way a coroutine-function could
> possibly return bool due to the overload collision. Is this right? Did
> I miss something completely obvious in the docs?
>
> It's easy enough to work around with a transparent bool wrapper, I
> just want to be sure I'm not being a muppet :-D
>
> TIA -- rob
>
> --
> Rob Desbois
> http://theotherbranch.wordpress.com/
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net