[llvm] 87dd312 - [ADT] Minor code cleanup in STLExtras.h (#104808)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 12:20:52 PDT 2024


Author: Rahul Joshi
Date: 2024-08-19T12:20:47-07:00
New Revision: 87dd31234a3c46ace097af73ecaedcdb6b306ef3

URL: https://github.com/llvm/llvm-project/commit/87dd31234a3c46ace097af73ecaedcdb6b306ef3
DIFF: https://github.com/llvm/llvm-project/commit/87dd31234a3c46ace097af73ecaedcdb6b306ef3.diff

LOG: [ADT] Minor code cleanup in STLExtras.h (#104808)

- Remove unnecessary return from `replace`.
- Add comment for `min_element` and `max_element`.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/STLExtras.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index a810a1c318c42..249ac384bec41 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));
 }


        


More information about the llvm-commits mailing list