![]() |
Home | Libraries | People | FAQ | More |
BOOST_CONTRACT_STATIC_INVARIANT — Program static class invariants that can be completely disabled at compile-time.
// In header: <boost/contract_macro.hpp>
BOOST_CONTRACT_STATIC_INVARIANT(...)BOOST_CONTRACT_STATIC_INVARIANT({ ... }) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_INVARIANTS is defined):
#ifndef BOOST_CONTRACT_NO_INVARIANTS static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() { ... } #endif
Where:
{ ... } is the definition of the function that checks class invariants for static public functions (see BOOST_CONTRACT_INVARIANT and BOOST_CONTRACT_INVARIANT_VOLATILE). The curly parenthesis are mandatory. Assertions within this function are usually programmed using BOOST_CONTRACT_ASSERT, but any exception thrown by a call to this function indicates a contract assertion failure (and will result in this library calling either boost::contract::entry_invariant_failure or boost::contract::exit_invariant_failure). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
See Also:
Disable Contract Compilation, Class Invariants