diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 2d988c9ef..251a04397 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -237,4 +237,31 @@ private: const std::string m_test; }; +namespace ContainerAlgorithms { + +template +struct DefaultDeleter +{ + void operator()(typename Container::value_type value) { + delete value; + } +}; + +template +struct DefaultDeleter > +{ + void operator()(typename std::map::value_type value) { + delete value.second; + } +}; + +} + +template +void cmDeleteAll(Container const& c) +{ + std::for_each(c.begin(), c.end(), + ContainerAlgorithms::DefaultDeleter()); +} + #endif