Bug 1791961 - accessible: Fix C++20 -Wambiguous-reversed-operator warnings. r=Jamie

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.

accessible/base/TextAttrs.h:139:54 [-Wambiguous-reversed-operator] ISO C++20 considers use of overloaded operator '!=' (with operand types 'mozilla::a11y::TextAttrsMgr::TextDecorValue' and 'mozilla::a11y::TextAttrsMgr::TextDecorValue') to be ambiguous despite there being a unique best viable function with non-reversed arguments
...

Differential Revision: https://phabricator.services.mozilla.com/D179019
This commit is contained in:
Chris Peterson 2023-05-26 04:51:43 +00:00
Родитель 6234013ded
Коммит 386cfe958f
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -378,11 +378,13 @@ class TextAttrsMgr {
return bool(mLine & mozilla::StyleTextDecorationLine::LINE_THROUGH);
}
bool operator==(const TextDecorValue& aValue) {
bool operator==(const TextDecorValue& aValue) const {
return mColor == aValue.mColor && mLine == aValue.mLine &&
mStyle == aValue.mStyle;
}
bool operator!=(const TextDecorValue& aValue) { return !(*this == aValue); }
bool operator!=(const TextDecorValue& aValue) const {
return !(*this == aValue);
}
private:
nscolor mColor;