This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
cache_latest_view
and to_input_view
miss reserve_hint
Section: 25.7.34.2 [range.cache.latest.view], 25.7.35.2 [range.to.input.view] Status: New Submitter: Hewill Kang Opened: 2025-03-25 Last modified: 2025-03-27
Priority: Not Prioritized
View all issues with New status.
Discussion:
Intuitively, both view classes should also have reserve_hint
members.
Proposed resolution:
This wording is relative to N5008.
Modify 25.7.34.2 [range.cache.latest.view] as indicated:
[…]namespace std::ranges { template<input_range V> requires view<V> class cache_latest_view : public view_interface<cache_latest_view<V>> { […] constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>; constexpr auto reserve_hint() requires approximately_sized_range<V>; constexpr auto reserve_hint() const requires approximately_sized_range<const V>; }; […] }constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>;-4- Effects: Equivalent to:
return ranges::size(base_);
constexpr auto reserve_hint() requires approximately_sized_range<V>; constexpr auto reserve_hint() const requires approximately_sized_range<const V>;-?- Effects: Equivalent to:
return ranges::reserve_hint(base_);
Modify 25.7.35.2 [range.to.input.view] as indicated:
[…]template<input_range V> requires view<V> class to_input_view : public view_interface<to_input_view<V>> { […] constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>; constexpr auto reserve_hint() requires approximately_sized_range<V>; constexpr auto reserve_hint() const requires approximately_sized_range<const V>; }; […]constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>;-5- Effects: Equivalent to:
return ranges::size(base_);
constexpr auto reserve_hint() requires approximately_sized_range<V>; constexpr auto reserve_hint() const requires approximately_sized_range<const V>;-?- Effects: Equivalent to:
return ranges::reserve_hint(base_);