https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59170

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jan Kratochvil from comment #6)
> This all depends more on a different non-pretty-printers feature I plan to
> file for libstdc++ for years but I have never done so yet.  With
> -D_GLIBCXX_DEBUG the iterators could be memory-managed - they already track
> their container by _M_sequence.  The container could also track all its live
> iterators, elements could track iterators pointing at them (and properly
> invalidate them upon container updates) etc.  Deleting the container would
> invalidate all its iterators etc.  Accessing an invalidated iterator would
> then immediately assert.

This is all already done, isn't it?

Containers keep a list of active iterators (see
_Safe_sequence_base::_M_iterators) which are automatically invalidated by the
relevant container operations.

Reply via email to