18 Sep
2002
18 Sep
'02
1:03 p.m.
From: "Craig Henderson"
My existing solution uses a unary functor, as below, but this met with critism on the Boost Developers' list. What would be the 'boost' solution to this problem?
template<typename T> class free_heap_ptr : public std::unary_function
{ public: free_heap_ptr() { } ~free_heap_ptr() { } void operator() (T p) { delete p; } };
I see nothing wrong with your solution (except the redundant constructor and destructor.) On a slightly higher level, the "boost" solution is to not keep raw pointers in a list, but I'm sure you know that.