Quote:Original post by Richy2kCompile-time asserts are an awesome tool!
You can do a compile time assert if you so very wish:#define COMPILE_TIME_ASSERT( a ) { int Temp[ ( a ) ? 1 : 0 ]; }
Although these generally shouldn't be needed, used, or glanced at.
I wouldn't do it like that though. In a debug build at least that will actually take up the size of an int. You needn't actually declare an array, simply doing a typedef of an invalid sized array will do. The second problem is that some compilers allow zero lengthed arrays, or at least only give a warning. Better to make the 0 a -1.
This bring you to up to par with the definition of C_ASSERT that already come with MSVC.
If you want to go furthur and get a nicer error message look into boost's STATIC_ASSERT instead.