u128: Add comparison operators
This commit is contained in:
parent
f17cd6f2c5
commit
3e62fea003
1 changed files with 25 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
#include "common/bit_util.h"
|
||||
|
@ -51,6 +52,30 @@ inline u128 operator-(u128 a, u128 b) {
|
|||
return result;
|
||||
}
|
||||
|
||||
inline bool operator<(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) < std::tie(b.upper, b.lower);
|
||||
}
|
||||
|
||||
inline bool operator>(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) > std::tie(b.upper, b.lower);
|
||||
}
|
||||
|
||||
inline bool operator<=(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) <= std::tie(b.upper, b.lower);
|
||||
}
|
||||
|
||||
inline bool operator>=(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) >= std::tie(b.upper, b.lower);
|
||||
}
|
||||
|
||||
inline bool operator==(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) == std::tie(b.upper, b.lower);
|
||||
}
|
||||
|
||||
inline bool operator!=(u128 a, u128 b) {
|
||||
return std::tie(a.upper, a.lower) != std::tie(b.upper, b.lower);
|
||||
}
|
||||
|
||||
u128 operator<<(u128 operand, int amount);
|
||||
u128 operator>>(u128 operand, int amount);
|
||||
|
||||
|
|
Loading…
Reference in a new issue