Boost logo

Boost :

From: Mike Tegtmeyer (tegtmeye_at_[hidden])
Date: 2007-11-06 22:15:10


How is this just not replacing a wrapper with a specialization?

On Nov 6, 2007, at 10:00 PM, John Torjo wrote:

> 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
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/
> listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk