[llvm] [NFC][ADT] Add range wrapper for std::maximal (PR #104838)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 12:26:29 PDT 2024


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

None

>From fb2b9b864a0968919f69ae0f77005f42bff25f90 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Mon, 19 Aug 2024 12:24:23 -0700
Subject: [PATCH] [NFC][ADT] Add range wrapper for std::maximal

---
 llvm/include/llvm/ADT/STLExtras.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 249ac384bec41e..61022cc5a2d289 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -2002,6 +2002,13 @@ template <typename R, typename Compare> auto max_element(R &&Range, Compare C) {
   return std::max_element(adl_begin(Range), adl_end(Range), C);
 }
 
+/// Provide wrappers to std::mismatch which take ranges instead of having to
+/// pass begin/end explicitly.
+template <typename R1, typename R2> auto mismatch(R1 &&Range1, R2 &&Range2) {
+  return std::mismatch(adl_begin(Range1), adl_end(Range1), adl_begin(Range2),
+                       adl_end(Range2));
+}
+
 template <typename R>
 void stable_sort(R &&Range) {
   std::stable_sort(adl_begin(Range), adl_end(Range));



More information about the llvm-commits mailing list