summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-10-03 00:03:00 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-10-03 00:03:00 +0000
commit3f57b82979a633eb8f38f4de69d58faf9691e8b5 (patch)
treedc61a7f19cfe815005a82d91bb85816c8b29b585 /llvm/include
parent214156c43dc1522c22faa730e5c51e192992478b (diff)
downloadbcm5719-llvm-3f57b82979a633eb8f38f4de69d58faf9691e8b5.tar.gz
bcm5719-llvm-3f57b82979a633eb8f38f4de69d58faf9691e8b5.zip
Switch the SetVector::remove_if implementation to use partition which
preserves the values of the relocated entries, unlikely remove_if. This allows walking them and erasing them. Also flesh out the predicate we are using for this to support the various constraints actually imposed on a UnaryPredicate -- without this we can't compose it with std::not1. Thanks to Sean Silva for the review here and noticing the issue with std::remove_if. llvm-svn: 165073
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ADT/SetVector.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/SetVector.h b/llvm/include/llvm/ADT/SetVector.h
index e8d63edf9e5..0ff0f46f88d 100644
--- a/llvm/include/llvm/ADT/SetVector.h
+++ b/llvm/include/llvm/ADT/SetVector.h
@@ -141,8 +141,9 @@ public:
/// \returns true if any element is removed.
template <typename UnaryPredicate>
bool remove_if(UnaryPredicate P) {
- typename vector_type::iterator B = std::remove_if(vector_.begin(),
- vector_.end(), P),
+ typename vector_type::iterator B = std::partition(vector_.begin(),
+ vector_.end(),
+ std::not1(P)),
E = vector_.end();
if (B == E)
return false;
OpenPOWER on IntegriCloud