diff --git a/libluna/include/luna/Result.h b/libluna/include/luna/Result.h index 9f833b8e..39fda591 100644 --- a/libluna/include/luna/Result.h +++ b/libluna/include/luna/Result.h @@ -110,11 +110,25 @@ template class Result return m_value.try_set_value(ref); } + bool try_set_value_or_error(T& ref, int& err) const + { + bool ok = m_value.try_set_value(ref); + if (!ok) err = m_error; + return ok; + } + bool try_move_value(T& ref) { return m_value.try_move_value(ref); } + bool try_move_value_or_error(T& ref, int& err) const + { + bool ok = m_value.try_move_value(ref); + if (!ok) err = m_error; + return ok; + } + T release_value(SourceLocation caller = SourceLocation::current()) { expect_at(has_value(), caller, "Result::release_value() called on a Result that holds an error");