Comment on PEP-0322: Reverse Iteration Methods

David Abrahams dave at
Sat Sep 27 18:17:53 CEST 2003

Stephen Horne <$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$> writes:

> On Sat, 27 Sep 2003 15:22:37 GMT, Alex Martelli <aleax at>
> wrote:
>>David Abrahams wrote:
>>   ...
>>> Well, (understanding that you don't nececessarily agree with the
>>> above) you can in fact iterate on std::pair<T,T> with the usual C++
>>> iterator protocol, 
>>You mean there's an std::pair::begin etc?!  OK, I guess I'm even
>>rustier on standard C++ than I thought I was -- I could have SWORN
>>there wasn't.  (Std chapter & verse pls?  I plan to win bets based
>>on this tidbit...!-).  So I guess the lack of those in gcc is a
>>breach of the Standard on gcc's part...?
> Somehow I think David is mistaken here - I cannot believe that
> dereferencing an iterator returns a different datatype depending on
> which item it happens to point to at runtime in statically typed
> C++,

You didn't read carefully enough: I said std::pair<T,T>, not

> and without that ability to dereference the iterator (1) I cannot see
> the point of iterating through a pair, and (2) the 'iterator' would
> not be a true iterator as C++ iterators have to comply with one of a
> set of standard protocols (forward, bidirectional, random etc) which
> all include subscripting.

I'm pretty well familiar with those protocols - I've been working on
the C++ standards committee since 1997 and have written several
related proposals, c.f.

> Of course you can iterate through a container that holds std::pair
> objects - you do that every time you iterate through an std::map - but
> that isn't the same thing.

No, definitely not.

Dave Abrahams
Boost Consulting

More information about the Python-list mailing list