mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +00:00
AK: Add operator== to AK::Optional
The semantics: - two Optionals are equal if they are both None - two Optionals are equal if they are both Some, and their values are operator==
This commit is contained in:
parent
b0ffd4e946
commit
c68537271c
1 changed files with 6 additions and 0 deletions
|
@ -97,6 +97,12 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename O>
|
||||||
|
bool operator==(const Optional<O>& other) const
|
||||||
|
{
|
||||||
|
return has_value() == other.has_value() && (!has_value() || value() == other.value());
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE ~Optional()
|
ALWAYS_INLINE ~Optional()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue