Macro to replace C++ operator new

后端 未结 7 1839
臣服心动
臣服心动 2020-12-04 13:47

Is it possible to create macros to replace all forms of operator new with overloads that include additional args...say __FILE__ and __LINE__<

7条回答
  •  生来不讨喜
    2020-12-04 14:04

    No, there's no way.

    You could do this in the bad old days of malloc()/free() but not for new.

    You can replace the memory allocator by globally overriding the new operator, but you cannot inject the special variables you're talking about.

提交回复
热议问题