Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG6851d078c54e: [libc++][PSTL] Implement std::transform
rGcbd9e5454741: [libc++][PSTL] Implement std::transform
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/pstl.transform.binary.pass.cpp | ||
---|---|---|
23 | We should also include a SFINAE test that checks that we SFINAE-out whenever the first argument is not an execution policy. We could do that in a single big test file for all the algorithms, like we did for some ranges algorithms. | |
31 | I think we're missing tests for constraints here and in the other test. | |
libcxx/test/support/type_algorithms.h | ||
56–60 | I would suggest this instead: template <template <class...> class F, class ...T> struct partial_instantiation { template <class ...Args> using apply = F<T..., Args...>; }; This suggests that we're doing partial application of the template F. apply is often used in these cases so it's kind of idiomatic (e.g. the old MPL and derivatives of it). |
Address comments
libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/pstl.transform.binary.pass.cpp | ||
---|---|---|
31 | What kind of constraints do you mean? | |
libcxx/test/support/type_algorithms.h | ||
56–60 | template <class...> doesn't work when template <class> is expected. I first had it the way you have it right now. |
libcxx/include/__algorithm/pstl_transform.h | ||
---|---|---|
36–38 | Per your suggestion, we could name those _ForwardIterator and _ForwardOutIterator. And for the binary version, _ForwardIterator1, _ForwardIterator2, and _ForwardOutIterator. | |
libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/pstl.transform.binary.pass.cpp | ||
31 | I meant the execution policy constraint that you added a test for, thanks! I don't know why I left two comments that were so similar, maybe I wanted to point out that it was missing from both the tests. | |
50 | We need to test the result type of this algorithm (and all the other PSTL algorithms we have so far, where I think we've neglected that). | |
libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/pstl.transform.unary.pass.cpp | ||
29 | Here, let's add a comment explaining "we can't test the constraint on the execution policy, because that would conflict with the binary transform algorithm that doesn't take an execution policy, which is not constrained at all". |
libcxx/test/support/type_algorithms.h | ||
---|---|---|
56–60 | Ahhhh yeah I remember that issue. I still think apply would be a naming improvement though. |
LGTM w/ comments and CI. Thanks!!!
libcxx/include/__algorithm/pstl_transform.h | ||
---|---|---|
51 | We need to reject the case where a non-forward iterator is provided as the output (and also for the input I guess). Otherwise, folks could try to pass something like back_inserter which is not only invalid but also potentially dangerous (race conditions). We don't have to do this in this patch, but let's add appropriate static asserts pretty aggressively in the frontend "layer" of all the parallel algorithms in another patch. And from then on let's do it for all the algos. | |
libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/pstl.transform.binary.pass.cpp | ||
78 | I think we can do the lambda trick here. And in all the other patches you have open too, I guess. |
Per your suggestion, we could name those _ForwardIterator and _ForwardOutIterator. And for the binary version, _ForwardIterator1, _ForwardIterator2, and _ForwardOutIterator.