Created on 2025-02-15.00:00:00 last changed 2 weeks ago
Proposed resolution:
This wording is relative to N5001 plus additions from P3471R4.
Modify [range.take.overview] as indicated:
-2- The name
views::takedenotes a range adaptor object ([range.adaptor.object]). LetEandFbe expressions, letTberemove_cvref_t<decltype((E))>, and letDberange_difference_t<decltype((E))>. Ifdecltype((F))does not modelconvertible_to<D>,views::take(E, F)is ill-formed. Otherwise, the expressionviews::take(E, F)is expression-equivalent to:
(2.?) — Hardened preconditions:
static_cast<D>(F) >= 0istrue.(2.1) — if
Tis a specialization ofempty_view([range.empty.view]), then((void)F, decay-copy(E)), except that the evaluations ofEandFare indeterminately sequenced.
Modify [range.drop.overview] as indicated:
-2- The name
views::dropdenotes a range adaptor object ([range.adaptor.object]). LetEandFbe expressions, letTberemove_cvref_t<decltype((E))>, and letDberange_difference_t<decltype((E))>. Ifdecltype((F))does not modelconvertible_to<D>,views::drop(E, F)is ill-formed. Otherwise, the expressionviews::drop(E, F)is expression-equivalent to:
(2.?) — Hardened preconditions:
static_cast<D>(F) >= 0istrue.(2.1) — if
Tis a specialization ofempty_view([range.empty.view]), then((void)F, decay-copy(E)), except that the evaluations ofEandFare indeterminately sequenced.
[ 2025-10-21; Reflector poll. ]
Set priority to 3 after reflector poll.
"Disagreement on whether to introduce Hardened preconditions in this Clause. Some discomfort with adding the element as a bullet point inside a list, no better suggestions though.
[ 2025-02-24 ]
Upon reflector discussion many preferred to use instead the new Hardened preconditions: element which have been introduced by the recently voted in P3471R4.
The take/drop adaptor does not explicitly require N to be non-negative (although
the view class does), which makes it possible for some specialized cases to be well-defined when N is negative,
since no Preconditions are violated:
auto e = std::views::empty<int>
| std::views::take(-1); // []
auto i = std::views::iota(1, 5)
| std::views::drop(-1); // [0, 1, 2, 3, 4]
auto r = std::views::repeat('a', 2)
| std::views::drop(-1); // ['a', 'a', 'a']
This is not the intention, we should ban these cases.
This wording is relative to N5001.
Modify [range.take.overview] as indicated:
-2- The name
views::takedenotes a range adaptor object ([range.adaptor.object]). LetEandFbe expressions, letTberemove_cvref_t<decltype((E))>, and letDberange_difference_t<decltype((E))>. Ifdecltype((F))does not modelconvertible_to<D>,views::take(E, F)is ill-formed. Otherwise, the expressionviews::take(E, F)is expression-equivalent to:
(2.?) — Preconditions:
static_cast<D>(F) >= 0istrue.(2.1) — if
Tis a specialization ofempty_view([range.empty.view]), then((void)F, decay-copy(E)), except that the evaluations ofEandFare indeterminately sequenced.
Modify [range.drop.overview] as indicated:
-2- The name
views::dropdenotes a range adaptor object ([range.adaptor.object]). LetEandFbe expressions, letTberemove_cvref_t<decltype((E))>, and letDberange_difference_t<decltype((E))>. Ifdecltype((F))does not modelconvertible_to<D>,views::drop(E, F)is ill-formed. Otherwise, the expressionviews::drop(E, F)is expression-equivalent to:
(2.?) — Preconditions:
static_cast<D>(F) >= 0istrue.(2.1) — if
Tis a specialization ofempty_view([range.empty.view]), then((void)F, decay-copy(E)), except that the evaluations ofEandFare indeterminately sequenced.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-10-21 15:17:02 | admin | set | messages: + msg15324 |
| 2025-02-24 17:05:32 | admin | set | messages: + msg14659 |
| 2025-02-23 15:37:26 | admin | set | messages: + msg14656 |
| 2025-02-15 00:00:00 | admin | create | |