Boost logo

Boost :

Subject: Re: [boost] On Iteration
From: James Porter (porterj_at_[hidden])
Date: 2009-11-10 23:04:13


Andrei Alexandrescu wrote:
> My article with a draft name "Iterators Must Go (Ahead)" is now
> published on InformIt and mentioned on reddit.com. Due to the vagaries
> of posting time and reddit dynamics, the article didn't stay long on
> reddit's programming page so it got very few views and comments.

Having considered this problem myself, I went down a slightly different
path. I was never really comfortable with the idea of "find" and friends
returning a range when conceptually, what you're asking for is a location.

My solution to that was to introduce a "referent" type that works like a
MyType * const (more-or-less). Instead of having something like "Until",
I take the referent and use it to split the range into two subranges and
then take the piece I care about. Obviously, this has some of the same
safety concerns that iterators do, but I'm not sure if it's worth
worrying about in practice (especially since there are plenty of ways of
invalidating a range to begin with).

Still, ranges are pretty useful, and having played around with
implementing them, they definitely make it easier to write functions
like zip or cartesian_product.

- Jim


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk