Re: [gtkmm] using RefPtr out of Gtkmm



On Wed, Feb 11, 2004 at 08:36:45PM +0000, Chris Vine wrote:
> It is certainly more aesthetically pleasing, I agree, and puts the reference 
> counting where intuitively one thinks it ought to be.  Intrusive pointers are 
> fine for languages which require all objects to be derived from a common base 
> object class (which can do the reference counting), but that isn't the model 
> that C++ follows.
> 

On the other hand, there is a logic to intrusive reference counting
where there is inheritance. Suppose Derived is derived from Base,
and EvenMoreDerived is derived from Derived. Suppose my_instance
is a instance of EvenMoreDerived. Different modules "think"
of my_instance in deferent ways. Module A deals with my_instance
as a Base and wants to keep a smart pointer to base of my_instance.
Module C deals with my_instance as a Derived and wants to keep
a smart pointer to my_instance as a Derived. Module C deals with
my_instance as an EvenMoreDerived ect.

How would you do that with unintrusive pointers? smart_ptr<Base>,
smart_ptr<Derived>, smart_ptr<EvenMoreDerived> how do they
all use a common reference count?

With intrusive reference counts, the refcounts can be hidden
in the Object class that all these other classes have to be dervied from.

With unintrusive reference counts the templade smart_ptr<EvenMoreDerived>
does not even know that Base and Derived exist, so how can it
use the same reference counts as these?


-- 
Paul Elliott                       1(512)837-1096
pelliott io com                    PMB 181, 11900 Metric Blvd Suite J
http://www.io.com/~pelliott/pme/   Austin TX 78758-3117

Attachment: pgpPnvO3m8sIk.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]