Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-07-25 16:09:32


----- Original Message -----
From: "George A. Heintzelman" <georgeh_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, July 25, 2001 4:13 PM
Subject: [boost] indirect iterator help

> So I guess what I'm asking is, is
> there any way for an indirect_iterator instance to give one access to
> the 'inbetween' iterator it is using (that is, the iterator to the
> iterator to the foo)?

Yes; the Base type of the indirect iterator is actually the outer iterator
you are interested in, so you can just call base() on the indirect iterator.
I guess we need to document the iterator_adaptor-specific interfaces for all
of the specialized adaptors. The general documentation is here:

www.boost.org/libs/utility/iterator_adaptors.htm#additional_members

> On a more petulant note, is there a reason that one has to write
>
> boost::indirect_iterator_generator<BaseIterator>::type;
> rather than
> boost::indirect_iterator<BaseIterator>
> ?

Yes, it has to do with what it takes to make the const/non-const conversions
work correctly.
In order to re-use the global template operator definitions written for
iterator_adaptor, the type of the indirect iterator really needs to be an
iterator_adaptor<...> and not something else (not even something derived).

> I realize that there are no template typedefs, but it seems that one
> could just hide the generator machinery as an implementation detail and
> add just one more level of inheritance, and you would be done.

Unfortunately, inheritance defeats template argument matching.

-Dave


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