1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-threads
15 // const error_code& code() const noexcept;
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
));