C++ Static Assert
StaticAssert is like assert for C++, except that the test is done at compile
time. Of course this can only be done when the test is possible at compile
const char *stiName =
StaticAssert((sizeof(stiName) / sizeof(stiName)) == 100,
Here the array is one element in size, and we have a StaticAssert that will
fail if the array is not 100 in size with an error of WrongSizeOfArray.
boost also provides a Static Assert
(http://www.boost.org/libs/static_assert/static_assert.htm), but if you
don't want all of boost, or you can't get it to compile, then this might
still be of use to you.
References This is simply a packaged standalone header of the StaticAssert shown in
Modern C++ Design: Generic Programming and Design Patterns Applied
by Andrei Alexandrescu.
Original Link http://www.openoffice.org/servlets/ReadMsg?msgId=930121&listName=dev
See StaticAssert.hxx for more details.
Caolan McNamara (2003) <firstname.lastname@example.org>