[libcxx-commits] [PATCH] D149706: [libc++][PSTL] Implement std::copy{, _n}
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 4 17:48:13 PDT 2023
philnik added inline comments.
================
Comment at: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy.pass.cpp:98
+int main(int, char**) {
+ types::for_each(types::forward_iterator_list<int*>{}, TestIteratorsInt{});
+ types::for_each(types::forward_iterator_list<CopiedToTester*>{}, TestIteratorsNonTrivial{});
----------------
ldionne wrote:
> I see this is repeating a lot, and because of C++17 we can't use template lambas. But we can do this:
>
> ```
> types::for_each(types::forward_iterator_list<int*>{}, types::apply_type_identity([](auto It) {
> using Iter = typename decltype(It)::type;
> // the rest of your stuff
> }));
>
> // where
> template <class F>
> struct apply_type_identity {
> F f;
> template <class ...Args>
> auto operator()() const {
> return f(std::type_identity<Args>{}...);
> }
> };
> ```
>
> We can bikeshed about the name of `apply_type_identity`, I'm open to anything reasonable. IMO if we apply this throughout, it will localize the "loops" and make the testing code easier to read (and write!). WDYT?
I'm not a huge fan of the name, but I can't come up with anything better.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149706/new/
https://reviews.llvm.org/D149706
More information about the libcxx-commits
mailing list