I have a pool manager template class. When a class object gets added back to the pool manager I would like to reset it back to it's initial state. I would like to call the placment destructor and placment constructor on it so it gets fully reset for the next time it is given out by the pool manager. I've tried many ways to get this to work but I'm stumped. Here is an example of what I have tried.
template <class T>
void PoolClass<T>::ReleaseToPool(T *obj)
{
obj->~T(); //call destructor
obj->T::T(); //call constructor
//also tried new (obj)T(); //but this doesn't seem to work either
//then misc code to add a pointer to the object
//to my list of available objects for re-use later
}
I've tried a bunch of different syntaxes and none seem to work. The code itself is cross platform so should compile using gcc ( under mingw or linux or mac ) and for windows I'm still using vs 2003.