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: no-threads, c++03 |
10 | |
11 | // <future> |
12 | |
13 | // class future<R> |
14 | |
15 | // future(future&& rhs); |
16 | |
17 | #include <future> |
18 | #include <cassert> |
19 | |
20 | #include "test_macros.h" |
21 | |
22 | int main(int, char**) |
23 | { |
24 | { |
25 | typedef int T; |
26 | std::promise<T> p; |
27 | std::future<T> f0 = p.get_future(); |
28 | std::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::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::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::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::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::future<T> f = std::move(f0); |
66 | assert(!f0.valid()); |
67 | assert(!f.valid()); |
68 | } |
69 | |
70 | return 0; |
71 | } |
72 | |