<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3551: borrowed_{iterator,subrange}_t are overspecified</title>
<meta property="og:title" content="Issue 3551: borrowed_{iterator,subrange}_t are overspecified">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3551.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++23">C++23</a> status.</em></p>
<h3 id="3551"><a href="lwg-defects.html#3551">3551</a>. <code>borrowed_{iterator,subrange}_t</code> are overspecified</h3>
<p><b>Section:</b> 25.5.5 <a href="https://wg21.link/range.dangling">[range.dangling]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2021-05-12 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>
<p>
As discussed in <a href="https://wg21.link/p1715r0">P1715R0</a>, 
there are ways to implement something equivalent to <code>std::conditional_t</code> 
that are better for compile times. However, <code>borrowed_{iterator,subrange}_t</code> 
are currently specified to use <code>conditional_t</code>, and this appears to be 
user-observable due to the transparency of alias templates. We should simply 
specify the desired result and leave the actual definition to the implementation.
</p>

<p><i>[2021-05-20; Reflector poll]</i></p>

<p>
Set status to Tentatively Ready after seven votes in favour during reflector poll.
</p>

<p><i>[2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting &rarr; WP.]</i></p>



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

<ol>
<li><p>Modify 25.2 <a href="https://wg21.link/ranges.syn">[ranges.syn]</a>, header <code>&lt;ranges&gt;</code> synopsis, as indicated:</p>

<blockquote>
<pre>
  [&hellip;]
namespace std::ranges {
  [&hellip;]
  <i>// 25.5.5 <a href="https://wg21.link/range.dangling">[range.dangling]</a>, dangling iterator handling</i>
  struct dangling;
  
  template&lt;range R&gt;
    using borrowed_iterator_t = <ins><i>see below</i></ins><del>conditional_t&lt;borrowed_range&lt;R&gt;, iterator_t&lt;R&gt;, dangling&gt;</del>;

  template&lt;range R&gt;
    using borrowed_subrange_t = <ins><i>see below</i></ins>
      <del>conditional_t&lt;borrowed_range&lt;R&gt;, subrange&lt;iterator_t&lt;R&gt;&gt;, dangling&gt;</del>;

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

</li>
<li>
<p>Modify 25.5.5 <a href="https://wg21.link/range.dangling">[range.dangling]</a> as indicated: </p>
<blockquote>
<p>
-1- The tag type <code>dangling</code> is used together with the template aliases <code>borrowed_iterator_t</code> and 
<code>borrowed_subrange_t</code>. When an algorithm that typically returns an iterator into, or a subrange of, a 
range argument is called with an rvalue range argument that does not model <code>borrowed_range</code> 
(25.4.2 <a href="https://wg21.link/range.range">[range.range]</a>), the return value possibly refers to a range whose lifetime has ended. In such 
cases, the tag type <code>dangling</code> is returned instead of an iterator or subrange.
</p>
<blockquote><pre>
namespace std::ranges {
  struct dangling {
    [&hellip;]
  };
}
</pre></blockquote>
<p>
-2- [<i>Example 1:</i> [&hellip;] &mdash; <i>end example</i>]
<p/>
<ins>-?- For a type <code>R</code> that models <code>range</code>:</ins>
<ol style="list-style-type: none">
<li><p><ins>(?.1) &mdash; if <code>R</code> models <code>borrowed_range</code>, then <code>borrowed_iterator_t&lt;R&gt;</code>
denotes <code>iterator_t&lt;R&gt;</code>, and <code>borrowed_subrange_t&lt;R&gt;</code> denotes 
<code>subrange&lt;iterator_t&lt;R&gt;&gt;</code>;</ins></p></li>
<li><p><ins>(?.2) &mdash; otherwise, both <code>borrowed_iterator_t&lt;R&gt;</code> and <code>borrowed_subrange_t&lt;R&gt;</code> 
denote <code>dangling</code>.</ins></p></li>
</ol>
</p>
</blockquote>
</li>
</ol>





</body>
</html>
