added explicit ref-qualifiers for Error::what() and a additional overload to allow moving Error::what_ to caller if Error is an rvalue (#505)

This commit is contained in:
Philemon Benner
2025-09-29 08:20:47 +03:00
committed by GitHub
parent 6f27b8a49a
commit 075488a673
+3 -1
View File
@@ -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