<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3452: Are views really supposed to have strict &#x1d4aa;(1) destruction?</title>
<meta property="og:title" content="Issue 3452: Are views really supposed to have strict &#x1d4aa;(1) destruction?">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3452.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="3452"><a href="lwg-defects.html#3452">3452</a>. Are views really supposed to have strict <code>&#x1d4aa;(1)</code> destruction?</h3>
<p><b>Section:</b> 25.4.5 <a href="https://wg21.link/range.view">[range.view]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Mathias Stearn <b>Opened:</b> 2020-06-16 <b>Last modified:</b> 2021-10-23</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#range.view">issues</a> in [range.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 second bullet of 25.4.5 <a href="https://wg21.link/range.view">[range.view]</a> paragraph 3 says
"Examples of views are:[&hellip;]
A range type that holds its elements by <code>shared_ptr</code>
and shares ownership with all its copies".
That clearly does not have <code>&#x1d4aa;(1)</code> destruction in all cases.
However, that does seem like a useful type of view,
and is related to the discussions around the proposed <code>std::generator</code>.
</p>

<p>
What is the purpose of requiring <code>&#x1d4aa;(1)</code> destruction?
Would it still be achieved by weakening it slightly to something like
"If <i>N</i> copies and/or moves are made from a view that yields <i>M</i> values,
destroying all of them takes time proportional to at worst <code>&#x1d4aa;(<i>N</i>+<i>M</i>)</code>"?
This in particular prevents the <code>&#x1d4aa;(<i>N</i>*<i>M</i>)</code> case that I think the rules
are trying to prevent, while still allowing some more interesting types of views.
</p>

<p>
If instead we actually really do want strict <code>&#x1d4aa;(1)</code> destruction,
then the example needs to be fixed.
</p>

<p><i>[2020-06-26; Reflector prioritization]</i></p>

<p>
Set priority to 2 after reflector discussions.
</p>

<p><i>[2021-01-15; Telecon discussion]</i></p>

<p>
Set status to LEWG for guidance on the issue of what it means to model view.
</p>

<p><i>[2021-02-16; Library Evolution Telecon Minutes]</i></p>

<p>
Poll: The <code>shared_ptr</code> part of the example mentioned in LWG3452 should be removed.
</p>
<pre>
SF F N A SA
4  6 3 1 0
</pre>
<p>
Attendance: 25
<p/>
Outcome: Remove the <code>shared_ptr</code> part.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>
This wording is relative to <a href="https://wg21.link/n4878">N4878</a>.
</p>

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

<blockquote>
<pre>
template&lt;class T&gt;
  concept view =
    range&lt;T&gt; &amp;&amp; movable&lt;T&gt; &amp;&amp; default_initializable&lt;T&gt; &amp;&amp; enable_view&lt;T&gt;;
</pre>
[&hellip;]
<blockquote>
<p>
-3- [<i>Example 1</i>: Examples of <code>view</code>s are:
</p>
<ol style="list-style-type: none">
<li><p>(3.1) &mdash; A <code>range</code> type that wraps a pair of iterators.</p></li>
<li><p><del>(3.2) &mdash; A <code>range</code> type that holds its elements by shared_ptr and shares ownership with all its copies.</del></p></li>
<li><p>(3.3) &mdash; A <code>range</code> type that generates its elements on demand.</p></li>
</ol>
<p>
Most containers (Clause 22) are not views since destruction of the container destroys the elements, which cannot
be done in constant time. &mdash; <i>end example</i>]
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>
<p><i>[2021-10-23 Resolved by the adoption of <a href="https://wg21.link/P2415R2" title=" What is a view?">P2415R2</a> at the October 2021 plenary. Status changed: LEWG &rarr; Resolved.]</i></p>



<p id="res-3452"><b>Proposed resolution:</b></p>





</body>
</html>
