xref: /llvm-project/libcxx/test/std/thread/futures/futures.future_error/ctor.pass.cpp (revision d2cb198f25c82bf77bb113763771590cc79a21a4)
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, c++11, c++14
11 
12 // <future>
13 
14 // class future_error
15 //
16 // explicit future_error(future_errc e); // since C++17
17 
18 #include <cassert>
19 #include <future>
20 #include <type_traits>
21 
main(int,char **)22 int main(int, char**) {
23   {
24     std::future_error f(std::future_errc::broken_promise);
25     assert(f.code() == std::make_error_code(std::future_errc::broken_promise));
26   }
27   {
28     std::future_error f(std::future_errc::future_already_retrieved);
29     assert(f.code() == std::make_error_code(std::future_errc::future_already_retrieved));
30   }
31   {
32     std::future_error f(std::future_errc::promise_already_satisfied);
33     assert(f.code() == std::make_error_code(std::future_errc::promise_already_satisfied));
34   }
35   {
36     std::future_error f(std::future_errc::no_state);
37     assert(f.code() == std::make_error_code(std::future_errc::no_state));
38   }
39 
40   // Make sure the constructor is explicit
41   static_assert(!std::is_convertible_v<std::future_errc, std::future_error>);
42 
43   return 0;
44 }
45