Boost logo

Boost :

Subject: Re: [boost] [shared_ptr] delete shared_ptr
From: pavel (paul.cpprules_at_[hidden])
Date: 2011-03-17 14:53:27


 Frank wrote on Thursday, March 17, 2011 at 21:26:02:
> It violates the fundamental premise of shared_ptr: shared ownership.
> Whoever deletes the object directly is taking total ownership of the object.

you misunderstood
the point is that

  hypothetical_smart_ptr<int>
    p = new int, //allocating data
    q;
  p = q; //data intended to be shared now
  delete p; //equivalent to 'p.reset()' in the 'shared_ptr' case
  delete q; //<--actually releases allocated data

it deletes or otherwise releases guarded resource only if no other
smart pointer holds a reference to the resource

-- 
Pavel
P.S.
if you notice a grammar mistake or weird phrasing in my message
please point it out

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