RE: [Boost-users] Re: map with minimal memory footprint
Gottlob Frege wrote:
I believe you, but can you explain what you mean by "iterator invalidation properties". I wrote a vector_map once, and it was as "map-ish" as needed at the time, so I suspect it was just a "useful associative container", but I'm just curious as to what I was missing... When you insert or erase elements in a container, The Standard imposes requirements on what happens to iterators and references you have to elements in a container.
All map iterators and references must remain valid after inserts. After erasing, only iterators and references to the erased element are allowed to be invalidated. Inserts into vectors (including via 'resize' or 'reserve') can invalidate all references and iterators, if the vector has to reallocate; otherwise, only references and iterators to elements prior to the one being inserted remain valid. Erasing invalidates iterators and references to elements after the one being erased. If you have a copy of the Standard, search for "invalidate" in section 23 for full details. -- Jim Hyslop Senior Software Designer Leitch Technology International Inc. ( http://www.leitch.com ) Columnist, C/C++ Users Journal ( http://www.cuj.com/experts )
participants (1)
-
Jim.Hyslop