diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-03-24 16:39:20 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-03-24 16:39:20 +0100 |
commit | 6d9b2bfee07c906699faef4de5ad85787978be3a (patch) | |
tree | 43e0c435583af0fa02c99f871ba93f48581a14b1 /include/extensible.h | |
parent | 671a80a70be60ccad1c0176556487c09be810489 (diff) |
Make it possible to customize how SimpleExtItem should delete items
Diffstat (limited to 'include/extensible.h')
-rw-r--r-- | include/extensible.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/include/extensible.h b/include/extensible.h index 0e1afdbdf..87fe65ccb 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -126,7 +126,7 @@ class CoreExport LocalExtItem : public ExtensionItem virtual void free(void* item) = 0; }; -template<typename T> +template <typename T, typename Del = stdalgo::defaultdeleter<T> > class SimpleExtItem : public LocalExtItem { public: @@ -147,24 +147,28 @@ class SimpleExtItem : public LocalExtItem { T* ptr = new T(value); T* old = static_cast<T*>(set_raw(container, ptr)); - delete old; + Del del; + del(old); } inline void set(Extensible* container, T* value) { T* old = static_cast<T*>(set_raw(container, value)); - delete old; + Del del; + del(old); } inline void unset(Extensible* container) { T* old = static_cast<T*>(unset_raw(container)); - delete old; + Del del; + del(old); } virtual void free(void* item) { - delete static_cast<T*>(item); + Del del; + del(static_cast<T*>(item)); } }; |