Skip to content

Commit

Permalink
Merge pull request #1599 from BRevzin/drop-last-empty
Browse files Browse the repository at this point in the history
Removing bogus assert in drop_last.
  • Loading branch information
ericniebler authored Apr 22, 2021
2 parents b014521 + 4a74aac commit b0696c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion include/range/v3/view/drop_last.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ namespace ranges
RANGES_EXPECT(n_ >= 0);
range_size_t<Rng> const initial_size = ranges::size(rng);
range_size_t<Rng> const n = static_cast<range_size_t<Rng>>(n_);
RANGES_EXPECT(initial_size >= n);
return initial_size > n ? initial_size - n : 0;
}

Expand Down
6 changes: 6 additions & 0 deletions test/view/drop_last.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ void test_range(Rng&& src)
auto list = src_ | views::drop_last(4);
CHECK(list.empty());
}
{
auto src_ = src;
auto list = src_ | views::drop_last(5);
CHECK(list.empty());
}
}

template<class Rng>
Expand All @@ -83,6 +88,7 @@ void test_size(Rng&& src)
CHECK( (src | views::drop_last(0)).size() == std::size_t(4) );
CHECK( (src | views::drop_last(2)).size() == std::size_t(2) );
CHECK( (src | views::drop_last(4)).size() == std::size_t(0) );
CHECK( (src | views::drop_last(5)).size() == std::size_t(0) );
}

template<class Rng>
Expand Down

0 comments on commit b0696c7

Please sign in to comment.