summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-26 10:30:40 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-26 10:30:40 -0400
commit6ac59d1d5e200cccd3ddaa6d1c3b0d8d116a06be (patch)
treec07c22bdabbd6a2a979f581429448284cbd59a19 /indra
parent6400284278071b774d2837d62142a15b94120198 (diff)
Fix GCC ambiguous-reversed-operator errors for `LLKeyData` compares.
`LLKeyData::operator==(const LLKeyData&)` and `operator!=(const LLKeyData&)` were not themselves `const` methods. In C++20, that can produce a fatal warning that if the compare operands were reversed, you'd get different results. Making them both `const` should fix it. While touching the method definitions, make `operator==()` more intuitive, and make `operator!=()` simply negate `operator==()` instead of restating it in reverse.
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llkeybind.cpp20
-rw-r--r--indra/llcommon/llkeybind.h4
2 files changed, 10 insertions, 14 deletions
diff --git a/indra/llcommon/llkeybind.cpp b/indra/llcommon/llkeybind.cpp
index e36c1d0a4c..34254f3ef5 100644
--- a/indra/llcommon/llkeybind.cpp
+++ b/indra/llcommon/llkeybind.cpp
@@ -123,22 +123,18 @@ LLKeyData& LLKeyData::operator=(const LLKeyData& rhs)
return *this;
}
-bool LLKeyData::operator==(const LLKeyData& rhs)
+bool LLKeyData::operator==(const LLKeyData& rhs) const
{
- if (mMouse != rhs.mMouse) return false;
- if (mKey != rhs.mKey) return false;
- if (mMask != rhs.mMask) return false;
- if (mIgnoreMasks != rhs.mIgnoreMasks) return false;
- return true;
+ return
+ (mMouse == rhs.mMouse) &&
+ (mKey == rhs.mKey) &&
+ (mMask == rhs.mMask) &&
+ (mIgnoreMasks == rhs.mIgnoreMasks);
}
-bool LLKeyData::operator!=(const LLKeyData& rhs)
+bool LLKeyData::operator!=(const LLKeyData& rhs) const
{
- if (mMouse != rhs.mMouse) return true;
- if (mKey != rhs.mKey) return true;
- if (mMask != rhs.mMask) return true;
- if (mIgnoreMasks != rhs.mIgnoreMasks) return true;
- return false;
+ return ! (*this == rhs);
}
bool LLKeyData::canHandle(const LLKeyData& data) const
diff --git a/indra/llcommon/llkeybind.h b/indra/llcommon/llkeybind.h
index 1bbb2fadb5..68efe38689 100644
--- a/indra/llcommon/llkeybind.h
+++ b/indra/llcommon/llkeybind.h
@@ -44,8 +44,8 @@ public:
bool empty() const { return isEmpty(); };
void reset();
LLKeyData& operator=(const LLKeyData& rhs);
- bool operator==(const LLKeyData& rhs);
- bool operator!=(const LLKeyData& rhs);
+ bool operator==(const LLKeyData& rhs) const;
+ bool operator!=(const LLKeyData& rhs) const;
bool canHandle(const LLKeyData& data) const;
bool canHandle(EMouseClickType mouse, KEY key, MASK mask) const;