Deriving a struct from another one via template: Easy way to propagate UDAs?

Inkrementator anon at example.org
Sat Mar 16 20:24:23 UTC 2024


On Friday, 15 March 2024 at 19:13:38 UTC, cc wrote:
> This is trivially easy if your types are visible at module 
> level, and mixin is a fine tool for the job.  It doesn't work 
> quite so well with [Voldemort 
> types](https://wiki.dlang.org/Voldemort_types).
I used the following lines to make it work for Unknown and I 
think even Voldemort types.
```d
static foreach(att; allFieldTypes){
			//pragma(msg, "alias %s =att;\n".format(att.stringof));
			mixin("alias %s = att;\n".format(att.stringof));
		}
```
But I don't know how to do this (in a general) for UDAs, since 
they can be values instead of types too, i.e. @UDA(Voldemort!2(3))


More information about the Digitalmars-d-learn mailing list