Boost logo

Boost Users :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2006-02-06 10:17:32


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net