6 Feb
2006
6 Feb
'06
3:17 p.m.
Guy Peleg wrote:
Suppose that class A that accepts a pointer to class B. An instance of A class can own the pointer or it can share it with some other A instances. The knowledge of whether or not the A instance should own the pointer is something that depends by the one that construct the instance. Shared_ptr seems as a good candidate for this problem but what if the pointer passed to the A instance might come from a legacy code that works with raw-pointers ? I think that a kind of scoped_ptr with a ownership flag will help here
Shared_ptr also takes a deleter in addition to the initial raw pointer. See http://www.boost.org/libs/smart_ptr/sp_techniques.html#static as an example of providing your own deleter. Jeff Flinn