// Copyright (C) 2014 Vicente Botet // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #define BOOST_THREAD_VERSION 4 #include #if ! defined BOOST_NO_CXX11_DECLTYPE #define BOOST_RESULT_OF_USE_DECLTYPE #endif #define BOOST_THREAD_PROVIDES_EXECUTORS #include #include #include #include struct TestCallback { typedef boost::future result_type; result_type operator()(boost::future future) const { assert(future.is_ready()); future.get(); return boost::make_ready_future(); } result_type operator()(boost::future > future) const { assert(future.is_ready()); future.get(); return boost::make_ready_future(); } }; int main() { #if ! defined BOOST_NO_CXX11_DECLTYPE && ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS { boost::promise test_promise; boost::future test_future(test_promise.get_future()); auto f1 = test_future.then(TestCallback()); BOOST_STATIC_ASSERT(std::is_same > >::value); auto f2 = f1.then(TestCallback()); BOOST_STATIC_ASSERT(std::is_same > >::value); } { boost::basic_thread_pool executor; boost::promise test_promise; boost::future test_future(test_promise.get_future()); auto f1 = test_future.then(executor, TestCallback()); BOOST_STATIC_ASSERT(std::is_same > >::value); auto f2 = f1.then(executor, TestCallback()); BOOST_STATIC_ASSERT(std::is_same > >::value); } #endif return 0; }