[libcxx-commits] [PATCH] D129390: [lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.
Hui via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 12 04:58:58 PDT 2022
huixie90 accepted this revision.
huixie90 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;
----------------
question. why double underscores here?
================
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));
+ }
----------------
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.
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