diff options
author | Benjamin Barenblat <bbaren@google.com> | 2024-09-03 11:49:29 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2024-09-03 11:49:29 -0400 |
commit | c1afa8b8238c25591ca80d068477aa7d4ce05fc8 (patch) | |
tree | 284a9f8b319de5783ff83ad004a9e390cb60fd0d /absl/numeric/int128_no_intrinsic.inc | |
parent | 23778b53f420f54eebc195dd8430e79bda165e5b (diff) | |
parent | 4447c7562e3bc702ade25105912dce503f0c4010 (diff) |
Merge new upstream LTS 20240722.0
Diffstat (limited to 'absl/numeric/int128_no_intrinsic.inc')
-rw-r--r-- | absl/numeric/int128_no_intrinsic.inc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/absl/numeric/int128_no_intrinsic.inc b/absl/numeric/int128_no_intrinsic.inc index 6f5d8377..195b7452 100644 --- a/absl/numeric/int128_no_intrinsic.inc +++ b/absl/numeric/int128_no_intrinsic.inc @@ -186,6 +186,24 @@ constexpr bool operator<=(int128 lhs, int128 rhs) { return !(lhs > rhs); } constexpr bool operator>=(int128 lhs, int128 rhs) { return !(lhs < rhs); } +#ifdef __cpp_impl_three_way_comparison +constexpr absl::strong_ordering operator<=>(int128 lhs, int128 rhs) { + if (int64_t lhs_high = Int128High64(lhs), rhs_high = Int128High64(rhs); + lhs_high < rhs_high) { + return absl::strong_ordering::less; + } else if (lhs_high > rhs_high) { + return absl::strong_ordering::greater; + } else if (uint64_t lhs_low = Uint128Low64(lhs), rhs_low = Uint128Low64(rhs); + lhs_low < rhs_low) { + return absl::strong_ordering::less; + } else if (lhs_low > rhs_low) { + return absl::strong_ordering::greater; + } else { + return absl::strong_ordering::equal; + } +} +#endif + // Unary operators. constexpr int128 operator-(int128 v) { |