Date: Tue, 20 Oct 2020 20:04:37 -0400
On Tue, Oct 20, 2020 at 11:23 AM Giuseppe D'Angelo via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> Hi,
>
> With uniform container erasure merged in C++20 we've now got functions like:
>
> > template<class T, class Allocator, class U>
> > ...
> > erase(vector<T, Allocator>& c, const U& value);
>
> (return type elided).
>
> Why the template argument U isn't defaulted to T? This would allow for
> code like
>
> > erase(v, {})
>
> or similar. Neither N4009 nor P1209 seem to address the issue at all.
`U` is permitted to be any type which is equality-comparable with `T`.
As you've noted, this is common practice for algorithms, dating back
to `std::find` and many others.
Ignoring the issue of compatibility, I'm not sure if removing all
default-constructed elements of a list is common enough to warrant
making this easier for people.
<std-discussion_at_[hidden]> wrote:
>
> Hi,
>
> With uniform container erasure merged in C++20 we've now got functions like:
>
> > template<class T, class Allocator, class U>
> > ...
> > erase(vector<T, Allocator>& c, const U& value);
>
> (return type elided).
>
> Why the template argument U isn't defaulted to T? This would allow for
> code like
>
> > erase(v, {})
>
> or similar. Neither N4009 nor P1209 seem to address the issue at all.
`U` is permitted to be any type which is equality-comparable with `T`.
As you've noted, this is common practice for algorithms, dating back
to `std::find` and many others.
Ignoring the issue of compatibility, I'm not sure if removing all
default-constructed elements of a list is common enough to warrant
making this easier for people.
Received on 2020-10-20 19:04:50