
28 Sep
2008
28 Sep
'08
5:10 p.m.
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.