From f8780d0075a7b8987db2ee71f4da574a98066252 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Sun, 2 Feb 2014 16:34:17 +0000 Subject: [PATCH] fixes #114 incorrect iterator increment in for loop in CContainerBase::removeIf --- src/blackmisc/containerbase.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/blackmisc/containerbase.h b/src/blackmisc/containerbase.h index c35d01db9..bbf2507a1 100644 --- a/src/blackmisc/containerbase.h +++ b/src/blackmisc/containerbase.h @@ -132,9 +132,10 @@ namespace BlackMisc template void removeIf(Predicate p) { - for (auto it = derived().begin(); it != derived().end(); ++it) + for (auto it = derived().begin(); it != derived().end(); ) { if (p(*it)) { it = derived().erase(it); } + else { ++it; } } }