Boost logo

Boost :

Subject: Re: [boost] [shared_ptr] delete shared_ptr
From: Nevin Liber (nevin_at_[hidden])
Date: 2011-03-18 11:42:57


On 18 March 2011 01:40, Sid Sacek <ssacek_at_[hidden]> wrote:

> I think it's simply stating an intention; the intention being that the
> current shared pointer is no longer interesting in the shared object; who
> cares if the shared object gets deleted under the covers.

Suppose the shared object holds an open file descriptor or a lock on a
mutex. It would be nice if the file actually got closed or the lock got
released.

> This is the mentality that one needs to have in a garbage-collected
> environment, since you get the same exact effect when you set a reference to
> null.
>

The single most important feature of C++ is that destruction of objects
happen at well defined times. GC in C++ would separate destruction of
objects from memory reclamation. Other GC languages have a harder time
reclaiming resources other than memory because they don't or can't separate
out these two distinct phases.

-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

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