On Wednesday, 4 June 2025 at 02:11:18 UTC, H. S. Teoh wrote:
The correct way to do this is to create a method in the
container that returns a range over its contents. Popping the
range should NOT mutate the container. It should be regarded
as something separate from the container. Only then will you
get sane semantics. Trying to conflate an unordered container
with a range will only lead to pain and bugs.
So, concretely, my container has an opApply method, and because
of that foreach works to iterate its contents. Imagine that I
now want to chain() across several of these, along the lines of:
```d
foreach(val; s1) {
...;
}
// But now:
foreach(val; chain(s1, s2, s3)) {
...;
}
```
What API do I add to my container so that chain will do its
magic? I don't see the infrastructure under std.range.chain
using it. Or is there a non-Range chain I haven't found yet?
Thank you again,
Andy