[Boost.Thread] Compile error: boost::promise<T>::set_value(const T&) doesn't exist
Hi all,
I'm having problems compiling with Boost.Thread's futures I can't seem
to pass anything but a primitive type into make_ready_future. I've had
problems with other parts of Thread (packaged_task, promise,
unique/shared_future) that have produced horrendously unhelpful
compile errors.
Here is a minimal testcase:
#include
On 7 Aug 2014 at 11:28, Rob Desbois wrote:
I'm having problems compiling with Boost.Thread's futures I can't seem to pass anything but a primitive type into make_ready_future. I've had problems with other parts of Thread (packaged_task, promise, unique/shared_future) that have produced horrendously unhelpful compile errors.
Here is a minimal testcase: #include
struct foo { foo(int i_): i(i_) {} int i; };
int main() { // A const future ref isn't much use, but I needed to prove // the problem wasn't me trying to copy a unique_future const boost::unique_future<foo>& fut = boost::make_ready_future( foo(42) ); }
With `BOOST_THREAD_USES_MOVE` defined before including the Boost.Future header I get the following error with gcc 4.8.2 and Boost 1.55 (full output at http://pastebin.com/0sePWBWr):
../../deps/boost/include/boost/thread/future.hpp:3634:5: error: no matching function for call to `boost::promise<foo>::set_value(const foo&)´ p.set_value(boost::forward
(value)); ^ There seems to be no overload of promise::set_value() that takes a const lvalue reference. Looking at `promise` and `future_traits` in `future.hpp` it seems that the const lvalue ref overload will only exist when `BOOST_NO_CXX11_RVALUE_REFERENCES` is undefined. That makes no sense to me however...surely the const lvalue ref overload is needed precisely when there are no rvalue references? (Note this happens even if I pass a mutable lvalue ref to `make_ready_future()`).
If I don't define `BOOST_THREAD_USES_MOVE` it fails compilation with the following error (full output at http://pastebin.com/jBwiJLeC):
../../deps/boost/include/boost/thread/detail/move.hpp:183:54: error: no matching function for call to boost::unique_future<foo>::unique_future(boost::unique_future<foo>)´ #define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE.move() ^
Have I missed something? I'm unable to switch to C++11 mode unfortunately, but this seems such a big problem I can only assume I've done something wrong. I still get similar compile errors trying with Clang 3.4, and also with Boost 1.54 (g++ or Clang).
I confirm that futures have become broken under C++03 in 1.56. Please file a bug report. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
participants (2)
-
Niall Douglas
-
Rob Desbois