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& operator=(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;
37         p = std::move(p0);
38         assert(!p0.valid());
39         assert(p.valid());
40         std::future<double> f = p.get_future();
41         p(3, 'a');
42         assert(f.get() == 105.0);
43     }
44     {
45         std::packaged_task<double(int, char)> p0;
46         std::packaged_task<double(int, char)> p;
47         p = std::move(p0);
48         assert(!p0.valid());
49         assert(!p.valid());
50     }
51 }
52