Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2001-10-18 12:07:50

on 10/18/01 9:05 AM, David Abrahams at david.abrahams_at_[hidden] wrote:

> I am prepared to accept that; I cited the design as a possible cause without
> any real evidence. I think your swap() solution does much to simplify
> things. What else needs to be done? Anything?

I think Peter's proposed revision of smart_ptr.hpp is great. After reading
it over again I have a few thoughts about it.

Things in there that I like without reservations:

    a) separate headers for each class
    b) swap idiom for assignment and reset for clarity and to fix the
recently-discussed bug [but see (j) below]
    c) shared_dynamic_cast
    d) shared_ptr<void> support

Things in there that I like, but I'd like to see taken further:

    e) removal of std::swap overload is good, but I'd like to see a
boost::swap overload added, since that has good effects for standard library
algorithms with MSL at least, even if the improvement is not guaranteed by
the standard
    f) removal of std::less partial specialization and addition of <
operator is good, but I'd like to either see the other comparison operators
or a rationale for why they are not provided

Things missing (no criticism of the proposal is intended here, just a
comment on the state of what's up there right now):

    g) shared_array needs many of the fixes already in shared_ptr
    h) documentation

Things in there that I am not sure we want:

    i) removal of "self assignment" feature of reset member -- it's a
strange feature, but I'm not sure we should remove it
    j) reset() on a unique shared_ptr now allocates memory due to simpler
swap idiom implementation
    k) use of shared_count for implementation -- I don't see any publicly
exported features in the current version; I think we might want to go the
other direction and do pool allocation of the count, rather than making the
reference count object even bigger

Since the smart_ptr library is the most loved library in Boost, we probably
want to take care what we do with it. That's presumably one reason we've
been so slow to make changes.

I have a patch ready and tested that introduces the swap idiom into today's
smart_ptr.hpp to fix the bug we discussed earlier, but I'll hold off until
we have some consensus. It addresses (b), but introduces (j).

    -- Darin

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