This isn't a legal comparison for use with std::set. A valid comparison needs to be a strict weak ordering. One of the properties of a strict weak ordering is that if you have three objects A, B and C if A and B are equivalent and B and C are equivalent then A and C must also be equivalent. However, with this kind of comparison this property doesn't hold. One way to do this is to use a lexicographical comparison. Ex:
My code returns true only whan a's all fields are less than b'sif (a.dir < b.dir) return true; if (a.dir > b.dir) return false; if (a.startx < b.startx) return true; if (a.startx > b.startx) return false; return a.starty < b.starty;
Interesting, thanks for sharing.