Fix bugs and refactor

This commit is contained in:
Данил
2025-04-11 20:54:19 +07:00
parent 70ab7f2370
commit 2389b605fc
2 changed files with 10 additions and 9 deletions
+6
View File
@@ -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;
+4 -9
View File
@@ -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<class Kind>
static bool IsA(const Classes type)
{
return Meta<Kind>::Type == type;
}
public:
template<class Kind>
static bool IsA(const IRTTI* object)
{
return IsA<Kind>(object->type);
return Meta<Kind>::Type == object->type;
}
// That method realized dynamic_cast
@@ -52,7 +47,7 @@ public:
static To* dyn_cast(From* object)
{
IRTTI* InterfaceOfObject = static_cast<IRTTI*>(object);
if (IsA<To>(InterfaceOfObject->type))
if (IsA<To>(object))
return reinterpret_cast<To*>(object);
if (InterfaceOfObject->Tree.find(Meta<To>::Type))