Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / contract / doc / reference.xml
1 <?xml version="1.0" standalone="yes"?>
2 <library-reference id="reference"><title>Reference</title><header name="boost/contract.hpp">
3 <para>Include all header files required by this library at once (for convenience). </para><para>All header files <computeroutput>boost/contract/*.hpp</computeroutput> 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 <computeroutput>boost/contract.hpp</computeroutput> can be included directly in most cases). Instead the headers <computeroutput>boost/contract/core/*.hpp</computeroutput> are not independent from other library headers and they are automatically included by the <computeroutput>boost/contract/*.hpp</computeroutput> headers (so the <computeroutput>boost/contract/core/*.hpp</computeroutput> headers are usually not directly included by programmers).</para><para>All files under the <computeroutput>boost/contract/detail/</computeroutput> directory, names within the <computeroutput>boost::contract::detail</computeroutput> namespace, names prefixed by <computeroutput>boost_contract_detail</computeroutput>... and <computeroutput>BOOST_CONTRACT_DETAIL</computeroutput>... (in any namesapce, including user's code) are reserved for internal use of this library and should never be used directly by programmers.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.getting_started"> Getting Started</link> </para>
4 </para>
5 </para></header>
6 <header name="boost/contract/assert.hpp">
7 <para>Assert contract conditions. </para><macro name="BOOST_CONTRACT_ASSERT" kind="functionlike"><macro-parameter name="cond"><description><para>Boolean contract condition to check. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis and <computeroutput>BOOST_CONTRACT_ASSERT((cond))</computeroutput> will always work.) </para></description></macro-parameter><purpose>Preferred way to assert contract conditions. </purpose><description><para>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 <computeroutput>false</computeroutput> (this library will then call the appropriate contract failure handler  <computeroutput><functionname alt="boost::contract::precondition_failure">boost::contract::precondition_failure</functionname></computeroutput>, etc.). However, it is preferred to use this macro because it expands to code that throws <computeroutput><classname alt="boost::contract::assertion_failure">boost::contract::assertion_failure</classname></computeroutput> with the correct assertion file name (using <computeroutput>__FILE__</computeroutput>), line number (using <computeroutput>__LINE__</computeroutput>), and asserted condition code so to produce informative error messages (C++11 <computeroutput>__func__</computeroutput> is not used here because in most cases it will simply expand to the internal compiler name of the lambda function used to program the contract conditions adding no specificity to the error message).</para><para> <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT_AUDIT">BOOST_CONTRACT_ASSERT_AUDIT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT_AXIOM">BOOST_CONTRACT_ASSERT_AXIOM</macroname></computeroutput> are the three assertion levels predefined by this library.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exceptions Guarantees</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
8 </para>
9
10 </para></description></macro>
11 <macro name="BOOST_CONTRACT_ASSERT_AUDIT" kind="functionlike"><macro-parameter name="cond"><description><para>Boolean contract condition to check. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis and <computeroutput>BOOST_CONTRACT_ASSERT_AUDIT((cond))</computeroutput> will always work.) </para></description></macro-parameter><purpose>Preferred way to assert contract conditions that are computationally expensive, at least compared to the computational cost of executing the function body. </purpose><description><para>The asserted condition will always be compiled and validated syntactically, but it will not be checked at run-time unless  <computeroutput><macroname alt="BOOST_CONTRACT_AUDITS">BOOST_CONTRACT_AUDITS</macroname></computeroutput> is defined (undefined by default). This macro is defined by code equivalent to:</para><para><programlisting language="c++">#ifdef BOOST_CONTRACT_AUDITS
12     #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \
13         BOOST_CONTRACT_ASSERT(cond)
14 #else
15     #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \
16         BOOST_CONTRACT_ASSERT(true || cond)
17 #endif
18 </programlisting></para><para> <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT_AUDIT">BOOST_CONTRACT_ASSERT_AUDIT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT_AXIOM">BOOST_CONTRACT_ASSERT_AXIOM</macroname></computeroutput> 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.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_levels"> Assertion Levels</link>,  <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
19 </para>
20
21 </para></description></macro>
22 <macro name="BOOST_CONTRACT_ASSERT_AXIOM" kind="functionlike"><macro-parameter name="cond"><description><para>Boolean contract condition to check. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis and <computeroutput>BOOST_CONTRACT_ASSERT_AXIOM((cond))</computeroutput> will always work.) </para></description></macro-parameter><purpose>Preferred way to document in the code contract conditions that are computationally prohibitive, at least compared to the computational cost of executing the function body. </purpose><description><para>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:</para><para><programlisting language="c++">#define BOOST_CONTRACT_ASSERT_AXIOM(cond) \
23     BOOST_CONTRACT_ASSERT(true || cond)
24 </programlisting></para><para> <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT_AUDIT">BOOST_CONTRACT_ASSERT_AUDIT</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT_AXIOM">BOOST_CONTRACT_ASSERT_AXIOM</macroname></computeroutput> 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.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_levels"> Assertion Levels</link>,  <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
25 </para>
26
27 </para></description></macro>
28 </header>
29 <header name="boost/contract/base_types.hpp">
30 <para>Specify inheritance form base classes (for subcontracting). </para><macro name="BOOST_CONTRACT_BASE_TYPES" kind="functionlike"><macro-parameter name="..."><description><para>Comma separated list of base classes. Each base must explicitly specify its access specifier <computeroutput>public</computeroutput>, <computeroutput>protected</computeroutput>, or <computeroutput>private</computeroutput>, and also <computeroutput>virtual</computeroutput> 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 <computeroutput>typedef</computeroutput> for base classes can be programmed manually without using this macro (see  <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link>). </para></description></macro-parameter><purpose>Used to program the <computeroutput>typedef</computeroutput> that lists the bases of a derived class. </purpose><description><para>In order to support subcontracting, a derived class that specifies contracts for one or more overriding public functions must declare a <computeroutput>typedef</computeroutput> named <computeroutput>base_types</computeroutput> (or <computeroutput><macroname alt="BOOST_CONTRACT_BASES_TYPEDEF">BOOST_CONTRACT_BASES_TYPEDEF</macroname></computeroutput>) using this macro:</para><para><programlisting language="c++">class u
31     #define BASES public b, protected virtual w1, private w2
32     : BASES
33 {
34     friend class boost::contract:access;
35
36     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
37     #undef BASES
38
39     ...
40 };
41 </programlisting></para><para>This <computeroutput>typedef</computeroutput> must be <computeroutput>public</computeroutput> unless <computeroutput><classname alt="boost::contract::access">boost::contract::access</classname></computeroutput> is used.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.base_classes__subcontracting_"> Base Classes</link></para>
42 </para>
43
44 </para></description></macro>
45 </header>
46 <header name="boost/contract/call_if.hpp">
47 <para>Statically disable compilation and execution of functor calls. </para><para><note><para>These facilities allow to emulate C++17 <computeroutput>if constexpr</computeroutput> statements when used together with functor templates (and C++14 generic lambdas). Therefore, they are not useful on C++17 compilers where <computeroutput> if constexpr</computeroutput> can be directly used instead. </para>
48 </note>
49 </para><namespace name="boost">
50 <namespace name="contract">
51 <struct name="call_if_statement"><template>
52       <template-nontype-parameter name="Pred"><type>bool</type><purpose><para>Static boolean predicate that selects which functor template call to compile and execute. </para></purpose></template-nontype-parameter>
53       <template-type-parameter name="Then"><purpose><para>Type of the functor template to call if the static predicate <computeroutput>Pred</computeroutput> is <computeroutput>true</computeroutput>. </para></purpose></template-type-parameter>
54       <template-type-parameter name="ThenResult"><default>internal_type</default><purpose><para>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 <computeroutput>internal_type</computeroutput> in this documentation). </para></purpose></template-type-parameter>
55     </template><purpose>Select compilation and execution of functor template calls using a static boolean predicate (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>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  <computeroutput><functionname alt="boost::contract::call_if">boost::contract::call_if</functionname></computeroutput> and <computeroutput><functionname alt="boost::contract::call_if_c">boost::contract::call_if_c</functionname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
56         Assertion Requirements</link></para>
57 </para>
58
59 </para></description></struct><struct-specialization name="call_if_statement"><template>
60       <template-type-parameter name="Then"><purpose><para>Type of functor template to call when the static predicate is <computeroutput>true</computeroutput> (never the case for this template specialization). </para></purpose></template-type-parameter>
61     </template><specialization><template-arg>false</template-arg><template-arg>Then</template-arg><template-arg>internal_type</template-arg></specialization><purpose>Template specialization to handle static predicates that are <computeroutput>false</computeroutput> (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>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  <computeroutput><functionname alt="boost::contract::call_if">boost::contract::call_if</functionname></computeroutput> and <computeroutput><functionname alt="boost::contract::call_if_c">boost::contract::call_if_c</functionname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
62         Assertion Requirements</link></para>
63 </para>
64
65 </para></description><method-group name="public member functions">
66 <method name="else_" cv="const"><type>result_of&lt; Else()&gt;::type</type><template>
67           <template-type-parameter name="Else"/>
68         </template><parameter name="f"><paramtype>Else</paramtype><description><para>Else-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is actually compiled and executed for this template specialization (because the if-statement static predicate is <computeroutput>false</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.</para></description></parameter><purpose>Specify the else-branch functor template. </purpose><description><para><note><para>The <computeroutput>result_of&lt;Else()&gt;::type</computeroutput> expression needs be evaluated only when the static predicate is already checked to be <computeroutput>false</computeroutput> (because <computeroutput>Else()</computeroutput> is required to compile only in that case). Thus, this result-of expression is evaluated lazily and only in instantiations of this template specialization.</para>
69 </note>
70
71
72 </para></description><returns><para>A copy of the value returned by the call to the else-branch functor template <computeroutput>f()</computeroutput>. </para>
73 </returns></method>
74 <method name="else_if_c" cv="const"><type><classname>call_if_statement</classname>&lt; ElseIfPred, ElseIfThen &gt;</type><template>
75           <template-nontype-parameter name="ElseIfPred"><type>bool</type><purpose><para>Static boolean predicate selecting which functor template call to compile and execute.</para></purpose></template-nontype-parameter>
76           <template-type-parameter name="ElseIfThen"/>
77         </template><parameter name="f"><paramtype>ElseIfThen</paramtype><description><para>Else-if-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is actually compiled and executed if and only if <computeroutput>ElseIfPred</computeroutput> is <computeroutput>true</computeroutput> (because the if-statement static predicate is already <computeroutput>false</computeroutput> for this template specialization). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.</para></description></parameter><purpose>Specify an else-if-branch functor template (using a static boolean predicate). </purpose><description><para>
78
79
80 </para></description><returns><para>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 one functor template call being compiled and executed. </para>
81 </returns></method>
82 <method name="else_if" cv="const"><type><classname>call_if_statement</classname>&lt; ElseIfPred::value, ElseIfThen &gt;</type><template>
83           <template-type-parameter name="ElseIfPred"><purpose><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></purpose></template-type-parameter>
84           <template-type-parameter name="ElseIfThen"/>
85         </template><parameter name="f"><paramtype>ElseIfThen</paramtype><description><para>Else-if-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is actually compiled and executed if and only if <computeroutput>ElseIfPred::value</computeroutput> is <computeroutput>true</computeroutput> (because the if-statement static predicate is already <computeroutput>false</computeroutput> for this template specialization). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.</para></description></parameter><purpose>Specify an else-if-branch functor template (using a nullary boolen meta-function). </purpose><description><para>
86
87
88 </para></description><returns><para>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 one functor template call being compiled and executed. </para>
89 </returns></method>
90 </method-group>
91 <constructor specifiers="explicit"><parameter name="f"><paramtype>Then const &amp;</paramtype><description><para>Then-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is never compiled or executed for this template specialization (because the if-statement static predicate is <computeroutput>false</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object. </para></description></parameter><purpose>Construct this object with the then-branch functor template. </purpose><description><para>
92 </para></description></constructor>
93 </struct-specialization><struct-specialization name="call_if_statement"><template>
94       <template-type-parameter name="Then"><purpose><para>Type of functor template to call when the static predicate is <computeroutput>true</computeroutput> (as it is for this template specialization). </para></purpose></template-type-parameter>
95     </template><specialization><template-arg>true</template-arg><template-arg>Then</template-arg><template-arg>internal_type</template-arg></specialization><inherit access="public">boost::contract::call_if_statement&lt; true, Then, result_of&lt; Then()&gt;::type &gt;</inherit><purpose>Template specialization to dispatch between then-branch functor template calls that return void and the ones that return non-void (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>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  <computeroutput><functionname alt="boost::contract::call_if">boost::contract::call_if</functionname></computeroutput> and <computeroutput><functionname alt="boost::contract::call_if_c">boost::contract::call_if_c</functionname></computeroutput>.</para><para><note><para>The <computeroutput>result_of&lt;Then()&gt;::type</computeroutput> expression needs be evaluated only when the static predicate is already checked to be <computeroutput>true</computeroutput> (because <computeroutput>Then()</computeroutput> 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.</para>
96 </note>
97 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
98         Assertion Requirements</link></para>
99 </para>
100
101 </para></description><method-group name="public member functions">
102 </method-group>
103 <constructor specifiers="explicit"><parameter name="f"><paramtype>Then</paramtype><description><para>Then-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is compiled and called for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object. </para></description></parameter><purpose>Construct this object with the then-branch functor template. </purpose><description><para>
104 </para></description></constructor>
105 </struct-specialization><struct-specialization name="call_if_statement"><template>
106       <template-type-parameter name="Then"><purpose><para>Type of functor template to call when the static predicate is <computeroutput>true</computeroutput> (as it is for this template specialization). </para></purpose></template-type-parameter>
107       <template-type-parameter name="ThenResult"><purpose><para>Non-void return type of the then-branch functor template call. </para></purpose></template-type-parameter>
108     </template><specialization><template-arg>true</template-arg><template-arg>Then</template-arg><template-arg>ThenResult</template-arg></specialization><purpose>Template specialization to handle static predicates that are <computeroutput>true</computeroutput> for then-branch functor template calls that do not return void (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>Usually this class template is instantiated only via the return value of  <computeroutput><functionname alt="boost::contract::call_if">boost::contract::call_if</functionname></computeroutput> and <computeroutput><functionname alt="boost::contract::call_if_c">boost::contract::call_if_c</functionname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
109         Assertion Requirements</link></para>
110 </para>
111
112 </para></description><method-group name="public member functions">
113 <method name="conversion-operator" cv="const"><type>ThenResult</type><purpose>This implicit type conversion returns a copy of the value returned by the call to the then-branch functor template. </purpose></method>
114 <method name="else_" cv="const"><type>ThenResult</type><template>
115           <template-type-parameter name="Else"/>
116         </template><parameter name="f"><paramtype>Else const &amp;</paramtype><description><para>Else-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is never compiled or executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the <computeroutput>ThenResult</computeroutput> type.</para></description></parameter><purpose>Specify the else-branch functor template. </purpose><description><para>
117
118 </para></description><returns><para>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). </para>
119 </returns></method>
120 <method name="else_if_c" cv="const"><type><classname>call_if_statement</classname>&lt; true, Then, ThenResult &gt;</type><template>
121           <template-nontype-parameter name="ElseIfPred"><type>bool</type><purpose><para>Static boolean predicate selecting which functor template call to compile and execute.</para></purpose></template-nontype-parameter>
122           <template-type-parameter name="ElseIfThen"/>
123         </template><parameter name="f"><paramtype>ElseIfThen const &amp;</paramtype><description><para>Else-if-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is never compiled or executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the <computeroutput>ThenResult</computeroutput> type.</para></description></parameter><purpose>Specify an else-if-branch functor template (using a static boolean predicate). </purpose><description><para>
124
125
126 </para></description><returns><para>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 <computeroutput>true</computeroutput>). </para>
127 </returns></method>
128 <method name="else_if" cv="const"><type><classname>call_if_statement</classname>&lt; true, Then, ThenResult &gt;</type><template>
129           <template-type-parameter name="ElseIfPred"><purpose><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></purpose></template-type-parameter>
130           <template-type-parameter name="ElseIfThen"/>
131         </template><parameter name="f"><paramtype>ElseIfThen const &amp;</paramtype><description><para>Else-if-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is never compiled or executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the <computeroutput>ThenResult</computeroutput> type.</para></description></parameter><purpose>Specify an else-if-branch functor template (using a nullary boolean meta-function). </purpose><description><para>
132
133
134 </para></description><returns><para>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 <computeroutput>true</computeroutput>). </para>
135 </returns></method>
136 </method-group>
137 <constructor specifiers="explicit"><parameter name="f"><paramtype>Then</paramtype><description><para>Then-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is actually compiled and executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be the same as (or implicitly convertible to) the <computeroutput>ThenResult</computeroutput> type. </para></description></parameter><purpose>Construct this object with the then-branch functor template. </purpose><description><para>
138 </para></description></constructor>
139 </struct-specialization><struct-specialization name="call_if_statement"><template>
140       <template-type-parameter name="Then"><purpose><para>Type of functor template to call when the static predicate if <computeroutput>true</computeroutput> (as it is for this template specialization). </para></purpose></template-type-parameter>
141     </template><specialization><template-arg>true</template-arg><template-arg>Then</template-arg><template-arg>void</template-arg></specialization><purpose>Template specialization to handle static predicates that are <computeroutput>true</computeroutput> for then-branch functor template calls that return void (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>Usually this class template is instantiated only via the return value of  <computeroutput><functionname alt="boost::contract::call_if">boost::contract::call_if</functionname></computeroutput> and <computeroutput><functionname alt="boost::contract::call_if_c">boost::contract::call_if_c</functionname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
142         Assertion Requirements</link></para>
143 </para>
144
145 </para></description><method-group name="public member functions">
146 <method name="else_" cv="const"><type>void</type><template>
147           <template-type-parameter name="Else"/>
148         </template><parameter name="f"><paramtype>Else const &amp;</paramtype><description><para>Else-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is never compiled or executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be <computeroutput>void</computeroutput> for this template specialization (because the then-branch functor template calls return void). </para></description></parameter><purpose>Specify the else-branch functor template. </purpose><description><para>
149 </para></description></method>
150 <method name="else_if_c" cv="const"><type><classname>call_if_statement</classname>&lt; true, Then, void &gt;</type><template>
151           <template-nontype-parameter name="ElseIfPred"><type>bool</type><purpose><para>Static boolean predicate selecting which functor template call to compile and execute.</para></purpose></template-nontype-parameter>
152           <template-type-parameter name="ElseIfThen"/>
153         </template><parameter name="f"><paramtype>ElseIfThen const &amp;</paramtype><description><para>Else-if-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is never compiled or executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be <computeroutput>void</computeroutput> for this template specialization (because the then-branch functor template calls return void).</para></description></parameter><purpose>Specify an else-if-branch functor template (using a static boolean predicate). </purpose><description><para>
154
155
156 </para></description><returns><para>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). </para>
157 </returns></method>
158 <method name="else_if" cv="const"><type><classname>call_if_statement</classname>&lt; true, Then, void &gt;</type><template>
159           <template-type-parameter name="ElseIfPred"><purpose><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></purpose></template-type-parameter>
160           <template-type-parameter name="ElseIfThen"/>
161         </template><parameter name="f"><paramtype>ElseIfThen const &amp;</paramtype><description><para>Else-if-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is never compiled or executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be <computeroutput>void</computeroutput> for this template specialization (because the then-branch functor template calls return void).</para></description></parameter><purpose>Specify an else-if-branch functor template (using a nullary boolean meta-function). </purpose><description><para>
162
163
164 </para></description><returns><para>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). </para>
165 </returns></method>
166 </method-group>
167 <constructor specifiers="explicit"><parameter name="f"><paramtype>Then</paramtype><description><para>Then-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is actually compiled and executed for this template specialization (because the if-statement static predicate is <computeroutput>true</computeroutput>). The return type of <computeroutput>f()</computeroutput> must be <computeroutput>void</computeroutput> for this template specialization (because the then-branch functor template calls return void). </para></description></parameter><purpose>Construct this object with the then-branch functor template. </purpose><description><para>
168 </para></description></constructor>
169 </struct-specialization><function name="call_if_c"><type><classname>call_if_statement</classname>&lt; Pred, Then &gt;</type><template>
170           <template-nontype-parameter name="Pred"><type>bool</type><purpose><para>Static boolean predicate selecting which functor template call to compile and execute.</para></purpose></template-nontype-parameter>
171           <template-type-parameter name="Then"/>
172         </template><parameter name="f"><paramtype>Then</paramtype><description><para>Then-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is compiled and executed if and only if <computeroutput>Pred</computeroutput> is <computeroutput>true</computeroutput>. 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 <computeroutput>f()</computeroutput>.</para></description></parameter><purpose>Select compilation and execution of functor template calls using a static boolean predicate (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>Create a call-if object with the specified then-branch functor template:</para><para><programlisting language="c++">boost::contract::call_if_c&lt;Pred1&gt;(
173     then_functor_template1
174 ).template else_if_c&lt;Pred2&gt;(            // Optional.
175     then_functor_template2
176 )                                       // Optionally, other `else_if_c` or
177 ...                                     // `else_if`.
178 .else_(                                 // Optional for `void` functors,
179     else_functor_template               // but required for non `void`.
180 )
181 </programlisting></para><para>Optional functor templates for else-if-branches and the else-branch can be specified as needed (the else-branch function template is required if <computeroutput>f</computeroutput> returns non-void).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
182         Assertion Requirements</link></para>
183 </para>
184
185
186
187 </para></description><returns><para>A call-if statement so else and else-if statements can be specified if needed. Eventually, this will be the return value of the one functor template call being compiled and executed (which could also be <computeroutput>void</computeroutput>). </para>
188 </returns></function>
189 <function name="call_if"><type><classname>call_if_statement</classname>&lt; Pred::value, Then &gt;</type><template>
190           <template-type-parameter name="Pred"><purpose><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></purpose></template-type-parameter>
191           <template-type-parameter name="Then"/>
192         </template><parameter name="f"><paramtype>Then</paramtype><description><para>Then-branch nullary functor template. The functor template call <computeroutput>f()</computeroutput> is compiled and executed if and only if <computeroutput>Pred::value</computeroutput> is <computeroutput>true</computeroutput>. 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 <computeroutput>f()</computeroutput>.</para></description></parameter><purpose>Select compilation and execution of functor template calls using a nullary boolean meta-function (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>This is equivalent to <computeroutput>boost::contract::call_if_c&lt;Pred::value&gt;(f)</computeroutput>. Create a call-if object with the specified then-branch functor template:</para><para><programlisting language="c++">boost::contract::call_if&lt;Pred1&gt;(
193     then_functor_template1
194 ).template else_if&lt;Pred2&gt;(              // Optional.
195     then_functor_template2
196 )                                       // Optionally, other `else_if` or
197 ...                                     // `else_if_c`.
198 .else_(                                 // Optional for `void` functors,
199     else_functor_template               // but required for non `void`.
200 )
201 </programlisting></para><para>Optional functor templates for else-if-branches and the else-branch can be specified as needed (the else-branch functor template is required if <computeroutput>f</computeroutput> returns non-void).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
202         Assertion Requirements</link></para>
203 </para>
204
205
206
207 </para></description><returns><para>A call-if statement so else and else-if statements can be specified if needed. Eventually, this will be the return value of the one functor template call being compiled and executed (which could also be <computeroutput>void</computeroutput>). </para>
208 </returns></function>
209 <function name="condition_if_c"><type>bool</type><template>
210           <template-nontype-parameter name="Pred"><type>bool</type><purpose><para>Static boolean predicate selecting when the functor template call <computeroutput>f()</computeroutput> should be compiled and executed. </para></purpose></template-nontype-parameter>
211           <template-type-parameter name="Then"/>
212         </template><parameter name="f"><paramtype>Then</paramtype><description><para>Nullary boolean functor template. The functor template call <computeroutput>f()</computeroutput> is compiled and executed if and only if <computeroutput>Pred</computeroutput> is <computeroutput>true</computeroutput>.</para></description></parameter><parameter name="else_"><paramtype>bool</paramtype><default>true</default><description><para>Boolean value to return when <computeroutput>Pred</computeroutput> is <computeroutput>false</computeroutput> (instead of compiling and executing the functor template call <computeroutput>f()</computeroutput>).</para></description></parameter><purpose>Select compilation and execution of a boolean functor template condition using a static boolean predicate (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>Compile and execute the nullary boolean functor template call <computeroutput>f()</computeroutput> if and only if the specified static boolean predicate <computeroutput>Pred</computeroutput> is <computeroutput>true</computeroutput>, otherwise trivially return <computeroutput>else_</computeroutput> (<computeroutput>true</computeroutput> by default) at run-time.</para><para>A call to <computeroutput>boost::contract::condition_if_c&lt;Pred&gt;(f, else_)</computeroutput> is logically equivalent to <computeroutput>boost::contract::call_if_c&lt;Pred&gt;(f, [] { return else_; })</computeroutput> (but its internal implementation is optimized and it does not actually use <computeroutput>call_if_c</computeroutput>).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
213         Assertion Requirements</link></para>
214 </para>
215
216
217
218
219 </para></description><returns><para>Boolean value returned by <computeroutput>f()</computeroutput> if the static predicate <computeroutput>Pred</computeroutput> is <computeroutput>true</computeroutput>. Otherwise, trivially return <computeroutput>else_</computeroutput>. </para>
220 </returns></function>
221 <function name="condition_if"><type>bool</type><template>
222           <template-type-parameter name="Pred"><purpose><para>Nullary boolean meta-function selecting when the functor template call <computeroutput>f()</computeroutput> should be compiled and executed.</para></purpose></template-type-parameter>
223           <template-type-parameter name="Then"/>
224         </template><parameter name="f"><paramtype>Then</paramtype><description><para>Nullary boolean functor template. The functor template call <computeroutput>f()</computeroutput> is compiled and executed if and only if <computeroutput>Pred::value</computeroutput> is <computeroutput>true</computeroutput>. </para></description></parameter><parameter name="else_"><paramtype>bool</paramtype><default>true</default><description><para>Boolean value to return when <computeroutput>Pred::value</computeroutput> is <computeroutput>false</computeroutput> (instead of compiling and executing the functor template call <computeroutput>f()</computeroutput>).</para></description></parameter><purpose>Select compilation and execution of a boolean functor template condition using a nullary boolean meta-function (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </purpose><description><para>This is equivalent to <computeroutput>boost::contract::condition_if_c&lt;Pred::value&gt;(f, else_)</computeroutput>. Compile and execute the nullary boolean functor template call <computeroutput>f()</computeroutput> if and only if the specified nullary boolean meta-function <computeroutput>Pred::value</computeroutput> is <computeroutput>true</computeroutput>, otherwise trivially return <computeroutput>else_</computeroutput> (<computeroutput>true</computeroutput> by default) at run-time.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
225         Assertion Requirements</link></para>
226 </para>
227
228
229
230 </para></description><returns><para>Boolean value returned by <computeroutput>f()</computeroutput> if the static predicate <computeroutput>Pred::value</computeroutput> is <computeroutput>true</computeroutput>. Otherwise, trivially return <computeroutput>else_</computeroutput>. </para>
231 </returns></function>
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268 </namespace>
269 </namespace>
270 </header>
271 <header name="boost/contract/check.hpp">
272 <para>RAII object that checks contracts. </para><namespace name="boost">
273 <namespace name="contract">
274 <class name="check"><purpose>RAII object that checks the contracts. </purpose><description><para>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  <link linkend="boost_contract.contract_programming_overview"> Contract Programming Overview</link>):</para><para><itemizedlist>
275 <listitem><para>Postconditions are checked only if the body does not throw an exception. </para>
276 </listitem>
277 <listitem><para>Exceptions guarantees are checked only if the body throws an exception. </para>
278 </listitem>
279 <listitem><para>Constructor entry never checks class invariants. </para>
280 </listitem>
281 <listitem><para>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++ and they are implicitly declared <computeroutput>noexcept</computeroutput> since C++11). </para>
282 </listitem>
283 <listitem><para>Static invariants are always checked at entry and exit (and regardless of the body throwing exceptions or not).</para>
284 </listitem>
285 </itemizedlist>
286 When used this way, this object is constructed and initialized to the return value of one of the contract functions <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::constructor">boost::contract::constructor</functionname></computeroutput>, <computeroutput><functionname alt="boost::contract::destructor">boost::contract::destructor</functionname></computeroutput>, or <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput>. In addition to that, this object can be constructed from a nullary functor when it is used to program implementation checks.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial"> Tutorial</link>,  <link linkend="boost_contract.advanced.implementation_checks"> Implementation Checks</link> </para>
287 </para>
288 </para></description><method-group name="public member functions">
289 </method-group>
290 <constructor><template>
291           <template-type-parameter name="F"/>
292         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor that asserts implementation checks. <computeroutput>f()</computeroutput> will be called as soon as this object is constructed at the point it is declared within the implementation code (see  <link linkend="boost_contract.advanced.implementation_checks">
293             Implementation Checks</link>). </para></description></parameter><purpose>Construct this object for implementation checks. </purpose><description><para>This can be used to program checks within implementation code (body, etc.). This constructor is not declared <computeroutput>explicit</computeroutput> so initializations can use assignment syntax <computeroutput>=</computeroutput>.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
294             Throw on Failure</link>).</para><para>
295 </para></description></constructor>
296 <constructor><parameter name="other"><paramtype><classname>check</classname> const &amp;</paramtype><description><para>Copied-from object. </para></description></parameter><purpose>Construct this object copying it from the specified one. </purpose><description><para>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).</para><para>
297 </para></description></constructor>
298 <constructor><template>
299           <template-type-parameter name="VirtualResult"><purpose><para>Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always <computeroutput>void</computeroutput>. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
300         </template><parameter name="contract"><paramtype><classname>specify_precondition_old_postcondition_except</classname>&lt; VirtualResult &gt; const &amp;</paramtype><description><para>Contract to be checked (usually the return value of  <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput> or  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput>).</para></description></parameter><purpose>Construct this object to check the specified contract. </purpose><description><para>This checks class invariants at entry (if those were specified for the given contract). This constructor is not declared <computeroutput>explicit</computeroutput> so initializations can use assignment syntax <computeroutput>=</computeroutput>.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
301             Throw on Failure</link>).</para><para>
302
303 </para></description></constructor>
304 <constructor><template>
305           <template-type-parameter name="VirtualResult"><purpose><para>Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always <computeroutput>void</computeroutput>. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
306         </template><parameter name="contract"><paramtype><classname>specify_old_postcondition_except</classname>&lt; VirtualResult &gt; const &amp;</paramtype><description><para>Contract to be checked (usually the return value of  <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::constructor">boost::contract::constructor</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::destructor">boost::contract::destructor</functionname></computeroutput>, or  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput>).</para></description></parameter><purpose>Construct this object to check the specified contract. </purpose><description><para>This checks class invariants at entry and preconditions (if any of those were specified for the given contract). This constructor is not declared <computeroutput>explicit</computeroutput> so initializations can use assignment syntax <computeroutput>=</computeroutput>.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
307             Throw on Failure</link>).</para><para>
308
309 </para></description></constructor>
310 <constructor><template>
311           <template-type-parameter name="VirtualResult"><purpose><para>Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always <computeroutput>void</computeroutput>. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
312         </template><parameter name="contract"><paramtype><classname>specify_postcondition_except</classname>&lt; VirtualResult &gt; const &amp;</paramtype><description><para>Contract to be checked (usually the return value of  <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::constructor">boost::contract::constructor</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::destructor">boost::contract::destructor</functionname></computeroutput>, or  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput>).</para></description></parameter><purpose>Construct this object to check the specified contract. </purpose><description><para>This checks class invariants at entry and preconditions then it makes old value copies at body (if any of those were specified for the given contract). This constructor is not declared <computeroutput>explicit</computeroutput> so initializations can use assignment syntax <computeroutput>=</computeroutput>.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating te program (see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
313             Throw on Failure</link>).</para><para>
314
315 </para></description></constructor>
316 <constructor><parameter name="contract"><paramtype><classname>specify_except</classname> const &amp;</paramtype><description><para>Contract to be checked (usually the return value of  <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::constructor">boost::contract::constructor</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::destructor">boost::contract::destructor</functionname></computeroutput>, or  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput>).</para></description></parameter><purpose>Construct this object to check the specified contract. </purpose><description><para>This checks class invariants at entry and preconditions then it makes old value copies at body, plus the destructor of this object will also check postconditions in this case (if any of those were specified for the given contract). This constructor is not declared <computeroutput>explicit</computeroutput> so initializations can use assignment syntax <computeroutput>=</computeroutput>.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
317             Throw on Failure</link>).</para><para>
318
319 </para></description></constructor>
320 <constructor><parameter name="contract"><paramtype><classname>specify_nothing</classname> const &amp;</paramtype><description><para>Contract to be checked (usually the return value of  <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::constructor">boost::contract::constructor</functionname></computeroutput>,  <computeroutput><functionname alt="boost::contract::destructor">boost::contract::destructor</functionname></computeroutput>, or  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput>).</para></description></parameter><purpose>Construct this object to check the specified contract. </purpose><description><para>This checks class invariants at entry and preconditions then it makes old value copies at body, plus the destructor of this object will also check postconditions and exception guarantees in this case (if any of those were specified for the given contract). This constructor is not declared <computeroutput>explicit</computeroutput> so initializations can use assignment syntax <computeroutput>=</computeroutput>.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
321             Throw on Failure</link>).</para><para>
322
323 </para></description></constructor>
324 <destructor><purpose>Destruct this object. </purpose><description><para>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 (if class invariants, postconditions, and exception guarantees respectively were specified for the enclosing class and the contract parameter given when constructing this object).</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify contract failure handlers that throw exceptions instead of terminating the program (see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
325             Throw on Failure</link>). (This is declared <computeroutput>noexcept(false)</computeroutput> since C++11.) </para></description></destructor>
326 </class>
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366 </namespace>
367 </namespace>
368 </header>
369 <header name="boost/contract/constructor.hpp">
370 <para>Program contracts for constructors. </para><namespace name="boost">
371 <namespace name="contract">
372
373
374
375
376 <function name="constructor"><type><classname>specify_old_postcondition_except</classname></type><template>
377           <template-type-parameter name="Class"><purpose><para>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.)</para></purpose></template-type-parameter>
378         </template><parameter name="obj"><paramtype>Class *</paramtype><description><para>The object <computeroutput>this</computeroutput> from the scope of the enclosing constructor declaring the contract. (Constructors check all class invariants, including static and volatile invariants, see <link linkend="boost_contract.tutorial.class_invariants">
379             Class Invariants</link> and  <link linkend="boost_contract.extras.volatile_public_functions">
380             Volatile Public Functions</link>).</para></description></parameter><purpose>Program contracts for constructors. </purpose><description><para>This is used to specify postconditions, exception guarantees, old value copies at body, and check class invariants for constructors (see  <computeroutput><classname alt="boost::contract::constructor_precondition">boost::contract::constructor_precondition</classname></computeroutput> to specify preconditions for constructors):</para><para><programlisting language="c++">class u {
381     friend class boost::contract:access;
382
383     void invariant() const { // Optional (as for static and volatile).
384         BOOST_CONTRACT_ASSERT(...);
385         ...
386     }
387
388 public:
389     u(...) {
390         boost::contract::old_ptr&lt;old_type&gt; old_var;
391         boost::contract::check c = boost::contract::constructor(this)
392             // No `.precondition` (use `constructor_precondition` instead).
393             .old([&amp;] { // Optional.
394                 old_var = BOOST_CONTRACT_OLDOF(old_expr);
395                 ...
396             })
397             .postcondition([&amp;] { // Optional.
398                 BOOST_CONTRACT_ASSERT(...);
399                 ...
400             })
401             .except([&amp;] { // Optional.
402                 BOOST_CONTRACT_ASSERT(...);
403                 ...
404             })
405         ;
406
407         ... // Constructor body.
408     }
409
410     ...
411 };
412 </programlisting></para><para>For optimization, this can be omitted for constructors that do not have postconditions and exception guarantees, within classes that have no invariants.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.constructors"> Constructors</link></para>
413 </para>
414
415
416
417 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the constructor body (otherwise this library will generate a run-time error, see <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
418 </returns></function>
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454 </namespace>
455 </namespace>
456 </header>
457 <header name="boost/contract/core/access.hpp">
458 <para>Allow to declare invariants, base types, etc all as private members. </para><namespace name="boost">
459 <namespace name="contract">
460 <class name="access"><purpose>Declare this class as friend to program invariants and base types as private members. </purpose><description><para>Declare this class a friend of the user-defined class specifying the contracts and then invariant functions and the base types <computeroutput>typedef</computeroutput> can be declared as non-public members:</para><para><programlisting language="c++">class u
461     #define BASES public b, private w
462     : BASES
463 {
464     friend class boost::contract::access;
465
466     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types; // Private.
467     #undef BASES
468
469     void invariant() const { ... } // Private (same for static and volatile).
470
471 public:
472     ...
473 };
474 </programlisting></para><para>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 is not extensively done in the examples of this documentation only for brevity). This class is not intended to be directly used by programmers a part from being declared as <computeroutput>friend</computeroutput> (and that is why this class does not have any public member and it is not copyable).</para><para><warning><para>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 or to always declare invariant functions and base types <computeroutput>typedef</computeroutput> as public members.</para>
475 </warning>
476 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.access_specifiers"> Access Specifiers</link> </para>
477 </para>
478 </para></description></class>
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518 </namespace>
519 </namespace>
520 </header>
521 <header name="boost/contract/core/check_macro.hpp">
522 <para>Macros for implementation checks. </para><macro name="BOOST_CONTRACT_CHECK" kind="functionlike"><macro-parameter name="cond"><description><para>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 and <computeroutput>BOOST_CONTRACT_CHECK((cond))</computeroutput> will always work.) </para></description></macro-parameter><purpose>Preferred way to assert implementation check conditions. </purpose><description><para>It is preferred to use this macro instead of programming implementation checks in a nullary functor passed to <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> constructor because this macro will completely remove implementation checks from the code when <computeroutput><macroname alt="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</macroname></computeroutput> is defined:</para><para><programlisting language="c++">void f() {
523     ...
524     BOOST_CONTRACT_CHECK(cond);
525     ...
526 }
527 </programlisting></para><para> <computeroutput><macroname alt="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</macroname></computeroutput> are the three assertion levels predefined by this library for implementation checks.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.implementation_checks"> Implementation Checks</link></para>
528 </para>
529
530 </para></description></macro>
531 <macro name="BOOST_CONTRACT_CHECK_AUDIT" kind="functionlike"><macro-parameter name="cond"><description><para>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 and <computeroutput>BOOST_CONTRACT_CHECK_AUDIT((cond))</computeroutput> will always work.) </para></description></macro-parameter><purpose>Preferred way to assert implementation check conditions that are computationally expensive, at least compared to the computational cost of executing the function body. </purpose><description><para>The specified condition will always be compiled and validated syntactically, but it will not be checked at run-time unless  <computeroutput><macroname alt="BOOST_CONTRACT_AUDITS">BOOST_CONTRACT_AUDITS</macroname></computeroutput> is defined (undefined by default). This macro is defined by code equivalent to:</para><para><programlisting language="c++">#ifdef BOOST_CONTRACT_AUDITS
532     #define BOOST_CONTRACT_CHECK_AUDIT(cond) \
533         BOOST_CONTRACT_CHECK(cond)
534 #else
535     #define BOOST_CONTRACT_CHECK_AUDIT(cond) \
536         BOOST_CONTRACT_CHECK(true || cond)
537 #endif
538 </programlisting></para><para> <computeroutput><macroname alt="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</macroname></computeroutput> 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.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_levels"> Assertion Levels</link></para>
539 </para>
540
541 </para></description></macro>
542 <macro name="BOOST_CONTRACT_CHECK_AXIOM" kind="functionlike"><macro-parameter name="cond"><description><para>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 and <computeroutput>BOOST_CONTRACT_CHECK_AXIOM((cond))</computeroutput> will always work.) </para></description></macro-parameter><purpose>Preferred way to document in the code implementation check conditions that are computationally prohibitive, at least compared to the computational cost of executing the function body. </purpose><description><para>The specified 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:</para><para><programlisting language="c++">#define BOOST_CONTRACT_CHECK_AXIOM(cond) \
543     BOOST_CONTRACT_CHECK(true || cond)
544 </programlisting></para><para> <computeroutput><macroname alt="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</macroname></computeroutput> 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.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_levels"> Assertion Levels</link></para>
545 </para>
546
547 </para></description></macro>
548 </header>
549 <header name="boost/contract/core/config.hpp">
550 <para>Configure this library compile-time and run-time behaviours. </para><macro name="BOOST_CONTRACT_DYN_LINK"><purpose>Define this macro to compile this library as a shared library (recommended). </purpose><description><para>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. This library will automatically define this macro when Boost libraries are built as shared libraries (e.g., defining <computeroutput>BOOST_ALL_DYN_LINK</computeroutput> or using <computeroutput>bjam link=shared ...</computeroutput>).</para><para><warning><para>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). Therefore, it is recommended to build and use this library as a shared library by defining this macro (or equivalently by building all Boost libraries as shared libraries).</para>
551 </warning>
552 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.getting_started"> Getting Started</link> </para>
553 </para>
554 </para></description></macro>
555 <macro name="BOOST_CONTRACT_STATIC_LINK"><purpose>Define this macro to compile this library as a static library (not recommended). </purpose><description><para>If this macro is defined, this library is compiled so it can be linked statically to user code. This library will automatically define this macro when Boost libraries are built as static libraries.</para><para><warning><para>This library is not guaranteed to always work correctly at run-time when this macro is defined (define  <computeroutput><macroname alt="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</macroname></computeroutput> or <computeroutput>BOOST_ALL_DYN_LINK</computeroutput> 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).</para>
556 </warning>
557 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.getting_started"> Getting Started</link> </para>
558 </para>
559 </para></description></macro>
560 <macro name="BOOST_CONTRACT_HEADER_ONLY"><purpose>Automatically defined by this library when it is being used as a header-only library (not recommended). </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users do not define  <computeroutput><macroname alt="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</macroname></computeroutput> (or <computeroutput>BOOST_ALL_DYN_LINK</computeroutput>) and  <computeroutput><macroname alt="BOOST_CONTRACT_STATIC_LINK">BOOST_CONTRACT_STATIC_LINK</macroname></computeroutput>. 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.</para><para><warning><para>This library is not guaranteed to always work correctly at run-time when this macro is defined (define  <computeroutput><macroname alt="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</macroname></computeroutput> or <computeroutput>BOOST_ALL_DYN_LINK</computeroutput> 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).</para>
561 </warning>
562 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.getting_started"> Getting Started</link> </para>
563 </para>
564 </para></description></macro>
565 <macro name="BOOST_CONTRACT_DISABLE_THREADS"><purpose>Define this macro to not lock internal library data for thread safety (undefined by default). </purpose><description><para>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 <computeroutput>BOOST_DISABLE_THREADS</computeroutput>).</para><para><note><para>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.</para>
566 </note>
567 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.contract_programming_overview.assertions"> Assertions</link> </para>
568 </para>
569 </para></description></macro>
570 <macro name="BOOST_CONTRACT_MAX_ARGS"><purpose>Maximum number of arguments for public function overrides on compilers that do not support variadic templates (default to <computeroutput>10</computeroutput>). </purpose><description><para>On compilers that do not support C++11 variadic templates, this macro is defined to the maximum number of arguments that public function overrides can have and pass to <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> (users can redefine this macro to a different value). On compilers that support variadic templates, this macro has no effect.</para><para><note><para>Regardless of the value of this macro and of compiler support for variadic templates, there might be 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).</para>
571 </note>
572 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link> </para>
573 </para>
574 </para></description></macro>
575 <macro name="BOOST_CONTRACT_BASES_TYPEDEF"><purpose>Define the name of the base type <computeroutput>typedef</computeroutput> (<computeroutput>base_types</computeroutput> by default). </purpose><description><para>This macro expands to the name of the <computeroutput>typedef</computeroutput> that lists the base classes for subcontracting via <computeroutput><macroname alt="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</macroname></computeroutput>:</para><para><programlisting language="c++">class u
576     #define BASES public b, private w
577     : BASES
578 {
579     friend class boost::contract:access;
580
581     typedef BOOST_CONTRACT_BASE_TYPES(BASES) BOOST_CONTRACT_TYPEDEF;
582     #undef BASES
583
584     ...
585 };
586 </programlisting></para><para>When used this way, users can redefine this macro if the <computeroutput>typedef</computeroutput> must have a name different from <computeroutput>base_types</computeroutput> (because of name clashes in user code, etc.).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.base_classes__subcontracting_"> Base Classes</link> </para>
587 </para>
588 </para></description></macro>
589 <macro name="BOOST_CONTRACT_INVARIANT_FUNC"><purpose>Define the name of the class invariant member function (<computeroutput>invariant</computeroutput> by default). </purpose><description><para>This macro expands to the name of the <computeroutput>const</computeroutput> and <computeroutput>const volatile</computeroutput> member functions that check class invariants and volatile class invariants respectively:</para><para><programlisting language="c++">class u {
590     friend class boost::contract::access;
591
592     void BOOST_CONTRACT_INVARIANT_FUNC() const {
593         BOOST_CONTRACT_ASSERT(...);
594         ...
595     }
596     
597     void BOOST_CONTRACT_INVARIANT_FUNC() const volatile {
598         BOOST_CONTRACT_ASSERT(...);
599         ...
600     }
601
602     ...
603 };
604 </programlisting></para><para>When used this way, users can redefine this macro if the invariant functions must have a name different from <computeroutput>invariant</computeroutput> (because of name clashes in user code, etc.).</para><para><note><para>C++ does not allow to overload member functions based on the <computeroutput>static</computeroutput> classifier, so this macro must always be defined to be different than the function name defined for  <computeroutput><macroname alt="BOOST_CONTRACT_STATIC_INVARIANT_FUNC">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</macroname></computeroutput>.</para>
605 </note>
606 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
607         Volatile Public Functions</link> </para>
608 </para>
609 </para></description></macro>
610 <macro name="BOOST_CONTRACT_STATIC_INVARIANT_FUNC"><purpose>Define the name of the static invariant member function (<computeroutput>static_invariant</computeroutput> by default). </purpose><description><para>This macro expands to the name of the <computeroutput>static</computeroutput> member function that checks static class invariants:</para><para><programlisting language="c++">class u {
611     friend class boost::contract::access;
612
613     static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() {
614         BOOST_CONTRACT_ASSERT(...);
615         ...
616     }
617
618     ...
619 };
620 </programlisting></para><para>When used this way, users can redefine this macro if the static invariant function must have a name different from <computeroutput>static_invariant</computeroutput> (because of name clashes in user code, etc.).</para><para><note><para>C++ does not allow to overload member functions based on the <computeroutput>static</computeroutput> classifier, so this macro must always be defined to be different than the function name defined for  <computeroutput><macroname alt="BOOST_CONTRACT_INVARIANT_FUNC">BOOST_CONTRACT_INVARIANT_FUNC</macroname></computeroutput>.</para>
621 </note>
622 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link> </para>
623 </para>
624 </para></description></macro>
625 <macro name="BOOST_CONTRACT_PERMISSIVE"><purpose>Disable some compile-time errors generated by this library (undefined by default). </purpose><description><para>Defining this macro disables a number of static checks and related compile-time errors generated by this library, for example:</para><para><itemizedlist>
626 <listitem><para>The static invariant member function named as <computeroutput>BOOST_CONTRACT_STATIC_INVARIANT_FUNC</computeroutput> must be declared <computeroutput>static</computeroutput>. </para>
627 </listitem>
628 <listitem><para>Non-static invariant member functions named as <computeroutput>BOOST_CONTRACT_INVARIANT_FUNC</computeroutput> must be declared either <computeroutput>const</computeroutput>, <computeroutput>const volatile</computeroutput>, or <computeroutput>volatile const</computeroutput>. </para>
629 </listitem>
630 <listitem><para>Derived classes that program contracts for one or more public function overrides via <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> must also define the <computeroutput><macroname alt="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</macroname></computeroutput> <computeroutput>typedef</computeroutput>.</para>
631 </listitem>
632 </itemizedlist>
633 In general, it is not recommended to define this macro because these compile-time checks can guard against misuses of this library.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.tutorial.base_classes__subcontracting_"> Base Classes</link> </para>
634 </para>
635 </para></description></macro>
636 <macro name="BOOST_CONTRACT_ON_MISSING_CHECK_DECL"><purpose>Code block to execute if contracts are not assigned to a  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> variable (undefined and executes <computeroutput>BOOST_ASSERT(false)</computeroutput> by default). </purpose><description><para>In general, there is a logic error in the program when contracts are not explicitly assigned to a local variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> and without using C++11 <computeroutput>auto</computeroutput> declarations (because that is a misuse of this library). Therefore, by default (i.e., when this macro is not defined) this library calls <computeroutput>BOOST_ASSERT(false)</computeroutput> in those cases. If this macro is defined, this library will execute the code expanded by this macro instead of calling <computeroutput>BOOST_ASSERT(false)</computeroutput> (if programmers prefer to throw an exception, etc.).</para><para>This macro can also be defined to be any block of code (and use empty curly brackets <computeroutput>{}</computeroutput> to generate no error, not recommended), for example (on GCC): <programlisting language="c++">gcc -DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }' ...
637 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial"> Tutorial</link> </para>
638 </para>
639 </para></description></macro>
640 <macro name="BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION"><purpose>Define this macro to not disable other assertions while checking preconditions (undefined by default). </purpose><description><para>Not disabling other assertions while checking preconditions can lead to infinite recursion in user code so by default this macro is not defined.</para><para>However, the <link linkend="boost_contract.bibliography"> [N1962]</link> 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  <link linkend="boost_contract.bibliography"> [N1962]</link> (at the risk of infinite recursion).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.contract_programming_overview.feature_summary">
641         Feature Summary</link> </para>
642 </para>
643 </para></description></macro>
644 <macro name="BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION"><purpose>Define this macro to not disable any assertion while checking other assertions (undefined by default). </purpose><description><para>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  <computeroutput><macroname alt="BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION">BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</macroname></computeroutput> was also defined.)</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.contract_programming_overview.feature_summary">
645         Feature Summary</link> </para>
646 </para>
647 </para></description></macro>
648 <macro name="BOOST_CONTRACT_AUDITS"><purpose>Define this macro to evaluate and check audit assertions at run-time (undefined by default). </purpose><description><para>Audit assertions and implementation checks programmed via  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT_AUDIT">BOOST_CONTRACT_ASSERT_AUDIT</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</macroname></computeroutput> 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 computational cost of executing the function body).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_levels"> Assertion Levels</link> </para>
649 </para>
650 </para></description></macro>
651 <macro name="BOOST_CONTRACT_NO_CHECKS"><purpose>If defined, this library disables implementation checks (undefined by default). </purpose><description><para>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. In addition, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of implementation checks or use <computeroutput><macroname alt="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</macroname></computeroutput> (recommended).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.implementation_checks">
652         Implementation Checks</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
653         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
654         Disable Contract Compilation</link> </para>
655 </para>
656 </para></description></macro>
657 <macro name="BOOST_CONTRACT_NO_PRECONDITIONS"><purpose>If defined, this library does not check preconditions (undefined by default). </purpose><description><para>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. In addition, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of preconditions or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
658         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
659         Disable Contract Compilation</link> </para>
660 </para>
661 </para></description></macro>
662 <macro name="BOOST_CONTRACT_NO_POSTCONDITIONS"><purpose>If defined, this library does not check postconditions (undefined by default). </purpose><description><para>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. In addition, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of postconditions or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para>It is necessary to disable both postconditions and exception guarantees defining <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput> in order to disable old value copies (see <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput>).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
663         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
664         Disable Contract Compilation</link> </para>
665 </para>
666 </para></description></macro>
667 <macro name="BOOST_CONTRACT_NO_EXCEPTS"><purpose>If defined, this library does not check exception guarantees (undefined by default). </purpose><description><para>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. In addition, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of exception guarantees or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para>It is necessary to disable both postconditions and exception guarantees defining <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput> in order to disable old value copies (see <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput>).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
668         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
669         Disable Contract Compilation</link> </para>
670 </para>
671 </para></description></macro>
672 <macro name="BOOST_CONTRACT_NO_ENTRY_INVARIANTS"><purpose>If defined, this library does not check class invariants at entry (undefined by default). </purpose><description><para>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. In addition, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of entry class invariants or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para>This macro is automatically defined when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput> is defined.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
673         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
674         Disable Contract Compilation</link> </para>
675 </para>
676 </para></description></macro>
677 <macro name="BOOST_CONTRACT_NO_EXIT_INVARIANTS"><purpose>If defined, this library does not check class invariants at exit (undefined by default). </purpose><description><para>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. In addition, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of exit class invariants or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para>This macro is automatically defined when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput> is defined.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
678         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
679         Disable Contract Compilation</link> </para>
680 </para>
681 </para></description></macro>
682 <macro name="BOOST_CONTRACT_NO_INVARIANTS"><purpose>If defined, this library does not check class invariants (undefined by default). </purpose><description><para>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. In addition, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of class invariants or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para>Defining this macro is equivalent to defining both  <computeroutput><macroname alt="BOOST_CONTRACT_NO_ENTRY_INVARIANTS">BOOST_CONTRACT_NO_ENTRY_INVARIANTS</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXIT_INVARIANTS">BOOST_CONTRACT_NO_EXIT_INVARIANTS</macroname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
683         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
684         Disable Contract Compilation</link> </para>
685 </para>
686 </para></description></macro>
687 <macro name="BOOST_CONTRACT_NO_OLDS"><purpose>Automatically defined by this library when old value copies are not to be performed. </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define both  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput>. Users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of old value copies or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.old_values"> Old Values</link>,  <link linkend="boost_contract.advanced.old_values_copied_at_body">
688         Old Values Copied at Body</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
689         Disable Contract Compilation</link> </para>
690 </para>
691 </para></description></macro>
692 <macro name="BOOST_CONTRACT_NO_CONSTRUCTORS"><purpose>Automatically defined by this library when contracts are not checked for constructors. </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput>. Users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of contracts for constructors or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para><note><para>Constructor preconditions are checked separately by  <computeroutput><classname alt="boost::contract::constructor_precondition">boost::contract::constructor_precondition</classname></computeroutput> so they are disabled by <computeroutput><macroname alt="BOOST_CONTRACT_NO_PRECONDITIONS">BOOST_CONTRACT_NO_PRECONDITIONS</macroname></computeroutput> instead.</para>
693 </note>
694 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.constructors"> Constructors</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
695         Disable Contract Compilation</link> </para>
696 </para>
697 </para></description></macro>
698 <macro name="BOOST_CONTRACT_NO_DESTRUCTORS"><purpose>Automatically defined by this library when contracts are not checked for destructors. </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput>. Users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of contracts for destructors or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.destructors"> Destructors</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
699         Disable Contract Compilation</link> </para>
700 </para>
701 </para></description></macro>
702 <macro name="BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS"><purpose>Automatically defined by this library when contracts are not checked for public functions. </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PRECONDITIONS">BOOST_CONTRACT_NO_PRECONDITIONS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput>. Users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of contracts for public functions or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.public_functions"> Public Functions</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
703         Disable Contract Compilation</link> </para>
704 </para>
705 </para></description></macro>
706 <macro name="BOOST_CONTRACT_NO_FUNCTIONS"><purpose>Automatically defined by this library when contracts are not checked for non-member, private, or protected functions. </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PRECONDITIONS">BOOST_CONTRACT_NO_PRECONDITIONS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput>. Users can manually program <computeroutput>#ifndef</computeroutput> 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 <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para>This macro is also used when contracts are not checked for private or protected functions, lambda functions, code blocks, loops, etc.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.non_member_functions"> Non-Member Functions</link>,  <link linkend="boost_contract.advanced.private_and_protected_functions">
707         Private and Protected Functions</link>,  <link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">
708         Lambdas, Loops, Code Blocks</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
709         Disable Contract Compilation</link> </para>
710 </para>
711 </para></description></macro>
712 <macro name="BOOST_CONTRACT_NO_CONDITIONS"><purpose>Automatically defined by this library when contracts are not checked for preconditions, postconditions, exceptions guarantees, and class invariants (excluding implementation checks). </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PRECONDITIONS">BOOST_CONTRACT_NO_PRECONDITIONS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput>. Users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to completely disable compilation of contracts within specifications (so excluding implementation checks which are contracts within implementations instead), or use the macros defined in <computeroutput>boost/contract_macro.hpp</computeroutput> (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
713         Disable Contract Compilation</link> </para>
714 </para>
715 </para></description></macro>
716 <macro name="BOOST_CONTRACT_NO_ALL"><purpose>Automatically defined by this library when contracts are not checked at all (neither for specifications nor for implementations). </purpose><description><para>This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PRECONDITIONS">BOOST_CONTRACT_NO_PRECONDITIONS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</macroname></computeroutput>. For example, users can manually program <computeroutput>#ifndef</computeroutput> statements in their code using this macro to avoid including the <computeroutput>boost/contract.hpp</computeroutput> header all together:</para><para><programlisting language="c++">#include &lt;boost/contract/core/config.hpp&gt;
717 #ifndef BOOST_CONTRACT_NO_ALL
718     #include &lt;boost/contract.hpp&gt;
719 #endif
720 </programlisting></para><para>Or, use the <computeroutput>boost/contract_macro.hpp</computeroutput> header and related macros instead (because the <computeroutput>boost/contract_macro.hpp</computeroutput> 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).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
721         Disable Contract Compilation</link> </para>
722 </para>
723 </para></description></macro>
724 </header>
725 <header name="boost/contract/core/constructor_precondition.hpp">
726 <para>Program preconditions for constructors. </para><namespace name="boost">
727 <namespace name="contract">
728 <class name="constructor_precondition"><template>
729       <template-type-parameter name="Class"><purpose><para>The class type of the constructor for which preconditions are being programmed. </para></purpose></template-type-parameter>
730     </template><purpose>Program preconditions for constructors. </purpose><description><para>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):</para><para><programlisting language="c++">class u
731     #define BASES private boost::contract::constructor_precondition&lt;u&gt;, \
732             public b
733     : BASES
734 {
735     friend class boost::contract::access;
736
737     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
738     #undef BASES
739
740 public:
741     explicit u(unsigned x) :
742         boost::contract::constructor_precondition&lt;u&gt;([&amp;] {
743             BOOST_CONTRACT_ASSERT(x != 0);
744             ...
745         }),
746         b(1.0 / float(x))
747     {
748         ...
749     }
750
751     ...
752 };
753 </programlisting></para><para>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).</para><para>This class cannot be used this way in a <computeroutput>union</computeroutput> because unions cannot have base classes in C++. Instead, this class is used in a <computeroutput>union</computeroutput> to declare a local object within the constructor definition just before <computeroutput><functionname alt="boost::contract::constructor">boost::contract::constructor</functionname></computeroutput> is used (see <link linkend="boost_contract.extras.unions"> Unions</link>).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.constructors"> Constructors</link></para>
754 </para>
755
756 </para></description><method-group name="public member functions">
757 </method-group>
758 <constructor><purpose>Construct this object without specifying constructor preconditions. </purpose><description><para>This is implicitly called for those constructors of the contracted class that do not specify preconditions.</para><para><note><para>The implementation of this library is optimized so that calling this default constructor should amount to negligible compile-time and run-time overheads (likely to be optimized away completely by most compilers). </para>
759 </note>
760 </para></description></constructor>
761 <constructor specifiers="explicit"><template>
762           <template-type-parameter name="F"/>
763         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library to check constructor preconditions <computeroutput>f()</computeroutput>. Assertions within this functor call are usually programmed using <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::precondition_failure">boost::contract::precondition_failure</functionname></computeroutput>). This functor should capture variables by (constant) value, or better by (constant) reference to avoid extra copies. </para></description></parameter><purpose>Construct this object specifying constructor preconditions. </purpose><description><para>
764 </para></description></constructor>
765 </class>
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805 </namespace>
806 </namespace>
807 </header>
808 <header name="boost/contract/core/exception.hpp">
809 <para>Handle contract assertion failures. </para><namespace name="boost">
810 <namespace name="contract">
811 <class name="assertion_failure"><inherit access="public">std::exception</inherit><inherit access="public">boost::contract::exception</inherit><purpose>Exception typically used to report a contract assertion failure. </purpose><description><para>This exception is thrown by code expanded by <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput> (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 when handling contract assertion failures).</para><para>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 ( <computeroutput><functionname alt="boost::contract::precondition_failure">boost::contract::precondition_failure</functionname></computeroutput>, etc.) when this or any other exception is thrown while checking contracts (by default, these failure handler functions print an error message to <computeroutput>std::cerr</computeroutput> and terminate the program, but they can be customized to take any other action).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link> </para>
812 </para>
813 </para></description><method-group name="public member functions">
814 <method name="what" cv="const" specifiers="virtual"><type>char const  *</type><purpose>String describing the failed assertion. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
815 </para></description><returns><para>A string formatted similarly to the following: <computeroutput>assertion "`code()`" failed: file "`file()`", line `line()`</computeroutput> (where `` indicate execution quotes). File, line, and code will be omitted from this string if they were not specified when constructing this object. </para>
816 </returns></method>
817 <method name="file" cv="const"><type>char const  *</type><purpose>Name of the file containing the assertion. </purpose><description><para>
818 </para></description><returns><para>File name as specified at construction (or <computeroutput>""</computeroutput> if no file was specified). </para>
819 </returns></method>
820 <method name="line" cv="const"><type>unsigned long</type><purpose>Number of the line containing the assertion. </purpose><description><para>
821 </para></description><returns><para>Line number as specified at construction (or <computeroutput>0</computeroutput> if no line number was specified). </para>
822 </returns></method>
823 <method name="code" cv="const"><type>char const  *</type><purpose>Text listing the source code of the assertion condition. </purpose><description><para>
824 </para></description><returns><para>Assertion condition source code as specified at construction (or <computeroutput>""</computeroutput> if no source code text was specified). </para>
825 </returns></method>
826 </method-group>
827 <constructor specifiers="explicit"><parameter name="file"><paramtype>char const *</paramtype><default>""</default><description><para>Name of the file containing the assertion (usually set using <computeroutput>__FILE__</computeroutput>). </para></description></parameter><parameter name="line"><paramtype>unsigned long</paramtype><default>0</default><description><para>Number of the line containing the assertion (usually set using <computeroutput>__LINE__</computeroutput>). </para></description></parameter><parameter name="code"><paramtype>char const *</paramtype><default>""</default><description><para>Text listing the source code of the assertion condition. </para></description></parameter><purpose>Construct this object with file name, line number, and source code text of an assertion condition (all optional). </purpose><description><para>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).</para><para>
828 </para></description></constructor>
829 <constructor specifiers="explicit"><parameter name="code"><paramtype>char const *</paramtype><description><para>Text listing the source code of the assertion condition. </para></description></parameter><purpose>Construct this object only with the source code text of the assertion condition. </purpose><description><para>
830 </para></description></constructor>
831 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></description></destructor>
832 </class><class name="bad_virtual_result_cast"><inherit access="public">std::bad_cast</inherit><inherit access="public">boost::contract::exception</inherit><purpose>Exception thrown when inconsistent return values are passed to overridden virtual public functions. </purpose><description><para>This exception is thrown when programmers pass to this library return value parameters for public function overrides in derived classes that are not consistent with the return type parameter passed for the virtual public function being overridden from the base classes. This allows this library to give more descriptive error messages in such cases of misuse.</para><para>This exception is internally thrown by this library and programmers should not need to throw it from user code.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
833         Public Function Overrides</link> </para>
834 </para>
835 </para></description><method-group name="public member functions">
836 <method name="what" cv="const" specifiers="virtual"><type>char const  *</type><purpose>Description for this error (containing both from- and to- type names). </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></description></method>
837 </method-group>
838 <constructor specifiers="explicit"><parameter name="from_type_name"><paramtype>char const *</paramtype><description><para>Name of the from-type (source of the cast). </para></description></parameter><parameter name="to_type_name"><paramtype>char const *</paramtype><description><para>Name of the to-type (destination of the cast). </para></description></parameter><purpose>Construct this object with the name of the from- and to- result types. </purpose><description><para>
839 </para></description></constructor>
840 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></description></destructor>
841 </class><class name="exception"><purpose>Public base class for all exceptions directly thrown by this library. </purpose><description><para>This class does not inherit from <computeroutput>std::exception</computeroutput> because exceptions deriving from this class will do that (inheriting from <computeroutput>std::exception</computeroutput>, <computeroutput>std::bad_cast</computeroutput>, etc.).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <computeroutput><classname alt="boost::contract::assertion_failure">boost::contract::assertion_failure</classname></computeroutput>,  <computeroutput><classname alt="boost::contract::bad_virtual_result_cast">boost::contract::bad_virtual_result_cast</classname></computeroutput>, etc. </para>
842 </para>
843 </para></description><method-group name="public member functions">
844 </method-group>
845 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></description></destructor>
846 </class><enum name="from"><enumvalue name="from_constructor"><purpose>Assertion failed when checking contracts for constructors. </purpose></enumvalue><enumvalue name="from_destructor"><purpose>Assertion failed when checking contracts for destructors . </purpose></enumvalue><enumvalue name="from_function"><purpose>Assertion failed when checking contracts for functions (members or not, public or not). </purpose></enumvalue><purpose>Indicate the kind of operation where the contract assertion failed. </purpose><description><para>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.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link> </para>
847 </para>
848 </para></description></enum>
849 <typedef name="from_failure_handler"><purpose>Type of assertion failure handler functions (with <computeroutput>from</computeroutput> parameter). </purpose><description><para>Assertion failure handler functions specified by this type must be functors returning <computeroutput>void</computeroutput> and taking a single parameter of type  <computeroutput><enumname alt="boost::contract::from">boost::contract::from</enumname></computeroutput>. For example, this is used to specify contract failure handlers for class invariants, preconditions, postconditions, and exception guarantees.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link> </para>
850 </para>
851 </para></description><type>boost::function&lt; void(from)&gt;</type></typedef>
852 <typedef name="failure_handler"><purpose>Type of assertion failure handler functions (without <computeroutput>from</computeroutput> parameter). </purpose><description><para>Assertion failure handler functions specified by this type must be nullary functors returning <computeroutput>void</computeroutput>. For example, this is used to specify contract failure handlers for implementation checks.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link> </para>
853 </para>
854 </para></description><type>boost::function&lt; void()&gt;</type></typedef>
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873 <function name="set_check_failure"><type>failure_handler const  &amp;</type><parameter name="f"><paramtype>failure_handler const &amp;</paramtype><description><para>New failure handler functor to set.</para></description></parameter><purpose>Set failure handler for implementation checks. </purpose><description><para>Set a new failure handler and returns it.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
874
875 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.advanced.implementation_checks"> Implementation Checks</link> </para>
876 </para>
877 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
878 </returns></function>
879 <function name="get_check_failure"><type>failure_handler</type><purpose>Return failure handler currently set for implementation checks. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
880 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.advanced.implementation_checks"> Implementation Checks</link> </para>
881 </para>
882 </para></description><returns><para>A copy of the failure handler currently set.</para>
883 </returns></function>
884 <function name="check_failure"><type>void</type><purpose>Call failure handler for implementation checks. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify a failure handler that throws exceptions on implementation check failures (not the default).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.advanced.implementation_checks"> Implementation Checks</link> </para>
885 </para>
886 </para></description></function>
887 <function name="set_precondition_failure"><type>from_failure_handler const  &amp;</type><parameter name="f"><paramtype>from_failure_handler const &amp;</paramtype><description><para>New failure handler functor to set.</para></description></parameter><purpose>Set failure handler for preconditions. </purpose><description><para>Set a new failure handler and returns it.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
888
889 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link> </para>
890 </para>
891 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
892 </returns></function>
893 <function name="get_precondition_failure"><type>from_failure_handler</type><purpose>Return failure handler currently set for preconditions. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
894 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link> </para>
895 </para>
896 </para></description><returns><para>A copy of the failure handler currently set.</para>
897 </returns></function>
898 <function name="precondition_failure"><type>void</type><parameter name="where"><paramtype>from</paramtype><description><para>Operation that failed the contract assertion (when this function is called by this library, this parameter will never be <computeroutput>from_destructor</computeroutput> because destructors do not have preconditions).</para></description></parameter><purpose>Call failure handler for preconditions. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).</para><para>
899 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link> </para>
900 </para>
901 </para></description></function>
902 <function name="set_postcondition_failure"><type>from_failure_handler const  &amp;</type><parameter name="f"><paramtype>from_failure_handler const &amp;</paramtype><description><para>New failure handler functor to set.</para></description></parameter><purpose>Set failure handler for postconditions. </purpose><description><para>Set a new failure handler and returns it.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
903
904 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link> </para>
905 </para>
906 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
907 </returns></function>
908 <function name="get_postcondition_failure"><type>from_failure_handler</type><purpose>Return failure handler currently set for postconditions. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
909 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link> </para>
910 </para>
911 </para></description><returns><para>A copy of the failure handler currently set.</para>
912 </returns></function>
913 <function name="postcondition_failure"><type>void</type><parameter name="where"><paramtype>from</paramtype><description><para>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).</para></description></parameter><purpose>Call failure handler for postconditions. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).</para><para>
914 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link> </para>
915 </para>
916 </para></description></function>
917 <function name="set_except_failure"><type>from_failure_handler const  &amp;</type><parameter name="f"><paramtype>from_failure_handler const &amp;</paramtype><description><para>New failure handler functor to set.</para></description></parameter><purpose>Set failure handler for exception guarantees. </purpose><description><para>Set a new failure handler and returns it.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
918
919 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link> </para>
920 </para>
921 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
922 </returns></function>
923 <function name="get_except_failure"><type>from_failure_handler</type><purpose>Return failure handler currently set for exception guarantees. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
924 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link> </para>
925 </para>
926 </para></description><returns><para>A copy of the failure handler currently set.</para>
927 </returns></function>
928 <function name="except_failure"><type>void</type><parameter name="where"><paramtype>from</paramtype><description><para>Operation that failed the contract assertion.</para></description></parameter><purpose>Call failure handler for exception guarantees. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default), however:</para><para><warning><para>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.</para>
929 </warning>
930
931 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link> </para>
932 </para>
933 </para></description></function>
934 <function name="set_old_failure"><type>from_failure_handler const  &amp;</type><parameter name="f"><paramtype>from_failure_handler const &amp;</paramtype><description><para>New failure handler functor to set.</para></description></parameter><purpose>Set failure handler for old values copied at body. </purpose><description><para>Set a new failure handler and returns it.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
935
936 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.advanced.old_values_copied_at_body"> Old Values Copied at Body</link> </para>
937 </para>
938 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
939 </returns></function>
940 <function name="get_old_failure"><type>from_failure_handler</type><purpose>Return failure handler currently set for old values copied at body. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
941 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.advanced.old_values_copied_at_body"> Old Values Copied at Body</link> </para>
942 </para>
943 </para></description><returns><para>A copy of the failure handler currently set.</para>
944 </returns></function>
945 <function name="old_failure"><type>void</type><parameter name="where"><paramtype>from</paramtype><description><para>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).</para></description></parameter><purpose>Call failure handler for old values copied at body. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).</para><para>
946 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.advanced.old_values_copied_at_body"> Old Values Copied at Body</link> </para>
947 </para>
948 </para></description></function>
949 <function name="set_entry_invariant_failure"><type>from_failure_handler const  &amp;</type><parameter name="f"><paramtype>from_failure_handler const &amp;</paramtype><description><para>New failure handler functor to set.</para></description></parameter><purpose>Set failure handler for class invariants at entry. </purpose><description><para>Set a new failure handler and returns it.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
950
951 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
952         Volatile Public Functions</link> </para>
953 </para>
954 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
955 </returns></function>
956 <function name="get_entry_invariant_failure"><type>from_failure_handler</type><purpose>Return failure handler currently set for class invariants at entry. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
957 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
958         Volatile Public Functions</link> </para>
959 </para>
960 </para></description><returns><para>A copy of the failure handler currently set.</para>
961 </returns></function>
962 <function name="entry_invariant_failure"><type>void</type><parameter name="where"><paramtype>from</paramtype><description><para>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).</para></description></parameter><purpose>Call failure handler for class invariants at entry. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).</para><para>
963 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
964         Volatile Public Functions</link> </para>
965 </para>
966 </para></description></function>
967 <function name="set_exit_invariant_failure"><type>from_failure_handler const  &amp;</type><parameter name="f"><paramtype>from_failure_handler const &amp;</paramtype><description><para>New failure handler functor to set.</para></description></parameter><purpose>Set failure handler for class invariants at exit. </purpose><description><para>Set a new failure handler and returns it.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
968
969 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
970         Volatile Public Functions</link> </para>
971 </para>
972 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
973 </returns></function>
974 <function name="get_exit_invariant_failure"><type>from_failure_handler</type><purpose>Return failure handler currently set for class invariants at exit. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
975 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
976         Volatile Public Functions</link> </para>
977 </para>
978 </para></description><returns><para>A copy of the failure handler currently set.</para>
979 </returns></function>
980 <function name="exit_invariant_failure"><type>void</type><parameter name="where"><paramtype>from</paramtype><description><para>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).</para></description></parameter><purpose>Call failure handler for class invariants at exit. </purpose><description><para>This is often called only internally by this library.</para><para><emphasis role="bold">Throws:</emphasis> This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default).</para><para>
981 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
982         Volatile Public Functions</link> </para>
983 </para>
984 </para></description></function>
985 <function name="set_invariant_failure"><type>from_failure_handler const  &amp;</type><parameter name="f"><paramtype>from_failure_handler const &amp;</paramtype><description><para>New failure handler functor to set for both entry and exit invariants.</para></description></parameter><purpose>Set failure handler for class invariants (at both entry and exit). </purpose><description><para>This is provided for convenience and it is equivalent to call both  <computeroutput><functionname alt="boost::contract::set_entry_invariant_failure">boost::contract::set_entry_invariant_failure</functionname></computeroutput> and  <computeroutput><functionname alt="boost::contract::set_exit_invariant_failure">boost::contract::set_exit_invariant_failure</functionname></computeroutput> with the same functor parameter <computeroutput>f</computeroutput>.</para><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
986
987 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__"> Throw on Failure</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
988         Volatile Public Functions</link> </para>
989 </para>
990 </para></description><returns><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para>
991 </returns></function>
992 </namespace>
993 </namespace>
994 </header>
995 <header name="boost/contract/core/specify.hpp">
996 <para>Specify preconditions, old values copied at body, postconditions, and exception guarantees. </para><para>Preconditions, old values copied at body, postconditions, and exception guarantees are all optionals but, when they are specified, they need to be specified in that order. </para><namespace name="boost">
997 <namespace name="contract">
998 <class name="specify_except"><purpose>Allow to specify exception guarantees. </purpose><description><para>Allow to specify the functor this library will call to check exception guarantees. This object is internally constructed by the library when users specify contracts calling <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput> and similar functions (that is why this class does not have a public constructor).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link> </para>
999 </para>
1000 </para></description><method-group name="public member functions">
1001 <method name="except"><type><classname>specify_nothing</classname></type><template>
1002           <template-type-parameter name="F"/>
1003         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::except_failure">boost::contract::except_failure</functionname></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></description></parameter><purpose>Allow to specify exception guarantees. </purpose><description><para>
1004
1005 </para></description><returns><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para>
1006 </returns></method>
1007 </method-group>
1008 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept(false)</computeroutput> since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
1009             Throw on Failure</link>). </para></description></destructor>
1010 </class><class name="specify_nothing"><purpose>Used to prevent setting other contract conditions after exception guarantees. </purpose><description><para>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 the library when users specify contracts calling <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput> and similar functions (that is why this class does not have a public constructor).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial"> Tutorial</link> </para>
1011 </para>
1012 </para></description><method-group name="public member functions">
1013 </method-group>
1014 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept(false)</computeroutput> since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
1015             Throw on Failure</link>). </para></description></destructor>
1016 </class><class name="specify_old_postcondition_except"><template>
1017       <template-type-parameter name="VirtualResult"><default>void</default><purpose><para>Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always <computeroutput>void</computeroutput>. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
1018     </template><purpose>Allow to specify old values copied at body, postconditions, and exception guarantees. </purpose><description><para>Allow to specify functors this library will call to copy old values at body, check postconditions, and check exception guarantees. This object is internally constructed by the library when users specify contracts calling <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput> and similar functions (that is why this class does not have a public constructor).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.old_values_copied_at_body"> Old Values Copied at Body</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link></para>
1019 </para>
1020
1021 </para></description><method-group name="public member functions">
1022 <method name="old"><type><classname>specify_postcondition_except</classname>&lt; VirtualResult &gt;</type><template>
1023           <template-type-parameter name="F"/>
1024         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library <computeroutput>f()</computeroutput> 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 <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput>. Any exception thrown by a call to this functor will result in this library calling <computeroutput><functionname alt="boost::contract::old_failure">boost::contract::old_failure</functionname></computeroutput> (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).</para></description></parameter><purpose>Allow to specify old values copied at body. </purpose><description><para>It should often be sufficient to initialize old value pointers as soon as they are declared, without using this function (see  <link linkend="boost_contract.advanced.old_values_copied_at_body"> Old Values Copied at Body</link>).</para><para>
1025
1026 </para></description><returns><para>After old values copied at body have been specified, the object returned by this function allows to optionally specify postconditions and exception guarantees. </para>
1027 </returns></method>
1028 <method name="postcondition"><type><classname>specify_except</classname></type><template>
1029           <template-type-parameter name="F"/>
1030         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Functor called by this library to check postconditions <computeroutput>f()</computeroutput> or <computeroutput>f(result)</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::postcondition_failure">boost::contract::postcondition_failure</functionname></computeroutput>). 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 <computeroutput>f()</computeroutput> if <computeroutput>VirtualResult</computeroutput> is <computeroutput>void</computeroutput>, otherwise it must be a unary functor <computeroutput>f(result)</computeroutput> accepting the return value <computeroutput>result</computeroutput> as a parameter of type <computeroutput>VirtualResult const&amp;</computeroutput> (to avoid extra copies of the return value, or of type <computeroutput>VirtualResult</computeroutput> or <computeroutput>VirtualResult const</computeroutput> if extra copies of the return value are irrelevant).</para></description></parameter><purpose>Allow to specify postconditions. </purpose><description><para>
1031
1032 </para></description><returns><para>After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. </para>
1033 </returns></method>
1034 <method name="except"><type><classname>specify_nothing</classname></type><template>
1035           <template-type-parameter name="F"/>
1036         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::except_failure">boost::contract::except_failure</functionname></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></description></parameter><purpose>Allow to specify exception guarantees. </purpose><description><para>
1037
1038 </para></description><returns><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para>
1039 </returns></method>
1040 </method-group>
1041 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept(false)</computeroutput> since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
1042             Throw on Failure</link>). </para></description></destructor>
1043 </class><class name="specify_postcondition_except"><template>
1044       <template-type-parameter name="VirtualResult"><default>void</default><purpose><para>Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always <computeroutput>void</computeroutput>. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
1045     </template><purpose>Allow to specify postconditions or exception guarantees. </purpose><description><para>Allow to specify functors this library will call to check postconditions or exception guarantees. This object is internally constructed by the library when users specify contracts calling <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput> and similar functions (that is why this class does not have a public constructor).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link></para>
1046 </para>
1047
1048 </para></description><method-group name="public member functions">
1049 <method name="postcondition"><type><classname>specify_except</classname></type><template>
1050           <template-type-parameter name="F"/>
1051         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Functor called by this library to check postconditions <computeroutput>f()</computeroutput> or <computeroutput>f(result)</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::postcondition_failure">boost::contract::postcondition_failure</functionname></computeroutput>). 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 <computeroutput>f()</computeroutput> if <computeroutput>VirtualResult</computeroutput> is <computeroutput>void</computeroutput>, otherwise it must be a unary functor <computeroutput>f(result)</computeroutput> accepting the return value <computeroutput>result</computeroutput> as a parameter of type <computeroutput>VirtualResult const&amp;</computeroutput> (to avoid extra copies of the return value, or of type <computeroutput>VirtualResult</computeroutput> or <computeroutput>VirtualResult const</computeroutput> if extra copies of the return value are irrelevant).</para></description></parameter><purpose>Allow to specify postconditions. </purpose><description><para>
1052
1053 </para></description><returns><para>After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. </para>
1054 </returns></method>
1055 <method name="except"><type><classname>specify_nothing</classname></type><template>
1056           <template-type-parameter name="F"/>
1057         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::except_failure">boost::contract::except_failure</functionname></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></description></parameter><purpose>Allow to specify exception guarantees. </purpose><description><para>
1058
1059 </para></description><returns><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para>
1060 </returns></method>
1061 </method-group>
1062 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept(false)</computeroutput> since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
1063             Throw on Failure</link>). </para></description></destructor>
1064 </class><class name="specify_precondition_old_postcondition_except"><template>
1065       <template-type-parameter name="VirtualResult"><default>void</default><purpose><para>Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always <computeroutput>void</computeroutput>. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
1066     </template><purpose>Allow to specify preconditions, old values copied at body, postconditions, and exception guarantees. </purpose><description><para>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 the library when users specify contracts calling <computeroutput><functionname alt="boost::contract::function">boost::contract::function</functionname></computeroutput> and similar functions (that is why this class does not have a public constructor).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link>,  <link linkend="boost_contract.advanced.old_values_copied_at_body"> Old Values Copied at Body</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link></para>
1067 </para>
1068
1069 </para></description><method-group name="public member functions">
1070 <method name="precondition"><type><classname>specify_old_postcondition_except</classname>&lt; VirtualResult &gt;</type><template>
1071           <template-type-parameter name="F"/>
1072         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library to check preconditions <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::precondition_failure">boost::contract::precondition_failure</functionname></computeroutput>). This functor should capture variables by (constant) value, or better by (constant) reference (to avoid extra copies).</para></description></parameter><purpose>Allow to specify preconditions. </purpose><description><para>
1073
1074 </para></description><returns><para>After preconditions have been specified, the object returned by this function allows to optionally specify old values copied at body, postconditions, and exception guarantees. </para>
1075 </returns></method>
1076 <method name="old"><type><classname>specify_postcondition_except</classname>&lt; VirtualResult &gt;</type><template>
1077           <template-type-parameter name="F"/>
1078         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library <computeroutput>f()</computeroutput> 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 <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput>. Any exception thrown by a call to this functor will result in this library calling <computeroutput><functionname alt="boost::contract::old_failure">boost::contract::old_failure</functionname></computeroutput> (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).</para></description></parameter><purpose>Allow to specify old values copied at body. </purpose><description><para>It should often be sufficient to initialize old value pointers as soon as they are declared, without using this function (see  <link linkend="boost_contract.advanced.old_values_copied_at_body"> Old Values Copied at Body</link>).</para><para>
1079
1080 </para></description><returns><para>After old values copied at body have been specified, the object returned by this functions allows to optionally specify postconditions and exception guarantees. </para>
1081 </returns></method>
1082 <method name="postcondition"><type><classname>specify_except</classname></type><template>
1083           <template-type-parameter name="F"/>
1084         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Functor called by this library to check postconditions <computeroutput>f()</computeroutput> or <computeroutput>f(result)</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::postcondition_failure">boost::contract::postcondition_failure</functionname></computeroutput>). 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 <computeroutput>f()</computeroutput> if <computeroutput>VirtualResult</computeroutput> is <computeroutput>void</computeroutput>, otherwise it must be a unary functor <computeroutput>f(result)</computeroutput> accepting the return value <computeroutput>result</computeroutput> as a parameter of type <computeroutput>VirtualResult const&amp;</computeroutput> (to avoid extra copies of the return value, or of type <computeroutput>VirtualResult</computeroutput> or <computeroutput>VirtualResult const</computeroutput> if extra copies of the return value are irrelevant).</para></description></parameter><purpose>Allow to specify postconditions. </purpose><description><para>
1085
1086 </para></description><returns><para>After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. </para>
1087 </returns></method>
1088 <method name="except"><type><classname>specify_nothing</classname></type><template>
1089           <template-type-parameter name="F"/>
1090         </template><parameter name="f"><paramtype>F const &amp;</paramtype><description><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::except_failure">boost::contract::except_failure</functionname></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></description></parameter><purpose>Allow to specify exception guarantees. </purpose><description><para>
1091
1092 </para></description><returns><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para>
1093 </returns></method>
1094 </method-group>
1095 <destructor><purpose>Destruct this object. </purpose><description><para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept(false)</computeroutput> since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see  <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">
1096             Throw on Failure</link>). </para></description></destructor>
1097 </class>
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137 </namespace>
1138 </namespace>
1139 </header>
1140 <header name="boost/contract/core/virtual.hpp">
1141 <para>Handle virtual public functions with contracts (for subcontracting). </para><namespace name="boost">
1142 <namespace name="contract">
1143 <class name="virtual_"><purpose>Type of extra function parameter to handle contracts for virtual public functions (for subcontracting). </purpose><description><para>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 their parameter list. This parameter must be a pointer to this class and it must have default value <computeroutput>0</computeroutput> or <computeroutput>nullptr</computeroutput> (this extra parameter is often named <computeroutput>v</computeroutput> in this documentation, but any name can be used):</para><para><programlisting language="c++">class u {
1144 public:
1145     virtual void f(int x, boost::contract::virtual_* v = 0) { // Declare `v`.
1146         ... // Contract declaration (which will use `v`) and function body.
1147     }
1148
1149     ...
1150 };
1151 </programlisting></para><para>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  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput>, and all other operations of this library that accept a pointer to  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput>. 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).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.virtual_public_functions"> Virtual Public Functions</link>,  <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
1152         Public Function Overrides</link> </para>
1153 </para>
1154 </para></description></class>
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194 </namespace>
1195 </namespace>
1196 </header>
1197 <header name="boost/contract/destructor.hpp">
1198 <para>Program contracts for destructors. </para><namespace name="boost">
1199 <namespace name="contract">
1200
1201
1202
1203
1204
1205 <function name="destructor"><type><classname>specify_old_postcondition_except</classname></type><template>
1206           <template-type-parameter name="Class"><purpose><para>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.)</para></purpose></template-type-parameter>
1207         </template><parameter name="obj"><paramtype>Class *</paramtype><description><para>The object <computeroutput>this</computeroutput> from the scope of the enclosing destructor declaring the contract. (Destructors check all class invariants, including static and volatile invariants, see <link linkend="boost_contract.tutorial.class_invariants">
1208             Class Invariants</link> and  <link linkend="boost_contract.extras.volatile_public_functions">
1209             Volatile Public Functions</link>).</para></description></parameter><purpose>Program contracts for destructors. </purpose><description><para>This is used to specify postconditions, exception guarantees, old value copies at body, and check class invariants for destructors (destructors cannot have preconditions, see  <link linkend="boost_contract.contract_programming_overview.destructor_calls"> Destructor Calls</link>):</para><para><programlisting language="c++">class u {
1210     friend class boost::contract::access;
1211
1212     void invariant() const { // Optional (as for static and volatile).
1213         BOOST_CONTRACT_ASSERT(...);
1214         ...
1215     }
1216
1217 public:
1218     ~u() {
1219         boost::contract::old_ptr&lt;old_type&gt; old_var;
1220         boost::contract::check c = boost::contract::destructor(this)
1221             // No `.precondition` (destructors have no preconditions).
1222             .old([&amp;] { // Optional.
1223                 old_var = BOOST_CONTRACT_OLDOF(old_expr);
1224                 ...
1225             })
1226             .postcondition([&amp;] { // Optional.
1227                 BOOST_CONTRACT_ASSERT(...);
1228                 ...
1229             })
1230             .except([&amp;] { // Optional.
1231                 BOOST_CONTRACT_ASSERT(...);
1232                 ...
1233             })
1234         ;
1235
1236         ... // Destructor body.
1237     }
1238     
1239     ...
1240 };
1241 </programlisting></para><para>For optimization, this can be omitted for destructors that do not have postconditions and exception guarantees, within classes that have no invariants.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.destructors"> Destructors</link></para>
1242 </para>
1243
1244
1245
1246 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the destructor body (otherwise this library will generate a run-time error, see <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1247 </returns></function>
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282 </namespace>
1283 </namespace>
1284 </header>
1285 <header name="boost/contract/function.hpp">
1286 <para>Program contracts for (non-public) functions. </para><namespace name="boost">
1287 <namespace name="contract">
1288
1289
1290
1291
1292
1293
1294 <function name="function"><type><classname>specify_precondition_old_postcondition_except</classname></type><purpose>Program contracts for non-member, private and protected functions. </purpose><description><para>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  <link linkend="boost_contract.contract_programming_overview.function_calls"> Function Calls</link>):</para><para><programlisting language="c++">void f(...) {
1295     boost::contract::old_ptr&lt;old_type&gt; old_var;
1296     boost::contract::check c = boost::contract::function()
1297         .precondition([&amp;] { // Optional.
1298             BOOST_CONTRACT_ASSERT(...);
1299             ...
1300         })
1301         .old([&amp;] { // Optional.
1302             old_var = BOOST_CONTRACT_OLDOF(old_expr);  
1303             ...
1304         })
1305         .postcondition([&amp;] { // Optional.
1306             BOOST_CONTRACT_ASSERT(...);
1307             ...
1308         })
1309         .except([&amp;] { // Optional.
1310             BOOST_CONTRACT_ASSERT(...);
1311             ...
1312         })
1313     ;
1314
1315     ... // Function body.
1316 }
1317 </programlisting></para><para>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.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.non_member_functions"> Non-Member Functions</link>,  <link linkend="boost_contract.advanced.private_and_protected_functions">
1318         Private and Protected Functions</link>,  <link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">
1319         Lambdas, Loops, Code Blocks</link></para>
1320 </para>
1321
1322 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the function body (otherwise this library will generate a run-time error, see <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1323 </returns></function>
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357 </namespace>
1358 </namespace>
1359 </header>
1360 <header name="boost/contract/old.hpp">
1361 <para>Handle old values. </para><namespace name="boost">
1362 <namespace name="contract">
1363 <struct name="is_old_value_copyable"><template>
1364       <template-type-parameter name="T"/>
1365     </template><inherit access="public">boost::is_copy_constructible&lt; T &gt;</inherit><purpose>Trait to check if an old value type can be copied or not. </purpose><description><para>By default, this unary boolean meta-function is equivalent to <computeroutput>boost::is_copy_constructible&lt;T&gt;</computeroutput> but programmers can chose to specialize it for user-defined types (in general some kind of specialization is also needed on compilers that do not support C++11, see <ulink url="http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html"><computeroutput>boost::is_copy_constructible</computeroutput></ulink>):</para><para><programlisting language="c++">class u; // Some user-defined type for which old values shall not be copied.
1366
1367 namespace boost { namespace contract {
1368     template&lt;&gt; // Specialization to not copy old values of type `u`.
1369     struct is_old_value_copyable&lt;u&gt; : boost::false_type {};
1370 } } // namespace
1371 </programlisting></para><para>A given old value type <computeroutput>T</computeroutput> is copied only if <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> is <computeroutput>true</computeroutput>. A copyable old value type <computeroutput>V</computeroutput> is always copied using <computeroutput>boost::contract::old_value_copy&lt;V&gt;</computeroutput>. A non-copyable old value type <computeroutput>W</computeroutput> generates a compile-time error when <computeroutput>boost::contract::old_ptr&lt;W&gt;</computeroutput> is dereferenced, but instead leaves <computeroutput>boost::contract::old_ptr_if_copyable&lt;W&gt;</computeroutput> always null (without generating compile-time errors).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.old_value_requirements__templates_">
1372         Old Value Requirements</link> </para>
1373 </para>
1374 </para></description></struct><class name="old_pointer"><purpose>Convert old value copies into old value pointers. </purpose><description><para>This class is usually 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.). </para></description><method-group name="public member functions">
1375 <method name="conversion-operator"><type>old_ptr_if_copyable&lt; T &gt;</type><template>
1376           <template-type-parameter name="T"><purpose><para>Type of the pointed old value. The old value pointer will always be null if this type is not copyable (see <computeroutput><classname alt="boost::contract::is_old_value_copyable">boost::contract::is_old_value_copyable</classname></computeroutput>), but this library will not generate a compile-time error. </para></purpose></template-type-parameter>
1377         </template><purpose>Convert this object to an actual old value pointer for which the old value type <computeroutput>T</computeroutput> might or not be copyable. </purpose><description><para>For example, this is implicitly called when assigning or initializing old value pointers of type <computeroutput><classname alt="boost::contract::old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</classname></computeroutput>.</para><para>
1378 </para></description></method>
1379 <method name="conversion-operator"><type>old_ptr&lt; T &gt;</type><template>
1380           <template-type-parameter name="T"><purpose><para>Type of the pointed old value. This type must be copyable (see <computeroutput><classname alt="boost::contract::is_old_value_copyable">boost::contract::is_old_value_copyable</classname></computeroutput>), otherwise this library will generate a compile-time error when the old value pointer is dereferenced. </para></purpose></template-type-parameter>
1381         </template><purpose>Convert this object to an actual old value pointer for which the old value type <computeroutput>T</computeroutput> must be copyable. </purpose><description><para>For example, this is implicitly called when assigning or initializing old value pointers of type <computeroutput><classname alt="boost::contract::old_ptr">boost::contract::old_ptr</classname></computeroutput>.</para><para>
1382 </para></description></method>
1383 </method-group>
1384 </class><class name="old_ptr"><template>
1385       <template-type-parameter name="T"><purpose><para>Type of the pointed old value. This type must be copyable (i.e., <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> must be <computeroutput>true</computeroutput>), otherwise this pointer will always be null and this library will generate a compile-time error when the pointer is dereferenced. </para></purpose></template-type-parameter>
1386     </template><purpose>Old value pointer that requires the pointed old value type to be copyable. </purpose><description><para>This pointer can be set to point an actual old value copy using either  <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput> or <computeroutput><functionname alt="boost::contract::make_old">boost::contract::make_old</functionname></computeroutput> (that is why this class does not have public non-default constructors):</para><para><programlisting language="c++">class u {
1387 public:
1388     virtual void f(..., boost::contract::virtual_* v = 0) {
1389         boost::contract::old_ptr&lt;old_type&gt; old_var = // For copyable `old_type`.
1390                 BOOST_CONTRACT_OLDOF(v, old_expr);
1391         ...
1392     }
1393
1394     ...
1395 };
1396 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.old_values"> Old Values</link></para>
1397 </para>
1398
1399 </para></description><typedef name="element_type"><purpose>Pointed old value type. </purpose><type>T</type></typedef>
1400 <method-group name="public member functions">
1401 <method name="operator *" cv="const"><type>T const  &amp;</type><purpose>Dereference this old value pointer. </purpose><description><para>This will generate a run-time error if this pointer is null and a compile-time error if the pointed type <computeroutput>T</computeroutput> is not copyable (i.e., if <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> is <computeroutput>false</computeroutput>).</para><para>
1402 </para></description><returns><para>The pointed old value. Contract assertions should not change the state of the program so this member function is <computeroutput>const</computeroutput> and it returns the old value as a reference to a constant object (see  <link linkend="boost_contract.contract_programming_overview.constant_correctness">
1403         Constant Correctness</link>). </para>
1404 </returns></method>
1405 <method name="operator-&gt;" cv="const"><type>T const  *</type><purpose>Structure-dereference this old value pointer. </purpose><description><para>This will generate a compile-time error if the pointed type <computeroutput>T</computeroutput> is not copyable (i.e., if <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> is <computeroutput>false</computeroutput>).</para><para>
1406 </para></description><returns><para>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 <computeroutput>const</computeroutput> and it returns the old value as a pointer to a constant object (see  <link linkend="boost_contract.contract_programming_overview.constant_correctness">
1407         Constant Correctness</link>). </para>
1408 </returns></method>
1409 <method name="conversion-operator" cv="const" specifiers="explicit"><type>bool</type><purpose>Query if this old value pointer is null or not (safe-bool operator). </purpose><description><para>(This is implemented using safe-bool emulation on compilers that do not support C++11 explicit type conversion operators.)</para><para>
1410 </para></description><returns><para>True if this pointer is not null, false otherwise. </para>
1411 </returns></method>
1412 </method-group>
1413 <constructor><purpose>Construct this old value pointer as null. </purpose></constructor>
1414 </class><class name="old_ptr_if_copyable"><template>
1415       <template-type-parameter name="T"><purpose><para>Type of the pointed old value. If this type is not copyable (i.e., <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> is <computeroutput>false</computeroutput>), this pointer will always be null (but this library will not generate a compile-time error when this pointer is dereferenced). </para></purpose></template-type-parameter>
1416     </template><purpose>Old value pointer that does not require the pointed old value type to be copyable. </purpose><description><para>This pointer can be set to point to an actual old value copy using either  <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput> or <computeroutput><functionname alt="boost::contract::make_old">boost::contract::make_old</functionname></computeroutput>:</para><para><programlisting language="c++">template&lt;typename T&gt; // Type `T` might or not be copyable.
1417 class u {
1418 public:
1419     virtual void f(..., boost::contract::virtual_* v = 0) {
1420         boost::contract::old_ptr_if_copyable&lt;T&gt; old_var =
1421                 BOOST_CONTRACT_OLDOF(v, old_expr);
1422         ...
1423             if(old_var) ... // Always null for non-copyable types.
1424         ...
1425     }
1426
1427     ...
1428 };
1429 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.old_value_requirements__templates_">
1430         Old Value Requirements</link></para>
1431 </para>
1432
1433 </para></description><typedef name="element_type"><purpose>Pointed old value type. </purpose><type>T</type></typedef>
1434 <method-group name="public member functions">
1435 <method name="operator *" cv="const"><type>T const  &amp;</type><purpose>Dereference this old value pointer. </purpose><description><para>This will generate a run-time error if this pointer is null, but no compile-time error is generated if the pointed type <computeroutput>T</computeroutput> is not copyable (i.e., if <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> is <computeroutput>false</computeroutput>).</para><para>
1436 </para></description><returns><para>The pointed old value. Contract assertions should not change the state of the program so this member function is <computeroutput>const</computeroutput> and it returns the old value as a reference to a constant object (see  <link linkend="boost_contract.contract_programming_overview.constant_correctness">
1437         Constant Correctness</link>). </para>
1438 </returns></method>
1439 <method name="operator-&gt;" cv="const"><type>T const  *</type><purpose>Structure-dereference this old value pointer. </purpose><description><para>This will return null but will not generate a compile-time error if the pointed type <computeroutput>T</computeroutput> is not copyable (i.e., if <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> is <computeroutput>false</computeroutput>).</para><para>
1440 </para></description><returns><para>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 <computeroutput>const</computeroutput> and it returns the old value as a pointer to a constant object (see  <link linkend="boost_contract.contract_programming_overview.constant_correctness">
1441         Constant Correctness</link>). </para>
1442 </returns></method>
1443 <method name="conversion-operator" cv="const" specifiers="explicit"><type>bool</type><purpose>Query if this old value pointer is null or not (safe-bool operator). </purpose><description><para>(This is implemented using safe-bool emulation on compilers that do not support C++11 explicit type conversion operators.)</para><para>
1444 </para></description><returns><para>True if this pointer is not null, false otherwise. </para>
1445 </returns></method>
1446 </method-group>
1447 <constructor><purpose>Construct this old value pointer as null. </purpose></constructor>
1448 <constructor><parameter name="other"><paramtype><classname>old_ptr</classname>&lt; T &gt; const &amp;</paramtype><description><para>Old value pointer that requires the old value type to be copyable. </para></description></parameter><purpose>Construct this old value pointer from an old value pointer that requires the old value type to be copyable. </purpose><description><para>Ownership of the pointed value object is transferred to this pointer. This constructor is implicitly called by this library when assigning an object of this type using <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput> (this constructor is usually not explicitly called by user code).</para><para>
1449 </para></description></constructor>
1450 </class><class name="old_value"><purpose>Convert user-specified expressions to old values. </purpose><description><para>This class is usually only implicitly used by this library and it does not explicitly appear in user code.</para><para>On older compilers that cannot correctly deduce the <computeroutput><classname alt="boost::contract::is_old_value_copyable">boost::contract::is_old_value_copyable</classname></computeroutput> trait used in the declaration of this class, programmers can manually specialize that trait to make sure that only old value types that are copyable are actually copied.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.old_value_requirements__templates_">
1451         Old Value Requirements</link> </para>
1452 </para>
1453 </para></description><method-group name="public member functions">
1454 </method-group>
1455 <constructor><template>
1456           <template-type-parameter name="T"><purpose><para>Old value type. </para></purpose></template-type-parameter>
1457         </template><parameter name="old"><paramtype>T const &amp;</paramtype><description><para>Old value to be copied.</para></description></parameter><parameter name=""><paramtype>typename boost::enable_if&lt; <classname>boost::contract::is_old_value_copyable</classname>&lt; T &gt; &gt;::type *</paramtype><default>0</default></parameter><purpose>Construct this object from the specified old value when the old value type is copy constructible. </purpose><description><para>The specified old value <computeroutput>old</computeroutput> is copied (one time only) using <computeroutput><classname alt="boost::contract::old_value_copy">boost::contract::old_value_copy</classname></computeroutput>, in which case the related old value pointer will not be null (but no copy is made if postconditions and exception guarantees are not being checked, see  <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput>).</para><para>
1458
1459 </para></description></constructor>
1460 <constructor><template>
1461           <template-type-parameter name="T"><purpose><para>Old value type. </para></purpose></template-type-parameter>
1462         </template><parameter name="old"><paramtype>T const &amp;</paramtype><description><para>Old value (that will not be copied in this case).</para></description></parameter><parameter name=""><paramtype>typename boost::disable_if&lt; <classname>boost::contract::is_old_value_copyable</classname>&lt; T &gt; &gt;::type *</paramtype><default>0</default></parameter><purpose>Construct this object from the specified old value when the old value type is not copyable. </purpose><description><para>The specified old value <computeroutput>old</computeroutput> cannot be copied in this case so it is not copied and the related old value pointer will always be null (thus calls to this constructor have no effect and they will likely be optimized away by most compilers).</para><para>
1463
1464 </para></description></constructor>
1465 </class><struct name="old_value_copy"><template>
1466       <template-type-parameter name="T"/>
1467     </template><purpose>Trait to copy an old value. </purpose><description><para>By default, the implementation of this trait uses <computeroutput>T's</computeroutput> 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 <computeroutput>T's</computeroutput> copy constructor. The default implementation of this trait is equivalent to:</para><para><programlisting language="c++">template&lt;typename T&gt;
1468 class old_value_copy {
1469 public:
1470     explicit old_value_copy(T const&amp; old) :
1471         old_(old) // One single copy of value using T's copy constructor.
1472     {}
1473
1474     T const&amp; old() const { return old_; }
1475
1476 private:
1477     T const old_; // The old value copy.
1478 };
1479 </programlisting></para><para>This library will instantiate and use this trait only on old value types <computeroutput>T</computeroutput> that are copyable (i.e., for which <computeroutput>boost::contract::is_old_value_copyable&lt;T&gt;::value</computeroutput> is <computeroutput>true</computeroutput>).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.old_value_requirements__templates_">
1480         Old Value Requirements</link> </para>
1481 </para>
1482 </para></description><method-group name="public member functions">
1483 <method name="old" cv="const"><type>T const  &amp;</type><purpose>Return a (constant) reference to the old value that was copied. </purpose><description><para>Contract assertions should not change the state of the program so the old value copy is returned as <computeroutput>const</computeroutput> (see  <link linkend="boost_contract.contract_programming_overview.constant_correctness">
1484 Constant Correctness</link>). </para></description></method>
1485 </method-group>
1486 <constructor specifiers="explicit"><parameter name="old"><paramtype>T const &amp;</paramtype><description><para>The old value to copy. </para></description></parameter><purpose>Construct this object by making one single copy of the specified old value. </purpose><description><para>This is the only operation within this library that actually copies old values. This ensures this library makes one and only one copy of an old value (if they actually need to be copied, see <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput>).</para><para>
1487 </para></description></constructor>
1488 </struct>
1489
1490
1491
1492
1493
1494
1495 <function name="null_old"><type><classname>old_value</classname></type><purpose>Return a "null" old value. </purpose><description><para>The related old value pointer will also be null. This function is usually only called by the code expanded by  <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
1496 </para>
1497
1498 </para></description><returns><para>Null old value. </para>
1499 </returns></function>
1500 <function name="make_old"><type><classname>old_pointer</classname></type><parameter name="old"><paramtype><classname>old_value</classname> const &amp;</paramtype><description><para>Old value which is usually implicitly constructed from the user old value expression to be copied (use the ternary operator <computeroutput>?:</computeroutput> to completely avoid to evaluate the old value expression when <computeroutput>boost::contract::copy_old()</computeroutput> is <computeroutput>false</computeroutput>).</para></description></parameter><purpose>Make an old value pointer (but not for virtual public functions and public functions overrides). </purpose><description><para>The related old value pointer will not be null if the specified old value was actually copied. This function is usually only called by code expanded by <computeroutput>BOOST_CONTRACT_OLDOF(old_expr)</computeroutput> as in:</para><para><programlisting language="c++">boost::contract::make_old(boost::contract::copy_old() ? old_expr :
1501         boost::contract::null_old())
1502 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
1503 </para>
1504
1505
1506 </para></description><returns><para>Old value pointer (usually implicitly converted to either  <computeroutput><classname alt="boost::contract::old_ptr">boost::contract::old_ptr</classname></computeroutput> or  <computeroutput><classname alt="boost::contract::old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</classname></computeroutput> in user code). </para>
1507 </returns></function>
1508 <function name="make_old"><type><classname>old_pointer</classname></type><parameter name="v"><paramtype><classname>virtual_</classname> *</paramtype><description><para>The trailing parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual or overriding public function declaring the contract. </para></description></parameter><parameter name="old"><paramtype><classname>old_value</classname> const &amp;</paramtype><description><para>Old value which is usually implicitly constructed from the user old value expression to be copied (use the ternary operator <computeroutput>?:</computeroutput> to completely avoid to evaluate the old value expression when <computeroutput>boost::contract::copy_old(v)</computeroutput> is <computeroutput>false</computeroutput>).</para></description></parameter><purpose>Make an old value pointer (for virtual public functions and public functions overrides). </purpose><description><para>The related old value pointer will not be null if the specified old value was actually copied. This function is usually only called by code expanded by <computeroutput>BOOST_CONTRACT_OLDOF(v, old_expr)</computeroutput> as in:</para><para><programlisting language="c++">boost::contract::make_old(v, boost::contract::copy_old(v) ? old_expr :
1509         boost::contract::null_old())
1510 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
1511 </para>
1512
1513
1514 </para></description><returns><para>Old value pointer (usually implicitly converted to either  <computeroutput><classname alt="boost::contract::old_ptr">boost::contract::old_ptr</classname></computeroutput> or  <computeroutput><classname alt="boost::contract::old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</classname></computeroutput> in user code). </para>
1515 </returns></function>
1516 <function name="copy_old"><type>bool</type><purpose>Query if old values need to be copied (but not for virtual public functions and public function overrides). </purpose><description><para>For example, this function always returns false when both postconditions and exception guarantees are not being checked (see  <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput>). This function is usually only called by the code expanded by  <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
1517 </para>
1518
1519 </para></description><returns><para>True if old values need to be copied, false otherwise. </para>
1520 </returns></function>
1521 <function name="copy_old"><type>bool</type><parameter name="v"><paramtype><classname>virtual_</classname> *</paramtype><description><para>The trailing parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual or overriding public function declaring the contract.</para></description></parameter><purpose>Query if old values need to be copied (for virtual public functions and public function overrides). </purpose><description><para>For example, this function always returns false when both postconditions and exception guarantees are not being checked (see  <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput>). In addition, this function returns false when overridden functions are being called subsequent times by this library to support subcontracting. This function is usually only called by the code expanded by  <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link></para>
1522 </para>
1523
1524
1525 </para></description><returns><para>True if old values need to be copied, false otherwise. </para>
1526 </returns></function>
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555 </namespace>
1556 </namespace>
1557 <macro name="BOOST_CONTRACT_OLDOF" kind="functionlike"><macro-parameter name="..."/><purpose>Macro typically used to copy an old value expression and assign it to an old value pointer. </purpose><description><para>The expression expanded by this macro should be assigned to an old value pointer of type <computeroutput><classname alt="boost::contract::old_ptr">boost::contract::old_ptr</classname></computeroutput> or  <computeroutput><classname alt="boost::contract::old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</classname></computeroutput>. This is an overloaded variadic macro and it can be used in the following different ways.</para><para>1. From within virtual public functions and public functions overrides:</para><para><programlisting language="c++">BOOST_CONTRACT_OLDOF(v, old_expr)
1558 </programlisting></para><para>2. From all other operations:</para><para><programlisting language="c++">BOOST_CONTRACT_OLDOF(old_expr)
1559 </programlisting></para><para>Where:</para><para><itemizedlist>
1560 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function or public function overrides declaring the contract. </para>
1561 </listitem>
1562 <listitem><para><computeroutput><emphasis role="bold">old_expr</emphasis></computeroutput> is the expression to be evaluated and copied into the old value pointer. (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis and <computeroutput>BOOST_CONTRACT_OLDOF(v, (old_expr))</computeroutput> will always work.)</para>
1563 </listitem>
1564 </itemizedlist>
1565 On compilers that do not support variadic macros, programmers can manually copy old value expressions without using this macro (see  <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link>).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.old_values"> Old Values</link> </para>
1566 </para>
1567 </para></description></macro>
1568 </header>
1569 <header name="boost/contract/override.hpp">
1570 <para>Handle public function overrides (for subcontracting). </para><macro name="BOOST_CONTRACT_NAMED_OVERRIDE" kind="functionlike"><macro-parameter name="type_name"><description><para>Name of the override type trait this macro will declare. (This is not a variadic macro parameter but it should never contain commas because it is an identifier.) </para></description></macro-parameter><macro-parameter name="func_name"><description><para>Function name of the public function override. This macro is called just once even if the function name is overloaded (the same override type trait is used for all overloaded functions with the same name, see  <link linkend="boost_contract.advanced.function_overloads">
1571                     Function Overloads</link>). (This is not a variadic macro parameter but it should never contain commas because it is an identifier.) </para></description></macro-parameter><purpose>Declare an override type trait with an arbitrary name. </purpose><description><para>Declare the override type trait named <computeroutput>type_name</computeroutput> to pass as an explicit template parameter to <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> for public function overrides.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.named_overrides"> Named Overrides</link></para>
1572 </para>
1573
1574 </para></description></macro>
1575 <macro name="BOOST_CONTRACT_OVERRIDE" kind="functionlike"><macro-parameter name="func_name"><description><para>Function name of the public function override. This macro is called just once even if the function name is overloaded (the same override type trait is used for all overloaded functions with the same name, see  <link linkend="boost_contract.advanced.function_overloads"> Function Overloads</link>). (This is not a variadic macro parameter but it should never contain any comma because it is an identifier.) </para></description></macro-parameter><purpose>Declare an override type trait named <computeroutput>override_<emphasis>func_name</emphasis></computeroutput>. </purpose><description><para>Declare the override type trait named <computeroutput>override_<emphasis>func_name</emphasis></computeroutput> to pass as an explicit template parameter to <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> for public function overrides. Use <computeroutput><macroname alt="BOOST_CONTRACT_NAMED_OVERRIDE">BOOST_CONTRACT_NAMED_OVERRIDE</macroname></computeroutput> to generate an override type trait with a name different than <computeroutput>override_<emphasis>func_name</emphasis></computeroutput> (usually not needed).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
1576         Public Function Overrides</link></para>
1577 </para>
1578
1579 </para></description></macro>
1580 <macro name="BOOST_CONTRACT_OVERRIDES" kind="functionlike"><macro-parameter name="..."><description><para>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.) </para></description></macro-parameter><purpose>Declare multiple override type traits at once naming them <computeroutput>override_...</computeroutput> (for convenience). </purpose><description><para>This variadic macro is provided for convenience as <computeroutput>BOOST_CONTRACT_OVERRIDES(f_1, f_2, ..., f_n)</computeroutput> expands to code equivalent to:</para><para><programlisting language="c++">BOOST_CONTRACT_OVERRIDE(f_1)
1581 BOOST_CONTRACT_OVERRIDE(f_2)
1582 ...
1583 BOOST_CONTRACT_OVERRIDE(f_n)
1584 </programlisting></para><para>On compilers that do not support variadic macros, the override type traits can be equivalently programmed one-by-one calling  <computeroutput><macroname alt="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</macroname></computeroutput> for each function name as shown above.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
1585         Public Function Overrides</link></para>
1586 </para>
1587
1588 </para></description></macro>
1589 </header>
1590 <header name="boost/contract/public_function.hpp">
1591 <para>Program contracts for public functions (including subcontracting). </para><para>The different overloads handle public functions that are static, virtual void, virtual non-void, overriding void, and overriding non-void. </para><namespace name="boost">
1592 <namespace name="contract">
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605 <function name="public_function"><type><classname>specify_precondition_old_postcondition_except</classname></type><template>
1606           <template-type-parameter name="Class"><purpose><para>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 <computeroutput>this</computeroutput> so there is no function argument from which this type template parameter can be automatically deduced by C++).</para></purpose></template-type-parameter>
1607         </template><purpose>Program contracts for static public functions. </purpose><description><para>This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check static class invariants for static public functions:</para><para><programlisting language="c++">class u {
1608     friend class boost::contract::access;
1609
1610     static void static_invariant() { // Optional (as for non-static).
1611         BOOST_CONTRACT_ASSERT(...);
1612         ...
1613     }
1614
1615 public:
1616     static void f(...) {
1617         boost::contract::old_ptr&lt;old_type&gt; old_var;
1618         boost::contract::check c = boost::contract::public_function&lt;u&gt;()
1619             .precondition([&amp;] { // Optional.
1620                 BOOST_CONTRACT_ASSERT(...);
1621                 ...
1622             })
1623             .old([&amp;] { // Optional.
1624                 old_var = BOOST_CONTRACT_OLDOF(old_expr);
1625                 ...
1626             })
1627             .postcondition([&amp;] { // Optional.
1628                 BOOST_CONTRACT_ASSERT(...);
1629                 ...
1630             })
1631             .except([&amp;] { // Optional.
1632                 BOOST_CONTRACT_ASSERT(...);
1633                 ...
1634             })
1635         ;
1636
1637         ... // Function body.
1638     }
1639     
1640     ...
1641 };
1642 </programlisting></para><para>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.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.static_public_functions"> Static Public Functions</link></para>
1643 </para>
1644
1645
1646 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the static public function body (otherwise this library will generate a run-time error, see <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1647 </returns></function>
1648 <function name="public_function"><type><classname>specify_precondition_old_postcondition_except</classname></type><template>
1649           <template-type-parameter name="Class"><purpose><para>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.)</para></purpose></template-type-parameter>
1650         </template><parameter name="obj"><paramtype>Class *</paramtype><description><para>The object <computeroutput>this</computeroutput> from the scope of the enclosing public function declaring the contract. This object might be mutable, <computeroutput>const</computeroutput>, <computeroutput>volatile</computeroutput>, or <computeroutput>const volatile</computeroutput> depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see  <link linkend="boost_contract.extras.volatile_public_functions">
1651             Volatile Public Functions</link>).</para></description></parameter><purpose>Program contracts for public functions that are not static, not virtual, and do not not override. </purpose><description><para>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:</para><para><programlisting language="c++">class u {
1652     friend class boost::contract::access;
1653
1654     void invariant() const { // Optional (as for static and volatile).
1655         BOOST_CONTRACT_ASSERT(...);
1656         ...
1657     }
1658
1659 public:
1660     void f(...) {
1661         boost::contract::old_ptr&lt;old_type&gt; old_var;
1662         boost::contract::check c = boost::contract::public_function(this)
1663             .precondition([&amp;] { // Optional.
1664                 BOOST_CONTRACT_ASSERT(...);
1665                 ...
1666             })
1667             .old([&amp;] { // Optional.
1668                 old_var = BOOST_CONTRACT_OLDOF(old_expr);
1669                 ...
1670             })
1671             .postcondition([&amp;] { // Optional.
1672                 BOOST_CONTRACT_ASSERT(...);
1673                 ...
1674             })
1675             .except([&amp;] { // Optional.
1676                 BOOST_CONTRACT_ASSERT(...);
1677                 ...
1678             })
1679         ;
1680
1681         ... // Function body.
1682     }
1683     
1684     ...
1685 };
1686 </programlisting></para><para>For optimization, this can be omitted for public functions that do not have preconditions, postconditions and exception guarantees, within classes that have no invariants.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.public_functions"> Public Functions</link></para>
1687 </para>
1688
1689
1690
1691 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the public function body (otherwise this library will generate a run-time error, see <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1692 </returns></function>
1693 <function name="public_function"><type><classname>specify_precondition_old_postcondition_except</classname></type><template>
1694           <template-type-parameter name="Class"><purpose><para>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.)</para></purpose></template-type-parameter>
1695         </template><parameter name="v"><paramtype><classname>virtual_</classname> *</paramtype><description><para>The trailing parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function. </para></description></parameter><parameter name="obj"><paramtype>Class *</paramtype><description><para>The object <computeroutput>this</computeroutput> from the scope of the enclosing virtual public function declaring the contract. This object might be mutable, <computeroutput>const</computeroutput>, <computeroutput>volatile</computeroutput>, or <computeroutput>const volatile</computeroutput> depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see  <link linkend="boost_contract.extras.volatile_public_functions">
1696             Volatile Public Functions</link>).</para></description></parameter><purpose>Program contracts for void virtual public functions that do not override. </purpose><description><para>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 <computeroutput>void:</computeroutput> </para><para><programlisting language="c++">class u {
1697     friend class boost::contract::access;
1698
1699     void invariant() const { // Optional (as for static and volatile).
1700         BOOST_CONTRACT_ASSERT(...);
1701         ...
1702     }
1703
1704 public:
1705     void f(..., boost::contract::virtual_* v = 0) {
1706         boost::contract::old_ptr&lt;old_type&gt; old_var;
1707         boost::contract::check c = boost::contract::public_function(v, this)
1708             .precondition([&amp;] { // Optional.
1709                 BOOST_CONTRACT_ASSERT(...);
1710                 ...
1711             })
1712             .old([&amp;] { // Optional.
1713                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
1714                 ...
1715             })
1716             .postcondition([&amp;] { // Optional.
1717                 BOOST_CONTRACT_ASSERT(...);
1718                 ...
1719             })
1720             .except([&amp;] { // Optional.
1721                 BOOST_CONTRACT_ASSERT(...);
1722                 ...
1723             })
1724         ;
1725
1726         ... // Function body.
1727     }
1728     
1729     ...
1730 };
1731 </programlisting></para><para>A virtual public function should always call  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> otherwise this library will not be able to correctly use it for subcontracting.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.virtual_public_functions"> Virtual Public Functions</link></para>
1732 </para>
1733
1734
1735
1736 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the public function body (otherwise this library will generate a run-time error, see  <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1737 </returns></function>
1738 <function name="public_function"><type><classname>specify_precondition_old_postcondition_except</classname>&lt; VirtualResult &gt;</type><template>
1739           <template-type-parameter name="VirtualResult"><purpose><para>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, <computeroutput>boost::optional&lt;<emphasis>return-type</emphasis>&gt;</computeroutput> can also be used (see  <link linkend="boost_contract.advanced.optional_return_values">
1740                         Optional Return Values</link>). (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
1741           <template-type-parameter name="Class"><purpose><para>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.)</para></purpose></template-type-parameter>
1742         </template><parameter name="v"><paramtype><classname>virtual_</classname> *</paramtype><description><para>The trailing parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function. </para></description></parameter><parameter name="r"><paramtype>VirtualResult &amp;</paramtype><description><para>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 <computeroutput>return</computeroutput> statement. </para></description></parameter><parameter name="obj"><paramtype>Class *</paramtype><description><para>The object <computeroutput>this</computeroutput> from the scope of the enclosing virtual public function declaring the contract. This object might be mutable, <computeroutput>const</computeroutput>, <computeroutput>volatile</computeroutput>, or <computeroutput>const volatile</computeroutput> depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see  <link linkend="boost_contract.extras.volatile_public_functions">
1743             Volatile Public Functions</link>).</para></description></parameter><purpose>Program contracts for non-void virtual public functions that do not override. </purpose><description><para>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 <computeroutput>void:</computeroutput> </para><para><programlisting language="c++">class u {
1744     friend class boost::contract::access;
1745
1746     void invariant() const { // Optional (as for static and volatile).
1747         BOOST_CONTRACT_ASSERT(...);
1748         ...
1749     }
1750
1751 public:
1752     t f(..., boost::contract::virtual_* v = 0) {
1753         t result;
1754         boost::contract::old_ptr&lt;old_type&gt; old_var;
1755         boost::contract::check c = boost::contract::public_function(
1756                 v, result, this)
1757             .precondition([&amp;] { // Optional.
1758                 BOOST_CONTRACT_ASSERT(...);
1759                 ...
1760             })
1761             .old([&amp;] { // Optional.
1762                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
1763                 ...
1764             })
1765             .postcondition([&amp;] (t const&amp; result) { // Optional.
1766                 BOOST_CONTRACT_ASSERT(...);
1767                 ...
1768             })
1769             .except([&amp;] { // Optional.
1770                 BOOST_CONTRACT_ASSERT(...);
1771                 ...
1772             })
1773         ;
1774
1775         ... // Function body (use `return result = return_expr`).
1776     }
1777     
1778     ...
1779 };
1780 </programlisting></para><para>A virtual public function should always call  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> otherwise this library will not be able to correctly use it for subcontracting.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.virtual_public_functions"> Virtual Public Functions</link></para>
1781 </para>
1782
1783
1784
1785 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the public function body (otherwise this library will generate a run-time error, see  <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1786 </returns></function>
1787 <function name="public_function"><type><classname>specify_precondition_old_postcondition_except</classname></type><template>
1788           <template-type-parameter name="Override"><purpose><para>The type trait <computeroutput>override_<emphasis>function-name</emphasis></computeroutput> declared using the <computeroutput><macroname alt="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</macroname></computeroutput> 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++). </para></purpose></template-type-parameter>
1789           <template-type-parameter name="F"><purpose><para>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.) </para></purpose></template-type-parameter>
1790           <template-type-parameter name="Class"><purpose><para>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.) </para></purpose></template-type-parameter>
1791           <template-nontype-parameter name="Args"><type>typename...</type><purpose><para>The types of all parameters passed to the enclosing public function override declaring the contract, but excluding the trailing parameter type <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname>*</computeroutput>. 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  <computeroutput><macroname alt="BOOST_CONTRACT_MAX_ARGS">BOOST_CONTRACT_MAX_ARGS</macroname></computeroutput>). (Usually these template parameters are automatically deduced by C++ and they do not need to be explicitly specified by programmers.)</para></purpose></template-nontype-parameter>
1792         </template><parameter name="v"><paramtype><classname>virtual_</classname> *</paramtype><description><para>The trailing parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing public function override. </para></description></parameter><parameter name="f"><paramtype>F</paramtype><description><para>A pointer to the enclosing public function override declaring the contract (but see <link linkend="boost_contract.advanced.function_overloads">
1793             Function Overloads</link>). </para></description></parameter><parameter name="obj"><paramtype>Class *</paramtype><description><para>The object <computeroutput>this</computeroutput> from the scope of the enclosing public function override declaring the contract. This object might be mutable, <computeroutput>const</computeroutput>, <computeroutput>volatile</computeroutput>, or <computeroutput>const volatile</computeroutput> depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see  <link linkend="boost_contract.extras.volatile_public_functions">
1794             Volatile Public Functions</link>). </para></description></parameter><parameter name="args"><paramtype>Args &amp;...</paramtype><description><para>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 <computeroutput>v</computeroutput>.</para></description></parameter><purpose>Program contracts for void public functions overrides (virtual or not). </purpose><description><para>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 <computeroutput>void:</computeroutput> </para><para><programlisting language="c++">class u
1795     #define BASES private boost::contract::constructor_precondition&lt;u&gt;, \
1796             public b, private w
1797     : BASES
1798 {
1799     friend class boost::contract::access;
1800
1801     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
1802     #undef BASES
1803
1804     void invariant() const { // Optional (as for static and volatile).
1805         BOOST_CONTRACT_ASSERT(...);
1806         ...
1807     }
1808
1809     BOOST_CONTRACT_OVERRIDES(f)
1810
1811 public:
1812     // Override from `b::f`.
1813     void f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
1814         boost::contract::old_ptr&lt;old_type&gt; old_var;
1815         boost::contract::check c = boost::contract::public_function&lt;
1816                 override_f&gt;(v, &amp;u::f, this, a_1, ..., a_n)
1817             .precondition([&amp;] { // Optional.
1818                 BOOST_CONTRACT_ASSERT(...);
1819                 ...
1820             })
1821             .old([&amp;] { // Optional.
1822                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
1823                 ...
1824             })
1825             .postcondition([&amp;] { // Optional.
1826                 BOOST_CONTRACT_ASSERT(...);
1827                 ...
1828             })
1829             .except([&amp;] { // Optional.
1830                 BOOST_CONTRACT_ASSERT(...);
1831                 ...
1832             })
1833         ;
1834
1835         ... // Function body.
1836     }
1837     
1838     ...
1839 };
1840 </programlisting></para><para>A public function override should always call  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> otherwise this library will not be able to correctly use it for subcontracting.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
1841         Public Function Overrides</link></para>
1842 </para>
1843
1844
1845
1846 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the public function body (otherwise this library will generate a run-time error, see  <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1847 </returns></function>
1848 <function name="public_function"><type><classname>specify_precondition_old_postcondition_except</classname>&lt; VirtualResult &gt;</type><template>
1849           <template-type-parameter name="Override"><purpose><para>The type trait <computeroutput>override_<emphasis>function-name</emphasis></computeroutput> declared using the <computeroutput><macroname alt="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</macroname></computeroutput> 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++). </para></purpose></template-type-parameter>
1850           <template-type-parameter name="VirtualResult"><purpose><para>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, <computeroutput>boost::optional&lt;<emphasis>return-type</emphasis>&gt;</computeroutput> can also be used (see  <link linkend="boost_contract.advanced.optional_return_values">
1851                         Optional Return Values</link>). (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) </para></purpose></template-type-parameter>
1852           <template-type-parameter name="F"><purpose><para>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.) </para></purpose></template-type-parameter>
1853           <template-type-parameter name="Class"><purpose><para>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.) </para></purpose></template-type-parameter>
1854           <template-nontype-parameter name="Args"><type>typename...</type><purpose><para>The types of all parameters passed to the enclosing public function override declaring the contract, but excluding the trailing parameter type <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname>*</computeroutput>. 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  <computeroutput><macroname alt="BOOST_CONTRACT_MAX_ARGS">BOOST_CONTRACT_MAX_ARGS</macroname></computeroutput>). (Usually these template parameters are automatically deduced by C++ and they do not need to be explicitly specified by programmers.)</para></purpose></template-nontype-parameter>
1855         </template><parameter name="v"><paramtype><classname>virtual_</classname> *</paramtype><description><para>The trailing parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing public function override. </para></description></parameter><parameter name="r"><paramtype>VirtualResult &amp;</paramtype><description><para>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 <computeroutput>return</computeroutput> statement. </para></description></parameter><parameter name="f"><paramtype>F</paramtype><description><para>A pointer to the enclosing public function override declaring the contract (but see <link linkend="boost_contract.advanced.function_overloads">
1856             Function Overloads</link>). </para></description></parameter><parameter name="obj"><paramtype>Class *</paramtype><description><para>The object <computeroutput>this</computeroutput> from the scope of the enclosing public function override declaring the contract. This object might be mutable, <computeroutput>const</computeroutput>, <computeroutput>volatile</computeroutput>, or <computeroutput>const volatile</computeroutput> depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see  <link linkend="boost_contract.extras.volatile_public_functions">
1857             Volatile Public Functions</link>). </para></description></parameter><parameter name="args"><paramtype>Args &amp;...</paramtype><description><para>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 <computeroutput>v</computeroutput>.</para></description></parameter><purpose>Program contracts for non-void public functions overrides (virtual or not). </purpose><description><para>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 <computeroutput>void:</computeroutput> </para><para><programlisting language="c++">class u
1858     #define BASES private boost::contract::constructor_precondition&lt;u&gt;, \
1859             public b, private w
1860     : BASES
1861 {
1862     friend class boost::contract::access;
1863
1864     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
1865     #undef BASES
1866
1867     void invariant() const { // Optional (as for static and volatile).
1868         BOOST_CONTRACT_ASSERT(...);
1869         ...
1870     }
1871
1872     BOOST_CONTRACT_OVERRIDES(f)
1873
1874 public:
1875     // Override from `b::f`.
1876     t f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
1877         t result;
1878         boost::contract::old_ptr&lt;old_type&gt; old_var;
1879         boost::contract::check c = boost::contract::public_function&lt;
1880                 override_f&gt;(v, result, &amp;u::f, this, a_1, ..., a_n)
1881             .precondition([&amp;] { // Optional.
1882                 BOOST_CONTRACT_ASSERT(...);
1883                 ...
1884             })
1885             .old([&amp;] { // Optional.
1886                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
1887                 ...
1888             })
1889             .postcondition([&amp;] (t const&amp; result) { // Optional.
1890                 BOOST_CONTRACT_ASSERT(...);
1891                 ...
1892             })
1893             .except([&amp;] { // Optional.
1894                 BOOST_CONTRACT_ASSERT(...);
1895                 ...
1896             })
1897         ;
1898
1899         ... // Function body (use `return result = return_expr`).
1900     }
1901     
1902     ...
1903 };
1904 </programlisting></para><para>A public function override should always call  <computeroutput><functionname alt="boost::contract::public_function">boost::contract::public_function</functionname></computeroutput> otherwise this library will not be able to correctly use it for subcontracting.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
1905         Public Function Overrides</link></para>
1906 </para>
1907
1908
1909
1910 </para></description><returns><para>The result of this function must be assigned to a variable of type  <computeroutput><classname alt="boost::contract::check">boost::contract::check</classname></computeroutput> declared explicitly (i.e., without using C++11 <computeroutput>auto</computeroutput> declarations) and locally just before the code of the public function body (otherwise this library will generate a run-time error, see  <computeroutput><macroname alt="BOOST_CONTRACT_ON_MISSING_CHECK_DECL">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</macroname></computeroutput>). </para>
1911 </returns></function>
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934 </namespace>
1935 </namespace>
1936 </header>
1937 <header name="boost/contract_macro.hpp">
1938 <para>Allow to disable contracts to completely remove their compile-time and run-time overhead. </para><para>This header automatically includes all header files <computeroutput>boost/contract/*.hpp</computeroutput> necessary to use its macros.</para><para>Almost all the macros defined in this header file are variadic macros. On compilers that do not support variadic macros, programmers can manually code <computeroutput>#ifndef BOOST_CONTRACT_NO_...</computeroutput> statements instead (see  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
1939 Disable Contract Compilation</link>). </para><macro name="BOOST_CONTRACT_PRECONDITION" kind="functionlike"><macro-parameter name="..."/><purpose>Program preconditions that can be completely disabled at compile-time. </purpose><description><para><computeroutput>BOOST_CONTRACT_PRECONDITION(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PRECONDITIONS">BOOST_CONTRACT_NO_PRECONDITIONS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_PRECONDITIONS
1940     .precondition(f)
1941 #endif
1942 </programlisting></para><para>Where:</para><para><itemizedlist>
1943 <listitem><para><computeroutput><emphasis role="bold">f</emphasis></computeroutput> is the nullay functor called by this library to check preconditions <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::precondition_failure">boost::contract::precondition_failure</functionname></computeroutput>). 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.)</para>
1944 </listitem>
1945 </itemizedlist>
1946 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
1947         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link> </para>
1948 </para>
1949 </para></description></macro>
1950 <macro name="BOOST_CONTRACT_POSTCONDITION" kind="functionlike"><macro-parameter name="..."/><purpose>Program postconditions that can be completely disabled at compile-time. </purpose><description><para><computeroutput>BOOST_CONTRACT_POSTCONDITION(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_POSTCONDITIONS">BOOST_CONTRACT_NO_POSTCONDITIONS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
1951     .postcondition(f)
1952 #endif
1953 </programlisting></para><para>Where:</para><para><itemizedlist>
1954 <listitem><para><computeroutput><emphasis role="bold">f</emphasis></computeroutput> is the functor called by this library to check postconditions <computeroutput>f()</computeroutput> or <computeroutput>f(result)</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::postcondition_failure">boost::contract::postcondition_failure</functionname></computeroutput>). 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 <computeroutput>const&amp;</computeroutput>) <computeroutput>result</computeroutput> as its one single parameter <computeroutput>f(result)</computeroutput> but only for virtual public functions and public functions overrides, otherwise it takes no parameter <computeroutput>f()</computeroutput>. (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)</para>
1955 </listitem>
1956 </itemizedlist>
1957 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
1958         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link> </para>
1959 </para>
1960 </para></description></macro>
1961 <macro name="BOOST_CONTRACT_EXCEPT" kind="functionlike"><macro-parameter name="..."/><purpose>Program exception guarantees that can be completely disabled at compile-time. </purpose><description><para><computeroutput>BOOST_CONTRACT_EXCEPT(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when <computeroutput><macroname alt="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_EXCEPTS
1962     .except(f)
1963 #endif
1964 </programlisting></para><para>Where:</para><para><itemizedlist>
1965 <listitem><para><computeroutput><emphasis role="bold">f</emphasis></computeroutput> is the nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::except_failure">boost::contract::except_failure</functionname></computeroutput>). 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.)</para>
1966 </listitem>
1967 </itemizedlist>
1968 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
1969         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link> </para>
1970 </para>
1971 </para></description></macro>
1972 <macro name="BOOST_CONTRACT_OLD" kind="functionlike"><macro-parameter name="..."/><purpose>Program old value copies at body that can be completely disabled at compile-time. </purpose><description><para><computeroutput>BOOST_CONTRACT_OLD(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_OLDS
1973     .old(f)
1974 #endif
1975 </programlisting></para><para>Where:</para><para><itemizedlist>
1976 <listitem><para><computeroutput><emphasis role="bold">f</emphasis></computeroutput> is the nullary functor called by this library <computeroutput>f()</computeroutput> 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 <computeroutput><macroname alt="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</macroname></computeroutput>. Any exception thrown by a call to this functor will result in this library calling <computeroutput><functionname alt="boost::contract::old_failure">boost::contract::old_failure</functionname></computeroutput> (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.)</para>
1977 </listitem>
1978 </itemizedlist>
1979 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
1980         Disable Contract Compilation</link>,  <link linkend="boost_contract.advanced.old_values_copied_at_body">
1981         Old Values Copied at Body</link> </para>
1982 </para>
1983 </para></description></macro>
1984 <macro name="BOOST_CONTRACT_OLD_PTR" kind="functionlike"><macro-parameter name="..."/><purpose>Program old values that can be completely disabled at compile-time for old value types that are required to be copyable. </purpose><description><para>This is used to program old value copies for copyable types:</para><para><programlisting language="c++">class u {
1985 public:
1986     void f(...) {
1987         BOOST_CONTRACT_OLD_PTR(old_type_a)(old_var_a); // Null...
1988         BOOST_CONTRACT_OLD_PTR(old_type_b)(old_var_b, old_expr_b); // Set.
1989         BOOST_CONTRACT_PUBLIC_FUNCTION(this)
1990             ...
1991             BOOST_CONTRACT_OLD([&amp;] {
1992                 old_var_a = BOOST_CONTRACT_OLDOF(old_expr_a); // ...set.
1993                 ...
1994             })
1995             ...
1996         ;
1997
1998         ... // Function body.
1999     }
2000
2001     virtual void g(..., boost::contract::virtual_* v = 0) {
2002         BOOST_CONTRACT_OLD_PTR(old_type_a)(old_var_a); // No `v`
2003         BOOST_CONTRACT_OLD_PTR(old_type_b)(v, old_var_b, old_expr_b); // `v`
2004         BOOST_CONTRACT_PUBLIC_FUNCTION(v, this)
2005             ...
2006             BOOST_CONTRACT_OLD([&amp;] {
2007                 old_var_a = BOOST_CONTRACT_OLDOF(v, old_expr_a); // `v`
2008                 ...
2009             })
2010             ...
2011         ;
2012
2013         ... // Function body.
2014     }
2015
2016     ...
2017 };
2018 </programlisting></para><para>This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput> is defined).</para><para>1. <computeroutput>BOOST_CONTRACT_OLD_PTR(old_type)(old_var)</computeroutput> expands to code equivalent to the following (this leaves the old value pointer null):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_OLDS
2019     // This declaration does not need to use `v`.
2020     boost::contract::old_ptr&lt;old_type&gt; old_var
2021 #endif
2022 </programlisting></para><para>2. <computeroutput>BOOST_CONTRACT_OLD_PTR(old_type)(old_var, old_expr)</computeroutput> 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):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_OLDS
2023     boost::contract::old_ptr&lt;old_type&gt; old_var =
2024             BOOST_CONTRACT_OLDOF(old_expr)
2025 #endif
2026 </programlisting></para><para>3. <computeroutput>BOOST_CONTRACT_OLD_PTR(old_type)(v, old_var, old_expr)</computeroutput> expands to code equivalent to the following (this initializes the pointer to the old value copy for virtual public functions and public function overrides):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_OLDS
2027     boost::contract::old_ptr&lt;old_type&gt; old_var =
2028             BOOST_CONTRACT_OLDOF(v, old_expr)
2029 #endif
2030 </programlisting></para><para>Where:</para><para><itemizedlist>
2031 <listitem><para><computeroutput><emphasis role="bold">old_type</emphasis></computeroutput> is the type of the pointed old value. This type must be copyable (i.e., <computeroutput>boost::contract::is_old_value_copyable&lt;old_type&gt;::value</computeroutput> is <computeroutput>true</computeroutput>), otherwise this pointer will always be null and this library will generate a compile-time error when the pointer is dereferenced (see <computeroutput><macroname alt="BOOST_CONTRACT_OLD_PTR_IF_COPYABLE">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</macroname></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.) (Rationale: Template parameters like this one are specified to this library macro interface using their own set of parenthesis <computeroutput>SOME_MACRO(template_params)(other_params)</computeroutput>.) </para>
2032 </listitem>
2033 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra training parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function or public function override declaring the contract. (This is not a variadic macro parameter but it should never contain commas because it is an identifier.) </para>
2034 </listitem>
2035 <listitem><para><computeroutput><emphasis role="bold">old_var</emphasis></computeroutput> 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.) </para>
2036 </listitem>
2037 <listitem><para><computeroutput><emphasis role="bold">old_expr</emphasis></computeroutput> 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 and <computeroutput>BOOST_CONTRACT_OLD_PTR(old_type)(v, old_var, (old_expr))</computeroutput> will always work.)</para>
2038 </listitem>
2039 </itemizedlist>
2040 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2041         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.old_values"> Old Values</link> </para>
2042 </para>
2043 </para></description></macro>
2044 <macro name="BOOST_CONTRACT_OLD_PTR_IF_COPYABLE" kind="functionlike"><macro-parameter name="..."/><purpose>Program old values that can be completely disabled at compile-time for old value types that are not required to be copyable. </purpose><description><para>This is used to program old value copies for types that might or might not be copyable:</para><para><programlisting language="c++">template&lt;typename T&gt; // Type `T` might or not be copyable.
2045 class u {
2046 public:
2047     void f(...) {
2048         BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_a)(old_var_a);
2049         BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_b)(old_var_b,
2050                 old_expr_b);
2051         BOOST_CONTRACT_PUBLIC_FUNCTION(this)
2052             ...
2053             BOOST_CONTRACT_OLD([&amp;] {
2054                 old_var_a = BOOST_CONTRACT_OLDOF(old_expr_a);
2055                 ...
2056             })
2057             ... // In postconditions or exception guarantees:
2058                 if(old_var_a) ... // Always null for non-copyable types.
2059                 if(old_var_b) ... // Always null for non-copyable types.
2060             ...
2061         ;
2062
2063         ... // Function body.
2064     }
2065
2066     virtual void g(..., boost::contract::virtual_* v = 0) {
2067         BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_a)(old_var_a);
2068         BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_b)(v, old_var_b,
2069                 old_expr_b);
2070         BOOST_CONTRACT_PUBLIC_FUNCTION(v, this)
2071             ...
2072             BOOST_CONTRACT_OLD([&amp;] {
2073                 old_var_a = BOOST_CONTRACT_OLDOF(v, old_expr_a);
2074                 ...
2075             })
2076             ... // In postconditions or exception guarantees:
2077                 if(old_var_a) ... // Always null for non-copyable types.
2078                 if(old_var_b) ... // Always null for non-copyable types.
2079             ...
2080         ;
2081
2082         ... // Function body.
2083     }
2084
2085     ...
2086 };
2087 </programlisting></para><para>This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</macroname></computeroutput> is defined).</para><para>1. <computeroutput>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(old_var)</computeroutput> expands to code equivalent to the following (this leaves the old value pointer null):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_OLDS
2088     // This declaration does not need to use `v`.
2089     boost::contract::old_ptr_if_copyable&lt;old_type&gt; old_var
2090 #endif
2091 </programlisting></para><para>2. <computeroutput>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(old_var, old_expr)</computeroutput> 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):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_OLDS
2092     boost::contract::old_ptr_if_copyable&lt;old_type&gt; old_var =
2093             BOOST_CONTRACT_OLDOF(old_expr)
2094 #endif
2095 </programlisting></para><para>3. <computeroutput>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(v, old_var, old_expr)</computeroutput> expands to code equivalent to the following (this initializes the pointer to the old value copy for virtual public functions and public function overrides):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_OLDS
2096     boost::contract::old_ptr_if_copyable&lt;old_type&gt; old_var =
2097             BOOST_CONTRACT_OLDOF(v, old_expr)
2098 #endif
2099 </programlisting></para><para>Where:</para><para><itemizedlist>
2100 <listitem><para><computeroutput><emphasis role="bold">old_type</emphasis></computeroutput> is the type of the pointed old value. If this type is not copyable (i.e., <computeroutput>boost::contract::is_old_value_copyable&lt;old_type&gt;::value</computeroutput> is <computeroutput>false</computeroutput>), this pointer will always be null, but this library will not generate a compile-time error when this pointer is dereferenced (see <computeroutput><macroname alt="BOOST_CONTRACT_OLD_PTR">BOOST_CONTRACT_OLD_PTR</macroname></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.) </para>
2101 </listitem>
2102 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra trailing parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function or public function override declaring the contract. (This is not a variadic macro parameter but it should never contain commas because it is an identifier.) </para>
2103 </listitem>
2104 <listitem><para><computeroutput><emphasis role="bold">old_var</emphasis></computeroutput> 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.) </para>
2105 </listitem>
2106 <listitem><para><computeroutput><emphasis role="bold">old_expr</emphasis></computeroutput> 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 and <computeroutput>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(v, old_var, (old_expr))</computeroutput> will always work.)</para>
2107 </listitem>
2108 </itemizedlist>
2109 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2110         Disable Contract Compilation</link>,  <link linkend="boost_contract.extras.old_value_requirements__templates_">
2111         Old Value Requirements</link> </para>
2112 </para>
2113 </para></description></macro>
2114 <macro name="BOOST_CONTRACT_INVARIANT" kind="functionlike"><macro-parameter name="..."/><purpose>Program (constant) class invariants that can be completely disabled at compile-time. </purpose><description><para><computeroutput>BOOST_CONTRACT_INVARIANT</computeroutput>({ ... }) expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_INVARIANTS
2115     void BOOST_CONTRACT_INVARIANT_FUNC() const {
2116         ...
2117     }
2118 #endif
2119 </programlisting></para><para>Where:</para><para><itemizedlist>
2120 <listitem><para><emphasis role="bold">{ ... }</emphasis> is the definition of the function that checks class invariants for public functions that are not static and not volatile (see <computeroutput><macroname alt="BOOST_CONTRACT_STATIC_INVARIANT">BOOST_CONTRACT_STATIC_INVARIANT</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_INVARIANT_VOLATILE">BOOST_CONTRACT_INVARIANT_VOLATILE</macroname></computeroutput>). The curly parenthesis are mandatory (rationale: this is so the syntax of this macro resembles mote the syntax of the lambda functions usually used to specify preconditions, etc.). Assertions within this function are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this function indicates a contract assertion failure (and will result in this library calling either  <computeroutput><functionname alt="boost::contract::entry_invariant_failure">boost::contract::entry_invariant_failure</functionname></computeroutput> or  <computeroutput><functionname alt="boost::contract::exit_invariant_failure">boost::contract::exit_invariant_failure</functionname></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)</para>
2121 </listitem>
2122 </itemizedlist>
2123 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2124         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link> </para>
2125 </para>
2126 </para></description></macro>
2127 <macro name="BOOST_CONTRACT_INVARIANT_VOLATILE" kind="functionlike"><macro-parameter name="..."/><purpose>Program volatile class invariants that can be completely disabled at compile-time. </purpose><description><para><computeroutput>BOOST_CONTRACT_INVARIANT_VOLATILE</computeroutput>({ ... }) expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_INVARIANTS
2128     void BOOST_CONTRACT_INVARIANT_FUNC() const volatile {
2129         ...
2130     }
2131 #endif
2132 </programlisting></para><para>Where:</para><para><itemizedlist>
2133 <listitem><para><emphasis role="bold">{ ... }</emphasis> is the definition of the function that checks class invariants for volatile public functions (see <computeroutput><macroname alt="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_STATIC_INVARIANT">BOOST_CONTRACT_STATIC_INVARIANT</macroname></computeroutput>). The curly parenthesis are mandatory. Assertions within this function are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this function indicates a contract assertion failure (and will result in this library calling either  <computeroutput><functionname alt="boost::contract::entry_invariant_failure">boost::contract::entry_invariant_failure</functionname></computeroutput> or  <computeroutput><functionname alt="boost::contract::exit_invariant_failure">boost::contract::exit_invariant_failure</functionname></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)</para>
2134 </listitem>
2135 </itemizedlist>
2136 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2137         Disable Contract Compilation</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
2138         Volatile Public Functions</link> </para>
2139 </para>
2140 </para></description></macro>
2141 <macro name="BOOST_CONTRACT_STATIC_INVARIANT" kind="functionlike"><macro-parameter name="..."/><purpose>Program static class invariants that can be completely disabled at compile-time. </purpose><description><para><computeroutput>BOOST_CONTRACT_STATIC_INVARIANT</computeroutput>({ ... }) expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_INVARIANTS">BOOST_CONTRACT_NO_INVARIANTS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_INVARIANTS
2142     static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() {
2143         ...
2144     }
2145 #endif
2146 </programlisting></para><para>Where:</para><para><itemizedlist>
2147 <listitem><para><emphasis role="bold">{ ... }</emphasis> is the definition of the function that checks class invariants for static public functions (see <computeroutput><macroname alt="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</macroname></computeroutput> and  <computeroutput><macroname alt="BOOST_CONTRACT_INVARIANT_VOLATILE">BOOST_CONTRACT_INVARIANT_VOLATILE</macroname></computeroutput>). The curly parenthesis are mandatory. Assertions within this function are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this function indicates a contract assertion failure (and will result in this library calling either  <computeroutput><functionname alt="boost::contract::entry_invariant_failure">boost::contract::entry_invariant_failure</functionname></computeroutput> or  <computeroutput><functionname alt="boost::contract::exit_invariant_failure">boost::contract::exit_invariant_failure</functionname></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)</para>
2148 </listitem>
2149 </itemizedlist>
2150 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2151         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link> </para>
2152 </para>
2153 </para></description></macro>
2154 <macro name="BOOST_CONTRACT_CONSTRUCTOR" kind="functionlike"><macro-parameter name="..."/><purpose>Program contracts that can be completely disabled at compile-time for constructors. </purpose><description><para>This is used together with <computeroutput><macroname alt="BOOST_CONTRACT_POSTCONDITION">BOOST_CONTRACT_POSTCONDITION</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</macroname></computeroutput> to specify postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for constructors (see  <computeroutput><macroname alt="BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION">BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION</macroname></computeroutput> to specify preconditions for constructors):</para><para><programlisting language="c++">class u {
2155     friend class boost::contract::access;
2156
2157     BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
2158         BOOST_CONTRACT_ASSERT(...);
2159         ...
2160     })
2161
2162 public:
2163     u(...) {
2164         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2165         BOOST_CONTRACT_CONSTRUCTOR(this)
2166             // No `PRECONDITION` (use `CONSTRUCTOR_PRECONDITION` if needed).
2167             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2168                 old_var = BOOST_CONTRACT_OLDOF(old_epxr);
2169                 ...
2170             })
2171             BOOST_CONTRACT_POSTCONDITION([&amp;] { // Optional.
2172                 BOOST_CONTRACT_ASSERT(...);
2173                 ...
2174             })
2175             BOOST_CONTRACT_EXCEPT([&amp;] { // Optional.
2176                 BOOST_CONTRACT_ASSERT(...);
2177                 ...
2178             })
2179         ; // Trailing `;` is required.
2180
2181         ... // Constructor body.
2182     }
2183
2184     ...
2185 };
2186 </programlisting></para><para>For optimization, this can be omitted for constructors that do not have postconditions and exception guarantees, within classes that have no invariants.</para><para><computeroutput>BOOST_CONTRACT_CONSTRUCTOR(obj)</computeroutput> expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_CONSTRUCTORS">BOOST_CONTRACT_NO_CONSTRUCTORS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_CONSTRUCTORS
2187     boost::contract::check internal_var =
2188             boost::contract::constructor(obj)
2189 #endif
2190 </programlisting></para><para>Where:</para><para><itemizedlist>
2191 <listitem><para><computeroutput><emphasis role="bold">obj</emphasis></computeroutput> is the object <computeroutput>this</computeroutput> from the scope of the enclosing constructor declaring the contract. Constructors check all class invariants, including static and volatile invariants (see <computeroutput><macroname alt="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_STATIC_INVARIANT">BOOST_CONTRACT_STATIC_INVARIANT</macroname></computeroutput>, and  <computeroutput><macroname alt="BOOST_CONTRACT_INVARIANT_VOLATILE">BOOST_CONTRACT_INVARIANT_VOLATILE</macroname></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.) </para>
2192 </listitem>
2193 <listitem><para><computeroutput><emphasis role="bold">internal_var</emphasis></computeroutput> 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).</para>
2194 </listitem>
2195 </itemizedlist>
2196 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2197         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.constructors"> Constructors</link> </para>
2198 </para>
2199 </para></description></macro>
2200 <macro name="BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION" kind="functionlike"><macro-parameter name="..."/><purpose>Program preconditions that can be disabled at compile-time for constructors. </purpose><description><para>This is used together with <computeroutput><macroname alt="BOOST_CONTRACT_CONSTRUCTOR">BOOST_CONTRACT_CONSTRUCTOR</macroname></computeroutput> 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,  <computeroutput><classname alt="boost::contract::constructor_precondition">boost::contract::constructor_precondition</classname></computeroutput> must be the first and private base of the class declaring the constructor for which preconditions are programmed:</para><para><programlisting language="c++">class u
2201     #define BASES private boost::contract::constructor_precondition&lt;u&gt;, \
2202             public b
2203     : BASES
2204 {
2205     friend class boost::contract::access;
2206
2207     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
2208     #undef BASES
2209
2210     ...
2211
2212 public:
2213     explicit u(unsigned x) :
2214         BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(u)([&amp;] {
2215             BOOST_CONTRACT_ASSERT(x != 0);
2216         }),
2217         b(1 / x)
2218     {
2219         ...
2220     }
2221
2222     ...
2223 };
2224 </programlisting></para><para><computeroutput>BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(class_type)(f)</computeroutput> expands to code equivalent to the following (note that when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PRECONDITIONS">BOOST_CONTRACT_NO_PRECONDITIONS</macroname></computeroutput> 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):</para><para><programlisting language="c++">// Guarded only by NO_PRECONDITIONS (and not also by NO_CONSTRUCTORS)
2225 // because for constructor's preconditions (not for postconditions, etc.).
2226 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
2227     boost::contract::constructor_precondition&lt;class_type&gt;(f)
2228 #else // No-op call (likely optimized away, minimal to no overhead).
2229     boost::contract::constructor_precondition&lt;class_type&gt;()
2230 #endif
2231 </programlisting></para><para>Where:</para><para><itemizedlist>
2232 <listitem><para><computeroutput><emphasis role="bold">class_type</emphasis></computeroutput> 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.) </para>
2233 </listitem>
2234 <listitem><para><computeroutput><emphasis role="bold">f</emphasis></computeroutput> is the nullary functor called by this library to check constructor preconditions <computeroutput>f()</computeroutput>. Assertions within this functor call are usually programmed using  <computeroutput><macroname alt="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</macroname></computeroutput>, but any exception thrown by a call to this functor indicates a contract failure (and will result in this library calling  <computeroutput><functionname alt="boost::contract::precondition_failure">boost::contract::precondition_failure</functionname></computeroutput>). 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.)</para>
2235 </listitem>
2236 </itemizedlist>
2237 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2238         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.constructors"> Constructors</link> </para>
2239 </para>
2240 </para></description></macro>
2241 <macro name="BOOST_CONTRACT_DESTRUCTOR" kind="functionlike"><macro-parameter name="..."/><purpose>Program contracts that can be completely disabled at compile-time for destructors. </purpose><description><para>This is used together with <computeroutput><macroname alt="BOOST_CONTRACT_POSTCONDITION">BOOST_CONTRACT_POSTCONDITION</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</macroname></computeroutput> 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  <link linkend="boost_contract.contract_programming_overview.destructor_calls"> Destructor Calls</link>):</para><para><programlisting language="c++">class u {
2242     friend class boost::contract::access;
2243
2244     BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
2245         BOOST_CONTRACT_ASSERT(...);
2246         ...
2247     })
2248
2249 public:
2250     ~u() {
2251         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2252         BOOST_CONTRACT_DESTRUCTOR(this)
2253             // No `PRECONDITION` (destructors have no preconditions).
2254             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2255                 old_var = BOOST_CONTRACT_OLDOF(old_expr);
2256                 ...
2257             })
2258             BOOST_CONTRACT_POSTCONDITION([&amp;] { // Optional.
2259                 BOOST_CONTRACT_ASSERT(...);
2260                 ...
2261             })
2262             BOOST_CONTRACT_EXCEPT([&amp;] { // Optional.
2263                 BOOST_CONTRACT_ASSERT(...);
2264                 ...
2265             })
2266         ; // Trailing `;` is required.
2267
2268         ... // Destructor body.
2269     }
2270     
2271     ...
2272 };
2273 </programlisting></para><para>For optimization, this can be omitted for destructors that do not have postconditions and exception guarantees, within classes that have no invariants.</para><para><computeroutput>BOOST_CONTRACT_DESTRUCTOR(obj)</computeroutput> expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_DESTRUCTORS">BOOST_CONTRACT_NO_DESTRUCTORS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_DESTRUCTORS
2274     boost::contract::check internal_var =
2275             boost::contract::destructor(obj)
2276 #endif
2277 </programlisting></para><para>Where:</para><para><itemizedlist>
2278 <listitem><para><computeroutput><emphasis role="bold">obj</emphasis></computeroutput> is the object <computeroutput>this</computeroutput> from the scope of the enclosing destructor declaring the contract. Destructors check all class invariants, including static and volatile invariants (see <link linkend="boost_contract.tutorial.class_invariants">
2279         Class Invariants</link> and  <link linkend="boost_contract.extras.volatile_public_functions">
2280         Volatile Public Functions</link>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.) </para>
2281 </listitem>
2282 <listitem><para><computeroutput><emphasis role="bold">internal_var</emphasis></computeroutput> 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).</para>
2283 </listitem>
2284 </itemizedlist>
2285 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2286         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.destructors"> Destructors</link> </para>
2287 </para>
2288 </para></description></macro>
2289 <macro name="BOOST_CONTRACT_FUNCTION" kind="functionlike"><macro-parameter name=""/><purpose>Program contracts that can be completely disabled at compile-time for (non-public) functions. </purpose><description><para>This is used together with <computeroutput><macroname alt="BOOST_CONTRACT_PRECONDITION">BOOST_CONTRACT_PRECONDITION</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_POSTCONDITION">BOOST_CONTRACT_POSTCONDITION</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</macroname></computeroutput> to specify preconditions, postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for (non-public) functions:</para><para><programlisting language="c++">void f(...) {
2290     BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2291     BOOST_CONTRACT_FUNCTION()
2292         BOOST_CONTRACT_PRECONDITION([&amp;] { // Optional.
2293             BOOST_CONTRACT_ASSERT(...);
2294             ...
2295         })
2296         BOOST_CONTRACT_OLD([&amp;] { // Optional.
2297             old_var = BOOST_CONTRACT_OLDOF(old_expr);  
2298             ...
2299         })
2300         BOOST_CONTRACT_POSTCONDITION([&amp;] { // Optional.
2301             BOOST_CONTRACT_ASSERT(...);
2302             ...
2303         })
2304         BOOST_CONTRACT_EXCEPT([&amp;] { // Optional.
2305             BOOST_CONTRACT_ASSERT(...);
2306             ...
2307         })
2308     ; // Trailing `;` is required.
2309
2310     ... // Function body.
2311 }
2312 </programlisting></para><para>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.</para><para><computeroutput>BOOST_CONTRACT_FUNCTION()</computeroutput> expands to code equivalent to the following (note that no code is generated when <computeroutput><macroname alt="BOOST_CONTRACT_NO_FUNCTIONS">BOOST_CONTRACT_NO_FUNCTIONS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_FUNCTIONS
2313     boost::contract::check internal_var =
2314             boost::contract::function()
2315 #endif
2316 </programlisting></para><para>Where:</para><para><itemizedlist>
2317 <listitem><para><computeroutput><emphasis role="bold">internal_var</emphasis></computeroutput> 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).</para>
2318 </listitem>
2319 </itemizedlist>
2320 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2321         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.non_member_functions"> Non-Member Functions</link>,  <link linkend="boost_contract.advanced.private_and_protected_functions">
2322         Private and Protected Functions</link>,  <link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">
2323         Lambdas, Loops, Code Blocks</link> </para>
2324 </para>
2325 </para></description></macro>
2326 <macro name="BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION" kind="functionlike"><macro-parameter name="..."/><purpose>Program contracts that can be completely disabled at compile-time for static public functions. </purpose><description><para>This is used together with <computeroutput><macroname alt="BOOST_CONTRACT_PRECONDITION">BOOST_CONTRACT_PRECONDITION</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_POSTCONDITION">BOOST_CONTRACT_POSTCONDITION</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</macroname></computeroutput> to specify preconditions, postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for static public functions:</para><para><programlisting language="c++">class u {
2327     friend class boost::contract::access;
2328
2329     BOOST_CONTRACT_STATIC_INVARIANT({ // Optional (as for non-static).
2330         BOOST_CONTRACT_ASSERT(...);
2331         ...
2332     })
2333
2334 public:
2335     static void f(...) {
2336         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2337         BOOST_CONTRACT_PUBLIC_FUNCTION(u)
2338             BOOST_CONTRACT_PRECONDITION([&amp;] { // Optional.
2339                 BOOST_CONTRACT_ASSERT(...);
2340                 ...
2341             })
2342             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2343                 old_var = BOOST_CONTRACT_OLDOF(old_expr);
2344                 ...
2345             })
2346             BOOST_CONTRACT_POSTCONDITION([&amp;] { // Optional.
2347                 BOOST_CONTRACT_ASSERT(...);
2348                 ...
2349             })
2350             BOOST_CONTRACT_EXCEPT([&amp;] { // Optional.
2351                 BOOST_CONTRACT_ASSERT(...);
2352                 ...
2353             })
2354         ; // Trailing `;` is required.
2355
2356         ... // Function body.
2357     }
2358     
2359     ...
2360 };
2361 </programlisting></para><para>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.</para><para><computeroutput>BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(class_type)</computeroutput> expands to code equivalent to the following (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</macroname></computeroutput> is defined):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
2362     boost::contract::check internal_var =
2363             boost::contract::public_function&lt;class_type&gt;()
2364 #endif
2365 </programlisting></para><para>Where:</para><para><itemizedlist>
2366 <listitem><para><computeroutput><emphasis role="bold">class_type</emphasis></computeroutput> 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.) </para>
2367 </listitem>
2368 <listitem><para><computeroutput><emphasis role="bold">internal_var</emphasis></computeroutput> 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).</para>
2369 </listitem>
2370 </itemizedlist>
2371 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2372         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.static_public_functions"> Static Public Functions</link> </para>
2373 </para>
2374 </para></description></macro>
2375 <macro name="BOOST_CONTRACT_PUBLIC_FUNCTION" kind="functionlike"><macro-parameter name="..."/><purpose>Program contracts that can be completely disabled at compile-time for non-static public functions that do not override. </purpose><description><para>This is used together with <computeroutput><macroname alt="BOOST_CONTRACT_PRECONDITION">BOOST_CONTRACT_PRECONDITION</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_POSTCONDITION">BOOST_CONTRACT_POSTCONDITION</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</macroname></computeroutput> 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:</para><para><programlisting language="c++">class u {
2376     friend class boost::contract::access;
2377
2378     BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
2379         BOOST_CONTRACT_ASSERT(...);
2380         ...
2381     })
2382
2383 public:
2384     // Non-virtual (same if void).
2385     t f(...) {
2386         t result;
2387         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2388         BOOST_CONTRACT_PUBLIC_FUNCTION(this)
2389             BOOST_CONTRACT_PRECONDITION([&amp;] { // Optional.
2390                 BOOST_CONTRACT_ASSERT(...);
2391                 ...
2392             })
2393             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2394                 old_var = BOOST_CONTRACT_OLDOF(old_expr);
2395                 ...
2396             })
2397             BOOST_CONTRACT_POSTCONDITION([&amp;] { // Optional.
2398                 BOOST_CONTRACT_ASSERT(...);
2399                 ...
2400             })
2401             BOOST_CONTRACT_EXCEPT([&amp;] { // Optional.
2402                 BOOST_CONTRACT_ASSERT(...);
2403                 ...
2404             })
2405         ; // Trailing `;` is required.
2406
2407         ... // Function body (use `return result = return_expr`).
2408     }
2409     
2410     // Virtual and void.
2411     virtual void g(..., boost::contract::virtual_* v = 0) {
2412         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2413         BOOST_CONTRACT_PUBLIC_FUNCTION(v, this)
2414             ...
2415             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2416                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
2417                 ...
2418             })
2419             ...
2420         ; // Trailing `;` is required.
2421         
2422         ... // Function body.
2423     }
2424     
2425     // Virtual and non-void.
2426     virtual t h(..., boost::contract::virtual_* v = 0) {
2427         t result;
2428         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2429         BOOST_CONTRACT_PUBLIC_FUNCTION(v, result, this)
2430             ...
2431             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2432                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
2433                 ...
2434             })
2435             BOOST_CONTRACT_POSTCONDITION([&amp;] (t const&amp; result) { // Optional
2436                 BOOST_CONTRACT_ASSERT(...);
2437                 ...
2438             })
2439             ...
2440         ; // Trailing `;` is required.
2441         
2442         ... // Function body (use `return result = return_expr`).
2443     }
2444     
2445     ...
2446 };
2447 </programlisting></para><para>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  <computeroutput><macroname alt="BOOST_CONTRACT_PUBLIC_FUNCTION">BOOST_CONTRACT_PUBLIC_FUNCTION</macroname></computeroutput> otherwise this library will not be able to correctly use them for subcontracting.</para><para>This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</macroname></computeroutput> is defined).</para><para>1. <computeroutput>BOOST_CONTRACT_PUBLIC_FUNCTION(obj)</computeroutput> expands to code equivalent to the following (for non-virtual public functions that are not static and do not override, returning void or not):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
2448     boost::contract::check internal_var =
2449             boost::contract::public_function(obj)
2450 #endif
2451 </programlisting></para><para>2. <computeroutput>BOOST_CONTRACT_PUBLIC_FUNCTION(v, obj)</computeroutput> expands to code equivalent to the following (for virtual public functions that do not override, returning void):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
2452     boost::contract::check internal_var =
2453             boost::contract::public_function(v, obj)
2454 #endif
2455 </programlisting></para><para>3. <computeroutput>BOOST_CONTRACT_PUBLIC_FUNCTION(v, r, obj)</computeroutput> expands to code equivalent to the following (for virtual public functions that do not override, not returning void):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
2456     boost::contract::check internal_var =
2457             boost::contract::public_function(v, r, obj)
2458 #endif
2459 </programlisting></para><para>Where (these are all variadic macro parameters so they can contain commas not protected by round parenthesis):</para><para><itemizedlist>
2460 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function declaring the contract. </para>
2461 </listitem>
2462 <listitem><para><computeroutput><emphasis role="bold">r</emphasis></computeroutput> 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 <computeroutput>return</computeroutput> statement. </para>
2463 </listitem>
2464 <listitem><para><computeroutput><emphasis role="bold">obj</emphasis></computeroutput> is the object <computeroutput>this</computeroutput> from the scope of the enclosing public function declaring the contract. This object might be mutable, <computeroutput>const</computeroutput>, <computeroutput>volatile</computeroutput>, or <computeroutput>const volatile</computeroutput> depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see <link linkend="boost_contract.extras.volatile_public_functions">
2465         Volatile Public Functions</link>). </para>
2466 </listitem>
2467 <listitem><para><computeroutput><emphasis role="bold">internal_var</emphasis></computeroutput> 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).</para>
2468 </listitem>
2469 </itemizedlist>
2470 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2471         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.public_functions"> Public Functions</link>,  <link linkend="boost_contract.tutorial.virtual_public_functions">
2472         Virtual Public Functions</link> </para>
2473 </para>
2474 </para></description></macro>
2475 <macro name="BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE" kind="functionlike"><macro-parameter name="..."/><purpose>Program contracts that can be completely disabled at compile-time for public function overrides. </purpose><description><para>This is used together with <computeroutput><macroname alt="BOOST_CONTRACT_PRECONDITION">BOOST_CONTRACT_PRECONDITION</macroname></computeroutput>,  <computeroutput><macroname alt="BOOST_CONTRACT_POSTCONDITION">BOOST_CONTRACT_POSTCONDITION</macroname></computeroutput>, <computeroutput><macroname alt="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</macroname></computeroutput>, and <computeroutput><macroname alt="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</macroname></computeroutput> 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):</para><para><programlisting language="c++">class u
2476     #define BASES private boost::contract::constructor_precondition&lt;u&gt;, \
2477             public b, private w
2478     : BASES
2479 {
2480     friend class boost::contract::access;
2481
2482     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
2483     #undef BASES
2484
2485     BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile).
2486         BOOST_CONTRACT_ASSERT(...);
2487         ...
2488     })
2489
2490     BOOST_CONTRACT_OVERRIDES(f, g)
2491
2492 public:
2493     // Override from `b::f`, and void.
2494     void f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
2495         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2496         BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_f)(
2497                 v, &amp;u::f, this, a_1, ..., a_n)
2498             BOOST_CONTRACT_PRECONDITION([&amp;] { // Optional.
2499                 BOOST_CONTRACT_ASSERT(...);
2500                 ...
2501             })
2502             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2503                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
2504                 ...
2505             })
2506             BOOST_CONTRACT_POSTCONDITION([&amp;] { // Optional.
2507                 BOOST_CONTRACT_ASSERT(...);
2508                 ...
2509             })
2510             BOOST_CONTRACT_EXCEPT([&amp;] { // Optional.
2511                 BOOST_CONTRACT_ASSERT(...);
2512                 ...
2513             })
2514         ; // Trailing `;` is required.
2515
2516         ... // Function body.
2517     }
2518     
2519     // Override from `b::g`, and void.
2520     t g(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
2521         t result;
2522         BOOST_CONTRACT_OLD_PTR(old_type)(old_var);
2523         BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_g)(
2524                 v, result, &amp;u::g, this, a_1, ..., a_n)
2525             ...
2526             BOOST_CONTRACT_OLD([&amp;] { // Optional.
2527                 old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
2528                 ...
2529             })
2530             BOOST_CONTRACT_POSTCONDITION([&amp;] (t const&amp; result) { // Optional
2531                 BOOST_CONTRACT_ASSERT(...);
2532                 ...
2533             })
2534             ...
2535         ; // Trailing `;` is required.
2536
2537         ... // Function body (use `return result = return_expr`).
2538     }
2539     
2540     ...
2541 };
2542 </programlisting></para><para>Public function overrides should always use  <computeroutput><macroname alt="BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE">BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</macroname></computeroutput> otherwise this library will not be able to correctly use it for subcontracting.</para><para>This is an overloaded variadic macro and it can be used in the following different ways (note that no code is generated when  <computeroutput><macroname alt="BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</macroname></computeroutput> is defined).</para><para>1. <computeroutput>BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_type)(v, f, obj, ...)</computeroutput> expands to code equivalent to the following (for public function overrides that return void):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
2543     boost::contract::check internal_var = boost::contract::
2544             public_function&lt;override_type&gt;(v, f, obj, ...)
2545 #endif
2546 </programlisting></para><para>2. <computeroutput>BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_type)(v, r, f, obj, ...)</computeroutput> expands to code equivalent to the following (for public function overrides that do not return void):</para><para><programlisting language="c++">#ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
2547     boost::contract::check internal_var = boost::contract::
2548             public_function&lt;override_type&gt;(v, r, f, obj, ...)
2549 #endif
2550 </programlisting></para><para>Where (these are all variadic macro parameters so they can contain commas not protected by round parenthesis):</para><para><itemizedlist>
2551 <listitem><para><computeroutput><emphasis role="bold">override_type</emphasis></computeroutput> is the type <computeroutput>override_<emphasis>function-name</emphasis></computeroutput> declared using the  <computeroutput><macroname alt="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</macroname></computeroutput> or related macros. </para>
2552 </listitem>
2553 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra parameter of type  <computeroutput><classname alt="boost::contract::virtual_">boost::contract::virtual_</classname></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function declaring the contract. </para>
2554 </listitem>
2555 <listitem><para><computeroutput><emphasis role="bold">r</emphasis></computeroutput> 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 <computeroutput>return</computeroutput> statement. </para>
2556 </listitem>
2557 <listitem><para><computeroutput><emphasis role="bold">f</emphasis></computeroutput> is a pointer to the enclosing public function override declaring the contract. </para>
2558 </listitem>
2559 <listitem><para><computeroutput><emphasis role="bold">obj</emphasis></computeroutput> is the object <computeroutput>this</computeroutput> from the scope of the enclosing public function declaring the contract. This object might be mutable, <computeroutput>const</computeroutput>, <computeroutput>volatile</computeroutput>, or <computeroutput>const volatile</computeroutput> depending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see <link linkend="boost_contract.extras.volatile_public_functions">
2560         Volatile Public Functions</link>). </para>
2561 </listitem>
2562 <listitem><para><computeroutput><emphasis role="bold">...</emphasis></computeroutput> is a variadic macro parameter listing all the 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 <computeroutput>v</computeroutput>. </para>
2563 </listitem>
2564 <listitem><para><computeroutput><emphasis role="bold">internal_var</emphasis></computeroutput> 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).</para>
2565 </listitem>
2566 </itemizedlist>
2567 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
2568         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
2569         Public Function Overrides</link> </para>
2570 </para>
2571 </para></description></macro>
2572 </header>
2573 </library-reference>