I decided to overload the new, new[],... operators in my classes so I can log the file and line at which they were called so I can easier track memory allocations/leaks.
Now the problems is in my stack and array classes (and other template container classes which allocate memory):
If I use them with one of my classes which has the new,new[],... operators overloaded it works fine.
But if I use it with the standard c++ data types (int,float,...) I can't allocate them, since no overloaded new operator matches the arguments of the new(__ LINE __ , __ FILE __) operator (or others like placement new).
Example of stack code:
// placement new
T* t=new(__ LINE __ , __ FILE__)(&m_data[i])T;
So I'm out of good ideas on how to make this work. If I replace new(__ LINE __ ,__ FILE __) with new I loose memory logging ability. One solution is to make a separated stack for standard data types in which the default new is used.
Is there any way to detect at compile time if a template parameter is a struct, class or a built in c++ type?
How do you handle stuff like this? What do you suggest? Any comments on this design (good,bad) are obviously welcome (just don't post stuff like "don't reinvent the wheel with your own containers ").