<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3832: Missing change for element_view::iterator in LWG 3798</title>
<meta property="og:title" content="Issue 3832: Missing change for element_view::iterator in LWG 3798">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3832.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="3832"><a href="lwg-active.html#3832">3832</a>. Missing change for <code>element_view::<i>iterator</i></code> in LWG 3798</h3>
<p><b>Section:</b> 25.7.23.3 <a href="https://wg21.link/range.elements.iterator">[range.elements.iterator]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2022-11-23 <b>Last modified:</b> 2024-07-21</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#range.elements.iterator">active issues</a> in [range.elements.iterator].</p>
<p><b>View all other</b> <a href="lwg-index.html#range.elements.iterator">issues</a> in [range.elements.iterator].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
In LWG <a href="lwg-defects.html#3798" title="Rvalue reference and iterator_category (Status: C++23)">3798</a><sup><a href="https://cplusplus.github.io/LWG/issue3798" title="Latest snapshot">(i)</a></sup> (voted into WP in November 2022), iterator types of several range adaptors may have 
<code>forward_iterator_tag</code> or stronger iterator tag types as their <code>iterator_category</code> type when 
their <code>operator*</code> returns rvalue references. However, the proposed resolution missed the similar change 
for <code>element_view::<i>iterator</i></code>.
</p>

<p><i>[2022-11-30; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
</p>
<p>
"The proposed resolution is incorrect - just because the <code>get</code>
expression is an xvalue doesn't mean <code>operator*</code> returns by reference."
</p>

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

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

<blockquote>
<p>
-2- The member <i>typedef-name</i> <code>iterator_category</code> is defined if and only if <code><i>Base</i></code> 
models <code>forward_range</code>. In that case, <code>iterator_category</code> is defined as follows: Let <code>C</code> 
denote the type <code>iterator_traits&lt;iterator_t&lt;<i>Base</i>&gt;&gt;::iterator_category</code>.
</p>
<ol style="list-style-type: none">
<li><p>(2.1) &mdash; If <code>std::get&lt;N&gt;(*<i>current_</i>)</code> is a<del>n</del> <ins>p</ins>rvalue, 
<code>iterator_category</code> denotes <code>input_iterator_tag</code>.</p></li>
<li><p>(2.2) &mdash; Otherwise, if <code>C</code> models <code>derived_from&lt;random_access_iterator_tag&gt;</code>, 
<code>iterator_category</code> denotes <code>random_access_iterator_tag</code>.</p></li>
<li><p>(2.3) &mdash; Otherwise, <code>iterator_category</code> denotes <code>C</code>.</p></li>
</ol>
</blockquote>
</li>

</ol>
</blockquote>

<p><i>[2023-01-22; Jiang An comments and provides improved wording]</i></p>

<p>
The old proposed resolution was incorrect. I think the correct criteria could be that determined from the return type of 
<code><i>get-element</i></code>.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">

<p>
This wording is relative to <a href="https://wg21.link/N4928" title=" Working Draft, Standard for Programming Language C++">N4928</a>.
</p>

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

<blockquote>
<p>
-2- The member <i>typedef-name</i> <code>iterator_category</code> is defined if and only if <code><i>Base</i></code> 
models <code>forward_range</code>. In that case, <code>iterator_category</code> is defined as follows: Let <code>C</code> 
denote the type <code>iterator_traits&lt;iterator_t&lt;<i>Base</i>&gt;&gt;::iterator_category</code>.
</p>
<ol style="list-style-type: none">
<li><p>(2.1) &mdash; If <ins><code>range_reference_t&lt;<i>Base</i>&gt;</code> is a reference type and</ins> 
<code>std::get&lt;N&gt;(*<i>current_</i>)</code> is a<del>n</del> <ins>p</ins>rvalue <ins>or neither 
<code>range_reference_t&lt;<i>Base</i>&gt;</code> nor <code>tuple_element_t&lt;N, range_reference_t&lt;<i>Base</i>&gt;</code> 
is a reference type</ins>, <code>iterator_category</code> denotes <code>input_iterator_tag</code>.</p></li>
<li><p>(2.2) &mdash; Otherwise, if <code>C</code> models <code>derived_from&lt;random_access_iterator_tag&gt;</code>, 
<code>iterator_category</code> denotes <code>random_access_iterator_tag</code>.</p></li>
<li><p>(2.3) &mdash; Otherwise, <code>iterator_category</code> denotes <code>C</code>.</p></li>
</ol>
</blockquote>
</li>

</ol>
</blockquote>

<p><i>[2024-07-08; Hewill Kang provides improved wording]</i></p>



<p id="res-3832"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4986" title=" Working Draft, Programming Languages — C++">N4986</a>.
</p>

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

<blockquote>
<p>
-2- The member <i>typedef-name</i> <code>iterator_category</code> is defined if and only if <code><i>Base</i></code> 
models <code>forward_range</code>. In that case, <code>iterator_category</code> is defined as follows: Let <code>C</code> 
denote the type <code>iterator_traits&lt;iterator_t&lt;<i>Base</i>&gt;&gt;::iterator_category</code>.
</p>
<ol style="list-style-type: none">
<li><p>(2.1) &mdash; If <del><code>std::get&lt;N&gt;(*<i>current_</i>)</code></del><ins><code>is_reference_v&lt;decltype(<i>get-element</i>(<i>current_</i>))&gt;</code></ins> 
is <del>an rvalue</del><ins><code>false</code></ins>, <code>iterator_category</code> denotes <code>input_iterator_tag</code>.</p></li>
<li><p>(2.2) &mdash; Otherwise, if <code>C</code> models <code>derived_from&lt;random_access_iterator_tag&gt;</code>, 
<code>iterator_category</code> denotes <code>random_access_iterator_tag</code>.</p></li>
<li><p>(2.3) &mdash; Otherwise, <code>iterator_category</code> denotes <code>C</code>.</p></li>
</ol>
</blockquote>
</li>

</ol>






</body>
</html>
