views:

86

answers:

1

I'm investigating smart pointers with "shared" functionality for Windows CE and Mobile, where the VS 2008 tr1 std::shared_ptr cannot be used (due to linkage to a v.9 dll not present on CE, obviously, if I understand it correctly).

There's a semi-old MSDN Magazine article with sources from a Microsoftie (Eric Niebler): Achieve More Reliable Resource Management with Our Custom C++ Classes.

The reasoning, design and implementation of his shared_any looks solid, but I'm wondering if anyone ever actually tested the lot on any platform (not necessarily WinCe/WM)?

+5  A: 

You might want to use boost::shared_ptr. As I understand it, the Boost.SmartPointer library is a header-only library, and so you can just copy over the headers you need from Boost to get everything working.

Michael Aaron Safyan
Be sure not to use boost::shared_ptr with an array unless you specify a destructing function in the shared_ptr constructor. This is unwieldy without lambda syntax, so you may want to also use boost::shared_array
Steve
@Steve: There's no problem using boost::shared_ptr elements in a std::vector, right?
Johann Gerell
@Johann, that should be fine, the vector will call the object's destrutor when it goes out of scope
Steve