title: Why does std::binary_search return bool?
body: <p>According to draft <a href="http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4431.pdf" rel="noreferrer">N4431</a>, the function <code>std::binary_search</code> in the algorithms library returns a <code>bool</code>, [binary.search]:</p>
  
  <blockquote>
  <pre><code>  template&lt;class ForwardIterator, class T&gt;
    bool binary_search(ForwardIterator first, ForwardIterator last,
                       const T&amp; value);
  
    template&lt;class ForwardIterator, class T, class Compare&gt;
    bool binary_search(ForwardIterator first, ForwardIterator last,
                       const T&amp; value, Compare comp);
  </code></pre>
    
    <p><em>Requires</em>: The elements <code>e</code> of <code>[first,last)</code> are partitioned with respect to the expressions <code>e &lt; value</code> and <code>!(value &lt; e)</code> or <code>comp(e, value)</code> and <code>!comp(value, e)</code>. Also, for all elements <code>e</code> of <code>[first,last)</code>, <code>e &lt; value</code> implies <code>!(value &lt; e)</code> or <code>comp(e, value)</code> <code>implies !comp(value, e)</code>.</p>
    
    <p><em>Returns</em>: <code>true</code> if there is an iterator <code>i</code> in the range <code>[first,last)</code> that satisfies the corresponding conditions:
    <code>!(*i &lt; value) &amp;&amp; !(value &lt; *i)</code> or <code>comp(*i, value) == false &amp;&amp; comp(value, *i) ==
    false</code>.</p>
    
    <p><em>Complexity</em>: At most log<sub>2</sub>(last - first) + O(1) comparisons.</p>
  </blockquote>
  
  <p>Does anyone know why this is the case?  </p>
  
  <p>Most other generic algorithms either return an iterator to the element or an iterator that is equivalent to the iterator denoting the end of the sequence of elements (i.e., one after the last element to be considered in the sequence), which is what I would have expected.</p>