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
10 // UNSUPPORTED: c++98, c++03
11 
12 // <future>
13 
14 // class packaged_task<R(ArgTypes...)>
15 
16 // packaged_task(packaged_task&& other);
17 
18 #include <future>
19 #include <cassert>
20 
21 class A
22 {
23     long data_;
24 
25 public:
26     explicit A(long i) : data_(i) {}
27 
28     long operator()(long i, long j) const {return data_ + i + j;}
29 };
30 
31 int main(int, char**)
32 {
33     {
34         std::packaged_task<double(int, char)> p0(A(5));
35         std::packaged_task<double(int, char)> p = std::move(p0);
36         assert(!p0.valid());
37         assert(p.valid());
38         std::future<double> f = p.get_future();
39         p(3, 'a');
40         assert(f.get() == 105.0);
41     }
42     {
43         std::packaged_task<double(int, char)> p0;
44         std::packaged_task<double(int, char)> p = std::move(p0);
45         assert(!p0.valid());
46         assert(!p.valid());
47     }
48 
49   return 0;
50 }
51