Boost logo

Boost :

From: Thant Tessman (thant_at_[hidden])
Date: 2000-08-07 11:05:15


boost_at_[hidden] wrote:

> Date: Sun, 6 Aug 2000 10:54:34 -0600
> From: "Greg Colvin" <greg_at_[hidden]>
> Subject: Re: really smart pointers submission
>
> I had a little time this morning to study your code.
>
> I have three concerns so far:
>
> Multiple inheritance. It appears that your use of void* in RawHandle
> will not work for multiple inheritance.

Yes, but there may be a fix for this. I didn't want to bother working it
out until/unless there was interest. Currently an assert checks that
multiple inheritance isn't being used in such a way as to break things.

> Pointer comparison. The contains() function is not portable, because
> pointers that are not into the same array are not comparable.

Yes. According to a conversation on c.l.c++.m, this test will work on
most "normal" hardware. There's another test that is supposedly
portable, but it's much slower. I guess a compile-time switch is
appropriate in any final version of this.

> Performance. It appears (I could be wrong) that your collection
> algorithm is not linear in the number of managed objects, but is of
> order N squared.

Each object is checked against every pointer for containment. So it's
O(M*N) where M is the number of pointers and N is the number of objects.
I can't think of a direct way around this, but one idea to minimize this
effect is to only check new objects (that is, objects that have been
created or modified since the last collection). I'm not sure, but this
may significantly complicate housekeeping. I'm very open to other
ideas...

To be honest, I'm just happy it works at all. I don't follow the C++
literature religiously, but I haven't seen this problem addressed in a
general way before.

Note that Daryle Walker has done some work on the implementation. As
soon as I get a chance to look through it, I'll resubmit it.

-thant


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