]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_9711.cpp
d8fd8e3e812aa63551463a9bf3a2b363be86584e
[ceph.git] / ceph / src / boost / libs / thread / test / test_9711.cpp
1 // Copyright (C) 2014 Vicente Botet
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #define BOOST_THREAD_PROVIDES_FUTURE
7 #define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
8 #include <boost/config.hpp>
9 #if ! defined BOOST_NO_CXX11_DECLTYPE
10 #define BOOST_RESULT_OF_USE_DECLTYPE
11 #endif
12
13 #include <boost/thread/future.hpp>
14
15
16 int main()
17 {
18 #if ! defined BOOST_NO_CXX11_LAMBDAS && ! (defined BOOST_MSVC && _MSC_VER < 1700)
19 boost::promise<int> prom;
20 boost::future<int> futr = prom.get_future();
21
22 int callCount = 0;
23
24 boost::future<void> futr2 = futr.then(boost::launch::deferred,
25 [&] (boost::future<int> f) {
26 callCount++;
27 assert(f.valid());
28 assert(f.is_ready());
29 assert(17 == f.get());
30 });
31
32 assert(futr2.valid());
33 assert(!futr2.is_ready());
34 assert(0 == callCount);
35
36 prom.set_value(17);
37 assert(0 == callCount);
38
39 futr2.get();
40 assert(1 == callCount);
41
42 #endif
43 return 0;
44 }