Don't allow XToString for *_INVALID values. Nothing uses this and it makes the range assert not fire if the string array has one fewer entry than the enum.
This commit is contained in:
@@ -35,13 +35,9 @@ static inline void enum_add( T &val, int iAmt )
|
|||||||
#define FOREACH_ENUM( e, max, var ) for( e var=(e)0; var<max; enum_add<e>( var, +1 ) )
|
#define FOREACH_ENUM( e, max, var ) for( e var=(e)0; var<max; enum_add<e>( var, +1 ) )
|
||||||
|
|
||||||
|
|
||||||
static const CString EMPTY_STRING;
|
|
||||||
|
|
||||||
#define XToString(X, CNT) \
|
#define XToString(X, CNT) \
|
||||||
const CString& X##ToString( X x ) \
|
const CString& X##ToString( X x ) \
|
||||||
{ \
|
{ \
|
||||||
if( x == ARRAYSIZE(X##Names)+1 ) \
|
|
||||||
return EMPTY_STRING; \
|
|
||||||
ASSERT(unsigned(x) < CNT); \
|
ASSERT(unsigned(x) < CNT); \
|
||||||
return X##Names[x]; \
|
return X##Names[x]; \
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user