Is there a standard algorithm that I can use to subset a vector of structs by a vector of pointers to these structs?
E.g.
typedef struct {
int a;
char b;
} some_struct_t;
int main()
{
std::vector<some_struct_t> v = { {10, '1'}, { 5, '2'} };
std::vector<some_struct_t*> v2;
std::some_subset_command<some_struct_t, some_struct_t*>(begin(v), end(v), std::back_inserter(v2), [](const somestruct&) { if (somestruct.a == 5) { return &somestruct; }});
}
some_subset_command()
should construct the new vector using the back_inserter
and the output from the lambda predicate.
How can I do this in the most declarative way?