Original Post
Thank you (anyone) for helping me out. I am coding in C++. This is my issue. I have a templated container class - it is essentially an array of the templated parameter. I would like the user to be able to pass in a construction argument that allows him/her to specify whether or not the memory that the class allocates is aligned. So I have code that looks like this: typedef enum{ ALIGN_THIS = 0 } ACV_INTERNAL_ENUM; void* operator new[]( std::size_t size, std::size_t alignment, ACV_INTERNAL_ENUM acvEnum ) throw(std::bad_alloc){ if( size==0 ) size=1; void* pMem = _aligned_malloc( size, alignment ); if(pMem) return pMem else throw std::bad_alloc(); } void operator delete[]( void* pMem, std::size_t alignment, ACV_INTERNAL_ENUM acvEnum ) throw(){ _aligned_free( pMem ); } template myClass::myClass( std::size_t nElements, bool iShouldAlign ){ if( iShouldAlign ){ m_data = new( 16, ALIGN_THIS ) T [nElements]; // Call my overloaded new } else { m_data = new T[nElements]; // Call regular new } } I have overloaded the new operator with the unused parameter 'acvEnum' to be able to specify when to use this version of operator new without overriding a standard version of new. I am failing at creating the destructor for myClass. The problem is that one cannot specifically call the corresponding overloaded delete. I need to call _aligned_free to correspond with _aligned_malloc, so the default version of delete will not work. The templated parameter T can be a primitive type, so it doesn't necessarily have a destructor; nor can I create a class that inherits from T. Any suggestions and thoughts would be greatly appreciated. Again, thank you all for your help. [Edited by - ndwork on December 3, 2008 1:02:55 PM]