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

Jonathan Wakely jwakely@redhat.com
Fri Nov 30 11:01:00 GMT 2018


On 30/11/18 12:40 +0200, Ville Voutilainen wrote:
>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.

We're not, but we don't need to be. Anything in the current draft
could get removed before the final standard.

>> 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

Oops, I meant "should also return the number of removed elements", not
"the number of removed element and also the new size".


>> 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.

No need for a pair, sorry for the confusing wording above.




More information about the Libstdc++ mailing list