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& operator=(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;
27         f = std::move(f0);
28         assert(!f0.valid());
29         assert(f.valid());
30     }
31     {
32         typedef int T;
33         std::future<T> f0;
34         std::future<T> f;
35         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::future<T> f;
44         f = std::move(f0);
45         assert(!f0.valid());
46         assert(f.valid());
47     }
48     {
49         typedef int& T;
50         std::future<T> f0;
51         std::future<T> f;
52         f = std::move(f0);
53         assert(!f0.valid());
54         assert(!f.valid());
55     }
56     {
57         typedef void T;
58         std::promise<T> p;
59         std::future<T> f0 = p.get_future();
60         std::future<T> f;
61         f = std::move(f0);
62         assert(!f0.valid());
63         assert(f.valid());
64     }
65     {
66         typedef void T;
67         std::future<T> f0;
68         std::future<T> f;
69         f = std::move(f0);
70         assert(!f0.valid());
71         assert(!f.valid());
72     }
73 
74   return 0;
75 }
76