• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // UNSUPPORTED: libcpp-has-no-threads
11 // UNSUPPORTED: c++98, c++03
12 
13 // <future>
14 
15 // class shared_future<R>
16 
17 // shared_future& operator=(const shared_future& rhs);
18 // noexcept in C++17
19 
20 #include <future>
21 #include <cassert>
22 
23 #include "test_macros.h"
24 
main()25 int main()
26 {
27     {
28         typedef int T;
29         std::promise<T> p;
30         std::shared_future<T> f0 = p.get_future();
31         std::shared_future<T> f;
32         f = f0;
33 #if TEST_STD_VER > 14
34         static_assert(noexcept(f = f0), "" );
35 #endif
36         assert(f0.valid());
37         assert(f.valid());
38     }
39     {
40         typedef int T;
41         std::shared_future<T> f0;
42         std::shared_future<T> f;
43         f = f0;
44         assert(!f0.valid());
45         assert(!f.valid());
46     }
47     {
48         typedef int& T;
49         std::promise<T> p;
50         std::shared_future<T> f0 = p.get_future();
51         std::shared_future<T> f;
52         f = f0;
53         assert(f0.valid());
54         assert(f.valid());
55     }
56     {
57         typedef int& T;
58         std::shared_future<T> f0;
59         std::shared_future<T> f;
60         f = f0;
61         assert(!f0.valid());
62         assert(!f.valid());
63     }
64     {
65         typedef void T;
66         std::promise<T> p;
67         std::shared_future<T> f0 = p.get_future();
68         std::shared_future<T> f;
69         f = f0;
70         assert(f0.valid());
71         assert(f.valid());
72     }
73     {
74         typedef void T;
75         std::shared_future<T> f0;
76         std::shared_future<T> f;
77         f = f0;
78         assert(!f0.valid());
79         assert(!f.valid());
80     }
81 }
82