Date: 2001-07-13 13:00:53
--- In boost_at_y..., Christian Thäter <chth_at_g...> wrote:
> > Excuse me for breaking in where I probably don't belong, but I'm
> > sure I'm understanding what you're asking. Do you expect to have
> > 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
> > 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
> > I wouldn't argue against inclusion of a smart pointer that works
> > way (provided concrete uses can be illustrated), but I'd
> > argue against any desire to change shared_ptr<> itself to behave
> > this manner.
> That leads to the Question "Who owns a shared resource?".
All references share the ownership. That does not mean that if I
reset one reference I want or expect all other references to be reset
> The actual state
> is some lazy-ownership where anyone who holds a shared_pointer can
> member in sharing it but can't reset it for the entire 'sharing-
> 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.
It's the most natural design. This is the same semantics employed by
languages that have garbage collection, though the implementation is
different. Calling this design "poor" is awfully strong in the face
> std::auto_ptr the ownership is strict defined and has no such
There are no side effects for shared_ptr<> as it is today. What you
are proposing would be a side effect.
> 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
> but i think moving the reset and assign to be protected or removing
> should be possible, making the current boost::shared_ptr immutable
> more precise defined.
It is very precisely defined as is, and the ability to reassign the
reference is key to the whole concept.
> Also i would like to see some kind of semantic like
> i proposed where 'ownership' is more coherent than actually.
Ownership isn't more coherent with your proposed semantics. Every
pointer *still* shares ownership with a single object. The only
thing you've changed is the semantics of assigning a new value to the
pointer, and the proposed semantics cause a side effect to occur.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk