Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-05-01 22:40:44


The subject says it all. Well, the main point, at least. To check it
out, visit:
http://groups.yahoo.com/group/boost/files/smart_pointers/loki_ptr/mi_smart_p
tr.hpp

I added a boost_ref Ownership policy, which is pretty much a
dummy do-nothing policy, and three new Storage policies
corresponding to shared_ptr, weak_ptr, and intrusive_ptr. On
the one hand, shared_ptr didn't fit into boost::loki::smart_ptr's
policy layout. On the other hand, it's a testament to the power
and flexibility of the policy-based design that it works anyway.
The only thing missing is support for custom deleters. The
only reason I didn't add that was because I didn't get to it, and
because it would change smart_ptr's public interface. It seems
reasonable to add, but I'd like Andrei to comment on it, since
it's his baby.

I did two other things: ported it to VC6, and added array support
(taking a hint from Beman's reference implementation).
Unfortunately, I uncovered a nasty bug in bcc where the first
smart_ptr instantiated trumps the policy specifications of later
instantiations. I'm not sure how such a glaring error could
occur, but it's specific to bcc, since both gcc 3 and VC6 compile
and run the test program correctly. I didn't want to release the
test program, as a matter of personal pride (it's pretty ugly, and
pretty small), but it illustrates my hack for VC6's lack of template
template parameter support. Take a look here:
http://groups.yahoo.com/group/boost/files/smart_pointers/loki_ptr/mi_sp_test
.cpp
Basically, I retained the template template interface, and provided
a set of macros that simulates template template parameters
for VC6 users. I'm bothered by the different interfaces for
different compilers, but even more bothered by the idea of
abandoning the template template parameters.

I used the latest versions of shared_ptr and friends in the CVS,
and was even going to provide conversion c'tors from *_ptr,
but didn't get to it. I hope this work inspires (or provokes) some
more discussion. ;)

Dave


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