[libcxx-commits] [PATCH] D117817: [libc++][ranges] Implement ranges::mismatch

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 8 14:07:01 PST 2022


Quuxplusone added inline comments.


================
Comment at: libcxx/include/__algorithm/ranges_mismatch.h:61
+                                       _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+    return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
+  }
----------------
ldionne wrote:
> philnik wrote:
> > ldionne wrote:
> > > Any reason why we don't implement the algorithm here and then call `*this` in the range version immediately below?
> > With the current implementation the predicates and projections are never moved. using `*this()` would mean we have to move them at least once.
> Oh, I see. Clever. Can you please add a libc++ specific test for that? I know it's nitpicky, but that seems like a useful guarantee to test if we're providing it. I suggest finding a simple way to test this because I'll be requesting the same kind of test for other algorithms as well (e.g. `find_if`).
I'd be happy to tackle this in a different PR; it'd basically be a Ranges version of `libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117817



More information about the libcxx-commits mailing list