Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-07-16 16:08:58


AMDG

Meryl Silverburgh wrote:
> Thank you. You said 'btw, do you really wish to return the reference?'
> , Can you please tell me what do you mean, like what kind of problems
> it will cause?
>

The potential problem is if the reference outlives all the
shared_ptrs. Whether this is an actual problem or not
depends on how getB is used. If the result is a short-lived
reference, then it's safe. If the result is saved somewhere, it's
safer to return a shared_ptr to make sure that the object doesn't
get destroyed from underneath you.

In Christ,
Steven Watanabe


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