<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3287: Exposition-only cpp17-input-iterator concept is needlessly complex</title>
<meta property="og:title" content="Issue 3287: Exposition-only cpp17-input-iterator concept is needlessly complex">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3287.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="3287"><a href="lwg-active.html#3287">3287</a>. Exposition-only <code><i>cpp17-input-iterator</i></code> concept is needlessly complex</h3>
<p><b>Section:</b> 24.3.2.3 <a href="https://wg21.link/iterator.traits">[iterator.traits]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Eric Niebler <b>Opened:</b> 2019-09-10 <b>Last modified:</b> 2020-09-06</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#iterator.traits">issues</a> in [iterator.traits].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The new C++20 iterator concepts use <code>common_reference</code> to constrain the value, reference, and 
rvalue_reference associated types in order to support proxy references (see 
24.3.4.2 <a href="https://wg21.link/iterator.concept.readable">[iterator.concept.readable]</a>).
<p/>
However, the C++17 iterators did not support proxy references, so the use of <code>common_reference</code> in 
24.3.2.3 <a href="https://wg21.link/iterator.traits">[iterator.traits]</a>/p2 is needlessly complex. The <code>common_reference</code> constraints can be 
replaced with simple convertibility requirements to a <code>const</code> lvalue reference to the value type.
<p/>
This fix has been implemented in range-v3.
</p>

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

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


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

<ol>
<li><p>Modify 24.3.2.3 <a href="https://wg21.link/iterator.traits">[iterator.traits]</a> as indicated:</p>

<blockquote>
<p>
-2- The definitions in this subclause make use of the following exposition-only concepts:
</p>
<blockquote>
<pre>
template&lt;class I&gt;
concept <i>cpp17-iterator</i> =
  copyable&lt;I&gt; &amp;&amp; requires(I i) {
    {   *i } -&gt; <i>can-reference</i>;
    {  ++i } -&gt; same_as&lt;I&amp;&gt;;
    { *i++ } -&gt; <i>can-reference</i>;
  };

template&lt;class I&gt;
concept <i>cpp17-input-iterator</i> =
  <i>cpp17-iterator</i>&lt;I&gt; &amp;&amp; equality_comparable&lt;I&gt; &amp;&amp; requires(I i) {
    typename incrementable_traits&lt;I&gt;::difference_type;
    typename readable_traits&lt;I&gt;::value_type;
    <del>typename common_reference_t&lt;iter_reference_t&lt;I&gt;&amp;&amp;,
                                typename readable_traits&lt;I&gt;::value_type&amp;&gt;;
    typename common_reference_t&lt;decltype(*i++)&amp;&amp;,
                                typename readable_traits&lt;I&gt;::value_type&amp;&gt;;</del>
    <ins>{ *i } -&gt; convertible_to&lt;const typename readable_traits&lt;I&gt;::value_type&amp;&gt;;
    { *i++ } -&gt; convertible_to&lt;const typename readable_traits&lt;I&gt;::value_type&amp;&gt;;</ins>
    requires signed_integral&lt;typename incrementable_traits&lt;I&gt;::difference_type&gt;;
  };

[&hellip;]
</pre>
</blockquote>
</blockquote>
</li>

</ol>





</body>
</html>
