|
Boost : |
Subject: Re: [boost] [smart_ptr] shared_ptr<T> T destructor requiredevenifadeleter function is provided
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-09-29 07:19:53
----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, September 29, 2008 12:44 PM
Subject: Re: [boost] [smart_ptr] shared_ptr<T> T destructor
requiredevenifadeleter function is provided
>
> vicente.botet:
>> Hello Peter,
>>
>> what about the following in which we don't transfer ownership. (Note that
>> now X::create() return X*)
>>
>> int main () {
>> shared_ptr<X> ptr(X::create(), X::deleter());
>> ptr.reset(X::create());
>
> This is the equivalent of doing
>
> shared_ptr<X> ptr( X::create() );
>
> which you're explicitly trying to prevent. The equivalent of
>
>> shared_ptr<X> ptr(X::create(), X::deleter());
>
> is
>
> ptr.reset( X::create(), X::deleter() );
>
>> return 0;
>> }
>
Peter ,
thanks for pointing me to
template<class Y, class D> void reset(Y * p, D d);
I was not aware that deleter is associated to the pointer instance and not
to the shared_ptr. I see now.
I suppose that you have already discused about a template version of
shared_ptr and that you have good raisons no not include them for the
standard. Please could you point me to the rational?
Has a wrapper class that takes the deleter and allocators as template
parameter has a sence?
template <typename T, typename Deleter, typename Allocator>
struct shared_ptr_wrapper : private shared_ptr<T>
{
...
void reset(T * p) {
this->shared_ptr::reset(p, Deleter())
}
...
}
Sorry for the noice and thanks again,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk