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:
Peter Elliott 2020-08-22 15:57:34 -06:00 committed by Andreas Kling
parent b0ffd4e946
commit c68537271c
Notes: sideshowbarker 2024-07-19 03:16:40 +09:00

View file

@ -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();