an enum inside another enum
    maarten van damme 
    maartenvd1994 at gmail.com
       
    Thu Jul 26 09:08:24 PDT 2012
    
    
  
Such a shame that enums do not allow mixins to be made. This
(mixin(EnumInh!First)) would've been an imho way cleaner solution then
declaring your own kind off enum and doing template magic on that.
I still have some problems with Simen's code (the first one, haven't
yet experimented with enumeration.d)
template ExtendEnum(T, string s)
        if (is(T == enum) && is(typeof({mixin("enum a {"~s~"}");}))){
        mixin(
        "enum ExtendEnum {"
        ~ EnumDefAsString!T() ~ s
        ~ "}");
}
The newly generated ExtendEnum will try to convert my old enum with
string fields to integer fields. the mixin should generated
"ExtendEnum : string" when passing in an enum with type string. Same
problem apply's to the second line of this sniped. enum a doesn't have
a type yet so it will try to convert everything to ints.
As I seem to run into problems few others have, is my usage of enum's incorrect?
    
    
More information about the Digitalmars-d-learn
mailing list