Re: Comment on PEP-0322: Reverse Iteration Methods
On Sat, 27 Sep 2003 15:22:37 GMT, Alex Martelli <aleax@aleax.it >
wrote:
[color=blue]
>David Abrahams wrote:
> ...[color=green]
>> 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,[/color]
>
>You mean there's an std::pair::begi n 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...?[/color]
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
On Sat, 27 Sep 2003 15:22:37 GMT, Alex Martelli <aleax@aleax.it >
wrote:
[color=blue]
>David Abrahams wrote:
> ...[color=green]
>> 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,[/color]
>
>You mean there's an std::pair::begi n 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...?[/color]
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
Comment