P99
|
◆ P99_PROTECTED_BLOCK
A meta-macro to protect a dependent block or statement by the statements BEFORE that is executed before the block and AFTER that is executed afterward. Early exit from the block is possible with
An example of a potential use is #define P99_INVARIANT(EXPR) P99_PROTECTED_BLOCK(assert((EXPR) && "failed on entry"), assert((EXPR) && "failed on leave"))
Such a construct may then be used like this P99_INVARIANT(x > 5) {
// do something with x that changes it but ensures that
// it will be strictly less than 5 at the end
}
and this would trigger an assertion whenever the condition is not fulfilled when entering or leaving the block. Definition at line 217 of file p99_block.h. |