import std.array : array;
import std.range : repeat, take;
// bit array with 300 elements
auto a = BitArray(true.repeat.take(300).array);
size_t[] v = cast(size_t[]) a;
const blockSize = size_t.sizeof * 8;
assert(v.length == (a.length + blockSize - 1) / blockSize);
Convert to size_t[].