Custom delete not getting called

Ali Çehreli acehreli at yahoo.com
Fri Jun 24 22:50:35 PDT 2011


On Sat, 25 Jun 2011 07:36:21 +0200, Daniel Gibson wrote:

> Am 25.06.2011 06:33, schrieb Ali Çehreli:
>> On Sat, 25 Jun 2011 06:24:31 +0200, Andrej Mitrovic wrote:
>> 
>>> These are going away, I don't know why they're still being kept in the
>>> docs.
>> 
>> If I understood correctly, you mean that the custom new and delete
>> operators for user defined types are going away? If so, I am wasting my
>> time writing something about those. :)
>> 
>> Is there a replacement for the custom new and delete?
> 
> emplace() (and clear() to call the destructor)

I am aware of the discussions about delete going away. I always thought 
that it was about the 'delete o;' usage that was going away.

emplace() is to construct an object at a location that you already have.

clear() is to call the destructor.

Custom new and delete are (were?) different:

- Custom new gets called to give you a chance to allocate the memory for 
an object (Note that this is different than emplace() where you want to 
construct the object on memory that is already available.)

- Custom delete is the reverse of custom new. (And this is not clear(), 
as when custom delete is called, the object has already been destroyed.)

I want to ask again: Are custom new and delete going away? Oh! Let me 
check TDPL... I can't find those there. I guess they are deprecated. 
Cool! Less to write about. :)

Ali


More information about the Digitalmars-d mailing list