BitArray.opBinary

Support for binary operator ~ for BitArray.

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

Examples

1 bool[] ba = [1,0];
2 bool[] bb = [0,1,0];
3 
4 auto a = BitArray(ba);
5 auto b = BitArray(bb);
6 BitArray c;
7 
8 c = (a ~ b);
9 assert(c.length == 5);
10 assert(c[0] == 1);
11 assert(c[1] == 0);
12 assert(c[2] == 0);
13 assert(c[3] == 1);
14 assert(c[4] == 0);
15 
16 c = (a ~ true);
17 assert(c.length == 3);
18 assert(c[0] == 1);
19 assert(c[1] == 0);
20 assert(c[2] == 1);
21 
22 c = (false ~ a);
23 assert(c.length == 3);
24 assert(c[0] == 0);
25 assert(c[1] == 1);
26 assert(c[2] == 0);

Meta

Suggestion Box / Bug Report