Iterators for D
Craig Black
cblack at ara.com
Tue Nov 7 06:03:13 PST 2006
When writing custom C++ iterators, I find that end() is not ever necessary.
If end() is not used, it means that a little more smarts have to be added to
the iterator itself so that the iterator knows when to stop. In some cases
this means that the iterator needs a pointer to the collection/container
object in order to get that information.
-Craig
"Walter Bright" <newshound at digitalmars.com> wrote in message
news:eioqvl$26t0$2 at digitaldaemon.com...
> Bill Baxter wrote:
> > I think the iterator-as-range idea is at least worth discussing. 99% of
> > the time you use an iterator you also need to know where to stop. It's
> > pretty similar to how arrays in D keep a length, because 99% of the time
> > when you have an array you need to know how long it is too. So it makes
> > sense to keep those two bits of information together. Similarly in C++,
> > when you have an iterator, you almost always need the end() too. And
> > any time you want to pass around iterators you end up having to pass the
> > two bits of information around separately.
>
> That's a very good point. Got any ideas on that?
More information about the Digitalmars-d
mailing list