Type boost :: future <> from boost :: async ()

I get unexpected results from boost::async()(Boost 1.56, Windows: VS2010 and VS2012).

#include <boost/thread/future.hpp>
...
auto func = [](){ return 123; };
auto boostFut = boost::async(func);
// boostFut = 42; // intentional error to reveal deduced type in compilation error

For some reason, boostFutoutput as boost::unique_future<void>instead boost::unique_future<int>.

What am I doing wrong?

Note: on VS2012, if I used std::async(func)instead boost::async(func), it works as expected, and the future type is displayed as int.

+4
source share
1 answer

boost::async . Boost boost::result_of<T>. async :

template <class F>
boost::future<typename boost::result_of<typename boost::decay<F>::type()>::type>
async(F f);

/ , boost::result_of<T> :

  • decltype() .
  • result_type typedef F result<T> F ( - , ).

(2), -, Boost , void .

, Boost decltype() ( -), Boost:

#define BOOST_RESULT_OF_USE_DECLTYPE

boost/config/user.hpp.

+4

All Articles