hasElaborateDestructor
Nick Treleaven
nick at geany.org
Wed Apr 30 11:48:21 UTC 2025
On Sunday, 27 April 2025 at 22:01:11 UTC, Luna wrote:
> Elaborate refers to destructors which are not automatically
> generated by the D compiler; eg. If you have a type with
> subtypes that can be destroyed D will automatically set up a
> destructor that handles the destruction chain for you. But if
> you define your own destructor; potentially in a template your
> destructor now becomes elaborate since it has more
> functionality than just ensuring its children are destroyed if
> needed. Elaborate destructors only apply to structs however,
> not classes.
An elaborate destructor can either be directly declared for a
type or generated by the compiler due to its fields:
```d
static struct S2 { ~this() {} }
static struct S3 { S2 field; }
static assert( hasElaborateDestructor!S2);
static assert( hasElaborateDestructor!S3);
```
More information about the Digitalmars-d
mailing list