C++ Logo


Advanced search

Re: [forward_list] push_front is allowed to invalidate iterators and/or references?

From: Brian Bi <bbi5291_at_[hidden]>
Date: Wed, 26 Jun 2019 16:45:29 -0500
On Wed, Jun 26, 2019 at 4:35 PM Tadeus Prastowo <tadeus.prastowo_at_[hidden]>

> On Wed, Jun 26, 2019 at 11:00 PM Brian Bi <bbi5291_at_[hidden]> wrote:
> >
> > http://eel.is/c++draft/container.requirements.general#12
> >
> >> Unless otherwise specified (either explicitly or by defining a function
> in terms of other functions), invoking a container member function or
> passing a container as an argument to a library function shall not
> invalidate iterators to, or change the values of, objects within that
> container.
> Thank you very much for pointing that out. Any idea why that passage
> mentions only the word "iterator" but not "reference"?

I don't know. Maybe it's just an oversight, maybe they thought it was
obvious. I am also curious about the answer now.

> > I suppose that the first sentence of [sequence.forwardlist.modifiers]/1
> is redundant.
> Yes, unless the words "reference" and "iterator" imply different things.

Good point... they do imply different things. But I would be surprised if
there isn't also an (implied) general requirement for container member
functions to not invalidate references unless the standard specifies

> --
> Best regards,
> Tadeus

*Brian Bi*

Received on 2019-06-26 16:47:34