I need to map a delete ptrAddr; to a boost::function0 but i have some troubles doing that for delete. free works just fine. The issue appears to be std::ptr_fun(operator delete) but i can’t figure how to make this work without writing a helper functor.
boost::function0<void> Function;
Function = boost::bind(std::ptr_fun(free), (void*)malloc_string); //this works
Function = boost::bind(std::ptr_fun(operator delete), (void*)new_string); //doesn't work
Function(); //call function
You can use
delete_ptrfrom Boost.Lambda:In C++11, you can use
std::default_delete<T>:Or just a lambda: