|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4235" status="New"> |
| 5 | +<title><code>cache_latest_view</code> and <code>to_input_view</code> miss <code>reserve_hint</code></title> |
| 6 | +<section> |
| 7 | +<sref ref="[range.cache.latest.view]"/><sref ref="[range.to.input.view]"/> |
| 8 | +</section> |
| 9 | +<submitter>Hewill Kang</submitter> |
| 10 | +<date>25 Mar 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +Intuitively, both view classes should also have <code>reserve_hint</code> members. |
| 16 | +</p> |
| 17 | +</discussion> |
| 18 | + |
| 19 | +<resolution> |
| 20 | +<p> |
| 21 | +This wording is relative to <paper num="N5008"/>. |
| 22 | +</p> |
| 23 | + |
| 24 | +<ol> |
| 25 | + |
| 26 | +<li><p>Modify <sref ref="[range.cache.latest.view]"/> as indicated:</p> |
| 27 | + |
| 28 | +<blockquote> |
| 29 | +<blockquote> |
| 30 | +<pre> |
| 31 | +namespace std::ranges { |
| 32 | + template<input_range V> |
| 33 | + requires view<V> |
| 34 | + class cache_latest_view : public view_interface<cache_latest_view<V>> { |
| 35 | + […] |
| 36 | + constexpr auto size() requires sized_range<V>; |
| 37 | + constexpr auto size() const requires sized_range<const V>; |
| 38 | + |
| 39 | + <ins>constexpr auto reserve_hint() requires approximately_sized_range<V>; |
| 40 | + constexpr auto reserve_hint() const requires approximately_sized_range<const V>;</ins> |
| 41 | + }; |
| 42 | + […] |
| 43 | +} |
| 44 | +</pre> |
| 45 | +</blockquote> |
| 46 | +[…] |
| 47 | +<pre> |
| 48 | +constexpr auto size() requires sized_range<V>; |
| 49 | +constexpr auto size() const requires sized_range<const V>; |
| 50 | +</pre> |
| 51 | +<blockquote> |
| 52 | +<p> |
| 53 | +-4- <i>Effects</i>: Equivalent to: <tt>return ranges::size(<i>base_</i>);</tt> |
| 54 | +</p> |
| 55 | +</blockquote> |
| 56 | +<pre><ins> |
| 57 | +constexpr auto reserve_hint() requires approximately_sized_range<V>; |
| 58 | +constexpr auto reserve_hint() const requires approximately_sized_range<const V>;</ins> |
| 59 | +</pre> |
| 60 | +<blockquote> |
| 61 | +<p> |
| 62 | +<ins>-?- <i>Effects</i>: Equivalent to: <tt>return ranges::reserve_hint(<i>base_</i>);</tt></ins> |
| 63 | +</p> |
| 64 | +</blockquote> |
| 65 | +</blockquote> |
| 66 | + |
| 67 | +</li> |
| 68 | + |
| 69 | +<li><p>Modify <sref ref="[range.to.input.view]"/> as indicated:</p> |
| 70 | + |
| 71 | +<blockquote> |
| 72 | +<blockquote> |
| 73 | +<pre> |
| 74 | +template<input_range V> |
| 75 | + requires view<V> |
| 76 | +class to_input_view : public view_interface<to_input_view<V>> { |
| 77 | + […] |
| 78 | + constexpr auto size() requires sized_range<V>; |
| 79 | + constexpr auto size() const requires sized_range<const V>; |
| 80 | + |
| 81 | + <ins>constexpr auto reserve_hint() requires approximately_sized_range<V>; |
| 82 | + constexpr auto reserve_hint() const requires approximately_sized_range<const V>;</ins> |
| 83 | +}; |
| 84 | +[…] |
| 85 | +</pre> |
| 86 | +</blockquote> |
| 87 | +[…] |
| 88 | +<pre> |
| 89 | +constexpr auto size() requires sized_range<V>; |
| 90 | +constexpr auto size() const requires sized_range<const V>; |
| 91 | +</pre> |
| 92 | +<blockquote> |
| 93 | +<p> |
| 94 | +-5- <i>Effects</i>: Equivalent to: <tt>return ranges::size(<i>base_</i>);</tt> |
| 95 | +</p> |
| 96 | +</blockquote> |
| 97 | +<pre><ins> |
| 98 | +constexpr auto reserve_hint() requires approximately_sized_range<V>; |
| 99 | +constexpr auto reserve_hint() const requires approximately_sized_range<const V>;</ins> |
| 100 | +</pre> |
| 101 | +<blockquote> |
| 102 | +<p> |
| 103 | +<ins>-?- <i>Effects</i>: Equivalent to: <tt>return ranges::reserve_hint(<i>base_</i>);</tt></ins> |
| 104 | +</p> |
| 105 | +</blockquote> |
| 106 | +</blockquote> |
| 107 | + |
| 108 | +</li> |
| 109 | + |
| 110 | +</ol> |
| 111 | +</resolution> |
| 112 | + |
| 113 | +</issue> |
0 commit comments