[llvm] [PatternMatch] Implement match_fn using bind_back (NFC) (PR #175811)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 13 11:38:46 PST 2026
================
@@ -50,17 +50,11 @@ template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
return P.match(V);
}
-template <typename Val, typename Pattern> struct MatchFunctor {
- const Pattern &P;
- MatchFunctor(const Pattern &P) : P(P) {}
- bool operator()(Val *V) const { return P.match(V); }
-};
-
/// A match functor that can be used as a UnaryPredicate in functional
/// algorithms like all_of.
template <typename Val = const Value, typename Pattern>
-MatchFunctor<Val, Pattern> match_fn(const Pattern &P) {
- return P;
+auto match_fn(const Pattern &P) {
+ return bind_back(match<Val, Pattern>, P);
----------------
kuhar wrote:
You should be able to use `bind_back<match<Val, Pattern>>(P), no? Also elsewhere.
https://github.com/llvm/llvm-project/pull/175811
More information about the llvm-commits
mailing list