Title
adjacent_view, adjacent_transform_view and slide_view missing base accessor
Status
c++23
Section
[range.adjacent.view] [range.adjacent.transform.view] [range.slide.view]
Submitter
Hewill Kang

Created on 2023-01-06.00:00:00 last changed 12 months ago

Messages

Date: 2023-02-13.10:17:57

Proposed resolution:

This wording is relative to N4917.

  1. Modify [range.adjacent.view] as indicated:

    namespace std::ranges {
      template<forward_range V, size_t N>
        requires view<V> && (N > 0)
      class adjacent_view : public view_interface<adjacent_view<V, N>> {
        V base_ = V();                      // exposition only
        […]
      public:
        adjacent_view() requires default_initializable<V> = default;
        constexpr explicit adjacent_view(V base);
    
        constexpr V base() const & requires copy_constructible<V> { return base_; }
        constexpr V base() && { return std::move(base_); }
        […]
      };
    }
    
  2. Modify [range.adjacent.transform.view] as indicated:

    namespace std::ranges {
      template<forward_range V, move_constructible F, size_t N>
        requires view<V> && (N > 0) && is_object_v<F> &&
                 regular_invocable<F&, REPEAT(range_reference_t<V>, N)...> &&
                 can-reference<invoke_result_t<F&, REPEAT(range_reference_t<V>, N)...>>
      class adjacent_transform_view : public view_interface<adjacent_transform_view<V, F, N>> {
        movable-box<F> fun_;                        // exposition only
        adjacent_view<V, N> inner_;                 // exposition only
    
        using InnerView = adjacent_view<V, N>;      // exposition only
        […]
      public:
        adjacent_transform_view() = default;
        constexpr explicit adjacent_transform_view(V base, F fun);
    
        constexpr V base() const & requires copy_constructible<InnerView> { return inner_.base(); }
        constexpr V base() && { return std::move(inner_).base(); }
        […]
      };
    }
    
  3. Modify [range.slide.view] as indicated:

    namespace std::ranges {
      […]
      template<forward_range V>
        requires view<V>
      class slide_view : public view_interface<slide_view<V>> {
        V base_;                            // exposition only
        range_difference_t<V> n_;           // exposition only
        […]
      public:
        constexpr explicit slide_view(V base, range_difference_t<V> n);
    
        constexpr V base() const & requires copy_constructible<V> { return base_; }
        constexpr V base() && { return std::move(base_); }
        […]
      };
      […]
    }
    
Date: 2023-02-13.00:00:00

[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting → WP. ]

Date: 2023-02-15.00:00:00

[ 2023-02-01; Reflector poll ]

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

Date: 2023-01-06.00:00:00

Like most range adaptors, these three views accept a single range and store it as a member variable. However, they do not provide a base() member function for accessing the underlying range, which seems like an oversight.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2023-02-13 10:17:57adminsetmessages: + msg13368
2023-02-13 10:17:57adminsetstatus: voting -> wp
2023-02-06 15:33:48adminsetstatus: ready -> voting
2023-02-01 20:28:28adminsetmessages: + msg13242
2023-02-01 20:28:28adminsetstatus: new -> ready
2023-01-06 16:24:01adminsetmessages: + msg13183
2023-01-06 00:00:00admincreate