[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:30:27 PDT 2024
================
@@ -188,11 +229,12 @@ constexpr bool test() {
check_forward_sized_sentinel<int*>( range, range+size, n, expected);
}
- {
- // Note that we can only test ranges::advance with a negative n for iterators that
- // are sized sentinels for themselves, because ranges::advance is UB otherwise.
- // In particular, that excludes bidirectional_iterators since those are not sized sentinels.
+ // Exclude the `n == 0` case for the backwards checks.
----------------
jiixyj wrote:
I guess it isn't strictly needed. I thought it would be more appropriate for the `check_backward` tests to only test the `n < 0` case as the `n == 0` case is covered by the `check_forward` tests above. I added a comment to that effect.
https://github.com/llvm/llvm-project/pull/84126
More information about the libcxx-commits
mailing list