RFC on range design for D2
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Sep 9 17:30:06 PDT 2008
Steven Schveighoffer wrote:
> "Andrei Alexandrescu" wrote
> For example, std::list defines multiple erase functions:
>
> iterator erase(iterator first, iterator last);
> iterator erase(iterator position);
>
> In the second case, the iterator need not support incrementing or
> decrementing (to the user anyway), just referencing. They just used
> iterator because it's already there :)
>
> But in your proposed scenario, I can't have the second function, only the
> first. My example shows a case where I'd want the second function. What I
> basically want is a range type where the upper limit is specified as 'always
> null', so that iterating the range once always results in an empty range,
> even if the container has changed topology.
I understand. That can't be had in my design. You'd have:
List.Range List.erase(Range toErase);
and you'd model erasure of one element through a range of size one. I
understand how that can be annoying on occasion, but I consider that a
minor annoyance and do not plan to allow bare iterators for such cases.
I think the absence of naked iterators has huge cognitive and safety
advantages.
Andrei
More information about the Digitalmars-d-announce
mailing list