diff --git a/llvm/include/llvm/ADT/SetVector.h b/llvm/include/llvm/ADT/SetVector.h index 85d4f2d5ee28a..273a011d1da1b 100644 --- a/llvm/include/llvm/ADT/SetVector.h +++ b/llvm/include/llvm/ADT/SetVector.h @@ -250,8 +250,13 @@ class SetVector { if (isSmall()) return llvm::remove_if(vector_, P); - return llvm::remove_if(vector_, - TestAndEraseFromSet(P, set_)); + return llvm::remove_if(vector_, [&](const value_type &V) { + if (P(V)) { + set_.erase(V); + return true; + } + return false; + }); }(); if (I == vector_.end()) @@ -335,29 +340,6 @@ class SetVector { } 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 set_.erase(x) on each element which is slated for removal. - template - class TestAndEraseFromSet { - UnaryPredicate P; - set_type &set_; - - public: - TestAndEraseFromSet(UnaryPredicate P, set_type &set_) - : P(std::move(P)), set_(set_) {} - - template - bool operator()(const ArgumentT &Arg) { - if (P(Arg)) { - set_.erase(Arg); - return true; - } - return false; - } - }; - [[nodiscard]] static constexpr bool canBeSmall() { return N != 0; } [[nodiscard]] bool isSmall() const { return set_.empty(); }