C++ Logo

std-discussion

Advanced search

Default template parameter for uniform erasure

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Tue, 20 Oct 2020 17:23:01 +0200
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.


One might even think of broadening the question -- that is, why other
algorithms (find, remove, ...) also don't default? Surely they're all
consistent in this design, but is such consistency deliberate or simply
never addressed when introducing list initialization?


Thanks,
-- 
Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2020-10-20 10:23:08