title: std::set with user defined type, how to ensure no duplicates
body: <p>So I have an std::set which needs to keep specific ordering as well as not allowing duplicates of a user defined (by me) type. Now I can get the order to work correctly by overloading the '&lt;' operator in my type. However, the set does not appropriately detect duplicates, and to be honest I'm not entirely sure how it does this internally. I have overloaded the '==' operator, but somehow im not sure this is what the set is actually using? So the question is how does the set determine duplicates when you add values? Here is the relevant code:</p>
  
  <p>The user defined type:</p>
  
  <pre><code>//! An element used in the route calculation.
  struct RouteElem {
      int shortestToHere; // Shortest distance from the start.
      int heuristic;      // The heuristic estimate to the goal.
      Coordinate position;
      bool operator&lt;( const RouteElem&amp; other ) const
      {
          return (heuristic+shortestToHere) &lt; (other.heuristic+other.shortestToHere);
      }
      bool operator==( const RouteElem&amp; other ) const
      {
          return (position.x == other.position.x &amp;&amp; position.y == other.position.y);
      }
  };
  </code></pre>
  
  <p>So the elements are equivalent when their position is equivalent, and an element is less than another if its combined functional is less than that of the other. The sorting works, but the set will accept two elements of the same position.</p>