Boost logo

Boost Users :

From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-07-11 16:56:19


--- In Boost-Users_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> From: "bill_kempf" <williamkempf_at_h...>
> >
> > Well, you could write the weak_ptr<>::operator-> to "do the right
> > thing":
> >
> > shared_ptr<T> weak_ptr<T>::operator->()
> > {
> > shared_ptr<T> p = make_shared(wp);
> > if (!p)
> > throw "something";
> > return p;
>
> return shared_ptr<T>(*this); // same as above
>
> > }
>
> Yes, I can, and I did - initially. Darin objected that such an
operator->
> would be confusing for weak_ptr users and people that read the code
(too
> much hidden meaning in p->f(),) and it's better to be explicit.

Oh, I agree with the design decision. I just didn't feel comfortable
leaving the particulars out of the reply to the original op. You can
provide a working implementation, and for some people it might seem
like the right thing to do, and if the op was in this camp (or
someone else reading the thread) then the answer wasn't complete
enough. I just was trying to help point out some of the obvious (to
me) reasons it wasn't done that way for those who might not have seen
it (as in it wasn't obvious to them).

Bill Kempf


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net