|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-08-30 13:27:20
First Issue:
I've just found myself wanting a really flexible smart pointer, along the
lines of the one in Loki by Andrei Alexandrescu. For a long time I thought
that I would rarely want more than shared_ptr, but I can see that this is
going to come up again and again for me. Unfortunately, I couldn't use
Andrei's design because very few compilers will apply the empty base
optimization in cases of multiple inheritance. So, even if shared_ptr is our
choice for submission to the committee I would really like to see a
policy-based smart pointer in boost.
Second Issue:
I found the following code in shared_array (and I assume the analogous code
is in shared_ptr):
void reset(T* p=0)
{
if ( px == p ) return; // fix: self-assignment safe
What this does is to make a silent success of resetting a shared_ptr with
the pointer it owns. The problem with that is that resetting a shared_ptr to
any /other/ pointer which is managed by a shared_ptr is a fatal (and
hard-to-detect) error, which happens even to experienced programmers. I
don't think the trade-off is a good one. Making this special case (which we
can detect) silently work when all other cases will fail without complaint
is a mistake. I'd rather see an assert() here.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk