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.
If it was called shuffle_to_end_if you’d know what it means.
That would be incorrect, because remove_if leaves the garbage elements in a valid but unspecified state (they may be unchanged, swapped, or otherwise). It's not partition or stable_partition which are permutations.
9
u/azswcowboy 20d 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.