u128: Add u128::Bit

This commit is contained in:
MerryMage 2018-07-23 15:57:05 +01:00
parent 3e62fea003
commit 5566fab29a

View File

@ -32,6 +32,16 @@ struct u128 {
u64 lower = 0; u64 lower = 0;
u64 upper = 0; u64 upper = 0;
template<size_t bit_position>
bool Bit() {
static_assert(bit_position < 128);
if constexpr (bit_position < 64) {
return Common::Bit<bit_position>(lower);
} else {
return Common::Bit<bit_position - 64>(upper);
}
}
}; };
static_assert(Common::BitSize<u128>() == 128); static_assert(Common::BitSize<u128>() == 128);