]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/thread/futures/futures.unique_future/move_assign.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / thread / futures / futures.unique_future / move_assign.pass.cpp
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, c++98, c++03
11
12 // <future>
13
14 // class future<R>
15
16 // future& operator=(future&& rhs);
17
18 #include <future>
19 #include <cassert>
20
21 int main()
22 {
23     {
24         typedef int T;
25         std::promise<T> p;
26         std::future<T> f0 = p.get_future();
27         std::future<T> f;
28         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;
36         f = std::move(f0);
37         assert(!f0.valid());
38         assert(!f.valid());
39     }
40     {
41         typedef int& T;
42         std::promise<T> p;
43         std::future<T> f0 = p.get_future();
44         std::future<T> f;
45         f = std::move(f0);
46         assert(!f0.valid());
47         assert(f.valid());
48     }
49     {
50         typedef int& T;
51         std::future<T> f0;
52         std::future<T> f;
53         f = std::move(f0);
54         assert(!f0.valid());
55         assert(!f.valid());
56     }
57     {
58         typedef void T;
59         std::promise<T> p;
60         std::future<T> f0 = p.get_future();
61         std::future<T> f;
62         f = std::move(f0);
63         assert(!f0.valid());
64         assert(f.valid());
65     }
66     {
67         typedef void T;
68         std::future<T> f0;
69         std::future<T> f;
70         f = std::move(f0);
71         assert(!f0.valid());
72         assert(!f.valid());
73     }
74 }