[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / futures / futures.task / futures.task.nonmembers / swap.pass.cpp
blob3ac2712d0412cd4f9c67d71e178efb22058775ef
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 R, class... ArgTypes>
17 // void
18 // swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y);
20 #include <future>
21 #include <cassert>
23 #include "test_macros.h"
25 class A
27 long data_;
29 public:
30 explicit A(long i) : data_(i) {}
32 long operator()(long i, long j) const {return data_ + i + j;}
35 int main(int, char**)
38 std::packaged_task<double(int, char)> p0(A(5));
39 std::packaged_task<double(int, char)> p;
40 swap(p, p0);
41 assert(!p0.valid());
42 assert(p.valid());
43 std::future<double> f = p.get_future();
44 p(3, 97);
45 assert(f.get() == 105.0);
48 std::packaged_task<double(int, char)> p0;
49 std::packaged_task<double(int, char)> p;
50 swap(p, p0);
51 assert(!p0.valid());
52 assert(!p.valid());
55 return 0;