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