Boost logo

Boost Users :

Subject: [Boost-users] [Coroutine 1.54] Compile error with bool return from coroutine-function
From: Rob Desbois (rob.desbois_at_[hidden])
Date: 2014-04-24 12:56:46

(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)

   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
   In file included from
                    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>’:
  required from ‘void
boost::coroutines::detail::coroutine_base_resume<Signature, D, void,
D, void, 1>::arg_type) [with Signature = void(bool); D =
boost::coroutines::detail::coroutine_base_resume<Signature, D, void,
1>::arg_type = bool]’
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:
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
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

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at