Result: Add try_{set,move}_value_or_error
This commit is contained in:
parent
c752b2b343
commit
baa2296aed
@ -110,11 +110,25 @@ template <typename T> 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");
|
||||
|
Loading…
Reference in New Issue
Block a user