C++ Logo

std-discussion

Advanced search

Re: Sequential containers. Method erase with the iterator returned by end()

From: Andrew Schepler <aschepler_at_[hidden]>
Date: Wed, 29 Apr 2020 12:15:24 -0400
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
>

Received on 2020-04-29 11:18:35