Title
Constrain return type of transformation function for transform_view
Status
c++20
Section
[range.transform.view]
Submitter
United States

Created on 2019-11-06.00:00:00 last changed 38 months ago

Messages

Date: 2022-01-15.16:40:18

Proposed resolution:

This wording is relative to N4835.

  1. Modify [range.transform.view], class template transform_view synopsis, as indicated:

    namespace std::ranges {
      template<input_range V, copy_constructible F>
        requires view<V> && is_object_v<F> &&
                 regular_invocable<F&, range_reference_t<V>> &&
                 can-reference<invoke_result_t<F&, range_reference_t<V>>>
      class transform_view : public view_interface<transform_view<V, F>> {
        […]
      };
    […]
    }
    
Date: 2019-11-07.08:02:35

[ 2019-11 Status to Ready during Wednesday night issue processing in Belfast. ]

Date: 2019-11-06.00:00:00

Addresses US 303

The transform_view does not constrain the return type of the transformation function. It is invalid to pass a void-returning transformation function to the transform_view, which would cause its iterators' operator* member to return void.

Proposed change:

Change the constraints on transform_view to the following:

template<input_range V, copy_constructible F>
  requires view<V> && is_object_v<F> &&
           regular_invocable<F&, range_reference_t<V>> &&
           can-reference<invoke_result_t<F&, range_reference_t<V>>>
class transform_view;

Jonathan Wakely:

The NB comment says "The transform_view does not constrain the return type of the transformation function. It is invalid to pass a void-returning transformation function to the transform_view, which would cause its iterators' operator* member to return void."

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: voting -> wp
2020-01-17 04:54:50adminsetstatus: ready -> voting
2019-11-07 08:02:35adminsetmessages: + msg10776
2019-11-07 08:02:35adminsetstatus: new -> ready
2019-11-06 20:24:59adminsetmessages: + msg10766
2019-11-06 00:00:00admincreate