
We should be able to solve this ;) We have: template<class Y, class D> shared_ptr <http://www.boost.org/libs/smart_ptr/shared_ptr.htm#constructors>(Y * p, D d); So, for type 'Y', we can have the default deleter default_delete<Y*>(); 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); } }; ...etc Users can even specialize default_delete for their custom classes if they wish. Best, John
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.
-- http://John.Torjo.com -- C++ expert ... call me only if you want things done right