[libcxx-commits] [PATCH] D149615: [libc++][PSTL] Implement std::transform
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 12 08:26:23 PDT 2023
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.
LGTM w/ comments and CI. Thanks!!!
================
Comment at: libcxx/include/__algorithm/pstl_transform.h:50
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
+ _ExecutionPolicy&& __policy,
----------------
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.
================
Comment at: libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/pstl.transform.binary.pass.cpp:77
+ void operator()() {
+ types::for_each(types::forward_iterator_list<int*>{}, TestIterators2<Iter3>{});
+ }
----------------
I think we can do the lambda trick here. And in all the other patches you have open too, I guess.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149615/new/
https://reviews.llvm.org/D149615
More information about the libcxx-commits
mailing list