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