samedi 11 mars 2017

How to obtain a subset of vector's pointer elements?

I have a vector of unique_ptr Foo objects. I want to get a collection of all vector items that match some condition. I see the std functions but they all seem to test for a predicate (and return bool) or return a single element.

Is there a built-in mechanism to get a collection that's a subset of a vector? If not, is there a way to construct an iterator that tests items against an arbitrary predicate (to identify ones that meet my condition) and a mechanism to return all items that meet that predicate?

Aucun commentaire:

Enregistrer un commentaire