Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG3a7876f6e2b0: [libc++][PSTL] Implement std::is_partitioned
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__algorithm/pstl_is_partitioned.h | ||
---|---|---|
42 | You forgot to pass the policy to the find_if call. Also, this could be std::none_of(__policy, __g_first, __g_last, __g_pred);. | |
libcxx/test/std/algorithms/alg.sorting/alg.partitions/pstl.is_partitioned.pass.cpp | ||
28 | You're missing a test that is_partition(empty-range) is true. | |
33 | paritioned => partitioned. You probably want to search and replace globally, I can see other instances of this. You also have a few parititoned around. | |
45 | I think this comment is incomplete |
Address comments
libcxx/test/std/algorithms/alg.sorting/alg.partitions/pstl.is_partitioned.pass.cpp | ||
---|---|---|
45 | This is the empty range test. |
LGTM w/ fix and test
libcxx/include/__algorithm/pstl_is_partitioned.h | ||
---|---|---|
42–43 | Technically, I think we could implement it this way instead: __g_first = std::find_if_not(__policy, __g_first, __g_last, __g_pred); if (__g_first == __g_last) return true; ++__g_first; return std::none_of(__policy, __g_first, __g_last, __g_pred); This way, we avoid running the predicate twice on the first element that doesn't satisfy the predicate (which we do right now). This also mirrors what we do for the serial version of the algorithm. If you agree, I think it might be useful to add a test for this. In particular, we could have a libc++ specific test that ensures that we satisfy this complexity guarantee (from the serial version):
Could you also take a look at whether this is tested in the serial version, where that's definitely a requirement? |
You forgot to pass the policy to the find_if call.
Also, this could be std::none_of(__policy, __g_first, __g_last, __g_pred);.