1eb5cfb02SEric Fiselier //===----------------------------------------------------------------------===//
2eb5cfb02SEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6eb5cfb02SEric Fiselier //
7eb5cfb02SEric Fiselier //===----------------------------------------------------------------------===//
8eb5cfb02SEric Fiselier //
9*a7f9895cSLouis Dionne // UNSUPPORTED: no-threads
1031cbe0f2SLouis Dionne // UNSUPPORTED: c++03
11eb5cfb02SEric Fiselier 
12eb5cfb02SEric Fiselier // <future>
13eb5cfb02SEric Fiselier 
14eb5cfb02SEric Fiselier // class packaged_task<R(ArgTypes...)>
15eb5cfb02SEric Fiselier 
16eb5cfb02SEric Fiselier // packaged_task(packaged_task&& other);
17eb5cfb02SEric Fiselier 
18eb5cfb02SEric Fiselier #include <future>
19eb5cfb02SEric Fiselier #include <cassert>
20eb5cfb02SEric Fiselier 
217fc6a556SMarshall Clow #include "test_macros.h"
227fc6a556SMarshall Clow 
23eb5cfb02SEric Fiselier class A
24eb5cfb02SEric Fiselier {
25eb5cfb02SEric Fiselier     long data_;
26eb5cfb02SEric Fiselier 
27eb5cfb02SEric Fiselier public:
A(long i)28eb5cfb02SEric Fiselier     explicit A(long i) : data_(i) {}
29eb5cfb02SEric Fiselier 
operator ()(long i,long j) const30eb5cfb02SEric Fiselier     long operator()(long i, long j) const {return data_ + i + j;}
31eb5cfb02SEric Fiselier };
32eb5cfb02SEric Fiselier 
main(int,char **)332df59c50SJF Bastien int main(int, char**)
34eb5cfb02SEric Fiselier {
35eb5cfb02SEric Fiselier     {
36eb5cfb02SEric Fiselier         std::packaged_task<double(int, char)> p0(A(5));
37eb5cfb02SEric Fiselier         std::packaged_task<double(int, char)> p = std::move(p0);
38eb5cfb02SEric Fiselier         assert(!p0.valid());
39eb5cfb02SEric Fiselier         assert(p.valid());
40eb5cfb02SEric Fiselier         std::future<double> f = p.get_future();
413f05377dSMuiez Ahmed         p(3, 97);
42eb5cfb02SEric Fiselier         assert(f.get() == 105.0);
43eb5cfb02SEric Fiselier     }
44eb5cfb02SEric Fiselier     {
45eb5cfb02SEric Fiselier         std::packaged_task<double(int, char)> p0;
46eb5cfb02SEric Fiselier         std::packaged_task<double(int, char)> p = std::move(p0);
47eb5cfb02SEric Fiselier         assert(!p0.valid());
48eb5cfb02SEric Fiselier         assert(!p.valid());
49eb5cfb02SEric Fiselier     }
502df59c50SJF Bastien 
512df59c50SJF Bastien   return 0;
52eb5cfb02SEric Fiselier }
53