質問

If I want a compile-time-sized bit-array (on stack) what are my alternatives?

I'm thinking something like

struct Bitset(size_t nBits) {
    enum wsz = 8 * size_t.sizeof; // Word-Size.
    enum nBlocks = nBits/wsz + nBits % wsz * wsz;
    alias _bits this;
    size_t[nBlocks] _bits;
}

along with bt and alikes from core.bitop

would suit my needs.

Has anybody already written a template for this along with some nice boolean operations?

役に立ちましたか?

解決

I would simply check if BitArray uses the stack or not. If not, grab the source code and modify it...

IMHO BitArray could be improved with some sort of option whether you want it on the stack or not...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top