1 static bool[] ba = [1,0,1]; 2 auto a = StaticBitArray!3(ba); 3 size_t i; 4 foreach (immutable b; a[]) // TODO is `opSlice` the right thing? 5 { 6 switch (i) 7 { 8 case 0: assert(b == true); break; 9 case 1: assert(b == false); break; 10 case 2: assert(b == true); break; 11 default: assert(0); 12 } 13 i++; 14 } 15 foreach (j, b; a) // TODO is `opSlice` the right thing? 16 { 17 switch (j) 18 { 19 case 0: assert(b == true); break; 20 case 1: assert(b == false); break; 21 case 2: assert(b == true); break; 22 default: assert(0); 23 } 24 }
Support for foreach loops for StaticBitArray.