Is stability of std::remove and std::remove_if design fail?
问题 Recently (from one SO comment) I learned that std::remove and std:remove_if are stable. Am I wrong to think this is a terrible design choice since it prevents certain optimizations? Imagine removing the first and fifth elements of a 1M std::vector . Because of stability, we can't implement remove with swap. Instead we must shift every remaining element. :( If we weren't limited by stability we could (for RA and BD iter) practically have 2 iters, one from front, second from behind, and then