|
63 | 63 | <hr> |
64 | 64 | <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> |
65 | 65 | <h3 id="4226"><a href="lwg-active.html#4226">4226</a>. <code>to_input_view::<i>iterator</i></code> cannot be compared to its <code class='backtick'>const</code> sentinel</h3> |
66 | | -<p><b>Section:</b> 99 [range.to.input.view] <b>Status:</b> <a href="lwg-active.html#New">New</a> |
67 | | - <b>Submitter:</b> Hewill Kang <b>Opened:</b> 2025-03-15 <b>Last modified:</b> 2025-03-15</p> |
| 66 | +<p><b>Section:</b> 99 [range.to.input] <b>Status:</b> <a href="lwg-active.html#New">New</a> |
| 67 | + <b>Submitter:</b> Hewill Kang <b>Opened:</b> 2025-03-15 <b>Last modified:</b> 2025-03-16</p> |
68 | 68 | <p><b>Priority: </b>Not Prioritized |
69 | 69 | </p> |
70 | 70 | <p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> |
@@ -111,6 +111,211 @@ <h3 id="4226"><a href="lwg-active.html#4226">4226</a>. <code>to_input_view::<i>i |
111 | 111 |
|
112 | 112 |
|
113 | 113 | <p id="res-4226"><b>Proposed resolution:</b></p> |
| 114 | +<p> |
| 115 | +This wording is relative to the <a href="https://github.com/cplusplus/draft/actions/runs/13875532168/artifacts/2758179972"> |
| 116 | +working draft just after application of the Hagenberg motions</a>. |
| 117 | +</p> |
| 118 | + |
| 119 | +<ol> |
| 120 | + |
| 121 | +<li><p>Modify [range.to.input.view] as indicated:</p> |
| 122 | + |
| 123 | +<blockquote> |
| 124 | +<blockquote> |
| 125 | +<pre> |
| 126 | +namespace std::ranges { |
| 127 | + template<input_range V> |
| 128 | + requires view<V> |
| 129 | + class to_input_view : public view_interface<to_input_view<V>> { |
| 130 | + V <i>base_</i> = V(); // <i>exposition only</i> |
| 131 | + |
| 132 | + template<bool Const> |
| 133 | + class <i>iterator</i>; // <i>exposition only</i> |
| 134 | + <ins>template<bool Const> |
| 135 | + class <i>sentinel</i>; // <i>exposition only</i></ins> |
| 136 | + […] |
| 137 | + }; |
| 138 | + […] |
| 139 | +} |
| 140 | +</pre> |
| 141 | +</blockquote> |
| 142 | +[…] |
| 143 | +<pre> |
| 144 | +constexpr auto end() requires (!<i>simple-view</i><V>); |
| 145 | +</pre> |
| 146 | +<blockquote> |
| 147 | +<p> |
| 148 | +<ins>-?- <i>Effects</i>: Equivalent to:</ins> |
| 149 | +</p> |
| 150 | +<pre> |
| 151 | +<ins>return <i>sentinel</i><false>(ranges::end(<i>base_</i>));</ins> |
| 152 | +</pre> |
| 153 | +</blockquote> |
| 154 | +<pre> |
| 155 | +constexpr auto end() const requires range<const V>; |
| 156 | +</pre> |
| 157 | +<blockquote> |
| 158 | +<p> |
| 159 | +-4- <i>Effects</i>: Equivalent to: |
| 160 | +</p> |
| 161 | +<pre> |
| 162 | +return <ins><i>sentinel</i><true>(</ins>ranges::end(<i>base_</i>)<ins>)</ins>; |
| 163 | +</pre> |
| 164 | +</blockquote> |
| 165 | +</blockquote> |
| 166 | +</li> |
| 167 | + |
| 168 | +<li><p>Modify [range.to.input.iterator] as indicated:</p> |
| 169 | + |
| 170 | +<blockquote> |
| 171 | +<blockquote> |
| 172 | +<pre> |
| 173 | +namespace std::ranges { |
| 174 | + template<input_range V> |
| 175 | + requires view<V> |
| 176 | + template<bool Const> |
| 177 | + class to_input_view<V>::<i>iterator</i> { |
| 178 | + […] |
| 179 | + <del>friend constexpr bool operator==(const <i>iterator</i>& x, const sentinel_t<<i>Base</i>>& y); |
| 180 | + |
| 181 | + friend constexpr difference_type operator-(const sentinel_t<<i>Base</i>>& y, const <i>iterator</i>& x) |
| 182 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>Base</i>>>; |
| 183 | + friend constexpr difference_type operator-(const <i>iterator</i>& x, const sentinel_t<<i>Base</i>>& y) |
| 184 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>Base</i>>>;</del> |
| 185 | + […] |
| 186 | + }; |
| 187 | +} |
| 188 | +</pre> |
| 189 | +</blockquote> |
| 190 | +[…] |
| 191 | +<pre><del> |
| 192 | +friend constexpr bool operator==(const <i>iterator</i>& x, const sentinel_t<<i>Base</i>>& y);</del> |
| 193 | +</pre> |
| 194 | +<blockquote> |
| 195 | +<p> |
| 196 | +<del>-7- <i>Returns</i>: <code>x.<i>current_</i> == y</code>.</del> |
| 197 | +</p> |
| 198 | +</blockquote> |
| 199 | +<pre><del> |
| 200 | +friend constexpr difference_type operator-(const sentinel_t<<i>Base</i>>& y, const <i>iterator</i>& x) |
| 201 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>Base</i>>>;</del> |
| 202 | +</pre> |
| 203 | +<blockquote> |
| 204 | +<p> |
| 205 | +<del>-8- <i>Returns</i>: <code>y - x.<i>current_</i></code>.</del> |
| 206 | +</p> |
| 207 | +</blockquote> |
| 208 | +<pre><del> |
| 209 | +friend constexpr difference_type operator-(const <i>iterator</i>& x, const sentinel_t<<i>Base</i>>& y) |
| 210 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>Base</i>>>;</del> |
| 211 | +</pre> |
| 212 | +<blockquote> |
| 213 | +<p> |
| 214 | +<del>-9- <i>Returns</i>: <code>x.<i>current_</i> - y</code>.</del> |
| 215 | +</p> |
| 216 | +</blockquote> |
| 217 | +</blockquote> |
| 218 | +</li> |
| 219 | + |
| 220 | + |
| 221 | +<li><p>Add [range.to.input.sentinel] after [range.to.input.iterator] as indicated:</p> |
| 222 | + |
| 223 | +<blockquote> |
| 224 | +<blockquote> |
| 225 | +<pre><ins> |
| 226 | +namespace std::ranges { |
| 227 | + template<input_range V> |
| 228 | + requires view<V> |
| 229 | + template<bool Const> |
| 230 | + class to_input_view<V>::<i>sentinel</i> { |
| 231 | + using <i>Base</i> = <i>maybe-const</i><Const, V>; // <i>exposition only</i> |
| 232 | + sentinel_t<<i>Base</i>> <i>end_</i> = sentinel_t<<i>Base</i>>(); // <i>exposition only</i> |
| 233 | + constexpr explicit <i>sentinel</i>(sentinel_t<<i>Base</i>> end); // <i>exposition only</i> |
| 234 | + |
| 235 | + public: |
| 236 | + <i>sentinel</i>() = default; |
| 237 | + constexpr <i>sentinel</i>(<i>sentinel</i><!Const> other) |
| 238 | + requires Const && convertible_to<sentinel_t<V>, sentinel_t<<i>Base</i>>>; |
| 239 | + |
| 240 | + constexpr sentinel_t<Base> base() const; |
| 241 | + |
| 242 | + template<bool OtherConst> |
| 243 | + requires sentinel_for<sentinel_t<Base>, iterator_t<<i>maybe-const</i><OtherConst, V>>> |
| 244 | + friend constexpr bool operator==(const <i>iterator</i><OtherConst>& x, const <i>sentinel</i>& y); |
| 245 | + |
| 246 | + template<bool OtherConst> |
| 247 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>maybe-const</i><OtherConst, V>>> |
| 248 | + friend constexpr range_difference_t<<i>maybe-const</i><OtherConst, V>> |
| 249 | + operator-(const <i>iterator</i><OtherConst>& x, const <i>sentinel</i>& y); |
| 250 | + |
| 251 | + template<bool OtherConst> |
| 252 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>maybe-const</i><OtherConst, V>>> |
| 253 | + friend constexpr range_difference_t<<i>maybe-const</i><OtherConst, V>> |
| 254 | + operator-(const <i>sentinel</i>& x, const <i>iterator</i><OtherConst>& y); |
| 255 | + }; |
| 256 | +}</ins> |
| 257 | +</pre> |
| 258 | +</blockquote> |
| 259 | +<pre><ins> |
| 260 | +constexpr explicit <i>sentinel</i>(sentinel_t<<i>Base</i>> end);</ins> |
| 261 | +</pre> |
| 262 | +<blockquote> |
| 263 | +<p> |
| 264 | +<ins>-?- <i>Effects</i>: Initializes <code><i>end_</i></code> with <code>std::move(end)</code>.</ins> |
| 265 | +</p> |
| 266 | +</blockquote> |
| 267 | +<pre><ins> |
| 268 | +constexpr <i>sentinel</i>(<i>sentinel</i><!Const> other) |
| 269 | + requires Const && convertible_to<sentinel_t<V>, sentinel_t<<i>Base</i>>>;</ins> |
| 270 | +</pre> |
| 271 | +<blockquote> |
| 272 | +<p> |
| 273 | +<ins>-?- <i>Effects</i>: Initializes <code><i>end_</i></code> with <code>std::move(other.<i>end_</i>)</code>.</ins> |
| 274 | +</p> |
| 275 | +</blockquote> |
| 276 | +<pre><ins> |
| 277 | +constexpr sentinel_t<Base> base() const;</ins> |
| 278 | +</pre> |
| 279 | +<blockquote> |
| 280 | +<p> |
| 281 | +<ins>-?- <i>Effects</i>: Equivalent to: <code>return <i>end_</i>;</code></ins> |
| 282 | +</p> |
| 283 | +</blockquote> |
| 284 | +<pre><ins> |
| 285 | +template<bool OtherConst> |
| 286 | + requires sentinel_for<sentinel_t<Base>, iterator_t<<i>maybe-const</i><OtherConst, V>>> |
| 287 | +friend constexpr bool operator==(const <i>iterator</i><OtherConst>& x, const <i>sentinel</i>& y);</ins> |
| 288 | +</pre> |
| 289 | +<blockquote> |
| 290 | +<p> |
| 291 | +<ins>-?- <i>Effects</i>: Equivalent to: <code>return x.<i>current_</i> == y.<i>end_</i>;</code></ins> |
| 292 | +</p> |
| 293 | +</blockquote> |
| 294 | +<pre><ins> |
| 295 | +template<bool OtherConst> |
| 296 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>maybe-const</i><OtherConst, V>>> |
| 297 | +friend constexpr range_difference_t<<i>maybe-const</i><OtherConst, V>> |
| 298 | + operator-(const <i>iterator</i><OtherConst>& x, const <i>sentinel</i>& y);</ins> |
| 299 | +</pre> |
| 300 | +<blockquote> |
| 301 | +<p> |
| 302 | +<ins>-?5- <i>Effects</i>: Equivalent to: <code>return x.<i>current_</i> - y.<i>end_</i>;</code></ins> |
| 303 | +</p> |
| 304 | +</blockquote> |
| 305 | +<pre><ins> |
| 306 | +template<bool OtherConst> |
| 307 | + requires sized_sentinel_for<sentinel_t<<i>Base</i>>, iterator_t<<i>maybe-const</i><OtherConst, V>>> |
| 308 | +friend constexpr range_difference_t<<i>maybe-const</i><OtherConst, V>> |
| 309 | + operator-(const <i>sentinel</i>& x, const <i>iterator</i><OtherConst>& y);</ins> |
| 310 | +</pre> |
| 311 | +<blockquote> |
| 312 | +<p> |
| 313 | +<ins>-6- <i>Effects</i>: Equivalent to: <code>return x.<i>end_</i> - y.<i>current_</i>;</code></ins> |
| 314 | +</p> |
| 315 | +</blockquote> |
| 316 | +</blockquote> |
| 317 | +</li> |
| 318 | +</ol> |
114 | 319 |
|
115 | 320 |
|
116 | 321 |
|
|
0 commit comments