I would like to loop on a vector and filter out all the non-nullpointer elements. I'm looking for either an std function that checks for something being a nullptr or an std function that actually returns whatever is passed to it (like std::forward), since a nullpointer would evaluate to false.
std::copy_if(dynamicObjects.begin(), dynamicObjects.end(),
std::back_inserter(existingObjects),
std::is_pointer<ObjectType*>); // This does not compile
std::copy_if(dynamicObjects.begin(), dynamicObjects.end(),
std::back_inserter(existingObjects),
std::forwad<ObjectType*>); // This does not compile either
std::copy_if(dynamicObjects.begin(), dynamicObjects.end(),
std::back_inserter(existingObjects),
[] (const auto a) { return a; } ); // This is awkward
Aucun commentaire:
Enregistrer un commentaire