StaticBitArray.opApply

Support for foreach loops for StaticBitArray.

  1. int opApply(int delegate(ref bool) dg)
  2. int opApply(int delegate(bool) dg)
    struct StaticBitArray(uint capacity, Block = DefaultBlock)
    @safe const @trusted
    int
    opApply
    (
    scope int delegate
    (
    bool
    )
    dg
    )
    if (
    isUnsigned!DefaultBlock
    )
  3. int opApply(int delegate(const ref size_t, ref bool) dg)
  4. int opApply(int delegate(in size_t, bool) dg)

Examples

static bool[] ba = [1,0,1];
auto a = StaticBitArray!3(ba);
size_t i;
foreach (immutable b; a[]) /+ TODO: is `opSlice` the right thing? +/
{
	switch (i) {
	case 0: assert(b == true); break;
	case 1: assert(b == false); break;
	case 2: assert(b == true); break;
	default: assert(0);
	}
	i++;
}
foreach (j, b; a)	   /+ TODO: is `opSlice` the right thing? +/
{
	switch (j) {
	case 0: assert(b == true); break;
	case 1: assert(b == false); break;
	case 2: assert(b == true); break;
	default: assert(0);
	}
}

Meta