14 Mar
2016
14 Mar
'16
12:23 p.m.
On 03/14/2016 07:35 AM, Rob Stewart wrote:
Neither answer is great. The exception could occur during shack unwinding, so you couldn't use your pointers in very many contexts. No exception means UB, which means users have to remember a special case and thereby lose safety.
I fail to see how that is better than using weak_ptr. In that case, one must always be explicit rather than remember special cases.
It is much more complicated to use an explicit weak_ptr because you need to know where the cycle ends, etc. What if you have a neural network? How do you define where to use weak_ptr over shared_ptr, etc.?