|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4116" status="New"> |
| 5 | +<title><tt>enumerate_view::<i>iterator</i></tt> and <tt>cartesian_product_view::<i>iterator</i></tt> should not |
| 6 | + always provide <tt>iterator_category</tt></title> |
| 7 | +<section><sref ref="[range.enumerate.iterator]"/><sref ref="[range.cartesian.iterator]"/></section> |
| 8 | +<submitter>Hewill Kang</submitter> |
| 9 | +<date>07 Jul 2024</date> |
| 10 | +<priority>99</priority> |
| 11 | + |
| 12 | +<discussion> |
| 13 | +<p> |
| 14 | +These two iterators do not support <tt>*r++</tt> for non-forward iterators, |
| 15 | +so we should not provide <tt>iterator_category</tt> as they are not C++17 iterators. |
| 16 | +</p> |
| 17 | +</discussion> |
| 18 | + |
| 19 | +<resolution> |
| 20 | +<p> |
| 21 | +This wording is relative to <paper num="N4981"/>. |
| 22 | +</p> |
| 23 | + |
| 24 | +<ol> |
| 25 | +<li><p>Modify <sref ref="[range.enumerate.iterator]"/> as indicated:</p> |
| 26 | + |
| 27 | +<blockquote><pre> |
| 28 | +namespace std::ranges { |
| 29 | + template<view V> |
| 30 | + requires <i>range-with-movable-references</i><V> |
| 31 | + template<bool Const> |
| 32 | + class enumerate_view<V>::<i>iterator</i> { |
| 33 | + using <i>Base</i> = <i>maybe-const</i><Const, V>; // <i>exposition only</i> |
| 34 | + |
| 35 | + public: |
| 36 | + using iterator_category = input_iterator_tag; <ins>// present only if <i>Base</i> |
| 37 | + // models forward_range</ins> |
| 38 | + using iterator_concept = <i>see below</i>; |
| 39 | + […] |
| 40 | + }; |
| 41 | +} |
| 42 | +</pre></blockquote> |
| 43 | + |
| 44 | +</li> |
| 45 | + |
| 46 | +<li><p>Modify <sref ref="[range.cartesian.iterator]"/> as indicated:</p> |
| 47 | + |
| 48 | +<blockquote> |
| 49 | +<pre> |
| 50 | +namespace std::ranges { |
| 51 | + template<input_range First, forward_range... Vs> |
| 52 | + requires (view<First> && ... && view<Vs>) |
| 53 | + template<bool Const> |
| 54 | + class cartesian_product_view<First, Vs...>::<i>iterator</i> { |
| 55 | + public: |
| 56 | + using iterator_category = input_iterator_tag; <ins>// present only if <i><i>maybe-const</i><Const, First></i> |
| 57 | + // models forward_range</ins> |
| 58 | + using iterator_concept = see below; |
| 59 | + […] |
| 60 | + }; |
| 61 | +} |
| 62 | +</pre> |
| 63 | +</blockquote> |
| 64 | + |
| 65 | +</li> |
| 66 | +</ol> |
| 67 | +</resolution> |
| 68 | + |
| 69 | +</issue> |
0 commit comments