From: Glenn M. <de...@st...> - 2009-10-29 20:22:09
|
Modified: trunk/stepmania/src/RageUtil.h Log: helper for cycling through an enum Modified: trunk/stepmania/src/RageUtil.h ============================================================================== --- trunk/stepmania/src/RageUtil.h (original) +++ trunk/stepmania/src/RageUtil.h Thu Oct 29 13:21:54 2009 @@ -183,6 +183,14 @@ static inline T enum_add2( T val, int iA return static_cast<T>( val + iAmt ); } +template<typename T> +static inline T enum_cycle( T val, int iMax, int iAmt = 1 ) +{ + int iVal = val + iAmt; + iVal %= iMax; + return static_cast<T>( iVal ); +} + /* * We only have unsigned swaps; byte swapping a signed value doesn't make sense. |