<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3610: iota_view::size sometimes rejects integer-class types</title>
<meta property="og:title" content="Issue 3610: iota_view::size sometimes rejects integer-class types">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3610.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="3610"><a href="lwg-defects.html#3610">3610</a>. <code>iota_view::size</code> sometimes rejects integer-class types</h3>
<p><b>Section:</b> 25.6.4.2 <a href="https://wg21.link/range.iota.view">[range.iota.view]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2021-09-29 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#range.iota.view">issues</a> in [range.iota.view].</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>
It seems that the <code>iota_view</code> tends to accept integer-class types as its value types, by using 
<code><i>is-integer-like</i></code> or <code><i>is-signed-integer-like</i></code> through the specification, 
although it's unspecified whether any of them satisfies <code>weakly_incrementable</code>. However, the 
<i>requires-clause</i> of <code>iota_view::size</code> (25.6.4.2 <a href="https://wg21.link/range.iota.view">[range.iota.view]</a> p16) uses 
<code>(integral&lt;W&gt; &amp;&amp; integral&lt;Bound&gt;)</code>, which sometimes rejects integer-class types.
<p/>
Should we relax the restrictions by changing this part to <code>(<i>is-integer-like</i>&lt;W&gt; &amp;&amp; 
<i>is-integer-like</i>&lt;Bound&gt;)</code>?
</p>

<p><i>[2021-10-14; Reflector poll]</i></p>

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

<p><i>[2022-02-10 Approved at February 2022 virtual plenary. Status changed: Tentatively Ready &rarr; WP.]</i></p>



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

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

<blockquote>
<pre>
constexpr auto size() const requires <i>see below</i>;
</pre>
<blockquote>
<p>
-15- <i>Effects:</i> Equivalent to:
</p>
<blockquote><pre>
if constexpr (<i>is-integer-like</i>&lt;W&gt; &amp;&amp; <i>is-integer-like</i>&lt;Bound&gt;)
  return (<i>value_</i> &lt; 0)
    ? ((<i>bound_</i> &lt; 0)
      ? <i>to-unsigned-like</i>(-<i>value_</i>) - <i>to-unsigned-like</i>(-<i>bound_</i>)
      : <i>to-unsigned-like</i>(<i>bound_</i>) + <i>to-unsigned-like</i>(-<i>value_</i>))
    : <i>to-unsigned-like</i>(<i>bound_</i>) - <i>to-unsigned-like</i>(<i>value_</i>);
else
  return <i>to-unsigned-like</i>(<i>bound_</i> - <i>value_</i>);
</pre></blockquote>
<p>
-16- <i>Remarks:</i> The expression in the <i>requires-clause</i> is equivalent to:
</p>
<blockquote><pre>
(same_as&lt;W, Bound&gt; &amp;&amp; <i>advanceable</i>&lt;W&gt;) || (<del>integral</del><ins><i>is-integer-like</i></ins>&lt;W&gt; &amp;&amp; <del>integral</del><ins><i>is-integer-like</i></ins>&lt;Bound&gt;) ||
  sized_sentinel_for&lt;Bound, W&gt;
</pre></blockquote>
</blockquote>
</blockquote>
</li>

</ol>




</body>
</html>
