@@ -29,7 +29,7 @@ namespace mrdox {
29
29
/* * Holds the description of an error, or success.
30
30
*/
31
31
class [[nodiscard]] MRDOX_DECL
32
- Error final : public std:: exception
32
+ Error final
33
33
{
34
34
std::string message_;
35
35
std::string reason_;
@@ -47,19 +47,19 @@ class [[nodiscard]] MRDOX_DECL
47
47
A default constructed error is
48
48
equivalent to success.
49
49
*/
50
- Error () = default ;
50
+ Error () noexcept = default ;
51
51
52
52
/* * Constructor.
53
53
*/
54
- Error (Error&&) = default ;
54
+ Error (Error&&) noexcept = default ;
55
55
56
56
/* * Constructor.
57
57
*/
58
58
Error (Error const &) = default ;
59
59
60
60
/* * Constructor.
61
61
*/
62
- Error& operator =(Error&&) = default ;
62
+ Error& operator =(Error&&) noexcept = default ;
63
63
64
64
/* * Assignment.
65
65
*/
@@ -110,64 +110,79 @@ class [[nodiscard]] MRDOX_DECL
110
110
111
111
/* * Return true if this holds an error.
112
112
*/
113
- bool failed () const noexcept
113
+ constexpr bool
114
+ failed () const noexcept
114
115
{
115
116
return ! message_.empty ();
116
117
}
117
118
118
119
/* * Return true if this holds an error.
119
120
*/
120
- explicit
121
+ constexpr explicit
121
122
operator bool () const noexcept
122
123
{
123
124
return failed ();
124
125
}
125
126
126
127
/* * Return the error string.
127
128
*/
128
- std::string_view
129
+ constexpr std::string_view
129
130
message () const noexcept
130
131
{
131
132
return message_;
132
133
}
133
134
134
135
/* * Return the reason string.
135
136
*/
136
- std::string_view
137
+ constexpr std::string_view
137
138
reason () const noexcept
138
139
{
139
140
return reason_;
140
141
}
141
142
142
143
/* * Return the source location.
143
144
*/
144
- std::source_location
145
+ constexpr std::source_location
145
146
location () const noexcept
146
147
{
147
148
return loc_;
148
149
}
149
150
150
- /* * Return true if this equals other .
151
+ /* * Return true if this equals rhs .
151
152
*/
152
- bool
153
- operator ==(Error const & other ) const noexcept
153
+ constexpr bool
154
+ operator ==(Error const & rhs ) const noexcept
154
155
{
155
- return message_ == other .message_ ;
156
+ return message_ == rhs .message_ ;
156
157
}
157
158
159
+ #if 0
158
160
/** Return a null-terminated error string.
159
161
*/
160
162
char const*
161
163
what() const noexcept override
162
164
{
163
165
return reason_.c_str();
164
166
}
167
+ #endif
168
+
169
+ constexpr void swap (Error& rhs) noexcept
170
+ {
171
+ using std::swap;
172
+ swap (message_, rhs.message_ );
173
+ swap (reason_, rhs.reason_ );
174
+ swap (loc_, rhs.loc_ );
175
+ }
176
+
177
+ friend constexpr void swap (
178
+ Error& lhs, Error& rhs) noexcept
179
+ {
180
+ lhs.swap (rhs);
181
+ }
165
182
166
183
/* * Return a value indicating success.
167
184
*/
168
- static
169
- Error
170
- success () noexcept ;
185
+ static Error success () noexcept ;
171
186
};
172
187
173
188
inline
0 commit comments