<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2191: Incorrect specification of match_results(match_results&amp;&amp;)</title>
<meta property="og:title" content="Issue 2191: Incorrect specification of match_results(match_results&amp;&amp;)">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2191.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#C++23">C++23</a> status.</em></p>
<h3 id="2191"><a href="lwg-defects.html#2191">2191</a>. Incorrect specification of <code>match_results(match_results&amp;&amp;)</code></h3>
<p><b>Section:</b> 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Pete Becker <b>Opened:</b> 2012-10-02 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>4
</p>
<p><b>View all other</b> <a href="lwg-index.html#re.results.const">issues</a> in [re.results.const].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>

<p>
28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a>/3: "Move-constructs an object of class <code>match_results</code> satisfying the same 
postconditions as Table 141."
</p>
<p>
Table 141 lists various member functions and says that their results should be the results of the corresponding member 
function calls on <code>m</code>. But <code>m</code> has been moved from, so the actual requirement ought to be based on the 
value that <code>m</code> had <em>before</em> the move construction, not on <code>m</code> itself.
</p>
<p>
In addition to that, the requirements for the copy constructor should refer to Table 141.
<p/>
<u>Ganesh</u>:
<p/>
Also, the requirements for move-assignment should refer to Table 141. Further it seems as if in Table 141 all phrases of
"for all integers <code>n &lt; m.size()</code>" should be replaced by "for all <em>unsigned</em> integers 
<code>n &lt; m.size()</code>".
</p>

<p><i>[2019-03-26; Daniel comments and provides wording]</i></p>

<p>
The previous Table 141 (Now Table 128 in <a href="https://wg21.link/n4810">N4810</a>) has been modified to cover now
the effects of move/copy constructors and move/copy assignment operators. Newly added wording now clarifies that for
move operations the corresponding values refer to the values of the move source <em>before</em> the operation has started.
<p/>
Re Ganesh's proposal: Note that no further wording is needed for the move-assignment operator, because in the current 
working draft the move-assignment operator's <i>Effects:</i> element refers already to Table 128. The suggested clarification
of <em>unsigned</em> integers has been implemented by referring to <em>non-negative</em> integers instead.
<p/>
Upon suggestion from Casey, the wording also introduces <i>Ensures:</i> elements that refer to Table 128 and as drive-by fix
eliminates a "<i>Throws:</i> Nothing." element from a <code>noexcept</code> function.
</p>

<strong>Previous resolution [SUPERSEDED]:</strong>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4810">N4810</a>.</p>

<ol>
<li><p>Add a new paragraph at the beginning of 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a> as indicated:</p>

<blockquote><p>
<ins>-?- Table 128 lists the postconditions of <code>match_results</code> copy/move constructors and copy/move assignment
operators. For move operations, the results of the expressions depending on the parameter <code>m</code> denote the values
they had before the respective function calls.</ins>
</p></blockquote>

</li>

<li><p>Modify 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a> as indicated:</p>

<blockquote>
<pre>
match_results(const match_results&amp; m);
</pre>
<blockquote>
<p>
-3- <i>Effects:</i> Constructs <del>an object of class <code>match_results</code>, as</del> a copy of <code>m</code>.
<p/>
<ins>-?- <i>Ensures:</i> As indicated in Table 128.</ins>
</p>
</blockquote>
<pre>
match_results(match_results&amp;&amp; m) noexcept;
</pre>
<blockquote>
<p>
-4- <i>Effects:</i> Move constructs <del>an object of class <code>match_results</code></del> from <code>m</code> 
<del>satisfying the same postconditions as Table 128. Additionally</del>, the stored <code>Allocator</code> value 
is move constructed from <code>m.get_allocator()</code>.
<p/>
<ins>-?- <i>Ensures:</i> As indicated in Table 128.</ins>
<p/>
<del>-5- <i>Throws:</i> Nothing.</del>
</p>
</blockquote>
<pre>
match_results&amp; operator=(const match_results&amp; m);
</pre>
<blockquote>
<p>
-6- <i>Effects:</i> Assigns <code>m</code> to <code>*this</code>. <del>The postconditions of this function are indicated 
in Table 128.</del>
<p/>
<ins>-?- <i>Ensures:</i> As indicated in Table 128.</ins>
</p>
</blockquote>
<pre>
match_results&amp; operator=(match_results&amp;&amp; m);
</pre>
<blockquote>
<p>
-7- <i>Effects:</i> Move<del>-</del><ins> </ins>assigns <code>m</code> to <code>*this</code>. <del>The postconditions of 
this function are indicated in Table 128.</del>
<p/>
<ins>-?- <i>Ensures:</i> As indicated in Table 128.</ins>
</p>
</blockquote>
</blockquote>

</li>

<li><p>Modify 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a>, Table 128 &mdash; "<code>match_results</code> assignment operator effects", as indicated:</p>

<blockquote>
<table border="1">
<caption>Table 128 &mdash; <code>match_results</code> <del>assignment operator effects</del><ins>copy/move operation postconditions</ins></caption>
<tr style="text-align:center">
<th>Element</th>
<th>Value</th>
</tr>
<tr>
<td>
<code>ready()</code>
</td>
<td>
<code>m.ready()</code>
</td>
</tr>
<tr>
<td>
<code>size()</code>
</td>
<td>
<code>m.size()</code>
</td>
</tr>
<tr>
<td>
<code>str(n)</code>
</td>
<td>
<code>m.str(n)</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
<tr>
<td>
<code>prefix()</code>
</td>
<td>
<code>m.prefix()</code>
</td>
</tr>
<tr>
<td>
<code>suffix()</code>
</td>
<td>
<code>m.suffix()</code>
</td>
</tr>
<tr>
<td>
<code>(*this)[n]</code>
</td>
<td>
<code>m[n]</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
<tr>
<td>
<code>length(n)</code>
</td>
<td>
<code>m.length(n)</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
<tr>
<td>
<code>position(n)</code>
</td>
<td>
<code>m.position(n)</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
</table>
</blockquote>


</li>

</ol>
</blockquote>

<p><i>[2021-06-25; Daniel comments and provides new wording]</i></p>

<p>
The revised wording has been rebased to <a href="https://wg21.link/n4892">N4892</a>. It replaces the now
obsolete <i>Ensures:</i> element by the <i>Postconditions:</i> element and also restores the copy constructor
prototype that has been eliminated by <a href="https://wg21.link/P1722R2" title=" Mandating the Standard Library: Clause 30 - Regular Expression library">P1722R2</a> as anchor point for the link to Table 140.
</p>

<p><i>[2021-06-30; Reflector poll]</i></p>

<p>
Set status to Tentatively Ready after six votes in favour during reflector poll. 
</p>
<p><i>[2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting &rarr; WP.]</i></p>



<p id="res-2191"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4892">N4892</a>.</p>

<ol>
<li><p>Add a new paragraph at the beginning of 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a> as indicated:</p>

<blockquote><p>
<ins>-?- Table 140 [tab:re.results.const] lists the postconditions of <code>match_results</code> copy/move constructors 
and copy/move assignment operators. For move operations, the results of the expressions depending on the parameter 
<code>m</code> denote the values they had before the respective function calls.</ins>
</p></blockquote>

</li>

<li><p>Modify 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a> as indicated:</p>

<blockquote>
<pre>
explicit match_results(const Allocator&amp; a);
</pre>
<blockquote>
<p>
-1- <i>Postconditions:</i> <code>ready()</code> returns <code>false</code>. <code>size()</code> returns <code>0</code>.
</p>
</blockquote>
<pre>
<ins>match_results(const match_results&amp; m);</ins>
</pre>
<blockquote>
<p>
<ins>-?- <i>Postconditions:</i> As specified in Table 140.</ins>
</p>
</blockquote>
<pre>
match_results(match_results&amp;&amp; m) noexcept;
</pre>
<blockquote>
<p>
-2- <i>Effects:</i> The stored <code>Allocator</code> value is move constructed from <code>m.get_allocator()</code>.
<p/>
-3- <i>Postconditions:</i> As specified in Table 140.
</p>
</blockquote>
<pre>
match_results&amp; operator=(const match_results&amp; m);
</pre>
<blockquote>
<p>
-4- <i>Postconditions:</i> As specified in Table 140.
</p>
</blockquote>
<pre>
match_results&amp; operator=(match_results&amp;&amp; m);
</pre>
<blockquote>
<p>
-5- <i>Postconditions:</i> As specified in Table 140.
</p>
</blockquote>
</blockquote>

</li>

<li><p>Modify 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a>, Table 140 &mdash; "<code>match_results</code> assignment operator effects",
[tab:re.results.const], as indicated:</p>

<blockquote>
<table border="1">
<caption>Table 140 &mdash; <code>match_results</code> <del>assignment operator effects</del><ins>copy/move operation postconditions</ins></caption>
<tr style="text-align:center">
<th>Element</th>
<th>Value</th>
</tr>
<tr>
<td>
<code>ready()</code>
</td>
<td>
<code>m.ready()</code>
</td>
</tr>
<tr>
<td>
<code>size()</code>
</td>
<td>
<code>m.size()</code>
</td>
</tr>
<tr>
<td>
<code>str(n)</code>
</td>
<td>
<code>m.str(n)</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
<tr>
<td>
<code>prefix()</code>
</td>
<td>
<code>m.prefix()</code>
</td>
</tr>
<tr>
<td>
<code>suffix()</code>
</td>
<td>
<code>m.suffix()</code>
</td>
</tr>
<tr>
<td>
<code>(*this)[n]</code>
</td>
<td>
<code>m[n]</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
<tr>
<td>
<code>length(n)</code>
</td>
<td>
<code>m.length(n)</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
<tr>
<td>
<code>position(n)</code>
</td>
<td>
<code>m.position(n)</code> for all <ins>non-negative</ins> integers <code>n &lt; m.size()</code>
</td>
</tr>
</table>
</blockquote>


</li>

</ol>





</body>
</html>
