| Home | Libraries | People | FAQ | More

## Class template specify_old_postcondition_except

boost::contract::specify_old_postcondition_except — Allow to specify old value copies at body, postconditions, and exception guarantees.

## Synopsis

    // In header: <boost/contract/core/specify.hpp>

    template<typename VR>
    class specify_old_postcondition_except {
    public:
      // construct/copy/destruct
      ~specify_old_postcondition_except();

      // public member functions
      template<typename F>
        specify_postcondition_except< VirtualResult > old(F const &);
      template<typename F> specify_except postcondition(F const &);
      template<typename F> specify_nothing except(F const &);
    };

## Description

Allow to specify functors this library will call to copy old value at body, check postconditions, and check exception guarantees. This object is internally constructed by this library when users specify contracts calling `boost::contract::function` and similar functions (that is why this class does not have a public constructor).

See Also:

Old Value Copies at Body, Postconditions, Exception Guarantees

### `specify_old_postcondition_except` public construct/copy/destruct

1.     ~specify_old_postcondition_except();

   Destruct this object.

   Throws: This can throw in case programmers specify failure handlers that throw exceptions instead of terminating the program (see Throw on Failure). (This is declared `noexcept(false)` since C++11.)

### `specify_old_postcondition_except` public member functions

1.     template<typename F>
         specify_postcondition_except< VirtualResult > old(F const & f);

   Allow to specify old value copies at body.

   It should often be sufficient to initialize old value pointers as soon as they are declared, without using this function (see Old Value Copies at Body).

   Parameters: |
   `f` | Nullary functor called by this library `f()` to assign old value copies just before the body is executed 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).
   Returns: | After old value copies at body have been specified, the object returned by this function allows to optionally specify postconditions and exception guarantees.

2.     template<typename F> specify_except postcondition(F const & f);

   Allow to specify postconditions.

   Parameters: |
   `f` | Functor called by this library to check postconditions `f`(...). Assertions within this functor are usually programmed using ``BOOST_CONTRACT_ASSERT``, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling ``boost::contract::postcondition_failure``). This functor should capture variables by (constant) references (to access the values they will have at function exit). This functor must be a nullary functor if `VirtualResult` is `void`, otherwise it must be a unary functor accepting the return value as a parameter of type `VirtualResult const&` (to avoid extra copies of the return value, or of type `VirtualResult` or `VirtualResult const` if extra copies of the return value are irrelevant).
   Returns: | After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees.

3.     template<typename F> specify_nothing except(F const & f);

   Allow to specify exception guarantees.

   Parameters: |
   `f` | Nullary functor called by this library to check exception guarantees `f()`. Assertions within this functor are usually programmed using ``BOOST_CONTRACT_ASSERT``, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling ``boost::contract::except_failure``). This functor should capture variables by (constant) references (to access the values they will have at function exit).
   Returns: | After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract.