7#include "exception.hpp"
12namespace hi::inline
v1 {
22 hilet byte_index = index >> 3;
23 hilet bit_index = index & 7;
26 hi_axiom(byte_index < buffer.size());
27 return to_bool(std::bit_cast<uint8_t>(buffer[byte_index] >> bit_index) & 1);
57 hilet byte_index = index >> 3;
58 hilet bit_index = index & 7;
59 hi_axiom(byte_index < buffer.size());
61 hilet available_bits = 8 - bit_index;
64 hilet mask = (1 << nr_bits) - 1;
66 hilet tmp =
static_cast<int>(buffer[byte_index] >> bit_index) & mask;
Utilities to assert and bound check.
#define hi_axiom(expression)
Specify an axiom; an expression that is true.
Definition assert.hpp:133
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
bool get_bit(std::span< std::byte const > buffer, std::size_t &index) noexcept
Read a single bit from span of bytes Bits are ordered LSB first.
Definition bits.hpp:20
std::size_t get_bits(std::span< std::byte const > buffer, std::size_t &index, std::size_t length) noexcept
Read a bits from of span of bytes Bits are ordered LSB first.
Definition bits.hpp:48