diff --git a/RTTI/RTTI.cpp b/RTTI/RTTI.cpp index 48f5855..fe252b0 100644 --- a/RTTI/RTTI.cpp +++ b/RTTI/RTTI.cpp @@ -51,6 +51,12 @@ bool IRTTI::FastContainer::find(const Classes& Type) const return false; } +IRTTI::FastContainer::~FastContainer() +{ + _size = 0; + delete[] array; +} + void IRTTI::SetType(const Classes Type) { this->type = Type; diff --git a/RTTI/RTTI.h b/RTTI/RTTI.h index f61d16d..e6ad22d 100644 --- a/RTTI/RTTI.h +++ b/RTTI/RTTI.h @@ -15,6 +15,8 @@ class IRTTI long long constexpr size() const { return _size; } void push_back(const Classes object); bool find(const Classes& Type) const; + + ~FastContainer(); }; FastContainer Tree; Classes type; @@ -33,18 +35,11 @@ class RTTI final { RTTI() = default; - - // That method allow compare given type with real type object - template - static bool IsA(const Classes type) - { - return Meta::Type == type; - } public: template static bool IsA(const IRTTI* object) { - return IsA(object->type); + return Meta::Type == object->type; } // That method realized dynamic_cast @@ -52,7 +47,7 @@ public: static To* dyn_cast(From* object) { IRTTI* InterfaceOfObject = static_cast(object); - if (IsA(InterfaceOfObject->type)) + if (IsA(object)) return reinterpret_cast(object); if (InterfaceOfObject->Tree.find(Meta::Type))