Is it possible to create a function pointer to the a function's `new` operator/constructor?

允我心安 提交于 2019-12-05 10:55:22

boost::lambda provides function wrappers for new and delete. These can be used to easily convert an new call into a function object.

operator new (as well as the other flavours) takes care of allocating memory but does not construct objects. In fact its return type is void*. What constructs an object is a new expression, which is part of the language and not a function. So it's not possible to form a pointer or reference to it; it's as meaningless as forming a reference to return.

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