• 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(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 = f0;
32 #if TEST_STD_VER > 14
33         static_assert(noexcept(std::shared_future<T>{f0}), "" );
34 #endif
35         assert(f0.valid());
36         assert(f.valid());
37     }
38     {
39         typedef int T;
40         std::shared_future<T> f0;
41         std::shared_future<T> f = f0;
42         assert(!f0.valid());
43         assert(!f.valid());
44     }
45     {
46         typedef int& T;
47         std::promise<T> p;
48         std::shared_future<T> f0 = p.get_future();
49         std::shared_future<T> f = f0;
50         assert(f0.valid());
51         assert(f.valid());
52     }
53     {
54         typedef int& T;
55         std::shared_future<T> f0;
56         std::shared_future<T> f = std::move(f0);
57         assert(!f0.valid());
58         assert(!f.valid());
59     }
60     {
61         typedef void T;
62         std::promise<T> p;
63         std::shared_future<T> f0 = p.get_future();
64         std::shared_future<T> f = f0;
65         assert(f0.valid());
66         assert(f.valid());
67     }
68     {
69         typedef void T;
70         std::shared_future<T> f0;
71         std::shared_future<T> f = f0;
72         assert(!f0.valid());
73         assert(!f.valid());
74     }
75 }
76