diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-09-04 20:09:57 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-09-04 20:09:57 +0000 |
commit | ef36048760f80708ac1eaccbc2a21e7a700dc2ab (patch) | |
tree | adf7bde9971d56e55cdf1bb88880ccecc0451e6f /src/utils | |
parent | fd3706906e3408b497c61dcc54294dee8e6dbaf7 (diff) | |
download | Mana-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.gz Mana-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.bz2 Mana-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.xz Mana-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.h | 7 |
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 |