Quote Originally Posted by mickey View Post
But wanting use that way above, just only to learn to use algorithm generics....how could I do?
You have to start with the last element and not the first one, that's for sure. Otherwise probably your iterators/indexes on both containers will go out of sync.

Furthermore: isn't "remove_if" above faster than your suggestion?
No, you can't get better than O(n) here - you have to check each element (so it's actually omega(n) and theta(n)).