Add cleanup templates.
authorScott Cantor <cantor.2@osu.edu>
Mon, 20 Feb 2006 08:15:29 +0000 (08:15 +0000)
committerScott Cantor <cantor.2@osu.edu>
Mon, 20 Feb 2006 08:15:29 +0000 (08:15 +0000)
xmltooling/internal.h

index 5e6a0f8..383fbcf 100644 (file)
@@ -66,6 +66,17 @@ namespace {
         //PlugManager m_plugMgr;\r
     };\r
 \r
+    // Template cleanup functors for use with for_each algorithm\r
+    template<class T> struct cleanup\r
+    {\r
+        void operator()(T* ptr) {delete ptr;}\r
+        void operator()(const T* ptr) {delete const_cast<T*>(ptr);}\r
+    };\r
+\r
+    template<class A,class B> struct cleanup_pair\r
+    {\r
+        void operator()(const std::pair<A,B*>& p) {delete p.second;}\r
+    };\r
 };\r
 \r
 #endif /* __xmltooling_internal_h__ */\r