[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / futures / futures.task / futures.task.members / ctor_func.pass.cpp
blobb3581a751e39d62074c01ad999e78cd5db19b725
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: no-threads
10 // UNSUPPORTED: c++03
12 // <future>
14 // class packaged_task<R(ArgTypes...)>
16 // template <class F>
17 // explicit packaged_task(F&& f);
19 #include <future>
20 #include <cassert>
22 #include "test_macros.h"
24 class A
26 long data_;
28 public:
29 static int n_moves;
30 static int n_copies;
32 explicit A(long i) : data_(i) {}
33 A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;}
34 A(const A& a) : data_(a.data_) {++n_copies;}
36 long operator()(long i, long j) const {return data_ + i + j;}
39 int A::n_moves = 0;
40 int A::n_copies = 0;
42 int func(int i) { return i; }
44 int main(int, char**)
47 std::packaged_task<double(int, char)> p(A(5));
48 assert(p.valid());
49 std::future<double> f = p.get_future();
50 p(3, 97);
51 assert(f.get() == 105.0);
52 assert(A::n_copies == 0);
53 assert(A::n_moves > 0);
55 A::n_copies = 0;
56 A::n_copies = 0;
58 A a(5);
59 std::packaged_task<double(int, char)> p(a);
60 assert(p.valid());
61 std::future<double> f = p.get_future();
62 p(3, 97);
63 assert(f.get() == 105.0);
64 assert(A::n_copies > 0);
65 assert(A::n_moves > 0);
68 std::packaged_task<int(int)> p(&func);
69 assert(p.valid());
70 std::future<int> f = p.get_future();
71 p(4);
72 assert(f.get() == 4);
75 std::packaged_task<int(int)> p(func);
76 assert(p.valid());
77 std::future<int> f = p.get_future();
78 p(4);
79 assert(f.get() == 4);
82 return 0;