[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / futures / futures.promise / get_future.pass.cpp
blobe90e395a96b84996385400fb914e2b6dd3eb26f0
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 promise<R>
16 // future<R> get_future();
18 #include <future>
19 #include <cassert>
21 #include "test_macros.h"
23 int main(int, char**)
26 std::promise<double> p;
27 std::future<double> f = p.get_future();
28 p.set_value(105.5);
29 assert(f.get() == 105.5);
31 #ifndef TEST_HAS_NO_EXCEPTIONS
33 std::promise<double> p;
34 std::future<double> f = p.get_future();
35 try
37 f = p.get_future();
38 assert(false);
40 catch (const std::future_error& e)
42 assert(e.code() == make_error_code(std::future_errc::future_already_retrieved));
46 std::promise<double> p;
47 std::promise<double> p0 = std::move(p);
48 try
50 std::future<double> f = p.get_future();
51 assert(false);
53 catch (const std::future_error& e)
55 assert(e.code() == make_error_code(std::future_errc::no_state));
58 #endif
60 return 0;