[Scummvm-devel] SharedPtr usage

Peres _peres at libero.it
Tue Apr 1 09:34:00 CEST 2008


Hi there

I could finally try SharedPtr (revision 31287). Latest revision (31346) is now on my computer and will try it later if I get time, so what I write may be outdated/wrong. On the other side, I can't foresee when I will be able to connect again, so please be patient.

There is a routine in Parallaction (findZone) that scans two lists, one containing SharedPtr<A>'s and one containing SharedPtr<B>'s (with B subclassing A). The routine should be able to return a SharedPtr<A> if a certain condition is matched, or NULL (or similar) if no match is found.

The comments in common/ptr.h (at lines 98-99) suggest assigning a SharedPtr<B> to a SharedPtr<A> when B subclasses A is possible, but I haven't been able to do so (I tried!).

Also, how do you simulate a NULL value with SharedPtr<A>? Is a SharedPtr<A> that has been initialised by its default constructor a NULL SharedPtr<A>?

Both the issues above can be dealt with by resorting to the get() method and working with raw pointers, but that probably defeats the whole SharedPtr concept. Somebody please give some wisdom here :)

Thanks
peres





More information about the Scummvm-devel mailing list