C++ Logo

std-proposals

Advanced search

Re: [std-proposals] vector::push_back must not invalidate past-the-end iterator

From: Nikl Kelbon <kelbonage_at_[hidden]>
Date: Mon, 8 Dec 2025 21:56:00 +0500
i dont know what are you about, itry mplement it your ideas in code and you
will see why its impossible

пн, 8 дек. 2025 г. в 21:30, Andre Kostur <andre_at_[hidden]>:

> > > After that insertion: the references, iterators, and pointers that
> > were formed before the insertion no longer point/refer to the same
> > things they did before.
> >
> > no, there are no relocation
>
> Yes, they are still referring to the same chunks of memory, the
> contents of the objects may/would have been moved along. And by "same
> things" I'm talking about the contents of the object, not their
> addresses. If I had a pointer to the Player named "Parzival" before,
> that might have become a pointer to "Aech".
>
> >
> > > Also, with sufficient magic, the end iterator in a vector could be
> > some sentinel value
> >
> > no
>
> Care to elaborate? If vector::iterator were implemented as a
> full-blown class, it can have special logic to note that it has become
> the "end" iterator and use a special internal value to represent that.
>
> Also, my last question is still outstanding: "What's the use-case for
> this change to be useful?"
>

Received on 2025-12-08 16:56:12