title: How to create a std::set with custom comparator in C++?
body: <p>How do I create a set of pairs, the elements of which (the pairs) are sorted with a custom bool function? I write </p>
  
  <pre><code>set &lt;pair&lt;int,int&gt;,compare&gt; myset;
  </code></pre>
  
  <p>and get error : Type/value mismatch at argument 2, expected a type, got "compare"</p>
  
  <p>I have defined "compare" as</p>
  
  <pre><code>bool compare(pair &lt;int,int&gt; g1, pair &lt;int,int&gt; g2)
  {
      return (g1.second-g1.first &gt; g2.second-g2.first);
  }
  </code></pre>
  
  <p>and of course</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;set&gt;
  </code></pre>