Explorar el Código

Added a static assert to make sure type IDs always have a corresponding type name.

--HG--
branch : minor
Alex Szpakowski hace 10 años
padre
commit
dcbe7c4871
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  1. 2 0
      src/common/types.cpp

+ 2 - 0
src/common/types.cpp

@@ -202,6 +202,8 @@ StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
 
 
 StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
 StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
 
 
+static_assert((sizeof(typeEntries) / sizeof(typeEntries[0])) == TYPE_MAX_ENUM, "Type name array size doesn't match the total number of type IDs!");
+
 bool getType(const char *in, love::Type &out)
 bool getType(const char *in, love::Type &out)
 {
 {
 	return types.find(in, out);
 	return types.find(in, out);