My goal is to check a vector of Person*
for a Person
object with the name person_name
. The vector is sorted by the names alphabetically. Making a temp Person
is the only way I've seen to get this lower_bound call to work with the name. Is there a more efficient way of doing this, or is the temp
necessary to perform the comparisons?
//person_name is a string
Person temp(person_name);
auto it = lower_bound(personVec.begin(), personVec.end(), &temp, personCompare());
if (it != personVec.end() && (*it)->getName() == person_name) {}
else { return false; }