<smart_ptr> scoped_ptr with an ownership flag?
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 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
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
participants (2)
-
Guy Peleg
-
Jeff Flinn