On 4/27/12, Trass3r <[email protected]> wrote: > //! bring named enum members into current scope > string flattenNamedEnum(EnumType)() > if (is (EnumType == enum)) > { > string s = ""; > foreach (i, e; __traits(allMembers, EnumType)) > { > s ~= "alias " ~ EnumType.stringof ~ "." ~ __traits(allMembers, > EnumType)[i] ~ " " ~ __traits(allMembers, EnumType)[i] ~ ";\n"; > } > > return s; > }
I used something similar for a custom DLL symbol loader. I defined all extern(C) function pointers inside of a struct, then mixed in the loader code for each function by iterating all fields of the struct, and then used a "flattenName" type template to make all the function pointers global.
