<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3278: join_view&lt;V&gt;::iterator&lt;true&gt; tries to write through const join_view ptr</title>
<meta property="og:title" content="Issue 3278: join_view&lt;V&gt;::iterator&lt;true&gt; tries to write through const join_view ptr">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3278.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#Resolved">Resolved</a> status.</em></p>
<h3 id="3278"><a href="lwg-defects.html#3278">3278</a>. <code>join_view&lt;V&gt;::iterator&lt;true&gt;</code> tries to write through <code>const join_view</code> ptr</h3>
<p><b>Section:</b> 25.7.14.2 <a href="https://wg21.link/range.join.view">[range.join.view]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Eric Niebler <b>Opened:</b> 2019-09-09 <b>Last modified:</b> 2020-09-06</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#range.join.view">issues</a> in [range.join.view].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The non-<code>const</code> <code>join_view::begin()</code> returns <code>iterator&lt;<i>simple-view</i>&lt;V&gt;&gt;</code>. 
If <code><i>simple-view</i>&lt;V&gt;</code> is <code>true</code>, then the iterator stores a <code>const join_view*</code> 
named <code>parent_</code>. <code>iterator::satisfy()</code> will try to write to <code>parent_-&gt;inner_</code> if 
<code>ref_is_glvalue</code> is <code>false</code>. That doesn't work because the <code>inner_</code> field is not marked 
mutable.
</p>
<p><i>[2019-10 Priority set to 2 after reflector discussion]</i></p>


<p><i>[2020-02-10, Prague]</i></p>

<p>
Would be resolved by <a href="https://wg21.link/p1983r0">P1983R0</a>.
</p>
<p><i>[2020-08-21 Issue processing telecon: resolved by <a href="https://wg21.link/p1983r0#us291-join_viewbegin-requires-mutable-data">P1983R0 &sect;2.4</a>. Status changed: New &rarr; Resolved.]</i></p>



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

<ol>
<li><p>Modify 25.7.14.2 <a href="https://wg21.link/range.join.view">[range.join.view]</a>, class <code>template join_view</code> synopsis, as indicated:</p>

<blockquote class="note">
<p>
[<i>Drafting note:</i> Changing the <code>join_view&lt;V&gt;::inner_</code> member to be mutable is safe 
because this exposition-only member is only used when the <code>join_view</code> is single-pass and 
only modified by operations that invalidate other iterators]
</p>
</blockquote>

<blockquote>
<pre>
namespace std::ranges {
  template&lt;input_range V&gt;
    requires view&lt;V&gt; &amp;&amp; input_range&lt;range_reference_t&lt;V&gt;&gt;&gt; &amp;&amp;
            (is_reference_v&lt;range_reference_t&lt;V&gt;&gt; ||
            view&lt;range_value_t&lt;V&gt;&gt;)
  class join_view : public view_interface&lt;join_view&lt;V&gt;&gt; {
  private:
    [&hellip;]
    V base_ = V(); <i>// exposition only</i>
    <ins>mutable</ins> all_view&lt;InnerRng&gt; inner_ = <i>// exposition only, present only when</i> 
                                        <ins><i>//</i></ins> !is_reference_v&lt;InnerRng&gt;
      all_view&lt;InnerRng&gt;();
  public:
    [&hellip;]
  };
}
</pre>
</blockquote>
</li>
</ol>





</body>
</html>
