Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision 3c09d47c9fd762e66a4beaa4d096faba191e8d2a)
+++ src/Common/utility.h	(revision 78a0b882ee7cc867a4e3e1ce2e54da848ab13e10)
@@ -172,4 +172,19 @@
 auto filter(Args&&... args) -> decltype(std::copy_if(std::forward<Args>(args)...)) {
   return std::copy_if(std::forward<Args>(args)...);
+}
+
+template <typename E, typename UnaryPredicate, template< typename, typename...> class Container, typename... Args >
+void filter( Container< E *, Args... > & container, UnaryPredicate pred, bool doDelete ) {
+	auto i = begin( container );
+	while ( i != end( container ) ) {
+		auto it = next( i );
+		if ( pred( *i ) ) {
+			if ( doDelete ) {
+				delete *i;
+			} // if
+			container.erase( i );
+		} // if
+		i = it;
+	} // while
 }
 
