Option: Allow direct access to the underlying value via operator->
Crashes if the Option is empty.
This commit is contained in:
parent
30deed2820
commit
831973c39a
@ -109,6 +109,13 @@ template <typename T> class Option
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: This should also exist in Result.
|
||||||
|
T* operator->()
|
||||||
|
{
|
||||||
|
expect(has_value(), "Option::operator-> called on an empty Option");
|
||||||
|
return &m_storage.fetch_reference();
|
||||||
|
}
|
||||||
|
|
||||||
~Option()
|
~Option()
|
||||||
{
|
{
|
||||||
if (has_value()) m_storage.destroy();
|
if (has_value()) m_storage.destroy();
|
||||||
|
Loading…
Reference in New Issue
Block a user