foreach over enums?

Tomek Sowiński just at ask.me
Tue Oct 5 15:11:49 PDT 2010


Simen kjaeraas napisał:

> enum X { A=3, B=1, C }
> 
> void main( ) {
> foreach( e;  __traits(allMembers, X) ) {
> writeln( "X.", e, " = ", mixin( "X."~e ) );
> }
> }

mixin("X."~e)  =>  __traits(getMember, X, e)
For mixin-allergics.

-- 
Tomek


More information about the Digitalmars-d-learn mailing list