Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-08-23 12:36:46


----- Original Message -----
From: "Gabriel Dos Reis" <gdr_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, August 23, 2002 1:11 PM
Subject: Re: [boost] iterator::operator[]

> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
> | > The same argument applies to [].
> |
> | A weaker version of the argument. Only random access iterators have [],
so
> | users cannot expect all iterators to supply it.
>
> The whole story about iterators started with pointers :-) And users
> do use [] with pointers (which are supposed to provide a canonical
> example of random access iterator).
>
Yes, but users do use [] with pointers because a pointer can be used to
refer to an array -a container-. If you use [] with a pointer you are
referring to the underlying array which is identified by the pointer.
As others said, subscripting is a collection operation, and an iterator
denotes an element of the collection, not the collection itself. This is (or
should be, actually) a fundamental difference between pointers and
iterators, because a pointer also denotes an array.

IMO, subscripting should have never been part of the iterator semantics.

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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