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: Gruenke, Matt (mgruenke_at_[hidden])
Date: 2011-03-16 16:44:42


> without memory management and object ownership

I think a useful complement to the pointer types in boost.smart_ptr would be something I've referred to as passive_ptr<>. It's passive in the sense that it doesn't imply object ownership and therefore doesn't involve itself in object lifetime management.
 
The problem I am interested in solving is the case where you see bare pointers (i.e. non-smart pointers) being used in code and you're not sure whether there's a good reason that they're not one of the smart pointers (or auto_ptr<>, which I normally use in cases where I really want scoped_ptr<>, but I need to transfer ownership out of it). Also, it's helpful to easily know that it's not a bug that the pointer isn't deleted.
 
In other words, a passive_ptr<> class wouldn't add any functionality over a bare pointer, but it would enable users to communicate semantic intent. Perhaps that covers some of what you're targeting with valid_ptr<>? As for ensuring validity, I don't see how this is possible without getting involved in lifetime management.
 
 
Matt
 


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