From f2541bb90af059680aa7036f315f052175999355 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 8 Apr 2015 03:09:47 +0000 Subject: Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2. --- libs/thread/test/test_10964.cpp | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 libs/thread/test/test_10964.cpp (limited to 'libs/thread/test/test_10964.cpp') diff --git a/libs/thread/test/test_10964.cpp b/libs/thread/test/test_10964.cpp new file mode 100644 index 000000000..b8cc7b5c0 --- /dev/null +++ b/libs/thread/test/test_10964.cpp @@ -0,0 +1,76 @@ +// Copyright (C) 2015 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 + +#include +#include + +struct TestCallback +{ + typedef boost::future result_type; + + result_type operator()(boost::future future) const + { + future.get(); + return boost::make_ready_future(); + } + + result_type operator()(boost::future > future) const + { + future.get(); + return boost::make_ready_future(); + } +}; + +void p1() +{ +} + +int main() +{ +#if ! defined BOOST_NO_CXX11_DECLTYPE && ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS + std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; + { + auto f1 = boost::make_ready_future().then(TestCallback()); + BOOST_STATIC_ASSERT(std::is_same > >::value); + f1.wait(); + } + std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; + { + auto f1 = boost::make_ready_future().then(TestCallback()); + BOOST_STATIC_ASSERT(std::is_same > >::value); + auto f2 = f1.unwrap(); + BOOST_STATIC_ASSERT(std::is_same >::value); + f2.wait(); + } + std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; + { + auto f1 = boost::make_ready_future().then(TestCallback()); + BOOST_STATIC_ASSERT(std::is_same > >::value); + auto f2 = f1.unwrap(); + BOOST_STATIC_ASSERT(std::is_same >::value); + auto f3 = f2.then(TestCallback()); + BOOST_STATIC_ASSERT(std::is_same > >::value); + f3.wait(); + } + std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; + { + boost::make_ready_future().then( + TestCallback()).unwrap().then(TestCallback()).get(); + } + std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; + { + boost::future f = boost::async(p1); + f.then( + TestCallback()).unwrap().then(TestCallback()).get(); + } +#endif + return 0; +} -- cgit v1.2.1