[libcxx-commits] [PATCH] D128149: [libc++][ranges] Implement `ranges::nth_element`.

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 27 10:25:44 PDT 2022


huixie90 requested changes to this revision.
huixie90 added inline comments.


================
Comment at: libcxx/include/__algorithm/nth_element.h:71
+          _RandomAccessIterator __m = __first;
+          std::__sort3<_Compare>(__first, ++__m, --__last, __comp);
+          return;
----------------
similar for other reiviews, `ranges` overload require the implementation to use `iter_move` and `iter_swap`


================
Comment at: libcxx/include/__algorithm/nth_element.h:97
+      if (std::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {
+        swap(*__i, *__j);
+        ++__n_swaps;
----------------
`ranges` overload needs to use `iter_swap`. same for the rest of swaps


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128149/new/

https://reviews.llvm.org/D128149



More information about the libcxx-commits mailing list