Title
reverse_iterator::operator-> is underconstrained for non-pointer iterators
Status
nad
Section
[reverse.iter.elem]
Submitter
Hewill Kang

Created on 2022-06-27.00:00:00 last changed 24 months ago

Messages

Date: 2022-11-30.17:59:24

Proposed resolution:

This wording is relative to N4910.

  1. Modify [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->();

Date: 2022-11-30.00:00:00

[ 2022-11-30 LWG telecon. Status changed: Tentatively NAD → NAD. ]

Date: 2022-08-15.00:00:00

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

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

Date: 2022-06-27.00:00:00

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.

History
Date User Action Args
2022-11-30 17:59:24adminsetmessages: + msg13133
2022-08-23 15:00:26adminsetmessages: + msg12683
2022-08-23 15:00:26adminsetstatus: new -> nad
2022-07-03 10:27:58adminsetmessages: + msg12542
2022-06-27 00:00:00admincreate