Hi all, I am new to STL and I have a problem with my map. I made a class(Sort) for comparison on the map but the problem is map.find will not work or my keys are distroted or something.
Can someone explain why find was not able to locate the key?
you have to implement the logic of "operator<" not "operator<=". Look at your line 15 and 20. You have to use "<" not "<=".
(Why is it that map don't find the elements: Map knows when it found your requested element if "!Sort(elem,search) && !Sort(search,elem)", which is the definition of equivalence (neither one is smaller than the other). But this statement is never true for your Sort, since it always return true for "Sort(x,x)".)