mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-27 19:59:03 +00:00
AK: Add Optional::value_or(T).
This is like value() but with a fallback in case there's no value set.
This commit is contained in:
parent
442256b5f8
commit
adb7b1bc4c
Notes:
sideshowbarker
2024-07-19 13:04:55 +09:00
Author: https://github.com/awesomekling
Commit: adb7b1bc4c
1 changed files with 7 additions and 0 deletions
|
@ -96,6 +96,13 @@ public:
|
||||||
return released_value;
|
return released_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T value_or(const T& fallback) const
|
||||||
|
{
|
||||||
|
if (has_value())
|
||||||
|
return value();
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char m_storage[sizeof(T)] __attribute__((aligned(sizeof(T))));
|
char m_storage[sizeof(T)] __attribute__((aligned(sizeof(T))));
|
||||||
bool m_has_value { false };
|
bool m_has_value { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue