Skip to content

Commit

Permalink
fix: clang-tidy error on spaceship operator
Browse files Browse the repository at this point in the history
fixed by using legacy comparison operators

clang-tidy 12 used by cata-clang-tidy cannot handle spaceship operator

see: cataclysmbnteam#2341 (comment)
  • Loading branch information
scarf005 committed Apr 25, 2023
1 parent dca584e commit f2cf776
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/units_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,35 @@ class quantity
* The spaceship comparators, they compare the base value only.
*/
/**@{*/
// FIXME: blocked until cata-clang-tidy is updated to use latest clang-tidy (13+)
// https://github.com/cataclysmbnteam/Cataclysm-BN/pull/2341#issuecomment-1520397239
// template<Arithmetic other_value_type>
// constexpr friend bool operator==( const quantity<value_type, unit_type> &lhs,
// const quantity<other_value_type, unit_type> &rhs ) {
// return ( lhs <=> rhs ) == 0; // *NOPAD*
// }

// template<Arithmetic other_value_type>
// constexpr friend auto operator<=> ( const quantity<value_type, unit_type> &lhs, // *NOPAD*
// const quantity<other_value_type, unit_type> &rhs ) {
// return lhs.value() <=> rhs.value(); // *NOPAD*
// }
template<Arithmetic other_value_type>
constexpr friend bool operator==( const quantity<value_type, unit_type> &lhs,
const quantity<other_value_type, unit_type> &rhs ) {
return ( lhs <=> rhs ) == 0; // *NOPAD*
return lhs.value() == rhs.value();
}

template<Arithmetic other_value_type>
constexpr friend auto operator<=> ( const quantity<value_type, unit_type> &lhs, // *NOPAD*
const quantity<other_value_type, unit_type> &rhs ) {
return lhs.value() <=> rhs.value(); // *NOPAD*
constexpr bool operator<( const this_type &rhs ) const {
return value_ < rhs.value_;
}
constexpr bool operator<=( const this_type &rhs ) const {
return value_ <= rhs.value_;
}
constexpr bool operator>( const this_type &rhs ) const {
return value_ > rhs.value_;
}
constexpr bool operator>=( const this_type &rhs ) const {
return value_ >= rhs.value_;
}
/**@}*/

Expand Down

0 comments on commit f2cf776

Please sign in to comment.