[libcxx-commits] [libcxx] optimize minmax_element (PR #135495)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Apr 12 07:49:34 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h -- libcxx/include/__algorithm/minmax_element.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__algorithm/minmax_element.h b/libcxx/include/__algorithm/minmax_element.h
index 9f6ca6026..d69698573 100644
--- a/libcxx/include/__algorithm/minmax_element.h
+++ b/libcxx/include/__algorithm/minmax_element.h
@@ -39,10 +39,10 @@ public:
}
};
-template<class _Iter, class _Sent, class _Proj, class _Comp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter>
+template <class _Iter, class _Sent, class _Proj, class _Comp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter>
__minmax_element_loop(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
- __builtin_printf("Debug: __minmax_element_impl called, %d\n", __LINE__); // 不需要 iostream
+ __builtin_printf("Debug: __minmax_element_impl called, %d\n", __LINE__); // 不需要 iostream
auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
pair<_Iter, _Iter> __result(__first, __first);
@@ -80,41 +80,41 @@ __minmax_element_loop(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj)
return __result;
}
-
// template<class _Tp>
// typename std::iterator_traits<_Iter>::value_type
// __minmax_element_vectorized(_Tp __first, _Tp __last) {
// }
-
-template <class _Iter, class _Proj, class _Comp,
- __enable_if_t<is_integral_v<typename std::iterator_traits<_Iter>::value_type>
- && __is_identity<_Proj>::value && __desugars_to_v<__less_tag, _Comp, _Iter, _Iter>,
- int> = 0
- >
+template <class _Iter,
+ class _Proj,
+ class _Comp,
+ __enable_if_t<is_integral_v<typename std::iterator_traits<_Iter>::value_type> &&
+ __is_identity<_Proj>::value && __desugars_to_v<__less_tag, _Comp, _Iter, _Iter>,
+ int> = 0 >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter>
__minmax_element_impl(_Iter __first, _Iter __last, _Comp& __comp, _Proj& __proj) {
if (__libcpp_is_constant_evaluated()) {
return __minmax_element_loop(__first, __last, __comp, __proj);
} else {
-
}
}
-template <class _Iter, class _Proj, class _Comp,
- __enable_if_t<!is_integral_v<typename std::iterator_traits<_Iter>::value_type>
- && __can_map_to_integer_v<typename std::iterator_traits<_Iter>::value_type>
- && __libcpp_is_trivially_equality_comparable<typename std::iterator_traits<_Iter>::value_type, typename std::iterator_traits<_Iter>::value_type>::value
- && __is_identity<_Proj>::value && __desugars_to_v<__less_tag, _Comp, _Iter, _Iter>,
- int> = 0
- >
+template <class _Iter,
+ class _Proj,
+ class _Comp,
+ __enable_if_t<
+ !is_integral_v<typename std::iterator_traits<_Iter>::value_type> &&
+ __can_map_to_integer_v<typename std::iterator_traits<_Iter>::value_type> &&
+ __libcpp_is_trivially_equality_comparable<typename std::iterator_traits<_Iter>::value_type,
+ typename std::iterator_traits<_Iter>::value_type>::value &&
+ __is_identity<_Proj>::value && __desugars_to_v<__less_tag, _Comp, _Iter, _Iter>,
+ int> = 0 >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter>
__minmax_element_impl(_Iter __first, _Iter __last, _Comp& __comp, _Proj& __proj) {
if (__libcpp_is_constant_evaluated()) {
return __minmax_element_loop(__first, __last, __comp, __proj);
} else {
-
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/135495
More information about the libcxx-commits
mailing list