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
10// UNSUPPORTED: c++03
11
12// <future>
13
14// class shared_future<R>
15
16// shared_future(shared_future&& rhs);
17
18#include <future>
19#include <cassert>
20
21#include "test_macros.h"
22
23int main(int, char**)
24{
25 {
26 typedef int T;
27 std::promise<T> p;
28 std::shared_future<T> f0 = p.get_future();
29 std::shared_future<T> f = std::move(f0);
30 assert(!f0.valid());
31 assert(f.valid());
32 }
33 {
34 typedef int T;
35 std::shared_future<T> f0;
36 std::shared_future<T> 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::shared_future<T> f0 = p.get_future();
44 std::shared_future<T> f = std::move(f0);
45 assert(!f0.valid());
46 assert(f.valid());
47 }
48 {
49 typedef int& T;
50 std::shared_future<T> f0;
51 std::shared_future<T> f = std::move(f0);
52 assert(!f0.valid());
53 assert(!f.valid());
54 }
55 {
56 typedef void T;
57 std::promise<T> p;
58 std::shared_future<T> f0 = p.get_future();
59 std::shared_future<T> f = std::move(f0);
60 assert(!f0.valid());
61 assert(f.valid());
62 }
63 {
64 typedef void T;
65 std::shared_future<T> f0;
66 std::shared_future<T> f = std::move(f0);
67 assert(!f0.valid());
68 assert(!f.valid());
69 }
70
71 return 0;
72}
73

source code of libcxx/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp