[libcxx-commits] [libcxx] [libc++] Introduce one-sided binary search for set_intersection so that it can be completed in sub-linear time for a large class of inputs. (PR #75230)

Iuri Chaer via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 24 04:59:19 PDT 2024


================
@@ -85,6 +86,56 @@ struct _IterOps<_ClassicAlgPolicy> {
     std::advance(__iter, __count);
   }
 
+  // advance with sentinel, a la std::ranges::advance
+  // it's unclear whether _Iter has a difference_type and whether that's signed, so we play it safe:
----------------
ichaer wrote:

I was trying to preserve compatibility with the previous implementation of `std::set_intersection()`, which didn't make use of `difference_type`. I completely agree with you that the standard requires `LegacyInputIterator`, which mandates the presence of `difference_type`, but it felt like a small price to pay to preserve the flexibility of the previous implementation...

I'm happy to tighten the requirements if you're sure.

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


More information about the libcxx-commits mailing list