[libcxx-commits] [PATCH] D129390: [lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 12 05:12:34 PDT 2022
philnik added inline comments.
================
Comment at: libcxx/include/__algorithm/iterator_operations.h:39
static constexpr auto distance = ranges::distance;
+ static constexpr auto __iter_move = ranges::iter_move;
+ static constexpr auto iter_swap = ranges::iter_swap;
----------------
huixie90 wrote:
> question. why double underscores here?
`iter_move` is only used by the standard since C++20, so we can't use it in earlier versions.
================
Comment at: libcxx/include/__algorithm/iterator_operations.h:76
+ static void iter_swap(_Iter1&& __a, _Iter2&& __b) {
+ std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b));
+ }
----------------
huixie90 wrote:
> philnik wrote:
> > Is there a reason you don't use the customization point? AFAIK `iter_swap` has to be implemented properly or not at all, just like `swap`.
> `std::iter_swap` is not a customization point, it simply does the two step `swap` (`using std::swap` then ADL `swap`).
> On the other hand, `std::ranges::iter_swap` is a customization point where ADL `iter_swap` should be looked up.
> (unrelated but FYI `std::iter_swap` is not constrained so to make `std::ranges::iter_swap` work probably, it needs the poison pill `void iter_swap(a,b) = delete;`)
>
> Anyway I think this code is fine as `std::iter_swap` isn't a customization point.
I misread the cppreference entry as it being a customization point. Never mind then.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129390/new/
https://reviews.llvm.org/D129390
More information about the libcxx-commits
mailing list