Boost logo

Boost :

Subject: Re: [boost] [valid_ptr] proposing a new type of pointer object that allows validity tracking without memory management and object ownership
From: Dan Walters (dan683_at_[hidden])
Date: 2011-03-17 08:21:16


On 17 March 2011 03:33, Gruenke, Matt <mgruenke_at_[hidden]> wrote:
...
 the possibility of templates which parameterize both the object
lifetime management policy and pointer validity (or non-null-ness, at
least).  Whether it would be worthwhile is a separate question.

I think the issue of semantics, showing intent, suggesting behavior is
very relevant. Perhaps the name subscribed_ptr describes the usage and
mechanics better than valid_ptr does?

Matt <mgruenke_at_[hidden]> wrote:
... put a shared_mutex in valid_target<> and hide some locking in
accesses via valid_ptr<> (i.e. put a scoped_lock in a temporary object
returned by valid_ptr<>'s operators)
... Unfortunately, I don't see how that would be better than weak_ptr<>

Right now, I agree. I think thread safety is beyond the ambitions of
valid_ptr which should be intentionally light weight. On the flip
side, there are plenty of MT programs out there that don't use
reference counting smart pointers and get by fine.

Matt <mgruenke_at_[hidden]> wrote:
the same thing could be accomplished by using weak pointers to an
object whose refcount had been manually incremented by 1.  When you
want to kill it, one of the referers could then manually decrement the
refcount, so that it gets killed when it goes back to idle.

valid_ptr should not be able to release it's target object by design -
it is not a memory management pointer.


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