[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / futures / futures.promise / set_rvalue.pass.cpp
blobf5a6ab937d611155c3a13e7ab62c33f33967f3fa
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
10 // UNSUPPORTED: no-threads, no-exceptions
12 // <future>
14 // class promise<R>
16 // void promise::set_value(R&& r);
18 #include <future>
19 #include <memory>
20 #include <cassert>
22 #include "test_macros.h"
24 struct A
26 A() {}
27 A(const A&) = delete;
28 A(A&&) {throw 9;}
31 int main(int, char**)
34 typedef std::unique_ptr<int> T;
35 T i(new int(3));
36 std::promise<T> p;
37 std::future<T> f = p.get_future();
38 p.set_value(std::move(i));
39 assert(*f.get() == 3);
40 try
42 p.set_value(std::move(i));
43 assert(false);
45 catch (const std::future_error& e)
47 assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
51 typedef A T;
52 T i;
53 std::promise<T> p;
54 std::future<T> f = p.get_future();
55 try
57 p.set_value(std::move(i));
58 assert(false);
60 catch (int j)
62 assert(j == 9);
66 return 0;