C++ ranges are nice, but AFAIK they still "suffer" from the fact that they do not know to modify containers, e.g. if you use ranges::remove
you still need to do container.erase(...
Now there are algorithms that do know how to erase from containers (std::erase
, std::erase_if
) but unlike ranges they do not support projection.
My question if this is just because (AFAIK) that functionality was proposed separately from ranges(+ lack of time/lack of proposals), or is there fundamental reason why this functionality is not available.
std::erase
and std::erase_if
are not algorithms applicable to any container. They are an overload set of functions that do "the same thing" to many containers.
The associative containers don't have std::erase
, because it would either be inconsistent with their member erase
, or it would be inconsistent with the sequence container erase
.
I don't think there is a fundamental incompatibility with having a projection argument in erase_if
, nor in erase
where it is present, but they were defined in terms of the existing std::remove
, std::remove_if
and member erase
s and remove
s, which lack projections.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With