Contextual metaprogramming, query the parent type.
Nick Treleaven
nick at geany.org
Fri Feb 4 16:03:08 UTC 2022
On Friday, 4 February 2022 at 15:56:05 UTC, Nick Treleaven wrote:
> I think you can do this but users would need to use a string
> mixin when defining the field. A function can obtain the parent
> symbol name using this trick:
Sorry, that doesn't work. But hopefully you get the idea - the
string mixin produces something that obtains the parent type name:
```d
struct Parent
{
pragma(msg, __traits(parent, {}).stringof); // Parent
}
```
More information about the Digitalmars-d
mailing list