Search code examples
c++new-operatorfunction-pointersboost-bind

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


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.


Solution

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