是否可以创建指向函数的"new"运算符/构造函数的函数指针? [英] Is it possible to create a function pointer to the a function's `new` operator/constructor?

查看:76
本文介绍了是否可以创建指向函数的"new"运算符/构造函数的函数指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要参数化创建对象的参数,我当然可以创建一个函数,该函数在特定类上调用new并传递一个指针.我想知道是否有可能跳过该步骤,并将函数指针传递给new运算符本身.

If I were to wanted to parameterize creating an object, I could of course make a function which called new on a particular class and passed out a pointer. I am wondering if it's possible to skip that step and pass a function pointer to the new operator itself.

推荐答案

boost :: lambda提供

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

这篇关于是否可以创建指向函数的"new"运算符/构造函数的函数指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆