cplusplus / papers

ISO/IEC JTC1 SC22 WG21 paper scheduling and management
644 stars 18 forks source link

P3060 R1 Add std::views::upto(n) #1727

Open wg21bot opened 10 months ago

wg21bot commented 10 months ago

P3060R0 Add std::ranges::upto(n) (Weile Wei)

wg21bot commented 8 months ago

P3060R1 Add std::views::upto(n) (Weile Wei, Zhihao Yuan)

dhollman commented 7 months ago

SG9 agreed on the following summary of the discussion in the room, with the understanding that it would be posted to GitHub as the outcome of the discussion.


SG9 believes that the failure of the following (already arcane because of the name iota) beginner code to compile is a defect in the standard that is worth our time to address

vector v = { /*...*/ };
for (auto i : views::iota(0, ranges::size(v))) {
  // ...
}

Most of the rest of the discussion revolved around the name upto, the most popular alternative to which was indices. The arguments on each side were as follows:


We took the following polls to summarize the outcomes of our discussion:

_Change the name views::upto to views::indices (with the understanding that we anticipate probably later adding a facility like views::indices_of)_

SF F N A SA
6 6 2 3 0

Result: Consensus for change (borderline strong) Attendance: 17 Authors: N and A Author Against: the name doesn't look as generic as upto, but it's acceptable

SG9 believes that we should use the is-integer-like exposition-only constraint rather than the std::integral (is-integer-like allows implementation-defined types and removes bool).

SF F N A SA
6 9 0 0 0

Result: Unanimous Consent Attendance: 17 Authors: SF (x2)

Forward P3060R1 to LEWG with the two changes polled above for inclusion in C++26.

SF F N A SA
11 4 2 0 0

Result: Strong consensus Attendance: 17 Authors: SF


SG9 also polled on the inclusion of a facility like indices_of in the current paper, in an attempt to make the case for indices as a more compelling name. The poll had weak consensus, but one attendee discovered a late argument (raised in their strongly against statement) that convinced the room that indices_of should be in a separate paper: For a sized_range, indices_of has to choose whether to return a range of size_type or difference_type, either of which may lead to implicit conversions or other incompatibilities. The former choice may not work with indexing into the range, but the latter may be inconsistent with views::indices(ranges::size(r)), which would use the size_type. We anticipate a separate paper proposing this facility.