GCC Code Coverage Report


Directory: ./
File: libs/capy/include/boost/capy/error.hpp
Date: 2026-01-18 18:26:31
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/cppalliance/capy
8 //
9
10 #ifndef BOOST_CAPY_ERROR_HPP
11 #define BOOST_CAPY_ERROR_HPP
12
13 #include <boost/capy/detail/config.hpp>
14 #include <boost/system/error_category.hpp>
15 #include <boost/system/is_error_code_enum.hpp>
16
17 namespace boost {
18 namespace capy {
19
20 /** Error codes returned from algorithms and operations.
21
22 Return `error::eof` when originating an eof error.
23 Check `ec == cond::eof` for portable comparison.
24
25 Return `error::canceled` when originating a cancellation error.
26 Check `ec == cond::canceled` for portable comparison.
27 */
28 enum class error
29 {
30 eof = 1,
31 canceled,
32 test_failure
33 };
34
35 //-----------------------------------------------
36
37 } // capy
38
39 namespace system {
40 template<>
41 struct is_error_code_enum<
42 ::boost::capy::error>
43 {
44 static bool const value = true;
45 };
46 } // system
47
48 namespace capy {
49
50 //-----------------------------------------------
51
52 namespace detail {
53
54 struct BOOST_SYMBOL_VISIBLE
55 error_cat_type
56 : system::error_category
57 {
58 BOOST_CAPY_DECL const char* name(
59 ) const noexcept override;
60 BOOST_CAPY_DECL std::string message(
61 int) const override;
62 BOOST_CAPY_DECL char const* message(
63 int, char*, std::size_t
64 ) const noexcept override;
65 BOOST_SYSTEM_CONSTEXPR error_cat_type()
66 : error_category(0x884562ca8e2fc5fd)
67 {
68 }
69 };
70
71 BOOST_CAPY_DECL extern error_cat_type error_cat;
72
73 } // detail
74
75 //-----------------------------------------------
76
77 inline
78 BOOST_SYSTEM_CONSTEXPR
79 system::error_code
80 94 make_error_code(
81 error ev) noexcept
82 {
83 return system::error_code{
84 static_cast<std::underlying_type<
85 error>::type>(ev),
86 94 detail::error_cat};
87 }
88
89 } // capy
90 } // boost
91
92 #endif
93