title: C++: how to use std::less<int> with boost::bind and boost::lambda?
body: <p>I am trying to lean boost::bind, boost::lambda libraries and how they can be used with STL algorithms. Suppose I have vector of int-string pairs which is sorted by int key. Then a place to insert a new pair while keeping the vector sorted can be found as follows:</p>
  
  <pre><code>std::vector&lt;std::pair&lt;int, string&gt; &gt; entries;
  ...
  int k = ...;
  
  // Let's ignore std::lower_bound return value for now
  std::lower_bound (entries.begin(), entries.end(), k, 
                    boost::bind (&amp;std::pair&lt;int, string&gt;::first, _1) &lt; k)
  </code></pre>
  
  <p>Now I would like to replace <code>operator&lt;</code> with a function object (of type <code>std::less&lt;int&gt;</code> in this example):</p>
  
  <pre><code>std::less&lt;int&gt; comparator;
  </code></pre>
  
  <p>How do I change the code above so it works? I cannot just do</p>
  
  <pre><code>std::lower_bound (entries.begin(), entries.end(), k, 
                    comparator (boost::bind (&amp;std::pair&lt;int, string&gt;::first, _1), k))
  </code></pre>
  
  <p>because <code>std::less&lt;int&gt;::operator()</code> does not accept whatever is the return type of <code>boost::bind</code>. What am I missing here? TIA</p>