
29 Sep
2008
29 Sep
'08
10:44 a.m.
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; }