From 5566fab29a42abfa5c20f8cd3fbbe06789a89437 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 23 Jul 2018 15:57:05 +0100 Subject: [PATCH] u128: Add u128::Bit --- src/common/u128.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/u128.h b/src/common/u128.h index 401c608f..867ac1dd 100644 --- a/src/common/u128.h +++ b/src/common/u128.h @@ -24,7 +24,7 @@ struct u128 { u128(u64 lower_, u64 upper_) : lower(lower_), upper(upper_) {} - template + template /* implicit */ u128(T value) : lower(value), upper(0) { static_assert(std::is_integral_v); static_assert(Common::BitSize() <= Common::BitSize()); @@ -32,6 +32,16 @@ struct u128 { u64 lower = 0; u64 upper = 0; + + template + bool Bit() { + static_assert(bit_position < 128); + if constexpr (bit_position < 64) { + return Common::Bit(lower); + } else { + return Common::Bit(upper); + } + } }; static_assert(Common::BitSize() == 128);