<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2195: Missing constructors for match_results</title>
<meta property="og:title" content="Issue 2195: Missing constructors for match_results">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2195.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="2195"><a href="lwg-defects.html#2195">2195</a>. Missing constructors for <code>match_results</code></h3>
<p><b>Section:</b> 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2012-10-06 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#re.results">issues</a> in [re.results].</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>
The requirement expressed in 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> p2
</p>
<blockquote><p>
The class template <code>match_results</code> shall satisfy the requirements of an allocator-aware container and of a
sequence container, as specified in 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a>, except that only operations defined for 
const-qualified sequence containers are supported.
</p></blockquote>
<p>
can be read to require the existence of the described constructors from as well, but they do not exist in the
synopsis. 
<p/>
The missing sequence constructors are: 
</p>
<blockquote><pre>
match_results(initializer_list&lt;value_type&gt;);
match_results(size_type, const value_type&amp;);
template&lt;class InputIterator&gt; match_results(InputIterator, InputIterator);
</pre></blockquote>
<p>
The missing allocator-aware container constructors are:
</p>
<blockquote><pre>
match_results(const match_results&amp;, const Allocator&amp;);
match_results(match_results&amp;&amp;, const Allocator&amp;);
</pre></blockquote>
<p>
It should be clarified, whether (a) constructors are an exception of above mentioned operations or (b) whether
at least some of them (like those accepting a <code>match_results</code> value and an allocator) should be added.
<p/>
As visible in several places of the standard (including the core language), constructors seem usually to be considered 
as "operations" and they certainly can be invoked for const-qualified objects.
<p/>
The below given proposed resolution applies only the minimum necessary fix, i.e. it excludes constructors from
above requirement. 
</p>

<p><i>[2013-04-20, Bristol]</i></p>

<p>Check current implementations to see what they do and, possibly, write a paper.</p>

<p><i>[2013-09 Chicago]</i></p>

<p>Ask Daniel to update the proposed wording to include the allocator copy and move constructors.</p>

<p><i>[2014-01-18 Daniel changes proposed resolution]</i></p>

<p><strong>Previous resolution from Daniel [SUPERSEDED]:</strong></p>

<blockquote class="note">
<ol>
<li><p>Change 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> p2 as indicated:</p>
<blockquote><p>
The class template <code>match_results</code> shall satisfy the requirements of an allocator-aware container and of a
sequence container, as specified in 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a>, except that only operations defined for 
const-qualified sequence containers <ins>that are not constructors</ins> are supported.
</p></blockquote>
</li>
</ol>
</blockquote>

<p><i>[2015-05-06 Lenexa]</i></p>

<p>MC passes important knowledge to EF.</p>
<p>VV, RP: Looks good.</p>
<p>TK: Second form should be conditionally noexcept</p>
<p>JY: Sequence constructors are not here, but mentioned in the issue writeup. Why?</p>
<p>TK: That would have been fixed by the superseded wording.</p>
<p>JW: How does this interact with Mike Spertus' allocator-aware regexes? [...] Perhaps it doesn't.</p>
<p>JW: Can't create match_results, want both old and new resolution.</p>
<p>JY: It's problematic that users can't create these, but not this issue.</p>
<p>VV: Why conditional noexcept?</p>
<p>MC: Allocator move might throw.</p>
<p>JW: Update superseded wording to "only non-constructor operations that are"?</p>
<p>MC: Only keep superseded, but append "and the means of constructing match_results are limited to [...]"?</p>
<p>JY: Bullet 4 paragraph 2 needs to address the allocator constructor.</p>
<p>Assigned to JW for drafting.</p>

<p><i>[2015-10, Kona Saturday afternoon]</i></p>

<p>STL: I want Mike Spertus to be aware of this issue.</p>

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

<ol>
<li><p>Change 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> p4, class template <code>match_results</code> synopsis, as indicated:</p>
<blockquote><pre>
[&hellip;]
// 28.10.1, construct/copy/destroy:
explicit match_results(const Allocator&amp; a = Allocator());
match_results(const match_results&amp; m);
<ins>match_results(const match_results&amp; m, const Allocator&amp; a);</ins>
match_results(match_results&amp;&amp; m) noexcept;
<ins>match_results(match_results&amp;&amp; m, const Allocator&amp; a) noexcept;</ins>
[&hellip;]
</pre></blockquote>
</li>

<li><p>Change 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a>  as indicated: [<i>Drafting note:</i> Paragraph 6 as currently written,
makes not much sense, because the <code>noexcept</code> does not allow any exception to propagate. Further-on, the allocator requirements
do not allow for throwing move constructors. Deleting it seems to be near to editorial &mdash; <i>end drafting note</i>]</p>
<blockquote>

<pre>
match_results(const match_results&amp; m);
<ins>match_results(const match_results&amp; m, const Allocator&amp; a);</ins>
</pre>
<blockquote>
<p>
-4- <i>Effects:</i> Constructs an object of class <code>match_results</code>, as a copy of <code>m</code>.
</p>
</blockquote>

<pre>
match_results(match_results&amp;&amp; m) noexcept;
<ins>match_results(match_results&amp;&amp; m, const Allocator&amp; a) noexcept;</ins>
</pre>
<blockquote>
<p>
-5- <i>Effects:</i> Move-constructs an object of class <code>match_results</code> from <code>m</code> satisfying the same postconditions
as Table 142. <del>Additionally</del><ins>For the first form</ins>, the stored <code>Allocator</code> value is move constructed 
from <code>m.get_allocator()</code>.
<p/>
<del>-6- <i>Throws:</i> Nothing if the allocator's move constructor throws nothing.</del>
</p>
</blockquote>

</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2019-03-27 Jonathan updates proposed resolution]</i></p>


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

<p>
These edits overlap with the proposed resolution of <a href="lwg-defects.html#2191" title="Incorrect specification of match_results(match_results&amp;&amp;) (Status: C++23)">2191</a><sup><a href="https://cplusplus.github.io/LWG/issue2191" title="Latest snapshot">(i)</a></sup>
but it should be obvious how to resolve the conflicts.
Both resolutions remove the word "Additionally" from p4.
Issue 2191 removes the entire <i>Throws:</i> element in p5 but this issue
replaces it with different text that applies to the new constructor only.
</p>

<ol>
<li><p>Change 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> p4, class template <code>match_results</code> synopsis, as indicated:</p>
<blockquote><pre>
[&hellip;]
// 30.10.1, construct/copy/destroy:
explicit match_results(const Allocator&amp; a = Allocator());
match_results(const match_results&amp; m);
<ins>match_results(const match_results&amp; m, const Allocator&amp; a);</ins>
match_results(match_results&amp;&amp; m) noexcept;
<ins>match_results(match_results&amp;&amp; m, const Allocator&amp; a);</ins>
[&hellip;]
</pre></blockquote>
</li>

<li><p>Change 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);
<ins>match_results(const match_results&amp; m, const Allocator&amp; a);</ins>
</pre>
<blockquote>
<p>
-3- <i>Effects:</i> Constructs an object of class <code>match_results</code>, as a copy of <code>m</code>.
<ins>For the second form, the stored <code>Allocator</code> value is constructed from <code>a</code>.</ins>
</p>
</blockquote>

<pre>
match_results(match_results&amp;&amp; m) noexcept;
<ins>match_results(match_results&amp;&amp; m, const Allocator&amp; a);</ins>
</pre>
<blockquote>
<p>
-4- <i>Effects:</i> Move-constructs an object of class <code>match_results</code> from <code>m</code> satisfying the same postconditions
as Table 128. <del>Additionally</del><ins>For the first form</ins>, the stored <code>Allocator</code> value is move constructed
from <code>m.get_allocator()</code>.
<ins>For the second form, the stored <code>Allocator</code> value is constructed from <code>a</code>.</ins>
</p>
<p>
-6- <i>Throws:</i> <del>Nothing.</del>
<ins>The second form throws nothing if <code>a == m.get_allocator()</code>.</ins>
</p>
</blockquote>

</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2022-11-06; Daniel syncs wording with recent working draft]</i></p>

<p>
To ensure that all constructors are consistent in regard to the information about how the stored
allocator is constructed, more wording is added. This harmonizes with the way how we specify the
individual container constructors (Such as <code>vector</code>) even though 23.2.2.5 <a href="https://wg21.link/container.alloc.reqmts">[container.alloc.reqmts]</a>
already provides some guarantees. For the copy-constructor we intentionally refer to
23.2.2.2 <a href="https://wg21.link/container.reqmts">[container.reqmts]</a> so that we don't need to repeat what is said there.
</p>

<p><i>[Kona 2022-11-08; Move to Ready]</i></p>


<p><i>[2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting &rarr; WP.]</i></p>



<p id="res-2195"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4917" title=" Working Draft, Standard for Programming Language C++">N4917</a>.
</p>

<ol>
<li><p>Change 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a>, class template <code>match_results</code> synopsis, as indicated:</p>
<blockquote><pre>
[&hellip;]
<i>// 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a>, construct/copy/destroy:</i>
match_results() : match_results(Allocator()) {}
explicit match_results(const Allocator&amp; <ins>a</ins>);
match_results(const match_results&amp; m);
<ins>match_results(const match_results&amp; m, const Allocator&amp; a);</ins>
match_results(match_results&amp;&amp; m) noexcept;
<ins>match_results(match_results&amp;&amp; m, const Allocator&amp; a);</ins>
[&hellip;]
</pre></blockquote>
</li>

<li><p>Change 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>
<ins>-?- <i>Effects:</i> The stored <code>Allocator</code> value is constructed from <code>a</code>.</ins>
<p/>
-2- <i>Postconditions</i>: <code>ready()</code> returns <code>false</code>. <code>size()</code> returns <code>0</code>.
</p>
</blockquote>
<pre>
match_results(const match_results&amp; m);
<ins>match_results(const match_results&amp; m, const Allocator&amp; a);</ins>
</pre>
<blockquote>
<p>
<ins>-?- <i>Effects:</i> For the first form, the stored <code>Allocator</code> value 
is obtained as specified in 23.2.2.2 <a href="https://wg21.link/container.reqmts">[container.reqmts]</a>. For the second form, the stored 
<code>Allocator</code> value is constructed from <code>a</code>.</ins>
<p/>
-3- <i>Postconditions</i>: As specified in Table 142 [tab:re.results.const].
</p>
</blockquote>
<pre>
match_results(match_results&amp;&amp; m) noexcept;
<ins>match_results(match_results&amp;&amp; m, const Allocator&amp; a);</ins>
</pre>
<blockquote>
<p>
-4- <i>Effects:</i> <ins>For the first form, t</ins><del>T</del>he stored <code>Allocator</code> value 
is move constructed from <code>m.get_allocator()</code>. <ins>For the second form, the stored <code>Allocator</code> 
value is constructed from <code>a</code>.</ins>
<p/>
-5- <i>Postconditions</i>: As specified in Table 142 [tab:re.results.const].
<p/>
<ins>-?- <i>Throws:</i> The second form throws nothing if <code>a == m.get_allocator()</code> is <code>true</code>.</ins>
</p>
</blockquote>

</blockquote>
</li>
</ol>






</body>
</html>
