Boost logo

Boost :

From: Christian Thäter (chth_at_[hidden])
Date: 2001-07-13 10:51:26

> Excuse me for breaking in where I probably don't belong, but I'm not
> sure I'm understanding what you're asking. Do you expect to have the
> following semantics?
> shared_ptr<foo> p1(new foo());
> shared_ptr<foo> p2(p1);
> p1.reset(new foo());
> assert(p1.get() == p2.get());


> That certainly seems to be what you mean when you say "they should
> not break the shared resource as they do now so either update all
> copies or none."
> If this is what you mean, I don't find such semantics to be
> intuitive, or even useful for anything but the most obscure designs.
> I wouldn't argue against inclusion of a smart pointer that works this
> way (provided concrete uses can be illustrated), but I'd definately
> argue against any desire to change shared_ptr<> itself to behave in
> this manner.

That leads to the Question "Who owns a shared resource?". The actual state
is some lazy-ownership where anyone who holds a shared_pointer can be
member in sharing it but can't reset it for the entire 'sharing-community',
the only use of reset() is to detach from the existing resource and
reuse the pointer in some manner.
I think reusing a object in such a manner is a poor design. In
std::auto_ptr the ownership is strict defined and has no such
side-effects. Thats why i promoted a all or nothing practice for
consistency reasons. So I deprecate the the current change-policy in
boost::shared_ptr, well changeing to a new semantic might be unacceptable,
but i think moving the reset and assign to be protected or removing them
should be possible, making the current boost::shared_ptr immutable and
more precise defined. Also i would like to see some kind of semantic like
i proposed where 'ownership' is more coherent than actually.

cya Christian


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