• 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(future<R>&& rhs);
18 
19 #include <future>
20 #include <cassert>
21 
main()22 int main()
23 {
24     {
25         typedef int T;
26         std::promise<T> p;
27         std::future<T> f0 = p.get_future();
28         std::shared_future<T> f = std::move(f0);
29         assert(!f0.valid());
30         assert(f.valid());
31     }
32     {
33         typedef int T;
34         std::future<T> f0;
35         std::shared_future<T> f = std::move(f0);
36         assert(!f0.valid());
37         assert(!f.valid());
38     }
39     {
40         typedef int& T;
41         std::promise<T> p;
42         std::future<T> f0 = p.get_future();
43         std::shared_future<T> f = std::move(f0);
44         assert(!f0.valid());
45         assert(f.valid());
46     }
47     {
48         typedef int& T;
49         std::future<T> f0;
50         std::shared_future<T> f = std::move(f0);
51         assert(!f0.valid());
52         assert(!f.valid());
53     }
54     {
55         typedef void T;
56         std::promise<T> p;
57         std::future<T> f0 = p.get_future();
58         std::shared_future<T> f = std::move(f0);
59         assert(!f0.valid());
60         assert(f.valid());
61     }
62     {
63         typedef void T;
64         std::future<T> f0;
65         std::shared_future<T> f = std::move(f0);
66         assert(!f0.valid());
67         assert(!f.valid());
68     }
69 }
70