Often I find myself working with some STL container and wishing to modify it based on some external condition. By external, I mean something that cannot be derived from the object in the container alone.
For example, let's say I have worked out which elements of the container I want to keep based on some elaborate criterion involving not only the elements themselves. The keep flags are stored in a container of the same size as the original container. Now I want to use std::remove_if to remove those for which the flag is zero. How can I do that?
Aucun commentaire:
Enregistrer un commentaire