1 | // Copyright 2021 Peter Dimov. |
---|---|
2 | // Distributed under the Boost Software License, Version 1.0. |
3 | // http://www.boost.org/LICENSE_1_0.txt |
4 | |
5 | #include <boost/system/error_code.hpp> |
6 | #include <boost/core/lightweight_test.hpp> |
7 | #include <boost/config.hpp> |
8 | #include <cerrno> |
9 | #include <system_error> |
10 | |
11 | enum my_errc |
12 | { |
13 | my_enoent = ENOENT |
14 | }; |
15 | |
16 | #if defined(BOOST_GCC) && BOOST_GCC < 70000 |
17 | |
18 | // g++ 6 and earlier do not allow specializations outside the namespace |
19 | |
20 | namespace boost |
21 | { |
22 | namespace system |
23 | { |
24 | |
25 | template<> struct is_error_code_enum<my_errc>: std::true_type {}; |
26 | |
27 | } // namespace system |
28 | } // namespace boost |
29 | |
30 | namespace std |
31 | { |
32 | |
33 | template<> struct is_error_code_enum<my_errc>: std::true_type {}; |
34 | |
35 | } // namespace std |
36 | |
37 | #else |
38 | |
39 | template<> struct boost::system::is_error_code_enum<my_errc>: std::true_type {}; |
40 | template<> struct std::is_error_code_enum<my_errc>: std::true_type {}; |
41 | |
42 | #endif |
43 | |
44 | boost::system::error_code make_error_code( my_errc e ) |
45 | { |
46 | return boost::system::error_code( e, boost::system::generic_category() ); |
47 | } |
48 | |
49 | int main() |
50 | { |
51 | { |
52 | boost::system::error_code e1 = my_enoent; |
53 | |
54 | BOOST_TEST( e1 == my_enoent ); |
55 | BOOST_TEST_NOT( e1 != my_enoent ); |
56 | } |
57 | |
58 | { |
59 | std::error_code e1 = my_enoent; |
60 | |
61 | BOOST_TEST( e1 == my_enoent ); |
62 | BOOST_TEST_NOT( e1 != my_enoent ); |
63 | } |
64 | |
65 | return boost::report_errors(); |
66 | } |
67 |