[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:39 PDT 2024


================
@@ -76,7 +88,11 @@ constexpr void check_forward_sized_sentinel(int* first, int* last, std::iter_dif
 
 template <typename It>
 constexpr void check_backward(int* first, int* last, std::iter_difference_t<It> n, int* expected) {
-  static_assert(std::random_access_iterator<It>, "This test doesn't support non random access iterators");
+  // Check preconditions for `advance` when called with negative `n`:
+  // <https://eel.is/c++draft/iterators#range.iter.op.advance-5>
----------------
jiixyj wrote:

done!

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


More information about the libcxx-commits mailing list