<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2184: Muddled allocator requirements for match_results assignments</title>
<meta property="og:title" content="Issue 2184: Muddled allocator requirements for match_results assignments">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2184.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++20">C++20</a> status.</em></p>
<h3 id="2184"><a href="lwg-defects.html#2184">2184</a>. Muddled allocator requirements for <code>match_results</code> assignments</h3>
<p><b>Section:</b> 28.6.9.2 <a href="https://wg21.link/re.results.const">[re.results.const]</a>, 28.6.9.7 <a href="https://wg21.link/re.results.all">[re.results.all]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Pete Becker <b>Opened:</b> 2012-08-29 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>3
</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++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>

<p>
The effects of the two assignment operators are specified in Table 141. Table 141 makes no mention of allocators, 
so, presumably, they don't touch the target object's allocator. That's okay, but it leaves the question: 
<code>match_results::get_allocator()</code> is supposed to return "A copy of the Allocator that was passed to the 
object's constructor or, if that allocator has been replaced, a copy of the most recent replacement"; if assignment 
doesn't replace the allocator, how can the allocator be replaced?
</p>

<p><i>[2018-06-04, Daniel comments and provides wording]</i></p>

<p>
Similar to the reasoning provided in the 2018-06-02 comment in LWG <a href="lwg-defects.html#2183" title="Muddled allocator requirements for match_results constructors (Status: C++20)">2183</a><sup><a href="https://cplusplus.github.io/LWG/issue2183" title="Latest snapshot">(i)</a></sup>, it is possible to refer to 
the introductory wording of <code>match_results</code> which says 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> satisfies the requirements of an allocator-aware container and 
of a sequence container (26.2.1, 26.2.3) except that only operations defined for const-qualified sequence 
containers are supported and that the semantics of comparison functions are different from those required 
for a container.
</p></blockquote>
<p>
Again, similar to LWG <a href="lwg-defects.html#2183" title="Muddled allocator requirements for match_results constructors (Status: C++20)">2183</a><sup><a href="https://cplusplus.github.io/LWG/issue2183" title="Latest snapshot">(i)</a></sup>, this allows us to deduce the required effects of the copy/move
assignment operators discussed here, because 23.2.2 <a href="https://wg21.link/container.requirements.general">[container.requirements.general]</a> p8 also says:
</p>
<blockquote><p>
[&hellip;] The allocator may be replaced only via assignment or <code>swap()</code>. Allocator replacement is 
performed by copy assignment, move assignment, or swapping of the allocator only if 
<code>allocator_traits&lt;allocator_type&gt;::propagate_on_container_copy_assignment::value</code>,
<code>allocator_traits&lt;allocator_type&gt;::propagate_on_container_move_assignment::value</code>, or 
<code>allocator_traits&lt;allocator_type&gt;::propagate_on_container_swap::value</code> is <code>true</code> 
within the implementation of the corresponding container operation. In all container types defined in 
this Clause, the member <code>get_allocator()</code> returns a copy of the allocator used to construct the 
container or, if that allocator has been replaced, a copy of the most recent replacement. [&hellip;]
</p></blockquote>
<p>
So this wording already specifies everything we need, <em>except</em> for the problem that
28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> p2 quoted above restricts to operations supported by a const-qualified sequence 
container, which of-course would exclude the copy assignment and the move assignment operators.
But given that these mutable definitions are defined for <code>match_results</code>, it seems that the only fix 
needed is to adjust 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> p2 a bit to ensure that both assignment operators are 
covered (again) by the general allocator-aware container wording. 
</p>

<p><i>[2018-06, Rapperswil]</i></p>

<p>
The group generally likes the suggested direction, but would prefer the changed wording to say effectively
"except that only copy assignment, move assignment, and operations defined...". Once applied, move to ready.
</p>

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

<ol>
<li><p>Edit 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> as indicated:</p>
<blockquote>
<p>
-2- The class template <code>match_results</code> satisfies the requirements of an allocator-aware container 
and of a sequence container (23.2.2 <a href="https://wg21.link/container.requirements.general">[container.requirements.general]</a>, 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a>) 
except that <ins>besides copy assignment and move assignment</ins> only operations defined for 
const-qualified sequence containers are supported and that the semantics of comparison functions are 
different from those required for a container.
</p>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2018-06-06, Daniel updates wording]</i></p>

<p><i>[2018-11, Adopted in San Diego]</i></p>



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

<ol>
<li><p>Edit 28.6.9 <a href="https://wg21.link/re.results">[re.results]</a> as indicated:</p>
<blockquote>
<p>
-2- The class template <code>match_results</code> satisfies the requirements of an allocator-aware container 
and of a sequence container (23.2.2 <a href="https://wg21.link/container.requirements.general">[container.requirements.general]</a>, 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a>) 
except that only <ins>copy assignment, move assignment, and</ins> operations defined for 
const-qualified sequence containers are supported and that the semantics of comparison functions are 
different from those required for a container.
</p>
</blockquote>
</li>
</ol>





</body>
</html>
