17 constexpr auto subset(
const std::bitset<bit_size>& bits) -> std::bitset<max - min>
19 constexpr auto max_size = 64;
20 static_assert(max > min);
21 static_assert(max_size >= (max - min));
22 constexpr auto ignore_high = bit_size - max;
24 auto new_bits = (bits << ignore_high) >> (ignore_high + min);
25 return std::bitset<max - min>{ new_bits.to_ullong() };
29 constexpr auto merge_bits(
const std::bitset<high_size>& high_bits,
const std::bitset<low_size>& low_bits)
30 -> std::bitset<high_size + low_size>
32 using NewBit = std::bitset<high_size + low_size>;
33 constexpr auto max_size = 64;
34 static_assert(max_size >= high_size + low_size);
36 auto high_bits_part = NewBit(high_bits.to_ullong());
37 auto low_bits_part = NewBit(low_bits.to_ullong());
38 auto new_bits = (high_bits_part << low_size) | low_bits_part;
39 return std::bitset<high_size + low_size>(new_bits.to_ullong());