[mlir][PDLL] Allow (and ignore) `-D` tablegen macros. (#124166)
[llvm-project.git] / libcxx / test / std / thread / futures / futures.future_error / code.pass.cpp
blob22d74bba803d9b8fc4ce493122d05cd874a6234a
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
11 // <future>
13 // class future_error
15 // const error_code& code() const noexcept;
17 #include <cassert>
18 #include <future>
19 #include <utility>
21 #include "test_macros.h"
23 int main(int, char**) {
24 ASSERT_NOEXCEPT(std::declval<std::future_error const&>().code());
25 ASSERT_SAME_TYPE(decltype(std::declval<std::future_error const&>().code()), std::error_code const&);
27 // Before C++17, we can't construct std::future_error directly in a standards-conforming way
28 #if TEST_STD_VER >= 17
30 std::future_error const f(std::future_errc::broken_promise);
31 std::error_code const& code = f.code();
32 assert(code == std::make_error_code(std::future_errc::broken_promise));
35 std::future_error const f(std::future_errc::future_already_retrieved);
36 std::error_code const& code = f.code();
37 assert(code == std::make_error_code(std::future_errc::future_already_retrieved));
40 std::future_error const f(std::future_errc::promise_already_satisfied);
41 std::error_code const& code = f.code();
42 assert(code == std::make_error_code(std::future_errc::promise_already_satisfied));
45 std::future_error const f(std::future_errc::no_state);
46 std::error_code const& code = f.code();
47 assert(code == std::make_error_code(std::future_errc::no_state));
49 #endif
51 return 0;