The following C++ code fills a vector with a number of objects and then removes some of these objects, but it looks like it deletes the wrong ones:
vector
the elegant way would be:
std::vector photons = source->emitPhotons(); photons.erase( std::remove_if(photons.begin(), photons.end(), isUseless), photons.end());
and:
bool isUseless(const Photon& photon) { /* whatever */ }