title: C++ <unresolved overloaded function type> with comparison function
body: <p>I am trying to implement a custom binary search to run over a vector of dates.</p>
  
  <p>My binary search function is the following:</p>
  
  <pre><code>template &lt;typename RandomAccessIterator, typename Value, typename Comparer&gt;
  inline int binary_search(RandomAccessIterator const  first, RandomAccessIterator const  last, Value const&amp; value, Comparer comparer)
  {
      RandomAccessIterator it(std::lower_bound(first, last, value, comparer));
      if (it == last || comparer(*it, value) || comparer(value, *it))
        return distance(first,last);
  
      return distance(first,it);
  }
  </code></pre>
  
  <p>The comparator I am using is defined as:</p>
  
  <pre><code>template &lt;class T&gt;
  inline bool cmp(T lhs,T rhs)
  {
    return lhs&lt;rhs;
  }
  </code></pre>
  
  <p>These two compile without issues, however, I get a compilation error when I try to call the binary_search function using the following code:</p>
  
  <pre><code>binary_search(date_list.begin(),date_list.end(),date2,cmp)
  </code></pre>
  
  <p>where date_list is a vector containing dates, date2 is an int.</p>
  
  <p>The exact error message is:</p>
  
  <pre><code>error: no matching function for call to ?binary_search(__gnu_cxx::__normal_iterator&lt;int*, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt;, __gnu_cxx::__normal_iterator&lt;int*, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt;, int&amp;, &lt;unresolved overloaded function type&gt;)?
  </code></pre>
  
  <p>Any ideas on how to solve this?</p>