Result: Add try_set_value_with_specific_error()

This commit is contained in:
apio 2022-12-18 16:30:09 +01:00
parent b01878cd3c
commit 730d0682ee
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -90,6 +90,13 @@ template <typename T> class Result
return m_value.try_set_value(ref);
}
Result<bool> try_set_value_with_specific_error(T& ref, int error)
{
if (has_error() && m_error != error) return release_error();
return m_value.try_set_value(ref);
}
T release_value()
{
expect(has_value(), "Result::release_value() called on a Result that holds an error");