Read this question about how to compare custom objects in C++. I did not understand the operator overloading used here. What is the operator being overloaded here? Is it ()? What is the use of overloading that?
struct MyStruct
{
int key;
std::string stringValue;
MyStruct(int k, const std::string& s) : key(k), stringValue(s) {}
};
struct less_than_key
{
inline bool operator() (const MyStruct& struct1, const MyStruct& struct2)
{
return (struct1.key < struct2.key);
}
};