|
![](/i/fill.gif) |
Am 14.03.2012 15:38, schrieb Invisible:
> On 14/03/2012 02:36 PM, clipka wrote:
>> Am 14.03.2012 10:55, schrieb Invisible:
>>
>>>> Note that the dispose is gone for good. Shared pointers use reference
>>>> counters to accomplish this feat.
>>>
>>> Every time I hear somebody say this, a part of me wants to scream "you
>>> /do/ understand that reference counting doesn't actually work, right?"
>>
>> Which is because...?
>
> Allow me to rephrase: Reference counting works if and only if the node
> reference graph is acyclic.
>
> Sometimes it's feasible to ensure that this is the case. Sometimes it is
> not.
While this is true, it is not a problem specific to reference counting,
but one that is inherent in /any/ attempt at automatic object lifetime
management.
That's why C++11 also provides weak pointers. They're not a cure-all for
such problems, but they do help in some situations (such as when the
cyclic references come from pointers to parent objects in a tree).
Post a reply to this message
|
![](/i/fill.gif) |