I have a typedef struct defined like so:
typedef struct myStruct {
int id;
double value;
bool operator <(const myStruct &x, const myStruct &y) {
return (x.id < y.id);
}
} myStruct;
I need to use this struct as a key in a std::map, thus the overloaded operator. However, I get the following error message when trying to compile this:
overloaded 'operator<' must be a binary operator (has 3 parameters)
Okay, so I tried this instead:
bool operator <(const pointcloud_keyframe &x) {
return (this->id < x.id);
}
However, that doesn't work either as I get this error message when trying to insert into the map:
invalid operands to binary expression ('const myStruct' and 'const myStruct')
Please help!