ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.11k stars 440 forks source link

drop_last - source range with fewer elements than to be dropped #1598

Closed szilardszaloki closed 3 years ago

szilardszaloki commented 3 years ago

Shouldn't drop_last produce an empty range if the source range has fewer elements than to be dropped? ("Given a source range and an integral count, return a range consisting of all but the last count elements from the source range, or an empty range if it has fewer elements." - https://ericniebler.github.io/range-v3/index.html#autotoc_md8)

for (std::vector one{ 1 }; auto i : one | ranges::views::drop_last(2)) {
    std::cout << i;
}

drop_last.hpp(53): RANGES_EXPECT(initial_size >= n); https://godbolt.org/z/81Kvs8

JohelEGP commented 3 years ago

@ericniebler This can be closed.