digitalmars.D - How do I do placement delete in D?
- Craig Black (3/3) Dec 14 2010 I know emplace is used to do placement new. What is the equivalent
- Steven Schveighoffer (8/10) Dec 14 2010 x = emplace(yourAllocationFunction!T());
- Craig Black (5/15) Dec 14 2010 Is there a way to explicitly invoke a struct destructor without doing an...
- Steven Schveighoffer (5/24) Dec 14 2010 Not sure what you mean. All clear is going to do is invoke the
- Craig Black (3/3) Dec 14 2010 Thanks Steve. clear seems to be calling the destructor twice. Is this
- Steven Schveighoffer (4/6) Dec 14 2010 No. Can you file a bug?
- Craig Black (1/4) Dec 14 2010 done
- Craig Black (2/2) Dec 14 2010 Arg! Someone removed my bug report and assumed I was wrong about it wit...
- Andrei Alexandrescu (3/5) Dec 14 2010 The bug report stands, thanks for clarifying it.
- Craig Black (3/8) Dec 14 2010 Thanks!
- Steven Schveighoffer (6/9) Dec 15 2010 Nobody removed your report, I'm not sure why you think that. I hope you...
- Stanislav Blinov (9/12) Dec 15 2010 AFAIR, it's not 'clear()' that calls destructor twice. Some time ago,
- Steven Schveighoffer (6/20) Dec 15 2010 No, the issue is different. Struct dtors are not called when GC memory ...
- Craig Black (3/3) Dec 14 2010 About the destructor being called twice, perhaps clear is passing by val...
I know emplace is used to do placement new. What is the equivalent placement delete? -Craig
Dec 14 2010
On Tue, 14 Dec 2010 15:18:32 -0500, Craig Black <craigblack2 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
Dec 14 2010
"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message news:op.vnpz6ob6eav7ka steve-laptop...On Tue, 14 Dec 2010 15:18:32 -0500, Craig Black <craigblack2 cox.net> wrote:Is there a way to explicitly invoke a struct destructor without doing an explicit delete? -CraigI 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
Dec 14 2010
On Tue, 14 Dec 2010 15:33:26 -0500, Craig Black <craigblack2 cox.net> wrote:"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message news:op.vnpz6ob6eav7ka steve-laptop...Not sure what you mean. All clear is going to do is invoke the destructor, so I don't know what else you need? -SteveOn Tue, 14 Dec 2010 15:18:32 -0500, Craig Black <craigblack2 cox.net> wrote:Is there a way to explicitly invoke a struct destructor without doing an explicit delete?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
Dec 14 2010
Thanks Steve. clear seems to be calling the destructor twice. Is this intentional? -Craig
Dec 14 2010
On Tue, 14 Dec 2010 16:05:14 -0500, Craig Black <craigblack2 cox.net> wrote:Thanks Steve. clear seems to be calling the destructor twice. Is this intentional?No. Can you file a bug? -Steve
Dec 14 2010
Arg! Someone removed my bug report and assumed I was wrong about it without even checking into it. Why do I even try to help the D community?
Dec 14 2010
On 12/14/10 5:09 PM, Craig Black wrote:Arg! Someone removed my bug report and assumed I was wrong about it without even checking into it. Why do I even try to help the D community?The bug report stands, thanks for clarifying it. Andrei
Dec 14 2010
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:ie8vpc$2gbg$1 digitalmars.com...On 12/14/10 5:09 PM, Craig Black wrote:Thanks!Arg! Someone removed my bug report and assumed I was wrong about it without even checking into it. Why do I even try to help the D community?The bug report stands, thanks for clarifying it. Andrei
Dec 14 2010
On Tue, 14 Dec 2010 18:09:44 -0500, Craig Black <craigblack2 cox.net> wrote:Arg! Someone removed my bug report and assumed I was wrong about it without even checking into it. Why do I even try to help the D community?Nobody removed your report, I'm not sure why you think that. I hope you don't stop trying to improve D, we need everyone's support who is willing to give it. -Steve
Dec 15 2010
15.12.2010 0:05, Craig Black пишет:Thanks Steve. clear seems to be calling the destructor twice. Is this intentional? -CraigAFAIR, it's not 'clear()' that calls destructor twice. Some time ago, there has been discussion on how to properly implement clear(). Initial implementation calls dtor, then calls default ctor to leave the object in a meaningful state for the GC to consume. Therefore, when object is being collected, dtor gets called for a second time. The discussion ended on the proposal of nullifying objec't vtbl instead of calling default ctor, which will obviate the need of a second dtor call, but I think this is not currently implemented.
Dec 15 2010
On Wed, 15 Dec 2010 12:46:34 -0500, Stanislav Blinov <blinov loniir.ru> wrote:15.12.2010 0:05, Craig Black пишет:No, the issue is different. Struct dtors are not called when GC memory is collected. I found the issue. I just checked in a fix: http://www.dsource.org/projects/druntime/changeset/451 -SteveThanks Steve. clear seems to be calling the destructor twice. Is this intentional? -CraigAFAIR, it's not 'clear()' that calls destructor twice. Some time ago, there has been discussion on how to properly implement clear(). Initial implementation calls dtor, then calls default ctor to leave the object in a meaningful state for the GC to consume. Therefore, when object is being collected, dtor gets called for a second time. The discussion ended on the proposal of nullifying objec't vtbl instead of calling default ctor, which will obviate the need of a second dtor call, but I think this is not currently implemented.
Dec 15 2010
About the destructor being called twice, perhaps clear is passing by value rather than by reference? If so, is this desirable? -Craig
Dec 14 2010