[libcxx-commits] [PATCH] D149706: [libc++][PSTL] Implement std::copy{, _n}

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 3 14:02:37 PDT 2023


ldionne accepted this revision.
ldionne added inline comments.
This revision is now accepted and ready to land.


================
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{});
----------------
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?


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