C++ Logo


Advanced search

Subject: Re: [forward_list] push_front is allowed to invalidate iterators and/or references?
From: Brian Bi (bbi5291_at_[hidden])
Date: 2019-06-26 16:00:44


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.
> <http://eel.is/c++draft/container.requirements.general#12.sentence-1>

I suppose that the first sentence of [sequence.forwardlist.modifiers]/1 is

On Wed, Jun 26, 2019 at 3:39 PM Tadeus Prastowo via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> Hello,
> To quote http://eel.is/c++draft/sequences#forwardlist.modifiers-1:
> None of the overloads of insert_­after shall affect the validity of
> iterators and references, [...].
> And, to quote http://eel.is/c++draft/sequences#forwardlist.modifiers-3
> on push_front: Effects: Inserts a copy of x at the beginning of the
> list.
> So, there is no requirement that performing push_front on an
> std::forward_list object shall not invalidate any iterators and/or
> references.
> Isn't this a defect in the standard, considering that
> https://en.cppreference.com/w/cpp/container/forward_list/push_front
> claims that no iterators and references will be invalidated by
> push_front?
> Thank you.
> --
> Best regards,
> Tadeus
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

*Brian Bi*

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups