J. Leeroy
J. Leeroy

Reputation: 440

boost::async returns only void?

c++ newbie here.

I've tried to initialize and set boost::unique_future variable value:

boost::unique_future<bool> result;
result = boost::async([this](){return false;});

But I've got next error on the second code string: Error: no operator "=" matches these operands, operand types are: boost::unique_future< bool> = boost::unique_future< void>.

And here user ikh successfully did this:

boost::unique_future<int> fu2 = boost::async([]{ return 43; });

But I've got the same error: Error: no operator "=" matches these operands, operand types are: boost::unique_future< int> = boost::unique_future< void>.

Where is my mistake?

Upvotes: 2

Views: 303

Answers (1)

ikh
ikh

Reputation: 10417

I think you haven't define BOOST_RESULT_OF_USE_DECLTYPE.

#define BOOST_RESULT_OF_USE_DECLTYPE
#include <boost/thread.hpp>

Upvotes: 1

Related Questions