This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.

3710. The end of chunk_view for input ranges can be const

Section: 26.7.28.2 [range.chunk.view.input] Status: C++23 Submitter: Hewill Kang Opened: 2022-06-09 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [range.chunk.view.input].

View all issues with C++23 status.

Discussion:

The input range version of chunk_view's end is a very simple function that only returns default_sentinel, and simple ends like this also appear in other range adaptors, such as basic_istream_view, lazy_split_view::outer-iterator::value_type, and chunk_view::outer-iterator::value_type.

However, unlike chunk_view, their ends all are const-qualified, which allows us to freely get default_sentinel through the end of these const objects even though they may not themselves be ranges.

I think we should add const to this chunk_view's end as I don't see any harm in doing this, and in some cases, it may have a certain value. Also, this makes it consistent with basic_istream_view and the upcoming std::generator, which, like it, only has a non-const begin.

[2022-06-21; Reflector poll]

Set status to Tentatively Ready after eight votes in favour during reflector poll.

[2022-07-15; LWG telecon: move to Ready]

[2022-07-25 Approved at July 2022 virtual plenary. Status changed: Ready → WP.]

Proposed resolution:

This wording is relative to N4910.

  1. Modify 26.7.28.2 [range.chunk.view.input] as indicated:

    namespace std::ranges {
      […]
     
      template<view V>
        requires input_range<V>
      class chunk_view : public view_interface<chunk_view<V>> {
        V base_ = V();                                        // exposition only
        […]
      public:
        […]
    
        constexpr outer-iterator begin();
        constexpr default_sentinel_t end() const noexcept;
    
        constexpr auto size() requires sized_range<V>;
        constexpr auto size() const requires sized_range<const V>;
      };
      […]
    }
    
    […]
    constexpr default_sentinel_t end() const noexcept;
    

    -4- Returns: default_sentinel.