(Manifest) constants inside structs

Sönke Ludwig ludwig at informatik_dot_uni-luebeck.de
Tue Jan 22 17:14:41 PST 2008


Finally found a dirty hack that works:

T ct_strip_const_helper(T)( const(T)[] t ){ return (cast(T[])t)[0]; }
T ct_strip_const(T)( const(T) t ){ return ct_strip_const_helper([t]); }

struct S {
   static const S ess_const = {1};

   int member;
}


struct T {
   static const T tee_const = {ct_strip_const(S.ess_const)};

   S member;
}



More information about the Digitalmars-d mailing list