I've overridden the global new and delete operators for my project, but I'm having trouble making it all work with the Boost libraries. I've implemented the solution here: Macro to replace C++ operator new to get around the problem that I was having with multiple overloads. However, the Boost libraries have an annoying habit of using operator new
rather than simply using new
leaving the preprocessor to expand:
::operator new(n);
to:
::operator (__file__ = "someFile.cpp", __line__ = 123) && 0 ? NULL : new(n);
Is it possible to write another macro to remove these "undesired" expansions? For example, I tried writing:
#define (operator (file, line) && 0 ? NULL :) operator new
But apparently parenthesis are not allowed in the identifier portion of the macro. How can I use the Boost libraries, but still get my memory allocation tracking?