<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4127: The Standard Library should not use predicates of the form pred(*i) != false</title>
<meta property="og:title" content="Issue 4127: The Standard Library should not use predicates of the form pred(*i) != false">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4127.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p>
<h3 id="4127"><a href="lwg-active.html#4127">4127</a>. The Standard Library should not use predicates of the form <code>pred(*i) != false</code></h3>
<p><b>Section:</b> 22.10.18.3 <a href="https://wg21.link/func.search.bm">[func.search.bm]</a>, 22.10.18.4 <a href="https://wg21.link/func.search.bmh">[func.search.bmh]</a>, 23.2.7.1 <a href="https://wg21.link/associative.reqmts.general">[associative.reqmts.general]</a>, 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a>, 26.6.6 <a href="https://wg21.link/alg.find">[alg.find]</a>, 26.6.9 <a href="https://wg21.link/alg.find.first.of">[alg.find.first.of]</a>, 26.6.10 <a href="https://wg21.link/alg.adjacent.find">[alg.adjacent.find]</a>, 26.6.11 <a href="https://wg21.link/alg.count">[alg.count]</a>, 26.6.12 <a href="https://wg21.link/alg.mismatch">[alg.mismatch]</a>, 26.6.15 <a href="https://wg21.link/alg.search">[alg.search]</a>, 26.8.1 <a href="https://wg21.link/alg.sorting.general">[alg.sorting.general]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Hewill Kang <b>Opened:</b> 2024-07-25 <b>Last modified:</b> 2024-08-05</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#func.search.bm">active issues</a> in [func.search.bm].</p>
<p><b>View all other</b> <a href="lwg-index.html#func.search.bm">issues</a> in [func.search.bm].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The <code><i>boolean-testable</i></code> concept introduced in <a href="https://wg21.link/P1964R2" title=" Wording for boolean-testable">P1964R2</a> 
places appropriate constraints on boolean-ish types, so that <code>!pred(x)</code> or 
<code>i != last &amp;&amp; pred(*i)</code> always has a valid definition.
<p/>
Subsequently, <a href="https://wg21.link/P2167R3" title=" Improved Proposed Wording for LWG 2114 (contextually convertible to bool)">P2167R3</a> applied this concept to 26.2 <a href="https://wg21.link/algorithms.requirements">[algorithms.requirements]</a> 
p6, requiring that <code>decltype(pred(*first))</code> should model <code><i>boolean-testable</i></code>.
<p/>
However, <code><i>boolean-testable</i></code> does not guarantee that 
<code>pred(*i) != false</code> is valid, because the type may overload <code>operator==</code>.
It is necessary to replace this form of expression with an appropriate one as we do in 
<a href="https://wg21.link/P1964R2#wording">P1964R2</a>.
</p>

<p><i>[2024-07-27; Daniel comments]</i></p>

<p>
I would recommend to add a wrapping "<code><ins>bool(</ins>pred([&hellip;])<ins>)</ins></code>" and possibly 
even extend to "<code><ins>bool(</ins>pred([&hellip;])<ins>)</ins></code> <ins>is <code>true</code></ins>"
following our usual wording convention, since an English phrase of the form "if <code>pred([&hellip;])</code>" 
where <code>pred([&hellip;])</code> is potential non-<code>bool</code> and the English "if" is not a C++ language 
<code>if</code> (with built-in conversion semantics) doesn't sound like a meaningful phrase to me.
</p>

<p><i>[2024-08-02; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll. "Needs more 'is <code class='backtick'>true</code>' added".
"Would prefer not to have explicit conversions to <code class='backtick'>bool</code> unless
<i><code class='backtick'>boolean-testable</code></i> requires that.
The 'Let E be' lists don't need an 'is true' there,
but the use of 'E' should say 'is true'".
[alg.search] and [func.search.bm] have changed editorially in the draft,
the proposed resolution needs updating.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">

<p>
This wording is relative to <a href="https://wg21.link/N4986" title=" Working Draft, Programming Languages — C++">N4986</a>.
</p>

<ol>
<li><p>Modify 22.10.18.3 <a href="https://wg21.link/func.search.bm">[func.search.bm]</a> as indicated:</p>

<blockquote>
<pre>
boyer_moore_searcher(RandomAccessIterator1 pat_first,
                     RandomAccessIterator1 pat_last,
                     Hash hf = Hash(),
                     BinaryPredicate pred = BinaryPredicate());
</pre>
<blockquote>
<p>
-1- <i>Preconditions</i>: The value type of <code>RandomAccessIterator1</code> meets the
<i>Cpp17DefaultConstructible</i>, the <i>Cpp17CopyConstructible</i>, and the 
<i>Cpp17CopyAssignable</i> requirements.
<p/>
-2- Let <code>V</code> be <code>iterator_traits&lt;RandomAccessIterator1&gt;::value_type</code>.
For any two values <code>A</code> and <code>B</code> of type <code>V</code>, if
<code>pred(A, B) <del>== true</del></code>, then <code>hf(A) == hf(B)</code> is 
<code>true</code>.
</p>
[&hellip;]
<p>
-7- <i>Returns</i>: A pair of iterators <code>i</code> and <code>j</code> such that
</p>
<ol style="list-style-type: none">
<li><p>(7.1) &mdash; <code>i</code> is the first iterator in the range [<code>first</code>,
<code>last - (pat_last_ - pat_first_)</code>) such that for every non-negative integer 
<code>n</code> less than <code>pat_last_ - pat_first_</code> the following condition holds: 
<code>pred(*(i + n), *(pat_first_ + n)) <del>!= false</del></code>, and
</p>
</li>
<li>
<p>[&hellip;]</p>
</li>
</ol>
</blockquote>
</blockquote>

</li>

<li><p>Modify 22.10.18.4 <a href="https://wg21.link/func.search.bmh">[func.search.bmh]</a> as indicated:</p>

<blockquote>
<pre>
boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
                              RandomAccessIterator1 pat_last,
                              Hash hf = Hash(),
                              BinaryPredicate pred = BinaryPredicate());
</pre>
<blockquote>
<p>
-1- <i>Preconditions</i>: The value type of <code>RandomAccessIterator1</code> meets the
<i>Cpp17DefaultConstructible</i>, <i>Cpp17CopyConstructible</i>, and <i>Cpp17CopyAssignable</i>
requirements.
<p/>
-2- Let <code>V</code> be <code>iterator_traits&lt;RandomAccessIterator1&gt;::value_type</code>.
For any two values <code>A</code> and <code>B</code> of type <code>V</code>, if  
<code>pred(A, B) <del>== true</del></code>, then <code>hf(A) == hf(B)</code> is <code>true</code>.
</p>
[&hellip;]
<p>
-7- <i>Returns</i>: A pair of iterators <code>i</code> and <code>j</code> such that
</p>
<ol style="list-style-type: none">
<li><p>
(7.1) &mdash; <code>i</code> is the first iterator in the range [<code>first</code>,
<code>last - (pat_last_ - pat_first_)</code>) such that for every non-negative integer <code>n</code> 
less than <code>pat_last_ - pat_first_</code> the following condition holds: 
<code>pred(*(i + n), *(pat_first_ + n)) <del>!= false</del></code>, and 
</p></li>
<li>
<p>[&hellip;]</p>
</li>
</ol>
</blockquote>
</blockquote>

</li>

<li><p>Modify 23.2.7.1 <a href="https://wg21.link/associative.reqmts.general">[associative.reqmts.general]</a> as indicated:</p>

<blockquote>
<p>
-3- The phrase "equivalence of keys" means the equivalence relation imposed by the comparison object.
That is, two keys <code>k1</code> and <code>k2</code> are considered to be equivalent if for the 
comparison object <code>comp</code>, <code><ins>!</ins>comp(k1, k2) <del>== false</del> &amp;&amp; 
<ins>!</ins>comp(k2, k1) <del>== false</del></code>.
</p>
[&hellip;]
<p>
-177- The fundamental property of iterators of associative containers is that they iterate through 
the containers in the non-descending order of keys where non-descending is defined by the comparison 
that was used to construct them. For any two dereferenceable iterators <code>i</code> and <code>j</code> 
such that distance from <code>i</code> to <code>j</code> is positive, the following condition holds:
</p>
<pre><blockquote><ins>!</ins>value_comp(*j, *i) <del>== false</del></blockquote></pre>
<p>
-178- For associative containers with unique keys the stronger condition holds:
</p>
<pre><blockquote>value_comp(*i, *j) <del>!= false</del></blockquote></pre>
</blockquote>

</li>

<li><p>Modify 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> as indicated:</p>

<blockquote>
<pre>
size_type remove(const T&amp; value);
template&lt;class Predicate&gt; size_type remove_if(Predicate pred);
</pre>
<blockquote>
<p>
-15- <i>Effects</i>: Erases all the elements in the list referred to by a list iterator 
<code>i</code> for which the following conditions hold: <code>*i == value, pred(*i) 
<del>!= false</del></code>. Invalidates only the iterators and references to
the erased elements.
<p/>
-16- <i>Returns</i>: The number of elements erased.
<p/>
-17- <i>Throws</i>: Nothing unless an exception is thrown by <code>*i == value</code> or
<code>pred(*i) <del>!= false</del></code>.
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>

</li>

<li><p>Modify 26.6.6 <a href="https://wg21.link/alg.find">[alg.find]</a> as indicated:</p>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li>
<p>(1.1) &mdash; <code>*i == value</code> for <code>find</code>;</p>
</li>
<li>
<p>(1.2) &mdash; <code>pred(*i) <del>!= false</del></code> for <code>find_if</code>;</p>
</li>
<li>
<p>(1.3) &mdash; <code><ins>!</ins>pred(*i) <del>== false</del></code> for <code>find_if_not</code>;
</p>
[&hellip;]
</li>
</ol>
</blockquote>

</li>

<li><p>Modify 26.6.9 <a href="https://wg21.link/alg.find.first.of">[alg.find.first.of]</a> as indicated:</p>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(1.1) &mdash; <code>*i == *j</code> for the overloads with no parameter <code>pred</code>;
</p></li>
<li><p>
(1.2) &mdash; <code>pred(*i, *j) <del>!= false</del></code> for the overloads with a parameter
<code>pred</code> and no parameter <code>proj1</code>;
</p>
[&hellip;]
</li>
</ol>
</blockquote>

</li>

<li><p>Modify 26.6.10 <a href="https://wg21.link/alg.adjacent.find">[alg.adjacent.find]</a> as indicated:</p>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(1.1) &mdash; <code>*i == *(i + 1)</code> for the overloads with no parameter <code>pred</code>;
</p></li>
<li><p>
(1.2) &mdash; <code>pred(*i, *(i + 1)) <del>!= false</del></code> for the overloads with a 
parameter <code>pred</code> and no parameter <code>proj1</code>;
</p>
[&hellip;]
</li>
</ol>
</blockquote>

</li>

<li><p>Modify 26.6.11 <a href="https://wg21.link/alg.count">[alg.count]</a> as indicated:</p>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(1.1) &mdash; <code>*i == value</code> for the overloads with no parameter <code>pred</code> 
or <code>proj</code>;
</p></li>
<li><p>
(1.2) &mdash; <code>pred(*i) <del>!= false</del></code> for the overloads with a parameter
<code>pred</code> but no parameter <code>proj</code>;
</p>
[&hellip;]
</li>
</ol>
</blockquote>

</li>

<li><p>Modify 26.6.12 <a href="https://wg21.link/alg.mismatch">[alg.mismatch]</a> as indicated:</p>

<blockquote>
<p>
-2- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(2.1) &mdash; <code>!(*(first1 + n) == *(first2 + n))</code> for the overloads with no 
parameter <code>pred</code>;
</p></li>
<li><p>
(2.2) &mdash; <code><ins>!</ins>pred(*(first1 + n), *(first2 + n)) <del>== false</del></code> 
for the overloads with a parameter <code>pred</code> and no parameter <code>proj1</code>;
</p>
[&hellip;]
</li>
</ol>
</blockquote>

</li>

<li><p>Modify 26.6.15 <a href="https://wg21.link/alg.search">[alg.search]</a> as indicated:</p>

<blockquote>
<p>
-1- <i>Returns</i>: The first iterator <code>i</code> in the range [<code>first1</code>,
<code>last1 - (last2-first2)</code>) such that for every non-negative integer <code>n</code> 
less than <code>last2 - first2</code> the following corresponding conditions hold:
<code>*(i + n) == *(first2 + n), pred(*(i + n), *(first2 + n)) <del>!= false</del></code>.
Returns <code>first1</code> if [<code>first2</code>, <code>last2</code>) is empty, otherwise 
returns <code>last1</code> if no such iterator is found.
</p>
[&hellip;]
<p>
-6- <i>Returns</i>: The first iterator <code>i</code> in the range [<code>first</code>,
<code>last-count</code>) such that for every non-negative integer <code>n</code> less than 
<code>count</code> the following corresponding conditions hold: <code>*(i + n) == value, 
pred(*(i + n), value) <del>!= false</del></code>. Returns <code>last</code> if no such 
iterator is found.
</p>
</blockquote>

</li>

<li><p>Modify 26.8.1 <a href="https://wg21.link/alg.sorting.general">[alg.sorting.general]</a> as indicated:</p>

<blockquote>
<p>
-3- For all algorithms that take <code>Compare</code>, there is a version that uses 
<code>operator&lt;</code> instead. That is, <code>comp(*i, *j) <del>!= false</del></code> 
defaults to <code>*i &lt; *j <del>!= false</del></code>. For algorithms other than those 
described in 26.8.4 <a href="https://wg21.link/alg.binary.search">[alg.binary.search]</a>, <code>comp</code> shall induce a strict 
weak ordering on the values.
</p>
</blockquote>

</li>

</ol>
</blockquote>

<p><i>[2024-08-03; Daniel provides improved wording]</i></p>

<p>
The current wording is inconsistent in regard to explicit conversion to <code>bool</code>
and lack of them in cases of expressions whose value is required to satisfy the
<code><i>boolean-testable</i></code> constraints. To realize consistent results for
all subclause references touched by the changes required by this issue I decided
that every <i>E</i> <b>definition</b> remains unconverted but and that every <i>E</i>
<b>evaluation</b> is interpreted as if an implied <code>bool</code> conversion has
been applied based on the reflector preference for that simplified approach.
<p/>
Nonetheless, during the wording preparation I noticed that the wording in the 
<i>Throws</i>: element 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> p17 is seriously <b>missing</b> the 
additional extra conversion to <code>bool</code> for both expressions, because the 
<code><i>boolean-testable</i></code> requirements do not impose a no-throw requirement for 
that conversion, and they must therefore be included here.
<p/>
This problem will be handled by a separate issue (LWG <a href="lwg-active.html#4132" title="Throws specifications need to include boolean-testable operations (Status: New)">4132</a><sup><a href="https://cplusplus.github.io/LWG/issue4132" title="Latest snapshot">(i)</a></sup>), because the 
rationale for this change is different from the actual target of this issue and not 
related to the other consistency adjustments done by the wording below.
</p>


<p id="res-4127"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4988" title=" Working Draft, Programming Languages — C++">N4988</a>.
</p>

<ol>
<li><p>Modify 22.10.18.3 <a href="https://wg21.link/func.search.bm">[func.search.bm]</a> as indicated:</p>

<blockquote>
<pre>
boyer_moore_searcher(RandomAccessIterator1 pat_first,
                     RandomAccessIterator1 pat_last,
                     Hash hf = Hash(),
                     BinaryPredicate pred = BinaryPredicate());
</pre>
<blockquote>
<p>
-1- <i>Preconditions</i>: The value type of <code>RandomAccessIterator1</code> meets the
<i>Cpp17DefaultConstructible</i>, <i>Cpp17CopyConstructible</i>, and 
<i>Cpp17CopyAssignable</i> requirements.
<p/>
-2- Let <code>V</code> be <code>iterator_traits&lt;RandomAccessIterator1&gt;::value_type</code>.
For any two values <code>A</code> and <code>B</code> of type <code>V</code>, if
<code>pred(A, B) <del>== true</del></code> <ins>is <code>true</code></ins>, then 
<code>hf(A) == hf(B)</code> is <code>true</code>.
</p>
[&hellip;]
</blockquote>
<pre>
template&lt;class RandomAccessIterator2&gt;
  pair&lt;RandomAccessIterator2, RandomAccessIterator2&gt;
    operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-7- <i>Returns</i>: A pair of iterators <code>i</code> and <code>j</code> such that
</p>
<ol style="list-style-type: none">
<li><p>(7.1) &mdash; <code>i</code> is the first iterator in the range [<code>first</code>,
<code>last - (pat_last_ - pat_first_)</code>) such that for every non-negative integer 
<code>n</code> less than <code>pat_last_ - pat_first_</code> the following condition holds: 
<code>pred(*(i + n), *(pat_first_ + n)) <del>!= false</del></code> <ins>is <code>true</code></ins>, and
</p>
</li>
<li><p>(7.2) &mdash; <code>j == next(i, distance(pat_first_, pat_last_))</code> <ins>is <code>true</code></ins>.
</p>
</li>
</ol>
</blockquote>
</blockquote>

</li>

<li><p>Modify 22.10.18.4 <a href="https://wg21.link/func.search.bmh">[func.search.bmh]</a> as indicated:</p>

<blockquote>
<pre>
boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
                              RandomAccessIterator1 pat_last,
                              Hash hf = Hash(),
                              BinaryPredicate pred = BinaryPredicate());
</pre>
<blockquote>
<p>
-1- <i>Preconditions</i>: The value type of <code>RandomAccessIterator1</code> meets the
<i>Cpp17DefaultConstructible</i>, <i>Cpp17CopyConstructible</i>, and <i>Cpp17CopyAssignable</i>
requirements.
<p/>
-2- Let <code>V</code> be <code>iterator_traits&lt;RandomAccessIterator1&gt;::value_type</code>.
For any two values <code>A</code> and <code>B</code> of type <code>V</code>, if  
<code>pred(A, B) <del>==</del> <ins>is</ins> true</code>, then <code>hf(A) == hf(B)</code> is 
<code>true</code>.
</p>
[&hellip;]
</blockquote>
<pre>
template&lt;class RandomAccessIterator2&gt;
  pair&lt;RandomAccessIterator2, RandomAccessIterator2&gt;
    operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-7- <i>Returns</i>: A pair of iterators <code>i</code> and <code>j</code> such that
</p>
<ol style="list-style-type: none">
<li><p>
(7.1) &mdash; <code>i</code> is the first iterator in the range [<code>first</code>,
<code>last - (pat_last_ - pat_first_)</code>) such that for every non-negative integer <code>n</code> 
less than <code>pat_last_ - pat_first_</code> the following condition holds: 
<code>pred(*(i + n), *(pat_first_ + n)) <del>!= false</del></code> <ins>is <code>true</code></ins>, and 
</p></li>
<li><p>(7.2) &mdash; <code>j == next(i, distance(pat_first_, pat_last_))</code> <ins>is <code>true</code></ins>.
</p>
</li>
</ol>
</blockquote>
</blockquote>

</li>

<li><p>Modify 23.2.7.1 <a href="https://wg21.link/associative.reqmts.general">[associative.reqmts.general]</a> as indicated:</p>

<blockquote>
<p>
-3- The phrase "equivalence of keys" means the equivalence relation imposed by the comparison object.
That is, two keys <code>k1</code> and <code>k2</code> are considered to be equivalent if for the 
comparison object <code>comp</code>, <code><ins>!</ins>comp(k1, k2) <del>== false</del> &amp;&amp; 
<ins>!</ins>comp(k2, k1) <del>== false</del></code> <ins>is <code>true</code></ins>.
</p>
[&hellip;]
<p>
-177- The fundamental property of iterators of associative containers is that they iterate through 
the containers in the non-descending order of keys where non-descending is defined by the comparison 
that was used to construct them. For any two dereferenceable iterators <code>i</code> and <code>j</code> 
such that distance from <code>i</code> to <code>j</code> is positive, the following condition holds:
</p>
<blockquote><p><code><ins>!</ins>value_comp(*j, *i) <del>== false</del></code> <ins>is <code>true</code>.</ins></p></blockquote>
<p>
-178- For associative containers with unique keys the stronger condition holds:
</p>
<blockquote><p><code>value_comp(*i, *j) <del>!= false</del></code> <ins>is <code>true</code>.</ins></p></blockquote>
</blockquote>

</li>

<li><p>Modify 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> as indicated:</p>

<blockquote>
<pre>
size_type remove(const T&amp; value);
template&lt;class Predicate&gt; size_type remove_if(Predicate pred);
</pre>
<blockquote>
<p>
-15- <i>Effects</i>: Erases all the elements in the list referred to by a list iterator 
<code>i</code> for which the following conditions hold: <code>*i == value</code> 
<ins>is <code>true</code></ins>, <code>pred(*i) <del>!= false</del></code> <ins>is <code>true</code></ins>. 
Invalidates only the iterators and references to the erased elements.
<p/>
-16- <i>Returns</i>: The number of elements erased.
<p/>
-17- <i>Throws</i>: Nothing unless an exception is thrown by <code>*i == value</code> or
<code>pred(*i) <del>!= false</del></code>.
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>

</li>

<li><p>Modify 26.6.6 <a href="https://wg21.link/alg.find">[alg.find]</a> as indicated:</p>

<blockquote class="note">
<p>
[<i>Drafting note</i>: Sub-bullets (1.4), (1.5), and (1.6) below regarding
<code>invoke</code> expressions are similarly required model <code><i>boolean-testable</i></code>,
as specified by concept <code>predicate</code> (18.7.4 <a href="https://wg21.link/concept.predicate">[concept.predicate]</a>), therefore
the explicit conversion is removed here for consistency]
</p>
</blockquote>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li>
<p>(1.1) &mdash; <code>*i == value</code> for <code>find</code>;</p>
</li>
<li>
<p>(1.2) &mdash; <code>pred(*i) <del>!= false</del></code> for <code>find_if</code>;</p>
</li>
<li>
<p>(1.3) &mdash; <code><ins>!</ins>pred(*i) <del>== false</del></code> for <code>find_if_not</code>;</p>
</li>
<li>
<p>(1.4) &mdash; <code><del>bool(</del>invoke(proj, *i) == value<del>)</del></code> for <code>ranges::find</code>;</p>
</li>
<li>
<p>(1.5) &mdash; <code><del>bool(</del>invoke(pred, invoke(proj, *i))<del>)</del></code> for <code>ranges::find_if</code>;</p>
</li>
<li>
<p>(1.6) &mdash; <code><del>bool(</del>!invoke(pred, invoke(proj, *i))<del>)</del></code> for <code>ranges::find_if_not</code>.</p>
</li>
</ol>
<p>
-2- <i>Returns</i>: The first iterator <code>i</code> in the range <code>[first, last)</code> for which 
<i>E</i> is <code>true</code>. Returns <code>last</code> if no such iterator is found.
</p>
</blockquote>

</li>

<li><p>Modify 26.6.9 <a href="https://wg21.link/alg.find.first.of">[alg.find.first.of]</a> as indicated:</p>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(1.1) &mdash; <code>*i == *j</code> for the overloads with no parameter <code>pred</code>;
</p></li>
<li><p>
(1.2) &mdash; <code>pred(*i, *j) <del>!= false</del></code> for the overloads with a parameter
<code>pred</code> and no parameter <code>proj1</code>;
</p></li>
<li><p>
(1.3) &mdash; <code><del>bool(</del>invoke(pred, invoke(proj1, *i), invoke(proj2, *j))<del>)</del></code> 
for the overloads with parameters <code>pred</code> and <code>proj1</code>.
</p>
</li>
</ol>
<p>
[&hellip;]
<p/>
-3- <i>Returns</i>: The first iterator <code>i</code> in the range <code>[first1, last1)</code> such that 
for some iterator <code>j</code> in the range <code>[first2, last2)</code> <i>E</i> <del>holds</del> 
<ins>is <code>true</code></ins>. Returns <code>last1</code> if <code>[first2, last2)</code> is empty or if no 
such iterator is found.
</p>
</blockquote>

</li>

<li><p>Modify 26.6.10 <a href="https://wg21.link/alg.adjacent.find">[alg.adjacent.find]</a> as indicated:</p>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(1.1) &mdash; <code>*i == *(i + 1)</code> for the overloads with no parameter <code>pred</code>;
</p></li>
<li><p>
(1.2) &mdash; <code>pred(*i, *(i + 1)) <del>!= false</del></code> for the overloads with a 
parameter <code>pred</code> and no parameter <code>proj</code>;
</p></li>
<li><p>
(1.3) &mdash; <code><del>bool(</del>invoke(pred, invoke(proj, *i), invoke(proj, *(i + 1)))<del>)</del></code> 
for the overloads with both parameters <code>pred</code> and <code>proj</code>.
</p></li>
</ol>
<p>
-2- <i>Returns</i>: The first iterator <code>i</code> such that both <code>i</code> and <code>i + 1</code> are 
in the range <code>[first, last)</code> for which <i>E</i> <del>holds</del> <ins>is <code>true</code></ins>.
Returns <code>last</code> if no such iterator is found.
</p>
</blockquote>

</li>

<li><p>Modify 26.6.11 <a href="https://wg21.link/alg.count">[alg.count]</a> as indicated:</p>

<blockquote>
<p>
-1- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(1.1) &mdash; <code>*i == value</code> for the overloads with no parameter <code>pred</code> 
or <code>proj</code>;
</p></li>
<li><p>
(1.2) &mdash; <code>pred(*i) <del>!= false</del></code> for the overloads with a parameter
<code>pred</code> but no parameter <code>proj</code>;
</p></li>
<li><p>
(1.3) &mdash; <code>invoke(proj, *i) == value</code> for the overloads with a parameter <code>proj</code> 
but no parameter <code>pred</code>;
</p></li>
<li><p>
(1.4) &mdash; <code><del>bool(</del>invoke(pred, invoke(proj, *i))<del>)</del></code> for the 
overloads with both parameters <code>proj</code> and <code>pred</code>.
</p></li>
</ol>
<p>
-2- <i>Effects</i>: Returns the number of iterators <code>i</code> in the range <code>[first, last)</code> 
for which <i>E</i> <del>holds</del> <ins>is <code>true</code></ins>.
</p>
</blockquote>

</li>

<li><p>Modify 26.6.12 <a href="https://wg21.link/alg.mismatch">[alg.mismatch]</a> as indicated:</p>

<blockquote>
<p>
-2- Let <i>E</i> be:
</p>
<ol style="list-style-type: none">
<li><p>
(2.1) &mdash; <code>!(*(first1 + n) == *(first2 + n))</code> for the overloads with no 
parameter <code>pred</code>;
</p></li>
<li><p>
(2.2) &mdash; <code><ins>!</ins>pred(*(first1 + n), *(first2 + n)) <del>== false</del></code> 
for the overloads with a parameter <code>pred</code> and no parameter <code>proj1</code>;
</p></li>
<li><p>
(2.3) &mdash; <code>!invoke(pred, invoke(proj1, *(first1 + n)), invoke(proj2, *(first2 + n)))</code> 
for the overloads with both parameters <code>pred</code> and <code>proj1</code>.
</p></li>
</ol>
<p>
[&hellip;]
<p/>
-4- <i>Returns</i>: <code>{ first1 + n, first2 + n }</code>, where <code>n</code> is the smallest integer 
in [<code>0</code>, <i>N</i>) such that <i>E</i> <del>holds</del> <ins>is <code>true</code></ins>,
or <i>N</i> if no such integer exists.
</p>
</blockquote>

</li>

<li><p>Modify 26.6.15 <a href="https://wg21.link/alg.search">[alg.search]</a> as indicated:</p>

<blockquote>
<p>
-1- <i>Returns</i>: The first iterator <code>i</code> in the range [<code>first1</code>,
<code>last1 - (last2-first2)</code>) such that for every non-negative integer <code>n</code> 
less than <code>last2 - first2</code> the following corresponding conditions hold:
<code>*(i + n) == *(first2 + n)</code> <ins>is <code>true</code></ins>, 
<code>pred(*(i + n), *(first2 + n)) <del>!= false</del></code> <ins>is <code>true</code></ins>.
Returns <code>first1</code> if [<code>first2</code>, <code>last2</code>) is empty, otherwise 
returns <code>last1</code> if no such iterator is found.
</p>
[&hellip;]
<p>
-6- Let <i>E</i> be <code>pred(*(i + n), value) <del>!= false</del></code> for the overloads with 
a parameter <code>pred</code>, and <code>*(i + n) == value</code> otherwise.
<p/>
-7- <i>Returns</i>: The first iterator <code>i</code> in the range <code>[first, last - count)</code> 
such that for every non-negative integer <code>n</code> less than <code>count</code> the condition <i>E</i> 
is <code>true</code>. Returns <code>last</code> if no such iterator is found.
</p>
</blockquote>

</li>

<li><p>Modify 26.8.1 <a href="https://wg21.link/alg.sorting.general">[alg.sorting.general]</a> as indicated:</p>

<blockquote class="note">
<p>
[<i>Drafting note</i>: The wording below does not require extra "is <code>true</code>" added to
the adjusted expressions. This is comparable to the <i>E</i> cases above, since
26.8.1 <a href="https://wg21.link/alg.sorting.general">[alg.sorting.general]</a> p2 already points out:
</p>
<blockquote><p>
The return value of the function call operation applied to an object of type <code>Compare</code>,
when converted to <code>bool</code>, yields <code>true</code> if the first argument of the call is 
less than the second, and <code>false</code> otherwise.
</p></blockquote>
<p>
]
</p>
</blockquote>

<blockquote>
<p>
-3- For all algorithms that take <code>Compare</code>, there is a version that uses 
<code>operator&lt;</code> instead. That is, <code>comp(*i, *j) <del>!= false</del></code> 
defaults to <code>*i &lt; *j <del>!= false</del></code>. For algorithms other than those 
described in 26.8.4 <a href="https://wg21.link/alg.binary.search">[alg.binary.search]</a>, <code>comp</code> shall induce a strict 
weak ordering on the values.
</p>
</blockquote>

</li>

</ol>





</body>
</html>
