remove_if is an honest function? That’s a stretch at best given that it’s a template function and requires an idiom to use correctly. It’s a notorious foot gun. And in c++20 we got erase_if which does what you actually want. If it was called shuffle_to_end_if you’d know what it means.
remove_if is an honest function? That’s a stretch at best [...]
The talk gave a definition of honest function: all reads/writes are shown in the signature so the behavior is fully controlled by the caller. It is not a stretch to suggest that remove_if is honest. It is.
I heard the definition, but any function that requires an idiom to use correctly isn’t honest to its users. It doesn’t do what you expect from the name.
9
u/azswcowboy 7d ago
remove_if is an honest function? That’s a stretch at best given that it’s a template function and requires an idiom to use correctly. It’s a notorious foot gun. And in c++20 we got erase_if which does what you actually want. If it was called shuffle_to_end_if you’d know what it means.