summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-09-04 20:09:57 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-09-04 20:09:57 +0000
commitef36048760f80708ac1eaccbc2a21e7a700dc2ab (patch)
treeadf7bde9971d56e55cdf1bb88880ccecc0451e6f /src/utils
parentfd3706906e3408b497c61dcc54294dee8e6dbaf7 (diff)
downloadmana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.gz
mana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.bz2
mana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.xz
mana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.zip
Introduced another template to make deleting all values in a container easier.
Inspired by qDeleteAll() from Qt.
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 f2c6c1b8..516fd916 100644
--- a/src/utils/dtor.h
+++ b/src/utils/dtor.h
@@ -24,6 +24,7 @@
#ifndef _TMW_UTILS_DTOR_H
#define _TMW_UTILS_DTOR_H
+#include <algorithm>
#include <functional>
#include <utility>
@@ -46,4 +47,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