title: error C2672: 'operator __surrogate_func': no matching overloaded function found when using std::upper_bound
body: <p>Consider the following program</p>
  
  <pre><code>struct slot {
      int item;
      bool operator&lt;(const int&amp; right) const {
          return item &lt; right;
      }
      slot(int item) : item(item) {}
  };
  int main() {
      std::vector&lt;slot&gt; rails;
      std::lower_bound(cbegin(rails), cend(rails), 5);
      std::upper_bound(cbegin(rails), cend(rails), 5);
  }
  </code></pre>
  
  <p>I am using std::upper_bound to binary search a vector but fails while compiling</p>
  
  <pre><code>c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm(2609): error C2672: 'operator __surrogate_func': no matching overloaded function found
  </code></pre>
  
  <p>Considering the fact that <code>std::upperbound</code> uses <code>operator&lt;</code> for implicit comparison without using a predicate, I cannot find a justified reason for the compiler to complain. Moreover, the error message is not quite meaningful as I do not see a reason for using a surrogate function here. Even if it is a case of using a functor <code>less&lt;&gt;</code>, it should not be an issue as <code>slot</code> is less comparable with an integer. It's worth noting that <code>std::lower_bound</code> has an acceptable syntax.  </p>
  
  <p>Refer: <a href="http://rextester.com/WKK72283" rel="nofollow">http://rextester.com/WKK72283</a></p>