...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
BOOST_CONTRACT_INVARIANT_VOLATILE — Program volatile class invariants that can be completely disabled at compile-time.
// In header: <boost/contract_macro.hpp>
BOOST_CONTRACT_INVARIANT_VOLATILE(...)
BOOST_CONTRACT_INVARIANT_VOLATILE
({ ... }) 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 void BOOST_CONTRACT_INVARIANT_FUNC() const volatile { ... } #endif
Where:
{ ... } is the definition of the function that checks class invariants for volatile public functions (see BOOST_CONTRACT_INVARIANT
and BOOST_CONTRACT_STATIC_INVARIANT
). 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, Volatile Public Functions