]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/thread/test/sync/futures/promise/dtor_pass.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / thread / test / sync / futures / promise / dtor_pass.cpp
CommitLineData
7c673cae
FG
1//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// Copyright (C) 2011 Vicente J. Botet Escriba
11//
12// Distributed under the Boost Software License, Version 1.0. (See accompanying
13// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
14
15// <boost/thread/future.hpp>
16
17// class promise<R>
18
19// ~promise();
20
21#define BOOST_THREAD_VERSION 3
22
23#include <boost/thread/future.hpp>
24#include <boost/detail/lightweight_test.hpp>
25
26int main()
27{
28 {
29 typedef int T;
30 boost::future<T> f;
31 {
32 boost::promise<T> p;
33 f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
34 p.set_value(3);
35 }
36 BOOST_TEST(f.get() == 3);
37 }
38 {
39 typedef int T;
40 boost::future<T> f;
41 {
42 boost::promise<T> p;
43 f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
44 }
45 try
46 {
47 //T i =
48 (void)f.get();
49 BOOST_TEST(false);
50 }
51 catch (const boost::future_error& e)
52 {
53 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::broken_promise));
54 }
55 }
56 {
57 typedef int& T;
58 int i = 4;
59 boost::future<T> f;
60 {
61 boost::promise<T> p;
62 f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
63 p.set_value(i);
64 }
65 BOOST_TEST(&f.get() == &i);
66 }
67 {
68 typedef int& T;
69 boost::future<T> f;
70 {
71 boost::promise<T> p;
72 f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
73 }
74 try
75 {
76 //T i =
77 (void)f.get();
78 BOOST_TEST(false);
79 }
80 catch (const boost::future_error& e)
81 {
82 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::broken_promise));
83 }
84 }
85 {
86 typedef void T;
87 boost::future<T> f;
88 {
89 boost::promise<T> p;
90 f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
91 p.set_value();
92 }
93 f.get();
94 BOOST_TEST(true);
95 }
96 {
97 typedef void T;
98 boost::future<T> f;
99 {
100 boost::promise<T> p;
101 f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
102 }
103 try
104 {
105 f.get();
106 BOOST_TEST(false);
107 }
108 catch (const boost::future_error& e)
109 {
110 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::broken_promise));
111 }
112 }
113
114 return boost::report_errors();
115}
116