From c00f944aaeda46955c7f72d8248a06f32c6c4c05 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Mon, 20 Feb 2006 08:15:29 +0000 Subject: [PATCH] Add cleanup templates. --- xmltooling/internal.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xmltooling/internal.h b/xmltooling/internal.h index 5e6a0f8..383fbcf 100644 --- a/xmltooling/internal.h +++ b/xmltooling/internal.h @@ -66,6 +66,17 @@ namespace { //PlugManager m_plugMgr; }; + // Template cleanup functors for use with for_each algorithm + template struct cleanup + { + void operator()(T* ptr) {delete ptr;} + void operator()(const T* ptr) {delete const_cast(ptr);} + }; + + template struct cleanup_pair + { + void operator()(const std::pair& p) {delete p.second;} + }; }; #endif /* __xmltooling_internal_h__ */ -- 2.1.4