How could I sensibly overload placement operator new?

后端 未结 9 2016
北恋
北恋 2020-12-05 23:49

C++ allows overloading operator new - both global and per-class - usual operator new, operator new[] used with new[] stat

9条回答
  •  既然无缘
    2020-12-06 00:41

    To define your own memory management for a prereserved area is one nice use.

    To have different views on the same physical data (no need to move the data) is other interseting use. It also allows you reading a structured file as chars on a buffer and then, the superimposition of the their logical structure by defining an object of that the class over the buffer. The combination of this thing with the memory mapping of files, can provide big improvements in performance. The memory mapped hardware... So, thousand applications!

提交回复
热议问题