Why doesn't this work? I'm assuming I'm not fully understanding how "alias this" interacts with ranges (i.e. the range isn't being reset after count is finished with it), but I'm not sure how to fix this either:

import std.algorithm;

class ArrayContainer
{
    int[] values;
    this(int[] v) { values = v; }
    alias values this;
}

void main(string[] args)
{
    auto c = new ArrayContainer([1, 2, 3]);
    assert(count(c) == 3); //succeeds
    assert(c.length == 3); //FAILS - is actually zero
}

Reply via email to