C++ Logo


Advanced search

Subject: Re: Sequential containers. Method erase with the iterator returned by end()
From: Andrew Schepler (aschepler_at_[hidden])
Date: 2020-04-29 11:15:24

And in particular, [sequence.reqmts]/3 says "In Tables 87 and 88, ... q
denotes a valid dereferenceable constant iterator to a, ...". The
one-argument erase entry in Table 87 is "a.erase(q)". Since a.end() is not
dereferenceable, passing it to a.erase() violates the table's implicit
requirement, and so has undefined behavior.

-- Andrew Schepler

On Wed, Apr 29, 2020 at 11:04 AM language.lawyer--- via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> On 29/04/2020 17:52, Vladimir Grigoriev via Std-Discussion wrote:
> > But looking through sections describing sequential containers I did not
> find where something is said what happens when the passed iterator is the
> iterator returned by end().
> See
> https://timsong-cpp.github.io/cppwp/n4659/sequence.reqmts#tab:containers.sequence.requirements
> https://timsong-cpp.github.io/cppwp/n4659/sequence.reqmts#11
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

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

Older Archives on Google Groups