C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Default template parameter for uniform erasure
From: Jason McKesson (jmckesson_at_[hidden])
Date: 2020-10-20 19:04:37


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 list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups