[libcxx-commits] [libcxx] [libc++] `std::ranges::advance`: avoid unneeded bounds checks when advancing iterator (PR #84126)
Jan Kokemüller via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 1 03:37:16 PDT 2024
================
@@ -42,6 +42,18 @@ constexpr void check_forward(int* first, int* last, std::iter_difference_t<It> n
// regardless of the iterator category.
assert(it.stride_count() == M);
assert(it.stride_displacement() == M);
+ if (n == 0) {
----------------
jiixyj wrote:
I think I finally understand. I now pass in the expected `stride_count`/`stride_displacement`/`equals_count` as appropriate so that the logic of the tests is now simpler. The tradeoff is at the call site of `check_forward`/`check_backward` where I need to calculate the expected values.
Did you have something like this in mind?
https://github.com/llvm/llvm-project/pull/84126
More information about the libcxx-commits
mailing list