Destroying structs without a typeinfo object

Benjamin Thaut code at benjamin-thaut.de
Thu May 3 23:45:03 PDT 2012


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.

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list