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:
@@ -48,19 +48,8 @@ class WPILIB_DLLEXPORT Trajectory {
|
||||
|
||||
/**
|
||||
* Checks equality between this State and another object.
|
||||
*
|
||||
* @param other The other object.
|
||||
* @return Whether the two objects are equal.
|
||||
*/
|
||||
bool operator==(const State& other) const;
|
||||
|
||||
/**
|
||||
* Checks inequality between this State and another object.
|
||||
*
|
||||
* @param other The other object.
|
||||
* @return Whether the two objects are not equal.
|
||||
*/
|
||||
bool operator!=(const State& other) const;
|
||||
bool operator==(const State&) const = default;
|
||||
|
||||
/**
|
||||
* Interpolates between two States.
|
||||
@@ -140,19 +129,8 @@ class WPILIB_DLLEXPORT Trajectory {
|
||||
|
||||
/**
|
||||
* Checks equality between this Trajectory and another object.
|
||||
*
|
||||
* @param other The other object.
|
||||
* @return Whether the two objects are equal.
|
||||
*/
|
||||
bool operator==(const Trajectory& other) const;
|
||||
|
||||
/**
|
||||
* Checks inequality between this Trajectory and another object.
|
||||
*
|
||||
* @param other The other object.
|
||||
* @return Whether the two objects are inequal.
|
||||
*/
|
||||
bool operator!=(const Trajectory& other) const;
|
||||
bool operator==(const Trajectory&) const = default;
|
||||
|
||||
private:
|
||||
std::vector<State> m_states;
|
||||
|
||||
@@ -68,10 +68,7 @@ class TrapezoidProfile {
|
||||
public:
|
||||
Distance_t position{0};
|
||||
Velocity_t velocity{0};
|
||||
bool operator==(const State& rhs) const {
|
||||
return position == rhs.position && velocity == rhs.velocity;
|
||||
}
|
||||
bool operator!=(const State& rhs) const { return !(*this == rhs); }
|
||||
bool operator==(const State&) const = default;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user