|
Boost Users : |
Subject: Re: [Boost-users] how to help an object to delete itself the boost way
From: Ireneusz SzczeÅniak (irek.szczesniak_at_[hidden])
Date: 2015-12-18 04:37:02
Richard, your comments are spot-on. The problem is that the object
should not care how it was created. Now I still remember that these
objects are dynamically created, but later I might forget that, and
create objects differently, thus causing problems.
Now it's clear for me, that objects should not delete themselves.
As you mention, an object should notify some piece of code to delete
it later. That's how I implemented it just now.
Thanks for your advice!
On 18.12.2015 03:50, Richard Damon wrote:
> On 12/17/15 3:15 PM, Ireneusz SzczeÅniak wrote:
>> Hi Ian,
>>
>> Thanks for your email. I only wonder how an object should trigger
>> its deletion...
>>
>>
>> Best,
>> Irek
> The big issue that I see is how do you know that the object was
> created via new? (that is the only sort of object that CAN be deleted).
>
> Also, if the object deletes itself, it somehow must make sure that no
> one else has kept a copy of its address and might try to access after
> it has deleted itself.
>
> Both of these questions, and some of your comments, point somewhat to
> the idea that it might not be the object that wants to delete itself,
> but that the object may be part of some framework, and it should
> inform the framework that it is done, and the framework can then
> remove the object and delete it.
>
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