u128: Implement comparison operators in terms of one another
We can just implement the comparisons in terms of operator< and implement inequality with the negation of operator==.
This commit is contained in:
parent
a04553eb91
commit
030820f649
1 changed files with 4 additions and 4 deletions
|
@ -69,15 +69,15 @@ inline bool operator<(u128 a, u128 b) {
|
|||
}
|
||||
|
||||
inline bool operator>(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) > std::tie(b.upper, b.lower);
|
||||
return operator<(b, a);
|
||||
}
|
||||
|
||||
inline bool operator<=(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) <= std::tie(b.upper, b.lower);
|
||||
return !operator>(a, b);
|
||||
}
|
||||
|
||||
inline bool operator>=(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) >= std::tie(b.upper, b.lower);
|
||||
return !operator<(a, b);
|
||||
}
|
||||
|
||||
inline bool operator==(u128 a, u128 b) {
|
||||
|
@ -85,7 +85,7 @@ inline bool operator==(u128 a, u128 b) {
|
|||
}
|
||||
|
||||
inline bool operator!=(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) != std::tie(b.upper, b.lower);
|
||||
return !operator==(a, b);
|
||||
}
|
||||
|
||||
u128 operator<<(u128 operand, int amount);
|
||||
|
|
Loading…
Reference in a new issue