Using boost::future with “then” continuations

Boost.Thread comes in several versions of which you can choose via the BOOST_THREAD_VERSION macro. Currently, the default is 2.

Up to version 2 of Boost.Thread, the name boost::unique_future was used for this class template (compare to boost::shared_future). Probably because of the standardization of std::future, more recent versions can use the name boost::future. Starting with version 3, boost::future is the default name.

The selection which name is to be used is done via a preprocessor macro:

When BOOST_THREAD_VERSION==2 define BOOST_THREAD_PROVIDES_FUTURE if
you want to use boost::future. When BOOST_THREAD_VERSION>=3 define
BOOST_THREAD_DONT_PROVIDE_FUTURE if you want to use
boost::unique_future.

From boost docs: unique_future vs future


So you can either explicitly enable boost::future by using BOOST_THREAD_PROVIDES_FUTURE or switch to a more modern version of Boost.Thread by setting BOOST_THREAD_VERSION to 4, for example.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)