title: Overload an operator by using a generic approach
body: <p>How can I overload an operator by using a generic approach?
  I have this situation:</p>
  
  <pre><code>struct sortByDesc1 {
      bool operator() (const pair&lt;int, int&gt; &amp;left, const pair&lt;int, int&gt; &amp;right) {
          return left.second &gt; right.second;
      }
  };
  </code></pre>
  
  <p>Change the operator <code>&gt;</code> to <code>&lt;</code></p>
  
  <pre><code>struct sortByAsc1 {
      bool operator() (const pair&lt;int, int&gt; &amp;left, const pair&lt;int, int&gt; &amp;right) {
          return left.second &lt; right.second;
      }
  };
  </code></pre>
  
  <p>Small change in the data type <code>pair&lt;int, int&gt;</code> to <code>pair&lt;float, float&gt;</code></p>
  
  <pre><code>struct sortByDesc2 {
      bool operator() (const pair&lt;float, float&gt; &amp;left, const pair&lt;float, float&gt; &amp;right) {
          return left.second &gt; right.second;
      }
  };
  </code></pre>
  
  <p>Example of use</p>
  
  <pre><code>vector&lt; pair&lt;int, int&gt; &gt; vec;
  sort(vec.begin(), vec.end(), sortByAsc1());
  </code></pre>
  
  <p>I want a generic function, is this possible?
  Eg.:</p>
  
  <pre><code># Abstracting
  sort(vec.begin(), vec.end(), generic(asc, int));
  </code></pre>