7#include "exception.hpp"
20[[nodiscard]]
inline bool get_bit(std::span<std::byte const> buffer, ssize_t &index)
noexcept
22 auto byte_index = index >> 3;
23 auto bit_index =
static_cast<uint8_t
>(index & 7);
26 tt_axiom(byte_index < std::ssize(buffer));
27 return static_cast<bool>(
28 static_cast<int>(buffer[byte_index] >> bit_index) & 1
50[[nodiscard]]
inline int get_bits(std::span<std::byte const> buffer, ssize_t &index,
int length)
noexcept
57 auto byte_index = index >> 3;
58 auto bit_index =
static_cast<int>(index & 7);
59 tt_axiom(byte_index < std::ssize(buffer));
61 auto available_bits = 8 - bit_index;
62 auto nr_bits =
std::min(available_bits, todo);
64 auto mask = (1 << nr_bits) - 1;
66 auto tmp =
static_cast<int>(buffer[byte_index] >> bit_index) & mask;