Boost logo

Boost :

From: John Torjo (john.groups_at_[hidden])
Date: 2007-11-06 22:00:03

We should be able to solve this ;)

We have:

template<class Y, class D> shared_ptr <>(Y * p, D d);

So, for type 'Y', we can have the default deleter

template<class Y> struct default_delete { void do_delete(Y p) { delete p; } };

template<> struct default_delete<FILE*> { void do_delete(FILE* p) { if (p) fclose(p); } };

Users can even specialize default_delete for their custom classes if they wish.


> I agree but it quickly becomes a pain because you end up writing a
> wrapper for every thing of this type to satisfy this 'wart' with
> shared_ptr:
> pthread_create ...
> opendir
> fopen
> open
> free
> COM objects
> the list goes on.

-- -- C++ expert
... call me only if you want things done right

Boost list run by bdawes at, gregod at, cpdaniel at, john at