Skip to content

Commit 2e2ec78

Browse files
Adapt the code so that C++-23 works with GCC 13
1 parent 633beb0 commit 2e2ec78

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

include/rfl/Result.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ namespace rfl {
1717
/// Defines the error class to be returned when something went wrong
1818
class Error {
1919
public:
20+
Error() = default;
21+
2022
Error(const std::string& _what) : what_(_what) {}
2123
Error(std::string&& _what) : what_(std::move(_what)) {}
2224

25+
~Error() = default;
26+
2327
Error(const Error& e) = default;
24-
Error(Error&& e) = default;
28+
Error(Error&& e) noexcept = default;
29+
30+
Error& operator=(const Error& _other) = default;
2531

26-
Error& operator=(const Error&) = default;
27-
Error& operator=(Error&&) = default;
32+
Error& operator=(Error&& _other) noexcept = default;
2833

2934
/// Returns the error message, equivalent to .what() in std::exception.
3035
const std::string& what() const& { return what_; }
@@ -450,17 +455,17 @@ template <>
450455
class std::bad_expected_access<rfl::Error> : public bad_expected_access<void> {
451456
public:
452457
explicit constexpr bad_expected_access(rfl::Error er) : err_(std::move(er)) {}
458+
453459
const char* what() const noexcept override { return err_.what().c_str(); }
454460

455-
template <typename Self>
456461
[[nodiscard]]
457-
auto error(this Self&& self) noexcept {
458-
return std::forward<Self>(self).err_;
462+
auto error() const noexcept {
463+
return err_;
459464
}
460465

461466
private:
462467
rfl::Error err_;
463468
};
464469
#endif
465470

466-
#endif
471+
#endif

include/rfl/parsing/Parser_unique_ptr.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct Parser<R, W, std::unique_ptr<T>, ProcessorsType> {
4040
}
4141
return Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::read(_r,
4242
_var)
43-
.transform([](T&& _t) { return std::make_unique<T>(std::move(_t)); });
43+
.transform([](T _t) { return std::make_unique<T>(std::move(_t)); });
4444
}
4545
}
4646

include/rfl/parsing/Parser_variant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class Parser<R, W, std::variant<AlternativeTypes...>, ProcessorsType> {
224224
if (res) {
225225
_result->emplace(std::move(*res));
226226
} else {
227-
_errors->emplace_back(std::move(res.error()));
227+
_errors->emplace_back(res.error());
228228
}
229229
}
230230
}

0 commit comments

Comments
 (0)