summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 21:13:38 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 21:22:43 +0100
commitddc93c461070fb3d868fbb5426e8361d1b93ee38 (patch)
tree250eacd391542d36a51c4d3aa398d4f6346619fb /src/utils
parentd129ce9776a6fd0e165b676a3addd14186c5d85d (diff)
downloadmana-ddc93c461070fb3d868fbb5426e8361d1b93ee38.tar.gz
mana-ddc93c461070fb3d868fbb5426e8361d1b93ee38.tar.bz2
mana-ddc93c461070fb3d868fbb5426e8361d1b93ee38.tar.xz
mana-ddc93c461070fb3d868fbb5426e8361d1b93ee38.zip
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)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/dtor.h7
1 files changed, 7 insertions, 0 deletions
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 <algorithm>
#include <functional>
#include <utility>
@@ -44,4 +45,10 @@ inline dtor<typename Cont::value_type> make_dtor(Cont const&)
return dtor<typename Cont::value_type>();
}
+template<typename Container>
+inline void delete_all(Container &c)
+{
+ std::for_each(c.begin(), c.end(), make_dtor(c));
+}
+
#endif