11 Jul
2002
11 Jul
'02
9:46 p.m.
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.