Created on 2023-11-08.00:00:00 last changed 2 days ago
Proposed resolution:
This wording is relative to N4964.
Modify [range.drop.view] as indicated:
constexpr auto begin()
requires (!(simple-view<V> &&
random_access_range<const V> && sized_range<const V>));
constexpr auto begin() const
requires random_access_range<const V> && sized_range<const V>;
-3- Returns:
(?.?) — If V models random_access_range and sized_range,
ranges::begin(base_) + (ranges::distance(base_) - range_difference_t<V>(size()))(?.?) — Otherwise, ranges::next(ranges::begin(base_), count_, ranges::end(base_)).
-4- Remarks: In order to provide the amortized constant-time complexity required by the range concept when V
[Note 1: Without this, applying a reverse_view over a drop_view would have quadratic iteration complexity. — end note]drop_viewdoes not modelsrandom_access_range and sized_rangeforward_range, this functionthe first overloadcaches the result within the drop_view for use on subsequent calls.
constexpr auto begin() const requires random_access_range<const V> && sized_range<const V>;
-?- Returns: ranges::begin(base_) + (ranges::distance(base_) - range_difference_t<const V>(size())).
[ 2025-10-22; Reflector poll. Status changed: New → Tentatively NAD ]
Set priority to 3 after reflector poll, status to Tentatively NAD.
"NAD, it's Returns: not 'Effects: Equivalent to ...', implementations need to implement it to return that while meeting the amortized 𝒪(1) guarantee."
drop_view::begin const is specified to return ranges::next(ranges::begin(base_), count_, ranges::end(base_)), which has 𝒪(n) complexity when base_ is a random-access-sized but non-common range (demo):
#include <ranges>
int main() {
const auto s = std::ranges::subrange(std::views::iota(0uz), size_t(-1));
const auto r = std::ranges::drop_view(s, s.size() - 1);
const auto b = r.begin(); // time out
}
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-10-22 17:48:23 | admin | set | messages: + msg15362 |
| 2025-10-22 17:48:23 | admin | set | status: new -> nad |
| 2023-11-18 11:26:51 | admin | set | messages: + msg13859 |
| 2023-11-08 00:00:00 | admin | create | |