[llvm] [ADT] Minor code cleanup in STLExtras.h (PR #104808)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 08:58:09 PDT 2024


https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/104808

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

>From 008d3f84bbc5406716df5c25422889e169cd6762 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Mon, 19 Aug 2024 08:55:13 -0700
Subject: [PATCH] [ADT] Minor code cleanup in STLExtras.h

- Remove unnecessary return from `replace`.
- Add comment for `min_element` and `max_element`.
---
 llvm/include/llvm/ADT/STLExtras.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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));
 }



More information about the llvm-commits mailing list