Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-07-13 09:39:42


At 10:03 AM 7/13/2001, Christian Thäter wrote:

> ... Does it [shared_ptr] need reset() and assign operations?

Yes, to support common usages. For example, shared_ptr<> is often used as
a class member, and reset() allows setting the member during execution of
the containing class constructor, after arguments needed for the pointee's
new are known.

The particular signatures follow std::auto_ptr.

>Won't a immutable shared_ref cover the semantics better? If we provide a
>reset() and/or assign operation then they should not break the shared
>resource as they do now so either update all copies or none.

Don't confuse better and different. Those semantics (which have been
discussed many times over the years) would be different. They would be
better for people who need those semantics. They would be worse for those
who need the current semantics.

There are literally thousands of useful sets of smart pointer
semantics. Some someone comes up with a generator or policy based solution
which can supply all of those combinations of semantics, and yet is easy
and safe enough for very broad (beginner through expert) usage. Once that
happens, people will abandon shared_ptr. But that hasn't happened yet, and
until it does boost::shared_ptr<> meets a wide variety of needs.

--Beman


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