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