On Tuesday, 13 January 2015 at 20:52:15 UTC, Dominikus Dittes
Scherkl wrote:
Of course you can calculate it, but the
syntax looks quite different if you want to do
a.bit[22] = false:
a &= ~(1<<16);
Or if you want to test a bit:
if(a.bit[16])
instead of
if(a & (1<<16))
much more convenient for arrays:
ulong[100] a;
a.bit[3000] = true;
doing this directly with shifts is lousy (and error prone)
But ok. I see, it's not really awesome :-/
I didn't mean to put a stop to your idea just because we have
bitwise operators. You're totally right: They're somewhat
cumbersome and easy to get wrong.
We also have std.bitmanip.BitArray which is what you're after, I
think:
import std.bitmanip: BitArray;
BitArray ba;
ba.length = 3001;
ba[3000] = true;