Getting Field Names of a specific UDA in compile time.

realhet real_het at
Sat Oct 3 13:10:31 UTC 2020


class Printer{
   @("NODES") int gem1, gem2, gem3, gem4, gem5, head1, head2, 
head3, head4;

   import std.traits, std.meta;
   alias Nodes = getSymbolsByUDA!(typeof(this), "NODES");
   enum NodeNames = ["gem1", "gem2", ....];

Is there a way to make an enum like the above with compile time 
I only managed to get the string[] by making a static foreach, 
but I don't know how to put that in an enum xxx = ...; statement.

More information about the Digitalmars-d-learn mailing list