<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3955: Add noexcept to several repeat_view[::iterator] member functions</title>
<meta property="og:title" content="Issue 3955: Add noexcept to several repeat_view[::iterator] member functions">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3955.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="3955"><a href="lwg-active.html#3955">3955</a>. Add <code>noexcept</code> to several <code>repeat_view[::<i>iterator</i>]</code> member functions</h3>
<p><b>Section:</b> 25.6.5.2 <a href="https://wg21.link/range.repeat.view">[range.repeat.view]</a>, 25.6.5.3 <a href="https://wg21.link/range.repeat.iterator">[range.repeat.iterator]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Hewill Kang <b>Opened:</b> 2023-07-06 <b>Last modified:</b> 2023-10-30</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#range.repeat.view">issues</a> in [range.repeat.view].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Several member functions of <code>repeat_view::<i>iterator</i></code> only operate on its integer member, indicating that 
they do not throw.
<p/>
Similarly, <code>repeat_view::size</code> should also be <code>noexcept</code> since it just performs the integer conversion.
</p>

<p><i>[2023-10-30; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
Some votes for NAD.
"The iterator changes violate the Lakos rule."
</p>



<p id="res-3955"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4950" title=" Working Draft, Standard for Programming Language C++">N4950</a>.
</p>

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


<blockquote>
<pre>
namespace std::ranges {
  [&hellip;]
  template&lt;move_constructible T, semiregular Bound = unreachable_sentinel_t&gt;
    requires (is_object_v&lt;T&gt; &amp;&amp; same_as&lt;T, remove_cv_t&lt;T&gt;&gt; &amp;&amp;
              (<i>integer-like-with-usable-difference-type</i>&lt;Bound&gt; ||
               same_as&lt;Bound, unreachable_sentinel_t&gt;))
  class repeat_view : public view_interface&lt;repeat_view&lt;T, Bound&gt;&gt; {
  private:
    [&hellip;]
  public:
    [&hellip;]

    constexpr auto size() const <ins>noexcept</ins> requires (!same_as&lt;Bound, unreachable_sentinel_t&gt;);
  };
  [&hellip;]
}
</pre>
<p>[&hellip;]</p>
<pre>
constexpr auto size() const <ins>noexcept</ins> requires (!same_as&lt;Bound, unreachable_sentinel_t&gt;);
</pre>
<blockquote>
<p>
-9- <i>Effects:</i> Equivalent to: <code>return <i>to-unsigned-like</i>(<i>bound_</i>);</code>
</p>
</blockquote>
</blockquote>

</li>

<li><p>Modify 25.6.5.3 <a href="https://wg21.link/range.repeat.iterator">[range.repeat.iterator]</a>, class <code>repeat_view::<i>iterator</i></code> synopsis, as indicated:</p>

<blockquote>
<pre>
namespace std::ranges {
  template&lt;move_constructible T, semiregular Bound&gt;
    requires (is_object_v&lt;T&gt; &amp;&amp; same_as&lt;T, remove_cv_t&lt;T&gt;&gt; &amp;&amp;
              (<i>integer-like-with-usable-difference-type</i>&lt;Bound&gt; ||
               same_as&lt;Bound, unreachable_sentinel_t&gt;))
  class repeat_view&lt;T, Bound&gt;::<i>iterator</i> {
  private:
   using <i>index-type</i> =                          // <i>exposition only</i>
      conditional_t&lt;same_as&lt;Bound, unreachable_sentinel_t&gt;, ptrdiff_t, Bound&gt;;
   const T* <i>value_</i> = nullptr;                  // <i>exposition only</i>
   <i>index-type current_</i> = <i>index-type()</i>;         // <i>exposition only</i>

   constexpr explicit <i>iterator</i>(const T* value, <i>index-type</i> b = <i>index-type</i>());   // <i>exposition only</i>

  public:
    [&hellip;]
    constexpr <i>iterator</i>&amp; operator++() <ins>noexcept</ins>;
    constexpr <i>iterator</i> operator++(int) <ins>noexcept</ins>;

    constexpr const T&amp; operator[](difference_type n) const noexcept;

    friend constexpr bool operator==(const <i>iterator</i>&amp; x, const <i>iterator</i>&amp; y) <ins>noexcept</ins>;
    friend constexpr auto operator&lt;=&gt;(const <i>iterator</i>&amp; x, const <i>iterator</i>&amp; y) <ins>noexcept</ins>;

    friend constexpr difference_type operator-(const <i>iterator</i>&amp; x, const <i>iterator</i>&amp; y) <ins>noexcept</ins>;
  };
}
</pre>
<p>
[&hellip;]
</p>
<pre>
constexpr <i>iterator</i>&amp; operator++() <ins>noexcept</ins>;
</pre>
<blockquote>
<p>
-5- <i>Effects:</i> Equivalent to:
</p>
<blockquote><pre>
++<i>current_</i>;
return *this;
</pre></blockquote>
</blockquote>
<pre>
constexpr <i>iterator</i> operator++(int) <ins>noexcept</ins>;
</pre>
<blockquote>
<p>
-6- <i>Effects:</i> Equivalent to:
</p>
<blockquote><pre>
auto tmp = *this;
++*this;
return tmp;
</pre></blockquote>
</blockquote>
<p>[&hellip;]</p>
<pre>
friend constexpr bool operator==(const <i>iterator</i>&amp; x, const <i>iterator</i>&amp; y) <ins>noexcept</ins>;
</pre>
<blockquote>
<p>
-15- <i>Effects:</i> Equivalent to: <code>return x.<i>current_</i> == y.<i>current_</i>;</code>
</p>
</blockquote>
<pre>
friend constexpr auto operator&lt;=&gt;(const <i>iterator</i>&amp;x, const <i>iterator</i>&amp; y) <ins>noexcept</ins>;
</pre>
<blockquote>
<p>
-16- <i>Effects:</i> Equivalent to: <code>return x.<i>current_</i> &lt;=&gt; y.<i>current_</i>;</code>
</p>
</blockquote>
<p>[&hellip;]</p>
<pre>
friend constexpr difference_type operator-(const <i>iterator</i>&amp; x, const <i>iterator</i>&amp; y) <ins>noexcept</ins>;
</pre>
<blockquote>
<p>
-19- <i>Effects:</i> Equivalent to:
</p>
<blockquote><pre>
return static_cast&lt;difference_type&gt;(x.<i>current_</i>) - static_cast&lt;difference_type&gt;(y.<i>current_</i>);
</pre></blockquote>
</blockquote>
</blockquote>

</li>

</ol>





</body>
</html>
