I have map where individual Colors are mapped to multiple Entities.
I want to erase all elements from the map with given value e
passed as an argument:
std::map<Color, Entity> encodedColors;
void eraseAllByValue(Entity e) {
for (auto it = encodedColors.begin(); it != encodedColors.end();) {
if (it->second == e) {
it = encodedColors.erase(it);
} else {
++it;
}
}
}
The above function works just fine, however: how can this be achieved with std::for_each
or similiar STL construct? I am having problem with creating correct Lambda expression.