Reference

Header <boost/contract.hpp>
Include all header files required by this library at once (for convenience).
All header files boost/contract/*.hpp are independent from one another and can be included one-by-one to reduce the amount of code to compile from this library in user code (but this was measured to not make an appreciable difference in compile-time so boost/contract.hpp can be included directly in most cases). Instead the headers boost/contract/core/*.hpp are not independent from other library headers and they are automatically included by the boost/contract/*.hpp headers (so the boost/contract/core/*.hpp headers are usually not directly included by programmers).
All files under the boost/contract/detail/ directory, names within the boost::contract::detail namespace, names prefixed with boost_contract_detail... and BOOST_CONTRACT_DETAIL... (in any namesapce, including user's code) are reserved for internal use of this library and should never be used directly by programmers.
See Also:
Getting Started

Header <boost/contract/assert.hpp>
Assert contract conditions.


BOOST_CONTRACT_ASSERT(cond)
BOOST_CONTRACT_ASSERT_AUDIT(cond)
BOOST_CONTRACT_ASSERT_AXIOM(cond)

BOOST_CONTRACT_ASSERT
Preferred way to assert contract conditions.

// In header: <boost/contract/assert.hpp>

BOOST_CONTRACT_ASSERT(cond)

Description
Any exception thrown from within a contract (preconditions, postconditions, exception guarantees, old value copies at body, class invariants, etc.) is interpreted by this library as a contract failure. Therefore, users can program contract assertions manually throwing an exception when an asserted condition is checked to be false (this library will then call the appropriate contract failure handler boost::contract::precondition_failure, etc.). However, it is preferred to use this macro because it expands to code that throws boost::contract::assertion_failure with the correct assertion file name (using __FILE__), line number (using __LINE__), and asserted condition code so to produce informative error messages.
BOOST_CONTRACT_ASSERT, BOOST_CONTRACT_ASSERT_AUDIT, and BOOST_CONTRACT_ASSERT_AXIOM are the three assertion levels predefined by this library.
See Also:
Preconditions, Postconditions, Exceptions Guarantees, Class Invariants
Parameters:	
cond	Boolean contract condition to check. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_ASSERT((cond)) will always work.)
BOOST_CONTRACT_ASSERT_AUDIT
Preferred way to assert contract conditions that are computationally expensive, at least compared to the cost of executing the function body.

// In header: <boost/contract/assert.hpp>

BOOST_CONTRACT_ASSERT_AUDIT(cond)

Description
The asserted condition will always be compiled and validated syntactically, but it will not be checked at run-time unless BOOST_CONTRACT_AUDITS is defined (undefined by default). This macro is defined by code equivalent to:

#ifdef BOOST_CONTRACT_AUDITS
    #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \
        BOOST_CONTRACT_ASSERT(cond)
#else
    #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \
        BOOST_CONTRACT_ASSERT(true || cond)
#endif

BOOST_CONTRACT_ASSERT, BOOST_CONTRACT_ASSERT_AUDIT, and BOOST_CONTRACT_ASSERT_AXIOM are the three assertion levels predefined by this library. If there is a need, programmers are free to implement their own assertion levels defining macros similar to the one above.
See Also:
Assertion Levels
Parameters:	
cond	Boolean contract condition to check. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_ASSERT_AUDIT((cond)) will always work.)
BOOST_CONTRACT_ASSERT_AXIOM
Preferred way to assert contract conditions that are computationally prohibitive, at least compared to the cost of executing the function body.

// In header: <boost/contract/assert.hpp>

BOOST_CONTRACT_ASSERT_AXIOM(cond)

Description
The asserted condition will always be compiled and validated syntactically, but it will never be checked at run-time. This macro is defined by code equivalent to:

#define BOOST_CONTRACT_ASSERT_AXIOM(cond) \
    BOOST_CONTRACT_ASSERT(true || cond)

BOOST_CONTRACT_ASSERT, BOOST_CONTRACT_ASSERT_AUDIT, and BOOST_CONTRACT_ASSERT_AXIOM are the three assertion levels predefined by this library. If there is a need, programmers are free to implement their own assertion levels defining macros similar to the one above.
See Also:
Assertion Levels
Parameters:	
cond	Boolean contract condition to check. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_ASSERT_AXIOM((cond)) will always work.)

Header <boost/contract/base_types.hpp>
Specify inheritance form base classes (for subcontracting).


BOOST_CONTRACT_BASE_TYPES(...)

BOOST_CONTRACT_BASE_TYPES
Used to program a typedef listing the bases of a derived class.

// In header: <boost/contract/base_types.hpp>

BOOST_CONTRACT_BASE_TYPES(...)

Description
In order to support subcontracting, a derived class that specifies contracts for one or more overriding public function must declare a typedef named base_types (or BOOST_CONTRACT_BASES_TYPEDEF) using this macro.

class u :
    #define BASES public b, protected virtual w1, private w2
    BASES
{
    friend class boost::contract:access;

    typedef BOOST_CONTRACT_BASES(BASES) base_types;
    #undef BASES

    ...
};

This typedef must be public if boost::contract::access is not used.
See Also:
Base Classes
Parameters:	
...	Comma separated list of base classes. Each base must explicitly specify its access specifier public, protected, or private, and also virtual when present (this not always required in C++ instead). There is a limit of about 20 maximum bases that can be listed (because of similar limits in Boost.MPL internally used by this library). This is a variadic macro parameter, on compilers that do not support variadic macros, the typedef for base classes can be programmed manually without using this macro.

Header <boost/contract/call_if.hpp>
Statically disable compilation and execution of functor calls.
This facility allows to emulate C++17 if constexpr statements when used together with functor templates (or C++14 generic lambdas).

namespace boost {
  namespace contract {
    template<bool Pred, typename Then, typename ThenResult = internal_type> 
      struct call_if_statement;

    template<typename Then> 
      struct call_if_statement<false, Then, internal_type>;
    template<typename Then> struct call_if_statement<true, Then, internal_type>;
    template<typename Then, typename ThenResult> 
      struct call_if_statement<true, Then, ThenResult>;
    template<typename Then> struct call_if_statement<true, Then, void>;
    template<bool Pred, typename Then> 
      call_if_statement< Pred, Then > call_if_c(Then);
    template<typename Pred, typename Then> 
      call_if_statement< Pred::value, Then > call_if(Then);
    template<bool Pred, typename Then> bool condition_if_c(Then, bool = true);
    template<typename Pred, typename Then> 
      bool condition_if(Then, bool = true);
  }
}

boost::contract::call_if_statement
Select compilation and execution of functor template calls using a static boolean predicate.

// In header: <boost/contract/call_if.hpp>

template<bool Pred, typename Then, typename ThenResult = internal_type> 
struct call_if_statement {
};

Description
This class template has no members because it is never used directly, it is only used via its specializations. Usually this class template is instantiated only via the return value of boost::contract::call_if and boost::contract::call_if_c.
See Also:
Assertion Requirements

Template Parameters

bool Pred

Static boolean predicate that selects which functor template call to compile and execute.

typename Then

Type of the functor template to call if the static predicate Pred is true.

typename ThenResult = internal_type

Return type of then-branch functor template call (this is usually automatically deduced by this library so it is never explicitly specified by the user, and that is why it is often marked as internal_type in this documentation).
boost::contract::call_if_statement<false, Then, internal_type>
Template specialization to handle static predicates that are false.

// In header: <boost/contract/call_if.hpp>

template<typename Then> 
struct call_if_statement<false, Then, internal_type> {
  // construct/copy/destruct
  explicit call_if_statement(Then const &);

  // public member functions
  template<typename Else> result_of< Else()>::type else_(Else) const;
  template<bool ElseIfPred, typename ElseIfThen> 
    call_if_statement< ElseIfPred, ElseIfThen > else_if_c(ElseIfThen) const;
  template<typename ElseIfPred, typename ElseIfThen> 
    call_if_statement< ElseIfPred::value, ElseIfThen > 
    else_if(ElseIfThen) const;
};

Description
This template specialization handles all else-branch functor template calls (whether they return void or not). Usually this class template is instantiated only via the return value of boost::contract::call_if and boost::contract::call_if_c.
See Also:
Assertion Requirements

Template Parameters

typename Then

Type of functor template to call when the static predicate is true (never the case for this template specialization).

call_if_statement public construct/copy/destruct

explicit call_if_statement(Then const & f);

Construct this object with the then-branch functor template.
Parameters:	
f	Then-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is false). The return type of f() must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.

call_if_statement public member functions

template<typename Else> result_of< Else()>::type else_(Else f) const;

Specify the else-branch functor template.
The result_of<Else()>::type expression should be evaluated only when the static predicate is already checked to be false (because Else() is required to compile only in that case). Thus, this result-of expression is evaluated lazily only in instantiations of this template specialization.
Parameters:	
f	Else-branch nullary functor template. The functor template call f() is actually compiled and executed for this template specialization (because the if-statement static predicate is false). The return type of f() must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.
Returns:	A copy of the value returned by the call to the else-branch functor template f().

template<bool ElseIfPred, typename ElseIfThen> 
  call_if_statement< ElseIfPred, ElseIfThen > else_if_c(ElseIfThen f) const;

Specify an else-if-branch functor template (using a static boolean predicate).
Parameters:	
f	Else-if-branch nullary functor template. The functor template call f() is actually compiled and executed if and only if ElseIfPred is true (because the if-statement static predicate is already false for this template specialization). The return type of f() must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.
Template Parameters:	
ElseIfPred	Static boolean predicate selecting which functor template call to compile and execute.
Returns:	A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, this will be the return value of the functor template call being compiled and executed.

template<typename ElseIfPred, typename ElseIfThen> 
  call_if_statement< ElseIfPred::value, ElseIfThen > 
  else_if(ElseIfThen f) const;

Specify an else-if-branch functor template (using a nullary boolen meta-function).
Parameters:	
f	Else-if-branch nullary functor template. The functor template call f() is actually compiled and executed if and only if ElseIfPred::value is true (because the if-statement static predicate is already false for this template specialization). The return type of f() must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.
Template Parameters:	
ElseIfPred	Nullary boolean meta-function selecting which functor template call to compile and execute.
Returns:	A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, this will be the return value of the functor template call being compiled and executed.
boost::contract::call_if_statement<true, Then, internal_type>
Template specialization to dispatch between then-branch functor template calls that return void and the ones that return non-void.

// In header: <boost/contract/call_if.hpp>

template<typename Then> 
struct call_if_statement<true, Then, internal_type> : public boost::contract::call_if_statement< true, Then, result_of< Then()>::type >
{
  // construct/copy/destruct
  explicit call_if_statement(Then);
};

Description
The base class is a call-if statement so the else and else-if statements can be specified if needed. Usually this class template is instantiated only via the return value of boost::contract::call_if and boost::contract::call_if_c.
The result_of<Then()>::type expression should be evaluated only when the static predicate is already checked to be true (because Then() is required to compile only in that case). Thus, this template specialization introduces an extra level of indirection necessary for proper lazy evaluation of this result-of expression.
See Also:
Assertion Requirements

Template Parameters

typename Then

Type of functor template to call when the static predicate is true (as it is for this template specialization).

call_if_statement public construct/copy/destruct

explicit call_if_statement(Then f);

Construct this object with the then-branch functor template.
Parameters:	
f	Then-branch nullary functor template. The functor template call f() is compiled and called for this template specialization (because the if-statement static predicate is true). The return type of f() must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.
boost::contract::call_if_statement<true, Then, ThenResult>
Template specialization to handle static predicates that are true for then-branch functor template calls that do not return void.

// In header: <boost/contract/call_if.hpp>

template<typename Then, typename ThenResult> 
struct call_if_statement<true, Then, ThenResult> {
  // construct/copy/destruct
  explicit call_if_statement(Then);

  // public member functions
  operator ThenResult() const;
  template<typename Else> ThenResult else_(Else const &) const;
  template<bool ElseIfPred, typename ElseIfThen> 
    call_if_statement< true, Then, ThenResult > 
    else_if_c(ElseIfThen const &) const;
  template<typename ElseIfPred, typename ElseIfThen> 
    call_if_statement< true, Then, ThenResult > 
    else_if(ElseIfThen const &) const;
};

Description
Usually this class template is instantiated only via the return value of boost::contract::call_if and boost::contract::call_if_c.
See Also:
Assertion Requirements

Template Parameters

typename Then

Type of functor template to call when the static predicate is true (as it is for this template specialization).

typename ThenResult

Non-void return type of the then-branch functor template call.

call_if_statement public construct/copy/destruct

explicit call_if_statement(Then f);

Construct this object with the then-branch functor template.
Parameters:	
f	Then-branch nullary functor template. The functor template call f() is actually compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be the same as (or implicitly convertible to) the ThenResult type.

call_if_statement public member functions

operator ThenResult() const;

This implicit type conversion returns a copy of the value returned by the call to the then-branch functor template.

template<typename Else> ThenResult else_(Else const & f) const;

Specify the else-branch functor template.
Parameters:	
f	Else-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be the same as (or implicitly convertible to) the ThenResult type.
Returns:	A copy of the value returned by the call to the then-branch functor template (because the else-branch functor template call is not executed).

template<bool ElseIfPred, typename ElseIfThen> 
  call_if_statement< true, Then, ThenResult > 
  else_if_c(ElseIfThen const & f) const;

Specify an else-if-branch functor template (using a static boolean predicate).
Parameters:	
f	Else-if-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be the same as (or implicitly convertible to) the ThenResult type.
Template Parameters:	
ElseIfPred	Static boolean predicate selecting which functor template call to compile and execute.
Returns:	A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, it will be the return value of the then-branch functor template call for this template specialization (because the if-statement static predicate is true).

template<typename ElseIfPred, typename ElseIfThen> 
  call_if_statement< true, Then, ThenResult > 
  else_if(ElseIfThen const & f) const;

Specify an else-if-branch functor template (using a nullary boolean meta-function).
Parameters:	
f	Else-if-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be the same as (or implicitly convertible to) the ThenResult type.
Template Parameters:	
ElseIfPred	Nullary boolean meta-function selecting which functor template call to compile and execute.
Returns:	A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, it will be the return value of the then-branch functor template call for this template specialization (because the if-statement static predicate is true).
boost::contract::call_if_statement<true, Then, void>
Template specialization to handle static predicates that are true for then-branch functor template calls that return void.

// In header: <boost/contract/call_if.hpp>

template<typename Then> 
struct call_if_statement<true, Then, void> {
  // construct/copy/destruct
  explicit call_if_statement(Then);

  // public member functions
  template<typename Else> void else_(Else const &) const;
  template<bool ElseIfPred, typename ElseIfThen> 
    call_if_statement< true, Then, void > else_if_c(ElseIfThen const &) const;
  template<typename ElseIfPred, typename ElseIfThen> 
    call_if_statement< true, Then, void > else_if(ElseIfThen const &) const;
};

Description
Usually this class template is instantiated only via the return value of boost::contract::call_if and boost::contract::call_if_c.
See Also:
Assertion Requirements

Template Parameters

typename Then

Type of functor template to call when the static predicate if true (as it is for this template specialization).

call_if_statement public construct/copy/destruct

explicit call_if_statement(Then f);

Construct this object with the then-branch functor template.
Parameters:	
f	Then-branch nullary functor template. The functor template call f() is actually compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be void for this template specialization (because the then-branch functor template calls return void).

call_if_statement public member functions

template<typename Else> void else_(Else const & f) const;

Specify the else-branch functor template.
Parameters:	
f	Else-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be void for this template specialization (because the then-branch functor template calls return void).

template<bool ElseIfPred, typename ElseIfThen> 
  call_if_statement< true, Then, void > else_if_c(ElseIfThen const & f) const;

Specify an else-if-branch functor template (using a static boolean predicate).
Parameters:	
f	Else-if-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be void for this template specialization (because the then-branch functor template calls return void).
Template Parameters:	
ElseIfPred	Static boolean predicate selecting which functor template call to compile and execute.
Returns:	A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, it will return void for this template specialization (because the then-branch functor template calls return void).

template<typename ElseIfPred, typename ElseIfThen> 
  call_if_statement< true, Then, void > else_if(ElseIfThen const & f) const;

Specify an else-if-branch functor template (using a nullary boolean meta-function).
Parameters:	
f	Else-if-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is true). The return type of f() must be void for this template specialization (because the then-branch functor template calls return void).
Template Parameters:	
ElseIfPred	Nullary boolean meta-function selecting which functor template call to compile and execute.
Returns:	A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, it will return void for this template specialization (because the then-branch functor template calls return void).
boost::contract::call_if_c
Select compilation and execution of functor template calls using a static boolean predicate.

// In header: <boost/contract/call_if.hpp>


template<bool Pred, typename Then> 
  call_if_statement< Pred, Then > call_if_c(Then f);

Description
Create a call-if object with the specified then-branch functor template:

boost::contract::call_if_c<Pred1>(
    then_functor_template1
).template else_if_c<Pred2>(            // Optional.
    then_functor_template2
)                                       // Optionally, other `else_if_c` or
...                                     // `else_if`.
.else_(                                 // Optional for `void` functors,
    else_functor_template               // but required for non `void`.
)

Optional functor templates for else-if-branches and the else-branch can be specified as needed (the else-branch function template is required if f returns non-void).
See Also:
Assertion Requirements
Parameters:	
f	Then-branch nullary functor template. The functor template call f() is compiled and executed if and only if Pred is true. The return type of other functor template calls specified for this call-if statement (else-branch, else-if-branches, etc.) must be the same as (or implicitly convertible to) the return type of then-branch functor call f().
Template Parameters:	
Pred	Static boolean predicate selecting which functor template call to compile and execute.
Returns:	A call-if statement so else and else-if statements can be specified if needed. Eventually, this will be the return value of the functor template call being compiled and executed (which can also be void).
boost::contract::call_if
Select compilation and execution of functor template calls using a nullary boolean meta-function.

// In header: <boost/contract/call_if.hpp>


template<typename Pred, typename Then> 
  call_if_statement< Pred::value, Then > call_if(Then f);

Description
This is equivalent to boost::contract::call_if_c<Pred::value>(f). Create a call-if object with the specified then-branch functor template:

boost::contract::call_if<Pred1>(
    then_functor_template1
).template else_if<Pred2>(              // Optional.
    then_functor_template2
)                                       // Optionally, other `else_if` or
...                                     // `else_if_c`.
.else_(                                 // Optional for `void` functors,
    else_functor_template               // but required for non `void`.
)

Optional functor templates for else-if-branches and the else-branch can be specified as needed (the else-branch functor template is required if f returns non-void).
See Also:
Assertion Requirements
Parameters:	
f	Then-branch nullary functor template. The functor template call f() is compiled and executed if and only if Pred::value is true. The return type of other functor template calls specified for this call-if statement (else-branch, else-if-branches, etc.) must be the same as (or implicitly convertible to) the return type of then-branch functor template call f().
Template Parameters:	
Pred	Nullary boolean meta-function selecting which functor template call to compile and execute.
Returns:	A call-if statement so else and else-if statements can be specified if needed. Eventually, this will be the return value of the functor template call being compiled and executed (which can also be void).
boost::contract::condition_if_c
Select compilation and execution of a boolean functor template condition using a static boolean predicate.

// In header: <boost/contract/call_if.hpp>


template<bool Pred, typename Then> 
  bool condition_if_c(Then f, bool else_ = true);

Description
Compile and execute the nullary boolean functor template call f() if and only if the specified static boolean predicate Pred is true, otherwise trivially return else_ (true by default) at run-time.
A call to boost::contract::condition_if_c<Pred>(f, else_) is logically equivalent to boost::contract::call_if_c<Pred>(f, [else_] { return else_; }) (but its internal implementation is optimized and it does not actually use call_if_c).
See Also:
Assertion Requirements
Parameters:	
else_	Boolean value to return when Pred is false (instead of compiling and executing the functor template call f()).
f	Nullary boolean functor template. The functor template call f() is compiled and executed if and only if Pred is true.
Template Parameters:	
Pred	Static boolean predicate selecting when the functor template call f() should be compiled and executed.
Returns:	Boolean value returned by f() if the static predicate Pred is true. Otherwise, trivially return else_.
boost::contract::condition_if
Select compilation and execution of a boolean functor template condition using a nullary boolean meta-function.

// In header: <boost/contract/call_if.hpp>


template<typename Pred, typename Then> 
  bool condition_if(Then f, bool else_ = true);

Description
This is equivalent to boost::contract::condition_if_c<Pred::value>(f, else_). Compile and execute the nullary boolean functor template call f() if and only if the specified nullary boolean meta-function Pred is true, otherwise trivially return else_ (true by default) at run-time.
See Also:
Assertion Requirements
Parameters:	
else_	Boolean value to return when Pred::value is false (instead of compiling and executing the functor template call f()).
f	Nullary boolean functor template. The functor template call f() is compiled and executed if and only if Pred::value is true.
Template Parameters:	
Pred	Nullary boolean meta-function selecting when the functor template call f() should be compiled and executed.
Returns:	Boolean value returned by f() if the static predicate Pred is true. Otherwise, trivially return else_.

Header <boost/contract/check.hpp>
RAII object that checks contracts.

namespace boost {
  namespace contract {
    class check;
  }
}

boost::contract::check
RAII object that checks the contracts.

// In header: <boost/contract/check.hpp>


class check {
public:
  // construct/copy/destruct
  template<typename F> check(F const &);
  check(check const &);
  template<typename VirtualResult> 
    check(specify_precondition_old_postcondition_except< VirtualResult > const &);
  template<typename VirtualResult> 
    check(specify_old_postcondition_except< VirtualResult > const &);
  template<typename VirtualResult> 
    check(specify_postcondition_except< VirtualResult > const &);
  check(specify_except const &);
  check(specify_nothing const &);
  ~check();
};

Description
In general, when this object is constructed it checks class invariants at entry, preconditions, and makes old value copies at body. When it is destructed, it checks class invariants at exist, postconditions, and exception guarantees. This object enforces the following (see Contract Programming Overview):
Postconditions are checked only if the body does not throw an exception.
Exceptions guarantees are checked only if the body throws an exception.
Constructor entry never checks class invariants.
Destructor exit checks class invariants only if the body throws an exception (even if destructors should usually not be programmed to throw exceptions in C++).
Static invariants are always checked at entry and exit (and regardless of the body throwing exceptions or not).
When used this way, this object is usually constructed and initialized to the return value of one of the contract functions boost::contract::function, boost::contract::constructor, boost::contract::destructor, or boost::contract::public_function. In addition, this object can be constructed from a nullary functor that is used to program implementation checks.
See Also:
Tutorial, Implementation Checks

check public construct/copy/destruct

template<typename F> check(F const & f);

Construct this object for implementation checks.
This can be used to program checks within implementation code (body, etc.). This constructor is not declared explicit so initializations can use assignment syntax =.
Throws: This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see Throw on Failure).
Parameters:	
f	Nullary functor that asserts implementation checks. f() will be called as soon as this object is constructed at the point it is declared within the implementation code (see Implementation Checks).

check(check const & other);

Construct this object copying it from the specified one.
This object will check the contract, the copied-from object will not (i.e., contract check ownership is transferred from the copied object to the new object being created by this constructor).
Parameters:	
other	Copied-from object.

template<typename VirtualResult> 
  check(specify_precondition_old_postcondition_except< VirtualResult > const & contract);

Construct this object to check the specified contract.
This checks class invariants at entry (if those apply to the specified contract). This constructor is not declared explicit so initializations can use assignment syntax =.
Throws: This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see Throw on Failure).
Parameters:	
contract	Contract to be checked (usually the return value of boost::contract::function or boost::contract::public_function).
Template Parameters:	
VirtualResult	Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function. Otherwise, this is always void.

template<typename VirtualResult> 
  check(specify_old_postcondition_except< VirtualResult > const & contract);

Construct this object to check the specified contract.
This checks class invariants at entry and preconditions (if any of those apply to the specified contract). This constructor is not declared explicit so initializations can use assignment syntax =.
Throws: This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see Throw on Failure).
Parameters:	
contract	Contract to be checked (usually the return value of boost::contract::function, boost::contract::constructor, boost::contract::destructor, or boost::contract::public_function).
Template Parameters:	
VirtualResult	Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function. Otherwise, this is always void.

template<typename VirtualResult> 
  check(specify_postcondition_except< VirtualResult > const & contract);

Construct this object to check the specified contract.
This checks class invariants at entry and preconditions then it makes old value copies at body (if any of those apply to the specified contract). This constructor is not declared explicit so initializations can use assignment syntax =.
Throws: This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating te program (see Throw on Failure).
Parameters:	
contract	Contract to be checked (usually the return value of boost::contract::function, boost::contract::constructor, boost::contract::destructor, or boost::contract::public_function).
Template Parameters:	
VirtualResult	Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function. Otherwise, this is always void.

check(specify_except const & contract);

Construct this object to check the specified contract.
This checks class invariants at entry and preconditions then it makes old value copies at body, plus the destructor of this object will check postconditions in this case (if any of those apply to the specified contract). This constructor is not declared explicit so initializations can use assignment syntax =.
Throws: This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see Throw on Failure).
Parameters:	
contract	Contract to be checked (usually the return value of boost::contract::function, boost::contract::constructor, boost::contract::destructor, or boost::contract::public_function).

check(specify_nothing const & contract);

Construct this object to check the specified contract.
This checks class invariants at entry and preconditions then it makes old value copies at body, plus the destructor of this object will check postconditions and exception guarantees in this case (if any of those apply to the specified contract). This constructor is not declared explicit so initializations can use assignment syntax =.
Throws: This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see Throw on Failure).
Parameters:	
contract	Contract to be checked (usually the return value of boost::contract::function, boost::contract::constructor, boost::contract::destructor, or boost::contract::public_function).

~check();

Destruct this object.
This checks class invariants at exit and either postconditions when the enclosing function body did not throw an exception, or exception guarantees when the function body threw an exception (that is if class invariants, postconditions, and exception guarantees respectively apply to the contract parameter specified when constructing this object).
Throws: This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see Throw on Failure). (This is declared noexcept(false) since C++11.)

Header <boost/contract/constructor.hpp>
Program contracts for constructors.

namespace boost {
  namespace contract {
    template<typename Class> 
      specify_old_postcondition_except constructor(Class *);
  }
}

boost::contract::constructor
Program contracts for constructors.

// In header: <boost/contract/constructor.hpp>


template<typename Class> 
  specify_old_postcondition_except constructor(Class * obj);

Description
This is used to specify postconditions, exception guarantees, old value copies at body, and check class invariants for constructors (see boost::contract::constructor_precondition to specify preconditions for constructors instead):

class u {
    friend class boost::contract:access;

    void invariant() const { // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

public:
    u(...) {
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::constructor(this)
            // No `.precondition` (use `constructor_precondition` if needed).
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_expr);
                ...
            })
            .postcondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Constructor body.
    }

    ...
};

For optimization, this can be omitted for constructors that do not have postconditions and exception guarantees, within classes that have no invariants.
See Also:
Constructors
Parameters:	
obj	The object this from the scope of the enclosing constructor declaring the contract. (Constructors check all class invariants, including static and volatile invariants, see Class Invariants and Volatile Public Functions).
Template Parameters:	
Class	The type of the class containing the constructor declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the constructor body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).

Header <boost/contract/core/access.hpp>
Allow to declare invariants, base types, etc all as private members.

namespace boost {
  namespace contract {
    class access;
  }
}

boost::contract::access
Friend this class to declare invariants and base types as private members.

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


class access {
};

Description
Declare this class a friend of the user-defined class specifying the contracts in order to declare the invariant functions and the base types typedef as non-public members:

class u :
    #define BASES public b, private w
    BASES
{
    friend class boost::contract::access;

    typedef BOOST_CONTRACT_BASES(BASES) base_types; // Private.
    #undef BASES

    void invariant() const { ... } // Private.

public:
    ...
};

In real code, programmers will likely chose to declare this class as friend so to fully control public interfaces of their user-defined classes. This class is not intended to be directly used by programmers a part from declaring it friend (and that is why this class does not have any public member and it is not copyable).
Not declaring this class friend of user-defined classes will cause compiler errors on some compilers (e.g., MSVC) because the private members needed to check the contracts will not be accessible. On other compilers (e.g., GCC and CLang), the private access will instead fail SFINAE and no compiler error will be reported while invariants and subcontracting will be silently skipped at run-time. Therefore, programmers must make sure to either declare this class as friend (preferred) or to always declare invariant functions and base types typedef as public members.
See Also:
Access Specifiers

Header <boost/contract/core/check_macro.hpp>
Macros for implementation checks.


BOOST_CONTRACT_CHECK(cond)
BOOST_CONTRACT_CHECK_AUDIT(cond)
BOOST_CONTRACT_CHECK_AXIOM(cond)

BOOST_CONTRACT_CHECK
Preferred way to assert implementation check conditions.

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

BOOST_CONTRACT_CHECK(cond)

Description
It is preferred to use this macro instead of programming implementation checks in a nullary functor passed to boost::contract::check constructor because this macro will completely remove implementation checks from the code when BOOST_CONTRACT_NO_CHECKS is defined:

void f() {
    ...
    BOOST_CONTRACT_CHECK(...);
    ...
}

BOOST_CONTRACT_CHECK, BOOST_CONTRACT_CHECK_AUDIT, and BOOST_CONTRACT_CHECK_AXIOM are the three assertion levels predefined by this library for implementation checks.
See Also:
Implementation Checks
Parameters:	
cond	Boolean condition to check within implementation code (function body, etc.). (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_CHECK((cond)) will always work.)
BOOST_CONTRACT_CHECK_AUDIT
Preferred way to assert implementation check conditions that are computationally expensive, at least compared to the cost of executing the function body.

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

BOOST_CONTRACT_CHECK_AUDIT(cond)

Description
The specified condition will always be compiled and validated syntactically, but it will not be evaluated at run-time unless BOOST_CONTRACT_AUDITS is defined (undefined by default). This macro is defined by code equivalent to:

#ifdef BOOST_CONTRACT_AUDITS
    #define BOOST_CONTRACT_CHECK_AUDIT(cond) \
        BOOST_CONTRACT_CHECK(cond)
#else
    #define BOOST_CONTRACT_CHECK_AUDIT(cond) \
        BOOST_CONTRACT_CHECK(true || cond)
#endif

BOOST_CONTRACT_CHECK, BOOST_CONTRACT_CHECK_AUDIT, and BOOST_CONTRACT_CHECK_AXIOM are the three assertion levels predefined by this library for implementation checks. If there is a need, programmers are free to implement their own assertion levels defining macros similar to the one above.
See Also:
Assertion Levels
Parameters:	
cond	Boolean condition to check within implementation code (function body, etc.). (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_CHECK_AUDIT((cond)) will always work.)
BOOST_CONTRACT_CHECK_AXIOM
Preferred way to assert implementation check conditions that are computationally prohibitive, at least compared to the cost of executing the function body.

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

BOOST_CONTRACT_CHECK_AXIOM(cond)

Description
The specified condition will always be compiled and validated syntactically, but it will never be evaluated at run-time. This macro is defined by code equivalent to:

#define BOOST_CONTRACT_CHECK_AXIOM(cond) \
    BOOST_CONTRACT_CHECK(true || cond)

BOOST_CONTRACT_CHECK, BOOST_CONTRACT_CHECK_AUDIT, and BOOST_CONTRACT_CHECK_AXIOM are the three assertion levels predefined by this library for implementation checks. If there is a need, programmers are free to implement their own assertion levels defining macros similar to the one above.
See Also:
Assertion Levels
Parameters:	
cond	Boolean condition to check within implementation code (function body, etc.). (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_CHECK_AXIOM((cond)) will always work.)

Header <boost/contract/core/config.hpp>
Configure this library compile-time and run-time behaviours.


BOOST_CONTRACT_DYN_LINK
BOOST_CONTRACT_STATIC_LINK
BOOST_CONTRACT_HEADER_ONLY
BOOST_CONTRACT_DISABLE_THREADS
BOOST_CONTRACT_MAX_ARGS
BOOST_CONTRACT_BASES_TYPEDEF
BOOST_CONTRACT_INVARIANT_FUNC
BOOST_CONTRACT_STATIC_INVARIANT_FUNC
BOOST_CONTRACT_PERMISSIVE
BOOST_CONTRACT_ON_MISSING_CHECK_DECL
BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION
BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
BOOST_CONTRACT_AUDITS
BOOST_CONTRACT_NO_CHECKS
BOOST_CONTRACT_NO_PRECONDITIONS
BOOST_CONTRACT_NO_POSTCONDITIONS
BOOST_CONTRACT_NO_EXCEPTS
BOOST_CONTRACT_NO_ENTRY_INVARIANTS
BOOST_CONTRACT_NO_EXIT_INVARIANTS
BOOST_CONTRACT_NO_INVARIANTS
BOOST_CONTRACT_NO_OLDS
BOOST_CONTRACT_NO_CONSTRUCTORS
BOOST_CONTRACT_NO_DESTRUCTORS
BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
BOOST_CONTRACT_NO_FUNCTIONS
BOOST_CONTRACT_NO_CONDITIONS
BOOST_CONTRACT_NO_ALL

BOOST_CONTRACT_DYN_LINK
Define this macro to compile this library as a shared library (recommended).

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

BOOST_CONTRACT_DYN_LINK

Description
If this macro is defined, this library is compiled so it can be linked as a shared library (a.k.a., Dynamically Linked Library or DLL) to user code. Also, this library will automatically define this macro when Boost libraries are built as dynamic libraries (e.g., defining BOOST_ALL_DYN_LINK).
In general this library will correctly check contracts at run-time only when compiled as a shared library, unless user code checks contracts in a single program unit (e.g., a single program with only statically linked libraries that check contracts). Therefore, it is recommended to build and use this library as a dynamic library by defining this macro (or equivalently by building all Boost libraries as dynamic libraries and BOOST_ALL_DYN_LINK is defined).
See Also:
Compilers and Platforms
BOOST_CONTRACT_STATIC_LINK
Define this macro to compile this library as a static library (not recommended).

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

BOOST_CONTRACT_STATIC_LINK

Description
If this macro is defined, this library is compiled so it can be linked statically to user code. This library build scripts will automatically define this macro when Boost libraries are being built as static libraries.
This library is not guaranteed to always work correctly at run-time when this macro is defined (define BOOST_CONTRACT_DYN_LINK or BOOST_ALL_DYN_LINK instead). However, this macro can be defined and this library can be safely used as a static library for user code that checks contracts in a single program unit (e.g., a single program with only statically linked libraries that check contracts).
See Also:
Compilers and Platforms
BOOST_CONTRACT_HEADER_ONLY
Automatically defined by this library when it is being used as a header-only library (not recommended).

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

BOOST_CONTRACT_HEADER_ONLY

Description
This library will define this macro when users do not define BOOST_CONTRACT_DYN_LINK (or BOOST_ALL_DYN_LINK) and BOOST_CONTRACT_STATIC_LINK (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). When used as a header-only library, this library code does not have to be compiled separately from user code, this library headers are simply included and compiled as part of the user program.
This library is not guaranteed to always work correctly at run-time when this macro is defined (define BOOST_CONTRACT_DYN_LINK or BOOST_ALL_DYN_LINK instead). However, this macro can be defined and this library can be safely used as a header-only library for user code that checks contracts in a single program unit (e.g., a single program with only statically linked libraries that check contracts).
See Also:
Compilers and Platforms
BOOST_CONTRACT_DISABLE_THREADS
Define this macro to not lock internal library data for thread safety (undefined by default).

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

BOOST_CONTRACT_DISABLE_THREADS

Description
Defining this macro will make the library implementation code not thread safe so this macro should not be defined unless the library is being used by single-threaded applications only. This library will automatically define this macro when Boost libraries are built without threads (e.g., defining BOOST_DISABLE_THREADS).
When this macro is left undefined this library needs to internally use some sort of global lock (to ensure contract checking is globally disabled when other contracts are being checked and also to safely access failure handler functors). That could introduce an undesired amount of synchronization in some multi-threaded applications.
See Also:
Assertions
BOOST_CONTRACT_MAX_ARGS
Maximum number of arguments for public function overrides on compilers that do not support variadic templates (default to 10).

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

BOOST_CONTRACT_MAX_ARGS

Description
On compilers that do not support variadic templates, this macro is defined to the maximum number of arguments that public function overrides can have and pass to boost::contract::public_function (users can redefine this macro to a different value). On compilers that support variadic templates, this macro has no effect.
Regardless of the value of this macro and of compiler support for variadic templates, there is an intrinsic limit of about 18 arguments for public function overrides (because of similar limits in Boost.MPL and Boost.FunctionTypes internally used by this library).
See Also:
No Macros
BOOST_CONTRACT_BASES_TYPEDEF
Define the name of the base type typedef (base_types by default).

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

BOOST_CONTRACT_BASES_TYPEDEF

Description
This macro expands to the name of the typedef that lists the base classes for subcontracting via BOOST_CONTRACT_BASE_TYPES:

class u :
    #define BASES public b, private w
    BASES
{
    friend class boost::contract:access;

    typedef BOOST_CONTRACT_BASES(BASES) BOOST_CONTRACT_TYPEDEF;
    #undef BASES

    ...
};

Users can redefine this macro if the typedef must have a name different from base_types (because of name clashes in user code, etc.).
See Also:
Base Classes
BOOST_CONTRACT_INVARIANT_FUNC
Define the name of the class invariant member function (invariant by default).

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

BOOST_CONTRACT_INVARIANT_FUNC

Description
This macro expands to the name of the const and const volatile member functions that check class invariants and volatile class invariants respectively:

class u {
    friend class boost::contract::access;

    void BOOST_CONTRACT_INVARIANT_FUNC() const {
        BOOST_CONTRACT_ASSERT(...);
        ...
    }
    
    void BOOST_CONTRACT_INVARIANT_FUNC() const volatile {
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

    ...
};

Users can redefine this macro if the invariant functions must have a name different from invariant (because of name clashes in user code, etc.).
C++ does not allow to overload member functions based on the static classifier, so this macro must always be defined to be different than the function name defined for BOOST_CONTRACT_STATIC_INVARIANT_FUNC.
See Also:
Class Invariants, Volatile Public Functions
BOOST_CONTRACT_STATIC_INVARIANT_FUNC
Define the name of the static invariant member function (static_invariant by default).

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

BOOST_CONTRACT_STATIC_INVARIANT_FUNC

Description
This macro expands to the name of the static member function that checks static class invariants:

class u {
    friend class boost::contract::access;

    static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() {
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

    ...
};

Users can redefine this macro if the static invariant function must have a name different from static_invariant (because of name clashes in user code, etc.).
C++ does not allow to overload member functions based on the static classifier, so this macro must always be defined to be different than the function name defined for BOOST_CONTRACT_INVARIANT_FUNC.
See Also:
Class Invariants
BOOST_CONTRACT_PERMISSIVE
Disable some compile-time errors generated by this library (undefined by default).

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

BOOST_CONTRACT_PERMISSIVE

Description
Defining this macro disables a number of static checks and related compile-time errors generated by this library, for example:
The static invariant member BOOST_CONTRACT_STATIC_INVARIANT_FUNC function must be declared static.
Non-static invariant member functions BOOST_CONTRACT_INVARIANT_FUNC must be declared either const, const volatile, or volatile const.
Derived classes that program contracts for one or more public function overrides via boost::contract::public_function must also define the BOOST_CONTRACT_BASE_TYPES typedef.
In general, it is not recommended to define this macro because these compile-time checks can guard against misuses of this library.
See Also:
Class Invariants, Base Classes
BOOST_CONTRACT_ON_MISSING_CHECK_DECL
Code block to execute if contracts are not assigned to a boost::contract::check variable (undefined by default and executes BOOST_ASSERT(false)).

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

BOOST_CONTRACT_ON_MISSING_CHECK_DECL

Description
In general, there is a logic error in the program when contracts are not assigned to a local variable of type boost::contract::check (because that is a misuse of this library). Therefore, by default (i.e., when this macro is not defined) this library calls BOOST_ASSERT(false) in those cases. If this macro is defined, this library will execute the code expanded by the macro instead of calling BOOST_ASSERT(false) (if programmers prefer to throw an exception, etc.).
This macro can be defined to be any block of code (use empty curly brackets {} to generate no error), for example (on GCC):

-DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }'

See Also:
Tutorial
BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION
Define this macro to not disable other assertions while checking preconditions (undefined by default).

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

BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION

Description
Not disabling other assertions while checking preconditions can lead to infinite recursion in user code so by default this macro is not defined.
However, the [1962] proposal does not disable assertions while checking preconditions because arguments can reach the function body unchecked if assertions are disabled while checking preconditions (e.g., when these same functions bodies are called to check the preconditions in question). This macro can be defined to obtain the behaviour specified in [1962] (at the risk of infinite recursion).
See Also:
Feature Summary
BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
Define this macro to not disable any assertion while checking other assertions (undefined by default).

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

BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION

Description
Not disabling assertions while checking other assertions can lead to infinite recursion in user code so by default this macro is not defined. (Defining this macro automatically implies that other assertion checking is disabled while checking preconditions as if BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION was also defined.)
See Also:
Feature Summary
BOOST_CONTRACT_AUDITS
Define this macro to evaluate and check audit assertions at run-time (undefined by default).

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

BOOST_CONTRACT_AUDITS

Description
Audit assertions and implementation checks programmed via BOOST_CONTRACT_ASSERT_AUDIT and BOOST_CONTRACT_CHECK_AUDIT are always compiled and validated syntactically. However, they are not evaluated and checked at run-time unless this macro is defined (because these conditions can be computationally expensive, at least compared to the cost of executing the function body).
See Also:
Assertion Levels
BOOST_CONTRACT_NO_CHECKS
If defined, this library does not perform implementation checks (undefined by default).

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

BOOST_CONTRACT_NO_CHECKS

Description
If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with implementation checks. Users can manually program #ifndef statements in their code using this macro to completely disable compilation of implementation checks or use BOOST_CONTRACT_CHECK (recommended).
See Also:
Implementation Checks, Disable Contract Checking, Disable Contract Compilation
BOOST_CONTRACT_NO_PRECONDITIONS
If defined, this library does not check preconditions (undefined by default).

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

BOOST_CONTRACT_NO_PRECONDITIONS

Description
If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking preconditions. Users can manually program #ifndef statements in their code using this macro to completely disable compilation of preconditions or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
See Also:
Preconditions, Disable Contract Checking, Disable Contract Compilation
BOOST_CONTRACT_NO_POSTCONDITIONS
If defined, this library does not check postconditions (undefined by default).

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

BOOST_CONTRACT_NO_POSTCONDITIONS

Description
If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking postconditions. Users can manually program #ifndef statements in their code using this macro to completely disable compilation of postconditions or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
It is necessary to disable both postconditions and exception guarantees defining BOOST_CONTRACT_NO_POSTCONDITIONS and BOOST_CONTRACT_NO_EXCEPTS in order to disable old value copies (see BOOST_CONTRACT_NO_OLDS).
See Also:
Postconditions, Disable Contract Checking, Disable Contract Compilation
BOOST_CONTRACT_NO_EXCEPTS
If defined, this library does not check exception guarantees (undefined by default).

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

BOOST_CONTRACT_NO_EXCEPTS

Description
If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking exception guarantees. Users can manually program #ifndef statements in their code using this macro to completely disable compilation of exception guarantees or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
It is necessary to disable both postconditions and exception guarantees defining BOOST_CONTRACT_NO_POSTCONDITIONS and BOOST_CONTRACT_NO_EXCEPTS in order to disable old value copies (see BOOST_CONTRACT_NO_OLDS).
See Also:
Exception Guarantees, Disable Contract Checking, Disable Contract Compilation
BOOST_CONTRACT_NO_ENTRY_INVARIANTS
If defined, this library does not check class invariants at entry (undefined by default).

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

BOOST_CONTRACT_NO_ENTRY_INVARIANTS

Description
If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking class invariants at entry. Users can manually program #ifndef statements in their code using this macro to completely disable compilation of entry class invariants or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
This macro is automatically defined when BOOST_CONTRACT_NO_INVARIANTS is defined.
See Also:
Class Invariants, Disable Contract Checking, Disable Contract Compilation
BOOST_CONTRACT_NO_EXIT_INVARIANTS
If defined, this library does not check class invariants at exit (undefined by default).

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

BOOST_CONTRACT_NO_EXIT_INVARIANTS

Description
If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking class invariants at exit. Users can manually program #ifndef statements in their code using this macro to completely disable compilation of exit class invariants or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
This macro is automatically defined when BOOST_CONTRACT_NO_INVARIANTS is defined.
See Also:
Class Invariants, Disable Contract Checking, Disable Contract Compilation
BOOST_CONTRACT_NO_INVARIANTS
If defined, this library does not check class invariants (undefined by default).

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

BOOST_CONTRACT_NO_INVARIANTS

Description
If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking class invariants. Users can manually program #ifndef statements in their code using this macro to completely disable compilation of class invariants or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
Defining this macro is equivalent to defining both BOOST_CONTRACT_NO_ENTRY_INVARIANTS and BOOST_CONTRACT_NO_EXIT_INVARIANTS.
See Also:
Class Invariants, Disable Contract Checking, Disable Contract Compilation
BOOST_CONTRACT_NO_OLDS
Automatically defined by this library when old value copies are not to be performed.

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

BOOST_CONTRACT_NO_OLDS

Description
This library will define this macro when users define both BOOST_CONTRACT_NO_POSTCONDITIONS and BOOST_CONTRACT_NO_EXCEPTS (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). Users can manually program #ifndef statements in their code using this macro to completely disable compilation of old value copies or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
See Also:
Old Values, Old Value Copies at Body, Disable Contract Compilation
BOOST_CONTRACT_NO_CONSTRUCTORS
Automatically defined by this library when contracts are not checked for constructors.

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

BOOST_CONTRACT_NO_CONSTRUCTORS

Description
This library will define this macro when users define all BOOST_CONTRACT_NO_INVARIANTS, BOOST_CONTRACT_NO_POSTCONDITIONS, and BOOST_CONTRACT_NO_EXCEPTS (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). Users can manually program #ifndef statements in their code using this macro to completely disable compilation of contracts for constructors or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
Constructor preconditions are checked separately by boost::contract::constructor_precondition so they are disabled by BOOST_CONTRACT_NO_PRECONDITIONS instead.
See Also:
Constructors, Disable Contract Compilation
BOOST_CONTRACT_NO_DESTRUCTORS
Automatically defined by this library when contracts are not checked for destructors.

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

BOOST_CONTRACT_NO_DESTRUCTORS

Description
This library will define this macro when users define all BOOST_CONTRACT_NO_INVARIANTS, BOOST_CONTRACT_NO_POSTCONDITIONS, and BOOST_CONTRACT_NO_EXCEPTS (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). Users can manually program #ifndef statements in their code using this macro to completely disable compilation of contracts for destructors or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
See Also:
Destructors, Disable Contract Compilation
BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
Automatically defined by this library when contracts are not checked for public functions.

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

BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS

Description
This library will define this macro when users define all BOOST_CONTRACT_NO_INVARIANTS, BOOST_CONTRACT_NO_PRECONDITIONS, BOOST_CONTRACT_NO_POSTCONDITIONS, and BOOST_CONTRACT_NO_EXCEPTS (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). Users can manually program #ifndef statements in their code using this macro to completely disable compilation of contracts for public functions or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
See Also:
Public Functions, Disable Contract Compilation
BOOST_CONTRACT_NO_FUNCTIONS
Automatically defined by this library when contracts are not checked for non-member, private and protected functions.

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

BOOST_CONTRACT_NO_FUNCTIONS

Description
This library will define this macro when users define all BOOST_CONTRACT_NO_PRECONDITIONS, BOOST_CONTRACT_NO_POSTCONDITIONS, and BOOST_CONTRACT_NO_EXCEPTS (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). Users can manually program #ifndef statements in their code using this macro to completely disable compilation of contracts for non-member, private and protected functions, or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
This macro is also used when contracts are not checked for private and protected functions, lambda functions, code blocks, loops, etc.
See Also:
Non-Member Functions, Private and Protected Functions, Lambdas, Loops, Code Blocks, Disable Contract Compilation
BOOST_CONTRACT_NO_CONDITIONS
Automatically defined by this library when contracts are not checked for preconditions, postconditions, exceptions guarantees, and class invariants (excluding implementation checks).

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

BOOST_CONTRACT_NO_CONDITIONS

Description
This library will define this macro when users define all BOOST_CONTRACT_NO_PRECONDITIONS, BOOST_CONTRACT_NO_POSTCONDITIONS, BOOST_CONTRACT_NO_EXCEPTS, and BOOST_CONTRACT_NO_INVARIANTS (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). Users can manually program #ifndef statements in their code using this macro to completely disable compilation of contracts within specifications or use the macros defined in boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
See Also:
Disable Contract Compilation
BOOST_CONTRACT_NO_ALL
Automatically defined by this library when contracts are not checked at all.

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

BOOST_CONTRACT_NO_ALL

Description
This library will define this macro when users define all BOOST_CONTRACT_NO_INVARIANTS, BOOST_CONTRACT_NO_PRECONDITIONS, BOOST_CONTRACT_NO_POSTCONDITIONS, BOOST_CONTRACT_NO_EXCEPTS, and BOOST_CONTRACT_NO_CHECKS (this macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly). For example, users can manually program #ifndef statements in their code using this macro to avoid including the boost/contract.hpp header all together:

#include <boost/contract/core/config.hpp>
#ifndef BOOST_CONTRACT_NO_ALL
    #include <boost/contract.hpp>
#endif

Or, use the boost/contract_macro.hpp header and related macros instead (because the boost/contract_macro.hpp header is already optimized to not include other headers from this library when contracts are not checked, but recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).
See Also:
Disable Contract Compilation

Header <boost/contract/core/constructor_precondition.hpp>
Program preconditions for constructors.

namespace boost {
  namespace contract {
    template<typename Class> class constructor_precondition;
  }
}

boost::contract::constructor_precondition
Program preconditions for constructors.

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

template<typename Class> 
class constructor_precondition {
public:
  // construct/copy/destruct
  constructor_precondition();
  template<typename F> explicit constructor_precondition(F const &);
};

Description
This class must be the very first base of the class declaring the constructor for which preconditions are programmed (that way constructor arguments can be checked by preconditions even before they are used to initialize other base classes):

class u
    #define BASES private boost::contract::constructor_precondition<u>, \
            public b
    : BASES
{
    ...
    #undef BASES

public:
    explicit u(unsigned x) :
        boost::contract::constructor_precondition<u>([&] {
            BOOST_CONTRACT_ASSERT(x != 0);
            ...
        }),
        b(1.0 / float(x))
    {
        ...
    }

    ...
};

User-defined classes should inherit privately from this class (to not alter the public interface of user-defined classes). In addition, this class should never be declared as a virtual base (because virtual bases are initialized only once across the entire inheritance hierarchy preventing preconditions of other base classes from being checked).
Unions cannot have base classes in C++ so this class can be used to declare a local object within the constructor definition just before boost::contract::constructor is used (see Unions).
See Also:
Constructors

Template Parameters

typename Class

The class type of the constructor for which preconditions are being programmed.

constructor_precondition public construct/copy/destruct

constructor_precondition();

Construct this object without specifying constructor preconditions.
This is implicitly called for those constructors of the contracted class that do not specify preconditions.
Calling this default constructor should amount to negligible compile-time and run-time overheads (likely to be optimized away completely by most compilers).

template<typename F> explicit constructor_precondition(F const & f);

Construct this object specifying constructor preconditions.
Parameters:	
f	Nullary functor called by this library to check constructor preconditions f(). Assertions within this functor call are usually programmed using BOOST_CONTRACT_ASSERT, but any exception thrown by a call to this functor indicates a contract failure (and will result in this library calling boost::contract::precondition_failure). This functor should capture variables by (constant) value, or better by (constant) reference to avoid extra copies.

Header <boost/contract/core/exception.hpp>
Handle contract assertion failures.

namespace boost {
  namespace contract {
    class assertion_failure;
    class bad_virtual_result_cast;
    class exception;

    enum from;
    typedef boost::function< void(from)> from_failure_handler;
    typedef boost::function< void()> failure_handler;
    failure_handler const  & set_check_failure(failure_handler const &);
    failure_handler get_check_failure();
    void check_failure();
    from_failure_handler const  & 
    set_precondition_failure(from_failure_handler const &);
    from_failure_handler get_precondition_failure();
    void precondition_failure(from);
    from_failure_handler const  & 
    set_postcondition_failure(from_failure_handler const &);
    from_failure_handler get_postcondition_failure();
    void postcondition_failure(from);
    from_failure_handler const  & 
    set_except_failure(from_failure_handler const &);
    from_failure_handler get_except_failure();
    void except_failure(from);
    from_failure_handler const  & 
    set_old_failure(from_failure_handler const &);
    from_failure_handler get_old_failure();
    void old_failure(from);
    from_failure_handler const  & 
    set_entry_invariant_failure(from_failure_handler const &);
    from_failure_handler get_entry_invariant_failure();
    void entry_invariant_failure(from);
    from_failure_handler const  & 
    set_exit_invariant_failure(from_failure_handler const &);
    from_failure_handler get_exit_invariant_failure();
    void exit_invariant_failure(from);
    from_failure_handler const  & 
    set_invariant_failure(from_failure_handler const &);
  }
}

boost::contract::assertion_failure
Exception typically used to report a contract assertion failure.

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


class assertion_failure :
  public std::exception, public boost::contract::exception
{
public:
  // construct/copy/destruct
  explicit assertion_failure(char const * = "", unsigned long = 0, 
                             char const * = "");
  explicit assertion_failure(char const *);
  ~assertion_failure();

  // public member functions
  virtual char const  * what() const;
  char const  * file() const;
  unsigned long line() const;
  char const  * code() const;
};

Description
This exception is thrown by code expanded by BOOST_CONTRACT_ASSERT (but it can also be thrown by user code programmed manually without that macro). This exception is typically used to report contract assertion failures because it contains detailed information about the file name, line number, and source code of the asserted condition (so it can be used by this library to provide detailed error messages). However, any other exception can be used to report a contract assertion failure (including user-defined exceptions).
This library will call the appropriate contract failure handler function ( boost::contract::precondition_failure, etc.) when this or any other exception is thrown while checking contracts (by default, these failure handler functions print an error message to std::cerr and terminate the program, but they can be customized to take any other action).
See Also:
Throw on Failure, No Macros

assertion_failure public construct/copy/destruct

explicit assertion_failure(char const * file = "", unsigned long line = 0, 
                           char const * code = "");

Construct this object with file name, line number, and source code text of an assertion condition (all optional).
This constructor can also be used to specify no information (default constructor), or to specify only file name and line number but not source code text (because of the parameter default values).
Parameters:	
code	Text listing the source code of the assertion condition.
file	Name of the file containing the assertion (usually set using __FILE__).
line	Number of the line containing the assertion (usually set using __LINE__).

explicit assertion_failure(char const * code);

Construct this object only with the source code text of the assertion condition.
Parameters:	
code	Text listing the source code of the assertion condition.

~assertion_failure();

Destruct this object.
Throws: This is declared noexcept (or throw() before C++11).

assertion_failure public member functions

virtual char const  * what() const;

String describing the failed assertion.
Throws: This is declared noexcept (or throw() before C++11).
Returns:	A string formatted similarly to the following: assertion "`code()`" failed: file "`file()`", line `line()`. File, line, and code will be omitted from this string if they were not specified when constructing this object.

char const  * file() const;

Name of the file containing the assertion.
Returns:	File name as specified at construction (or "" if no file was specified).

unsigned long line() const;

Number of the line containing the assertion.
Returns:	Line number as specified at construction (or 0 if no line number was specified).

char const  * code() const;

Text listing the source code of the assertion condition.
Returns:	Assertion condition source code as specified at construction (or "" if no source code text was specified).
boost::contract::bad_virtual_result_cast
Exception thrown when inconsistent return values are passed to overridden virtual public functions.

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


class bad_virtual_result_cast :
  public std::bad_cast, public boost::contract::exception
{
public:
  // construct/copy/destruct
  explicit bad_virtual_result_cast(char const *, char const *);
  ~bad_virtual_result_cast();

  // public member functions
  virtual char const  * what() const;
};

Description
This exception is internally thrown by this library when programmers specify return values for public function overrides in derived classes that are not consistent with the return types of the virtual public functions being overridden in the base classes. This allows this library to give more descriptive error messages in such cases.
See Also:
Public Function Overrides

bad_virtual_result_cast public construct/copy/destruct

explicit bad_virtual_result_cast(char const * from_type_name, 
                                 char const * to_type_name);

Construct this object with the name of the from- and to- result types.
Parameters:	
from_type_name	Name of the from-type (source of the cast).
to_type_name	Name of the to-type (destination of the cast).

~bad_virtual_result_cast();

Destruct this object.
Throws: This is declared noexcept (or throw() before C++11).

bad_virtual_result_cast public member functions

virtual char const  * what() const;

Description for this error (containing both from- and to- type names).
Throws: This is declared noexcept (or throw() before C++11).
boost::contract::exception
Public base class for all exceptions directly thrown by this library.

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


class exception {
public:
  // construct/copy/destruct
  ~exception();
};

Description
This class does not inherit from std::exception because exceptions deriving from this class will do that (inheriting from std::exception, std::bad_cast, etc.).
See Also:
boost::contract::assertion_failure, boost::contract::bad_virtual_result_cast, etc.

exception public construct/copy/destruct

~exception();

Destruct this object.
Throws: This is declared noexcept (or throw() before C++11).
boost::contract::from
Indicate the kind of operation where the contract assertion failed.

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



enum from { from_constructor, from_destructor, from_function };

Description
This is passed as a parameter to the assertion failure handler functions. For example, it might be necessary to know in which operation an assertion failed to make sure exceptions are never thrown from destructors, not even when contract failure handlers are programmed by users to throw exceptions instead of terminating the program.
See Also:
Throw on Failure
from_constructor	Assertion failed when checking contracts for constructors.
from_destructor	Assertion failed when checking contracts for destructors .
from_function	Assertion failed when checking contracts for functions (members or not).
from_failure_handler
Type of assertion failure handler functions (with from parameter).

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


typedef boost::function< void(from)> from_failure_handler;

Description
Assertion failure handler functions specified by this type must be functors returning void and taking a single parameter of type boost::contract::from. For example, this is used to specify contract failure handlers for class invariants, preconditions, postconditions, and exception guarantees.
See Also:
Throw on Failure
failure_handler
Type of assertion failure handler functions (without from parameter).

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


typedef boost::function< void()> failure_handler;

Description
Assertion failure handler functions specified by this type must be nullary functors returning void. For example, this is used to specify contract failure handlers for implementation checks.
See Also:
Throw on Failure
boost::contract::set_check_failure
Set failure handler for implementation checks.

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


failure_handler const  & set_check_failure(failure_handler const & f);

Description
Set a new failure handler and returns it.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Implementation Checks
Parameters:	
f	New failure handler functor to set.
Returns:	Same failure handler functor f passed as parameter (e.g., for concatenating function calls).
boost::contract::get_check_failure
Return failure handler currently set for implementation checks.

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


failure_handler get_check_failure();

Description
This is often called only internally by this library.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Implementation Checks
Returns:	A copy of the failure handler currently set.
boost::contract::check_failure
Call failure handler for implementation checks.

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


void check_failure();

Description
This is often called only internally by this library.
Throws: This can throw in case programmers specify a failure handler that throws exceptions on implementation check failures (not the default).
See Also:
Throw on Failure, Implementation Checks
boost::contract::set_precondition_failure
Set failure handler for preconditions.

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


from_failure_handler const  & 
set_precondition_failure(from_failure_handler const & f);

Description
Set a new failure handler and returns it.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Preconditions
Parameters:	
f	New failure handler functor to set.
Returns:	Same failure handler functor f passed as parameter (e.g., for concatenating function calls).
boost::contract::get_precondition_failure
Return failure handler currently set for preconditions.

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


from_failure_handler get_precondition_failure();

Description
This is often called only internally by this library.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Preconditions
Returns:	A copy of the failure handler currently set.
boost::contract::precondition_failure
Call failure handler for preconditions.

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


void precondition_failure(from where);

Description
This is often called only internally by this library.
Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).
See Also:
Throw on Failure, Preconditions
Parameters:	
where	Operation that failed the contract assertion (when this function is called by this library, this parameter will never be from_destructor because destructors do not have preconditions).
boost::contract::set_postcondition_failure
Set failure handler for postconditions.

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


from_failure_handler const  & 
set_postcondition_failure(from_failure_handler const & f);

Description
Set a new failure handler and returns it.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Postconditions
Parameters:	
f	New failure handler functor to set.
Returns:	Same failure handler functor f passed as parameter (e.g., fr concatenating function calls).
boost::contract::get_postcondition_failure
Return failure handler currently set for postconditions.

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


from_failure_handler get_postcondition_failure();

Description
This is often called only internally by this library.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Postconditions
Returns:	A copy of the failure handler currently set.
boost::contract::postcondition_failure
Call failure handler for postconditions.

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


void postcondition_failure(from where);

Description
This is often called only internally by this library.
Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).
See Also:
Throw on Failure, Postconditions
Parameters:	
where	Operation that failed the contract assertion (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program).
boost::contract::set_except_failure
Set failure handler for exception guarantees.

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


from_failure_handler const  & 
set_except_failure(from_failure_handler const & f);

Description
Set a new failure handler and returns it.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Exception Guarantees
Parameters:	
f	New failure handler functor to set.
Returns:	Same failure handler functor f passed as parameter (e.g., for concatenating function calls).
boost::contract::get_except_failure
Return failure handler currently set for exception guarantees.

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


from_failure_handler get_except_failure();

Description
This is often called only internally by this library.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Exception Guarantees
Returns:	A copy of the failure handler currently set.
boost::contract::except_failure
Call failure handler for exception guarantees.

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


void except_failure(from where);

Description
This is often called only internally by this library.
Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default), however:
When this failure handler is called there is already an active exception (the one that caused the exception guarantees to be checked in the first place). Therefore, programming this failure handler to throw yet another exception will force C++ to automatically terminate the program.
See Also:
Throw on Failure, Exception Guarantees
Parameters:	
where	Operation that failed the contract assertion.
boost::contract::set_old_failure
Set failure handler for old value copies at body.

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


from_failure_handler const  & set_old_failure(from_failure_handler const & f);

Description
Set a new failure handler and returns it.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Old Value Copies at Body
Parameters:	
f	New failure handler functor to set.
Returns:	Same failure handler functor f passed as parameter (e.g., for concatenating function calls).
boost::contract::get_old_failure
Return failure handler currently set for old value copies at body.

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


from_failure_handler get_old_failure();

Description
This is often called only internally by this library.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Old Value Copies at Body
Returns:	A copy of the failure handler currently set.
boost::contract::old_failure
Call failure handler for old value copies at body.

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


void old_failure(from where);

Description
This is often called only internally by this library.
Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).
See Also:
Throw on Failure, Old Value Copies at Body
Parameters:	
where	Operation that failed the old value copy (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program).
boost::contract::set_entry_invariant_failure
Set failure handler for class invariants at entry.

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


from_failure_handler const  & 
set_entry_invariant_failure(from_failure_handler const & f);

Description
Set a new failure handler and returns it.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Class Invariants, Volatile Public Functions
Parameters:	
f	New failure handler functor to set.
Returns:	Same failure handler functor f passed as parameter (e.g., for concatenating function calls).
boost::contract::get_entry_invariant_failure
Return failure handler currently set for class invariants at entry.

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


from_failure_handler get_entry_invariant_failure();

Description
This is often called only internally by this library.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Class Invariants, Volatile Public Functions
Returns:	A copy of the failure handler currently set.
boost::contract::entry_invariant_failure
Call failure handler for class invariants at entry.

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


void entry_invariant_failure(from where);

Description
This is often called only internally by this library.
Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).
See Also:
Throw on Failure, Class Invariants, Volatile Public Functions
Parameters:	
where	Operation that failed the contract assertion (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program).
boost::contract::set_exit_invariant_failure
Set failure handler for class invariants at exit.

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


from_failure_handler const  & 
set_exit_invariant_failure(from_failure_handler const & f);

Description
Set a new failure handler and returns it.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Class Invariants, Volatile Public Functions
Parameters:	
f	New failure handler functor to set.
Returns:	Same failure handler functor f passed as parameter (e.g., for concatenating function calls).
boost::contract::get_exit_invariant_failure
Return failure handler currently set for class invariants at exit.

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


from_failure_handler get_exit_invariant_failure();

Description
This is often called only internally by this library.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Class Invariants, Volatile Public Functions
Returns:	A copy of the failure handler currently set.
boost::contract::exit_invariant_failure
Call failure handler for class invariants at exit.

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


void exit_invariant_failure(from where);

Description
This is often called only internally by this library.
Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).
See Also:
Throw on Failure, Class Invariants, Volatile Public Functions
Parameters:	
where	Operation that failed the contract assertion (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program).
boost::contract::set_invariant_failure
Set failure handler for class invariants (at both entry and exit).

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


from_failure_handler const  & 
set_invariant_failure(from_failure_handler const & f);

Description
This is provided for convenience and it is equivalent to call both boost::contract::set_entry_invariant_failure and boost::contract::set_exit_invariant_failure with the same functor parameter f.
Throws: This is declared noexcept (or throw() before C++11).
See Also:
Throw on Failure, Class Invariants, Volatile Public Functions
Parameters:	
f	New failure handler functor to set for both entry and exit invariants.
Returns:	Same failure handler functor f passed as parameter (e.g., for concatenating function calls).

Header <boost/contract/core/specify.hpp>
Specify preconditions, old value copies at body, postconditions, and exception guarantees.
Preconditions, old value copies at body, postconditions, and exception guarantees are all optionals but, when they are specified, they need to be specified in that order.

namespace boost {
  namespace contract {
    class specify_except;
    class specify_nothing;
    template<typename VirtualResult = void> 
      class specify_old_postcondition_except;
    template<typename VirtualResult = void> class specify_postcondition_except;
    template<typename VirtualResult = void> 
      class specify_precondition_old_postcondition_except;
  }
}

boost::contract::specify_except
Allow to specify exception guarantees.

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


class specify_except {
public:
  // construct/copy/destruct
  ~specify_except();

  // public member functions
  template<typename F> specify_nothing except(F const &);
};

Description
Allow to specify the functor this library will call to 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:
Exception Guarantees

specify_except public construct/copy/destruct

~specify_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_except public member functions

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.
boost::contract::specify_nothing
Used to prevent setting other contract conditions after exception guarantees.

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


class specify_nothing {
public:
  // construct/copy/destruct
  ~specify_nothing();
};

Description
This class has no member function so it is used to prevent specifying additional functors to check any other contract. 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:
Tutorial

specify_nothing public construct/copy/destruct

~specify_nothing();

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.)
boost::contract::specify_old_postcondition_except
Allow to specify old value copies at body, postconditions, and exception guarantees.

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

template<typename VirtualResult = void> 
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

Template Parameters

typename VirtualResult = void

Return type of the enclosing function declaring the contract if that function is either a virtual public function or a public function override. Otherwise, this type is always void.

specify_old_postcondition_except public construct/copy/destruct

~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

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.

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.

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.
boost::contract::specify_postcondition_except
Allow to specify postconditions or exception guarantees.

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

template<typename VirtualResult = void> 
class specify_postcondition_except {
public:
  // construct/copy/destruct
  ~specify_postcondition_except();

  // public member functions
  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 check postconditions or 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:
Postconditions, Exception Guarantees

Template Parameters

typename VirtualResult = void

Return type of the enclosing function declaring the contract if that function is either a virtual public function or a public function override. Otherwise, this type is always void.

specify_postcondition_except public construct/copy/destruct

~specify_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_postcondition_except public member functions

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.

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.
boost::contract::specify_precondition_old_postcondition_except
Allow to specify preconditions, old value copies at body, postconditions, and exception guarantees.

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

template<typename VirtualResult = void> 
class specify_precondition_old_postcondition_except {
public:
  // construct/copy/destruct
  ~specify_precondition_old_postcondition_except();

  // public member functions
  template<typename F> 
    specify_old_postcondition_except< VirtualResult > precondition(F const &);
  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 check preconditions, copy old values 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:
Preconditions, Old Value Copies at Body, Postconditions, Exception Guarantees

Template Parameters

typename VirtualResult = void

Return type of the enclosing function declaring the contract if that function is either a virtual public function or a public function override. Otherwise, this type is always void.

specify_precondition_old_postcondition_except public construct/copy/destruct

~specify_precondition_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_precondition_old_postcondition_except public member functions

template<typename F> 
  specify_old_postcondition_except< VirtualResult > precondition(F const & f);

Allow to specify preconditions.
Parameters:	
f	Nullary functor called by this library to check preconditions 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::precondition_failure). This functor should capture variables by (constant) value, or better by (constant) reference (to avoid extra copies).
Returns:	After preconditions have been specified, the object returned by this function allows to optionally specify old value copies at body, postconditions, and exception guarantees.

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 functions allows to optionally specify postconditions and exception guarantees.

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.

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.

Header <boost/contract/core/virtual.hpp>
Handle virtual public functions with contracts (for subcontracting).

namespace boost {
  namespace contract {
    class virtual_;
  }
}

boost::contract::virtual_
Type of extra function parameter to handle contracts for virtual public functions (for subcontracting).

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


class virtual_ {
};

Description
Virtual public functions (and therefore also public function overrides) declaring contracts using this library must specify an extra function parameter at the very end of the parameter list. This parameter must be a pointer to this class and it must have default value 0 (i.e., nullptr). (This extra parameter is often named v in this documentation, but any name can be used.)
In practice this extra parameter does not alter the calling interface of the enclosing function declaring the contract because it is always the very last parameter and it has a default value (so it can always be omitted when users call the function). This extra parameter must be passed to boost::contract::public_function, BOOST_CONTRACT_OLDOF, and all other operations of this library that accept a pointer to boost::contract::virtual_. A part from that, this class is not intended to be directly used by programmers (and that is why this class does not have any public member and it is not copyable).
See Also:
Virtual Public Functions, Public Function Overrides

Header <boost/contract/destructor.hpp>
Program contracts for destructors.

namespace boost {
  namespace contract {
    template<typename Class> 
      specify_old_postcondition_except destructor(Class *);
  }
}

boost::contract::destructor
Program contracts for destructors.

// In header: <boost/contract/destructor.hpp>


template<typename Class> 
  specify_old_postcondition_except destructor(Class * obj);

Description
This is used to specify postconditions, exception guarantees, old value copies at body, and check class invariants for destructors (destructors cannot not have preconditions, see Destructor Calls):

class u {
    friend class boost::contract::access;

    void invariant() const { // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

public:
    ~u() {
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::destructor(this)
            // No `.precondition` (destructors have no preconditions).
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_expr);
                ...
            })
            .postcondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Destructor body.
    }
    
    ...
};

For optimization, this can be omitted for destructors that do not have postconditions and exception guarantees, within classes that have no invariants.
See Also:
Destructors
Parameters:	
obj	The object this from the scope of the enclosing destructor declaring the contract. (Destructors check all class invariants, including static and volatile invariants, see Class Invariants and Volatile Public Functions).
Template Parameters:	
Class	The type of the class containing the destructor declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the destructor body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).

Header <boost/contract/function.hpp>
Program contracts for (non-public) functions.

namespace boost {
  namespace contract {
    specify_precondition_old_postcondition_except function();
  }
}

boost::contract::function
Program contracts for non-member, private and protected functions.

// In header: <boost/contract/function.hpp>


specify_precondition_old_postcondition_except function();

Description
This is used to specify preconditions, postconditions, exception guarantees, and old value copies at body for non-member, private and protected functions (these functions never check class invariants, see Function Calls):

void f(...) {
    boost::contract::old_ptr<old_type> old_var;
    boost::contract::check c = boost::contract::function()
        .precondition([&] { // Optional.
            BOOST_CONTRACT_ASSERT(...);
            ...
        })
        .old([&] { // Optional.
            old_var = BOOST_CONTRACT_OLDOF(old_expr);  
            ...
        })
        .postcondition([&] { // Optional.
            BOOST_CONTRACT_ASSERT(...);
            ...
        })
        .except([&] { // Optional.
            BOOST_CONTRACT_ASSERT(...);
            ...
        })
    ;

    ... // Function body.
}

This can be used also to program contracts in implementation code for lambda functions, loops, and arbitrary blocks of code. For optimization, this can be omitted for code that does not have preconditions, postconditions, and exception guarantees.
See Also:
Non-Member Functions, Private and Protected Functions, Lambdas, Loops, Code Blocks
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the function body code (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).

Header <boost/contract/old.hpp>
Handle old values.


BOOST_CONTRACT_OLDOF(...)

namespace boost {
  namespace contract {
    template<typename T> struct is_old_value_copyable;

    class old_pointer;
    template<typename T> class old_ptr;
    template<typename T> class old_ptr_if_copyable;
    class old_value;

    template<typename T> struct old_value_copy;
    old_value null_old();
    old_pointer make_old(old_value const &);
    old_pointer make_old(virtual_ *, old_value const &);
    bool copy_old();
    bool copy_old(virtual_ *);
  }
}

boost::contract::is_old_value_copyable
Trait to check if an old value type can be copied or not.

// In header: <boost/contract/old.hpp>

template<typename T> 
struct is_old_value_copyable : public boost::is_copy_constructible< T > {
};

Description
By default, this unary boolean meta-function is equivalent to boost::is_copy_constructible<T> but programmers can chose to specialize it for user-defined types (in general some kind of specialization is needed on compilers that do not support C++11, see boost::is_copy_constructible):

class u; // Some user-defined type.

namespace boost { namespace contract {
    template<> // Specialization.
    struct is_old_value_copyable<u> : boost::false_type {};
} } // namespace

In summary, a given old value type T is copied only if boost::contract::is_old_value_copyable<T>::value is true. Copyable old value types are always copied using boost::contract::old_value_copy<T>. Non-copyable old value types generate a compile-time error when boost::contract::old_ptr<T> is dereferenced, but instead leave boost::contract::old_ptr_if_copyable<T> always null (without generating compile-time errors).
See Also:
Old Value Requirements
boost::contract::old_pointer
Convert old value copies to old value pointers.

// In header: <boost/contract/old.hpp>


class old_pointer {
public:

  // public member functions
  template<typename T> operator old_ptr_if_copyable< T >();
  template<typename T> operator old_ptr< T >();
};

Description
This class is often only implicitly used by this library and it does not explicitly appear in user code (that is why this class does not have public constructors, etc.).

old_pointer public member functions

template<typename T> operator old_ptr_if_copyable< T >();

Convert this object to an actual old value pointer for which the old value type T might or not be copyable.
For example, this is implicitly called when assigning or initializing old value pointers.
Template Parameters:	
T	Type of the pointed old value. The old value pointer will always be null if this type is not copyable (see boost::contract::is_old_value_copyable), but this library will not generate a compile-time error.

template<typename T> operator old_ptr< T >();

Convert this object to an actual old value pointer for which the old value type T must be copyable.
For example, this is implicitly called when assigning or initializing old value pointers.
Template Parameters:	
T	Type of the pointed old value. This type must be copyable (see boost::contract::is_old_value_copyable), otherwise this library will generate a compile-time error when the old value pointer is dereferenced.
boost::contract::old_ptr
Old value pointer that requires the pointed old value type to be copyable.

// In header: <boost/contract/old.hpp>

template<typename T> 
class old_ptr {
public:
  // types
  typedef T element_type;  // Pointed old value type. 

  // construct/copy/destruct
  old_ptr();

  // public member functions
  T const  & operator *() const;
  T const  *const operator->() const;
  explicit operator bool() const;
};

Description
This is set to point to an actual old value copy using either BOOST_CONTRACT_OLDOF or boost::contract::make_old (that is why this class does not have public non-default constructors):

class u {
public:
    virtual void f(..., boost::contract::virtual_* v = 0) {
        boost::contract::old_ptr<old_type> old_var =
                BOOST_CONTRACT_OLDOF(v, old_expr);
        ...
    }

    ...
};

See Also:
Old Values

Template Parameters

typename T

Type of the pointed old value. This type must be copyable (i.e., boost::contract::is_old_value_copyable<T>::value is true), otherwise this pointer will always be null and this library will generate a compile-time error when the pointer is dereferenced.

old_ptr public construct/copy/destruct

old_ptr();

Construct this old value pointer as null.

old_ptr public member functions

T const  & operator *() const;

Dereference this old value pointer.
This will generate a run-time error if this pointer is null and a compile-time error if the pointed type T is not copyable (i.e., if boost::contract::is_old_value_copyable<T>::value is false).
Returns:	The pointed old value. Contract assertions should not change the state of the program so this member function is const and it returns the old value as a reference to a constant object (see Constant Correctness).

T const  *const operator->() const;

Structure-dereference this old value pointer.
This will generate a compile-time error if the pointed type T is not copyable (i.e., if boost::contract::is_old_value_copyable<T>::value is false).
Returns:	A pointer to the old value (null if this old value pointer is null). Contract assertions should not change the state of the program so this member function is const and it returns the old value as a constant pointer to a constant object (see Constant Correctness).

explicit operator bool() const;

Check if this old value pointer is null or not.
(This is implemented using safe-bool emulation on compilers that do not support C++11 explicit type conversion operators.)
Returns:	True if this pointer is not null, false otherwise.
boost::contract::old_ptr_if_copyable
Old value pointer that does not require the pointed old value type to be copyable.

// In header: <boost/contract/old.hpp>

template<typename T> 
class old_ptr_if_copyable {
public:
  // types
  typedef T element_type;  // Pointed old value type. 

  // construct/copy/destruct
  old_ptr_if_copyable();
  old_ptr_if_copyable(old_ptr< T > const &);

  // public member functions
  T const  & operator *() const;
  T const  *const operator->() const;
  explicit operator bool() const;
};

Description
This is set to point to an actual old value copy using either BOOST_CONTRACT_OLDOF or boost::contract::make_old:

template<typename T> // Type `T` might or not be copyable.
class u {
public:
    virtual void f(..., boost::contract::virtual_* v = 0) {
        boost::contract::old_ptr_if_copyable<T> old_var =
                BOOST_CONTRACT_OLDOF(v, old_expr);
        ...
            if(old_var) ... // Always null for non-copyable types.
        ...
    }

    ...
};

See Also:
Old Value Requirements

Template Parameters

typename T

Type of the pointed old value. If this type is not copyable (i.e., boost::contract::is_old_value_copyable<T>::value is false), this pointer will always be null (but this library will not generate a compile-time error when this pointer is dereferenced).

old_ptr_if_copyable public construct/copy/destruct

old_ptr_if_copyable();

Construct this old value pointer as null.

old_ptr_if_copyable(old_ptr< T > const & other);

Construct this old value pointer from an old value pointer that requires the old value type to be copyable.
This constructor is implicitly called by this library when assigning an object of this type using BOOST_CONTRACT_OLDOF (this constructor is usually not explicitly called by user code).
Parameters:	
other	Old value pointer that requires the old value type to be copyable.

old_ptr_if_copyable public member functions

T const  & operator *() const;

Dereference this old value pointer.
This will generate a run-time error if this pointer is null, but no compile-time error is generated if the pointed type T is not copyable (i.e., if boost::contract::is_old_value_copyable<T>::value is false).
Returns:	The pointed old value. Contract assertions should not change the state of the program so this member function is const and it returns the old value as a reference to a constant object (see Constant Correctness).

T const  *const operator->() const;

Structure-dereference this old value pointer.
This will return null but will not generate a compile-time error if the pointed type T is not copyable (i.e., if boost::contract::is_old_value_copyable<T>::value is false).
Returns:	A pointer to the old value (null if this old value pointer is null). Contract assertions should not change the state of the program so this member function is const and it returns the old value as a constant pointer to a constant object (see Constant Correctness).

explicit operator bool() const;

Check if this old value pointer is null or not (safe-bool operator).
(This is implemented using safe-bool emulation on compilers that do not support C++11 explicit type conversion operators.)
Returns:	True if this pointer is not null, false otherwise.
boost::contract::old_value
Convert user-specified expressions to old values.

// In header: <boost/contract/old.hpp>


class old_value {
public:
  // construct/copy/destruct
  template<typename T> 
    old_value(T const &, 
              typename boost::enable_if< boost::contract::is_old_value_copyable< T > >::type * = 0);
  template<typename T> 
    old_value(T const &, 
              typename boost::disable_if< boost::contract::is_old_value_copyable< T > >::type * = 0);
};

Description
This class is often only implicitly used by this library and it does not explicitly appear in user code.
On older compilers that cannot correctly deduce the boost::contract::is_old_value_copyable trait, programmers can manually specialize that trait to make sure that only old value types that are copyable are actually copied.
See Also:
Old Value Requirements

old_value public construct/copy/destruct

template<typename T> 
  old_value(T const & old, 
            typename boost::enable_if< boost::contract::is_old_value_copyable< T > >::type * = 0);

Construct this object from the specified old value when the old value type is copy constructible.
The specified old value is copied (one time only) using boost::contract::old_value_copy, in which case related old value pointer will not be null (no copy is made if postconditions and exception guarantees are not being checked, see BOOST_CONTRACT_NO_OLDS).
Parameters:	
old	Old value to be copied.
Template Parameters:	
T	Old value type.

template<typename T> 
  old_value(T const & old, 
            typename boost::disable_if< boost::contract::is_old_value_copyable< T > >::type * = 0);

Construct this object from the specified old value when the old value type is not copyable.
The specified old value cannot be copied in this case so it is not copied and the related old value pointer will always be null (thus a call to this constructor has no effect and it will likely be optimized away by most compilers).
Parameters:	
old	Old value (that will not be copied in this case).
Template Parameters:	
T	Old value type.
boost::contract::old_value_copy
Trait to copy an old value.

// In header: <boost/contract/old.hpp>

template<typename T> 
struct old_value_copy {
  // construct/copy/destruct
  explicit old_value_copy(T const &);

  // public member functions
  T const  & old() const;
};

Description
By default, the implementation of this trait uses T's copy constructor to make one single copy of the specified value. However, programmers can specialize this trait to copy old values using user-specific operations different from T's copy constructor. The default implementation of this trait is equivalent to:

template<typename T>
class old_value_copy {
public:
    explicit old_value_copy(T const& old) :
        old_(value) // One single copy of value using T's copy constructor.
    {}

    T const& old() const { return old_; }

private:
    T const old_; // The old value copy.
};

This library will instantiate and use this trait only on old value types T that are copyable (i.e., for which boost::contract::is_old_value_copyable<T>::value is true).
See Also:
Old Value Requirements

old_value_copy public construct/copy/destruct

explicit old_value_copy(T const & old);

Construct this object by making one single copy of the specified old value.
This is the only operation within this library that actually copies old values. This ensures this library makes one and only one copy of old values (if they actually need to be copied).
Parameters:	
old	The old value to copy.

old_value_copy public member functions

T const  & old() const;

Return a (constant) reference to the old value that was copied.
Contract assertions should not change the state of the program so the old value copy is returned as const (see Constant Correctness).
boost::contract::null_old
Return a null old value.

// In header: <boost/contract/old.hpp>


old_value null_old();

Description
The related old value pointer will also be null. This function is often only used by the code expanded by BOOST_CONTRACT_OLDOF.
See Also:
No Macros
Returns:	Null old value.
boost::contract::make_old
Make an old value pointer (but not for virtual public functions and public functions overrides).

// In header: <boost/contract/old.hpp>


old_pointer make_old(old_value const & old);

Description
The related old value pointer will not be null if the specified old value was actually copied. This function is often only used by code expanded by BOOST_CONTRACT_OLDOF(old_expr):

boost::contract::make_old(boost::contract::copy_old() ? old_expr :
        boost::contract::null_old())

See Also:
No Macros
Parameters:	
old	Old value which is usually implicitly constructed from the user old value expression to be copied (use the ternary operator ?: to avoid evaluating the old value expression all together when boost::contract::copy_old() is false).
Returns:	Old value pointer (usually implicitly converted to either boost::contract::old_ptr or boost::contract::old_ptr_if_copyable in user code).
boost::contract::make_old
Make an old value pointer (for virtual public functions and public functions overrides).

// In header: <boost/contract/old.hpp>


old_pointer make_old(virtual_ * v, old_value const & old);

Description
The related old value pointer will not be null if the specified old value was actually copied. This function is often only used by code expanded by BOOST_CONTRACT_OLDOF(v, old_expr):

boost::contract::make_old(v, boost::contract::copy_old(v) ? old_expr :
        boost::contract::null_old())

See Also:
No Macros
Parameters:	
old	Old value which is usually implicitly constructed from the user old value expression to be copied (use the ternary operator ?: to avoid evaluating the old value expression all together when boost::contract::copy_old(v) is false).
v	The trailing parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual or overriding public function declaring the contract.
Returns:	Old value pointer (usually implicitly converted to either boost::contract::old_ptr or boost::contract::old_ptr_if_copyable in user code).
boost::contract::copy_old
Check if old values need to be copied (but not for virtual public functions and public function overrides).

// In header: <boost/contract/old.hpp>


bool copy_old();

Description
For example, this function always returns false when both postconditions and exception guarantees are not being checked (see BOOST_CONTRACT_NO_OLDS). This function is often only used by the code expanded by BOOST_CONTRACT_OLDOF.
See Also:
No Macros
Returns:	True if old values need to be copied, false otherwise.
boost::contract::copy_old
Check if old values need to be copied (for virtual public functions and public function overrides).

// In header: <boost/contract/old.hpp>


bool copy_old(virtual_ * v);

Description
For example, this function always returns false when both postconditions and exception guarantees are not being checked (see BOOST_CONTRACT_NO_OLDS). In addition, this function returns false when overridden functions are being called subsequent times by this library to support subcontracting. This function is often only used by the code expanded by BOOST_CONTRACT_OLDOF.
See Also:
No Macros
Parameters:	
v	The trailing parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual or overriding public function declaring the contract.
Returns:	True if old values need to be copied, false otherwise.
BOOST_CONTRACT_OLDOF
Macro typically used to copy an old value expression and assign it to an old value pointer.

// In header: <boost/contract/old.hpp>

BOOST_CONTRACT_OLDOF(...)

Description
The expression expanded by this macro should be assigned to an old value pointer of type boost::contract::old_ptr or boost::contract::old_ptr_if_copyable. This is an overloaded variadic macro and it can be used in the following different ways.
1. From within virtual public functions and public functions overrides:

BOOST_CONTRACT_OLDOF(v, old_expr)

2. From all other operations:

BOOST_CONTRACT_OLDOF(old_expr)

Where:
v is the extra parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual public function or public function overrides declaring the contract.
old_expr is the expression to be evaluated and copied to the old value pointer. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_OLDOF(v, (old_expr)) will always work.)
On compilers that do not support variadic macros, programmers can manually copy old value expressions without using this macro (see No Macros).
See Also:
Old Values

Header <boost/contract/override.hpp>
Handle public function overrides (for subcontracting).


BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name)
BOOST_CONTRACT_OVERRIDE(func_name)
BOOST_CONTRACT_OVERRIDES(...)

BOOST_CONTRACT_NAMED_OVERRIDE
Declare an override type with an arbitrary name.

// In header: <boost/contract/override.hpp>

BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name)

Description
Declare the override type to pass as an explicit template parameter to boost::contract::public_function for public function overrides.
See Also:
Named Overrides
Parameters:	
func_name	Function name of the public function override. This macro is called just once even if the function name is overloaded (the same override type is used for all overloaded functions with the same name, see Function Overloads). (This is not a variadic macro parameter but it should never contain commas because it is an identifier.)
type_name	Name of the override type this macro will declare. (This is not a variadic macro parameter but it should never contain commas because it is an identifier.)
BOOST_CONTRACT_OVERRIDE
Declare an override type named override_func_name.

// In header: <boost/contract/override.hpp>

BOOST_CONTRACT_OVERRIDE(func_name)

Description
Declare the override type to pass as an explicit template parameter to boost::contract::public_function for public function overrides.
See Also:
Public Function Overrides
Parameters:	
func_name	Function name of the public function override. This macro is called just once even if the function name is overloaded (the same override type is used for all overloaded functions with the same name, see Function Overloads). (This is not a variadic macro parameter but it should never contain any comma because it is an identifier.)
BOOST_CONTRACT_OVERRIDES
Declare multiple override types at once naming them override_... (for convenience).

// In header: <boost/contract/override.hpp>

BOOST_CONTRACT_OVERRIDES(...)

Description
This variadic macro is provided for convenience only, BOOST_CONTRACT_OVERRIDES(f_1, f_2, ..., f_n) expands to code equivalent to:

BOOST_CONTRACT_OVERRIDE(f_1)
BOOST_CONTRACT_OVERRIDE(f_2)
...
BOOST_CONTRACT_OVERRIDE(f_n)

On compilers that do not support variadic macros, the override types can be equivalently programmed one-by-one calling BOOST_CONTRACT_OVERRIDE for each function name as shown above.
See Also:
Public Function Overrides
Parameters:	
...	A comma separated list of one or more function names of public function overrides. (Each function name should never contain commas because it is an identifier.)

Header <boost/contract/public_function.hpp>
Program contracts for public functions (including subcontracting).
Overloads handle public functions that are static, virtual void, virtual non-void, overriding void, and overriding non-void.

namespace boost {
  namespace contract {
    template<typename Class> 
      specify_precondition_old_postcondition_except public_function();
    template<typename Class> 
      specify_precondition_old_postcondition_except public_function(Class *);
    template<typename Class> 
      specify_precondition_old_postcondition_except 
      public_function(virtual_ *, Class *);
    template<typename VirtualResult, typename Class> 
      specify_precondition_old_postcondition_except< VirtualResult > 
      public_function(virtual_ *, VirtualResult &, Class *);
    template<typename Override, typename F, typename Class, typename... Args> 
      specify_precondition_old_postcondition_except 
      public_function(virtual_ *, F, Class *, Args &...);
    template<typename Override, typename VirtualResult, typename F, 
             typename Class, typename... Args> 
      specify_precondition_old_postcondition_except< VirtualResult > 
      public_function(virtual_ *, VirtualResult &, F, Class *, Args &...);
  }
}

boost::contract::public_function
Program contracts for static public functions.

// In header: <boost/contract/public_function.hpp>


template<typename Class> 
  specify_precondition_old_postcondition_except public_function();

Description
This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check static class invariants for static public functions:

class u {
    friend class boost::contract::access;

    static void static_invariant() { // Optional (as for non-static).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

public:
    static void f(...) {
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::public_function<u>()
            .precondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_expr);
                ...
            })
            .postcondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body.
    }
    
    ...
};

For optimization, this can be omitted for static public functions that do not have preconditions, postconditions and exception guarantees, within classes that have no static invariants.
See Also:
Static Public Functions
Template Parameters:	
Class	The type of the class containing the static public function declaring the contract. This template parameter must be explicitly specified for static public functions (because they have no object this so there is no function argument from which this type template parameter can be deduced by this library).
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the static function body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).
boost::contract::public_function
Program contracts for public functions that are not static, not virtual, and do not not override.

// In header: <boost/contract/public_function.hpp>


template<typename Class> 
  specify_precondition_old_postcondition_except public_function(Class * obj);

Description
This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check class invariants for public functions that are not static, not virtual, and do not override:

class u {
    friend class boost::contract::access;

    void invariant() const { // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

public:
    void f(...) {
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::public_function(this)
            .precondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_expr);
                ...
            })
            .postcondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body.
    }
    
    ...
};

For optimization, this can be omitted for public functions that do not have preconditions, postconditions and exception guarantees, within classes that have no invariants.
See Also:
Public Functions
Parameters:	
obj	The object this from the scope of the enclosing public function declaring the contract. This object might be mutable, const, volatile, or const volatile depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see Volatile Public Functions).
Template Parameters:	
Class	The type of the class containing the public function declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the public function body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).
boost::contract::public_function
Program contracts for void virtual public functions that do not override.

// In header: <boost/contract/public_function.hpp>


template<typename Class> 
  specify_precondition_old_postcondition_except 
  public_function(virtual_ * v, Class * obj);

Description
This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check class invariants for public functions that are virtual, do not override, and return void:

class u {
    friend class boost::contract::access;

    void invariant() const { // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

public:
    void f(..., boost::contract::virtual_* v = 0) {
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::public_function(v, this)
            .precondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            .postcondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body.
    }
    
    ...
};

A virtual public function should always call boost::contract::public_function otherwise this library will not be able to correctly use it for subcontracting.
See Also:
Virtual Public Functions
Parameters:	
obj	The object this from the scope of the enclosing virtual public function declaring the contract. This object might be mutable, const, volatile, or const volatile depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see Volatile Public Functions).
v	The trailing parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual public function.
Template Parameters:	
Class	The type of the class containing the virtual public function declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the public function body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).
boost::contract::public_function
Program contracts for non-void virtual public functions that do not override.

// In header: <boost/contract/public_function.hpp>


template<typename VirtualResult, typename Class> 
  specify_precondition_old_postcondition_except< VirtualResult > 
  public_function(virtual_ * v, VirtualResult & r, Class * obj);

Description
This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check class invariants for public functions that are virtual, do not override, and do not return void:

class u {
    friend class boost::contract::access;

    void invariant() const { // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

public:
    t f(..., boost::contract::virtual_* v = 0) {
        t result;
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::public_function(
                v, result, this)
            .precondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            .postcondition([&] (t const& result) { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body (use `return result = return_expr`).
    }
    
    ...
};

A virtual public function should always call boost::contract::public_function otherwise this library will not be able to correctly use it for subcontracting.
See Also:
Virtual Public Functions
Parameters:	
obj	The object this from the scope of the enclosing virtual public function declaring the contract. This object might be mutable, const, volatile, or const volatile depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see Volatile Public Functions).
r	A reference to the return value of the enclosing virtual public function declaring the contract. This is usually a local variable declared by the enclosing virtual public function just before the contract, but programmers must set it to the actual value being returned by the function at each return statement.
v	The trailing parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual public function.
Template Parameters:	
Class	The type of the class containing the virtual public function declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
VirtualResult	This type must be the same as, or compatible with, the return type of the enclosing virtual public function declaring the contract (this library might not be able to generate a compile-time error if these types mismatch, but in general that will cause run-time errors or undefined behaviour). Alternatively, boost::optional<return-type> can also be used (see Optional Return Values). (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the public function body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).
boost::contract::public_function
Program contracts for void public functions overrides (virtual or not).

// In header: <boost/contract/public_function.hpp>


template<typename Override, typename F, typename Class, typename... Args> 
  specify_precondition_old_postcondition_except 
  public_function(virtual_ * v, F f, Class * obj, Args &... args);

Description
This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check class invariants for public function overrides (virtual or not) that return void:

class u
    #define BASES private boost::contract::constructor_precondition<u>, \
            public b, private w
    : BASES
{
    friend class boost::contract::access;

    typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
    #undef BASES

    void invariant() const { // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

    BOOST_CONTRACT_OVERRIDES(f)

public:
    // Override from `b::f`.
    void f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::public_function<
                override_f>(v, &u::f, this, a_1, ..., a_n)
            .precondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            .postcondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body.
    }
    
    ...
};

A public function override should always call boost::contract::public_function otherwise this library will not be able to correctly use it for subcontracting.
See Also:
Public Function Overrides
Parameters:	
args	All arguments passed to the enclosing public function override declaring the contract (by reference and in the order they appear in the enclosing function declaration), but excluding the trailing argument v.
f	A pointer to the enclosing public function override declaring the contract.
obj	The object this from the scope of the enclosing public function override declaring the contract. This object might be mutable, const, volatile, or const volatile depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see Volatile Public Functions).
v	The trailing parameter of type boost::contract::virtual_* and default value 0 from the enclosing public function override.
Template Parameters:	
Args	The types of all parameters passed to the enclosing public function override declaring the contract, but excluding the trailing parameter type boost::contract::virtual_*. On compilers that do not support variadic templates, this library internally implements this function using preprocessor meta-programming (in this case, the maximum number of supported arguments is defined by BOOST_CONTRACT_MAX_ARGS). (Usually these template parameters are automatically deduced by C++ and they do not need to be explicitly specified by programmers.)
Class	The type of the class containing the virtual public function declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
F	The function pointer type of the enclosing public function override declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers, but see Function Overloads.)
Override	The type override_function-name declared using the BOOST_CONTRACT_OVERRIDE or related macros. This template parameter must be explicitly specified (because there is no function argument from which it can be automatically deduced by C++).
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the public function body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).
boost::contract::public_function
Program contracts for non-void public functions overrides (virtual or not).

// In header: <boost/contract/public_function.hpp>


template<typename Override, typename VirtualResult, typename F, 
         typename Class, typename... Args> 
  specify_precondition_old_postcondition_except< VirtualResult > 
  public_function(virtual_ * v, VirtualResult & r, F f, Class * obj, 
                  Args &... args);

Description
This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check class invariants for public function overrides (virtual or not) that do not return void:

class u
    #define BASES private boost::contract::constructor_precondition<u>, \
            public b, private w
    : BASES
{
    friend class boost::contract::access;

    typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
    #undef BASES

    void invariant() const { // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    }

    BOOST_CONTRACT_OVERRIDES(f)

public:
    // Override from `b::f`.
    t f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
        t result;
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::public_function<
                override_f>(v, result, &u::f, this, a_1, ..., a_n)
            .precondition([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .old([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            .postcondition([&] (t const& result) { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body (use `return result = return_expr`).
    }
    
    ...
};

A public function override should always call boost::contract::public_function otherwise this library will not be able to correctly use it for subcontracting.
See Also:
Public Function Overrides
Parameters:	
args	All arguments passed to the enclosing public function override declaring the contract (by reference and in the order they appear in the enclosing function declaration), but excluding the trailing argument v.
f	A pointer to the enclosing public function override declaring the contract.
obj	The object this from the scope of the enclosing public function override declaring the contract. This object might be mutable, const, volatile, or const volatile depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see Volatile Public Functions).
r	A reference to the return value of the enclosing public function override declaring the contract. This is usually a local variable declared by the enclosing public function override just before the contract, but programmers must set it to the actual value being returned by the function at each return statement.
v	The trailing parameter of type boost::contract::virtual_* and default value 0 from the enclosing public function override.
Template Parameters:	
Args	The types of all parameters passed to the enclosing public function override declaring the contract, but excluding the trailing parameter type boost::contract::virtual_*. On compilers that do not support variadic templates, this library internally implements this function using preprocessor meta-programming (in this case, the maximum number of supported arguments is defined by BOOST_CONTRACT_MAX_ARGS). (Usually these template parameters are automatically deduced by C++ and they do not need to be explicitly specified by programmers.)
Class	The type of the class containing the virtual public function declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
F	The function pointer type of the enclosing public function override declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers, but see Function Overloads.)
Override	The type override_function-name declared using the BOOST_CONTRACT_OVERRIDE or related macros. This template parameter must be explicitly specified (because there is no function argument from which it can be automatically deduced by C++).
VirtualResult	This type must be the same as, or compatible with, the return type of the enclosing public function override declaring the contract (this library might not be able to generate a compile-time error if these types mismatch, but in general that will cause run-time errors or undefined behaviour). Alternatively, boost::optional<return-type> can also be used (see Optional Return Values). (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)
Returns:	The result of this function must be explicitly assigned to a variable of type boost::contract::check declared locally just before the code of the public function body (otherwise this library will generate a run-time error, see BOOST_CONTRACT_ON_MISSING_CHECK_DECL).

Header <boost/contract_macro.hpp>
Allow to disable contracts to completely remove their compile-time and run-time overhead.
This header also includes all headers file boost/contract/*.hpp that are necessary to use its macros.
Almost all the macros defined in this header file are variadic macros. On compilers that do not support variadic macros, programmers can manually code #ifndef BOOST_CONTRACT_NO_... statements instead (see Disable Contract Compilation).


BOOST_CONTRACT_PRECONDITION(...)
BOOST_CONTRACT_POSTCONDITION(...)
BOOST_CONTRACT_EXCEPT(...)
BOOST_CONTRACT_OLD(...)
BOOST_CONTRACT_OLD_PTR(...)
BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(...)
BOOST_CONTRACT_INVARIANT(...)
BOOST_CONTRACT_INVARIANT_VOLATILE(...)
BOOST_CONTRACT_STATIC_INVARIANT(...)
BOOST_CONTRACT_CONSTRUCTOR(...)
BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(...)
BOOST_CONTRACT_DESTRUCTOR(...)
BOOST_CONTRACT_FUNCTION()
BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(...)
BOOST_CONTRACT_PUBLIC_FUNCTION(...)
BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(...)

BOOST_CONTRACT_PRECONDITION
Program preconditions that can be completely disabled at compile-time.

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

BOOST_CONTRACT_PRECONDITION(...)

Description
BOOST_CONTRACT_PRECONDITION(f) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_PRECONDITIONS is defined):

#ifndef BOOST_CONTRACT_NO_PRECONDITIONS
    .precondition(f)
#endif

Where:
f is the nullay functor called by this library to check preconditions 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::precondition_failure). This functor should capture variables 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, Preconditions
BOOST_CONTRACT_POSTCONDITION
Program postconditions that can be completely disabled at compile-time.

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

BOOST_CONTRACT_POSTCONDITION(...)

Description
BOOST_CONTRACT_POSTCONDITION(f) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_POSTCONDITIONS is defined):

#ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
    .postcondition(f)
#endif

Where:
f is the 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 takes the return value (preferably by const&) as its one single parameter but only for virtual public functions and public functions overrides, otherwise it takes no parameter. (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
See Also:
Disable Contract Compilation, Postconditions
BOOST_CONTRACT_EXCEPT
Program exception guarantees that can be completely disabled at compile-time.

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

BOOST_CONTRACT_EXCEPT(...)

Description
BOOST_CONTRACT_EXCEPT(f) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_EXCEPTS is defined):

#ifndef BOOST_CONTRACT_NO_EXCEPTS
    .except(f)
#endif

Where:
f is the 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). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
See Also:
Disable Contract Compilation, Exception Guarantees
BOOST_CONTRACT_OLD
Program old value copies at body that can be completely disabled at compile-time.

// 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 Value Copies at Body
BOOST_CONTRACT_OLD_PTR
Program old values that can be completely disabled at compile-time and require the old value type to be copyable.

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

BOOST_CONTRACT_OLD_PTR(...)

Description
This is used to program old value copies for copyable types:

class u {
public:
    void f(...) {
        BOOST_CONTRACT_OLD_PTR(old_type_a)(old_var_a);
        BOOST_CONTRACT_OLD_PTR(old_type_b)(old_var_b, old_expr_b);
        BOOST_CONTRACT_PUBLIC_FUNCTION(this)
            ...
            BOOST_CONTRACT_OLD([&] {
                old_var_a = BOOST_CONTRACT_OLDOF(old_expr_a);
                ...
            })
            ...
        ;

        ... // Function body.
    }

    virtual void g(..., boost::contract::virtual_* v = 0) {
        BOOST_CONTRACT_OLD_PTR(old_type_a)(old_var_a);
        BOOST_CONTRACT_OLD_PTR(old_type_b)(v, old_var_b, old_expr_b);
        BOOST_CONTRACT_PUBLIC_FUNCTION(v, this)
            ...
            BOOST_CONTRACT_OLD([&] {
                old_var_a = BOOST_CONTRACT_OLDOF(v, old_expr_a);
                ...
            })
            ...
        ;

        ... // Function body.
    }

    ...
};

This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when BOOST_CONTRACT_NO_OLDS is defined).
1. BOOST_CONTRACT_OLD_PTR(old_type)(old_var) expands to code equivalent to the following (this leaves the old value pointer null):

#ifndef BOOST_CONTRACT_NO_OLDS
    // This declaration does not need to use `v`.
    boost::contract::old_ptr<old_type> old_var
#endif

2. BOOST_CONTRACT_OLD_PTR(old_type)(old_var, old_expr) expands to code equivalent to the following (this initializes the pointer to the old value copy, but not to be used for virtual public functions and public function overrides):

#ifndef BOOST_CONTRACT_NO_OLDS
    boost::contract::old_ptr<old_type> old_var =
            BOOST_CONTRACT_OLDOF(old_expr)
#endif

3. BOOST_CONTRACT_OLD_PTR(old_type)(v, old_var, old_expr) expands to code equivalent to the following (this initializes the pointer to the old value copy for virtual public functions and public function overrides):

#ifndef BOOST_CONTRACT_NO_OLDS
    boost::contract::old_ptr<old_type> old_var =
            BOOST_CONTRACT_OLDOF(v, old_expr)
#endif

Where:
old_type is the type of the pointed old value. This type must be copyable (i.e., boost::contract::is_old_value_copyable<old_type>::value is true), otherwise this pointer will always be null and this library will generate a compile-time error when the pointer is dereferenced (see BOOST_CONTRACT_OLD_PTR_IF_COPYABLE). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
v is the extra parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual public function or public function override declaring the contract. (This is not a variadic macro parameter.)
old_var is the name of the old value pointer variable. (This is not a variadic macro parameter but it should never contain commas because it is an identifier.)
old_expr is the expression to be evaluated and copied in the old value pointer. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_OLD_PTR(old_type)(v, old_var, (old_expr)) will always work.)
See Also:
Disable Contract Compilation, Old Values
BOOST_CONTRACT_OLD_PTR_IF_COPYABLE
Program old values that can be completely disabled at compile-time and do not require the old value type to be copyable.

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

BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(...)

Description
This is used to program old value copies for types that might or might not be copyable:

template<typename T> // Type `T` might or not be copyable.
class u {
public:
    void f(...) {
        BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_a)(old_var_a);
        BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_b)(old_var_b,
                old_expr_b);
        BOOST_CONTRACT_PUBLIC_FUNCTION(this)
            ...
            BOOST_CONTRACT_OLD([&] {
                old_var_a = BOOST_CONTRACT_OLDOF(old_expr_a);
                ...
            })
            ... // In postconditions or exception guarantees:
                if(old_var_a) ... // Always null for non-copyable types.
                if(old_var_b) ... // Always null for non-copyable types.
            ...
        ;

        ... // Function body.
    }

    virtual void g(..., boost::contract::virtual_* v = 0) {
        BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_a)(old_var_a);
        BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_b)(v, old_var_b,
                old_expr_b);
        BOOST_CONTRACT_PUBLIC_FUNCTION(v, this)
            ...
            BOOST_CONTRACT_OLD([&] {
                old_var_a = BOOST_CONTRACT_OLDOF(v, old_expr_a);
                ...
            })
            ... // In postconditions or exception guarantees:
                if(old_var_a) ... // Always null for non-copyable types.
                if(old_var_b) ... // Always null for non-copyable types.
            ...
        ;

        ... // Function body.
    }

    ...
};

This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when BOOST_CONTRACT_NO_OLDS is defined).
1. BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(old_var) expands to code equivalent to the following (this leaves the old value pointer null):

#ifndef BOOST_CONTRACT_NO_OLDS
    // This declaration does not need to use `v`.
    boost::contract::old_ptr_if_copyable<old_type> old_var
#endif

2. BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(old_var, old_expr) expands to code equivalent to the following (this initializes the pointer to the old value copy, but not to be used for virtual public functions and public function overrides):

#ifndef BOOST_CONTRACT_NO_OLDS
    boost::contract::old_ptr_if_copyable<old_type> old_var =
            BOOST_CONTRACT_OLDOF(old_expr)
#endif

3. BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(v, old_var, old_expr) expands to code equivalent to the following (this initializes the pointer to the old value copy for virtual public functions and public function overrides):

#ifndef BOOST_CONTRACT_NO_OLDS
    boost::contract::old_ptr_if_copyable<old_type> old_var =
            BOOST_CONTRACT_OLDOF(v, old_expr)
#endif

Where:
old_type is the type of the pointed old value. If this type is not copyable (i.e., boost::contract::is_old_value_copyable<old_type>::value is false), this pointer will always be null, but this library will not generate a compile-time error when this pointer is dereferenced (see BOOST_CONTRACT_OLD_PTR). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
v is the extra parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual public function or public function override declaring the contract. (This is not a variadic macro parameter.)
old_var is the name of the old value pointer variable. (This is not a variadic macro parameter but it should never contain commas because it is an identifier.)
old_expr is the expression to be evaluated and copied in the old value pointer. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis, BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(v, old_var, (old_expr)) will always work.)
See Also:
Disable Contract Compilation, Old Value Requirements
BOOST_CONTRACT_INVARIANT
Program (constant) class invariants that can be completely disabled at compile-time.

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

BOOST_CONTRACT_INVARIANT(...)

Description
BOOST_CONTRACT_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
    void BOOST_CONTRACT_INVARIANT_FUNC() const {
        ...
    }
#endif

Where:
{ ... } is the definition of the function that checks class invariants for public functions that are not static and not volatile (see BOOST_CONTRACT_STATIC_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
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(...)

Description
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
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(...)

Description
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
BOOST_CONTRACT_CONSTRUCTOR
Program contracts that can be completely disabled at compile-time for constructors.

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

BOOST_CONTRACT_CONSTRUCTOR(...)

Description
This is used together with BOOST_CONTRACT_POSTCONDITION, BOOST_CONTRACT_EXCEPT, and BOOST_CONTRACT_OLD to specify postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for constructors (see BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION to specify preconditions for constructors):

class u {
    friend class boost::contract::access;

    BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    })

public:
    u(...) {
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_CONSTRUCTOR(this)
            // No `PRECONDITION` (use `CONSTRUCTOR_PRECONDITION` if needed).
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_epxr);
                ...
            })
            BOOST_CONTRACT_POSTCONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_EXCEPT([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Constructor body.
    }

    ...
};

For optimization, this can be omitted for constructors that do not have postconditions and exception guarantees, within classes that have no invariants.
BOOST_CONTRACT_CONSTRUCTOR(obj) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_CONSTRUCTORS is defined):

#ifndef BOOST_CONTRACT_NO_CONSTRUCTORS
    boost::contract::check internal_var =
            boost::contract::constructor(obj)
#endif

Where:
obj is the object this from the scope of the enclosing constructor declaring the contract. Constructors check all class invariants, including static and volatile invariants (see BOOST_CONTRACT_INVARIANT, BOOST_CONTRACT_STATIC_INVARIANT, and BOOST_CONTRACT_INVARIANT_VOLATILE). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
internal_var is a variable name internally generated by this library (this name is unique but only on different line numbers so this macro cannot be expanded multiple times on the same line).
See Also:
Disable Contract Compilation, Constructors
BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION
Program preconditions that can be disabled at compile-time for constructors.

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

BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(...)

Description
This is used together with BOOST_CONTRACT_CONSTRUCTOR to specify contracts for constructors. Constructors that do not have preconditions do not use this macro. When at least one of the class constructors uses this macro, boost::contract::constructor_precondition must be the first and private base class of the class declaring the constructor for which preconditions are programmed:

class u
    #define BASES private boost::contract::constructor_precondition<u>, \
            public b
    : BASES
{
    ...
    #undef BASES

public:
    explicit u(unsigned x) :
        BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(u)([&] {
            BOOST_CONTRACT_ASSERT(x != 0);
        }),
        b(1.0 / float(x))
    {
        ...
    }

    ...
};

BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(class_type)(f) expands to code equivalent to the following (note that when BOOST_CONTRACT_NO_PRECONDITIONS is defined, this macro trivially expands to a default constructor call that is internally implemented to do nothing so this should have minimal to no overhead):

// Guarded only by NO_PRECONDITIONS (and not also by NO_CONSTRUCTORS)
// because for constructor's preconditions (not for postconditions, etc.).
#ifndef BOOST_CONTRACT_NO_PRECONDITIONS
    boost::contract::constructor_precondition<class_type>(f)
#else
    // No-op call (likely optimized away, minimal to no overhead).
    boost::contract::constructor_precondition<class_type>()
#endif

Where:
class_type is the type of the class containing the constructor for which preconditions are being programmed. (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
f is the nullary functor called by this library to check constructor preconditions f(). Assertions within this functor call are usually programmed using BOOST_CONTRACT_ASSERT, but any exception thrown by a call to this functor indicates a contract failure (and will result in this library calling boost::contract::precondition_failure). This functor should capture variables 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, Constructors
BOOST_CONTRACT_DESTRUCTOR
Program contracts that can be completely disabled at compile-time for destructors.

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

BOOST_CONTRACT_DESTRUCTOR(...)

Description
This is used together with BOOST_CONTRACT_POSTCONDITION, BOOST_CONTRACT_EXCEPT, and BOOST_CONTRACT_OLD to specify postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for destructors (destructors cannot have preconditions, see Destructor Calls):

class u {
    friend class boost::contract::access;

    BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    })

public:
    ~u() {
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_DESTRUCTOR(this)
            // No `PRECONDITION` (destructors have no preconditions).
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_expr);
                ...
            })
            BOOST_CONTRACT_POSTCONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_EXCEPT([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Destructor body.
    }
    
    ...
};

For optimization, this can be omitted for destructors that do not have postconditions and exception guarantees, within classes that have no invariants.
BOOST_CONTRACT_DESTRUCTOR(obj) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_DESTRUCTORS is defined):

#ifndef BOOST_CONTRACT_NO_DESTRUCTORS
    boost::contract::check internal_var =
            boost::contract::destructor(obj)
#endif

Where:
obj is the object this from the scope of the enclosing destructor declaring the contract. Destructors check all class invariants, including static and volatile invariants (see Class Invariants and Volatile Public Functions). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
internal_var is a variable name internally generated by this library (this name is unique but only on different line numbers so this macro cannot be expanded multiple times on the same line).
See Also:
Disable Contract Compilation, Destructors
BOOST_CONTRACT_FUNCTION
Program contracts that can be completely disabled at compile-time for (non-public) functions.

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

BOOST_CONTRACT_FUNCTION()

Description
This is used together with BOOST_CONTRACT_PRECONDITION, BOOST_CONTRACT_POSTCONDITION, BOOST_CONTRACT_EXCEPT, and BOOST_CONTRACT_OLD to specify preconditions, postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for (non-public) functions:

void f(...) {
    BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
    BOOST_CONTRACT_FUNCTION()
        BOOST_CONTRACT_PRECONDITION([&] { // Optional.
            BOOST_CONTRACT_ASSERT(...);
            ...
        })
        BOOST_CONTRACT_OLD([&] { // Optional.
            old_var = BOOST_CONTRACT_OLDOF(old_expr);  
            ...
        })
        BOOST_CONTRACT_POSTCONDITION([&] { // Optional.
            BOOST_CONTRACT_ASSERT(...);
            ...
        })
        BOOST_CONTRACT_EXCEPT([&] { // Optional.
            BOOST_CONTRACT_ASSERT(...);
            ...
        })
    ;

    ... // Function body.
}

This can be used to program contracts for non-member functions but also for private and protected functions, lambda functions, loops, arbitrary blocks of code, etc. For optimization, this can be omitted for code that does not have preconditions, postconditions, and exception guarantees.
BOOST_CONTRACT_FUNCTION() expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_FUNCTIONS is defined):

#ifndef BOOST_CONTRACT_NO_FUNCTIONS
    boost::contract::check internal_var =
            boost::contract::function()
#endif

Where:
internal_var is a variable name internally generated by this library (this name is unique but only on different line numbers so this macro cannot be expanded multiple times on the same line).
See Also:
Disable Contract Compilation, Non-Member Functions, Private and Protected Functions, Lambdas, Loops, Code Blocks
BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION
Program contracts that can be completely disabled at compile-time for static public functions.

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

BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(...)

Description
This is used together with BOOST_CONTRACT_PRECONDITION, BOOST_CONTRACT_POSTCONDITION, BOOST_CONTRACT_EXCEPT, and BOOST_CONTRACT_OLD to specify preconditions, postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for static public functions:

class u {
    friend class boost::contract::access;

    BOOST_CONTRACT_STATIC_INVARIANT({ // Optional (as for non-static).
        BOOST_CONTRACT_ASSERT(...);
        ...
    })

public:
    static void f(...) {
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_PUBLIC_FUNCTION(u)
            BOOST_CONTRACT_PRECONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_expr);
                ...
            })
            BOOST_CONTRACT_POSTCONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_EXCEPT([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body.
    }
    
    ...
};

For optimization, this can be omitted for static public functions that do not have preconditions, postconditions and exception guarantees, within classes that have no static invariants.
BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(class_type) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS is defined):

#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
    boost::contract::check internal_var =
            boost::contract::public_function<class_type>()
#endif

Where:
class_type is the type of the class containing the static public function declaring the contract. (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)
internal_var is a variable name internally generated by this library (this name is unique but only on different line numbers so this macro cannot be expanded multiple times on the same line).
See Also:
Disable Contract Compilation, Static Public Functions
BOOST_CONTRACT_PUBLIC_FUNCTION
Program contracts that can be completely disabled at compile-time for non-static public functions that do not override.

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

BOOST_CONTRACT_PUBLIC_FUNCTION(...)

Description
This is used together with BOOST_CONTRACT_PRECONDITION, BOOST_CONTRACT_POSTCONDITION, BOOST_CONTRACT_EXCEPT, and BOOST_CONTRACT_OLD to specify preconditions, postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for non-static public functions (virtual or not, void or not) that do not override:

class u {
    friend class boost::contract::access;

    BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    })

public:
    // Non-virtual (same if void).
    t f(...) {
        t result;
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_PUBLIC_FUNCTION(this)
            BOOST_CONTRACT_PRECONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(old_expr);
                ...
            })
            BOOST_CONTRACT_POSTCONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_EXCEPT([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body (use `return result = return_expr`).
    }
    
    // Virtual and void.
    virtual void g(..., boost::contract::virtual_* v = 0) {
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_PUBLIC_FUNCTION(v, this)
            ...
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            ...
        ;
        
        ... // Function body.
    }
    
    // Virtual and non-void.
    virtual t h(..., boost::contract::virtual_* v = 0) {
        t result;
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_PUBLIC_FUNCTION(v, result, this)
            ...
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            BOOST_CONTRACT_POSTCONDITION([&] (t const& result) { // Optional
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            ...
        ;
        
        ... // Function body (use `return result = return_expr`).
    }
    
    ...
};

For optimization, this can be omitted for non-virtual public functions that do not have preconditions, postconditions and exception guarantees, within classes that have no invariants. Virtual public functions should always use BOOST_CONTRACT_PUBLIC_FUNCTION otherwise this library will not be able to correctly use them for subcontracting.
This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS is defined).
1. BOOST_CONTRACT_PUBLIC_FUNCTION(obj) expands to code equivalent to the following (for non-virtual public functions that are not static and do not override, returning void or not):

#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
    boost::contract::check internal_var =
            boost::contract::public_function(obj)
#endif

2. BOOST_CONTRACT_PUBLIC_FUNCTION(v, obj) expands to code equivalent to the following (for virtual public functions that are not static and do not override, returning void):

#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
    boost::contract::check internal_var =
            boost::contract::public_function(v, obj)
#endif

3. BOOST_CONTRACT_PUBLIC_FUNCTION(v, r, obj) expands to code equivalent to the following (for virtual public functions that are not static and do not override, not returning void):

#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
    boost::contract::check internal_var =
            boost::contract::public_function(v, r, obj)
#endif

Where (these are all variadic macro parameters so they can contain commas not protected by round parenthesis):
v is the extra parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual public function declaring the contract.
r is a reference to the return value of the enclosing virtual public function declaring the contract. This is usually a local variable declared by the enclosing virtual public function just before the contract, but programmers must set it to the actual value being returned by the function at each return statement.
obj is the object this from the scope of the enclosing public function declaring the contract. This object might be mutable, const, volatile, or const volatile depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see Volatile Public Functions).
internal_var is a variable name internally generated by this library (this name is unique but only on different line numbers so this macro cannot be expanded multiple times on the same line).
See Also:
Disable Contract Compilation, Public Functions, Virtual Public Functions
BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE
Program contracts that can be completely disabled at compile-time for public function overrides.

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

BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(...)

Description
This is used together with BOOST_CONTRACT_PRECONDITION, BOOST_CONTRACT_POSTCONDITION, BOOST_CONTRACT_EXCEPT, and BOOST_CONTRACT_OLD to specify preconditions, postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for public function overrides (virtual or not):

class u
    #define BASES private boost::contract::constructor_precondition<u>, \
            public b, private w
    : BASES
{
    friend class boost::contract::access;

    typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
    #undef BASES

    BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
        BOOST_CONTRACT_ASSERT(...);
        ...
    })

    BOOST_CONTRACT_OVERRIDES(f, g)

public:
    // Override from `b::f`, and void.
    void f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_f)(
                v, &u::f, this, a_1, ..., a_n)
            BOOST_CONTRACT_PRECONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            BOOST_CONTRACT_POSTCONDITION([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            BOOST_CONTRACT_EXCEPT([&] { // Optional.
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;

        ... // Function body.
    }
    
    // Override from `b::g`, and void.
    t g(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
        t result;
        BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
        BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_g)(
                v, result, &u::g, this, a_1, ..., a_n)
            ...
            BOOST_CONTRACT_OLD([&] { // Optional.
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            BOOST_CONTRACT_POSTCONDITION([&] (t const& result) { // Optional
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            ...
        ;

        ... // Function body (use `return result = return_expr`).
    }
    
    ...
};

Public function overrides should always use BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE otherwise this library will not be able to correctly use it for subcontracting.
This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS is defined).
1. BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_type)(v, f, obj, ...) expands to code equivalent to the following (for public function overrides that return void):

#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
    boost::contract::check internal_var = boost::contract::
            public_function<override_type>(v, f, obj, ...)
#endif

2. BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_type)(v, r, f, obj, ...) expands to code equivalent to the following (for public function overrides that do not return void):

#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
    boost::contract::check internal_var = boost::contract::
            public_function<override_type>(v, r, f, obj, ...)
#endif

Where (these are all variadic macro parameters so they can contain commas not protected by round parenthesis):
override_type is the type override_function-name declared using the BOOST_CONTRACT_OVERRIDE or related macros.
v is the extra parameter of type boost::contract::virtual_* and default value 0 from the enclosing virtual public function declaring the contract.
r is a reference to the return value of the enclosing virtual public function declaring the contract. This is usually a local variable declared by the enclosing virtual public function just before the contract, but programmers must set it to the actual value being returned by the function at each return statement.
f is a pointer to the enclosing public function override declaring the contract.
obj is the object this from the scope of the enclosing public function declaring the contract. This object might be mutable, const, volatile, or const volatile depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see Volatile Public Functions).
... is a variadic macro parameter listing all the arguments passed to the enclosing public function override declaring the contract (by reference and in order they appear in the enclosing function declaration), but excluding the trailing argument v.
internal_var is a variable name internally generated by this library (this name is unique but only on different line numbers so this macro cannot be expanded multiple times on the same line).
See Also:
Disable Contract Compilation, Public Function Overrides

Release Notes
This section contains notes on all releases of this library (from the latest to the oldest).

Release 1.0.0
January 6, 2018 (Il Giorno della Befana)
First Boost release:
Fixed all tests to pass as Boost regression tests (and marked those that are expected to fail on some specific compiler/platform versions).
Adjusted build scripts to work within Boost libraries.
Updated documentation to fit as a Boost library.
Released files are part of Boost.

Release 0.5.0
September 2, 2017
Contracts without the macros:
Using plain C++ code instead of macros to program contracts.
The removed macros very hard to use because they required programmers to learn a domain-specific embedded language that replaced the usual C++ syntax for declaring functions and classes.
The removed macros also made the code less readable, increased compilation time (because of extensive preprocessor meta-programming), and gave cryptic compiler errors.
However, the removed macros more correctly specified contracts in code declarations instead of definitions, and they completely removed extra code when contracts were disabled (both of those can be done by the current version of this library but at the cost of manually writing some boiler-plate code which was previous automatically handled by the macros instead, see Separate Body Implementation and Disable Contract Compilation).
Simplified the library by removing some extra features that were not directly related to contract programming, specifically:
Removed loop variants (because these are rarely if ever used).
Removed named and deduced parameters (because these can be programmed directly using Boost.Parameter).
Removed concepts (because these can be programmed directly using Boost.ConceptCheck).
Removed emulation of virtual specifiers override, final, and new (because override can be programmed directly using C++11, while final and new are rarely if ever used).
Removed static_assert emulation (because this can be programmed directly using C++11, or using Boost.StaticAssert).
Ensuring that old values and return values are copied only once even when subcontracting is used with multiple inheritance.
Improved template meta-programming algorithm that searches the inheritance tree for subcontracting when multiple inheritance is used.
Exception specifications and function-try blocks apply also to exceptions thrown by the contracts, and not just to exceptions thrown by the body.
Added contracts for exception guarantees (using .except(...), etc.).
Added predefined assertion levels for "audit" and "axiom".
Added call_if and condition_if (assertions requirements were supported also by previous revisions of this library but they were handled by internal code generated by the contract macros).
Released files.

Release 0.4.1
This revision of the library passed Boost formal review and it was accepted into the Boost libraries (see https://groups.google.com/forum/?fromgroups=#!topic/boost-list/jQ7OjAmos_Y).
August 20, 2012
Accepted into Boost:
Using non-fix-spaced font in Full Table of Contents section.
Added a couple of notes to the documentation.
Changed CONTRACT_MEMBER_BODY(class_type, function_name) to class_type::CONTRACT_MEMBER_BODY(function_name) so the macro can also be used to declare derived classes avoiding using the library syntax even when the base class has contracts.
Released files.

Release 0.4.0
June 4, 2012
Simplified syntax, added named parameters and concepts:
Simplified syntax by reducing extra parenthesis to the bare necessary minimum (using some of the preprocessor parsing techniques originally introduced by Boost.LocalFunction).
Postcondition old values only copy the old-of expression (e.g., copy just vector size instead of entire vector). This improves performance and introduces the ConstantCopyConstructible requirement just for the old value expression type (e.g., a vector might not be copyable while its size always is because it is an integral type). Removed the copyable tag.
Body defined outside the macros (so compiler-errors for definitions retain their usual meaning).
Added CONTRACT_CLASS macro and removed the need to duplicate declaration elements (do not repeat function declaration, do not repeat class name in function declaration, etc).
Using _TPL macros so to reduce compile-time (instead of internally making all templates contract functions so to use typename freely).
Overloading no longer requires unique parameter names.
Added C++11-like virtual specifiers.
Added constant assertions plus constant-expressions for select assertion if-conditions and for loop variants.
Added named and deduced parameters.
Added concept checking.
Removed the interface to use the library without the macro (programmers were required to write too much boiler-plate code for the non-macro interface to be actually usable, plus supporting both the macro and non-macro interfaces limited what the macros could do).
Released files.

Release 0.3.490
March 7, 2010
Support for most/all C++ constructs:
Added support and examples for volatile, auto, explicit, export, extern, friend, inline, struct, and throw (for exception specifications).
Documented that union cannot be contracted.
Released files.

Release 0.3.469
February 21, 2010
Support for most/all contract programming features:
Removed use of self, variable.now, and variable.old in writing contracts. Object this and variables are now accessed as usual in member functions. CONTRACT_OLDOF(variable) is used to access old values in postconditions.
Added (precondition), (postcondition), and (body) to specify contracts within the function signature sequence. If no preconditions then (precondition) ({...}) is simply omitted from the sequence (same for postconditions, body is mandatory instead). For non-void functions, users can name the result argument with (postcondition) (result-name) ({...}).
Changed contract class template to use same syntax as Boost.Function (i.e., F function type).
Added support for free functions and static member functions.
Added support for subcontracting with multiple inheritance.
Added static class invariants which are always checked (also at constructors entry, destructor exit, and by static member functions).
Added block invariants and Eiffel-like loop variants.
Added handlers to customize action on contract failure (default to std::terminate()).
Removed feature for automatic contract documentation using Doxygen (this is not compatible with added (precondition), (postcondition), and (body) because Doxygen preprocessor is not capable to handle Boost.Preprocessor sequences).
Rewritten entire documentation (now using Boost.QuickBook instead of Doxygen).
Released files.

Release 0.2.190
November 21, 2009
Compiled on both GCC and MSVC:
Compiled using both GCC (Linux and Cygwin) and MSVC (Windows XP).
Required to use void to specify empty function argument list. This is to comply with C++03 standard that does not allow to pass empty macro parameters so it does not support empty preprocessor sequences ().
Released files.

Release 0.1.126
June 17, 2009
Added documentation:
Completed first documentation draft.
Released files.

Release 0.1.55
April 19, 2009
Cleaned-up first release:
Reorganized files to cleanup root directory.
Added installation program.
Released files.

Release 0.1.50
April 19, 2009
First release:
First public release.
Released files.

Bibliography
This section lists all references consulted while designing and developing this library.
[Andrzej13] A. Krzemienski. Andrzej's C++ blog: Preconditions. 2013.
[Bright04] W. Bright. Contract Programming for the D Programming Language. 2004.
[Bright04b] W. Bright. Contract Programming for the Digital Mars C++ Compiler. 2004.
[C2] Aechmea. C^2 Contract Programming add-on for C++. 2005.
[Chrome] RemObjects. Chrome: Contract Programming for Object Pascal in .NET. 2002.
[Clarke06] L. A. Clarke and D. S. Rosenblum. A Historical Perspective on Runtime Assertion Checking in Software Development. Newsletter ACM SIGSOFT Software Engineering Notes, 2006.
[Cline90] M. Cline and D. Lea. The Behaviour of C++ Classes and Using Annotated C++. Proc. of the Symposium on Object Oriented Programming Emphasizing Practical Applications, Maris College, 1990.
[Ellis90] M. A. Ellis and B. Stroustrup. The Annotated C++ Reference Manual. ANSI Base Document, Addison Wesley, 1990.
[Gautron92] P. Gautron. An Assertion Mechanism Based on Exceptions. Fourth C++ Technical Conference, 1992.
[Hoare73] C. A. R. Hoare. Hints on Programming Language Design. Stanford University Artificial Intelligence memo AIM-224/STAN-CS-73-403, pages 193-216, 1973.
[CodeContracts] Microsoft Research. Code Contracts: Design-By-Contract Programming for All .NET Programming Languages. 2012.
[iContract] O. Enseling. iContract: Contract Programming for Java. 2001.
[Jcontract] Parasoft. Jcontract: Contract Programming for Java.
[Lindrud04] J. Lindrud. Design by Contract in C++. 2004.
[Maley99] D. Maley and I. Spence. Emulating Design by Contract in C++. Proceedings of TOOLS, IEEE Computer Society, 1999.
[Meyer97] B. Meyer. Object Oriented Software Construction. Prentice-Hall, 2nd edition, 1997.
[Mitchell02] R. Mitchell and J. McKim. Design by Contract, by Example. Addison-Wesley, 2002.
[N1613] T. Ottosen. Proposal to add Design by Contract to C++. The C++ Standards Committee, N1613, 2004.
[N1653] C. Nelson. Working draft changes for C99 preprocessor synchronization. C++ Standards Committee, N1653, 2004.
[N1669] T. Ottosen. Proposal to add Contract Programming to C++ (revision 1). The C++ Standards Committee, N1669, 2004.
[N1773] D. Abrahams, L. Crowl, T. Ottosen, and J. Widman. Proposal to add Contract Programming to C++ (revision 2). The C++ Standards Committee, N1773, 2005.
[N1866] L. Crowl and T. Ottosen. Proposal to add Contract Programming to C++ (revision 3). The C++ Standards Committee, N1866, 2005.
[N1895] H. Sutter and F. Glassborow. Delegating Constructors (revision 2). C++ Standards Committee, N1895, 2005.
[N1962] L. Crowl and T. Ottosen. Proposal to add Contract Programming to C++ (revision 4). The C++ Standards Committee, N1962, 2006.
[N2081] D. Gregor and B. Stroustrup. Concepts (revision 1). The C++ Standards Committee, N2081, 2006.
[N2887] G. Dos Reis, B. Stroustrup, and A. Meredith. Axioms: Semantics Aspects of C++ Concepts. The C++ Standards Committee, N2887, 2009.
[N2914] P. Becker. Working Draft, Standard for Programming Language C++. The C++ Standards Committee, N2914, 2009.
[N2906] B. Stroustrup. Simplifying the sue of concepts. The C++ Standards Committee, N2906, 2009.
[N3248] J. Lakos. noexcept Prevents Library Validation. The C++ Standards Committee, N3248, 2011.
[N4154] D. Krauss. Operator assert. The C++ Standards Committee, N4154, 2014.
[N4160] A. Krzemienski. Value constraints. The C++ Standards Committee, N4160, 2014.
[N4248] A. Meredith. Library Preconditions are a Language Feature. The C++ Standards Committee, N4248, 2014.
[N4293] J. D. Garcia. C++ language support for contract programming. The C++ Standards Committee, N4293, 2014.
[N4378] J. Lakos, N. Myers, A. Zakharov, and A. Beels. Language Support for Contract Assertions (Revision 10). The C++ Standards Committee, N4378, 2015.
[Nana] P. J. Maker. GNU Nana. 2014.
[N4378] J. Lakos and N. Myers. FAQ about Contract Assertions. The C++ Standards Committee, N4379, 2015.
[N4435] W. E. Brown. Proposing Contract Attributes. The C++ Standards Committee, N4435, 2015.
[P0147] L. Crowl. The Use and Implementation of Contracts. The C++ Standards Committee, P0147R0, 2015.
[P0166] J. D. Garcia. Three interesting questions about contracts. The C++ Standards Committee, P0166R0, 2015.
[P0246] N. Myers. Criteria for Contract Support Merged Proposal. The C++ Standards Committee, P0246R0, 2016.
[P0287] G. Dos Reis, J.D. Garcia, F. Logozzo, M. Fahndrich, S. Lahiri. Simple Contracts for C++ (R1). The C++ Standards Committee, P0287R0, 2016.
[P0380] G. Dos Reis, J.D. Garcia, J. Lakos, A. Meredith, N. Myers, and B. Stroustrup. A Contract Design. The C++ Standards Committee, P0380R1, 2016.
[P0542] G. Dos Reis, J.D. Garcia, J. Lakos, A. Meredith, N. Myers, and B. Stroustrup. Support for contract based programming in C++. The C++ Standards Committee, P0542R0, 2017.
[Rosenblum95] D. S. Rosenblum. A practical Approach to Programming With Assertions. IEEE Transactions on Software Engineering, 1995.
[SPARKAda] Praxis. SPARKAda (Ada-like Language with Contract Programming).
[SpecSharp] Microsoft. Spec# (C# Extension).
[Stroustrup94] B. Stroustrup. The Design and Evolution of C++. Addison Wesley, 1994.
[Stroustrup13] B. Stroustrup. The C++ Programming Language. Addison Wesley, 4th Edition, 2013.
[Tandin04] A. Tandin. Design by Contract macros for C++ and link to Doxygen. 2004.
[Wilson06] M. Wilson. Contract Programming 101 - The Nuclear Reactor and the Deep Space Probe. The C++ Source, 2006.

Acknowledgments
This section tries to recognize the contributions of all the different people that participated directly or indirectly to the design and development of this library.
Sincere thanks to my parents for their support with my education and my studies in computer science.
Many thanks to Andrzej Krzemienski for reviewing early versions of this library providing valuable insights and exchanging early ideas on assertion requirements.
Many thanks to Vicente J. Botet Escriba for reviewing earlier versions of this library providing valuable insights and for suggesting to use a dedicated trait to copy old values.
Thanks to Steven Watanabe for providing valuable insights on C++, SFINAE, and introspection.
Thanks to Dave Abrahams for moderating the Boost review of this library.
Thanks to Daniel James for his help with incorporating this library files into the Boost Git repository.
Thanks to David Maley for sharing source code form his inspiring work on emulating contract programming and subcontracting in C++ in [Maley99].
Many thanks to Thorsten Ottosen for his work on the [N1962] proposal (and its previous revisions) and for clarifying the proposal requirements directly with the library authors when needed.
Many thanks to Bertrand Meyer for his pioneering and thorough work on contract programming in [Meyer97].
Finally, many thanks to the entire Boost community and mailing list for providing valuable comments on this library and great insights on the C++ programming language.