3558. elements_view::sentinel's first operator- has wrong return type

Section: 25.7.23.4 [range.elements.sentinel] Status: NAD Editorial Submitter: Hewill Kang Opened: 2021-05-28 Last modified: 2021-06-07

Priority: Not Prioritized

View all issues with NAD Editorial status.

Discussion:

Because the iterator type of the first operator- is const iterator<OtherConst>&, its return type should be range_difference_t<maybe-const<OtherConst, V>>.

[2021-06-07 Fixed by editorial issue #4603. Status changed: New → NAD Editorial.]

Proposed resolution:

This wording is relative to N4885.

  1. Modify 25.7.23.4 [range.elements.sentinel] as indicated:

        […]
        template<bool OtherConst>
          requires sized_sentinel_for<sentinel_t<Base>, iterator_t<maybe-const<OtherConst, V>>>
        friend constexpr range_difference_t<Basemaybe-const<OtherConst, V>>
          operator-(const iterator<OtherConst>& x, const sentinel& y);
        
        template<bool OtherConst>
          requires sized_sentinel_for<sentinel_t<Base>, iterator_t<maybe-const<OtherConst, V>>>
        friend constexpr range_difference_t<maybe-const<OtherConst, V>>
          operator-(const sentinel& x, const iterator<OtherConst>& y);
      };
    }
    
    […]
    template<bool OtherConst>
      requires sized_sentinel_for<sentinel_t<Base>, iterator_t<maybe-const<OtherConst, V>>>
    friend constexpr range_difference_t<Basemaybe-const<OtherConst, V>>
      operator-(const iterator<OtherConst>& x, const sentinel& y);
    

    -5- Effects: Equivalent to: return x.current_ - y.end_;