<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2793: Awkward conflation of trivial special members of istream_iterator</title>
<meta property="og:title" content="Issue 2793: Awkward conflation of trivial special members of istream_iterator">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2793.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++17">C++17</a> status.</em></p>
<h3 id="2793"><a href="lwg-defects.html#2793">2793</a>. Awkward conflation of trivial special members of <code>istream_iterator</code></h3>
<p><b>Section:</b> 24.6.2.2 <a href="https://wg21.link/istream.iterator.cons">[istream.iterator.cons]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Erich Keane <b>Opened:</b> 2016-11-09 <b>Last modified:</b> 2020-09-06</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#istream.iterator.cons">issues</a> in [istream.iterator.cons].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<b>Addresses GB 68, US 154, US 155</b>
<p/>
The term 'literal type' is dangerous and 
misleading, as text using this term really 
wants to require that a constexpr 
constructor/initialization is called with a 
constant expression, but does not actually 
tie the selected constructor to the type being 
'literal'.
<p/>
Suggested resolution:
<p/>
Verify the uses of the term in the Core and Library specifications and 
replace with something more precise where appropriate.
<p/>
The conflation of trivial copy constructor and literal 
type is awkward. Not all literal types have trivial copy 
constructors, and not all types with trivial copy 
constructors are literal.
<p/>
Suggested resolution:
<p/>
Revise p5 as:
</p>
<blockquote>
<p>
<i>Effects:</i> Constructs a copy of <code>x</code>. If <code>T</code> has a trivial copy 
constructor, then this constructor shall be a trivial copy constructor.
If <code>T</code> has a constexpr copy constructor, then this constructor shall be <code>constexpr</code>.
</p>
</blockquote>
<p>
The requirement that the destructor is trivial if <code>T</code> is a 
literal type should be generalized to any type <code>T</code> with a 
trivial destructor &mdash; this encompasses all literal types, 
as they are required to have a trivial destructor.
<p/>
Suggested resolution:
<p/>
Revise p7 as:
</p>
<blockquote>
<p>
<i>Effects:</i> The iterator is destroyed. If <code>T</code> has a trivial 
destructor, then this destructor shall be a trivial destructor.
</p>
</blockquote>

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

<ol>
<li><p>Change 24.6.2.2 <a href="https://wg21.link/istream.iterator.cons">[istream.iterator.cons]</a> p1 as indicated:</p>
<blockquote>
<pre>
<i>see below</i> istream_iterator();
</pre>
<blockquote>
<p>
-1- <i>Effects:</i> Constructs the end-of-stream iterator. If <del><code>T</code> is a literal 
type</del><ins><code>is_trivially_constructible_v&lt;T&gt; == true</code></ins>, then this constructor <del>shall be a</del><ins>is 
a trivial,</ins> <code>constexpr</code> constructor.
</p>
</blockquote>
</blockquote>
</li>

<li><p>Change 24.6.2.2 <a href="https://wg21.link/istream.iterator.cons">[istream.iterator.cons]</a> p5 as indicated:</p>

<blockquote>
<pre>
istream_iterator(const istream_iterator&amp; x) = default;
</pre>
<blockquote>
<p>
-5- <i>Effects:</i> Constructs a copy of <code>x</code>. If <del><code>T</code> is a literal 
type</del><ins><code>is_trivially_copyable_v&lt;T&gt; == true</code></ins>, then this constructor <del>shall be</del><ins>is</ins> a 
trivial copy constructor.
</p>
</blockquote>
</blockquote>
</li>

<li><p>Change 24.6.2.2 <a href="https://wg21.link/istream.iterator.cons">[istream.iterator.cons]</a> p7 as indicated:</p>

<blockquote>
<pre>
~istream_iterator() = default;
</pre>
<blockquote>
<p>
-7- <i>Effects:</i> The iterator is destroyed. If <del><code>T</code> is a literal 
type</del><ins><code>is_trivially_destructible_v&lt;T&gt; == true</code></ins>, then this destructor <del>shall 
be</del><ins>is</ins> a trivial destructor.
</p>
</blockquote>
</blockquote>
</li>
</ol>

</blockquote>

<p><i>[Issues Telecon 16-Dec-2016]</i></p>

<p>Resolved by the adoption of <a href="https://wg21.link/p0503r0">P0503R0</a></p>


<p id="res-2793"><b>Proposed resolution:</b></p>
<p>
Resolve by accepting the wording suggested by <a href="https://wg21.link/p0503r0">P0503R0</a>.
</p>





</body>
</html>
