title: Difference between upper_bound and lower_bound in stl
body: <p>I was looking at how the upper_bound and lower_bound algorithms work in stl on these pages: <a href="http://www.cplusplus.com/reference/algorithm/lower_bound/" rel="noreferrer">lower_bound</a>, <a href="http://www.cplusplus.com/reference/algorithm/upper_bound/" rel="noreferrer">upper_bound</a>, and it's documented the same way on these pages: <a href="http://en.cppreference.com/w/cpp/algorithm/lower_bound" rel="noreferrer" title="lower_bound">lower_bound</a>, <a href="http://en.cppreference.com/w/cpp/algorithm/upper_bound" rel="noreferrer">upper_bound</a></p>
  
  <p>Looking at the code from the links, they seem to do exactly the same thing to me, with only the following lines being different (looking at the code from the first 2 links):</p>
  
  <p>lower_bound (line 10):</p>
  
  <pre><code>if (*it&lt;val) {                 // or: if (comp(*it,val)), for version (2)
  </code></pre>
  
  <p>upper_bound (line 10):</p>
  
  <pre><code> if (!(val&lt;*it))                // or: if (!comp(val,*it)), for version (2) 
  </code></pre>
  
  <p>but surely reversing the compared elements and then comparing them to false is a double negative, and thus they do exactly the same thing?</p>
  
  <p>Is there actually a difference that I'm just not seeing, Is this an error in the documentation on the websites? If the latter, what would be the correct way?</p>