joiner: How to iterate over immutable ranges?
Bastiaan Veelo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Feb 14 11:32:31 PST 2016
On Sunday, 14 February 2016 at 18:28:11 UTC, Jonathan M Davis
wrote:
> An immutable range fundamentally does not work. The same goes
> with const. In fact, a type that's immutable is going to fail
> isInputRange precisely because it can't possibly function as
> one. While empty and front may be callable on an immutable
> range, depending on their exact signatures, popFront cannot be,
> because it has to mutate the range in order to work.
Thanks. I didn't know that iterating a range means mutating its
contents. I still don't quite get it, and it is probably because
I don't fully understand ranges. I think what confuses me the
most is their analogy to containers. It's no problem to iterate
over a container of immutable data, but it is for a range.
I thought that joiner provided a contiguous view on distinct
ranges, without needing to touch these. Is there another method
to traverse a range of ranges without making copies or mutation?
More information about the Digitalmars-d-learn
mailing list