Re: iterator as key for unordered_map
On Jun 24, 7:39 am, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
abir wrote:
(I am not sure if there is any formal requirement that
&(*iter) does not change as long as the underlying container
remains unchanged; however, I do not know of any STL
implementation where objects governed by a container move
about without reason.)
Each of the containers makes certain guarantees with regards to
the validity of pointers or references to its elements, just as
it does with regards to the validity of iterators. Thus, for
example, "An insertion at either end of the deque invalidates
all the iterators to the deque, but has no effect on the
validity of references to elements of the deque." (I cite this
one, because it is the only case I know of off hand where the
validity of references is different from that of iterators.)
Note that the result of *iter is a reference, so &*iter depends
only on the validity of this reference.
--
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