The exact error I'm getting is:
Cannot dynamic_cast 'object' (of type 'void*') to type 'class udDator(int)*' (source is not a pointer to a class)
This is happening inside an overridden operator delete. I'm attempting to create a templated memory management class that can inherit into any other class, managing memory through references. This would be in place of something like a smart shared_ptr, in an attempt to make memory management even more invisible, and without extra typing ( shared_ptr< someClass > shared( new someClass() ) is kinda long... ).
Anyway, here is the relevant code. If I have forgotten to mention any details, or do not have some code that you need to see, just let me know.
Overridden operator:
template< class T >
class udSharedMemory
{
public:
void operator delete( void *object )
{
T *temp = dynamic_cast< T* >( object ); //<------ ERROR!
assert( temp && "Something went wrong during casting" );
temp->release();
}
}
Templated class:
template< class T >
class udDator : public udMemoryManaged, public udSharedMemory< udDator< T > >
{
// stuff
};
Usage of the templated class:
udDator< int > *test = new udDator< int >( "5" );