I am using OGRE and I have run into an issue that is not so much specific to ORGE, but is a genreal C++ issue I am dealing with. ORGE just helps with the context of the question.
There is a macro that is something such as
OGRE_DELETE_T(obj, ExternalClass);
However, in order for delete to be called, I need to pass in the type of the class as the second parameter. However, say for instance I have a base class A
, then class B
, class C
, class D
, etc. If I were to store a std::vector
of just A
pointers, but in actuality I may have instantiated them as B
, C
, or some deriviative of A
, how could I pass the type of the actual class constructed into this macro? I do not know what type the derived object is when I go to delete it, all I know is there is class A
pointers.
I thought perhaps using dynamic_cast
, however, I did not like the runtime performance and I would also need to have some sort of a lookup table of types to check against.