Overloading global operator new/delete in C++

前端 未结 2 1035
名媛妹妹
名媛妹妹 2020-12-31 18:58

I am trying to overload the global operator new and delete for a performance sensitive application. I have read the concerns described at http://www.informit.com/articles/ar

相关标签:
2条回答
  • 2020-12-31 19:07

    If you are using Visual Studio and using precompiled headers, then you can throw the include into there. I think gcc has some form of precompiling headers as well, which would improve your compilation times as well.

    0 讨论(0)
  • 2020-12-31 19:25

    If you want to overload the global operator new and operator delete, you just need to implement it. You don't need to explicitly define it everywhere since it already is defined as part of the language.

    Edit: If you want to define an operator new that takes different parameters, then you'll need to #include it everywhere. However you do that is up to you; it's mostly a matter of style.

    And don't forget to implement all the variants of global operator new and delete: new, new[], delete, delete[], and the std::nothrow variants.

    0 讨论(0)
提交回复
热议问题