[libcxx-commits] [PATCH] D145287: [libc++] Fix ranges::binary_search() returning true for cases where the element is not in the range

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 7 08:29:00 PST 2023


philnik added inline comments.


================
Comment at: libcxx/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/ranges.lower_bound.pass.cpp:202
+      auto ret = std::ranges::lower_bound(It(a), It(a + 7), 5);
+      assert(base(ret) == a + 4);
+    }
----------------
Mordante wrote:
> Please test the value of `*ret` too. I know it's kind of double but it makes the test easier to understand.
> (The same for `upper_bound`.)
> 
> Do you know why these test don't use `std::begin(a)` and `std::end(a)`. To me that makes clear it tests the entire range and I don't need to count the elements.
I think Arthur wanted it that way, but I don't remember exactly why we did it that way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145287/new/

https://reviews.llvm.org/D145287



More information about the libcxx-commits mailing list