
16 Jul
2008
16 Jul
'08
9:51 a.m.
Howard Hinnant wrote:
The use of function-pointer-deleters allows for a nifty "poor-man's dynamic deleter". A hybrid if you will between the typical unique_ptr and shared_ptr use cases and overhead:
unique_ptr<int, void(*)(void*)> p1(std::malloc(sizeof(int)), std::free); unique_ptr<FILE, int(*)(FILE*)> p2(std::fopen("test.dat", "w"), std::fclose);
What about boost::function<void*>? How is that less powerful than a dynamic deleter? I personally don't see the point in dynamic deleters, they're only specializations of dynamic ones.