I have:
struct Coord { int row, col ; bool operator<( const Coord& other ) const { return row < other.row && col < other.col ; } } ;
I'm trying to create a map<Coord, Node*>
, where you can look up a Node*
by Coord
.
The problem is, it has bugs. Lookups into the map<Coord, Node*>
by Coord
are returning the wrong ones.
I'm having difficulty figuring out if this is appropriate or not.
Wikipedia says, map [keys] requires a strict weak ordering. Have I done this wrong? Is there a way to make it work, or should keys for a map be simple values that can be "strictly ordered"?
Basically the question is what is required for a custom struct
to work as a key for my std::map?