How do I do placement delete in D?
Steven Schveighoffer
schveiguy at yahoo.com
Tue Dec 14 12:42:57 PST 2010
On Tue, 14 Dec 2010 15:33:26 -0500, Craig Black <craigblack2 at cox.net>
wrote:
> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
> news:op.vnpz6ob6eav7ka at steve-laptop...
>> On Tue, 14 Dec 2010 15:18:32 -0500, Craig Black <craigblack2 at cox.net>
>> wrote:
>>
>>> I know emplace is used to do placement new. What is the equivalent
>>> placement delete?
>>
>> x = emplace(yourAllocationFunction!T());
>>
>> ...
>>
>> clear(x);
>> yourDeallocationFunction(x); // if necessary. For instance, stack data
>> doesn't need to be deallocated
>>
>> -Steve
>
> Is there a way to explicitly invoke a struct destructor without doing an
> explicit delete?
Not sure what you mean. All clear is going to do is invoke the
destructor, so I don't know what else you need?
-Steve
More information about the Digitalmars-d
mailing list