aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/__algorithm/max_element.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-11-20 17:36:30 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-20 17:36:30 +0000
commit846a2208a8ab099f595fe7e8b2e6d54a7b5e67fb (patch)
tree73c1a7a230c8bb19317a3893d937c4d8a219e91c /libcxx/include/__algorithm/max_element.h
parentc0981da47d5696fe36474fcf86b4ce03ae3ff818 (diff)
Diffstat (limited to 'libcxx/include/__algorithm/max_element.h')
-rw-r--r--libcxx/include/__algorithm/max_element.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/libcxx/include/__algorithm/max_element.h b/libcxx/include/__algorithm/max_element.h
index c51519605af9..f932ca7049fa 100644
--- a/libcxx/include/__algorithm/max_element.h
+++ b/libcxx/include/__algorithm/max_element.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,11 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+template <class _Compare, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::max_element requires a ForwardIterator");
@@ -37,11 +36,17 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
return __first;
}
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp);
+}
+
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::max_element(__first, __last,