In code I have queue of Events
sorted by waitTime
. I want to find which Events
should be executed for the current moment, so I do this:
std::vector<Event>::iterator up = std::upper_bound(queue.begin(), queue.end(), currentTime);
The std::upper_bound
will work if I overload <
operator:
bool Event::operator<(const double& currentTime) const
{
return waitTime <= currentTime;
}
But I have an error:
error: no match for ‘operator<’ (operand types are ‘const double’ and ‘Event’)
How should I correctly overload ‘operator<’ ?
Aucun commentaire:
Enregistrer un commentaire