Template Class BitArray

Class Documentation

template<std::size_t Bits>
class BitArray

Fixed-size packed bit array.

Storage uses the smallest fixed-width integer that can hold the requested bits without exceeding the platform’s native word size. Larger arrays are split across native words.

Bit zero is the least-significant bit. Mutable indexing returns a proxy so individual bits can be assigned as though they were ordinary booleans. words() exposes the same packed storage as a contiguous word array. Indices must be below Bits; assertions are not checked release-mode errors. Spans/proxies borrow this array. Access is unsynchronized, including writes to different bits in one word; whole-word access can modify unused high bits. Native storage/byte order is not a portable serialized representation.

Public Types

using word_type = ::CE::Math::Detail::bit_word_t<Bits>
using Reference = ::CE::Math::Detail::BitReference<word_type>

Public Functions

Reference operator[](std::size_t index) noexcept
bool operator[](std::size_t index) const noexcept
std::span<word_type, word_count> words() noexcept
std::span<const word_type, word_count> words() const noexcept

Public Static Attributes

static std::size_t word_bits = ::CE::Math::Detail::bit_word_bits<Bits>
static std::size_t word_count = ::CE::Math::Detail::bit_word_count<Bits>