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

### 3726. `reverse_iterator::operator->` is underconstrained for non-pointer iterators

Section: 25.5.1.6 [reverse.iter.elem] Status: Tentatively NAD Submitter: Hewill Kang Opened: 2022-06-27 Last modified: 2022-08-23

Priority: Not Prioritized

View other active issues in [reverse.iter.elem].

View all other issues in [reverse.iter.elem].

View all issues with Tentatively NAD status.

Discussion:

For non-pointer types, `reverse_iterator::operator->` only requires the expression `i.operator->()` to be well-formed.

Since the return type of this function is explicitly specified as `pointer`, this will cause a hard error in the function body when the return type of `i.operator->()` cannot be converted to `pointer`.

We should add a return type constraint for this.

[2022-08-23; Reflector poll: NAD]

`pointer` is `iterator_traits<Iterator>::pointer`, which is required to name `decltype(i.operator->())` (25.3.2.3 [iterator.traits]/1) so the postulated problem simply does not arise in valid code.

Proposed resolution:

This wording is relative to N4910.

1. Modify 25.5.1.6 [reverse.iter.elem] as indicated:

   >     constexpr pointer operator->() const
   >       requires (is_pointer_v<Iterator> ||
   >                 requires(const Iterator i) { { i.operator->() } -> convertible_to<pointer>; });

   > > -2- Effects:

   > > 1. (2.1) — If `Iterator` is a pointer type, equivalent to: `return prev(current);`

   > > 2. (2.2) — Otherwise, equivalent to: `return prev(current).operator->();`