[PATCH, libstdc++] Uniform container erasure for c++20.

Ville Voutilainen ville.voutilainen@gmail.com
Fri Nov 30 10:41:00 GMT 2018


On Fri, 30 Nov 2018 at 12:25, Jonathan Wakely <jwakely@redhat.com> wrote:
> Yes, that's exactly what I had in mind (and what I expect to get
> proposed for C++20 in the near future).
>
> What does everyone else think, should we go ahead and do this?

Yes, if we are confident that's what will be in C++20.

> The point is that C++20 changed forward_list (and list, for
> consistency) to return the number of removed elements. The reason for
> that is you can't easily find out the size before and after removing
> elements, because forward_list doesn't have a size() member!
> So IMHO the non-member erase should also return the size, and so that
> it's uniform it should do that for all containers not just the lists.

I don't mind forward_list being an exception. Returning the size from
other containers
is a bit pointless; presumably it would need to return a pair, and
handling that is clunky
even with structured bindings.



More information about the Libstdc++ mailing list