The OpenD Programming Language

bitpack

Bitpack slice over an integral slice.

Bitpack is used to represent unsigned integer slice with fewer number of bits in integer binary representation.

Parameters

pack

counts of bits in the integer.

Return Value

Type: auto

A bitpack slice.

Examples

size_t[10] data;
// creates a packed unsigned integer slice with max allowed value equal to `2^^6 - 1 == 63`.
auto packs = data[].bitpack!6;
assert(packs.length == data.length * size_t.sizeof * 8 / 6);
packs[$ - 1] = 24;
assert(packs[$ - 1] == 24);

packs.popFront;
assert(packs[$ - 1] == 24);

Meta