Comment #0 by matti.niemenmaa+dbugzilla — 2006-03-08T14:01:39Z
Using inout in a foreach loop through a BitArray has no effect: the bits in the BitArray do not change when assigned to or otherwise modified.
Can be easily circumvented by using a for loop, but is still an annoyance.
--
import std.bitarray;
void main() {
BitArray a;
a.length = 5;
foreach (inout bit b; a) {
assert (b == 0);
b = 1;
}
foreach (bit b; a)
assert (b == 1); // FAILS, they're all 0
}
Comment #1 by bugs-d — 2006-03-18T18:23:24Z
Created attachment 4
Naive, simple fix.
This adds to the unittests in bitarray.d for this bug, and calls opIndexAssign() on each bit (before the break.)
This would seem to make foreach over bit arrays slower, but then it's still not exceedingly fast anyway to call a function for every bit so I'd suggest the opIndexCall isn't going to hurt anyone much.
-[Unknown]