<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 684: Unclear which members of match_results should be used in comparison</title>
<meta property="og:title" content="Issue 684: Unclear which members of match_results should be used in comparison">
<meta property="og:description" content="C++ library issue. Status: NAD Editorial">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue684.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#NAD_Editorial">NAD Editorial</a> status.</em></p>
<h3 id="684"><a href="lwg-closed.html#684">684</a>. Unclear which members of match_results should be used in comparison</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#NAD_Editorial">NAD Editorial</a>
 <b>Submitter:</b> Nozomu Katoo <b>Opened:</b> 2007-05-27 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</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#NAD Editorial">NAD Editorial</a> status.</p>
<p><b>Discussion:</b></p>
<p>
In 28.6.3 <a href="https://wg21.link/re.syn">[re.syn]</a> of N2284, two template functions 
are declared here: 
</p>
<blockquote><pre>
// 28.10, class template match_results: 
  &lt;<i>snip</i>&gt;
// match_results comparisons 
  template &lt;class BidirectionalIterator, class Allocator&gt; 
    bool operator== (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1, 
                     const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2); 
  template &lt;class BidirectionalIterator, class Allocator&gt; 
    bool operator!= (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1, 
                     const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2); 

// 28.10.6, match_results swap:
</pre></blockquote>

<p>
But the details of these two bool operator functions (i.e., which members of
<code>match_results</code> should be used in comparison) are not described in any
following sections.
</p>

<p><i>[
John adds:
]</i></p>


<blockquote><p>
That looks like a bug: <code>operator==</code> should return <code>true</code> only if
the two objects refer to the same match - ie if one object was constructed as a
copy of the other.
</p></blockquote>

<p><i>[
Kona (2007): Bill and Pete to add minor wording to that proposed in
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2409.pdf">N2409</a>.
]</i></p>



<p id="res-684"><b>Proposed resolution:</b></p>
<p>
Add a new section after 28.6.9.8 <a href="https://wg21.link/re.results.swap">[re.results.swap]</a>, which reads:
</p>
<p>
28.10.7 match_results non-member functions.
</p>

<blockquote>
<pre>
template&lt;class BidirectionalIterator, class Allocator&gt; 
  bool operator==(const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1, 
                  const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>true</code> only if the two objects refer to the same match.
</p>
</blockquote>
</blockquote>

<blockquote>
<pre>
template&lt;class BidirectionalIterator, class Allocator&gt; 
  bool operator!=(const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1, 
                  const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>!(m1 == m2)</code>.
</p>
</blockquote>
</blockquote>

<blockquote>
<pre>
template&lt;class BidirectionalIterator, class Allocator&gt; 
  void swap(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1, 
            match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>m1.swap(m2)</code>.
</p>
</blockquote>
</blockquote>


<p><i>[
Bellevue:  Proposed wording now in WP.
]</i></p>





</body>
</html>
