Compilation error: boost :: prom <T> :: set_value (const T &) does not exist

I'm having trouble with Boost.Thread futures: I can't represent anything but a primitive type in a promise, future, or packaged task.

Here's a minimal test file:

#include <boost/thread/future.hpp>

struct foo
{
    foo(int i_): i(i_) {}
    int i;
};

int main()
{
    // A const future 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 the BOOST_THREAD_USES_MOVE

Boost.Future header defined before including the Boost.Future header, I get the following error: gcc 4.8.2 and Boost 1.55 (full output here ):

../../deps/boost/include/boost/thread/future.hpp:3634:5: error: no matching function for call toboost::promise<foo>::set_value(const foo&)p.set_value(boost::forward<future_value_type>(value));
     ^

      

There seems to be no promise overloading :: set_value () that takes a const lvalue reference. Looking at promise

and future_traits

at future.hpp

, it seems that the const lvalue ref overload will only exist when BOOST_NO_CXX11_RVALUE_REFERENCES

there is undefined. It doesn't make any sense to me, however ... surely the const lvalue ref overload is needed exactly when there are no rvalue references? (Note that this happens even if I pass the lvalue ref to make_ready_future()

).

If I don't define it BOOST_THREAD_USES_MOVE

, it fails compilation with the following error (full output here ):

../../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()
                                                     ^

      

Did I miss something?

+3


source to share


1 answer


It looks like the boost-users mailing list, which is a bug in Boost and is also present in version 1.56, looks mostly in C ++ 03 mode.



Bug report: https://svn.boost.org/trac/boost/ticket/10340

+2


source







All Articles