diff --git a/llvm/include/llvm/ADT/PriorityWorklist.h b/llvm/include/llvm/ADT/PriorityWorklist.h index 2b6510f42d569..144993a761ac3 100644 --- a/llvm/include/llvm/ADT/PriorityWorklist.h +++ b/llvm/include/llvm/ADT/PriorityWorklist.h @@ -191,8 +191,17 @@ class PriorityWorklist { /// \returns true if any element is removed. template bool erase_if(UnaryPredicate P) { - typename VectorT::iterator E = - remove_if(V, TestAndEraseFromMap(P, M)); + typename VectorT::iterator E = remove_if(V, [&](const T &Arg) { + if (Arg == T()) + // Skip null values in the PriorityWorklist. + return false; + + if (P(Arg)) { + M.erase(Arg); + return true; + } + return false; + }); if (E == V.end()) return false; for (auto I = V.begin(); I != E; ++I) @@ -214,34 +223,6 @@ class PriorityWorklist { } private: - /// A wrapper predicate designed for use with std::remove_if. - /// - /// This predicate wraps a predicate suitable for use with std::remove_if to - /// call M.erase(x) on each element which is slated for removal. This just - /// allows the predicate to be move only which we can't do with lambdas - /// today. - template - class TestAndEraseFromMap { - UnaryPredicateT P; - MapT &M; - - public: - TestAndEraseFromMap(UnaryPredicateT P, MapT &M) - : P(std::move(P)), M(M) {} - - bool operator()(const T &Arg) { - if (Arg == T()) - // Skip null values in the PriorityWorklist. - return false; - - if (P(Arg)) { - M.erase(Arg); - return true; - } - return false; - } - }; - /// The map from value to index in the vector. MapT M;