From: omy Date: Thu, 19 Dec 2013 10:17:33 +0000 (+0400) Subject: 0024456: Graphic3d_MaterialAspect - use static assert instead of runtime exception X-Git-Tag: HYDRO-2014-01-31~63 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=b5eb71669107337eadfc0f42f1f8b5f440326d97 0024456: Graphic3d_MaterialAspect - use static assert instead of runtime exception Graphic3d_MaterialAspect::NumberOfMaterials() : Standard_ASSERT_RAISE instead of run-time check is now used. Replaced with Standard_STATIC_ASSERT --- diff --git a/src/Graphic3d/Graphic3d_MaterialAspect.cxx b/src/Graphic3d/Graphic3d_MaterialAspect.cxx index e9359ee163..55197dfa3f 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.cxx +++ b/src/Graphic3d/Graphic3d_MaterialAspect.cxx @@ -63,7 +63,7 @@ // for the class #include - +#include //-Aliases //-Global data definitions @@ -887,10 +887,8 @@ static Material theMaterials[] = { }; Standard_Integer Graphic3d_MaterialAspect::NumberOfMaterials() { -Standard_Integer n =sizeof(theMaterials)/sizeof(Material); - if( n > Graphic3d_NOM_DEFAULT ) { - cout << " *** Graphic3d_MaterialAspect::NumberOfMaterials() may return a badvalue due to incoherente size between material name array and enum" << endl; - } + Standard_STATIC_ASSERT(sizeof(theMaterials)/sizeof(Material) == Graphic3d_NOM_DEFAULT); + return Graphic3d_NOM_DEFAULT; }