C++ Logo


Advanced search

Subject: Default template parameter for uniform erasure
From: Giuseppe D'Angelo (giuseppe.dangelo_at_[hidden])
Date: 2020-10-20 10:23:01


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?


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

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups