[PATCH] D106913: Add llvm::equal convenient wrapper for ranges around std::equal
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 27 13:06:57 PDT 2021
mehdi_amini created this revision.
mehdi_amini added a reviewer: rriddle.
Herald added subscribers: dcaballe, cota, teijeong, dexonsmith, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen.
Herald added a reviewer: antiagainst.
mehdi_amini requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: MLIR, LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106913
Files:
llvm/include/llvm/ADT/STLExtras.h
mlir/include/mlir/IR/OpBase.td
Index: mlir/include/mlir/IR/OpBase.td
===================================================================
--- mlir/include/mlir/IR/OpBase.td
+++ mlir/include/mlir/IR/OpBase.td
@@ -2356,10 +2356,7 @@
// ranged arguments.
class RangedTypesMatchWith<string summary, string lhsArg, string rhsArg,
string transform>
- : TypesMatchWith<summary, lhsArg, rhsArg, transform,
- "[](auto &&lhs, auto &&rhs) { "
- "return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());"
- " }">;
+ : TypesMatchWith<summary, lhsArg, rhsArg, transform, "llvm::equal">;
// Type Constraint operand `idx`'s Element type is `type`.
class TCopVTEtIs<int idx, Type type> : And<[
Index: llvm/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -1688,6 +1688,13 @@
return std::unique(adl_begin(R), adl_end(R), P);
}
+/// Wrapper function around std::equal to detect if pair-wise elements between
+/// two ranges are the same.
+template <typename L, typename R> bool equal(L &&LRange, R &&RRange) {
+ return std::equal(adl_begin(LRange), adl_end(LRange), adl_begin(RRange),
+ adl_end(RRange));
+}
+
/// Wrapper function around std::equal to detect if all elements
/// in a container are same.
template <typename R>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106913.362151.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210727/74846196/attachment.bin>
More information about the llvm-commits
mailing list