@@ -17,14 +17,19 @@ namespace rfl {
1717// / Defines the error class to be returned when something went wrong
1818class 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 ;
2529
26- Error& operator =(const Error&) = default ;
27- Error& operator =(Error&&) = default ;
30+ Error& operator =(const Error& _other) = default ;
31+
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,22 @@ template <>
450455class 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>
456- [[nodiscard]]
457- auto error (this Self&& self) noexcept {
458- return std::forward<Self>(self).err_ ;
461+ [[nodiscard]] rfl::Error& error () & noexcept { return err_; }
462+
463+ [[nodiscard]] const rfl::Error& error () const & noexcept { return err_; }
464+
465+ [[nodiscard]] rfl::Error&& error() && noexcept { return std::move (err_); }
466+
467+ [[nodiscard]] const rfl::Error&& error() const && noexcept {
468+ return std::move (err_);
459469 }
460470
461471 private:
462472 rfl::Error err_;
463473};
464474#endif
465475
466- #endif
476+ #endif
0 commit comments