GCC Code Coverage Report


Directory: ./
File: libs/capy/include/boost/capy/error.hpp
Date: 2026-01-17 11:19:32
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 enum class error
26 {
27 eof = 1,
28 test_failure
29 };
30
31 //-----------------------------------------------
32
33 } // capy
34
35 namespace system {
36 template<>
37 struct is_error_code_enum<
38 ::boost::capy::error>
39 {
40 static bool const value = true;
41 };
42 } // system
43
44 namespace capy {
45
46 //-----------------------------------------------
47
48 namespace detail {
49
50 struct BOOST_SYMBOL_VISIBLE
51 error_cat_type
52 : system::error_category
53 {
54 BOOST_CAPY_DECL const char* name(
55 ) const noexcept override;
56 BOOST_CAPY_DECL std::string message(
57 int) const override;
58 BOOST_CAPY_DECL char const* message(
59 int, char*, std::size_t
60 ) const noexcept override;
61 BOOST_SYSTEM_CONSTEXPR error_cat_type()
62 : error_category(0x884562ca8e2fc5fd)
63 {
64 }
65 };
66
67 BOOST_CAPY_DECL extern error_cat_type error_cat;
68
69 } // detail
70
71 //-----------------------------------------------
72
73 inline
74 BOOST_SYSTEM_CONSTEXPR
75 system::error_code
76 90 make_error_code(
77 error ev) noexcept
78 {
79 return system::error_code{
80 static_cast<std::underlying_type<
81 error>::type>(ev),
82 90 detail::error_cat};
83 }
84
85 } // capy
86 } // boost
87
88 #endif
89