I am creating a Lua api for my program. I want to be able to do the following:
void* CreateA()
{
A* a = new A();
PointerTypes[a] = A;
return reinterpret_cast<void*>(a);
}
void* CreateB()
{
B* b = new B();
PointerTypes[b] = B;
return reinterpret_cast<void*(b);
}
void DeleteThing( void* p )
{
typename type = PointerTypes[p];
type* t = reinterpret_cast< type >( p );
delete t;
}
Is there any straightforward way to do this? PS: My application already uses RTTI so it can be used here too.