Boost logo

Boost :

From: Eric Ford (eford_at_[hidden])
Date: 2001-05-19 12:03:50

> I was wanting to get by without making a copy of the shared pointer,
> but after your comment about it not being "safe" as far as the
> Standard is concerned I started thinking and realized that compilers
> are allowed to do any manner of magic when downcasting or upcasting
> classes so not allowing the compiler to truly typecast the object
> pointer contained within the smart pointer would not be portable
> if it did work for my platform. Of course, you may be referring to
> something else that I'm not even thinking of.

Thanks for your code snippet. I don't really like using non-standard
code, especially since in this case it could cause really weird and
hard to track down bugs, should it ever become a problem.

As for how to solve the problem, I was thinking of using a smart
pointer that used a linked list rather than a simple reference count.
Then if all the linked smart pointers were derived from a common
(empty) base class, the linked list could include linked smart
pointers of different types. I'm afraid there might be a significant
performance penalty, though. Maybe someone more familiar with how
compilers implement these things could comment.

Anyway, I've been busy with other things and have just left some ugly
code in place for the time being. If you or someone else do implement
something like this, please let me know. If you'd like I can supply a
smart pointer implemented in terms of a linked list (not my own but
freely distributable).


Boost list run by bdawes at, gregod at, cpdaniel at, john at