Skip to content

Commit 9bdf7bb

Browse files
committed
rebase
1 parent e2ec7a4 commit 9bdf7bb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libcxx/include/__ranges/drop_view.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ class drop_view : public view_interface<drop_view<_View>> {
9090
_LIBCPP_HIDE_FROM_ABI constexpr auto begin()
9191
requires(!(__simple_view<_View> && random_access_range<const _View> && sized_range<const _View>))
9292
{
93+
if constexpr (random_access_range<_View> && sized_range<_View>) {
94+
const auto __dist = std::min(ranges::distance(__base_), __count_);
95+
return ranges::begin(__base_) + __dist;
96+
}
9397
if constexpr (_UseCache)
9498
if (__cached_begin_.__has_value())
9599
return *__cached_begin_;
@@ -103,7 +107,8 @@ class drop_view : public view_interface<drop_view<_View>> {
103107
_LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
104108
requires random_access_range<const _View> && sized_range<const _View>
105109
{
106-
return ranges::next(ranges::begin(__base_), __count_, ranges::end(__base_));
110+
const auto __dist = std::min(ranges::distance(__base_), __count_);
111+
return ranges::begin(__base_) + __dist;
107112
}
108113

109114
_LIBCPP_HIDE_FROM_ABI constexpr auto end()

0 commit comments

Comments
 (0)