3947. Unexpected constraints on adjacent_transform_view::base()

Section: 26.7.27.2 [range.adjacent.transform.view] Status: WP Submitter: Bo Persson Opened: 2023-06-17 Last modified: 2023-11-22 16:02:17 UTC

Priority: Not Prioritized

View all issues with WP status.

Discussion:

In section 26.7.27.2 [range.adjacent.transform.view] the class ranges::adjacent_transform_view got two new base() members from 3848.

The first one looks like

constexpr V base() const & requires copy_constructible<InnerView>
{ return inner_.base(); }

Here the requirement is that InnerView is copy constructible, when it in fact returns an object of type V. That seems odd.

I would expect the constraint to instead be copy_constructible<V>.

[2023-10-27; Reflector poll]

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

[2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4950.

  1. Modify 26.7.27.2 [range.adjacent.transform.view], class template adjacent_transform_view synopsis, 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>> {
        […]
        adjacent_view<V, N> inner_; // exposition only
        
        using InnerView = adjacent_view<V, N>; // exposition only
        […]
      public:
        […]
        constexpr V base() const & requires copy_constructible<VInnerView> { return inner_.base(); }
        constexpr V base() && { return std::move(inner_).base(); }
        […]
      };
    }