[libcxx-commits] [PATCH] D128149: [libc++][ranges] Implement `ranges::nth_element`.
Konstantin Varlamov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jul 2 15:59:18 PDT 2022
var-const added inline comments.
================
Comment at: libcxx/include/__algorithm/nth_element.h:230
+ _Compare& __comp) {
+ if (__nth != __last) {
+ _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);
----------------
I think this condition is necessary -- otherwise, the function isn't a no-op when `__nth == __last`. The standard doesn't say it should be a no-op explicitly, but nevertheless, it seems strange to have a call to `nth_element(vector.begin(), vector.end(), vector.end());` reshuffle the vector.
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