1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // UNSUPPORTED: libcpp-has-no-threads, c++98, c++03
10 
11 // <future>
12 
13 // class future<R>
14 
15 // future(future&& rhs);
16 
17 #include <future>
18 #include <cassert>
19 
20 int main(int, char**)
21 {
22     {
23         typedef int T;
24         std::promise<T> p;
25         std::future<T> f0 = p.get_future();
26         std::future<T> f = std::move(f0);
27         assert(!f0.valid());
28         assert(f.valid());
29     }
30     {
31         typedef int T;
32         std::future<T> f0;
33         std::future<T> f = std::move(f0);
34         assert(!f0.valid());
35         assert(!f.valid());
36     }
37     {
38         typedef int& T;
39         std::promise<T> p;
40         std::future<T> f0 = p.get_future();
41         std::future<T> f = std::move(f0);
42         assert(!f0.valid());
43         assert(f.valid());
44     }
45     {
46         typedef int& T;
47         std::future<T> f0;
48         std::future<T> f = std::move(f0);
49         assert(!f0.valid());
50         assert(!f.valid());
51     }
52     {
53         typedef void T;
54         std::promise<T> p;
55         std::future<T> f0 = p.get_future();
56         std::future<T> f = std::move(f0);
57         assert(!f0.valid());
58         assert(f.valid());
59     }
60     {
61         typedef void T;
62         std::future<T> f0;
63         std::future<T> f = std::move(f0);
64         assert(!f0.valid());
65         assert(!f.valid());
66     }
67 
68   return 0;
69 }
70