[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
Tue Mar 19 11:48:48 PDT 2024


================
@@ -213,6 +221,20 @@ constexpr bool test() {
     assert(i == iota_iterator{INT_MIN+1});
   }
 
+  // Check that we don't do an unneeded bounds check when decrementing a
----------------
jiixyj wrote:

The existing tests for the "backwards" case seem to exclude bidirectional iterators: <https://github.com/llvm/llvm-project/blob/1d296ec226903a09de0215e05d852b2b80712855/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/iterator_count_sentinel.pass.cpp#L191-L199>

So the tests didn't cover the part of `std::ranges::advance` where the iterator is decremented "one by one".

https://github.com/llvm/llvm-project/pull/84126


More information about the libcxx-commits mailing list