[libcxx-commits] [libcxx] [libc++] `std::ranges::advance`: avoid unneeded bounds checks when advancing iterator (PR #84126)

Konstantin Varlamov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 31 16:24:57 PDT 2024


Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/84126 at github.com>


================
@@ -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) {
----------------
var-const wrote:

I would still prefer to pass the expected number of comparisons as an argument to the function -- is it undesirable for some reason? Comments definitely made it clearer what's going on, but my first reaction is still that there's too much logic in this test case.

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


More information about the libcxx-commits mailing list