Skip to content

Commit cbd7708

Browse files
committed
specialize std::bad_expected_access for rfl::Error
1 parent c732e45 commit cbd7708

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

include/rfl/Result.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,16 @@ inline Unexpected<Error> error(const Error& _err) {
445445

446446
} // namespace rfl
447447

448+
#ifdef REFLECTCPP_USE_STD_EXPECTED
449+
template <>
450+
class std::bad_expected_access<rfl::Error> : public bad_expected_access<void> {
451+
public:
452+
explicit constexpr bad_expected_access(rfl::Error er) : err_(std::move(er)) {}
453+
const char* what() const noexcept override { return err_.what().c_str(); }
454+
455+
private:
456+
rfl::Error err_;
457+
};
448458
#endif
459+
460+
#endif

0 commit comments

Comments
 (0)