Skip to content

Commit aaacd8c

Browse files
committed
Add llvm::equal convenient wrapper for ranges around std::equal
Differential Revision: https://reviews.llvm.org/D106913
1 parent 2e4755f commit aaacd8c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,13 @@ auto unique(Range &&R, Predicate P) {
16881688
return std::unique(adl_begin(R), adl_end(R), P);
16891689
}
16901690

1691+
/// Wrapper function around std::equal to detect if pair-wise elements between
1692+
/// two ranges are the same.
1693+
template <typename L, typename R> bool equal(L &&LRange, R &&RRange) {
1694+
return std::equal(adl_begin(LRange), adl_end(LRange), adl_begin(RRange),
1695+
adl_end(RRange));
1696+
}
1697+
16911698
/// Wrapper function around std::equal to detect if all elements
16921699
/// in a container are same.
16931700
template <typename R>

mlir/include/mlir/IR/OpBase.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,10 +2366,7 @@ class TypesMatchWith<string summary, string lhsArg, string rhsArg,
23662366
// ranged arguments.
23672367
class RangedTypesMatchWith<string summary, string lhsArg, string rhsArg,
23682368
string transform>
2369-
: TypesMatchWith<summary, lhsArg, rhsArg, transform,
2370-
"[](auto &&lhs, auto &&rhs) { "
2371-
"return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());"
2372-
" }">;
2369+
: TypesMatchWith<summary, lhsArg, rhsArg, transform, "llvm::equal">;
23732370

23742371
// Type Constraint operand `idx`'s Element type is `type`.
23752372
class TCopVTEtIs<int idx, Type type> : And<[

0 commit comments

Comments
 (0)