mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
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:
@@ -763,6 +763,8 @@ class Color {
|
||||
constexpr Color(int r, int g, int b)
|
||||
: Color(r / 255.0, g / 255.0, b / 255.0) {}
|
||||
|
||||
constexpr bool operator==(const Color&) const = default;
|
||||
|
||||
/**
|
||||
* Creates a Color from HSV values.
|
||||
*
|
||||
@@ -830,14 +832,6 @@ class Color {
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const Color& c1, const Color& c2) {
|
||||
return c1.red == c2.red && c1.green == c2.green && c1.blue == c2.blue;
|
||||
}
|
||||
|
||||
inline bool operator!=(const Color& c1, const Color& c2) {
|
||||
return !(c1 == c2);
|
||||
}
|
||||
|
||||
/*
|
||||
* FIRST Colors
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,8 @@ class Color8Bit {
|
||||
return Color(red / 255.0, green / 255.0, blue / 255.0);
|
||||
}
|
||||
|
||||
constexpr bool operator==(const Color8Bit&) const = default;
|
||||
|
||||
/**
|
||||
* Return this color represented as a hex string.
|
||||
*
|
||||
@@ -56,8 +58,4 @@ class Color8Bit {
|
||||
int blue = 0;
|
||||
};
|
||||
|
||||
inline bool operator==(const Color8Bit& c1, const Color8Bit& c2) {
|
||||
return c1.red == c2.red && c1.green == c2.green && c1.blue == c2.blue;
|
||||
}
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user