Title
iota_view::size sometimes rejects integer-class types
Status
c++23
Section
[range.iota.view]
Submitter
Jiang An

Created on 2021-09-29.00:00:00 last changed 12 months ago

Messages

Date: 2022-02-10.12:58:57

Proposed resolution:

This wording is relative to N4892.

  1. Modify [range.iota.view] as indicated:

    constexpr auto size() const requires see below;
    

    -15- Effects: Equivalent to:

    if constexpr (is-integer-like<W> && is-integer-like<Bound>)
      return (value_ < 0)
        ? ((bound_ < 0)
          ? to-unsigned-like(-value_) - to-unsigned-like(-bound_)
          : to-unsigned-like(bound_) + to-unsigned-like(-value_))
        : to-unsigned-like(bound_) - to-unsigned-like(value_);
    else
      return to-unsigned-like(bound_ - value_);
    

    -16- Remarks: The expression in the requires-clause is equivalent to:

    (same_as<W, Bound> && advanceable<W>) || (integralis-integer-like<W> && integralis-integer-like<Bound>) ||
      sized_sentinel_for<Bound, W>
    
Date: 2022-02-10.00:00:00

[ 2022-02-10 Approved at February 2022 virtual plenary. Status changed: Tentatively Ready → WP. ]

Date: 2021-10-15.00:00:00

[ 2021-10-14; Reflector poll ]

Set status to Tentatively Ready after six votes in favour during reflector poll.

Date: 2021-09-29.00:00:00

It seems that the iota_view tends to accept integer-class types as its value types, by using is-integer-like or is-signed-integer-like through the specification, although it's unspecified whether any of them satisfies weakly_incrementable. However, the requires-clause of iota_view::size ([range.iota.view] p16) uses (integral<W> && integral<Bound>), which sometimes rejects integer-class types.

Should we relax the restrictions by changing this part to (is-integer-like<W> && is-integer-like<Bound>)?

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-02-10 12:58:57adminsetmessages: + msg12351
2022-02-10 12:58:57adminsetstatus: ready -> wp
2021-10-14 11:35:22adminsetmessages: + msg12150
2021-10-14 11:35:22adminsetstatus: new -> ready
2021-10-03 13:27:56adminsetmessages: + msg12092
2021-09-29 00:00:00admincreate