[libcxx-commits] [libcxx] [libc++] Refactor std::equal to forward to the 3-leg overload if the size of the ranges is known (PR #171585)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 18 09:23:39 PST 2025


================
@@ -51,20 +52,15 @@ struct __equal {
       _Pred __pred   = {},
       _Proj1 __proj1 = {},
       _Proj2 __proj2 = {}) const {
-    if constexpr (sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>) {
-      if (__last1 - __first1 != __last2 - __first2)
+    auto [__ufirst1, __ulast1] = std::__unwrap_range(std::move(__first1), std::move(__last1));
+    auto [__ufirst2, __ulast2] = std::__unwrap_range(std::move(__first2), std::move(__last2));
----------------
ldionne wrote:

I would unwrap after doing the `if` check.

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


More information about the libcxx-commits mailing list