Comment on PEP-0322: Reverse Iteration Methods

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Sat Sep 27 11:35:10 EDT 2003


On Sat, 27 Sep 2003 15:22:37 GMT, Alex Martelli <aleax at aleax.it>
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++,
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.

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.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list