Static Assert in C++0x
This is post in the C++ Reference series on this site.
All the C++ programmers have used static asserts some have used Loki version, others have used Boost version or created their own. However, in all cases the error messages generated by Static Assert are incomplete. A language level support is needed to correctly support Static Assert.
The C++0x adds Static Assert to solve this specific issue. The synatx for static assert is something like:
static_assert(sizeof(int) == 4, "Size of int is not 4 bytes.") ;
On any machine where the sizeof(int) is not 4, the compilers should correctly generate error message “Size of int is not 4 bytes”. Sweet.
leave a comment