import std.algorithm.comparison : equal; import std.range : iota; // positions 0, 2, 4 are set auto b = BitArray([1, 0, 1, 0, 1, 0]); b.flip(); // after flipping, positions 1, 3, 5 are set assert(b.bitsSet.equal([1, 3, 5])); bool[270] bits; auto b1 = BitArray(bits); b1.flip(); assert(b1.bitsSet.equal(iota(0, 270)));
Flips all the bits in the BitArray