Use defaulted comparison operators in C++ (#4723)

Comparison operators which compared against every class member variable
now use C++20's default comparison operators.

Also remove operator!= that in C++20 is now auto-generated from operator==.
This commit is contained in:
Tyler Veness
2022-11-27 21:01:01 -08:00
committed by GitHub
parent 135c13958f
commit 42b6d4e3f7
39 changed files with 25 additions and 367 deletions

View File

@@ -520,14 +520,7 @@ class NetworkTableEntry final {
* Equality operator. Returns true if both instances refer to the same
* native handle.
*/
bool operator==(const NetworkTableEntry& oth) const {
return m_handle == oth.m_handle;
}
/** Inequality operator. */
bool operator!=(const NetworkTableEntry& oth) const {
return !(*this == oth);
}
bool operator==(const NetworkTableEntry&) const = default;
protected:
/* Native handle */

View File

@@ -688,14 +688,7 @@ class NetworkTableInstance final {
* Equality operator. Returns true if both instances refer to the same
* native handle.
*/
bool operator==(const NetworkTableInstance& other) const {
return m_handle == other.m_handle;
}
/** Inequality operator. */
bool operator!=(const NetworkTableInstance& other) const {
return !(*this == other);
}
bool operator==(const NetworkTableInstance&) const = default;
private:
/* Native handle */

View File

@@ -636,9 +636,6 @@ class Value final {
};
bool operator==(const Value& lhs, const Value& rhs);
inline bool operator!=(const Value& lhs, const Value& rhs) {
return !(lhs == rhs);
}
/**
* NetworkTable Value alias for similarity with Java.

View File

@@ -278,10 +278,7 @@ class Topic {
* Equality operator. Returns true if both instances refer to the same
* native handle.
*/
bool operator==(const Topic& oth) const { return m_handle == oth.m_handle; }
/** Inequality operator. */
bool operator!=(const Topic& oth) const { return !(*this == oth); }
bool operator==(const Topic&) const = default;
protected:
NT_Topic m_handle{0};