<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2741: is_partitioned requirements need updating</title>
<meta property="og:title" content="Issue 2741: is_partitioned requirements need updating">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2741.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#Resolved">Resolved</a> status.</em></p>
<h3 id="2741"><a href="lwg-defects.html#2741">2741</a>. <code>is_partitioned</code> requirements need updating</h3>
<p><b>Section:</b> 26.8.5 <a href="https://wg21.link/alg.partitions">[alg.partitions]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2016-07-06 <b>Last modified:</b> 2020-05-12</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#alg.partitions">issues</a> in [alg.partitions].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<blockquote class="note">
<p>
<i>Requires:</i> <code>InputIterator</code>'s value type shall be convertible to <code>Predicate</code>'s argument type.
</p>
</blockquote>
<p>
This seems to date from the days of adaptable function objects with an <code>argument_type</code> typedef, but in 
modern C++ the predicate might not have an argument type. It could have a function template that accepts various 
arguments, so it doesn't make sense to state requirements in terms of a type that isn't well defined.
</p>

<p><i>[2016-07, Toronto Saturday afternoon issues processing]</i></p>

<p>The proposed resolution needs to be updated because the underlying wording has changed. 
Also, since the sequence is homogeneous, we shouldn't have to say that the expression is well-formed
for all elements in the range; that implies that it need not be well-formed if the range is empty.</p>
<p>Marshall and JW to reword. Status to Open</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>This wording is relative to N4594.</p>

<ol>
<li><p>Edit 26.8.5 <a href="https://wg21.link/alg.partitions">[alg.partitions]</a> as indicated:</p>

<blockquote>
<pre>
template &lt;class InputIterator, class Predicate&gt;
bool is_partitioned(InputIterator first, InputIterator last, Predicate pred);
</pre>
<blockquote>
<p>
-1- <i>Requires:</i> <del><code>InputIterator</code>'s value type shall be convertible to <code>Predicate</code>'s argument 
type</del><ins>The expression <code>pred(*i)</code> shall be well-formed for all <code>i</code> in <code>[first, last)</code></ins>.
<p/>
[&hellip;]
</p>
</blockquote>
<pre>
template &lt;class InputIterator, class OutputIterator1,
          class OutputIterator2, class Predicate&gt;
  pair&lt;OutputIterator1, OutputIterator2&gt;
  partition_copy(InputIterator first, InputIterator last,
                 OutputIterator1 out_true, OutputIterator2 out_false,
                 Predicate pred);
</pre>
<blockquote>
<p>
-12- <i>Requires:</i> <code>InputIterator</code>'s value type shall be <code>CopyAssignable</code>, and shall be writable 
(24.3.1 <a href="https://wg21.link/iterator.requirements.general">[iterator.requirements.general]</a>) to the <code>out_true</code> and <code>out_false</code> 
<code>OutputIterator</code>s, and <del>shall be convertible to <code>Predicate</code>'s argument type</del><ins>the
expression <code>pred(*i)</code> shall be well-formed for all <code>i</code> in <code>[first, last)</code></ins>. 
The input range shall not overlap with either of the output ranges.
<p/>
[&hellip;]
</p>
</blockquote>
<pre>
template&lt;class ForwardIterator, class Predicate&gt;
  ForwardIterator partition_point(ForwardIterator first,
                                  ForwardIterator last,
                                  Predicate pred);
</pre>
<blockquote>
<p>
-16- <i>Requires:</i> <del><code>ForwardIterator</code>'s value type shall be convertible to <code>Predicate</code>'s argument 
type</del><ins>The expression <code>pred(*i)</code> shall be well-formed for all <code>i</code> in <code>[first, last)</code></ins>. 
<code>[first, last)</code> shall be partitioned by <code>pred</code>, i.e. all elements that satisfy <code>pred</code> shall appear 
before those that do not.
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2019-03-17; Daniel comments and removes previous wording]</i></p>

<p>
In the recent working draft <a href="https://wg21.link/n4810">N4810</a> all the "shall be convertible to <code>Predicate</code>'s 
argument type" are gone - they were cleaned up when "The One Range" proposal <a href="https://wg21.link/p0896r4">P0896R4</a> 
had been accepted in San Diego 2018.
<p/>
I also believe that we don't need the extra wording that was suggested in the previous P/R (effectively the need to say 
that the expression <code>pred(*i)</code> is well-formed), because this follows (in a more general way) by the expression 
<code>invoke(pred, invoke(proj, e))</code> that is applied to the elements <code>e</code> of <code>[first, last)</code>.
<p/>
Therefore I'm suggesting that the resolution for this issue should be: Resolved by <a href="https://wg21.link/p0896r4">P0896R4</a>.
</p>

<p><i>[2020-05-12; Reflector discussions]</i></p>

<p>
Resolved by <a href="https://wg21.link/p0896r4">P0896R4</a>.
</p>


<p><b>Rationale:</b></p>
Resolved by <a href="https://wg21.link/p0896r4">P0896R4</a>.


<p id="res-2741"><b>Proposed resolution:</b></p>





</body>
</html>
