Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-09-01 13:01:39


on Mon Sep 01 2008, "Giovanni Piero Deretta" <gpderetta-AT-gmail.com> wrote:

> Need to think about it. Could you give a practical example of an
> iterator adapter needing three iterators?

E.g., a bidirectional filtered_iterator needs to be prevented from
stepping off both ends of the underlying data to avoid undefined
behavior.

On the other hand, you shouldn't have to pay for those endpoint
comparisons all the time, which tells me that something may be wrong
with the design.

Iterators are supposed to be lightweight things. If we're seriously
worried about the cost of building iterator adaptors, we might consider
the idea that there's something wrong with the bigger picture. Maybe
these endpoint comparisons need to be dealt with differently, somehow.
The situation with deque iterators that led to segmented iterators is
very similar, and it resulted in a system of abstractions that allows
one to operate, once again, close to the machine model.

I wouldn't know how to address this issue without some real-life use
cases, though. This has all become a bit too abstract a discussion for
me, and Generic Programming is supposed to be driven by concrete
examples.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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