Re: Call destructor directly.

2013-10-21 Thread Agustin
On Monday, 21 October 2013 at 07:31:30 UTC, Ali Çehreli wrote: On 10/20/2013 10:59 PM, Agustin wrote: > That didn't work, but after reading how emplace works, i had to make > some changes. > > public T allocate(T : Object, A...)(auto ref A arguments) { > auto pMemory = rawAllocate(

Re: Call destructor directly.

2013-10-21 Thread Dicebot
On Monday, 21 October 2013 at 11:48:11 UTC, Benjamin Thaut wrote: Using destroy will zero the entire memory block after destroying the object. If you are freeing the memory right after destroying this is going to cost you performance. To avoid this declare: extern (C) void rt_finalize2(void*

Re: Call destructor directly.

2013-10-21 Thread Benjamin Thaut
Am 21.10.2013 04:17, schrieb Adam D. Ruppe: On Monday, 21 October 2013 at 02:06:02 UTC, Agustin wrote: I'm implementing some custom memory allocator, is possible to call an object destructor directly? destroy(object); destroy is in the automatically imported object.dm so you don't have to im

Re: Call destructor directly.

2013-10-21 Thread Ali Çehreli
On 10/20/2013 10:59 PM, Agustin wrote: > That didn't work, but after reading how emplace works, i had to make > some changes. > > public T allocate(T : Object, A...)(auto ref A arguments) { > auto pMemory = rawAllocate(__traits(classInstanceSize, T), > T.alignof); Does rawAllocate

Re: Call destructor directly.

2013-10-20 Thread Agustin
On Monday, 21 October 2013 at 05:40:13 UTC, Agustin wrote: On Monday, 21 October 2013 at 05:17:01 UTC, Jonathan M Davis wrote: On Monday, October 21, 2013 05:53:46 Agustin wrote: On Monday, 21 October 2013 at 03:50:24 UTC, Agustin wrote: > On Monday, 21 October 2013 at 03:46:33 UTC, Jonathan M

Re: Call destructor directly.

2013-10-20 Thread Agustin
On Monday, 21 October 2013 at 05:17:01 UTC, Jonathan M Davis wrote: On Monday, October 21, 2013 05:53:46 Agustin wrote: On Monday, 21 October 2013 at 03:50:24 UTC, Agustin wrote: > On Monday, 21 October 2013 at 03:46:33 UTC, Jonathan M Davis > > wrote: >> On Monday, October 21, 2013 05:07:02 A

Re: Call destructor directly.

2013-10-20 Thread Jonathan M Davis
On Monday, October 21, 2013 05:53:46 Agustin wrote: > On Monday, 21 October 2013 at 03:50:24 UTC, Agustin wrote: > > On Monday, 21 October 2013 at 03:46:33 UTC, Jonathan M Davis > > > > wrote: > >> On Monday, October 21, 2013 05:07:02 Agustin wrote: > >>> What about constructor?. My current code i

Re: Call destructor directly.

2013-10-20 Thread Agustin
On Monday, 21 October 2013 at 03:46:33 UTC, Jonathan M Davis wrote: On Monday, October 21, 2013 05:07:02 Agustin wrote: What about constructor?. My current code is: T allocate(T : Object, A...)(auto ref A arguments) { auto pMemory = rawAllocate(__traits(classInstanceSize

Re: Call destructor directly.

2013-10-20 Thread Agustin
On Monday, 21 October 2013 at 03:50:24 UTC, Agustin wrote: On Monday, 21 October 2013 at 03:46:33 UTC, Jonathan M Davis wrote: On Monday, October 21, 2013 05:07:02 Agustin wrote: What about constructor?. My current code is: T allocate(T : Object, A...)(auto ref A arguments) {

Re: Call destructor directly.

2013-10-20 Thread Jonathan M Davis
On Monday, October 21, 2013 05:07:02 Agustin wrote: > What about constructor?. My current code is: > > T allocate(T : Object, A...)(auto ref A arguments) { > auto pMemory = rawAllocate(__traits(classInstanceSize, T), > T.alignof); // Return void* > > emplace!T(ca

Re: Call destructor directly.

2013-10-20 Thread Agustin
On Monday, 21 October 2013 at 02:26:03 UTC, Agustin wrote: On Monday, 21 October 2013 at 02:17:54 UTC, Adam D. Ruppe wrote: On Monday, 21 October 2013 at 02:06:02 UTC, Agustin wrote: I'm implementing some custom memory allocator, is possible to call an object destructor directly? destroy(obj

Re: Call destructor directly.

2013-10-20 Thread Agustin
On Monday, 21 October 2013 at 02:17:54 UTC, Adam D. Ruppe wrote: On Monday, 21 October 2013 at 02:06:02 UTC, Agustin wrote: I'm implementing some custom memory allocator, is possible to call an object destructor directly? destroy(object); destroy is in the automatically imported object.dm so

Re: Call destructor directly.

2013-10-20 Thread Adam D. Ruppe
On Monday, 21 October 2013 at 02:06:02 UTC, Agustin wrote: I'm implementing some custom memory allocator, is possible to call an object destructor directly? destroy(object); destroy is in the automatically imported object.dm so you don't have to import anything, The source code is in dmd2/

Call destructor directly.

2013-10-20 Thread Agustin
I'm implementing some custom memory allocator, is possible to call an object destructor directly? For example void deallocate(T)(T object) { assert(object !is null); object.~this(); rawDeallocate(cast(void *)object); }