mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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
Notes:
sideshowbarker
2024-07-19 03:16:40 +09:00
Author: https://github.com/petelliott Commit: https://github.com/SerenityOS/serenity/commit/c68537271ca Pull-request: https://github.com/SerenityOS/serenity/pull/3255 Reviewed-by: https://github.com/awesomekling
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…
Reference in a new issue