Re: Destructing Struct

2018-02-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/21/18 6:24 AM, Jiyan wrote: I think i found my solution: is it __xdtor? :P Yes, that is the function that will run *recursively* all the destructors (just __dtor runs the destructor method if you provided one). But I'd recommend as the others did, using destroy. -Steve

Re: Destructing Struct

2018-02-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 12:07:47 UTC, ketmar wrote: `p.destroy` will call the dtors for you. So it is the same function but I prefer to always write it: .destroy(p); yes, a leading dot. This ensures you call the top-level destroy function instead of any members which may not do the

Re: Destructing Struct

2018-02-21 Thread ketmar via Digitalmars-d-learn
Jiyan wrote: Hi :), What i thought was that when i create a struct dynamically i can just deconstruct it with __dtor lets say: struct U {...} struct S {... private U _member;} S* p; p = cast(S*)malloc(S.sizeof); // just run that if it compiles, for simplicity // we dont use __traits(compil

Re: Destructing Struct

2018-02-21 Thread Jiyan via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 11:12:01 UTC, Jiyan wrote: Hi :), What i thought was that when i create a struct dynamically i can just deconstruct it with __dtor lets say: struct U {...} struct S {... private U _member;} S* p; p = cast(S*)malloc(S.sizeof); // just run that if it compiles

Destructing Struct

2018-02-21 Thread Jiyan via Digitalmars-d-learn
Hi :), What i thought was that when i create a struct dynamically i can just deconstruct it with __dtor lets say: struct U {...} struct S {... private U _member;} S* p; p = cast(S*)malloc(S.sizeof); // just run that if it compiles, for simplicity // we dont use __traits(compiles, ...) p.__dt