BitArray.opBinary

Support for binary operator ~ for BitArray.

  1. BitArray opBinary(BitArray e2)
  2. BitArray opBinary(bool b)
    struct BitArray
    const pure nothrow
    opBinary
    (
    string op
    )
    (
    bool b
    )
    if (
    op == "~"
    )
  3. BitArray opBinary(BitArray b)

Examples

bool[] ba = [1,0];
bool[] bb = [0,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
BitArray c;

c = (a ~ b);
assert(c.length == 5);
assert(c[0] == 1);
assert(c[1] == 0);
assert(c[2] == 0);
assert(c[3] == 1);
assert(c[4] == 0);

c = (a ~ true);
assert(c.length == 3);
assert(c[0] == 1);
assert(c[1] == 0);
assert(c[2] == 1);

c = (false ~ a);
assert(c.length == 3);
assert(c[0] == 0);
assert(c[1] == 1);
assert(c[2] == 0);

Meta