dimanche 22 juillet 2018

unable to use std::remove_if as it fails to work

I have a code snippet that looks like the following:

auto overOneHundred = [](Person& p){return p.getAge() > 100;};
std::remove_if(std::begin(colony), std::end(colony), overOneHundred);

This is supposed to remove people over the age of 100 from the colony of people. Assume Person has a getAge() function that returns their age in integer.

The problem is that the people are never removed from the colony even after their age exceeds 100.

Aucun commentaire:

Enregistrer un commentaire