On Wednesday, 27 June 2012 at 20:29:02 UTC, Roman D. Boiko wrote:
On Wednesday, 27 June 2012 at 20:14:53 UTC, Steven
Schveighoffer wrote:
Removal of that element is perfectly possible, you just need
to maintain a reference to its predecessor. Which SList's
range does not keep track of. It all depends on tradeoffs of
what you want for performance, vs. features. It's why I
contend that generic singly linked list is difficult to
create. Can't please everyone.
Yes, I agree.
And iterators are not necessary, ranges are quite possible.
In this respect it is not only a performance vs. features
tradeoff, semantics is (usually) different. Of course, we might
use a range for what is semantically an iterator. But it feels
unnatural for me.
E.g., to point to an element in the middle of some range we
would need to create another range and pass it to a function
along with the original range. I would hesitate to call them
ranges unless that is explicitly a goal for some particular
application. If that was the case, it would require an explicit
explanation. (IMO)
Why pass the original range?