--- In Boost-Users@y..., "Peter Dimov"
From: "bill_kempf"
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