$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [smart_ptr] shared_ptr<T> T destructor required even if adeleter function is provided
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-09-28 13:10:51
vicente.botet:
> Hello,
>
> I have compiled the example Preventing delete px.get()and every thing is 
> OK until we use the reset function because shared_ptr<X> request that the 
> destructor of X must be public even if a deleter function is provided. I'm 
> wondering if this is a BUG on the smart pointer library
...
> int main () {
>     shared_ptr<X> ptr = X::create();
>     ptr.reset(X::create().get());
>     return 0;
> }
shared_ptr is doing the right thing. The line
     ptr.reset(X::create().get());
is a bug in your code (taking ownership of a pointer already managed by 
shared_ptr), and it is correct for it to not compile.