From 030820f649c49d8e468f9d72ef2a56038f1b82bc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 23 Jul 2018 15:11:59 -0400 Subject: [PATCH] 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==. --- src/common/u128.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/u128.h b/src/common/u128.h index da184d10..71e4bcde 100644 --- a/src/common/u128.h +++ b/src/common/u128.h @@ -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);