Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision 9ed4f946a9631dd56fe6ab84e440eee3341514be)
+++ src/Common/utility.h	(revision a984e65cceaf54cae32c9c76370d3f267d90a57b)
@@ -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
 }
 
