[libcxx-commits] [libcxx] 40f7fca - [libc++] Add ranges::max_element to the synopsis and ADL-proof the __min_element_impl calls

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 23 11:50:50 PDT 2022


Author: Nikolas Klauser
Date: 2022-05-23T20:50:04+02:00
New Revision: 40f7fca3d91fa4a480a7f8477a207a6a1a4a2496

URL: https://github.com/llvm/llvm-project/commit/40f7fca3d91fa4a480a7f8477a207a6a1a4a2496
DIFF: https://github.com/llvm/llvm-project/commit/40f7fca3d91fa4a480a7f8477a207a6a1a4a2496.diff

LOG: [libc++] Add ranges::max_element to the synopsis and ADL-proof the __min_element_impl calls

Reviewed By: ldionne, #libc

Spies: sstefan1, libcxx-commits

Differential Revision: https://reviews.llvm.org/D126167

Added: 
    

Modified: 
    libcxx/include/__algorithm/ranges_max_element.h
    libcxx/include/algorithm

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__algorithm/ranges_max_element.h b/libcxx/include/__algorithm/ranges_max_element.h
index 2ec464a52d8b6..d8d7242e176bb 100644
--- a/libcxx/include/__algorithm/ranges_max_element.h
+++ b/libcxx/include/__algorithm/ranges_max_element.h
@@ -36,7 +36,7 @@ struct __fn {
   _LIBCPP_HIDE_FROM_ABI constexpr
   _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
     auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
-    return __min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
+    return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
   }
 
   template <forward_range _Rp, class _Proj = identity,
@@ -44,7 +44,7 @@ struct __fn {
   _LIBCPP_HIDE_FROM_ABI constexpr
   borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
     auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
-    return __min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
+    return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
   }
 };
 } // namespace __max_element

diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 1a75dc0dacb22..a95fa769f024a 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -45,6 +45,15 @@ namespace ranges {
     indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
   constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
 
+  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+    indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+  constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {});                        // since C++20
+
+  template<forward_range R, class Proj = identity,
+    indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+  constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {});             // since C++20
+
+
   template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
     requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>


        


More information about the libcxx-commits mailing list