<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 483: Heterogeneous equality and EqualityComparable</title>
<meta property="og:title" content="Issue 483: Heterogeneous equality and EqualityComparable">
<meta property="og:description" content="C++ library issue. Status: Dup">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue483.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#Dup">Dup</a> status.</em></p>
<h3 id="483"><a href="lwg-closed.html#483">483</a>. Heterogeneous equality and EqualityComparable</h3>
<p><b>Section:</b> 26.6 <a href="https://wg21.link/alg.nonmodifying">[alg.nonmodifying]</a>, 26.7 <a href="https://wg21.link/alg.modifying.operations">[alg.modifying.operations]</a> <b>Status:</b> <a href="lwg-active.html#Dup">Dup</a>
 <b>Submitter:</b> Peter Dimov <b>Opened:</b> 2004-09-20 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Dup">Dup</a> status.</p>
<p><b>Duplicate of:</b> <a href="lwg-defects.html#283" title="std::replace() requirement incorrect/insufficient (Status: CD1)">283</a></p>
<p><b>Discussion:</b></p>
<p>c++std-lib-14262</p>

<p>[lib.alg.find] requires T to be EqualityComparable:</p>

<pre>
template &lt;class InputIterator, class T>
   InputIterator find(InputIterator first, InputIterator last,
                      const T&amp; value);
</pre>

<p>
However the condition being tested, as specified in the Effects
clause, is actually *i == value, where i is an InputIterator.
</p>

<p>
The two clauses are in agreement only if the type of *i is T, but this
isn't necessarily the case. *i may have a heterogeneous comparison
operator that takes a T, or a T may be convertible to the type of *i.
</p>

<p>Further discussion (c++std-lib-14264): this problem affects a
  number of algorithsm in clause 25, not just <code>find</code>.  We
  should try to resolve this problem everywhere it appears.</p>


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

<p>[lib.alg.find]:</p>
<blockquote><p>
   Remove [lib.alg.find]/1.
</p></blockquote>

<p>[lib.alg.count]:</p>
<blockquote><p>
   Remove [lib.alg.count]/1.
</p></blockquote>

<p>[lib.alg.search]:</p>
<blockquote><p>
   Remove "Type T is EqualityComparable (20.1.1), " from [lib.alg.search]/4.
</p></blockquote>

<p>[lib.alg.replace]:</p>

<blockquote>
   <p>
   Remove [lib.alg.replace]/1.
   Replace [lb.alg.replace]/2 with:
   </p>

       <blockquote><p>
       For every iterator i in the range [first, last) for which *i == value
       or pred(*i) holds perform *i = new_value.
       </p></blockquote>

   <p>
   Remove the first sentence of /4.
   Replace the beginning of /5 with:
   </p>

       <blockquote><p>
       For every iterator i in the range [result, result + (last -
       first)), assign to *i either...
       </p></blockquote>

   <p>(Note the defect here, current text says assign to i, not *i).</p>
</blockquote>

<p>[lib.alg.fill]:</p>

<blockquote>
   <p>
   Remove "Type T is Assignable (23.1), " from /1.
   Replace /2 with:
   </p>

       <blockquote><p>
       For every iterator i in the range [first, last) or [first, first + n),
       perform *i = value.
       </p></blockquote>
</blockquote>

<p>[lib.alg.remove]:</p>
<blockquote><p>
   Remove /1.
   Remove the first sentence of /6.
</p></blockquote>



<p><b>Rationale:</b></p>
<p>Duplicate of (a subset of) issue <a href="lwg-defects.html#283" title="std::replace() requirement incorrect/insufficient (Status: CD1)">283</a><sup><a href="https://cplusplus.github.io/LWG/issue283" title="Latest snapshot">(i)</a></sup>.</p>






</body>
</html>
