mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1791961 - xpcom: Fix C++20 -Wambiguous-reversed-operator warnings. r=emilio
clang is warning that C++20 expects comparison operators to be commutative: `a == b` and `b == a` should resolve to the same comparison operator function. Warnings about the comparison of const and non-const objects can be fixed by making the comparison operator function const. xpcom/base/AvailableMemoryWatcherMac.cpp:404:14 [-Wambiguous-reversed-operator] ISO C++20 considers use of overloaded operator '==' (with operand types 'mozilla::MacMemoryPressureLevel' and 'mozilla::MacMemoryPressureLevel') to be ambiguous despite there being a unique best viable function xpcom/base/AvailableMemoryWatcherMac.cpp:568:24 [-Wambiguous-reversed-operator] ISO C++20 considers use of overloaded operator '==' (with operand types 'mozilla::MacMemoryPressureLevel' and 'mozilla::MacMemoryPressureLevel') to be ambiguous despite there being a unique best viable function Depends on D179024 Differential Revision: https://phabricator.services.mozilla.com/D179025
This commit is contained in:
parent
0d90734c1c
commit
c5f254d17c
@ -26,8 +26,8 @@ class MacMemoryPressureLevel {
|
||||
MacMemoryPressureLevel() : mValue(Value::eUnset) {}
|
||||
MOZ_IMPLICIT MacMemoryPressureLevel(Value aValue) : mValue(aValue) {}
|
||||
|
||||
bool operator==(const Value& aRhsValue) { return mValue == aRhsValue; }
|
||||
bool operator==(const MacMemoryPressureLevel& aRhs) {
|
||||
bool operator==(const Value& aRhsValue) const { return mValue == aRhsValue; }
|
||||
bool operator==(const MacMemoryPressureLevel& aRhs) const {
|
||||
return mValue == aRhs.mValue;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,9 @@ class PLDHashTable {
|
||||
|
||||
Slot& operator=(Slot&& aOther) = default;
|
||||
|
||||
bool operator==(const Slot& aOther) { return mEntry == aOther.mEntry; }
|
||||
bool operator==(const Slot& aOther) const {
|
||||
return mEntry == aOther.mEntry;
|
||||
}
|
||||
|
||||
PLDHashNumber KeyHash() const { return *HashPtr(); }
|
||||
void SetKeyHash(PLDHashNumber aHash) { *HashPtr() = aHash; }
|
||||
|
Loading…
Reference in New Issue
Block a user