libluna: Add move versions of value_or
This commit is contained in:
parent
5d5c85a022
commit
00382421b2
@ -94,6 +94,12 @@ template <typename T> class Option
|
||||
return other;
|
||||
}
|
||||
|
||||
T value_or(T&& other) const
|
||||
{
|
||||
if (has_value()) return m_storage.fetch_reference();
|
||||
return move(other);
|
||||
}
|
||||
|
||||
bool try_set_value(T& ref) const
|
||||
{
|
||||
if (!has_value()) return false;
|
||||
|
@ -106,6 +106,11 @@ template <typename T> class Result
|
||||
return m_value.value_or(other);
|
||||
}
|
||||
|
||||
T value_or(T&& other) const
|
||||
{
|
||||
return m_value.value_or(move(other));
|
||||
}
|
||||
|
||||
bool try_set_value(T& ref) const
|
||||
{
|
||||
return m_value.try_set_value(ref);
|
||||
|
Loading…
Reference in New Issue
Block a user