Generating enum members
Milli
alezardo02 at gmail.com
Sat Mar 15 14:47:01 UTC 2025
Hello everyone.
It's my first time starting a thread here please have patience
and let me know if there is anything i have done wrong!
I'm currently doing a project where there are two pretty lengthy
enums whose members depend on each other.
Declaring one after the other makes it hard to double check that
i haven't missed anything, which is why i'm trying to make a
template mixin where i can declare the members together and the
template does all the appropriate sorting.
I'm not having any luck in generating the enums though.
The simplified version of what i need would be
```D
mixin template create_enum(alias members) {
enum enumname {
static foreach(member; members) {
mixin(member.stringof,",");
}
}
}
```
which obviously doesn't work.
Is it possible at all to do something like this in D?
Thank you for the help!
More information about the Digitalmars-d
mailing list