Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision 5fda7143cbcbc2c8f66e8862aecc99dfa3619c54)
+++ src/Common/utility.h	(revision 4563a956eb56d3c7135208399eafd37c72ea72d3)
@@ -18,4 +18,5 @@
 
 #include <cctype>
+#include <algorithm>
 #include <iostream>
 #include <iterator>
@@ -111,9 +112,4 @@
 		return tmp;
 	} // if
-}
-
-template< class T, typename ResultType, ResultType( T::* memfunc )() >
-ResultType dispatch( T *pT ) {
-	return (pT->*memfunc)();
 }
 
@@ -162,15 +158,4 @@
 }
 
-template< class Constructed, typename Arg >
-Constructed *ctor( Arg arg ) {
-	Constructed *c = new Constructed( arg );
-	return c;
-}
-
-template< class Constructed, typename Arg >
-Constructed ctor_noptr( Arg arg ) {
-	return Constructed( arg );
-}
-
 template< typename T >
 void replace( std::list< T > &org, typename std::list< T >::iterator pos, std::list< T > &with ) {
@@ -185,31 +170,12 @@
 }
 
-template< typename T1, typename T2 >
-T2 *cast_ptr( T1 *from ) {
-	return dynamic_cast< T2 * >( from );
-}
-
-template< class Exception, typename Arg >
-void inline assert_throw( bool pred, Arg arg ) {
-	if (pred) throw Exception( arg );
-}
-
-template< typename T >
-struct is_null_pointer {
-	bool operator()( const T *ptr ) { return ( ptr == 0 ); }
-};
-
-template< class InputIterator, class OutputIterator, class Predicate >
-void filter(InputIterator begin, InputIterator end, OutputIterator out, Predicate pred) {
-	while ( begin++ != end )
-		if ( pred(*begin) ) *out++ = *begin;
-
-	return;
-}
-
-template< class InputIterator1, class InputIterator2, class OutputIterator >
-void zip( InputIterator1 b1, InputIterator1 e1, InputIterator2 b2, InputIterator2 e2, OutputIterator out ) {
-	while ( b1 != e1 && b2 != e2 )
-		*out++ = std::pair<typename InputIterator1::value_type, typename InputIterator2::value_type>(*b1++, *b2++);
+template< typename... Args >
+auto filter(Args&&... args) -> decltype(std::copy_if(std::forward<Args>(args)...)) {
+  return std::copy_if(std::forward<Args>(args)...);
+}
+
+template< typename... Args >
+auto zip(Args&&... args) -> decltype(zipWith(std::forward<Args>(args)..., std::make_pair)) {
+  return zipWith(std::forward<Args>(args)..., std::make_pair);
 }
 
@@ -221,11 +187,8 @@
 
 // it's nice to actually be able to increment iterators by an arbitrary amount
-template< typename Iterator >
-Iterator operator+(Iterator i, int inc) {
-	while ( inc > 0 ) {
-		++i;
-		--inc;
-	}
-	return i;
+template< class InputIt, class Distance >
+InputIt operator+( InputIt it, Distance n ) {
+	advance(it, n);
+	return it;
 }
 
@@ -246,4 +209,9 @@
 	warn_single( params... );
 }
+
+// -----------------------------------------------------------------------------
+// Ref Counted Singleton class
+// Objects that inherit from this class will have at most one reference to it
+// but if all references die, the object will be deleted.
 
 template< typename ThisType >
@@ -265,4 +233,5 @@
 std::weak_ptr<ThisType> RefCountSingleton<ThisType>::global_instance;
 
+// -----------------------------------------------------------------------------
 // RAII object to regulate "save and restore" behaviour, e.g.
 // void Foo::bar() {
@@ -279,4 +248,9 @@
 };
 
+// -----------------------------------------------------------------------------
+// Helper struct and function to support
+// for ( val : reverseIterate( container ) ) {}
+// syntax to have a for each that iterates backwards
+
 template< typename T >
 struct reverseIterate_t {
