[libcxx-commits] [PATCH] D118400: [libc++] Remove operator-> from the iterator archetypes
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 28 11:40:43 PST 2022
ldionne added inline comments.
================
Comment at: libcxx/test/support/test_iterators.h:253-264
+namespace std {
+ template <class It>
+ struct pointer_traits<::contiguous_iterator<It>> {
+ using pointer = ::contiguous_iterator<It>;
+ using element_type = typename pointer_traits<It>::element_type;
+ using difference_type = typename pointer_traits<It>::difference_type;
+ template <class Other>
----------------
Quuxplusone wrote:
> (A) please don't reopen namespace std, but also (B) please don't specialize `pointer_traits`.
> Is your goal just to make `contiguous_iterator` a contiguous iterator while (for some reason) removing its `operator->`? You can do that by giving `contiguous_iterator` a member `using element_type = typename pointer_traits<It>::element_type;`.
> https://stackoverflow.com/questions/65712091/in-c20-how-do-i-write-a-contiguous-iterator
>
> (A) please don't reopen namespace std, but also (B) please don't specialize pointer_traits.
Can you please explain why that's bad? That seems gratuitous -- `pointer_traits` is explicitly made to be customized, no? Arguably, if I could remove all that complexity and only have `element_type`, that would indeed better, but I don't see why specializing `pointer_traits` would be bad in itself. **Edit: Nope, that doesn't work, I have to keep `operator->()`.**
> Is your goal just to make `contiguous_iterator` a contiguous iterator while (for some reason) removing its `operator->`?
Yes, that's my goal. The reason is to make `congituous_iterator` more minimal, just like the other changes we did to e.g. `cpp17_input_iterator` to remove default-constructibility. Because it makes it more useful for testing.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118400/new/
https://reviews.llvm.org/D118400
More information about the libcxx-commits
mailing list