diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-03-24 16:50:48 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-03-24 16:50:48 +0100 |
commit | ef0fecc856d435ff140ce87ca38618d6edceafcc (patch) | |
tree | 5871c4a21f41ceee8db03fd55b3f23564bf5cdb8 /include/stdalgo.h | |
parent | facea197311f9dfbd9401b32b18cfd1245ff9be4 (diff) |
Add stdalgo::delete_all() that deletes all elements in a container
Diffstat (limited to 'include/stdalgo.h')
-rw-r--r-- | include/stdalgo.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/stdalgo.h b/include/stdalgo.h index 1ae5b8ae1..afbd763fb 100644 --- a/include/stdalgo.h +++ b/include/stdalgo.h @@ -84,4 +84,14 @@ namespace stdalgo { void operator()(classbase* item); }; + + /** + * Deletes all elements in a container using operator delete + * @param cont The container containing the elements to delete + */ + template <template<typename, typename> class Cont, typename T, typename Alloc> + inline void delete_all(const Cont<T*, Alloc>& cont) + { + std::for_each(cont.begin(), cont.end(), defaultdeleter<T>()); + } } |