Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Macro BOOST_CONTRACT_OLD

BOOST_CONTRACT_OLD — Program old value copies at body that can be completely disabled at compile-time.

Synopsis

// In header: <boost/contract_macro.hpp>

BOOST_CONTRACT_OLD(...)

Description

BOOST_CONTRACT_OLD(f) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_OLDS is defined):

#ifndef BOOST_CONTRACT_NO_OLDS
    .old(f)
#endif

Where:

  • f is the nullary functor called by this library f() to assign old value copies just before the body is execute but after entry invariants (when they apply) and preconditions are checked. Old value pointers within this functor call are usually assigned using BOOST_CONTRACT_OLDOF. Any exception thrown by a call to this functor will result in this library calling boost::contract::old_failure (because old values could not be copied to check postconditions and exception guarantees). This functor should capture old value pointers by references so they can be assigned (all other variables needed to evaluate old value expressions can be captured by (constant) value, or better by (constant) reference to avoid extra copies). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)

See Also:

Disable Contract Compilation, Old Values Copied at Body


PrevUpHomeNext