In C ++ 0x (from here ):
In C ++ 0x, static statements can be declared to detect and diagnose common usage errors at compile time.
This is the static_assert syntax:
>>-static_assert--(--constant-expression--,--string-literal----->
where constant-expression should be contextually converted to bool . If it converts to false , then the compiler will throw an error according to string-literal .
So this is basically an extension of the language that needs a keyword. This is not a execution mechanism.
Again from the document linked above:
Adding static statements to the C ++ language has the following advantages:
Libraries can detect common usage errors at compile time.
C ++ standard library implementations can detect and diagnose common usage errors, improving usability.
You can use the static_assert declaration to check for important software invariants at compile time.
source share