Rotating though an enum idiom
Spacen Jasset
spacenjasset at yahoo.co.uk
Sat Sep 6 15:18:32 PDT 2008
Spacen Jasset wrote:
> Is there a way to "rotate" though and enum; So that:
>
>
> enum RenderMode { POINT, LINE, FILL }
>
> renderMode = POINT;
> fn(renderMode) gives LINE
> fn(renderMode) gives FILL
> fn(renderMode) gives POINT
> and so on, in rotation.
>
> I would normally use some sort of modulo operation on an int to do this,
> but I wonder if there is another way.
Like this:
mRenderMode = cast(RenderMode)((mRenderMode + 1) % (RenderMode.max + 1));
More information about the Digitalmars-d-learn
mailing list