[llvm] [ADT] Minor code cleanup in STLExtras.h (PR #104808)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 08:58:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Rahul Joshi (jurahul)
<details>
<summary>Changes</summary>
- Remove unnecessary return from `replace`.
- Add comment for `min_element` and `max_element`.
---
Full diff: https://github.com/llvm/llvm-project/pull/104808.diff
1 Files Affected:
- (modified) llvm/include/llvm/ADT/STLExtras.h (+5-1)
``````````diff
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index a810a1c318c42c..249ac384bec41e 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1847,7 +1847,7 @@ OutputIt replace_copy(R &&Range, OutputIt Out, const T &OldValue,
/// begin/end explicitly.
template <typename R, typename T>
void replace(R &&Range, const T &OldValue, const T &NewValue) {
- return std::replace(adl_begin(Range), adl_end(Range), OldValue, NewValue);
+ std::replace(adl_begin(Range), adl_end(Range), OldValue, NewValue);
}
/// Provide wrappers to std::move which take ranges instead of having to
@@ -1982,6 +1982,8 @@ auto upper_bound(R &&Range, T &&Value, Compare C) {
std::forward<T>(Value), C);
}
+/// Provide wrappers to std::min_element which take ranges instead of having to
+/// pass begin/end explicitly.
template <typename R> auto min_element(R &&Range) {
return std::min_element(adl_begin(Range), adl_end(Range));
}
@@ -1990,6 +1992,8 @@ template <typename R, typename Compare> auto min_element(R &&Range, Compare C) {
return std::min_element(adl_begin(Range), adl_end(Range), C);
}
+/// Provide wrappers to std::max_element which take ranges instead of having to
+/// pass begin/end explicitly.
template <typename R> auto max_element(R &&Range) {
return std::max_element(adl_begin(Range), adl_end(Range));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/104808
More information about the llvm-commits
mailing list