From 905bcc0f580136554d2fad3c852b704c7fb304fe Mon Sep 17 00:00:00 2001 From: BestITUserEUW Date: Sun, 28 Sep 2025 18:45:01 +0200 Subject: [PATCH] added explicit ref-qualifiers for Error::what() and a additional overload to allow moving Error::what_ to caller if Error is an rvalue --- include/rfl/Result.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/rfl/Result.hpp b/include/rfl/Result.hpp index a7422203..cf67dbf2 100644 --- a/include/rfl/Result.hpp +++ b/include/rfl/Result.hpp @@ -30,7 +30,9 @@ class Error { Error& operator=(Error&&) = default; /// Returns the error message, equivalent to .what() in std::exception. - const std::string& what() const { return what_; } + const std::string& what() const & { return what_; } + /// Moves the error message out of Error object and leaves what_ in a moved from state + std::string what() && { return std::move(what_); } private: /// Documents what went wrong