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 // <system_error>
10 
11 // class error_code
12 
13 // template <ErrorCodeEnum E> error_code(E e);
14 
15 #include <system_error>
16 #include <cassert>
17 
18 enum testing
19 {
20     zero, one, two
21 };
22 
23 namespace std
24 {
25 
26 template <> struct is_error_code_enum<testing> : public std::true_type {};
27 
28 }
29 
30 std::error_code
31 make_error_code(testing x)
32 {
33     return std::error_code(static_cast<int>(x), std::generic_category());
34 }
35 
36 int main(int, char**)
37 {
38     {
39         std::error_code ec(two);
40         assert(ec.value() == 2);
41         assert(ec.category() == std::generic_category());
42     }
43 
44   return 0;
45 }
46