I've got a std::vector<Edge> edges
and I'd like to copy some items from this array into a std::vector<Edge*> outputs
using std library.
I know std::copy_if
can be used to copy a vector of pointers to a vector of pointers:
std::vector<Edge*> edges;
//setup edges
std::vector<Edge*> outputs;
std::copy_if(edges.cbegin(), edges.cend(), std::back_insert_iterator<decltype(outputs)>(outputs), [](auto edge) {
return true; //here should be some condition
});
but it's not possible to do this:
std::vector<Edge> edges;
//setup edges
std::vector<Edge*> outputs;
std::copy_if(edges.cbegin(), edges.cend(), std::back_insert_iterator<decltype(outputs)>(outputs), [](auto edge) {
return true; //here should be some condition
});
I understand why it's not possible.
My question is: Is there any algorithm that would let me do this?