This standard recommends the inclusion of diagnostic tests into your program using the assert()
macro or other mechanisms (see MSC11-A. Incorporate diagnostic tests using assertions). Static assertion is a new facility in the C++ 0X draft standard. This facility enables assertions to be made at compile time rather than runtime, meeting the following requirements:
...
Code Block |
---|
static_assert(sizeof(int) <= sizeof(void*), "sizeof(int) <= sizeof(void*)"); /* Passes */ static_assert(sizeof(double) <= sizeof(int), "sizeof(double) <= sizeof(int)"); /* Fails */ |
Static assertion is also a new facility in the C++ 0X draft standard
Non-Compliant Code Example
...