diff options
Diffstat (limited to 'src/crepe/util/Private.hpp')
-rw-r--r-- | src/crepe/util/Private.hpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/crepe/util/Private.hpp b/src/crepe/util/Private.hpp index 30c8146..d6ab23f 100644 --- a/src/crepe/util/Private.hpp +++ b/src/crepe/util/Private.hpp @@ -8,13 +8,15 @@ namespace crepe { template <typename T, typename... Args> -void Private::set(Args &&... args) { +T & Private::set(Args &&... args) { + if (!this->empty()) this->destructor(this->instance); T * instance = new T(std::forward<Args>(args)...); this->instance = static_cast<void*>(instance); this->destructor = [](void * instance) { delete static_cast<T*>(instance); }; this->type = typeid(T); + return *instance; } template <typename T> |