Boost logo

Boost Users :

From: Darin Adler (darin_at_[hidden])
Date: 2002-07-11 16:41:55


On Thursday, July 11, 2002, at 02:38 PM, bill_kempf wrote:

> 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;
> }

As long as you don't use the result of -> with the & operator or pass
it to a function taking a reference. I think the temporary lifetime is
a little to subtle to be a good solution here.

     -- Darin


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