enums and operator overloading

Just trying to make cyclical enum with an operator++ and really feeling like I'm fumbling around. Any advice appreciated {B¬)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
enum RENDER_MODE
{
RENDER_NORMAL,
RENDER_WIRE,
RENDER_DEBUG_WIRE,
RENDER_DEBUG_SOLID,
RENDER_MODE_LAST
};

inline RENDER_MODE operator++( RENDER_MODE &rs, int )
{
	int temp = rs;
	temp++;
	if( temp >= RENDER_MODE_LAST )
		temp = 0;
	rs = (RENDER_MODE)temp;
	return (RENDER_MODE)temp;
}


and then somewhere else I can cycle through the avalable enums with

1
2
3
4
5
RENDER_MODE drawtype = RENDER_NORMAL;

...

drawtype++;


Is this OK or am I doing something daft. Is there a better way of doing this?

Thanks
Topic archived. No new replies allowed.