Result: Add try_set_value()
This helper returns true if the Result contains a value, or false if it doesn't. Additionally, if it has a value, it sets the passed reference to it.
This commit is contained in:
parent
883a1da0d7
commit
db3e34b2ba
@ -104,6 +104,13 @@ template <typename T> class Result
|
||||
return other;
|
||||
}
|
||||
|
||||
bool try_set_value(T& ref)
|
||||
{
|
||||
if (!has_value()) return false;
|
||||
ref = m_storage.fetch_reference();
|
||||
return true;
|
||||
}
|
||||
|
||||
T release_value()
|
||||
{
|
||||
check(has_value());
|
||||
|
Loading…
Reference in New Issue
Block a user