On Fri, 04 May 2012 02:45:03 -0400, Benjamin Thaut
<c...@benjamin-thaut.de> wrote:
Hi,
I'm currently doing some manual memory management and as the delete
keyword is deperecated I want to replace it with a custom Delete
template. I now need to destroy a array of structs, this however seems
only be possible by using the typeinfo object of the struct and calling
xdtor on that which is a indirect function call for every struct in the
array. I would like to destroy the struct directly with a direct call to
the destructor. This seems not to be possible because calling __dtor
results in calling the wrong dtor (apperently there are 3, __dtor,
__fieldDtor, __aggrDtor). So __dtor is the wrong destructor because it
does not destroy any members of the struct but __fieldDtor and
__aggrDtor are not callable. They show up in the __traits(allMembers)
list but if you try to call them you get a error message that such a
property does not exist. So is there any way to directly destroy a
struct, and if not why can't we directly expose the correct destructor,
because apprently it is known at compile time.
Look at what object.clear() does, since it is meant to replace delete.
In fact, I'd advise just using that if you have the type handy.
-Steve