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

### 3325. Constrain return type of transformation function for `transform_view`

Section: 24.7.7.2 [range.transform.view] Status: C++20 Submitter: United States Opened: 2019-11-06 Last modified: 2022-01-15

Priority: 0

View all issues with C++20 status.

Discussion:

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 `iterator`s' `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 `iterator`s' `operator*` member to return `void`."

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

Proposed resolution:

This wording is relative to N4835.

1. Modify 24.7.7.2 [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>> {
   >         […]
   >       };
   >     […]
   >     }