Re: operator * of iterator
On Dec 3, 5:35 pm, Pete Becker <p...@versatilecoding.com> wrote:
On 2007-12-03 11:24:16 -0500, "Victor Bazarov" <v.Abaza...@comAcast.net> s=
aid:
George2 wrote:
Operator * on iterator of type T will result in reference to type T
(T&), right (i.e. not type T itself or some other types)?
I am looking for some STL implementation code for this (operator * on
iterator of type T will result in reference to type T (T&)), but can
not find (maybe I search method is not correct). Could anyone post
some internal implementation code please?
Iterators are closely tied to the container for which they were made,
and the implementation can differ greatly depending on the container.
Iterators provide access to the elements of a sequence. Containers are
one way of creating sequences, but not the only way. Unfortunately,
people tend to learn containers first, and give them undue importance,
ending up confused about how the STL works.
Maybe. But for anything more than an input or an output
iterator, operator*() must return a real reference; in addition,
"If a and b are both dereferenceable, then a == b if and only if
*a and *b are the same object." Meeting this requirement more
or less requires some sort of backing collection. The result is
that just about any interesting use without a backing collection
(and many with it, if you aren't returning exactly the element
of the collection) can only be an input iterator, which in turn
means that many of the algorithms won't work with them.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34