[libcxx-commits] [PATCH] D121964: [libc++][ranges] Implement ranges::binary_search and ranges::{lower, upper}_bound
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 20 13:40:22 PDT 2022
philnik added inline comments.
================
Comment at: libcxx/include/__algorithm/ranges_upper_bound.h:49
+ _Proj __proj = {}) const {
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return !std::invoke(__comp, __rhs, __lhs); };
+ return __lower_bound_impl(ranges::begin(__r), ranges::end(__r), __value, __comp_lhs_rhs_swapped, __proj);
----------------
philnik wrote:
> ldionne wrote:
> > Should we be forwarding `__lhs` and `__rhs`? I think we're not losing anything if we do it, and I suspect we might be required to (if so, then we're also missing a test case).
> `indirect_strict_weak_order` requires that `_Comp` is equality preserving (meaning that cv ref qualifications still give the same output) and it's callable with l- and rvalues, so only the const-ness has to stay (unless I missed some requirement). Because of this I see no reason to make the code harder to read. I think this should actually just be `auto& __lhs, auto& __rhs`.
Ignore the last part. Using `auto&` would just make the implementation weirder.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121964/new/
https://reviews.llvm.org/D121964
More information about the libcxx-commits
mailing list