title: How can I overload the compare operator for a set of pairs?
body: <p>How can I overload and pass a <code>&lt;</code> (less than) comparator to a set of pairs of integers? This is my current code:</p>
  
  <pre><code>class A{
  public:
      typedef std::pair&lt;int, int&gt; pair_type;  
  
      bool operator&lt;(const pair_type&amp; a, const pair_type&amp; b){ 
          if (a.first &lt; b.first) return true;
          else if ( (a.first == b.first) &amp;&amp; (a.second &lt; b.second) ) return true;
          else return false;
      }
  
  private:
      std::set&lt; pair_type &gt; edge_;
  };
  </code></pre>
  
  <p>If I try to compile this code, then I get the following error:</p>
  
  <pre><code>error: 'bool A::operator&lt;(const pair_type&amp;, const pair_type&amp;)' must take exactly one argument
  </code></pre>
  
  <p>How can I fix it?</p>