class MyClass
{
bool operator <(const MyClass& rhs) const
{
return this->key < rhs.key;
}
}
Set needs operator< to be const
- For set, the comparator (operator<) must be a const member function because the set needs to compare elements without modifying them.