mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 00:19:27 +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
|
@ -97,6 +97,12 @@ public:
|
|||
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()
|
||||
{
|
||||
clear();
|
||||
|
|
Loading…
Reference in a new issue