compilation time is a plague that has been ignored in 20 years now
STL is unfriendly and over complicated. I stopped using it after finding the "imbue" function name ...
template syntax is a crazy and unreadable mess
we wrap almost every stl class/function with usable and user friendly wrappers to be used
if one of the developer ever writes code like that is getting rejected as unreadable and unmaintable
Instead of adding new things please solve these issues! At this point I don't even mind of source compatibility, just fix it, the cost would be less than keeping the actual limitations ...
auto itr = std::remove_if(vec.begin(), vec.end(), func);
vec.erase(it);
And everything else related to the begin and end functions. No other language I've used works this way, it's impossible to pipe operations in a straightforward way, and holy fuck is it verbose
People tell me it's composable and generic but wow it that gross code to write
FYI (and this reinforces your point), your code snippet is incorrect. You need to say vec.erase(itr, vec.end()); to trim the vector. Otherwise, you're erasing a single element which is bogus.
The good news is that Uniform Container Erasure has been voted into C++20, so you will be able say std::erase_if(vec, func); and be done with it. (I designed and proposed this for Library Fundamentals v2, and Alisdair Meredith proposed merging it into C++20.)
I don't know why this was downvoted. According to cppreference the single iterator version needs a dereferenceable iterator which means that you can't skip checking if itr == vec.end(). This is unlike the two iterator version which doesn't need to dereference first when it is equal to last.
10
u/QbProg Dec 28 '18
Totally agree on everything.
compilation time is a plague that has been ignored in 20 years now
STL is unfriendly and over complicated. I stopped using it after finding the "imbue" function name ...
template syntax is a crazy and unreadable mess
we wrap almost every stl class/function with usable and user friendly wrappers to be used
if one of the developer ever writes code like that is getting rejected as unreadable and unmaintable
Instead of adding new things please solve these issues! At this point I don't even mind of source compatibility, just fix it, the cost would be less than keeping the actual limitations ...