Regarding placement new in C++

旧时模样 提交于 2019-12-07 13:27:43

In your [main.cpp] you're including <new>, which declares the function

 void* operator new( size_t size, void* p) throw()

You don't declare your own function.

Hence the function declared by new is the only one that's known, and the one that's called.

By the way, note that C++98 §18.4.1.3/1 prohibits replacement of the function shown above (plus three others, namely single object and array forms of new and delete with void* placement argument).

Also, while I'm on the "by the way" commenting, chances are that whatever placement new is thought to be the solution of, there is probably a safer and just as efficient and more clear higher level solution.

Cheers & hth.,

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!