From ddc93c461070fb3d868fbb5426e8361d1b93ee38 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Mon, 8 Dec 2008 21:13:38 +0100 Subject: Introduced another template to make deleting all values in a container easier. Inspired by qDeleteAll() from Qt. Conflicts: ChangeLog src/beingmanager.cpp src/channelmanager.cpp src/gui/skill.cpp src/map.cpp src/resources/monsterinfo.cpp (cherry picked from mainline) --- src/utils/dtor.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/utils') diff --git a/src/utils/dtor.h b/src/utils/dtor.h index f7c790c6..9aa92c84 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -22,6 +22,7 @@ #ifndef _TMW_UTILS_DTOR_H #define _TMW_UTILS_DTOR_H +#include #include #include @@ -44,4 +45,10 @@ inline dtor make_dtor(Cont const&) return dtor(); } +template +inline void delete_all(Container &c) +{ + std::for_each(c.begin(), c.end(), make_dtor(c)); +} + #endif -- cgit v1.2.3-70-g09d2