<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3297: Useless sequence container requirement</title>
<meta property="og:title" content="Issue 3297: Useless sequence container requirement">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3297.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#New">New</a> status.</em></p>
<h3 id="3297"><a href="lwg-active.html#3297">3297</a>. Useless sequence container requirement</h3>
<p><b>Section:</b> 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Casey Carter <b>Opened:</b> 2019-09-17 <b>Last modified:</b> 2022-04-24</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#sequence.reqmts">active issues</a> in [sequence.reqmts].</p>
<p><b>View all other</b> <a href="lwg-index.html#sequence.reqmts">issues</a> in [sequence.reqmts].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a> paragraph 3 says that the names <code>i</code> and <code>j</code> denote 
"iterators that meet the <i>Cpp17InputIterator</i> requirements and refer to elements implicitly 
convertible to <code>value_type</code>". Ignoring for the moment that this is an occurrence of LWG 
<a href="lwg-active.html#3105" title="T1 is convertible to T2 (Status: New)">3105</a><sup><a href="https://cplusplus.github.io/LWG/issue3105" title="Latest snapshot">(i)</a></sup> &mdash; we really mean that <code>*i</code> and <code>*j</code> must be implicitly 
convertible to <code>value_type</code> &mdash; this requirement seems to be completely extraneous.
<p/>
The names <code>i</code> and <code>j</code> are used in three places in the requirements table:
</p>
<ul>
<li><p>The range constructors <code>X(i, j)</code> and <code>X u(i, j)</code>, which require that the 
container's value type is <i>Cpp17EmplaceConstructible</i> into the container from <code>*i</code>; 
implicit conversion is neither necessary nor sufficient.</p></li>
<li><p>The range insert overload <code>a.insert(p, i, j)</code> which also requires <i>Cpp17EmplaceConstructible</i>, 
as well as the capability to move elements around for <code>vector</code> and <code>deque</code>; again, 
implicit conversion is neither necessary nor sufficient. It <em>would</em> be useful / performant 
here to require that the container's value type is assignable from <code>*i</code>, which may have 
been the intent of the implicit conversion requirement &mdash; would doing so be too breaking?</p></li>
<li><p>The range assign overload <code>a.assign(i, j)</code> which requires both 
<i>Cpp17EmplaceConstructible</i> as above and that it can assign the result of dereferencing an 
iterator directly to the container's value type; again, implicit conversion is not useful here.</p></li>
</ul>
<p>
We should strike the implicit conversion requirement since it is not useful and only serves to confuse 
readers of the Standard (see e.g. <a href="https://github.com/microsoft/STL/issues/107">here</a>).
</p>

<p><i>[2019-10-31 Issue Prioritization]</i></p>

<p>Priority to 3 after reflector discussion.</p>

<p>
<strong>Previous resolution [SUPERSEDED]:</strong>
</p>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/N4830" title=" Committee Draft, Standard for Programming Language C++">N4830</a>.</p>

<ol>
<li><p>Modify 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a> as indicated:</p>

<blockquote>
<p>
-3- In Tables 76 and 77, <code>X</code> denotes a sequence container class, <code>a</code> denotes a value 
of type <code>X</code> containing elements of type <code>T</code>, <code>u</code> denotes the name of a variable 
being declared, <code>A</code> denotes <code>X::allocator_type</code> if the <i>qualified-id</i>
<code>X::allocator_type</code> is valid and denotes a type (13.10.3 <a href="https://wg21.link/temp.deduct">[temp.deduct]</a>) and 
<code>allocator&lt;T&gt;</code> if it doesn't, <code>i</code> and <code>j</code> denote iterators that meet 
the <i>Cpp17InputIterator</i> requirements <del>and refer to elements implicitly convertible to
<code>value_type</code></del>, <code>[i, j)</code> denotes a valid range, [&hellip;]
</p>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2022-04-24; Daniel rebases wording on <a href="https://wg21.link/N4910" title=" Working Draft, Standard for Programming Language C++">N4910</a>]</i></p>



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

<ol>
<li><p>Modify 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a> as indicated:</p>

<blockquote>
<p>
-3- In this subclause,
</p>
<ol style="list-style-type:none">
<li><p>(3.1) &mdash; [&hellip;]</p></li>
<li><p>[&hellip;]</p></li>
<li><p>(3.5) &mdash; <code>i</code> and <code>j</code> denote iterators that meet the <i>Cpp17InputIterator</i> 
requirements <del>and refer to elements implicitly convertible to <code>value_type</code></del>,</p></li>
<li><p>[&hellip;]</p></li>
</ol>
</blockquote>
</li>
</ol>




</body>
</html>
