[libcxx-commits] [PATCH] D157131: [libc++][PSTL] Implement std::equal
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 16 08:53:48 PDT 2023
ldionne added inline comments.
================
Comment at: libcxx/include/__algorithm/pstl_equal.h:1
+//===----------------------------------------------------------------------===//
+//
----------------
Missing documentation comment for the backend.
================
Comment at: libcxx/include/__algorithm/pstl_equal.h:15
+#include <__functional/operations.h>
+#include <__numeric/pstl_transform_reduce.h>
+
----------------
`__utility/move.h`
================
Comment at: libcxx/include/__algorithm/pstl_equal.h:113
+ } else {
+ (void)__policy; // Avoid unused lambda captue warning
+ return std::equal(
----------------
================
Comment at: libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/pstl.equal.pass.cpp:48
+ template <class Policy>
+ void operator()(Policy&& policy) {
+ { // 3 iter overloads
----------------
We need to test combinations of empty ranges (empty/non-empty, non-empty/empty, empty/empty)
================
Comment at: libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/pstl.equal.pass.cpp:60-62
+ assert(std::equal(policy, Iter1(std::begin(a)), Iter1(std::end(a)), Iter2(std::begin(b)), [](int lhs, int rhs) {
+ return lhs == rhs || lhs + 1 == rhs || rhs + 1 == lhs;
+ }));
----------------
Why don't you just do this:
```
[](int lhs, int rhs) { return lhs % 2 == rhs % 2; };
```
Then you need to call that with two ranges that are not equal, but where all the elements have the same odd-ness.
================
Comment at: libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/pstl.exception_handling.pass.cpp:25
+#ifndef TEST_HAS_NO_EXCEPTIONS
+bool operator==(ThrowOnCompare, ThrowOnCompare) { throw int{}; }
+#endif
----------------
boilerplate
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157131/new/
https://reviews.llvm.org/D157131
More information about the libcxx-commits
mailing list