On Wednesday, 30 October 2013 at 14:58:21 UTC, Andrej Mitrovic wrote:
It allocates, I'm looking for a lazy range. I would be surprised that such a common task as iterating a tree is not possible without using
classes and workarounds.

It allocates, but it's still a lazy range. It only allocates when popFront is called. I looked around a bit more and found "only" in std.range that can do this without allocating:

With the walk function like this:
---
    InputRange!Tree walk()
    {
        return inputRangeObject(chain(
            only(this),
            children.map!(a=>a.walk).joiner));
    }
---

you would avoid allocations.

Reply via email to