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(object);

destroy is in the automatically imported object.dm so you don't have to import anything,

The source code is in dmd2/src/druntime/src/object_.d, there's a few overloads if you are curious how it is implemented. Short answer is there's a pointer to the destructor in the TypeInfo and destroy calls it.

Thank you :)

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(cast(T *)pMemory, arguments);
                return cast(T) pMemory;
        }

Doesn't seems to work, and i can't find any good documentation about it.

Reply via email to