Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / contract / doc / html / contract.docbook
1 <?xml version="1.0"?>
2 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
3 <chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="boost_contract" rev:last-revision="$Date: 2019/12/10 00:23:48 $">
4   <chapterinfo><author>
5       <firstname>Lorenzo</firstname> <surname>Caminiti <email>lorcaminiti@gmail.com</email></surname>
6     </author><copyright>
7       <year>2008</year> <year>2009</year> <year>2010</year> <year>2011</year> <year>2012</year>
8       <year>2013</year> <year>2014</year> <year>2015</year> <year>2016</year> <year>2017</year>
9       <year>2018</year> <year>2019</year> <holder>Lorenzo Caminiti</holder>
10     </copyright><legalnotice id="boost_contract.legal">
11       <para>
12         Distributed under the Boost Software License, Version 1.0 (see accompanying
13         file LICENSE_1_0.txt or a copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>)
14       </para>
15     </legalnotice></chapterinfo>
16   <title>Boost.Contract 1.0.0</title>
17   <blockquote>
18     <para>
19       <emphasis><quote>Our field needs more formality, but the profession has not
20       realized it yet.</quote></emphasis>
21     </para>
22   </blockquote>
23   <blockquote>
24     <para>
25       <emphasis>-- Bertrand Meyer (see <link linkend="Meyer97_anchor">[Meyer97]</link>
26       page 400)</emphasis>
27     </para>
28   </blockquote>
29   <para>
30     This library implements <ulink url="http://en.wikipedia.org/wiki/Design_by_contract">contract
31     programming</ulink> (a.k.a., Design by Contract or DbC) <footnote id="boost_contract.f0">
32     <para>
33       Design by Contract (DbC) is a registered trademark of the Eiffel Software company
34       and it was first introduced by the Eiffel programming language (see <link linkend="Meyer97_anchor">[Meyer97]</link>).
35     </para>
36     </footnote> for the C++ programming language. All contract programming features
37     are supported by this library: Subcontracting, class invariants (also for static
38     and volatile member functions), postconditions (with old and return values),
39     preconditions, customizable actions on assertion failure (e.g., terminate the
40     program or throw exceptions), optional compilation of assertions, disable assertions
41     while already checking other assertions (to avoid infinite recursion), and more
42     (see <link linkend="boost_contract.contract_programming_overview.feature_summary">Feature
43     Summary</link>).
44   </para>
45   <section id="boost_contract.introduction">
46     <title><link linkend="boost_contract.introduction">Introduction</link></title>
47     <para>
48       Contract programming allows to specify preconditions, postconditions, and class
49       invariants that are automatically checked when functions are executed at run-time.
50       These conditions assert program specifications within the source code itself
51       allowing to find bugs more quickly during testing, making the code self-documenting,
52       and increasing overall software quality (see <link linkend="boost_contract.contract_programming_overview">Contract
53       Programming Overview</link>).
54     </para>
55     <para>
56       For example, consider the following function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput>
57       that increments its argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput>
58       by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase></computeroutput> and let's write its contract
59       using code comments (see <ulink url="../../example/features/introduction_comments.cpp"><literal moreinfo="none">introduction_comments.cpp</literal></ulink>):
60     </para>
61     <para>
62 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">inc</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase>
63     <phrase role="comment">// Precondition:    x &lt; std::numeric_limit&lt;int&gt;::max()</phrase>
64     <phrase role="comment">// Postcondition:   x == oldof(x) + 1</phrase>
65 <phrase role="special">{</phrase>
66     <phrase role="special">++</phrase><phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="comment">// Function body.</phrase>
67 <phrase role="special">}</phrase>
68 </programlisting>
69     </para>
70     <para>
71       The precondition states that at function entry the argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput>
72       must be strictly smaller than the maximum allowable value of its type (so it
73       can be incremented by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase></computeroutput> without
74       overflowing). The postcondition states that at function exit the argument
75       <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput> must be incremented by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase></computeroutput> with respect to the <emphasis>old value</emphasis>
76       that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput> had before executing
77       the function (indicated here by <literal moreinfo="none"><emphasis>oldof</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">)</phrase></computeroutput>).
78       Note that postconditions shall be checked only when the execution of the function
79       body does not throw an exception.
80     </para>
81     <para>
82       Now let's program this function and its contract using this library (see <ulink url="../../example/features/introduction.cpp"><literal moreinfo="none">introduction.cpp</literal></ulink>
83       and <link linkend="boost_contract.tutorial.non_member_functions">Non-Member
84       Functions</link>):
85     </para>
86     <para>
87 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
88
89 <phrase role="keyword">void</phrase> <phrase role="identifier">inc</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
90     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase> <phrase role="comment">// Old value.</phrase>
91     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
92         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
93             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">());</phrase> <phrase role="comment">// Line 17.</phrase>
94         <phrase role="special">})</phrase>
95         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
96             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Line 20.</phrase>
97         <phrase role="special">})</phrase>
98     <phrase role="special">;</phrase>
99
100     <phrase role="special">++</phrase><phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="comment">// Function body.</phrase>
101 <phrase role="special">}</phrase>
102 </programlisting>
103     </para>
104     <para>
105       When the above function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput>
106       is called, this library will:
107     </para>
108     <itemizedlist>
109       <listitem>
110         <simpara>
111           First, execute the functor passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>
112           that asserts <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput> precondition.
113         </simpara>
114       </listitem>
115       <listitem>
116         <simpara>
117           Then, execute <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput> body
118           (i.e., all the code that follows the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="special">...</phrase></computeroutput> declaration).
119         </simpara>
120       </listitem>
121       <listitem>
122         <simpara>
123           Last, execute the functor passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase></computeroutput>
124           that asserts <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput> postcondition
125           (unless <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput> body threw
126           an exception).
127         </simpara>
128       </listitem>
129     </itemizedlist>
130     <para>
131       For example, if there is a bug in the code calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput>
132       so that the function is called with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput>
133       equal to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">()</phrase></computeroutput> then the program will terminate with an error
134       message similar to the following (and it will be evident that the bug is in
135       the calling code):
136     </para>
137 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">precondition assertion "x &lt; std::numeric_limits&lt;int&gt;::max()" failed: file "introduction.cpp", line 17
138 </programlisting>
139     <para>
140       Instead, if there is a bug in the implementation of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput>
141       so that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput> is not incremented
142       by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase></computeroutput> after the execution of the
143       function body then the program will terminate with an error message similar
144       to the following (and it will be evident that the bug is in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">inc</phrase></computeroutput>
145       body): <footnote id="boost_contract.introduction.f0">
146       <para>
147         In this example the function body is composed of a single trivial instruction
148         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">++</phrase><phrase role="identifier">x</phrase></computeroutput>
149         so it easy to check by visual inspection that it does not contain any bug
150         and it will always increment <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput>
151         by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase></computeroutput> thus the function postcondition
152         will never fail. In real production code, function bodies are rarely this
153         simple and can hide bugs which make checking postconditions useful.
154       </para>
155       </footnote>
156     </para>
157 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">postcondition assertion "x == *old_x + 1" failed: file "introduction.cpp", line 20
158 </programlisting>
159     <para>
160       By default, when an assertion fails this library prints an error message such
161       the ones above to the standard error <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput> and
162       terminates the program calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>
163       (this behaviour can be customized to take any user-specified action including
164       throwing exceptions, see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
165       on Failures</link>). Note that the error messages printed by this library contain
166       all the information necessary to easily and uniquely identify the point in
167       the code at which contract assertions fail. <footnote id="boost_contract.introduction.f1">
168       <para>
169         <emphasis role="bold">Rationale:</emphasis> The assertion failure message
170         printed by this library follows a format similar to the message printed by
171         Clang when the C-style <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput>
172         macro fails.
173       </para>
174       </footnote>
175     </para>
176     <note>
177       <para>
178         C++11 lambda functions are necessary to use this library without manually
179         writing a significant amount of boiler-plate code to program functors that
180         assert the contracts (see <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
181         Lambda Functions</link>). That said, this library implementation does not
182         use C++11 features and should work on most modern C++ compilers (see <link linkend="boost_contract.getting_started">Getting Started</link>).
183       </para>
184     </note>
185     <para>
186       In addition to contracts for non-member functions as shown the in the example
187       above, this library allows to program contracts for constructors, destructors,
188       and member functions. These can check class invariants and can also <emphasis>subcontract</emphasis>
189       inheriting and extending contracts from base classes (see <ulink url="../../example/features/introduction_public.cpp"><literal moreinfo="none">introduction_public.cpp</literal></ulink>
190       and <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
191       Function Overrides</link>): <footnote id="boost_contract.introduction.f2">
192       <para>
193         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pushable</phrase></computeroutput> base class is
194         used in this example just to show subcontracting, it is somewhat arbitrary
195         and it will likely not appear in real production code.
196       </para>
197       </footnote>
198     </para>
199     <para>
200 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
201 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase>
202     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">pushable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
203     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
204 <phrase role="special">{</phrase>
205 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
206     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// For subcontracting.</phrase>
207     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
208
209     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Checked in AND with base class invariants.</phrase>
210         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
211     <phrase role="special">}</phrase>
212
213     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase>
214             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase> <phrase role="comment">// For virtuals.</phrase>
215         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
216                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase> <phrase role="comment">// Old values for virtuals.</phrase>
217         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase> <phrase role="comment">// For overrides.</phrase>
218                 <phrase role="identifier">override_push_back</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vector</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
219             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Checked in OR with base preconditions.</phrase>
220                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
221             <phrase role="special">})</phrase>
222             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Checked in AND with base postconditions.</phrase>
223                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
224             <phrase role="special">})</phrase>
225         <phrase role="special">;</phrase>
226
227         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
228     <phrase role="special">}</phrase>
229     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">push_back</phrase><phrase role="special">)</phrase> <phrase role="comment">// Define `override_push_back` above.</phrase>
230
231     <phrase role="comment">// Could program contracts for those as well.</phrase>
232     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase>
233     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">max_size</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase>
234     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase>
235
236 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
237     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
238 <phrase role="special">};</phrase>
239 </programlisting>
240     </para>
241     <bridgehead renderas="sect3" id="boost_contract.introduction.h0">
242       <phrase id="boost_contract.introduction.language_support"/><link linkend="boost_contract.introduction.language_support">Language
243       Support</link>
244     </bridgehead>
245     <para>
246       The authors of this library advocate for contracts to be added to the core
247       language. Adding contract programming to the C++ standard has a number of advantages
248       over any library implementation (shorter and more concise syntax to program
249       contracts, specify contracts in declarations instead of definitions, enforce
250       contract constant-correctness, expected faster compile- and run-time, vendors
251       could develop static analysis tools to recognize and check contracts statically
252       when possible, compiler optimizations could be improved based on contract conditions,
253       etc.).
254     </para>
255     <para>
256       The <link linkend="P0380_anchor">[P0380]</link> proposal supports basic contract
257       programming, it was accepted and it will be included in C++20. This is undoubtedly
258       a step in the right direction, but unfortunately <link linkend="P0380_anchor">[P0380]</link>
259       only supports pre- and postconditions while missing important features such
260       as class invariants and old values in postconditions, not to mention the lack
261       of more advanced features like subcontracting (more complete proposals like
262       <link linkend="N1962_anchor">[N1962]</link> were rejected by the C++ standard
263       committee). All contracting programming features are instead supported by this
264       library (see <link linkend="boost_contract.contract_programming_overview.feature_summary">Feature
265       Summary</link> for a detailed comparison between the features supported by
266       this library and the ones listed in different contract programming proposals,
267       see <link linkend="boost_contract.bibliography">Bibliography</link> for a list
268       of references considered during the design and implementation of this library,
269       including the vast majority of contract programming proposals submitted to
270       the C++ standard committee).
271     </para>
272   </section>
273   <section id="boost_contract.full_table_of_contents">
274     <title><link linkend="boost_contract.full_table_of_contents">Full Table of Contents</link></title>
275 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_contract.introduction">Introduction</link>
276 <link linkend="boost_contract.full_table_of_contents">Full Table of Contents</link>
277 <link linkend="boost_contract.getting_started">Getting Started</link>
278     <link linkend="boost_contract.getting_started.this_documentation">This Documentation</link>
279     <link linkend="boost_contract.getting_started.compilers_and_platforms">Compilers and Platforms</link>
280     <link linkend="boost_contract.getting_started.code_organization">Code Organization</link>
281     <link linkend="boost_contract.getting_started.build">Build</link>
282 <link linkend="boost_contract.contract_programming_overview">Contract Programming Overview</link>
283     <link linkend="boost_contract.contract_programming_overview.assertions">Assertions</link>
284     <link linkend="boost_contract.contract_programming_overview.benefits_and_costs">Benefits and Costs</link>
285     <link linkend="boost_contract.contract_programming_overview.function_calls">Function Calls</link>
286     <link linkend="boost_contract.contract_programming_overview.public_function_calls">Public Function Calls</link>
287     <link linkend="boost_contract.contract_programming_overview.constructor_calls">Constructor Calls</link>
288     <link linkend="boost_contract.contract_programming_overview.destructor_calls">Destructor Calls</link>
289     <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>
290     <link linkend="boost_contract.contract_programming_overview.specifications_vs__implementation">Specifications vs. Implementation</link>
291     <link linkend="boost_contract.contract_programming_overview.on_contract_failures">On Contract Failures</link>
292     <link linkend="boost_contract.contract_programming_overview.feature_summary">Feature Summary</link>
293 <link linkend="boost_contract.tutorial">Tutorial</link>
294     <link linkend="boost_contract.tutorial.non_member_functions">Non-Member Functions</link>
295     <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>
296     <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>
297     <link linkend="boost_contract.tutorial.return_values">Return Values</link>
298     <link linkend="boost_contract.tutorial.old_values">Old Values</link>
299     <link linkend="boost_contract.tutorial.exception_guarantees">Exception Guarantees</link>
300     <link linkend="boost_contract.tutorial.class_invariants">Class Invariants</link>
301     <link linkend="boost_contract.tutorial.constructors">Constructors</link>
302     <link linkend="boost_contract.tutorial.destructors">Destructors</link>
303     <link linkend="boost_contract.tutorial.public_functions">Public Functions</link>
304     <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual Public Functions</link>
305     <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public Function Overrides (Subcontracting)</link>
306     <link linkend="boost_contract.tutorial.base_classes__subcontracting_">Base Classes (Subcontracting)</link>
307     <link linkend="boost_contract.tutorial.static_public_functions">Static Public Functions</link>
308 <link linkend="boost_contract.advanced">Advanced</link>
309     <link linkend="boost_contract.advanced.pure_virtual_public_functions">Pure Virtual Public Functions</link>
310     <link linkend="boost_contract.advanced.optional_return_values">Optional Return Values</link>
311     <link linkend="boost_contract.advanced.private_and_protected_functions">Private and Protected Functions</link>
312     <link linkend="boost_contract.advanced.friend_functions">Friend Functions</link>
313     <link linkend="boost_contract.advanced.function_overloads">Function Overloads</link>
314     <link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">Lambdas, Loops, Code Blocks (and <computeroutput><phrase role="keyword">constexpr</phrase></computeroutput>)</link>
315     <link linkend="boost_contract.advanced.implementation_checks">Implementation Checks</link>
316     <link linkend="boost_contract.advanced.old_values_copied_at_body">Old Values Copied at Body</link>
317     <link linkend="boost_contract.advanced.named_overrides">Named Overrides</link>
318     <link linkend="boost_contract.advanced.access_specifiers">Access Specifiers</link>
319     <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw on Failures (and <computeroutput><phrase role="keyword">noexcept</phrase></computeroutput>)</link>
320 <link linkend="boost_contract.extras">Extras</link>
321     <link linkend="boost_contract.extras.old_value_requirements__templates_">Old Value Requirements (Templates)</link>
322     <link linkend="boost_contract.extras.assertion_requirements__templates_">Assertion Requirements (Templates)</link>
323     <link linkend="boost_contract.extras.volatile_public_functions">Volatile Public Functions</link>
324     <link linkend="boost_contract.extras.move_operations">Move Operations</link>
325     <link linkend="boost_contract.extras.unions">Unions</link>
326     <link linkend="boost_contract.extras.assertion_levels">Assertion Levels</link>
327     <link linkend="boost_contract.extras.disable_contract_checking">Disable Contract Checking</link>
328     <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">Disable Contract Compilation (Macro Interface)</link>
329     <link linkend="boost_contract.extras.separate_body_implementation">Separate Body Implementation</link>
330     <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No Lambda Functions (No C++11)</link>
331     <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No Macros (and No Variadic Macros)</link>
332 <link linkend="boost_contract.examples">Examples</link>
333 <ulink url="reference.html">Reference</ulink>
334 <link linkend="boost_contract.release_notes">Release Notes</link>
335 <link linkend="boost_contract.bibliography">Bibliography</link>
336 <link linkend="boost_contract.acknowledgments">Acknowledgments</link>
337 </programlisting>
338   </section>
339   <section id="boost_contract.getting_started">
340     <title><link linkend="boost_contract.getting_started">Getting Started</link></title>
341     <para>
342       This section shows how to setup and start using this library.
343     </para>
344     <section id="boost_contract.getting_started.this_documentation">
345       <title><link linkend="boost_contract.getting_started.this_documentation">This
346       Documentation</link></title>
347       <para>
348         Programmers should be able to start using this library after reading the
349         <link linkend="boost_contract.introduction">Introduction</link>, <link linkend="boost_contract.getting_started">Getting
350         Started</link>, and <link linkend="boost_contract.tutorial">Tutorial</link>.
351         Other sections of this documentation (e.g., <link linkend="boost_contract.advanced">Advanced</link>
352         and <link linkend="boost_contract.extras">Extras</link>) can be consulted
353         at a later point to gain a more in-depth knowledge of the library. <link linkend="boost_contract.contract_programming_overview">Contract Programming
354         Overview</link> can be skipped by programmers that are already familiar with
355         the contract programming methodology.
356       </para>
357       <para>
358         Some of the source code listed in this documentation contains special code
359         comments of the form <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">//[...</phrase></computeroutput>
360         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">//]</phrase></computeroutput>. These mark sections
361         of the code that are automatically extracted from the source code and presented
362         as part of this documentation. <footnote id="boost_contract.getting_started.this_documentation.f0">
363         <para>
364           <emphasis role="bold">Rationale:</emphasis> This allows to make sure that
365           most of the example code presented in this documentation is always up-to-date,
366           builds and runs with the latest implementation of the library.
367         </para>
368         </footnote> It should be noted that the purpose of all examples of this documentation
369         is to illustrate how to use this library and not to show real production
370         code.
371       </para>
372       <para>
373         Some footnotes are marked by the word "<emphasis role="bold">Rationale</emphasis>".
374         These explain some of the decisions made during the design and implementation
375         of this library.
376       </para>
377     </section>
378     <section id="boost_contract.getting_started.compilers_and_platforms">
379       <title><link linkend="boost_contract.getting_started.compilers_and_platforms">Compilers
380       and Platforms</link></title>
381       <para>
382         In general, this library requires C++ compilers with a sound implementation
383         of SFINAE and other template meta-programming techniques supported by the
384         C++03 standard. It is possible to use this library without C++11 lambda functions
385         but a large amount of boiler-plate code is required to manually program separate
386         functors to specify preconditions, postconditions, etc. (so using this library
387         without C++11 lambda functions is possible but not recommended, see <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No Lambda
388         Functions</link>). It is also possible to use this library without variadic
389         macros by manually programming a small amount of boiler-plate code (but most
390         if not all modern C++ compilers support variadic macros even before C++99
391         and C++11 so this should never be needed in practice, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
392         Macros</link>).
393       </para>
394       <para>
395         Some parts of this documentation use the syntax <literal moreinfo="none"><emphasis>type-of</emphasis>(...)</literal>
396         to indicate an operator logically equivalent to C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">decltype</phrase><phrase role="special">(...)</phrase></computeroutput>. However, this library implementation
397         does not actually use type deduction in these cases (because the library
398         internally already knows the types in question) so support for C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">decltype</phrase></computeroutput> and other type-of implementations
399         are not actually required (that is why <literal moreinfo="none"><emphasis>type-of</emphasis></literal>
400         and not the real <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">decltype</phrase></computeroutput> operator
401         is used in this documentation).
402       </para>
403       <para>
404         This library has been developed and tested using:
405       </para>
406       <itemizedlist>
407         <listitem>
408           <simpara>
409             Visual Studio 2015 on Windows (MSVC <literal moreinfo="none">cl</literal> version 19.00.24215.1).
410           </simpara>
411         </listitem>
412         <listitem>
413           <simpara>
414             GCC version 5.4.0 on Cygwin (with C++11 features enabled <literal moreinfo="none">-std=c++11</literal>).
415           </simpara>
416         </listitem>
417         <listitem>
418           <simpara>
419             Clang version 3.8.1 on Cygwin (with C++11 features enabled <literal moreinfo="none">-std=c++11</literal>).
420           </simpara>
421         </listitem>
422       </itemizedlist>
423       <para>
424         For information on other compilers and platforms see the library <ulink url="http://www.boost.org/development/tests/master/developer/contract.html">regression
425         tests</ulink>. The development and maintenance of this library is hosted
426         on <ulink url="https://github.com/boostorg/contract">GitHub</ulink>.
427       </para>
428     </section>
429     <section id="boost_contract.getting_started.code_organization">
430       <title><link linkend="boost_contract.getting_started.code_organization">Code
431       Organization</link></title>
432       <para>
433         Let <literal moreinfo="none"><emphasis>boost-root</emphasis></literal> be the directory where
434         Boost source files were installed. This library flies are organized as follows:
435       </para>
436 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><emphasis>boost-root</emphasis>/libs/contract        # Directory where this library files are.
437     build/                      # Build files (using BJam).
438     doc/                        # Documentation (using Boost.QuickBook).
439     example/                    # Examples (also those listed in this documentation).
440     include/                    # DO NOT USE: Use copies of these files from
441         boost/                  # <emphasis>boost-root</emphasis>/boost/ instead:
442             contract.hpp        #   - Include all headers at once.
443             contract_macro.hpp  #   - Include library macro interface.
444             contract/           #   - Header files that can be included one-by-one.
445                 core/           #   - Fundamental headers (usually indirectly included by other headers).
446                 detail/         #   - Implementation code (should never be included or used directly).
447     src/                        # Library source code to be compiled.
448     test/                       # Tests.
449 </programlisting>
450       <para>
451         All headers required by this library can be included at once by:
452       </para>
453 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
454 </programlisting>
455       <para>
456         Or, by the following when using the library macro interface (see <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">Disable
457         Contract Compilation</link>):
458       </para>
459 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract_macro</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
460 </programlisting>
461       <para>
462         Alternatively, all <literal moreinfo="none">boost/contract/*.hpp</literal> headers are independent
463         from one another and they can be selectively included one-by-one based on
464         the specific functionality of this library being used (but this was measured
465         to not make an appreciable difference in compile-time so <literal moreinfo="none">boost/contract.hpp</literal>
466         can be included directly in most cases). The <literal moreinfo="none">boost/contract/core/*.hpp</literal>
467         headers are not independent from other headers and they do not need to be
468         directly included in user code when <literal moreinfo="none">boost/contract.hpp</literal>
469         or <literal moreinfo="none">boost/contract/*.hpp</literal> headers are included already.
470       </para>
471       <para>
472         All files under <literal moreinfo="none">boost/contract/detail/</literal>, names in the
473         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase></computeroutput> namespace, macros starting with
474         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_DETAIL</phrase><phrase role="special">...</phrase></computeroutput>,
475         and all names starting with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost_contract_detail</phrase><phrase role="special">...</phrase></computeroutput> (in any namespace, including user-defined
476         namespaces) are part of this library implementation and should never be used
477         directly in user code. Names starting with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ERROR</phrase><phrase role="special">...</phrase></computeroutput> are used by this library to report some
478         compile-time errors (so spotting these names in compiler error messages might
479         help troubleshooting).
480       </para>
481     </section>
482     <section id="boost_contract.getting_started.build">
483       <title><link linkend="boost_contract.getting_started.build">Build</link></title>
484       <para>
485         Let <literal moreinfo="none"><emphasis>boost-root</emphasis></literal> be the directory where
486         Boost source files were installed. This library is installed and compiled
487         as part of Boost using BJam.
488       </para>
489       <warning>
490         <para>
491           It is strongly recommended to compile and use this library as a shared
492           library (a.k.a., Dynamically Linked Library or DLL) by defining the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_ALL_DYN_LINK</phrase></computeroutput> macro (or at least
493           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</link></computeroutput>)
494           when building Boost. When using BJam to build Boost, this can be achieved
495           by the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">link</phrase><phrase role="special">=</phrase><phrase role="identifier">shared</phrase></computeroutput> parameter (which is already the
496           default so no extra parameter is actually needed for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">bjam</phrase></computeroutput>).
497         </para>
498         <para>
499           It is also possible to compile and use this library as a static library
500           (by defining the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_STATIC_LINK">BOOST_CONTRACT_STATIC_LINK</link></computeroutput>
501           macro) or as a header-only library (by leaving both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</link></computeroutput>
502           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_STATIC_LINK">BOOST_CONTRACT_STATIC_LINK</link></computeroutput>
503           undefined). However, this library is not guaranteed to always work correctly
504           in these cases. Specifically, this library might not correctly disable
505           contracts while checking other contracts and call the correct user-defined
506           contract failure handlers unless it is compiled as a shared library when
507           it is used across different program units (different programs, different
508           shared libraries in the same program, etc.).
509         </para>
510       </warning>
511       <bridgehead renderas="sect4" id="boost_contract.getting_started.build.h0">
512         <phrase id="boost_contract.getting_started.build.linux_based_systems"/><link linkend="boost_contract.getting_started.build.linux_based_systems">Linux-Based
513         Systems</link>
514       </bridgehead>
515       <para>
516         For example, to build all Boost libraries including this one (as shared libraries,
517         see also <ulink url="https://www.boost.org/doc/libs/1_70_0/more/getting_started">Boost
518         documentation</ulink>):
519       </para>
520 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">$ cd <emphasis>boost-root</emphasis>
521 $ ./bootstrap.sh
522 $ ./bjam
523 </programlisting>
524       <para>
525         To compile and run the <ulink url="../../example/features/introduction.cpp"><literal moreinfo="none"><emphasis>boost-root</emphasis>/libs/contract/example/features/introduction.cpp</literal></ulink>
526         example:
527       </para>
528 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">$ cd <emphasis>boost-root</emphasis>/libs/contract/example
529 $ ../../../bjam features-introduction
530 </programlisting>
531       <para>
532         To compile and run all this library's tests (this might take while):
533       </para>
534 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">$ cd <emphasis>boost-root</emphasis>/libs/contract/test
535 $ ../../../bjam
536 </programlisting>
537       <para>
538         To compile and run code that uses this library but without BJam (similarly
539         for Clang):
540       </para>
541 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">$ cd /tmp
542 $ g++ -std=c++11 -D BOOST_CONTRACT_DYN_LINK -I <emphasis>boost-root</emphasis> <emphasis>boost-root</emphasis>/stage/lib/<emphasis>system-prefix</emphasis>boost_contract.dll <emphasis>boost-root</emphasis>/libs/contract/example/features/introduction.cpp -o introduction
543 $ export PATH=$PATH:<emphasis>boost-root</emphasis>/stage/lib
544 $ ./introduction
545 </programlisting>
546       <bridgehead renderas="sect4" id="boost_contract.getting_started.build.h1">
547         <phrase id="boost_contract.getting_started.build.windows_based_systems"/><link linkend="boost_contract.getting_started.build.windows_based_systems">Windows-Based
548         Systems</link>
549       </bridgehead>
550       <para>
551         For example, to build all Boost libraries including this one (as DLLs, see
552         also <ulink url="https://www.boost.org/doc/libs/1_70_0/more/getting_started">Boost
553         documentation</ulink>):
554       </para>
555 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">&gt;cd <emphasis>boost-root</emphasis>
556 &gt;bootstrap.bat
557 &gt;bjam
558 </programlisting>
559       <para>
560         To compile and run the <ulink url="../../example/features/introduction.cpp"><literal moreinfo="none"><emphasis>boost-root</emphasis>/libs/contract/example/features/introduction.cpp</literal></ulink>
561         example:
562       </para>
563 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">&gt;cd <emphasis>boost-root</emphasis>\libs\contract\example
564 &gt;..\..\..\bjam features-introduction
565 </programlisting>
566       <para>
567         To compile and run all this library's tests (this might take while):
568       </para>
569 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">&gt;cd <emphasis>boost-root</emphasis>\libs\contract\test
570 &gt;..\..\..\bjam
571 </programlisting>
572       <para>
573         To compile and run code that uses this library but without BJam:
574       </para>
575 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">&gt;cd C:\Temp
576 &gt;cl /MDd /EHs /std:c++11 /D BOOST_CONTRACT_DYN_LINK /I <emphasis>boost-root</emphasis> /link /DLL /LIBPATH:<emphasis>boost-root</emphasis>\stage\lib <emphasis>boost-root</emphasis>\libs\contract\example\features\introduction.cpp /out:introduction
577 &gt;set PATH=%PATH%;<emphasis>boost-root</emphasis>/stage/lib
578 &gt;introduction
579 </programlisting>
580     </section>
581   </section>
582   <section id="boost_contract.contract_programming_overview">
583     <title><link linkend="boost_contract.contract_programming_overview">Contract
584     Programming Overview</link></title>
585     <blockquote>
586       <para>
587         <emphasis><quote>It is absurd to make elaborate security checks on debugging
588         runs, when no trust is put in the results, and then remove them in production
589         runs, when an erroneous result could be expensive or disastrous. What would
590         we think of a sailing enthusiast who wears his life-jacket when training
591         on dry land but takes it off as soon as he goes to sea?</quote></emphasis>
592       </para>
593     </blockquote>
594     <blockquote>
595       <para>
596         <emphasis>-- Charles Antony Richard Hoare (see <link linkend="Hoare73_anchor">[Hoare73]</link>)</emphasis>
597       </para>
598     </blockquote>
599     <para>
600       This section gives an overview of contract programming (see <link linkend="Meyer97_anchor">[Meyer97]</link>,
601       <link linkend="Mitchell02_anchor">[Mitchell02]</link>, and <link linkend="N1613_anchor">[N1613]</link>
602       for more extensive introductions to contract programming). Readers that already
603       have a basic understanding of contract programming can skip this section and
604       maybe come back to it after reading the <link linkend="boost_contract.tutorial">Tutorial</link>.
605     </para>
606     <note>
607       <para>
608         The objective of this library is not to convince programmers to use contract
609         programming. It is assumed that programmes understand the benefits and trade-offs
610         associated with contract programming and they have already decided to use
611         this methodology in their code. Then, this library aims to be the best and
612         more complete contract programming library for C++ (without using programs
613         and tools external to the C++ language and its preprocessor).
614       </para>
615     </note>
616     <section id="boost_contract.contract_programming_overview.assertions">
617       <title><link linkend="boost_contract.contract_programming_overview.assertions">Assertions</link></title>
618       <para>
619         Contract programming is characterized by the following assertion mechanisms:
620       </para>
621       <itemizedlist>
622         <listitem>
623           <simpara>
624             <emphasis>Preconditions</emphasis>: These are logical conditions that
625             programmers expect to be true when a function is called (e.g., to check
626             constraints on function arguments). Operations that logically have no
627             preconditions (i.e., that are always well-defined for the entire domain
628             of their inputs) are also referred to as having a <emphasis>wide contract</emphasis>.
629             This is in contrast to operations that have preconditions which are also
630             referred to as having a <emphasis>narrow contract</emphasis> (note that
631             operations with truly narrow contracts are also expected to never throw
632             exceptions because the implementation body of these operations is always
633             expected to succeed after its preconditions are checked to be true).
634             <footnote id="boost_contract.contract_programming_overview.assertions.f0">
635             <para>
636               The nomenclature of wide and narrow contracts has gained some popularity
637               in recent years in the C++ community (appearing in a number of more
638               recent proposals to add contract programming to the C++ standard, see
639               <link linkend="boost_contract.bibliography">Bibliography</link>). This
640               nomenclature is perfectly reasonable but it is not often used in this
641               document just because the authors usually prefer to explicitly say
642               "this operation has no preconditions..." or "this operation
643               has preconditions..." (this is just a matter of taste).
644             </para>
645             </footnote>
646           </simpara>
647         </listitem>
648         <listitem>
649           <simpara>
650             <emphasis>Postconditions</emphasis>: These are logical conditions that
651             programmers expect to be true when a function exits without throwing
652             an exception (e.g., to check the result and any side effect that a function
653             might have). Postconditions can access the function return value (for
654             non-void functions) and also <emphasis>old values</emphasis> (which are
655             the values that expressions had before the function implementation was
656             executed).
657           </simpara>
658         </listitem>
659         <listitem>
660           <simpara>
661             <emphasis>Exception guarantees</emphasis>: These are logical conditions
662             that programmers except to be true when a function exits throwing an
663             exception. Exception guarantees can access old values (but not the function
664             return value). <footnote id="boost_contract.contract_programming_overview.assertions.f1">
665             <para>
666               <emphasis role="bold">Rationale:</emphasis> Contract assertions for
667               exception guarantees were first introduced by this library, they are
668               not part of <link linkend="N1962_anchor">[N1962]</link> or other references
669               listed in the <link linkend="boost_contract.bibliography">Bibliography</link>
670               (even if exception safety guarantees have long been part of C++ STL
671               documentation).
672             </para>
673             </footnote>
674           </simpara>
675         </listitem>
676         <listitem>
677           <simpara>
678             <emphasis>Class invariants</emphasis>: These are logical conditions that
679             programmers expect to be true after a constructor exits without throwing
680             an exception, before and after the execution of every non-static public
681             function (even if they throw exceptions), before the destructor is executed
682             (and also after the destructor is executed but only when the destructor
683             throws an exception). Class invariants define valid states for all objects
684             of a given class. It is possible to specify a different set of class
685             invariants for volatile public functions, namely <emphasis>volatile class
686             invariants</emphasis>. It is also possible to specify <emphasis>static
687             class invariants</emphasis> which are excepted to be true before and
688             after the execution of any constructor, destructor (even if it does not
689             throw an exception), and public function (even if static). <footnote id="boost_contract.contract_programming_overview.assertions.f2">
690             <para>
691               <emphasis role="bold">Rationale:</emphasis> Static and volatile class
692               invariants were first introduced by this library (simply to reflect
693               the fact that C++ supports also static and volatile public functions),
694               they are not part of <link linkend="N1962_anchor">[N1962]</link> or
695               other references listed in the <link linkend="boost_contract.bibliography">Bibliography</link>.
696             </para>
697             </footnote>
698           </simpara>
699         </listitem>
700         <listitem>
701           <simpara>
702             <emphasis>Subcontracting</emphasis>: This indicates that preconditions
703             cannot be strengthen, while postconditions and class invariants cannot
704             be weaken when a public function in a derived class overrides public
705             functions in one or more of its base classes (this is formally defined
706             according to the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
707             principle</ulink>).
708           </simpara>
709         </listitem>
710       </itemizedlist>
711       <para>
712         The actual function implementation code, that remains outside of these contract
713         assertions, is often referred to as the <emphasis>function body</emphasis>
714         in contract programming.
715       </para>
716       <para>
717         Class invariants can also be used to specify <emphasis>basic</emphasis> exception
718         safety guarantees for an object (because they are checked at exit of public
719         functions even when those throw exceptions). Contract assertions for exception
720         guarantees can be used to specify <emphasis>strong</emphasis> exception safety
721         guarantees for a given operation on the same object.
722       </para>
723       <para>
724         It is also a common requirement for contract programming to automatically
725         disable contract checking while already checking assertions from another
726         contract (in order to avoid infinite recursion while checking contract assertions).
727       </para>
728       <note>
729         <para>
730           This library implements this requirement but in order to globally disable
731           assertions while checking another assertion some kind of global arbitrating
732           variable needs to be used by this library implementation. This library
733           will automatically protect such a global variable from race conditions
734           in multi-threated programs, but this will effectively introduce a global
735           lock in the program (the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999743888">BOOST_CONTRACT_DISABLE_THREADS</link></computeroutput>
736           macro can be defined to disable this global lock but at the risk of incurring
737           in race conditions). <footnote id="boost_contract.contract_programming_overview.assertions.f3">
738           <para>
739             <emphasis role="bold">Rationale:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999743888">BOOST_CONTRACT_DISABLE_THREADS</link></computeroutput>
740             is named after <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_DISABLE_THREADS</phrase></computeroutput>.
741           </para>
742           </footnote>
743         </para>
744       </note>
745       <para>
746         In general, it is recommended to specify different contract conditions using
747         separate assertion statements and not to group them together into a single
748         condition using logical operators (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&amp;&amp;</phrase></computeroutput>,
749         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">||</phrase></computeroutput>, etc.). This is because when
750         contract conditions are programmed together in a single assertion using logical
751         operators, it might not be clear which condition actually failed in case
752         the entire assertion fails at run-time.
753       </para>
754       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.assertions.h0">
755         <phrase id="boost_contract.contract_programming_overview.assertions.c_style_assertions"/><link linkend="boost_contract.contract_programming_overview.assertions.c_style_assertions">C-Style
756         Assertions</link>
757       </bridgehead>
758       <para>
759         A limited form of contract programming (typically some form of precondition
760         and basic postcondition checking) can be achieved using the C-style <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> macro. Using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput>
761         is common practice for many programmers but it suffers of the following limitations:
762       </para>
763       <itemizedlist>
764         <listitem>
765           <simpara>
766             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> does not distinguish
767             between preconditions and postconditions. In well-tested production code,
768             postconditions can usually be disabled trusting the correctness of the
769             implementation while preconditions might still need to remain enabled
770             because of possible changes in the calling code (e.g., postconditions
771             of a given library could be disabled after testing while keeping the
772             library preconditions enabled given that future changes in the user code
773             that calls the library cannot be anticipated). Using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput>
774             it is not possible to selectively disable only postconditions and all
775             assertions must be disabled at once.
776           </simpara>
777         </listitem>
778         <listitem>
779           <simpara>
780             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> requires to manually
781             program extra code to correctly check postconditions (specifically to
782             handle functions with multiple return statements, to not check postconditions
783             when functions throw exceptions, and to implement old values).
784           </simpara>
785         </listitem>
786         <listitem>
787           <simpara>
788             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> requires to manually
789             program extra code to check class invariants (extra member functions,
790             try blocks, etc.).
791           </simpara>
792         </listitem>
793         <listitem>
794           <simpara>
795             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> does not support
796             subcontracting.
797           </simpara>
798         </listitem>
799         <listitem>
800           <simpara>
801             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> calls are usually
802             scattered within function implementations thus the asserted conditions
803             are not immediately visible in their entirety by programmers (as they
804             are instead when the assertions appear in the function declaration or
805             at least at the very top of the function definition).
806           </simpara>
807         </listitem>
808       </itemizedlist>
809       <para>
810         Contract programming does not suffer of these limitations.
811       </para>
812     </section>
813     <section id="boost_contract.contract_programming_overview.benefits_and_costs">
814       <title><link linkend="boost_contract.contract_programming_overview.benefits_and_costs">Benefits
815       and Costs</link></title>
816       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.benefits_and_costs.h0">
817         <phrase id="boost_contract.contract_programming_overview.benefits_and_costs.benefits"/><link linkend="boost_contract.contract_programming_overview.benefits_and_costs.benefits">Benefits</link>
818       </bridgehead>
819       <para>
820         The main use of contract programming is to improve software quality. <link linkend="Meyer97_anchor">[Meyer97]</link> discusses how contract programming
821         can be used as the basic tool to write <quote>correct</quote> software.
822         <link linkend="Stroustrup94_anchor">[Stroustrup94]</link> discusses the key
823         importance of class invariants plus advantages and disadvantages of preconditions
824         and postconditions.
825       </para>
826       <para>
827         The following is a short summary of benefits associated with contract programming
828         inspired mainly by <link linkend="N1613_anchor">[N1613]</link>:
829       </para>
830       <itemizedlist>
831         <listitem>
832           <simpara>
833             Preconditions and postconditions: Using function preconditions and postconditions,
834             programmers can give a precise semantic description of what a function
835             requires at its entry and what it ensures at its exit (if it does not
836             throw an exception). In particular, using postcondition old values, contract
837             programming provides a mechanism that allows programmers to compare values
838             of an expression before and after the function body execution. This mechanism
839             is powerful enough to enable programmers to express many correctness
840             constraints within the code itself, constraints that would otherwise
841             have to be captured at best only informally by documentation.
842           </simpara>
843         </listitem>
844         <listitem>
845           <simpara>
846             Class invariants: Using class invariants, programmers can describe what
847             to expect from a class and the logic dependencies between the class members.
848             It is the job of the constructor to ensure that the class invariants
849             are satisfied when the object is first created. Then the implementation
850             of the member functions can be largely simplified as they can be written
851             knowing that the class invariants are satisfied because contract programming
852             checks them before and after the execution of every public function.
853             Finally, the destructor makes sure that the class invariants held for
854             the entire life of the object checking the class invariants one last
855             time before the object is destructed. Class invariants can also be used
856             as a criteria for good abstractions: If it is not possible to specify
857             an invariant, it might be an indication that the design abstraction maybe
858             be poor and it should not have been made into a class (maybe a namespace
859             would have sufficed instead).
860           </simpara>
861         </listitem>
862         <listitem>
863           <simpara>
864             Self-documenting code: Contracts are part of the source code, they are
865             checked at run-time so they are always up-to-date with the code itself.
866             Therefore program specifications, as documented by the contracts, can
867             be trusted to always be up-to-date with the implementation.
868           </simpara>
869         </listitem>
870         <listitem>
871           <simpara>
872             Easier debugging: Contract programming can provide a powerful debugging
873             facility because, if contracts are well-written, bugs will cause contract
874             assertions to fail exactly where the problem first occurs instead than
875             at some later stage of the program execution in an apparently unrelated
876             (and often hard to debug) manner. Note that a precondition failure points
877             to a bug in the function caller, a postcondition failure points instead
878             to a bug in the function implementation. <footnote id="boost_contract.contract_programming_overview.benefits_and_costs.f0">
879             <para>
880               Of course, if contracts are ill-written then contract programming is
881               of little use. However, it is less likely to have a bug in both the
882               function body and the contract than in the function body alone. For
883               example, consider the validation of a result in postconditions. Validating
884               the return value might seem redundant, but in this case we actually
885               want that redundancy. When programmers write a function, there is a
886               certain probability that they make a mistake in implementing the function
887               body. When programmers specify the result of the function in the postconditions,
888               there is also a certain probability that they make a mistake in writing
889               the contract. However, the probability that programmers make a mistake
890               twice (in both the body <emphasis>and</emphasis> the contract) is in
891               general lower than the probability that the mistake is made only once
892               (in either the body <emphasis>or</emphasis> the contract).
893             </para>
894             </footnote>
895           </simpara>
896         </listitem>
897         <listitem>
898           <simpara>
899             Easier testing: Contract programming facilitates testing because a contract
900             naturally specifies what a test should check. For example, preconditions
901             of a function state which inputs cause the function to fail and postconditions
902             state which outputs are produced by the function on successful exit (contract
903             programming should be seen as a tool to complement and guide, but obviously
904             not to replace, testing).
905           </simpara>
906         </listitem>
907         <listitem>
908           <simpara>
909             Formal design: Contract programming can serve to reduce the gap between
910             designers and programmers by providing a precise and unambiguous specification
911             language in terms of contract assertions. Moreover, contracts can make
912             code reviews easier by clarifying some of the semantics and usage of
913             the code.
914           </simpara>
915         </listitem>
916         <listitem>
917           <simpara>
918             Formalize inheritance: Contract programming formalizes the virtual function
919             overriding mechanism using subcontracting as justified by the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
920             principle</ulink>. This keeps the base class programmers in control as
921             overriding functions always have to fully satisfy the contracts of their
922             base classes.
923           </simpara>
924         </listitem>
925         <listitem>
926           <simpara>
927             Replace defensive programming: Contract programming assertions can replace
928             <ulink url="http://en.wikipedia.org/wiki/Defensive_programming">defensive
929             programming</ulink> checks localizing these checks within the contracts
930             and making the code more readable.
931           </simpara>
932         </listitem>
933       </itemizedlist>
934       <para>
935         Of course, not all formal contract specifications can be asserted in C++.
936         For example, in C++ is it not possible to assert the validity of an iterator
937         range in the general case (because the only way to check if two iterators
938         form a valid range is to keep incrementing the first iterator until it reaches
939         the second iterator, but if the iterator range is invalid then such a code
940         would render undefined behaviour or run forever instead of failing an assertion).
941         Nevertheless, a large amount of contract assertions can be successfully programmed
942         in C++ as illustrated by the numerous examples in this documentation and
943         from the literature (for example see how much of STL <link linkend="N1962_vector_anchor"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">vector</phrase></computeroutput></link> contract assertions can actually
944         be programmed in C++ using this library).
945       </para>
946       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.benefits_and_costs.h1">
947         <phrase id="boost_contract.contract_programming_overview.benefits_and_costs.costs"/><link linkend="boost_contract.contract_programming_overview.benefits_and_costs.costs">Costs</link>
948       </bridgehead>
949       <para>
950         In general, contract programming benefits come at the cost of performance
951         as discussed in detail by both <link linkend="Stroustrup94_anchor">[Stroustrup94]</link>
952         and <link linkend="Meyer97_anchor">[Meyer97]</link>. While performance trade-offs
953         should be carefully considered depending on the specific application domain,
954         software quality cannot be sacrificed: It is difficult to see value in software
955         that quickly and efficiently provides incorrect results.
956       </para>
957       <para>
958         The run-time performances are negatively impacted by contract programming
959         mainly because of extra time require to:
960       </para>
961       <itemizedlist>
962         <listitem>
963           <simpara>
964             Check the asserted conditions.
965           </simpara>
966         </listitem>
967         <listitem>
968           <simpara>
969             Copy old values when these are used in postconditions or exception guarantees.
970           </simpara>
971         </listitem>
972         <listitem>
973           <simpara>
974             Call additional functors that check preconditions, postconditions, exception
975             guarantees, class invariants, etc. (these can add up to many extra calls
976             especially when using subcontracting).
977           </simpara>
978         </listitem>
979       </itemizedlist>
980       <note>
981         <para>
982           In general, contracts introduce at least three extra functor calls to check
983           preconditions, postconditions, and exception guarantees for any given non-member
984           function call. Public functions introduce also two more function calls
985           to check class invariants (at entry and at exit). For subcontracting, these
986           extra calls (some of which become virtual calls) are repeated for the number
987           of functions being overridden from the base classes (possibly deep in the
988           inheritance tree). In addition to that, this library introduces a number
989           of function calls internal to its implementation in order to properly check
990           the contracts.
991         </para>
992       </note>
993       <para>
994         To mitigate the run-time performance impact, programmers can selectively
995         disable run-time checking of some of the contract assertions. Programmers
996         will have to decide based on the performance trade-offs required by their
997         specific applications, but a reasonable approach often is to (see <link linkend="boost_contract.extras.disable_contract_checking">Disable
998         Contract Checking</link>):
999       </para>
1000       <itemizedlist>
1001         <listitem>
1002           <simpara>
1003             Always write contracts to clarify the semantics of the design embedding
1004             the specifications directly in the code and making the code self-documenting.
1005           </simpara>
1006         </listitem>
1007         <listitem>
1008           <simpara>
1009             Check preconditions, postconditions, class invariants, and maybe even
1010             exception guarantees during initial testing.
1011           </simpara>
1012         </listitem>
1013         <listitem>
1014           <simpara>
1015             Check only preconditions (and maybe class invariants, but not postconditions
1016             and exception guarantees) during release testing and for the final release.
1017           </simpara>
1018         </listitem>
1019       </itemizedlist>
1020       <para>
1021         This approach is usually reasonable because in well-tested production code,
1022         validating the function body implementation using postconditions is rarely
1023         needed since the function has shown itself to be <quote>correct</quote> during
1024         testing. On the other hand, checking function arguments using preconditions
1025         is always needed because of changes that can be made to the calling code
1026         (without having to necessarily re-test and re-release the called code). Furthermore,
1027         postconditions and also exception guarantees, with related old value copies,
1028         are often computationally more expensive to check than preconditions and
1029         class invariants.
1030       </para>
1031     </section>
1032     <section id="boost_contract.contract_programming_overview.function_calls">
1033       <title><link linkend="boost_contract.contract_programming_overview.function_calls">Function
1034       Calls</link></title>
1035       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.function_calls.h0">
1036         <phrase id="boost_contract.contract_programming_overview.function_calls.non_member_functions"/><link linkend="boost_contract.contract_programming_overview.function_calls.non_member_functions">Non-Member
1037         Functions</link>
1038       </bridgehead>
1039       <para>
1040         A call to a non-member function with a contract executes the following steps
1041         (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>):
1042       </para>
1043       <orderedlist inheritnum="ignore" continuation="restarts">
1044         <listitem>
1045           <simpara>
1046             Check function preconditions.
1047           </simpara>
1048         </listitem>
1049         <listitem>
1050           <simpara>
1051             Execute the function body.
1052           </simpara>
1053         </listitem>
1054         <listitem>
1055           <simpara>
1056             If the body did not throw an exception, check function postconditions.
1057           </simpara>
1058         </listitem>
1059         <listitem>
1060           <simpara>
1061             Else, check function exception guarantees.
1062           </simpara>
1063         </listitem>
1064       </orderedlist>
1065       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.function_calls.h1">
1066         <phrase id="boost_contract.contract_programming_overview.function_calls.private_and_protected_functions"/><link linkend="boost_contract.contract_programming_overview.function_calls.private_and_protected_functions">Private
1067         and Protected Functions</link>
1068       </bridgehead>
1069       <para>
1070         Private and protected functions do not have to satisfy class invariants because
1071         these functions are part of the class implementation and not of the class
1072         public interface. Furthermore, the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
1073         principle</ulink> does not apply to private and protected functions because
1074         these functions are not accessible to the user at the calling site where
1075         the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
1076         principle</ulink> applies.
1077       </para>
1078       <para>
1079         Therefore, calls to private and protected functions with contracts execute
1080         the same steps as the ones indicated above for non-member functions (checking
1081         only preconditions and postconditions, without checking class invariants
1082         and without subcontracting).
1083       </para>
1084     </section>
1085     <section id="boost_contract.contract_programming_overview.public_function_calls">
1086       <title><link linkend="boost_contract.contract_programming_overview.public_function_calls">Public
1087       Function Calls</link></title>
1088       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.public_function_calls.h0">
1089         <phrase id="boost_contract.contract_programming_overview.public_function_calls.overriding_public_functions"/><link linkend="boost_contract.contract_programming_overview.public_function_calls.overriding_public_functions">Overriding
1090         Public Functions</link>
1091       </bridgehead>
1092       <para>
1093         Let's consider a public function in a derived class that overrides public
1094         virtual functions declared by its public base classes (because of C++ multiple
1095         inheritance, the function could override from more than one of its base classes).
1096         We refer to the function in the derived class as the <emphasis>overriding
1097         function</emphasis>, and to the set of base classes containing all the <emphasis>overridden
1098         functions</emphasis> as <emphasis>overridden bases</emphasis>.
1099       </para>
1100       <para>
1101         When subcontracting, overridden functions are searched (at compile-time)
1102         deeply in all public branches of the inheritance tree (i.e., not just the
1103         derived class' direct public parents are inspected, but also all its public
1104         grandparents, etc.). In case of multiple inheritance, this search also extends
1105         (at compile-time) widely to all public trees of the multiple inheritance
1106         forest (multiple public base classes are searched following their order of
1107         declaration in the derived class' inheritance list). As usual with C++ multiple
1108         inheritance, this search could result in multiple overridden functions and
1109         therefore in subcontracting from multiple public base classes. Note that
1110         only public base classes are considered for subcontracting because private
1111         and protected base classes are not accessible to the user at the calling
1112         site where the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
1113         principle</ulink> applies.
1114       </para>
1115       <para>
1116         A call to the overriding public function with a contract executes the following
1117         steps (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>):
1118       </para>
1119       <orderedlist inheritnum="ignore" continuation="restarts">
1120         <listitem>
1121           <simpara>
1122             Check static class invariants <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1123             non-static class invariants for all overridden bases, <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1124             then check the derived class static <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1125             non-static invariants.
1126           </simpara>
1127         </listitem>
1128         <listitem>
1129           <simpara>
1130             Check preconditions of overridden public functions from all overridden
1131             bases in <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
1132             with each other, <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
1133             else check the overriding function preconditions in the derived class.
1134           </simpara>
1135         </listitem>
1136         <listitem>
1137           <simpara>
1138             Execute the overriding function body.
1139           </simpara>
1140         </listitem>
1141         <listitem>
1142           <simpara>
1143             Check static class invariants <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1144             non-static class invariants for all overridden bases, <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1145             then check the derived class static <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1146             non-static invariants (even if the body threw an exception).
1147           </simpara>
1148         </listitem>
1149         <listitem>
1150           <simpara>
1151             If the body did not throw an exception, check postconditions of overridden
1152             public functions from all overridden bases in <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1153             with each other, <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1154             then check the overriding function postconditions in the derived class.
1155           </simpara>
1156         </listitem>
1157         <listitem>
1158           <simpara>
1159             Else, check exception guarantees of overridden public functions from
1160             all overridden bases in <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1161             with each other, <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1162             then check the overriding function exception guarantees in the derived
1163             class.
1164           </simpara>
1165         </listitem>
1166       </orderedlist>
1167       <para>
1168         Volatile public functions check static class invariants <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1169         volatile class invariants instead. Preconditions and postconditions of volatile
1170         public functions and volatile class invariants access the object as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>.
1171       </para>
1172       <para>
1173         Class invariants are checked before preconditions and postconditions so programming
1174         precondition and postcondition assertions can be simplified assuming that
1175         class invariants are satisfied already (e.g., if class invariants assert
1176         that a pointer cannot be null then preconditions and postconditions can safety
1177         dereference that pointer without additional checking). Similarly, static
1178         class invariants are checked before non-static class invariants so programming
1179         non-static class invariant (volatile and non) can be simplified assuming
1180         that static class invariants are satisfied already. Furthermore, subcontracting
1181         checks contracts of public base classes before checking the derived class
1182         contracts so programming derived class contract assertions can be simplified
1183         by assuming that public base class contracts are satisfied already.
1184       </para>
1185       <note>
1186         <para>
1187           <anchor id="and_anchor"/><anchor id="or_anchor"/>In this documentation
1188           <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1189           and <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
1190           indicate the logic <emphasis>and</emphasis> and <emphasis>or</emphasis>
1191           operations evaluated in <emphasis>short-circuit</emphasis>. For example:
1192           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">p</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1193           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">q</phrase></computeroutput> is true if and only if
1194           both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">p</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">q</phrase></computeroutput> are true, but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">q</phrase></computeroutput>
1195           is never evaluated when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">p</phrase></computeroutput>
1196           is false; <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">p</phrase></computeroutput> <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
1197           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">q</phrase></computeroutput> is true if and only if
1198           either <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">p</phrase></computeroutput> or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">q</phrase></computeroutput> are true, but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">q</phrase></computeroutput>
1199           is never evaluated when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">p</phrase></computeroutput>
1200           is true.
1201         </para>
1202         <para>
1203           As indicated by the steps above and in accordance with the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
1204           principle</ulink>, subcontracting checks preconditions in <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
1205           while class invariants, postconditions, and exceptions guarantees are checked
1206           in <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1207           with preconditions, class invariants, postconditions, and exceptions guarantees
1208           of base classes respectively.
1209         </para>
1210       </note>
1211       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.public_function_calls.h1">
1212         <phrase id="boost_contract.contract_programming_overview.public_function_calls.non_overriding_public_functions"/><link linkend="boost_contract.contract_programming_overview.public_function_calls.non_overriding_public_functions">Non-Overriding
1213         Public Functions</link>
1214       </bridgehead>
1215       <para>
1216         A call to a non-static public function with a contract (that does not override
1217         functions from any of its public base classes) executes the following steps
1218         (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>):
1219       </para>
1220       <orderedlist inheritnum="ignore" continuation="restarts">
1221         <listitem>
1222           <simpara>
1223             Check class static <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1224             non-static invariants (but none of the invariants from base classes).
1225           </simpara>
1226         </listitem>
1227         <listitem>
1228           <simpara>
1229             Check function preconditions (but none of the preconditions from functions
1230             in base classes).
1231           </simpara>
1232         </listitem>
1233         <listitem>
1234           <simpara>
1235             Execute the function body.
1236           </simpara>
1237         </listitem>
1238         <listitem>
1239           <simpara>
1240             Check the class static <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1241             non-static invariants (even if the body threw an exception, but none
1242             of the invariants from base classes).
1243           </simpara>
1244         </listitem>
1245         <listitem>
1246           <simpara>
1247             If the body did not throw an exception, check function postconditions
1248             (but none of the postconditions from functions in base classes).
1249           </simpara>
1250         </listitem>
1251         <listitem>
1252           <simpara>
1253             Else, check function exception guarantees (but none of the exception
1254             guarantees from functions in base classes).
1255           </simpara>
1256         </listitem>
1257       </orderedlist>
1258       <para>
1259         Volatile public functions check static class invariants <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1260         volatile class invariants instead. Preconditions and postconditions of volatile
1261         functions and volatile class invariants access the object as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>.
1262       </para>
1263       <para>
1264         Class invariants are checked because this function is part of the class public
1265         interface. However, none of the contracts of the base classes are checked
1266         because this function does not override any functions from any of the public
1267         base classes (so the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
1268         principle</ulink> does not require to subcontract in this case).
1269       </para>
1270       <bridgehead renderas="sect4" id="boost_contract.contract_programming_overview.public_function_calls.h2">
1271         <phrase id="boost_contract.contract_programming_overview.public_function_calls.static_public_functions"/><link linkend="boost_contract.contract_programming_overview.public_function_calls.static_public_functions">Static
1272         Public Functions</link>
1273       </bridgehead>
1274       <para>
1275         A call to a static public function with a contract executes the following
1276         steps (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>):
1277       </para>
1278       <orderedlist inheritnum="ignore" continuation="restarts">
1279         <listitem>
1280           <simpara>
1281             Check static class invariants (but not the non-static invariants and
1282             none of the invariants from base classes).
1283           </simpara>
1284         </listitem>
1285         <listitem>
1286           <simpara>
1287             Check function preconditions (but none of the preconditions from functions
1288             in base classes).
1289           </simpara>
1290         </listitem>
1291         <listitem>
1292           <simpara>
1293             Execute the function body.
1294           </simpara>
1295         </listitem>
1296         <listitem>
1297           <simpara>
1298             Check static class invariants (even if the body threw an exception, but
1299             not the non-static invariants and none of the invariants from base classes).
1300           </simpara>
1301         </listitem>
1302         <listitem>
1303           <simpara>
1304             If the body did not throw an exception, check function postconditions
1305             (but none of the postconditions from functions in base classes).
1306           </simpara>
1307         </listitem>
1308         <listitem>
1309           <simpara>
1310             Else, check function exception guarantees (but none of the exception
1311             guarantees from functions in base classes).
1312           </simpara>
1313         </listitem>
1314       </orderedlist>
1315       <para>
1316         Class invariants are checked because this function is part of the class public
1317         interface, but only static class invariants can be checked (because this
1318         is a static function so it cannot access the object that would instead be
1319         required to check non-static class invariants, volatile or not). Furthermore,
1320         static functions cannot override any function so the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
1321         principle</ulink> does not apply and they do not subcontract.
1322       </para>
1323       <para>
1324         Preconditions and postconditions of static functions and static class invariants
1325         cannot access the object (because they are checked from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
1326         member functions).
1327       </para>
1328     </section>
1329     <section id="boost_contract.contract_programming_overview.constructor_calls">
1330       <title><link linkend="boost_contract.contract_programming_overview.constructor_calls">Constructor
1331       Calls</link></title>
1332       <para>
1333         A call to a constructor with a contract executes the following steps (see
1334         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
1335         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>):
1336       </para>
1337       <orderedlist inheritnum="ignore" continuation="restarts">
1338         <listitem>
1339           <simpara>
1340             Check constructor preconditions (but these cannot access the object because
1341             the object is not constructed yet).
1342           </simpara>
1343         </listitem>
1344         <listitem>
1345           <simpara>
1346             Execute the constructor member initialization list (if present).
1347             <orderedlist inheritnum="ignore" continuation="restarts">
1348               <listitem>
1349                 <simpara>
1350                   Construct any base class (public or not) according with C++ construction
1351                   mechanism and also check the contracts of these base constructors
1352                   (according with steps similar to the ones listed here).
1353                 </simpara>
1354               </listitem>
1355             </orderedlist>
1356           </simpara>
1357         </listitem>
1358         <listitem>
1359           <simpara>
1360             Check static class invariants (but not the non-static or volatile class
1361             invariants, because the object is not constructed yet).
1362           </simpara>
1363         </listitem>
1364         <listitem>
1365           <simpara>
1366             Execute the constructor body.
1367           </simpara>
1368         </listitem>
1369         <listitem>
1370           <simpara>
1371             Check static class invariants (even if the body threw an exception).
1372           </simpara>
1373         </listitem>
1374         <listitem>
1375           <simpara>
1376             If the body did not throw an exception:
1377             <orderedlist inheritnum="ignore" continuation="restarts">
1378               <listitem>
1379                 <simpara>
1380                   Check non-static <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1381                   volatile class invariants (because the object is now successfully
1382                   constructed).
1383                 </simpara>
1384               </listitem>
1385               <listitem>
1386                 <simpara>
1387                   Check constructor postconditions (but these cannot access the object
1388                   old value <literal moreinfo="none"><emphasis>oldof</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase></computeroutput> because the object was not constructed
1389                   before the execution of the constructor body).
1390                 </simpara>
1391               </listitem>
1392             </orderedlist>
1393           </simpara>
1394         </listitem>
1395         <listitem>
1396           <simpara>
1397             Else, check constructor exception guarantees (but these cannot access
1398             the object old value <literal moreinfo="none"><emphasis>oldof</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase></computeroutput> because the object was not constructed
1399             before the execution of the constructor body, plus they can only access
1400             class' static members because the object has not been successfully constructed
1401             given the constructor body threw an exception in this case).
1402           </simpara>
1403         </listitem>
1404       </orderedlist>
1405       <para>
1406         Constructor preconditions are checked before executing the member initialization
1407         list so programming these initializations can be simplified assuming the
1408         constructor preconditions are satisfied (e.g., constructor arguments can
1409         be validated by the constructor preconditions before they are used to initialize
1410         base classes and data members).
1411       </para>
1412       <para>
1413         As indicated in step 2.a. above, C++ object construction mechanism will automatically
1414         check base class contracts when these bases are initialized (no explicit
1415         subcontracting behaviour is required here).
1416       </para>
1417     </section>
1418     <section id="boost_contract.contract_programming_overview.destructor_calls">
1419       <title><link linkend="boost_contract.contract_programming_overview.destructor_calls">Destructor
1420       Calls</link></title>
1421       <para>
1422         A call to a destructor with a contract executes the following steps (see
1423         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>):
1424       </para>
1425       <orderedlist inheritnum="ignore" continuation="restarts">
1426         <listitem>
1427           <simpara>
1428             Check static class invariants <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1429             non-static <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1430             volatile class invariants.
1431           </simpara>
1432         </listitem>
1433         <listitem>
1434           <simpara>
1435             Execute the destructor body (destructors have no parameters and they
1436             can be called at any time after object construction so they have no preconditions).
1437           </simpara>
1438         </listitem>
1439         <listitem>
1440           <simpara>
1441             Check static class invariants (even if the body threw an exception).
1442           </simpara>
1443         </listitem>
1444         <listitem>
1445           <simpara>
1446             If the body did not throw an exception:
1447             <orderedlist inheritnum="ignore" continuation="restarts">
1448               <listitem>
1449                 <simpara>
1450                   Check destructor postconditions (but these can only access class'
1451                   static members and the object old value <literal moreinfo="none"><emphasis>oldof</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase></computeroutput> because the object has been destroyed
1452                   after successful execution of the destructor body). <footnote id="boost_contract.contract_programming_overview.destructor_calls.f0">
1453                   <para>
1454                     <emphasis role="bold">Rationale:</emphasis> Postconditions for
1455                     destructors are not part of <link linkend="N1962_anchor">[N1962]</link>
1456                     or other references listed in the <link linkend="boost_contract.bibliography">Bibliography</link>
1457                     (but with respect to <link linkend="Meyer97_anchor">[Meyer97]</link>
1458                     it should be noted that Eiffel does not support static data members
1459                     and that might by why destructors do not have postconditions
1460                     in Eiffel). However, in principle there could be uses for destructor
1461                     postconditions so this library supports postconditions for destructors
1462                     (e.g., a class that counts object instances could use destructor
1463                     postconditions to assert that an instance counter stored in a
1464                     static data member is decreased by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase></computeroutput>
1465                     because the object has been destructed).
1466                   </para>
1467                   </footnote>
1468                 </simpara>
1469               </listitem>
1470               <listitem>
1471                 <simpara>
1472                   Destroy any base class (public or not) according with C++ destruction
1473                   mechanism and also check the contracts of these base destructors
1474                   (according with steps similar to the ones listed here).
1475                 </simpara>
1476               </listitem>
1477             </orderedlist>
1478           </simpara>
1479         </listitem>
1480         <listitem>
1481           <simpara>
1482             Else (even if destructors should rarely, if ever, be allowed to throw
1483             exceptions in C++):
1484             <orderedlist inheritnum="ignore" continuation="restarts">
1485               <listitem>
1486                 <simpara>
1487                   Check non-static <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
1488                   volatile class invariants (because the object was not successfully
1489                   destructed so it still exists and should satisfy its invariants).
1490                 </simpara>
1491               </listitem>
1492               <listitem>
1493                 <simpara>
1494                   Check destructor exception guarantees.
1495                 </simpara>
1496               </listitem>
1497             </orderedlist>
1498           </simpara>
1499         </listitem>
1500       </orderedlist>
1501       <para>
1502         As indicated in step 4.b. above, C++ object destruction mechanism will automatically
1503         check base class contracts when the destructor exits without throwing an
1504         exception (no explicit subcontracting behaviour is required here).
1505       </para>
1506       <note>
1507         <para>
1508           Given that C++ allows destructors to throw, this library handles the case
1509           when the destructor body throws an exception as indicated above. However,
1510           in order to comply with STL exception safety guarantees and good C++ programming
1511           practices, programmers should implement destructor bodies to rarely, if
1512           ever, throw exceptions (in fact destructors are implicitly declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput> in C++11).
1513         </para>
1514       </note>
1515     </section>
1516     <section id="boost_contract.contract_programming_overview.constant_correctness">
1517       <title><link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link></title>
1518       <para>
1519         Contracts should not be allowed to modify the program state because they
1520         are only responsible to check (and not to change) the program state in order
1521         to verify its compliance with the specifications. Therefore, contracts should
1522         only access objects, function arguments, function return values, old values,
1523         and all other program variables in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
1524         context (via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput>,
1525         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">*</phrase>
1526         <phrase role="keyword">const</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
1527         <phrase role="keyword">volatile</phrase></computeroutput>, etc.).
1528       </para>
1529       <para>
1530         Whenever possible (e.g., class invariants and postcondition old values),
1531         this library automatically enforces this <emphasis>constant-correctness constraint</emphasis>
1532         at compile-time using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>.
1533         However, this library cannot automatically enforce this constraint in all
1534         cases (for preconditions and postconditions of mutable member functions,
1535         for global variables, etc.). See <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
1536         Lambda Functions</link> for ways of using this library that enforce the constant-correctness
1537         constraint at compile-time (but at the cost of significant boiler-plate code
1538         to be programmed manually so not recommended in general).
1539       </para>
1540       <note>
1541         <para>
1542           In general, it is the responsibility of the programmers to code assertions
1543           that only check, and do not change, program variables. <footnote id="boost_contract.contract_programming_overview.constant_correctness.f0">
1544           <para>
1545             Note that this is true when using C-style <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput>
1546             as well.
1547           </para>
1548           </footnote>
1549         </para>
1550       </note>
1551     </section>
1552     <section id="boost_contract.contract_programming_overview.specifications_vs__implementation">
1553       <title><link linkend="boost_contract.contract_programming_overview.specifications_vs__implementation">Specifications
1554       vs. Implementation</link></title>
1555       <para>
1556         Contracts are part of the program specification and not of its implementation.
1557         Therefore, contracts should ideally be programmed within C++ declarations,
1558         and not within definitions.
1559       </para>
1560       <para>
1561         In general, this library cannot satisfy this requirement. However, even when
1562         contracts are programmed together with the body in the function definition,
1563         it is still fairly easy for users to identify and read just the contract
1564         portion of the function definition (because the contract code must always
1565         be programmed at the very top of the function definition). See <link linkend="boost_contract.extras.separate_body_implementation">Separate
1566         Body Implementation</link> for ways of using this library to program contract
1567         specifications outside of the body implementation (but at the cost of writing
1568         one extra function for any given function so not recommended in general).
1569       </para>
1570       <para>
1571         Furthermore, contracts are most useful when they assert conditions only using
1572         public members (in most cases, the need for using non-public members to check
1573         contracts, especially in preconditions, indicates an error in the class design).
1574         For example, the caller of a public function cannot in general make sure
1575         that the function preconditions are satisfied if the precondition assertions
1576         use private members that are not callable by the caller (therefore, a failure
1577         in the preconditions will not necessarily indicate a bug in the caller given
1578         that the caller was made unable to fully check the preconditions in the first
1579         place). However, given that C++ provides programmers ways around access level
1580         restrictions (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">friend</phrase></computeroutput>, function
1581         pointers, etc.), this library leaves it up to programmers to make sure that
1582         only public members are used in contract assertions (especially in preconditions).
1583         (<link linkend="N1962_anchor">[N1962]</link> follows the same approach not
1584         restricting contracts to only use public members, Eiffel instead generates
1585         a compile-time error if preconditions are asserted using non-public members.)
1586         <footnote id="boost_contract.contract_programming_overview.specifications_vs__implementation.f0">
1587         <para>
1588           <emphasis role="bold">Rationale:</emphasis> Out of curiosity, if C++ <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#45">defect
1589           45</ulink> had not been fixed, this library could have been implemented
1590           to generate a compile-time error when precondition assertions use non-public
1591           members more similarly to Eiffel's implementation (but still, not necessary
1592           the best approach for C++).
1593         </para>
1594         </footnote>
1595       </para>
1596     </section>
1597     <section id="boost_contract.contract_programming_overview.on_contract_failures">
1598       <title><link linkend="boost_contract.contract_programming_overview.on_contract_failures">On
1599       Contract Failures</link></title>
1600       <para>
1601         If preconditions, postconditions, exception guarantees, or class invariants
1602         are either checked to be false or their evaluation throws an exception at
1603         run-time then this library will call specific <emphasis>failure handler functions</emphasis>.
1604         <footnote id="boost_contract.contract_programming_overview.on_contract_failures.f0">
1605         <para>
1606           <emphasis role="bold">Rationale:</emphasis> If the evaluation of a contract
1607           assertion throws an exception, the assertion cannot be checked to be true
1608           so the only safe thing to assume is that the assertion failed (indeed the
1609           contract assertion checking failed) and call the contract failure handler
1610           in this case also.
1611         </para>
1612         </footnote>
1613       </para>
1614       <para>
1615         By default, these failure handler functions print a message to the standard
1616         error <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput> (with detailed information about the
1617         failure) and then terminate the program calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>.
1618         However, using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_precondition_failure">boost::contract::set_precondition_failure</link></computeroutput>,
1619         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_postcondition_failure">boost::contract::set_postcondition_failure</link></computeroutput>,
1620         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_except_failure">boost::contract::set_except_failure</link></computeroutput>,
1621         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_invariant_failure">boost::contract::set_invariant_failure</link></computeroutput>,
1622         etc. programmers can define their own failure handler functions that can
1623         take any user-specified action (throw an exception, exit the program with
1624         an error code, etc., see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
1625         on Failures</link>). <footnote id="boost_contract.contract_programming_overview.on_contract_failures.f1">
1626         <para>
1627           <emphasis role="bold">Rationale:</emphasis> This customizable failure handling
1628           mechanism is similar to the one used by C++ <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>
1629           and also to the one proposed in <link linkend="N1962_anchor">[N1962]</link>.
1630         </para>
1631         </footnote>
1632       </para>
1633       <note>
1634         <para>
1635           In C++ there are a number of issues with programming contract failure handlers
1636           that throw exceptions instead of terminating the program. Specifically,
1637           destructors check class invariants so they will throw if programmers change
1638           class invariant failure handlers to throw instead of terminating the program,
1639           but in general destructors should not throw in C++ (to comply with STL
1640           exception safety, C++11 implicit <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput>
1641           declarations for destructors, etc.). Furthermore, programming a failure
1642           handler that throws on exception guarantee failures results in throwing
1643           an exception (the one reporting the contract failure) while there is already
1644           an active exception (the one that caused the exception guarantees to be
1645           checked in the first place), and this will force C++ to terminate the program
1646           anyway.
1647         </para>
1648       </note>
1649       <para>
1650         Therefore, it is recommended to terminate the program at least for contract
1651         failures from destructors and exception guarantees (if not in all other cases
1652         of contract failures as it is done by default by this library). The contract
1653         failure handler functions programmed using this library have information
1654         about the failed contract (preconditions, postconditions, etc.) and the operation
1655         that was checking the contract (constructor, destructor, etc.) so programmers
1656         can granularly distinguish all cases and decide when it is appropriate to
1657         terminate, throw, or take some other user-specific action.
1658       </para>
1659     </section>
1660     <section id="boost_contract.contract_programming_overview.feature_summary">
1661       <title><link linkend="boost_contract.contract_programming_overview.feature_summary">Feature
1662       Summary</link></title>
1663       <para>
1664         The contract programming features supported by this library are largely based
1665         on <link linkend="N1962_anchor">[N1962]</link> and on the Eiffel programming
1666         language.
1667       </para>
1668       <para>
1669         The following table compares contract programming features among this library,
1670         <link linkend="N1962_anchor">[N1962]</link> (unfortunately the C++ standard
1671         committee rejected this proposal commenting on a lack of interest in adding
1672         contract programming to C++ at that time, even if <link linkend="N1962_anchor">[N1962]</link>
1673         itself is sound), a more recent proposal <link linkend="P0380_anchor">[P0380]</link>
1674         (which was accepted in the C++20 standard but unfortunately only supports
1675         preconditions and postconditions, while does not support class invariants,
1676         old values, and subcontracting), the Eiffel and D programming languages.
1677         Some of the items listed in this summary table will become clear in detail
1678         after reading the remaining sections of this documentation.
1679       </para>
1680       <informaltable frame="all">
1681         <tgroup cols="6">
1682           <thead>
1683             <row>
1684               <entry>
1685                 <para>
1686                   Feature
1687                 </para>
1688               </entry>
1689               <entry>
1690                 <para>
1691                   This Library
1692                 </para>
1693               </entry>
1694               <entry>
1695                 <para>
1696                   <link linkend="N1962_anchor">[N1962]</link> Proposal (not accepted
1697                   in C++)
1698                 </para>
1699               </entry>
1700               <entry>
1701                 <para>
1702                   C++20 (see <link linkend="P0380_anchor">[P0380]</link>)
1703                 </para>
1704               </entry>
1705               <entry>
1706                 <para>
1707                   ISE Eiffel 5.4 (see <link linkend="Meyer97_anchor">[Meyer97]</link>)
1708                 </para>
1709               </entry>
1710               <entry>
1711                 <para>
1712                   D (see <link linkend="Bright04_anchor">[Bright04]</link>)
1713                 </para>
1714               </entry>
1715             </row>
1716           </thead>
1717           <tbody>
1718             <row>
1719               <entry>
1720                 <para>
1721                   <emphasis>Keywords and specifiers</emphasis>
1722                 </para>
1723               </entry>
1724               <entry>
1725                 <para>
1726                   Specifiers: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">precondition</phrase></computeroutput>,
1727                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">postcondition</phrase></computeroutput>,
1728                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>. The last three specifiers
1729                   appear in user code so their names can be referred to or changed
1730                   using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</link></computeroutput>,
1731                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998621472">BOOST_CONTRACT_STATIC_INVARIANT</link></computeroutput>,
1732                   and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999732400">BOOST_CONTRACT_BASES_TYPEDEF</link></computeroutput>
1733                   macros respectively to avoid name clashes.
1734                 </para>
1735               </entry>
1736               <entry>
1737                 <para>
1738                   Keywords: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">precondition</phrase></computeroutput>,
1739                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">postcondition</phrase></computeroutput>,
1740                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">oldof</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>.
1741                 </para>
1742               </entry>
1743               <entry>
1744                 <para>
1745                   Attributes: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[[</phrase><phrase role="identifier">expects</phrase><phrase role="special">]]</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[[</phrase><phrase role="identifier">ensures</phrase><phrase role="special">]]</phrase></computeroutput>.
1746                 </para>
1747               </entry>
1748               <entry>
1749                 <para>
1750                   Keywords: <literal moreinfo="none">require</literal>, <literal moreinfo="none">require else</literal>,
1751                   <literal moreinfo="none">ensure</literal>, <literal moreinfo="none">ensure then</literal>, <literal moreinfo="none">old</literal>,
1752                   <literal moreinfo="none">result</literal>, <literal moreinfo="none">do</literal>, and <literal moreinfo="none">invariant</literal>.
1753                 </para>
1754               </entry>
1755               <entry>
1756                 <para>
1757                   Keywords: <literal moreinfo="none">in</literal>, <literal moreinfo="none">out</literal>, <literal moreinfo="none">do</literal>,
1758                   <literal moreinfo="none">assert</literal>, and <literal moreinfo="none">invariant</literal>.
1759                 </para>
1760               </entry>
1761             </row>
1762             <row>
1763               <entry>
1764                 <para>
1765                   <emphasis>On contract failures</emphasis>
1766                 </para>
1767               </entry>
1768               <entry>
1769                 <para>
1770                   Print an error to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput>
1771                   and call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput> (but can be customized
1772                   to throw exceptions, exit with an error code, etc.).
1773                 </para>
1774               </entry>
1775               <entry>
1776                 <para>
1777                   Call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput> (but can be customized
1778                   to throw exceptions, exit with an error code, etc.).
1779                 </para>
1780               </entry>
1781               <entry>
1782                 <para>
1783                   Call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">abort</phrase></computeroutput> (but can be customized
1784                   to throw exceptions, exit with an error code, etc.).
1785                 </para>
1786               </entry>
1787               <entry>
1788                 <para>
1789                   Throw exceptions.
1790                 </para>
1791               </entry>
1792               <entry>
1793                 <para>
1794                   Throw exceptions.
1795                 </para>
1796               </entry>
1797             </row>
1798             <row>
1799               <entry>
1800                 <para>
1801                   <emphasis>Return values in postconditions</emphasis>
1802                 </para>
1803               </entry>
1804               <entry>
1805                 <para>
1806                   Yes, captured by or passed as a parameter to (for virtual functions)
1807                   the postcondition functor.
1808                 </para>
1809               </entry>
1810               <entry>
1811                 <para>
1812                   Yes, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>result-variable-name</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
1813                 </para>
1814               </entry>
1815               <entry>
1816                 <para>
1817                   Yes, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[[</phrase><phrase role="identifier">ensures</phrase>
1818                   </computeroutput><literal moreinfo="none"><emphasis>result-variable-name</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">:</phrase> <phrase role="special">...]]</phrase></computeroutput>.
1819                 </para>
1820               </entry>
1821               <entry>
1822                 <para>
1823                   Yes, <literal moreinfo="none">result</literal> keyword.
1824                 </para>
1825               </entry>
1826               <entry>
1827                 <para>
1828                   Yes, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">out</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>result-variable-name</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
1829                 </para>
1830               </entry>
1831             </row>
1832             <row>
1833               <entry>
1834                 <para>
1835                   <emphasis>Old values in postconditions</emphasis>
1836                 </para>
1837               </entry>
1838               <entry>
1839                 <para>
1840                   Yes, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
1841                   macro and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
1842                   (but copied before preconditions unless <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput>
1843                   is used as shown in <link linkend="boost_contract.advanced.old_values_copied_at_body">Old
1844                   Values Copied at Body</link>). For templates, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>
1845                   skips old value copies for non-copyable types and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
1846                   skips old value copies selectively based on old expression type
1847                   requirements (on compilers that do not support <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
1848                   <phrase role="keyword">constexpr</phrase></computeroutput>).
1849                 </para>
1850               </entry>
1851               <entry>
1852                 <para>
1853                   Yes, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">oldof</phrase></computeroutput> keyword
1854                   (copied right after preconditions). (Never skipped, not even in
1855                   templates for non-copyable types.)
1856                 </para>
1857               </entry>
1858               <entry>
1859                 <para>
1860                   No.
1861                 </para>
1862               </entry>
1863               <entry>
1864                 <para>
1865                   Yes, <literal moreinfo="none">old</literal> keyword (copied right after preconditions).
1866                   (Never skipped, but all types are copyable in Eiffel.)
1867                 </para>
1868               </entry>
1869               <entry>
1870                 <para>
1871                   No.
1872                 </para>
1873               </entry>
1874             </row>
1875             <row>
1876               <entry>
1877                 <para>
1878                   <emphasis>Class invariants</emphasis>
1879                 </para>
1880               </entry>
1881               <entry>
1882                 <para>
1883                   Yes, checked at constructor exit, at destructor entry and throw,
1884                   and at public function entry, exit, and throw. Same for volatile
1885                   class invariants. Static class invariants checked at entry, exit,
1886                   and throw for constructors, destructors, and any (also <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>) public function.
1887                 </para>
1888               </entry>
1889               <entry>
1890                 <para>
1891                   Yes, checked at constructor exit, at destructor entry and throw,
1892                   and at public function entry, exit, and throw. (Volatile and static
1893                   class invariants not supported.)
1894                 </para>
1895               </entry>
1896               <entry>
1897                 <para>
1898                   No.
1899                 </para>
1900               </entry>
1901               <entry>
1902                 <para>
1903                   Yes, checked at constructor exit, and around public functions.
1904                   (Volatile and static class invariants do not apply to Eiffel.)
1905                 </para>
1906               </entry>
1907               <entry>
1908                 <para>
1909                   Yes, checked at constructor exit, at destructor entry, and around
1910                   public functions. However, invariants cannot call public functions
1911                   (to avoid infinite recursion because D does not disable contracts
1912                   while checking other contracts). (Volatile and static class invariants
1913                   not supported, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>
1914                   was deprecated all together in D.)
1915                 </para>
1916               </entry>
1917             </row>
1918             <row>
1919               <entry>
1920                 <para>
1921                   <emphasis>Subcontracting</emphasis>
1922                 </para>
1923               </entry>
1924               <entry>
1925                 <para>
1926                   Yes, also supports subcontracting for multiple inheritance (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>,
1927                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>,
1928                   and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput>
1929                   are used to declare base classes, overrides and virtual public
1930                   functions respectively).
1931                 </para>
1932               </entry>
1933               <entry>
1934                 <para>
1935                   Yes, also supports subcontracting for multiple inheritance, but
1936                   preconditions cannot be subcontracted. <footnote id="boost_contract.contract_programming_overview.feature_summary.f0">
1937                   <para>
1938                     <emphasis role="bold">Rationale:</emphasis> The authors of <link linkend="N1962_anchor">[N1962]</link> decided to forbid derived
1939                     classes from subcontracting preconditions because they found
1940                     that such a feature was rarely, if ever, used (see <ulink url="http://lists.boost.org/Archives/boost/2010/04/164862.php">Re:
1941                     [boost] [contract] diff n1962</ulink>). Still, it should be noted
1942                     that even in <link linkend="N1962_anchor">[N1962]</link> if a
1943                     derived class overrides two functions with preconditions coming
1944                     from two different base classes via multiple inheritance, the
1945                     overriding function contract will check preconditions from its
1946                     two base class functions in <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
1947                     (so even in <link linkend="N1962_anchor">[N1962]</link> preconditions
1948                     can indirectly subcontract when multiple inheritance is used).
1949                     Furthermore, subcontracting preconditions is soundly defined
1950                     by the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
1951                     principle</ulink> so this library allows to subcontract preconditions
1952                     as Eiffel does (users can always avoid using this feature if
1953                     they have no need for it). (This is essentially the only feature
1954                     on which this library deliberately differs from <link linkend="N1962_anchor">[N1962]</link>.)
1955                   </para>
1956                   </footnote>
1957                 </para>
1958               </entry>
1959               <entry>
1960                 <para>
1961                   No.
1962                 </para>
1963               </entry>
1964               <entry>
1965                 <para>
1966                   Yes.
1967                 </para>
1968               </entry>
1969               <entry>
1970                 <para>
1971                   Yes.
1972                 </para>
1973               </entry>
1974             </row>
1975             <row>
1976               <entry>
1977                 <para>
1978                   <emphasis>Contracts for pure virtual functions</emphasis>
1979                 </para>
1980               </entry>
1981               <entry>
1982                 <para>
1983                   Yes (programmed via out-of-line functions as always in C++ with
1984                   pure virtual function definitions).
1985                 </para>
1986               </entry>
1987               <entry>
1988                 <para>
1989                   Yes.
1990                 </para>
1991               </entry>
1992               <entry>
1993                 <para>
1994                   No (because no subcontracting).
1995                 </para>
1996               </entry>
1997               <entry>
1998                 <para>
1999                   Yes (contracts for abstract functions).
2000                 </para>
2001               </entry>
2002               <entry>
2003                 <para>
2004                   No.
2005                 </para>
2006               </entry>
2007             </row>
2008             <row>
2009               <entry>
2010                 <para>
2011                   <emphasis>Arbitrary code in contracts</emphasis>
2012                 </para>
2013               </entry>
2014               <entry>
2015                 <para>
2016                   Yes (but users are generally recommended to only program assertions
2017                   using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
2018                   and if-guard statements within contracts to avoid introducing bugs
2019                   and expensive code in contracts, and also to only use public functions
2020                   to program preconditions).
2021                 </para>
2022               </entry>
2023               <entry>
2024                 <para>
2025                   No, assertions only (use of only public functions to program preconditions
2026                   is recommended but not prescribed).
2027                 </para>
2028               </entry>
2029               <entry>
2030                 <para>
2031                   No, assertions only (in addition contracts of public, protected,
2032                   and private members can only use other public, public/protected,
2033                   and public/protected/private members respectively).
2034                 </para>
2035               </entry>
2036               <entry>
2037                 <para>
2038                   No, assertions only (in addition only public members can be used
2039                   in preconditions).
2040                 </para>
2041               </entry>
2042               <entry>
2043                 <para>
2044                   Yes.
2045                 </para>
2046               </entry>
2047             </row>
2048             <row>
2049               <entry>
2050                 <para>
2051                   <emphasis>Constant-correctness</emphasis>
2052                 </para>
2053               </entry>
2054               <entry>
2055                 <para>
2056                   No, enforced only for class invariants and old values (making also
2057                   preconditions and postconditions constant-correct is possible but
2058                   requires users to program a fare amount of boiler-plate code).
2059                 </para>
2060               </entry>
2061               <entry>
2062                 <para>
2063                   Yes.
2064                 </para>
2065               </entry>
2066               <entry>
2067                 <para>
2068                   Yes (side effects in contracts lead to undefined behaviour).
2069                 </para>
2070               </entry>
2071               <entry>
2072                 <para>
2073                   Yes.
2074                 </para>
2075               </entry>
2076               <entry>
2077                 <para>
2078                   No, enforced only for class invariants.
2079                 </para>
2080               </entry>
2081             </row>
2082             <row>
2083               <entry>
2084                 <para>
2085                   <emphasis>Contracts in specifications</emphasis>
2086                 </para>
2087               </entry>
2088               <entry>
2089                 <para>
2090                   No, in function definitions instead (unless programmers manually
2091                   write an extra function for any given function).
2092                 </para>
2093               </entry>
2094               <entry>
2095                 <para>
2096                   Yes (in function declarations).
2097                 </para>
2098               </entry>
2099               <entry>
2100                 <para>
2101                   Yes (in function declarations).
2102                 </para>
2103               </entry>
2104               <entry>
2105                 <para>
2106                   Yes.
2107                 </para>
2108               </entry>
2109               <entry>
2110                 <para>
2111                   Yes.
2112                 </para>
2113               </entry>
2114             </row>
2115             <row>
2116               <entry>
2117                 <para>
2118                   <emphasis>Function code ordering</emphasis>
2119                 </para>
2120               </entry>
2121               <entry>
2122                 <para>
2123                   Preconditions, postconditions, exception guarantees, body.
2124                 </para>
2125               </entry>
2126               <entry>
2127                 <para>
2128                   Preconditions, postconditions, body.
2129                 </para>
2130               </entry>
2131               <entry>
2132                 <para>
2133                   Preconditions, postconditions, body.
2134                 </para>
2135               </entry>
2136               <entry>
2137                 <para>
2138                   Preconditions, body, postconditions.
2139                 </para>
2140               </entry>
2141               <entry>
2142                 <para>
2143                   Preconditions, postconditions, body.
2144                 </para>
2145               </entry>
2146             </row>
2147             <row>
2148               <entry>
2149                 <para>
2150                   <emphasis>Disable assertion checking within assertions checking
2151                   (to avoid infinite recursion when checking contracts)</emphasis>
2152                 </para>
2153               </entry>
2154               <entry>
2155                 <para>
2156                   Yes, but use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999685184">BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</link></computeroutput>
2157                   to disable no assertion while checking preconditions (see also
2158                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999679376">BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION</link></computeroutput>).
2159                   <footnote id="boost_contract.contract_programming_overview.feature_summary.f1">
2160                   <para>
2161                     <emphasis role="bold">Rationale:</emphasis> Technically, it can
2162                     be shown that an invalid argument can reach the function body
2163                     when assertion checking is disabled while checking preconditions
2164                     (that is why <link linkend="N1962_anchor">[N1962]</link> does
2165                     not disable any assertion while checking preconditions, see
2166                     <ulink url="http://lists.boost.org/Archives/boost/2010/04/164862.php">Re:
2167                     [boost] [contract] diff n1962</ulink>). However, this can only
2168                     happen while checking contracts when an invalid argument passed
2169                     to the body, which should results in the body either throwing
2170                     an exception or returning an incorrect result, will in turn fail
2171                     the contract assertion being checked by the caller of the body
2172                     and invoke the related contract failure handler as desired in
2173                     the first place. Furthermore, not disabling assertions while
2174                     checking preconditions (like <link linkend="N1962_anchor">[N1962]</link>
2175                     does) makes it possible to have infinite recursion while checking
2176                     preconditions. Therefore, this library by default disables assertion
2177                     checking also while checking preconditions (like Eiffel does),
2178                     but it also provides the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999685184">BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</link></computeroutput>
2179                     configuration macro so users can change this behaviour to match
2180                     <link linkend="N1962_anchor">[N1962]</link> if needed.
2181                   </para>
2182                   </footnote> (In multi-threaded programs this introduces a global
2183                   lock, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999743888">BOOST_CONTRACT_DISABLE_THREADS</link></computeroutput>.)
2184                 </para>
2185               </entry>
2186               <entry>
2187                 <para>
2188                   Yes for class invariants and postconditions, but preconditions
2189                   disable no assertion.
2190                 </para>
2191               </entry>
2192               <entry>
2193                 <para>
2194                   No.
2195                 </para>
2196               </entry>
2197               <entry>
2198                 <para>
2199                   Yes.
2200                 </para>
2201               </entry>
2202               <entry>
2203                 <para>
2204                   No.
2205                 </para>
2206               </entry>
2207             </row>
2208             <row>
2209               <entry>
2210                 <para>
2211                   <emphasis>Nested member function calls</emphasis>
2212                 </para>
2213               </entry>
2214               <entry>
2215                 <para>
2216                   Disable nothing. <footnote id="boost_contract.contract_programming_overview.feature_summary.f2">
2217                   <para>
2218                     <emphasis role="bold">Rationale:</emphasis> Older versions of
2219                     this library defined a data member in the user class that was
2220                     automatically used to disable checking of class invariants within
2221                     nested member function calls (similarly to Eiffel). This feature
2222                     was required by older revisions of <link linkend="N1962_anchor">[N1962]</link>
2223                     but it is no longer required by <link linkend="N1962_anchor">[N1962]</link>
2224                     (because it seems to be motivated purely by optimization reasons
2225                     while similar performances can be achieved by disabling invariants
2226                     for release builds). Furthermore, in multi-threaded programs
2227                     this feature would introduce a lock that synchronizes all member
2228                     functions calls for a given object. Therefore, this feature was
2229                     removed in the current revision of this library.
2230                   </para>
2231                   </footnote>
2232                 </para>
2233               </entry>
2234               <entry>
2235                 <para>
2236                   Disable nothing.
2237                 </para>
2238               </entry>
2239               <entry>
2240                 <para>
2241                   Disable nothing.
2242                 </para>
2243               </entry>
2244               <entry>
2245                 <para>
2246                   Disable all contract assertions.
2247                 </para>
2248               </entry>
2249               <entry>
2250                 <para>
2251                   Disable nothing.
2252                 </para>
2253               </entry>
2254             </row>
2255             <row>
2256               <entry>
2257                 <para>
2258                   <emphasis>Disable contract checking</emphasis>
2259                 </para>
2260               </entry>
2261               <entry>
2262                 <para>
2263                   Yes, contract checking can be skipped at run-time by defining combinations
2264                   of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput>,
2265                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>,
2266                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput>,
2267                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999637264">BOOST_CONTRACT_NO_ENTRY_INVARIANTS</link></computeroutput>,
2268                   and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link></computeroutput>
2269                   macros (completely removing contract code from compiled object
2270                   code is also possible but requires using macros as shown in <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">Disable
2271                   Contract Compilation</link>).
2272                 </para>
2273               </entry>
2274               <entry>
2275                 <para>
2276                   Yes (contract code also removed from compiled object code, but
2277                   details are compiler-implementation specific).
2278                 </para>
2279               </entry>
2280               <entry>
2281                 <para>
2282                   Yes (contract code also removed from compiled object code, but
2283                   details are compiler-implementation specific).
2284                 </para>
2285               </entry>
2286               <entry>
2287                 <para>
2288                   Yes, but only predefined combinations of preconditions, postconditions,
2289                   and class invariants can be disabled (contract code also removed
2290                   from compiled object code).
2291                 </para>
2292               </entry>
2293               <entry>
2294                 <para>
2295                   Yes.
2296                 </para>
2297               </entry>
2298             </row>
2299             <row>
2300               <entry>
2301                 <para>
2302                   <emphasis>Assertion levels</emphasis>
2303                 </para>
2304               </entry>
2305               <entry>
2306                 <para>
2307                   Yes, predefined default, audit, and axiom, in addition programmers
2308                   can also define their own levels.
2309                 </para>
2310               </entry>
2311               <entry>
2312                 <para>
2313                   No (but a previous revision of this proposal considered adding
2314                   assertion levels under the name of "assertion ordering").
2315                 </para>
2316               </entry>
2317               <entry>
2318                 <para>
2319                   Yes, predefined default, audit, and axiom.
2320                 </para>
2321               </entry>
2322               <entry>
2323                 <para>
2324                   No.
2325                 </para>
2326               </entry>
2327               <entry>
2328                 <para>
2329                   No.
2330                 </para>
2331               </entry>
2332             </row>
2333           </tbody>
2334         </tgroup>
2335       </informaltable>
2336       <para>
2337         The authors of this library consulted the following references that implement
2338         contract programming for C++ (but usually for only a limited set of features,
2339         or using preprocessing tools other than the C++ preprocessor and external
2340         to the language itself) and for other languages (see <link linkend="boost_contract.bibliography">Bibliography</link>
2341         for a complete list of all references consulted during the design and development
2342         of this library):
2343       </para>
2344       <informaltable frame="all">
2345         <tgroup cols="3">
2346           <thead>
2347             <row>
2348               <entry>
2349                 <para>
2350                   Reference
2351                 </para>
2352               </entry>
2353               <entry>
2354                 <para>
2355                   Language
2356                 </para>
2357               </entry>
2358               <entry>
2359                 <para>
2360                   Notes
2361                 </para>
2362               </entry>
2363             </row>
2364           </thead>
2365           <tbody>
2366             <row>
2367               <entry>
2368                 <para>
2369                   <link linkend="Bright04b_anchor">[Bright04b]</link>
2370                 </para>
2371               </entry>
2372               <entry>
2373                 <para>
2374                   Digital Mars C++
2375                 </para>
2376               </entry>
2377               <entry>
2378                 <para>
2379                   The Digital Mars C++ compiler extends C++ adding contract programming
2380                   language support (among many other features).
2381                 </para>
2382               </entry>
2383             </row>
2384             <row>
2385               <entry>
2386                 <para>
2387                   <link linkend="Maley99_anchor">[Maley99]</link>
2388                 </para>
2389               </entry>
2390               <entry>
2391                 <para>
2392                   C++
2393                 </para>
2394               </entry>
2395               <entry>
2396                 <para>
2397                   This supports contract programming including subcontracting but
2398                   with limitations (e.g., programmers need to manually build an inheritance
2399                   tree using artificial template parameters), it does not use macros
2400                   but programmers are required to write by hand a significant amount
2401                   of boiler-plate code. (The authors have found this work very inspiring
2402                   when developing initial revisions of this library especially for
2403                   its attempt to support subcontracting.)
2404                 </para>
2405               </entry>
2406             </row>
2407             <row>
2408               <entry>
2409                 <para>
2410                   <link linkend="Lindrud04_anchor">[Lindrud04]</link>
2411                 </para>
2412               </entry>
2413               <entry>
2414                 <para>
2415                   C++
2416                 </para>
2417               </entry>
2418               <entry>
2419                 <para>
2420                   This supports class invariants and old values but it does not support
2421                   subcontracting (contracts are specified within definitions instead
2422                   of declarations and assertions are not constant-correct).
2423                 </para>
2424               </entry>
2425             </row>
2426             <row>
2427               <entry>
2428                 <para>
2429                   <link linkend="Tandin04_anchor">[Tandin04]</link>
2430                 </para>
2431               </entry>
2432               <entry>
2433                 <para>
2434                   C++
2435                 </para>
2436               </entry>
2437               <entry>
2438                 <para>
2439                   Interestingly, these contract macros automatically generate Doxygen
2440                   documentation <footnote id="boost_contract.contract_programming_overview.feature_summary.f3">
2441                   <para>
2442                     <emphasis role="bold">Rationale:</emphasis> Older versions of
2443                     this library also automatically generated Doxygen documentation
2444                     from contract definition macros. This functionality was abandoned
2445                     for a number of reasons: This library no longer uses macros to
2446                     program contracts; even before that, the implementation of this
2447                     library macros became too complex and the Doxygen preprocessor
2448                     was no longer able to expand them; the Doxygen documentation
2449                     was just a repeat of the contract code (so programmers could
2450                     directly look at contracts in the source code); Doxygen might
2451                     not necessarily be the documentation tool used by all C++ programmers.
2452                   </para>
2453                   </footnote> but old values, class invariants, and subcontracting
2454                   are not supported (plus contracts are specified within definitions
2455                   instead of declarations and assertions are not constant-correct).
2456                 </para>
2457               </entry>
2458             </row>
2459             <row>
2460               <entry>
2461                 <para>
2462                   <link linkend="Nana_anchor">[Nana]</link>
2463                 </para>
2464               </entry>
2465               <entry>
2466                 <para>
2467                   GCC C++
2468                 </para>
2469               </entry>
2470               <entry>
2471                 <para>
2472                   This uses macros but it only works on GCC (and maybe Clang, but
2473                   it does not work on MSVC, etc.). It does not support subcontracting.
2474                   It requires extra care to program postconditions for functions
2475                   with multiple return statements. It seems that it might not check
2476                   class invariants when functions throw exceptions (unless the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">END</phrase></computeroutput> macro does that...). (In
2477                   addition, it provides tools for logging and integration with GDB.)
2478                 </para>
2479               </entry>
2480             </row>
2481             <row>
2482               <entry>
2483                 <para>
2484                   <link linkend="C2_anchor">[C2]</link>
2485                 </para>
2486               </entry>
2487               <entry>
2488                 <para>
2489                   C++
2490                 </para>
2491               </entry>
2492               <entry>
2493                 <para>
2494                   This uses an external preprocessing tool (the authors could no
2495                   longer find this project's code to evaluate it).
2496                 </para>
2497               </entry>
2498             </row>
2499             <row>
2500               <entry>
2501                 <para>
2502                   <link linkend="iContract_anchor">[iContract]</link>
2503                 </para>
2504               </entry>
2505               <entry>
2506                 <para>
2507                   Java
2508                 </para>
2509               </entry>
2510               <entry>
2511                 <para>
2512                   This uses an external preprocessing tool.
2513                 </para>
2514               </entry>
2515             </row>
2516             <row>
2517               <entry>
2518                 <para>
2519                   <link linkend="Jcontract_anchor">[Jcontract]</link>
2520                 </para>
2521               </entry>
2522               <entry>
2523                 <para>
2524                   Java
2525                 </para>
2526               </entry>
2527               <entry>
2528                 <para>
2529                   This uses an external preprocessing tool.
2530                 </para>
2531               </entry>
2532             </row>
2533             <row>
2534               <entry>
2535                 <para>
2536                   <link linkend="CodeContracts_anchor">[CodeContracts]</link>
2537                 </para>
2538               </entry>
2539               <entry>
2540                 <para>
2541                   .NET
2542                 </para>
2543               </entry>
2544               <entry>
2545                 <para>
2546                   Microsoft contract programming for .NET programming languages.
2547                 </para>
2548               </entry>
2549             </row>
2550             <row>
2551               <entry>
2552                 <para>
2553                   <link linkend="SpecSharp_anchor">[SpecSharp]</link>
2554                 </para>
2555               </entry>
2556               <entry>
2557                 <para>
2558                   C#
2559                 </para>
2560               </entry>
2561               <entry>
2562                 <para>
2563                   This is a C# extension with contract programming language support.
2564                 </para>
2565               </entry>
2566             </row>
2567             <row>
2568               <entry>
2569                 <para>
2570                   <link linkend="Chrome_anchor">[Chrome]</link>
2571                 </para>
2572               </entry>
2573               <entry>
2574                 <para>
2575                   Object Pascal
2576                 </para>
2577               </entry>
2578               <entry>
2579                 <para>
2580                   This is the .NET version of Object Pascal and it has language support
2581                   for contract programming.
2582                 </para>
2583               </entry>
2584             </row>
2585             <row>
2586               <entry>
2587                 <para>
2588                   <link linkend="SPARKAda_anchor">[SPARKAda]</link>
2589                 </para>
2590               </entry>
2591               <entry>
2592                 <para>
2593                   Ada
2594                 </para>
2595               </entry>
2596               <entry>
2597                 <para>
2598                   This is an Ada-like programming language with support for contract
2599                   programming.
2600                 </para>
2601               </entry>
2602             </row>
2603           </tbody>
2604         </tgroup>
2605       </informaltable>
2606       <para>
2607         To the best knowledge of the authors, this the only library that fully supports
2608         all contract programming features for C++ (without using preprocessing tools
2609         external to the language itself). In general:
2610       </para>
2611       <itemizedlist>
2612         <listitem>
2613           <simpara>
2614             Implementing preconditions and postconditions in C++ is not difficult
2615             (e.g., using some kind of RAII object).
2616           </simpara>
2617         </listitem>
2618         <listitem>
2619           <simpara>
2620             Implementing postcondition old values is also not too difficult (usually
2621             requiring programmers to copy old values into local variables), but it
2622             is already somewhat more difficult to ensure such copies are not performed
2623             when postconditions are disabled. <footnote id="boost_contract.contract_programming_overview.feature_summary.f4">
2624             <para>
2625               For example, the following pseudocode attempts to emulate old values
2626               in <link linkend="P0380_anchor">[P0380]</link>:
2627 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">scope_exit</phrase> <phrase role="special">{</phrase> <phrase role="comment">// RAII.</phrase>
2628     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">F</phrase><phrase role="special">&gt;</phrase>
2629     <phrase role="keyword">explicit</phrase> <phrase role="identifier">scope_exit</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">f_</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="special">{}</phrase>
2630     <phrase role="special">~</phrase><phrase role="identifier">scope_exit</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">f_</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase>
2631
2632     <phrase role="identifier">scope_exit</phrase><phrase role="special">(</phrase><phrase role="identifier">scope_exit</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase>
2633     <phrase role="identifier">scope_exit</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase><phrase role="identifier">scope_exit</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase>
2634 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
2635     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">()&gt;</phrase> <phrase role="identifier">f_</phrase><phrase role="special">;</phrase>
2636 <phrase role="special">};</phrase>
2637
2638 <phrase role="keyword">void</phrase> <phrase role="identifier">fswap</phrase><phrase role="special">(</phrase><phrase role="identifier">file</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="identifier">file</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">y</phrase><phrase role="special">)</phrase>
2639     <phrase role="special">[[</phrase><phrase role="identifier">expects</phrase><phrase role="special">:</phrase> <phrase role="identifier">x</phrase><phrase role="special">.</phrase><phrase role="identifier">closed</phrase><phrase role="special">()]]</phrase>
2640     <phrase role="special">[[</phrase><phrase role="identifier">expects</phrase><phrase role="special">:</phrase> <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">closed</phrase><phrase role="special">()]]</phrase>
2641     <phrase role="comment">// Cannot use [[ensures]] for postconditions so to emulate old values.</phrase>
2642 <phrase role="special">{</phrase>
2643     <phrase role="identifier">file</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="comment">// Emulate old values with local copies (not disabled).</phrase>
2644     <phrase role="identifier">file</phrase> <phrase role="identifier">old_y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">y</phrase><phrase role="special">;</phrase>
2645     <phrase role="identifier">scope_exit</phrase> <phrase role="identifier">ensures</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check after local objects destroyed.</phrase>
2646         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uncaught_exceptions</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check only if no throw.</phrase>
2647             <phrase role="special">[[</phrase><phrase role="identifier">assert</phrase><phrase role="special">:</phrase> <phrase role="identifier">x</phrase><phrase role="special">.</phrase><phrase role="identifier">closed</phrase><phrase role="special">()]]</phrase>
2648             <phrase role="special">[[</phrase><phrase role="identifier">assert</phrase><phrase role="special">:</phrase> <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">closed</phrase><phrase role="special">()]]</phrase>
2649             <phrase role="special">[[</phrase><phrase role="identifier">assert</phrase><phrase role="special">:</phrase> <phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="identifier">old_y</phrase><phrase role="special">]]</phrase>
2650             <phrase role="special">[[</phrase><phrase role="identifier">assert</phrase><phrase role="special">:</phrase> <phrase role="identifier">y</phrase> <phrase role="special">==</phrase> <phrase role="identifier">old_x</phrase><phrase role="special">]]</phrase>
2651         <phrase role="special">}</phrase>
2652     <phrase role="special">});</phrase>
2653
2654     <phrase role="identifier">x</phrase><phrase role="special">.</phrase><phrase role="identifier">open</phrase><phrase role="special">();</phrase>
2655     <phrase role="identifier">scope_exit</phrase> <phrase role="identifier">close_x</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="identifier">x</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="special">});</phrase>
2656     <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">open</phrase><phrase role="special">();</phrase>
2657     <phrase role="identifier">scope_exit</phrase> <phrase role="identifier">close_y</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="special">});</phrase>
2658     <phrase role="identifier">file</phrase> <phrase role="identifier">z</phrase> <phrase role="special">=</phrase> <phrase role="identifier">file</phrase><phrase role="special">::</phrase><phrase role="identifier">temp</phrase><phrase role="special">();</phrase>
2659     <phrase role="identifier">z</phrase><phrase role="special">.</phrase><phrase role="identifier">open</phrase><phrase role="special">;</phrase>
2660     <phrase role="identifier">scope_exit</phrase> <phrase role="identifier">close_z</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="identifier">z</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="special">});</phrase>
2661
2662     <phrase role="identifier">x</phrase><phrase role="special">.</phrase><phrase role="identifier">mv</phrase><phrase role="special">(</phrase><phrase role="identifier">z</phrase><phrase role="special">);</phrase>
2663     <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">mv</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
2664     <phrase role="identifier">z</phrase><phrase role="special">.</phrase><phrase role="identifier">mv</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase><phrase role="special">);</phrase>
2665 <phrase role="special">}</phrase>
2666 </programlisting>
2667               This requires boiler-plate code to make sure postconditions are correctly
2668               checked only if the function did not throw an exception and in a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">scope_exit</phrase></computeroutput> RAII object after all
2669               other local objects have been destroyed (because some of these destructors
2670               contribute to establishing the postconditions). Still, it never disables
2671               old value copies (not even if postconditions are disabled in release
2672               builds, this would require adding even more boiler-plate code using
2673               <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifdef</phrase></computeroutput>, etc.).
2674             </para>
2675             </footnote>
2676           </simpara>
2677         </listitem>
2678         <listitem>
2679           <simpara>
2680             Implementing class invariants is more involved (especially if done automatically,
2681             without requiring programmers to manually invoke extra functions to check
2682             the invariants). <footnote id="boost_contract.contract_programming_overview.feature_summary.f5">
2683             <para>
2684               For example, the following pseudocode attempts to emulation of class
2685               invariants in <link linkend="P0380_anchor">[P0380]</link>:
2686 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
2687 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
2688     <phrase role="keyword">bool</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>        <phrase role="comment">// Check invariants at...</phrase>
2689         <phrase role="special">[[</phrase><phrase role="identifier">assert</phrase><phrase role="special">:</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)]]</phrase>
2690         <phrase role="special">[[</phrase><phrase role="identifier">assert</phrase><phrase role="special">:</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()]]</phrase>
2691         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
2692     <phrase role="special">}</phrase>
2693
2694 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
2695     <phrase role="identifier">vector</phrase><phrase role="special">()</phrase>
2696         <phrase role="special">[[</phrase><phrase role="identifier">ensures</phrase><phrase role="special">:</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()]]</phrase>    <phrase role="comment">// ...constructor exit (only if no throw).</phrase>
2697     <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase>
2698
2699     <phrase role="special">~</phrase><phrase role="identifier">vector</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase>
2700         <phrase role="special">[[</phrase><phrase role="identifier">expects</phrase><phrase role="special">:</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()]]</phrase>    <phrase role="comment">// ...destructor entry.</phrase>
2701     <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase>
2702
2703     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
2704         <phrase role="special">[[</phrase><phrase role="identifier">expects</phrase><phrase role="special">:</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()]]</phrase>    <phrase role="comment">// ...public function entry.</phrase>
2705         <phrase role="special">[[</phrase><phrase role="identifier">ensures</phrase><phrase role="special">:</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()]]</phrase>    <phrase role="comment">// ...public function exit (if no throw).</phrase>
2706     <phrase role="keyword">try</phrase> <phrase role="special">{</phrase>
2707         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
2708     <phrase role="special">}</phrase> <phrase role="keyword">catch</phrase><phrase role="special">(...)</phrase> <phrase role="special">{</phrase>
2709         <phrase role="identifier">invariant</phrase><phrase role="special">();</phrase>                <phrase role="comment">// ...public function exit (if throw).</phrase>
2710         <phrase role="keyword">throw</phrase><phrase role="special">;</phrase>
2711     <phrase role="special">}</phrase>
2712
2713     <phrase role="special">...</phrase>
2714 <phrase role="special">};</phrase>
2715 </programlisting>
2716               This requires boiler-plate code to manually invoke the function that
2717               checks the invariants (note that invariants are checked at public function
2718               exit regardless of exceptions being thrown while postconditions are
2719               not). In case the destructor can throw (e.g., it is declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">)</phrase></computeroutput>),
2720               the destructor also requires a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">try</phrase><phrase role="special">-</phrase><phrase role="keyword">catch</phrase></computeroutput>
2721               statement similar to the one programmed for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">push_back</phrase></computeroutput>
2722               to check class invariants at destructor exit when it throws exceptions.
2723               Still, an outstanding issue remains to avoid infinite recursion if
2724               also <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">empty</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">size</phrase></computeroutput> are public functions programmed
2725               to check class invariants (because <link linkend="P0380_anchor">[P0380]</link>
2726               does not automatically disable assertions while checking other assertions).
2727             </para>
2728             </footnote> In addition, all references reviewed by the authors seem
2729             to not consider static and volatile functions not supporting static and
2730             volatile invariants respectively.
2731           </simpara>
2732         </listitem>
2733         <listitem>
2734           <simpara>
2735             Implementing subcontracting involves a significant amount of complexity
2736             and it seems to not be properly supported by any C++ library other than
2737             this one (especially when handling multiple inheritance, correctly copying
2738             postcondition old values across all overridden contracts deep in the
2739             inheritance tree, and correctly reporting the return value to the postconditions
2740             of overridden virtual functions in base classes). <footnote id="boost_contract.contract_programming_overview.feature_summary.f6">
2741             <para>
2742               For example, it is not really possible to sketch pseudocode based on
2743               <link linkend="P0380_anchor">[P0380]</link> that emulates subcontracting
2744               in the general case.
2745             </para>
2746             </footnote>
2747           </simpara>
2748         </listitem>
2749       </itemizedlist>
2750     </section>
2751   </section>
2752   <section id="boost_contract.tutorial">
2753     <title><link linkend="boost_contract.tutorial">Tutorial</link></title>
2754     <para>
2755       This section is a guide to basic usage of this library.
2756     </para>
2757     <section id="boost_contract.tutorial.non_member_functions">
2758       <title><link linkend="boost_contract.tutorial.non_member_functions">Non-Member
2759       Functions</link></title>
2760       <para>
2761         Contracts for non-member functions are programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>.
2762         For example (see <ulink url="../../example/features/non_member.cpp"><literal moreinfo="none">non_member.cpp</literal></ulink>):
2763       </para>
2764       <para>
2765 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
2766
2767 <phrase role="comment">// Contract for a non-member function.</phrase>
2768 <phrase role="keyword">int</phrase> <phrase role="identifier">inc</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
2769     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
2770     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
2771     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
2772         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
2773             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">());</phrase>
2774         <phrase role="special">})</phrase>
2775         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
2776             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
2777             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase><phrase role="special">);</phrase>
2778         <phrase role="special">})</phrase>
2779         <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
2780             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase><phrase role="special">);</phrase>
2781         <phrase role="special">})</phrase>
2782     <phrase role="special">;</phrase>
2783
2784     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">++;</phrase> <phrase role="comment">// Function body.</phrase>
2785 <phrase role="special">}</phrase>
2786 </programlisting>
2787       </para>
2788       <para>
2789         All necessary header files of this library are included by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase></computeroutput>.
2790         Alternatively, programmers can selectively include only the header files
2791         they actually need among <literal moreinfo="none">boost/contract/*.hpp</literal> (see <link linkend="boost_contract.getting_started">Getting Started</link>).
2792       </para>
2793       <para>
2794         It is possible to specify preconditions, postconditions, and exception guarantees
2795         for non-member functions (see <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>,
2796         <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>,
2797         and <link linkend="boost_contract.tutorial.exception_guarantees">Exception
2798         Guarantees</link>).
2799       </para>
2800       <para>
2801         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
2802         function returns an RAII object that must always be assigned to a local variable
2803         of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
2804         (otherwise this library will generate a run-time error, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>).
2805         <footnote id="boost_contract.tutorial.non_member_functions.f0">
2806         <para>
2807           The name of this local variable is arbitrary, but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">c</phrase></computeroutput>
2808           is often used in this documentation for <quote>c</quote>heck or <quote>c</quote>aminiti
2809           <literal moreinfo="none">;-)</literal> .
2810         </para>
2811         </footnote> Furthermore, C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput>
2812         declarations cannot be used here and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
2813         type must be explicitly specified (otherwise this library will generate a
2814         compile-time error prior C++17 and a run-time error post C++17). <footnote id="boost_contract.tutorial.non_member_functions.f1">
2815         <para>
2816           <emphasis role="bold">Rationale:</emphasis> C++17 guaranteed copy elision
2817           on function return value voids the trick this library uses to force a compile-time
2818           error when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> is incorrectly
2819           used instead of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>.
2820           The library still generates a run-time error in this case (also on C++17).
2821           In any case, after reading this documentation it should be evident to programmers
2822           that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> should not be used
2823           in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
2824           declarations so this misuse of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput>
2825           should not be an issue in practice.
2826         </para>
2827         </footnote> The function body is programmed right after the declaration of
2828         this RAII object.
2829       </para>
2830       <note>
2831         <para>
2832           In some cases, it might be necessary to program some code before the contract.
2833           For example for acquiring resources that will be used while checking the
2834           contract like old values, but also to lock mutexes (or other synchronization
2835           mechanisms) in multi-threaded programs.
2836         </para>
2837       </note>
2838       <para>
2839         At construction, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
2840         RAII object for non-member functions does the following (enclosing function
2841         entry):
2842       </para>
2843       <orderedlist inheritnum="ignore" continuation="restarts">
2844         <listitem>
2845           <simpara>
2846             Check preconditions, by calling the nullary functor <literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
2847           </simpara>
2848         </listitem>
2849       </orderedlist>
2850       <para>
2851         At destruction instead (enclosing function exit):
2852       </para>
2853       <orderedlist inheritnum="ignore" continuation="restarts">
2854         <listitem>
2855           <simpara>
2856             If the function body did not throw an exception:
2857             <orderedlist inheritnum="ignore" continuation="restarts">
2858               <listitem>
2859                 <simpara>
2860                   Check postconditions, by calling the nullary functor <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
2861                 </simpara>
2862               </listitem>
2863             </orderedlist>
2864           </simpara>
2865         </listitem>
2866         <listitem>
2867           <simpara>
2868             Else:
2869             <orderedlist inheritnum="ignore" continuation="restarts">
2870               <listitem>
2871                 <simpara>
2872                   Check exception guarantees, by calling the nullary functor <literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
2873                 </simpara>
2874               </listitem>
2875             </orderedlist>
2876           </simpara>
2877         </listitem>
2878       </orderedlist>
2879       <para>
2880         This ensures that non-member function contracts are correctly checked at
2881         run-time (see <link linkend="boost_contract.contract_programming_overview.function_calls">Function
2882         Calls</link>). (Also note that functions will correctly check their contracts
2883         even when they are called via function pointers, function objects, etc.)
2884       </para>
2885       <note>
2886         <para>
2887           A non-member function can avoid calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
2888           for efficiency but only when it has no preconditions, no postconditions,
2889           and no exception guarantees.
2890         </para>
2891       </note>
2892     </section>
2893     <section id="boost_contract.tutorial.preconditions">
2894       <title><link linkend="boost_contract.tutorial.preconditions">Preconditions</link></title>
2895       <para>
2896         When preconditions are specified, they are programmed using a functor <literal moreinfo="none"><emphasis>r</emphasis></literal>
2897         passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> that can be called with no parameters as
2898         in <literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>.
2899         Contracts that do not have preconditions simply do not call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>. Preconditions must appear before postconditions
2900         and exception guarantees when these are all present (see <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>
2901         and <link linkend="boost_contract.tutorial.exception_guarantees">Exception
2902         Guarantees</link>).
2903       </para>
2904       <para>
2905         C++11 lambda functions are convenient to program preconditions, but any other
2906         nullary functor can be used (see <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
2907         Lambda Functions</link>). <footnote id="boost_contract.tutorial.preconditions.f0">
2908         <para>
2909           Lambda functions with no parameters can be programmed in C++11 as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[...]</phrase> <phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase></computeroutput>
2910           but also equivalently as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[...]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase></computeroutput>.
2911           This second from is often used in this documentation omitting the empty
2912           parameter list <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> for brevity.
2913         </para>
2914         </footnote> For example, for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
2915         (similarly for public functions, instead destructors do not have preconditions
2916         and constructors use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>,
2917         see <link linkend="boost_contract.tutorial.public_functions">Public Functions</link>,
2918         <link linkend="boost_contract.tutorial.destructors">Destructors</link>, and
2919         <link linkend="boost_contract.tutorial.constructors">Constructors</link>):
2920       </para>
2921 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(...)</phrase> <phrase role="special">{</phrase>
2922     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>  <phrase role="comment">// Same for all other contracts.</phrase>
2923         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>                                 <phrase role="comment">// Capture by reference or value...</phrase>
2924             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>                     <phrase role="comment">// ...and should not modify captures.</phrase>
2925             <phrase role="special">...</phrase>
2926         <phrase role="special">})</phrase>
2927         <phrase role="special">...</phrase>
2928     <phrase role="special">;</phrase>
2929
2930     <phrase role="special">...</phrase>
2931 <phrase role="special">}</phrase>
2932 </programlisting>
2933       <para>
2934         The precondition functor should capture all the variables that it needs to
2935         assert the preconditions. These variables can be captured by value when the
2936         overhead of copying such variables is acceptable. <footnote id="boost_contract.tutorial.preconditions.f1">
2937         <para>
2938           In this documentation preconditions often capture variables by reference
2939           to avoid extra copies.
2940         </para>
2941         </footnote> In any case, programmers should not write precondition assertions
2942         that modify the value of the captured variables, even when those are captured
2943         by reference (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
2944       </para>
2945       <para>
2946         Any code can be programmed in the precondition functor, but it is recommended
2947         to keep this code simple using mainly assertions and if-statements (to avoid
2948         programming complex preconditions that might be buggy and also slow to check
2949         at run-time). It is also recommended to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
2950         to program precondition assertions because that enables this library to print
2951         informative error messages when the asserted conditions are evaluated to
2952         be false (note that this is not a variadic macro, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
2953         Macros</link>):
2954       </para>
2955 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">)</phrase>
2956 <phrase role="comment">// Or, if `boolean-condition` contains commas `,` not already within parenthesis `()`...</phrase>
2957 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">))</phrase> <phrase role="comment">// ...use extra parenthesis (not a variadic macro).</phrase>
2958 </programlisting>
2959       <para>
2960         This library will automatically call the failure handler <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput>
2961         if any of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
2962         conditions are false or, more in general, if calling the functor specified
2963         via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput> throws any exception. By default, this
2964         failure handler prints an error message to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput>
2965         and terminates the program calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>
2966         (see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
2967         on Failures</link> to change the failure handler to throw exceptions, exit
2968         the program with an error code, etc.).
2969       </para>
2970       <note>
2971         <para>
2972           Contracts are most useful when their assertions only use public members
2973           that are accessible to the caller so the caller can properly check and
2974           use the contract. In particular, preconditions of a public function or
2975           constructor that use non-public members are essentially incorrect because
2976           they cannot be fully checked by the caller (in fact, Eiffel generates a
2977           compile-time error in this case). However, this library does not enforce
2978           such a constraint and it leaves it up to programmers to only use public
2979           members when programming contracts, especially when asserting preconditions
2980           (see <link linkend="boost_contract.contract_programming_overview.specifications_vs__implementation">Specifications
2981           vs. Implementation</link>).
2982         </para>
2983       </note>
2984     </section>
2985     <section id="boost_contract.tutorial.postconditions">
2986       <title><link linkend="boost_contract.tutorial.postconditions">Postconditions</link></title>
2987       <para>
2988         When postconditions are specified, they are programmed using a functor <literal moreinfo="none"><emphasis>s</emphasis></literal>
2989         passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> that can be called with no parameters as
2990         in <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>.
2991         Contracts that do not have postconditions simply do not call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase></computeroutput>. Postconditions must appear after preconditions
2992         but before exception guarantees when these are all present (see <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>
2993         and <link linkend="boost_contract.tutorial.exception_guarantees">Exception
2994         Guarantees</link>).
2995       </para>
2996       <para>
2997         C++11 lambda functions are convenient to program postconditions, but any
2998         other nullary functor can be used (see <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
2999         Lambda Functions</link>). For example, for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
3000         (similarly for all other contracts):
3001       </para>
3002 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(...)</phrase> <phrase role="special">{</phrase>
3003     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>  <phrase role="comment">// Same for all other contracts.</phrase>
3004         <phrase role="special">...</phrase>
3005         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>                                <phrase role="comment">// Capture by reference...</phrase>
3006             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>                     <phrase role="comment">// ...but should not modify captures.</phrase>
3007             <phrase role="special">...</phrase>
3008         <phrase role="special">})</phrase>
3009         <phrase role="special">...</phrase>
3010     <phrase role="special">;</phrase>
3011
3012     <phrase role="special">...</phrase>
3013 <phrase role="special">}</phrase>
3014 </programlisting>
3015       <para>
3016         The postcondition functor should capture all the variables that it needs
3017         to assert the postconditions. In general, these variables should be captured
3018         by reference and not by value (because postconditions need to access the
3019         value that these variables will have at function exit, and not the value
3020         these variables had when the postcondition functor was first declared). Postconditions
3021         can also capture return and old values (see <link linkend="boost_contract.tutorial.return_values">Return
3022         Values</link> and <link linkend="boost_contract.tutorial.old_values">Old
3023         Values</link>). In any case, programmers should not write postcondition assertions
3024         that modify the value of the captured variables, even when those are captured
3025         by reference (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
3026       </para>
3027       <para>
3028         Any code can be programmed in the postcondition functor, but it is recommended
3029         to keep this code simple using mainly assertions and if-statements (to avoid
3030         programming complex postconditions that might be buggy and slow to check
3031         at run-time). It is also recommended to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
3032         to program postcondition assertions because that enables this library to
3033         print informative error messages when the asserted conditions are evaluated
3034         to be false (note that this is not a variadic macro, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
3035         Macros</link>):
3036       </para>
3037 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">)</phrase>
3038 <phrase role="comment">// Or, if `boolean-condition` has commas `,` not already within parenthesis `()`...</phrase>
3039 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">))</phrase> <phrase role="comment">// ...use extra parenthesis (not a variadic macro).</phrase>
3040 </programlisting>
3041       <para>
3042         This library will automatically call the failure handler <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.postcondition_failure">boost::contract::postcondition_failure</link></computeroutput>
3043         if any of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
3044         conditions are false or, more in general, if calling the functor specified
3045         via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase></computeroutput> throws any exception. By default, this
3046         failure handler prints an error message to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput>
3047         and terminates the program calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>
3048         (see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
3049         on Failures</link> to change the failure handler to throw exceptions, exit
3050         the program with an error code, etc.).
3051       </para>
3052       <para>
3053         For non-void virtual public functions and non-void public function overrides,
3054         the functor <literal moreinfo="none"><emphasis>s</emphasis></literal> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> is not a nullary functor, instead it is
3055         a unary functor taking a variable holding the return value as its one parameter
3056         <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>result</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> (this is to properly support subcontracting,
3057         see <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
3058         Public Functions</link> and <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
3059         Function Overrides</link>).
3060       </para>
3061     </section>
3062     <section id="boost_contract.tutorial.return_values">
3063       <title><link linkend="boost_contract.tutorial.return_values">Return Values</link></title>
3064       <para>
3065         In non-void functions, postconditions might need to access the function return
3066         value to program assertions. In these cases, programmers are responsible
3067         to declare a local variable before the contract and to assign it to the return
3068         value at function exit (when the function does not throw an exception).
3069         <footnote id="boost_contract.tutorial.return_values.f0">
3070         <para>
3071           The name of the local variable that holds the return value is arbitrary,
3072           but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> is often used
3073           in this documentation.
3074         </para>
3075         </footnote> For example, for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
3076         (similarly for all other contracts):
3077       </para>
3078 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">return_type</phrase> <phrase role="identifier">f</phrase><phrase role="special">(...)</phrase> <phrase role="special">{</phrase>
3079     <phrase role="identifier">return_type</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>                                     <phrase role="comment">// Must be later assigned to return value.</phrase>
3080     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>  <phrase role="comment">// Same for all other contracts.</phrase>
3081         <phrase role="special">...</phrase>
3082         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>                                <phrase role="comment">// Also capture `result` reference...</phrase>
3083             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">...);</phrase>           <phrase role="comment">// ...but should not modify captures.</phrase>
3084             <phrase role="special">...</phrase>
3085         <phrase role="special">})</phrase>
3086         <phrase role="special">...</phrase>
3087     <phrase role="special">;</phrase>
3088
3089     <phrase role="special">...</phrase>
3090     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">...;</phrase>                                    <phrase role="comment">// Assign `result` at each return.</phrase>
3091 <phrase role="special">}</phrase>
3092 </programlisting>
3093       <para>
3094         At any point where the enclosing function returns, programmers are responsible
3095         to assign the result variable to the expression being returned. This can
3096         be done ensuring that <emphasis>all</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">return</phrase></computeroutput>
3097         statements in the function are of the form:
3098       </para>
3099 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><literal moreinfo="none"><emphasis>return-type</emphasis></literal> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
3100 <phrase role="special">...</phrase>
3101 <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <literal moreinfo="none"><emphasis>return-expression</emphasis></literal><phrase role="special">;</phrase>                           <phrase role="comment">// Assign `result` at each return.</phrase>
3102 </programlisting>
3103       <para>
3104         The functor used to program postconditions should capture the result variable
3105         by reference and not by value (because postconditions must access the value
3106         the result variable will have at function exit, and not the value the result
3107         variable had when the postcondition functor was first declared). The return
3108         value should never be used in preconditions, old value copies, or exception
3109         guarantees (because the return value is not yet correctly evaluated and set
3110         when preconditions are checked, old values are copied, or if the function
3111         throws an exception). In any case, programmers should not modify the result
3112         variable in the contract assertions (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
3113       </para>
3114       <para>
3115         It is also possible to declared the result variable using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput>
3116         when the function return type does not have a default constructor, or if
3117         the default constructor is too expensive or undesirable to execute when first
3118         declaring the result variable (see <link linkend="boost_contract.advanced.optional_return_values">Optional
3119         Return Values</link>).
3120       </para>
3121       <para>
3122         Non-void virtual public functions and non-void public function overrides
3123         must always declare and use a result variable even when postconditions do
3124         not directly use the function return value (this is to properly support subcontracting,
3125         see <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
3126         Public Functions</link> and <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
3127         Function Overrides</link>).
3128       </para>
3129     </section>
3130     <section id="boost_contract.tutorial.old_values">
3131       <title><link linkend="boost_contract.tutorial.old_values">Old Values</link></title>
3132       <para>
3133         When old values are used in postconditions or in exception guarantees, programmes
3134         are responsible to declare local variables before the contract and to assign
3135         them to related old value expressions using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>.
3136         <footnote id="boost_contract.tutorial.old_values.f0">
3137         <para>
3138           The name of a local variable that holds an old value is arbitrary, but
3139           <literal moreinfo="none">old_<emphasis>variable-name</emphasis></literal> is often used
3140           in this documentation.
3141         </para>
3142         </footnote> For example, for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
3143         (similarly for all other contracts):
3144       </para>
3145 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(...)</phrase> <phrase role="special">{</phrase>
3146     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">);</phrase>
3147     <phrase role="special">...</phrase>                                                     <phrase role="comment">// More old value declarations here if needed.</phrase>
3148     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>  <phrase role="comment">// Same for all other contracts.</phrase>
3149         <phrase role="special">...</phrase>                                                 <phrase role="comment">// Preconditions shall not use old values.</phrase>
3150         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>                                <phrase role="comment">// Capture by reference...</phrase>
3151             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_var</phrase> <phrase role="special">==</phrase> <phrase role="special">...);</phrase>         <phrase role="comment">// ...but should not modify captures.</phrase>
3152             <phrase role="special">...</phrase>
3153         <phrase role="special">})</phrase>
3154         <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>                                       <phrase role="comment">// Capture by reference...</phrase>
3155             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">-&gt;...);</phrase>            <phrase role="comment">// ...but should not modify captures.</phrase>
3156             <phrase role="special">...</phrase>
3157         <phrase role="special">})</phrase>
3158     <phrase role="special">;</phrase>
3159
3160     <phrase role="special">...</phrase>
3161 <phrase role="special">}</phrase>
3162 </programlisting>
3163       <para>
3164         Old values are handled by this library using the smart pointer class template
3165         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
3166         (so programmers do not directly manage allocation and deallocation of the
3167         pointed memory). <footnote id="boost_contract.tutorial.old_values.f1">
3168         <para>
3169           <emphasis role="bold">Rationale:</emphasis> Old values have to be optional
3170           values because they need to be left uninitialized when they are not used
3171           because both postconditions and exception guarantees are disabled (defining
3172           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>
3173           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>).
3174           That is to avoid old value copies when old values are not used, either
3175           a pointer or (better) a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput>
3176           could have been used to achieve that. In addition, old values need to be
3177           pointers internally allocated by this library so that they are never copied
3178           twice even when calling an overridden function multiple times to check
3179           preconditions, postconditions, etc. to implement subcontracting, so a smart
3180           pointer class template was used.
3181         </para>
3182         </footnote> The pointed old value type is automatically qualified as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> (so old values cannot be mistakenly
3183         changed by contract assertions, see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
3184         This library ensures that old value pointers are always not null by the time
3185         postconditions and exception guarantees are checked (so programmers can safely
3186         dereference and use these pointers in postcondition and exception guarantee
3187         assertions using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">operator</phrase><phrase role="special">*</phrase></computeroutput>
3188         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">operator</phrase><phrase role="special">-&gt;</phrase></computeroutput>
3189         without having to check if old value pointers are not null first).
3190       </para>
3191       <para>
3192         Old values should not be used in preconditions and this library does not
3193         guarantee that old value pointers are always not null when preconditions
3194         are checked. <footnote id="boost_contract.tutorial.old_values.f2">
3195         <para>
3196           For example, old value pointers might be null in preconditions when postconditions
3197           and exception guarantees are disabled defining <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>
3198           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>
3199           (but also when checking an overridden virtual public function contract
3200           via subcontracting, etc.).
3201         </para>
3202         </footnote> See <link linkend="boost_contract.advanced.old_values_copied_at_body">Old
3203         Values Copied at Body</link> for delaying the copy of old values until after
3204         class invariants (for constructors, destructors, and public functions) and
3205         preconditions are checked (when necessary, this allows to program old value
3206         expressions under the simplifying assumption that class invariant and precondition
3207         assertions are satisfied already).
3208       </para>
3209       <para>
3210         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput> is
3211         a variadic macro and it takes an extra parameter when used in virtual public
3212         functions or public function overrides (see <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
3213         Public Functions</link> and <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
3214         Function Overrides</link>). C++11 auto declarations can be used with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput> for brevity
3215         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase> </computeroutput><literal moreinfo="none">old_<emphasis>variable-name</emphasis>
3216         = BOOST_CONTRACT_OLDOF(<emphasis>expression</emphasis>)</literal> (but see
3217         also <link linkend="boost_contract.extras.old_value_requirements__templates_">Old
3218         Value Requirements</link>). See <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
3219         Macros</link> to program old values without using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
3220         (e.g., on compilers that do not support variadic macros).
3221       </para>
3222       <note>
3223         <para>
3224           This library ensures that old values are copied only once. This library
3225           also ensures that old values are never copied when postconditions and exception
3226           guarantees are disabled defining both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>
3227           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>
3228           (note that both these two macros must be defined, defining only <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>
3229           or only <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>
3230           is not sufficient to prevent the run-time cost of old value copies).
3231         </para>
3232       </note>
3233     </section>
3234     <section id="boost_contract.tutorial.exception_guarantees">
3235       <title><link linkend="boost_contract.tutorial.exception_guarantees">Exception
3236       Guarantees</link></title>
3237       <para>
3238         When exception guarantees are specified, they are programmed using a functor
3239         <literal moreinfo="none"><emphasis>e</emphasis></literal> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> that can be called with no parameters as
3240         in <literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>.
3241         Contracts that do not have exception guarantees simply do not call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(...)</phrase></computeroutput>. Exception guarantees must appear after
3242         both preconditions and postconditions when these are all present (see <link linkend="boost_contract.tutorial.preconditions">Preconditions</link> and
3243         <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>).
3244       </para>
3245       <para>
3246         C++11 lambda functions are convenient to program exception guarantees, but
3247         any other nullary functor can be used (see <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
3248         Lambda Functions</link>). For example, for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
3249         (similarly for all other contracts):
3250       </para>
3251 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(...)</phrase> <phrase role="special">{</phrase>
3252     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>  <phrase role="comment">// Same for all other contracts.</phrase>
3253         <phrase role="special">...</phrase>
3254         <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>                                       <phrase role="comment">// Capture by reference...</phrase>
3255             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>                     <phrase role="comment">// ...but should not modify captures.</phrase>
3256             <phrase role="special">...</phrase>
3257         <phrase role="special">})</phrase>
3258     <phrase role="special">;</phrase>
3259
3260     <phrase role="special">...</phrase>
3261 <phrase role="special">}</phrase>
3262 </programlisting>
3263       <para>
3264         The exception guarantee functor should capture all the variables that it
3265         needs to assert the exception guarantees. In general, these variables should
3266         be captured by reference and not by value (because exception guarantees need
3267         to access the value that these variables will have when the function throws,
3268         and not the value these variables had when the exception guarantee functor
3269         was first declared). Exception guarantees can also capture old values (see
3270         <link linkend="boost_contract.tutorial.old_values">Old Values</link>) but
3271         they should not access the function return value instead (because the return
3272         value is not be properly set when the function throws an exception). In any
3273         case, programmers should not write exception guarantee assertions that modify
3274         the value of the captured variables, even when those are captured by reference
3275         (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
3276       </para>
3277       <note>
3278         <para>
3279           In real production code, it might be difficult to program meaningful exception
3280           guarantees without resorting to expensive old value copies that will slow
3281           down execution. Therefore, the authors recognize that exception guarantees,
3282           even if supported by this library, might not be used often in practice
3283           (and they are not used in most of the examples listed in the rest of this
3284           documentation). In any case, these performance considerations are ultimately
3285           left to programmers and their specific application domains.
3286         </para>
3287       </note>
3288       <para>
3289         Any code can be programmed in the exception guarantee functor, but it is
3290         recommended to keep this code simple using mainly assertions and if-statements
3291         (to avoid programming complex exception guarantees that might be buggy and
3292         slow to check at run-time). It is also recommended to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
3293         to program exception guarantee assertions because that enables this library
3294         to print informative error messages when the asserted conditions are evaluated
3295         to be false (note that this is not a variadic macro, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
3296         Macros</link>):
3297       </para>
3298 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">)</phrase>
3299 <phrase role="comment">// Or, if `boolean-condition` has commas `,` not already within parenthesis `()`...</phrase>
3300 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">))</phrase> <phrase role="comment">// ...use extra parenthesis (not a variadic macro).</phrase>
3301 </programlisting>
3302       <para>
3303         This library will automatically call the failure handler <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput>
3304         if any of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
3305         conditions are false or, more in general, if calling the functor specified
3306         via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(...)</phrase></computeroutput> throws any exception. By default, this
3307         failure handler prints an error message to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput>
3308         and terminates the program calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>
3309         (see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
3310         on Failures</link> to change the failure handler to exit the program with
3311         an error code or to take some other custom action).
3312       </para>
3313       <note>
3314         <para>
3315           While it is technically possible for programmers to specify an exception
3316           guarantee handler that throws an exception in case of an exception guarantee
3317           failure, this will force C++ to terminate the program. That is because
3318           the handler will throw an exception while there is already an active exception
3319           on the stack (the exception thrown by the function body that caused the
3320           exception guarantees to be checked in the first place). Therefore, programmers
3321           should not change the exception guarantee failure handler to throw exceptions.
3322         </para>
3323       </note>
3324     </section>
3325     <section id="boost_contract.tutorial.class_invariants">
3326       <title><link linkend="boost_contract.tutorial.class_invariants">Class Invariants</link></title>
3327       <para>
3328         Public member functions, constructors, and destructors can be programmed
3329         to also check class invariants. When class invariants are specified, they
3330         are programmed in a public <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
3331         function named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3332         taking no argument and returning <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>.
3333         Classes that do not have invariants, simply do not declare the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput> function. <footnote id="boost_contract.tutorial.class_invariants.f0">
3334         <para>
3335           This library uses template meta-programming (SFINAE-based introspection
3336           techniques) to check invariants only for classes that declare a member
3337           function named by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999724496">BOOST_CONTRACT_INVARIANT_FUNC</link></computeroutput>.
3338         </para>
3339         </footnote> For example:
3340       </para>
3341 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
3342 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>                                 <phrase role="comment">// Must be public.</phrase>
3343     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>            <phrase role="comment">// Must be const.</phrase>
3344         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>
3345         <phrase role="special">...</phrase>
3346     <phrase role="special">}</phrase>
3347
3348     <phrase role="special">...</phrase>
3349 <phrase role="special">};</phrase>
3350 </programlisting>
3351       <para>
3352         This member function must be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
3353         because contracts should not modify the object state (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
3354         This library will generate a compile-time error if the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
3355         qualifier is missing (unless <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_PERMISSIVE">BOOST_CONTRACT_PERMISSIVE</link></computeroutput>
3356         is defined).
3357       </para>
3358       <para>
3359         Any code can be programmed in the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3360         function, but it is recommended to keep this code simple using mainly assertions
3361         and if-statements (to avoid programming complex invariants that might be
3362         buggy and slow to check at run-time). It is also recommended to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput> to program
3363         class invariant assertions because that enables this library to print informative
3364         error messages when the asserted conditions are evaluated to be false (note
3365         that this is not a variadic macro, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
3366         Macros</link>):
3367       </para>
3368 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">)</phrase>
3369 <phrase role="comment">// Or, if `boolean-condition` has commas `,` not already within parenthesis `()`...</phrase>
3370 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">))</phrase> <phrase role="comment">// ...use extra parenthesis (not a variadic macro).</phrase>
3371 </programlisting>
3372       <para>
3373         This library will automatically call failure handlers <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.entry_invariant_failure">boost::contract::entry_invariant_failure</link></computeroutput>
3374         or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.exit_invariant_failure">boost::contract::exit_invariant_failure</link></computeroutput>
3375         if any of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
3376         conditions are false or, more in general, if the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3377         function throws an exception when invariants are checked at function entry
3378         or exit respectively. By default, these handlers print an error message to
3379         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput> and terminate the program calling
3380         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput> (see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
3381         on Failures</link> to change these failure handlers to throw exceptions,
3382         exit the program with an error code, etc.).
3383       </para>
3384       <para>
3385         See <link linkend="boost_contract.advanced.access_specifiers">Access Specifiers</link>
3386         to avoid making the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3387         member function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>. <footnote id="boost_contract.tutorial.class_invariants.f1">
3388         <para>
3389           In this documentation the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3390           member function is often declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>
3391           for simplicity. However, in production code it might not be acceptable
3392           to augment the public members of a class adding the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3393           function (and that can be avoided using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
3394           as explained in <link linkend="boost_contract.advanced.access_specifiers">Access
3395           Specifiers</link>).
3396         </para>
3397         </footnote> See <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999724496">BOOST_CONTRACT_INVARIANT_FUNC</link></computeroutput>
3398         to use a name different from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3399         (e.g., because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
3400         clashes with other names in user-defined classes).
3401       </para>
3402       <note>
3403         <para>
3404           Contract assertions are not checked (not even class invariants) when data
3405           members are accessed directly (this is different from Eiffel where even
3406           accessing public data members checks class invariants). Therefore, it might
3407           be best for both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase></computeroutput>es and
3408           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase></computeroutput>s (and also <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">union</phrase></computeroutput>s, see <link linkend="boost_contract.extras.unions">Unions</link>)
3409           that have invariants to have no mutable public data members and to access
3410           data members publicly only via appropriate public functions (e.g., setters
3411           and getters) that can be programmed to check the class invariants using
3412           this library.
3413         </para>
3414       </note>
3415       <para>
3416         See <link linkend="boost_contract.extras.volatile_public_functions">Volatile
3417         Public Functions</link> to program invariants for classes with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput> public functions.
3418       </para>
3419       <bridgehead renderas="sect4" id="boost_contract.tutorial.class_invariants.h0">
3420         <phrase id="boost_contract.tutorial.class_invariants.static_class_invariants"/><link linkend="boost_contract.tutorial.class_invariants.static_class_invariants">Static
3421         Class Invariants</link>
3422       </bridgehead>
3423       <para>
3424         Static public functions can be programmed to check static class invariants.
3425         When static class invariants are specified, they are programmed in a public
3426         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput> function named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput> taking no argument and
3427         returning <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. Classes that
3428         do not have static class invariants, simply do not declare the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput> function. <footnote id="boost_contract.tutorial.class_invariants.f2">
3429         <para>
3430           This library uses template meta-programming (SFINAE-based introspection
3431           techniques) to check static invariants only for classes that declare a
3432           member function named by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999714768">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</link></computeroutput>.
3433         </para>
3434         </footnote> For example:
3435       </para>
3436 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
3437 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>                                 <phrase role="comment">// Must be public.</phrase>
3438     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>    <phrase role="comment">// Must be static.</phrase>
3439         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>
3440         <phrase role="special">...</phrase>
3441     <phrase role="special">}</phrase>
3442
3443     <phrase role="special">...</phrase>
3444 <phrase role="special">};</phrase>
3445 </programlisting>
3446       <para>
3447         This member function must be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
3448         (and it correctly cannot access the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput>).
3449         This library will generate a compile-time error if the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
3450         classifier is missing (unless the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_PERMISSIVE">BOOST_CONTRACT_PERMISSIVE</link></computeroutput>
3451         macro is defined).
3452       </para>
3453       <para>
3454         Any code can be programmed in the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>
3455         function, but it is recommended to keep this code simple using mainly assertions
3456         and if-statements (to avoid programming complex static invariants that might
3457         be buggy and slow to check at run-time). It is also recommended to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput> to program
3458         the assertions because that enables this library to print informative error
3459         messages when the asserted conditions are evaluated to be false (note that
3460         this is not a variadic macro, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
3461         Macros</link>):
3462       </para>
3463 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">)</phrase>
3464 <phrase role="comment">// Or, if `boolean-condition` has commas `,` not already within parenthesis `()`...</phrase>
3465 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">))</phrase> <phrase role="comment">// ...use extra parenthesis (not a variadic macro).</phrase>
3466 </programlisting>
3467       <para>
3468         This library will automatically call failure handlers <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.entry_invariant_failure">boost::contract::entry_invariant_failure</link></computeroutput>
3469         or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.exit_invariant_failure">boost::contract::exit_invariant_failure</link></computeroutput>
3470         if any of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
3471         conditions are false or, more in general, if the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>
3472         function throws an exception when invariants are checked at function entry
3473         or exit respectively. By default, these handlers print an error message to
3474         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput> and terminate the program calling
3475         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput> (see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
3476         on Failures</link> to change these failure handlers to throw exceptions,
3477         exit the program with an error code, etc.).
3478       </para>
3479       <para>
3480         See <link linkend="boost_contract.advanced.access_specifiers">Access Specifiers</link>
3481         to avoid making <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>
3482         member function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>. <footnote id="boost_contract.tutorial.class_invariants.f3">
3483         <para>
3484           In this documentation the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>
3485           member function is often declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>
3486           for simplicity. However, in production code it might not be acceptable
3487           to augment the public members of a class adding the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>
3488           function (and that can be avoided using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
3489           as explained in <link linkend="boost_contract.advanced.access_specifiers">Access
3490           Specifiers</link>).
3491         </para>
3492         </footnote> See <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999714768">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</link></computeroutput>
3493         to use a name different from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>
3494         (e.g., because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput>
3495         clashes with other names in user-defined classes). <footnote id="boost_contract.tutorial.class_invariants.f4">
3496         <para>
3497           <emphasis role="bold">Rationale:</emphasis> In C++, it is not possible
3498           to overload a member function based on the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
3499           classifier. Therefore, this library has to use different names for the
3500           member functions checking non-static and static class invariants (namely
3501           for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999724496">BOOST_CONTRACT_INVARIANT_FUNC</link></computeroutput>
3502           and for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999714768">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</link></computeroutput>).
3503         </para>
3504         </footnote>
3505       </para>
3506     </section>
3507     <section id="boost_contract.tutorial.constructors">
3508       <title><link linkend="boost_contract.tutorial.constructors">Constructors</link></title>
3509       <para>
3510         Contracts for constructors are programmed using the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
3511         function and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3512         base class. For example (see <ulink url="../../example/features/public.cpp"><literal moreinfo="none">public.cpp</literal></ulink>):
3513       </para>
3514       <para>
3515 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">unique_identifiers</phrase> <phrase role="special">:</phrase>
3516     <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">unique_identifiers</phrase><phrase role="special">&gt;</phrase>
3517 <phrase role="special">{</phrase>
3518 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
3519     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
3520         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
3521     <phrase role="special">}</phrase>
3522 </programlisting>
3523       </para>
3524       <para>
3525 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
3526     <phrase role="comment">// Contract for a constructor.</phrase>
3527     <phrase role="identifier">unique_identifiers</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">from</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">to</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
3528         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">unique_identifiers</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
3529             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
3530             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">to</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">from</phrase><phrase role="special">);</phrase>
3531         <phrase role="special">})</phrase>
3532     <phrase role="special">{</phrase>
3533         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
3534             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
3535                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">to</phrase> <phrase role="special">-</phrase> <phrase role="identifier">from</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">));</phrase>
3536             <phrase role="special">})</phrase>
3537         <phrase role="special">;</phrase>
3538
3539         <phrase role="comment">// Constructor body.</phrase>
3540         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">id</phrase> <phrase role="special">=</phrase> <phrase role="identifier">from</phrase><phrase role="special">;</phrase> <phrase role="identifier">id</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">to</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">);</phrase>
3541     <phrase role="special">}</phrase>
3542 </programlisting>
3543       </para>
3544       <para>
3545 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
3546 <phrase role="special">};</phrase>
3547 </programlisting>
3548       </para>
3549       <para>
3550         It is not possible to specify preconditions using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>
3551         for constructors (this library will generate a compile-time error if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput> is used on the object returned by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>).
3552         Constructor preconditions are specified using the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3553         base class instead (same considerations as the ones made in <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>
3554         apply also to the precondition functor passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>).
3555         Programmes should not access the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase><phrase role="keyword">this</phrase></computeroutput> from constructor preconditions (because
3556         the object does not exists yet before the constructor body is executed).
3557         <footnote id="boost_contract.tutorial.constructors.f0">
3558         <para>
3559           See <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
3560           Lambda Functions</link> to enforce this constraint at compile-time (but
3561           not recommended because of extra boiler-plate code).
3562         </para>
3563         </footnote> Constructors without preconditions simply do not explicitly initialize
3564         the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3565         base (because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3566         default constructor checks no contract). When the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3567         base class is used: <footnote id="boost_contract.tutorial.constructors.f1">
3568         <para>
3569           There is a MSVC bug that was fixed in MSVC 2013 for which lambdas cannot
3570           be used in constructor member initialization lists for templates. On MSVC
3571           compilers with that bug, an extra (static) member function can be used
3572           (together with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">bind</phrase></computeroutput> and
3573           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">cref</phrase></computeroutput> as needed) to program
3574           constructor preconditions instead of using lambdas (see <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
3575           Lambda Functions</link>).
3576         </para>
3577         </footnote>
3578       </para>
3579       <itemizedlist>
3580         <listitem>
3581           <simpara>
3582             It should be specified as the <emphasis>first</emphasis> class in the
3583             inheritance list (so constructor preconditions are checked before initializing
3584             any other base class or data member).
3585           </simpara>
3586         </listitem>
3587         <listitem>
3588           <simpara>
3589             Its inheritance access specifier should always be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput>
3590             (so this extra base class does not alter the public inheritance tree
3591             of its derived classes).
3592           </simpara>
3593         </listitem>
3594         <listitem>
3595           <simpara>
3596             It should never be declared as a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">virtual</phrase></computeroutput>
3597             base (because virtual bases are initialized only once across the entire
3598             inheritance hierarchy preventing preconditions of other base classes
3599             from being checked).
3600           </simpara>
3601         </listitem>
3602         <listitem>
3603           <simpara>
3604             It takes the derived class as template parameter. <footnote id="boost_contract.tutorial.constructors.f2">
3605             <para>
3606               <emphasis role="bold">Rationale:</emphasis> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3607               takes the derived class as its template parameter (using the Curiously
3608               Recursive Template Pattern, CRTP) so the instantiated template type
3609               is unique for each derived class. This always avoids base class ambiguity
3610               resolution errors even when multiple inheritance is used. Note that,
3611               as already mentioned, virtual inheritance could not be used instead
3612               of the template parameter here to resolve ambiguities (because virtual
3613               bases are initialized only once by the outer-most derived class, and
3614               that would not allow to properly check preconditions of all base classes).
3615             </para>
3616             </footnote>
3617           </simpara>
3618         </listitem>
3619       </itemizedlist>
3620       <note>
3621         <para>
3622           A class can avoid inheriting from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3623           for efficiency but only when all its constructors have no preconditions.
3624         </para>
3625       </note>
3626       <para>
3627         It is possible to specify postconditions for constructors (see <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>),
3628         but programmers should not access the old value of the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase><phrase role="keyword">this</phrase></computeroutput> in constructor
3629         postconditions (because the object did not exist yet before the constructor
3630         body was executed). <footnote id="boost_contract.tutorial.constructors.f3">
3631         <para>
3632           See <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
3633           Lambda Functions</link> to enforce this constraint at compile-time (but
3634           not recommended because of extra boiler-plate code).
3635         </para>
3636         </footnote> It is also possible to specify exceptions guarantees for constructors
3637         (see <link linkend="boost_contract.tutorial.exception_guarantees">Exception
3638         Guarantees</link>), but programmers should not access the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase><phrase role="keyword">this</phrase></computeroutput> or its
3639         old value in constructor exception guarantees (because the object did not
3640         exist before executing the constructor body and it was not properly constructed
3641         given the constructor body threw an exception). <footnote id="boost_contract.tutorial.constructors.f4">
3642         <para>
3643           See <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
3644           Lambda Functions</link> to enforce these constraints at compile-time (but
3645           not recommended because of extra boiler-plate code).
3646         </para>
3647         </footnote> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
3648         function takes <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput> as a parameter
3649         (because constructors check class invariants, see <link linkend="boost_contract.tutorial.class_invariants">Class
3650         Invariants</link>).
3651       </para>
3652       <para>
3653         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
3654         function returns an RAII object that must always be assigned to a local variable
3655         of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
3656         (otherwise this library will generate a run-time error, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>).
3657         Furthermore, C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> declarations
3658         cannot be used here and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
3659         type must be explicitly specified (otherwise this library will generate a
3660         compile-time error prior C++17 and a run-time error post C++17). The constructor
3661         body is programmed right after the declaration of this RAII object.
3662       </para>
3663       <para>
3664         At construction, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
3665         RAII object for constructors does the following (enclosing constructor entry):
3666       </para>
3667       <orderedlist inheritnum="ignore" continuation="restarts">
3668         <listitem>
3669           <simpara>
3670             Check static class invariants, by calling <literal moreinfo="none"><emphasis>type-of</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> (but not non-static class invariants
3671             because the object does not exist yet).
3672           </simpara>
3673         </listitem>
3674       </orderedlist>
3675       <para>
3676         At destruction instead (enclosing constructor exit):
3677       </para>
3678       <orderedlist inheritnum="ignore" continuation="restarts">
3679         <listitem>
3680           <simpara>
3681             Check static class invariants, by calling <literal moreinfo="none"><emphasis>type-of</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput>.
3682           </simpara>
3683         </listitem>
3684         <listitem>
3685           <simpara>
3686             If the constructor body did not throw an exception:
3687             <orderedlist inheritnum="ignore" continuation="restarts">
3688               <listitem>
3689                 <simpara>
3690                   Check non-static class invariants, by calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput>.
3691                 </simpara>
3692               </listitem>
3693               <listitem>
3694                 <simpara>
3695                   Check postconditions, by calling the nullary functor <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
3696                 </simpara>
3697               </listitem>
3698             </orderedlist>
3699           </simpara>
3700         </listitem>
3701         <listitem>
3702           <simpara>
3703             Else:
3704             <orderedlist inheritnum="ignore" continuation="restarts">
3705               <listitem>
3706                 <simpara>
3707                   Check exception guarantees, by calling the nullary functor <literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
3708                 </simpara>
3709               </listitem>
3710             </orderedlist>
3711           </simpara>
3712         </listitem>
3713       </orderedlist>
3714       <para>
3715         This together with C++ object construction mechanism of base classes and
3716         the use of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3717         ensures that the constructor contracts are correctly checked at run-time
3718         (see <link linkend="boost_contract.contract_programming_overview.constructor_calls">Constructor
3719         Calls</link>).
3720       </para>
3721       <note>
3722         <para>
3723           A constructor can avoid calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
3724           for efficiency but only when it has no postconditions, no exception guarantees,
3725           and its class has no invariants (even if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
3726           is not used by a derived class, contracts of base class constructors will
3727           still be correctly checked by C++ object construction mechanism).
3728         </para>
3729         <para>
3730           The default constructor and copy constructor automatically generated by
3731           C++ will not check contracts. Therefore, unless these constructors are
3732           not public or they have no preconditions, no postconditions, no exception
3733           guarantees, and their class has no invariants, programmers should manually
3734           define them using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
3735           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>.
3736           Similar considerations apply to all other constructors automatically generated
3737           by C++ (e.g., the move constructor).
3738         </para>
3739       </note>
3740       <bridgehead renderas="sect4" id="boost_contract.tutorial.constructors.h0">
3741         <phrase id="boost_contract.tutorial.constructors.private_and_protected_constructors"/><link linkend="boost_contract.tutorial.constructors.private_and_protected_constructors">Private
3742         and Protected Constructors</link>
3743       </bridgehead>
3744       <para>
3745         Private and protected constructors can omit <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
3746         (because they are not part of the public interface of the class so they are
3747         not required to check class invariants, see <link linkend="boost_contract.contract_programming_overview.constructor_calls">Constructor
3748         Calls</link>). They could still use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
3749         to check preconditions before member initializations, and even use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
3750         (but not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>)
3751         to only check postconditions and exception guarantees without checking class
3752         invariants and without calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>
3753         (see <link linkend="boost_contract.advanced.private_and_protected_functions">Private
3754         and Protected Functions</link>). For example:
3755       </para>
3756 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">:</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
3757 <phrase role="keyword">protected</phrase><phrase role="special">:</phrase>
3758     <phrase role="comment">// Contract for a protected constructor (same for private constructors).</phrase>
3759     <phrase role="identifier">u</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="comment">// Still use this base class to check constructor preconditions.</phrase>
3760         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
3761             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>
3762             <phrase role="special">...</phrase>
3763         <phrase role="special">})</phrase>
3764     <phrase role="special">{</phrase>
3765         <phrase role="comment">// Following will correctly not check class invariants.</phrase>
3766         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
3767             <phrase role="comment">// Do not use `.precondition(...)` here.</phrase>
3768             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
3769                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>
3770                 <phrase role="special">...</phrase>
3771             <phrase role="special">})</phrase>
3772             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
3773                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>
3774                 <phrase role="special">...</phrase>
3775             <phrase role="special">})</phrase>
3776         <phrase role="special">;</phrase>
3777
3778         <phrase role="special">...</phrase> <phrase role="comment">// Constructor body.</phrase>
3779     <phrase role="special">}</phrase>
3780
3781     <phrase role="special">...</phrase>
3782 <phrase role="special">};</phrase>
3783 </programlisting>
3784     </section>
3785     <section id="boost_contract.tutorial.destructors">
3786       <title><link linkend="boost_contract.tutorial.destructors">Destructors</link></title>
3787       <para>
3788         Contracts for destructors are programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>.
3789         For example (see <ulink url="../../example/features/public.cpp"><literal moreinfo="none">public.cpp</literal></ulink>):
3790       </para>
3791       <para>
3792 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">unique_identifiers</phrase> <phrase role="special">:</phrase>
3793     <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">unique_identifiers</phrase><phrase role="special">&gt;</phrase>
3794 <phrase role="special">{</phrase>
3795 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
3796     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
3797         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
3798     <phrase role="special">}</phrase>
3799 </programlisting>
3800       </para>
3801       <para>
3802 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
3803     <phrase role="comment">// Contract for a destructor.</phrase>
3804     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">unique_identifiers</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
3805         <phrase role="comment">// Following contract checks class invariants.</phrase>
3806         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
3807
3808         <phrase role="comment">// Destructor body here... (do nothing in this example).</phrase>
3809     <phrase role="special">}</phrase>
3810 </programlisting>
3811       </para>
3812       <para>
3813 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
3814 <phrase role="special">};</phrase>
3815 </programlisting>
3816       </para>
3817       <para>
3818         It is not possible to specify preconditions for destructors (this library
3819         will generate a compile-time error if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>
3820         is used here and that is because destructors can be called at any time after
3821         construction so they have no precondition). It is possible to specify postconditions
3822         for destructors (see <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>,
3823         and also <link linkend="boost_contract.tutorial.static_public_functions">Static
3824         Public Functions</link> for an example), but programmers should not access
3825         the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase><phrase role="keyword">this</phrase></computeroutput>
3826         in destructor postconditions (because the object no longer exists after the
3827         destructor body has been executed). <footnote id="boost_contract.tutorial.destructors.f0">
3828         <para>
3829           See <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
3830           Lambda Functions</link> to enforce this constraint at compile-time (but
3831           not recommended because of extra boiler-plate code).
3832         </para>
3833         </footnote> It is also possible to specify exceptions guarantees for destructors
3834         (see <link linkend="boost_contract.tutorial.exception_guarantees">Exception
3835         Guarantees</link>, even if destructors should usually be programmed to not
3836         throw exceptions in C++, in fact destructors are implicitly declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput> since C++11). <footnote id="boost_contract.tutorial.destructors.f1">
3837         <para>
3838           Exceptions guarantees in destructors can access both the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase><phrase role="keyword">this</phrase></computeroutput> and
3839           its old value because the object existed before executing the destructor
3840           body and it still exists given the destructor body failed throwing an exception
3841           so technically the object should still be properly constructed and satisfy
3842           its class invariants.
3843         </para>
3844         </footnote> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>
3845         function takes <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput> as a parameter
3846         (because destructors check class invariants, see <link linkend="boost_contract.tutorial.class_invariants">Class
3847         Invariants</link>).
3848       </para>
3849       <para>
3850         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>
3851         function returns an RAII object that must always be assigned to a local variable
3852         of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
3853         (otherwise this library will generate a run-time error, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>).
3854         Furthermore, C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> declarations
3855         cannot be used here and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
3856         type must be explicitly specified (otherwise this library will generate a
3857         compile-time error prior C++17 and a run-time error post C++17). The destructor
3858         body is programmed right after the declaration of this RAII object.
3859       </para>
3860       <para>
3861         At construction, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
3862         RAII object for destructors does the following (enclosing destructor entry):
3863       </para>
3864       <orderedlist inheritnum="ignore" continuation="restarts">
3865         <listitem>
3866           <simpara>
3867             Check static and non-static class invariants, by calling <emphasis><literal moreinfo="none">type-of</literal></emphasis><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
3868             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput>.
3869           </simpara>
3870         </listitem>
3871       </orderedlist>
3872       <para>
3873         At destruction instead (enclosing destructor exit):
3874       </para>
3875       <orderedlist inheritnum="ignore" continuation="restarts">
3876         <listitem>
3877           <simpara>
3878             Check static class invariants, by calling <literal moreinfo="none"><emphasis>type-of</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput>.
3879           </simpara>
3880         </listitem>
3881         <listitem>
3882           <simpara>
3883             If the destructor body did not throw an exception:
3884             <orderedlist inheritnum="ignore" continuation="restarts">
3885               <listitem>
3886                 <simpara>
3887                   Check postconditions, by calling the nullay functor <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
3888                 </simpara>
3889               </listitem>
3890             </orderedlist>
3891           </simpara>
3892         </listitem>
3893         <listitem>
3894           <simpara>
3895             Else (even if destructors should generally be programmed not to throw
3896             in C++):
3897             <orderedlist inheritnum="ignore" continuation="restarts">
3898               <listitem>
3899                 <simpara>
3900                   Check non-static class invariants, by calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput> (because the object was not successfully
3901                   destructed).
3902                 </simpara>
3903               </listitem>
3904               <listitem>
3905                 <simpara>
3906                   Check exception guarantees, by calling the nullary functor <literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
3907                 </simpara>
3908               </listitem>
3909             </orderedlist>
3910           </simpara>
3911         </listitem>
3912       </orderedlist>
3913       <para>
3914         This together with C++ object destruction mechanism of base classes ensures
3915         that destructor contracts are correctly checked at run-time (see <link linkend="boost_contract.contract_programming_overview.destructor_calls">Destructor
3916         Calls</link>).
3917       </para>
3918       <note>
3919         <para>
3920           A destructor can avoid calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>
3921           for efficiency but only when it has no postconditions, no exception guarantees,
3922           and its class has no invariants (even if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>
3923           is not used by a derived class, contracts of base class destructors will
3924           still be correctly checked by C++ object destruction mechanism).
3925         </para>
3926         <para>
3927           The default destructor automatically generated by C++ will not check contracts.
3928           Therefore, unless the destructor is not public or it has no postconditions,
3929           no exception guarantees, and its class has no invariants, programmers should
3930           manually define it using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>.
3931         </para>
3932       </note>
3933       <bridgehead renderas="sect4" id="boost_contract.tutorial.destructors.h0">
3934         <phrase id="boost_contract.tutorial.destructors.private_and_protected_destructors"/><link linkend="boost_contract.tutorial.destructors.private_and_protected_destructors">Private
3935         and Protected Destructors</link>
3936       </bridgehead>
3937       <para>
3938         Private and protected destructors can omit <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>
3939         (because they are not part of the public interface of the class so they are
3940         not required to check class invariants, see <link linkend="boost_contract.contract_programming_overview.destructor_calls">Destructor
3941         Calls</link>). They could use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
3942         (but not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>)
3943         to only check postconditions and exception guarantees without checking class
3944         invariants and without calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>
3945         (see <link linkend="boost_contract.advanced.private_and_protected_functions">Private
3946         and Protected Functions</link>). For example:
3947       </para>
3948 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
3949 <phrase role="keyword">protected</phrase><phrase role="special">:</phrase>
3950     <phrase role="comment">// Contract for a protected destructor (same for private destructors).</phrase>
3951     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">u</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
3952         <phrase role="comment">// Following will correctly not check class invariants.</phrase>
3953         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
3954             <phrase role="comment">// Do not use `.precondition(...)` here.</phrase>
3955             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
3956                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(...);</phrase>
3957                 <phrase role="special">...</phrase>
3958             <phrase role="special">})</phrase>
3959             <phrase role="comment">// Could use `.except(...)` here in rare cases of destructors declared to throw.</phrase>
3960         <phrase role="special">;</phrase>
3961
3962         <phrase role="special">...</phrase> <phrase role="comment">// Destructor body.</phrase>
3963     <phrase role="special">}</phrase>
3964
3965     <phrase role="special">...</phrase>
3966 <phrase role="special">};</phrase>
3967 </programlisting>
3968     </section>
3969     <section id="boost_contract.tutorial.public_functions">
3970       <title><link linkend="boost_contract.tutorial.public_functions">Public Functions</link></title>
3971       <para>
3972         Contracts for public functions are programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
3973         In this section, let's consider public functions that are not static, not
3974         virtual, and do not override any function from base classes. For example
3975         (see <ulink url="../../example/features/public.cpp"><literal moreinfo="none">public.cpp</literal></ulink>):
3976       </para>
3977       <para>
3978 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">unique_identifiers</phrase> <phrase role="special">:</phrase>
3979     <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">unique_identifiers</phrase><phrase role="special">&gt;</phrase>
3980 <phrase role="special">{</phrase>
3981 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
3982     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
3983         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
3984     <phrase role="special">}</phrase>
3985 </programlisting>
3986       </para>
3987       <para>
3988 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
3989     <phrase role="comment">// Contract for a public function (but no static, virtual, or override).</phrase>
3990     <phrase role="keyword">bool</phrase> <phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
3991         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
3992         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
3993             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
3994                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
3995             <phrase role="special">})</phrase>
3996             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
3997                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">result</phrase><phrase role="special">);</phrase>
3998             <phrase role="special">})</phrase>
3999         <phrase role="special">;</phrase>
4000
4001         <phrase role="comment">// Function body.</phrase>
4002         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="special">!=</phrase>
4003                 <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase>
4004     <phrase role="special">}</phrase>
4005 </programlisting>
4006       </para>
4007       <para>
4008 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
4009 <phrase role="special">};</phrase>
4010 </programlisting>
4011       </para>
4012       <para>
4013         It is possible to specify preconditions, postconditions, and exception guarantees
4014         for public functions (see <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>,
4015         <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>,
4016         and <link linkend="boost_contract.tutorial.exception_guarantees">Exception
4017         Guarantees</link>). When called from non-static public functions, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4018         function takes <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput> as a parameter
4019         (because public functions check class invariants, see <link linkend="boost_contract.tutorial.class_invariants">Class
4020         Invariants</link>).
4021       </para>
4022       <para>
4023         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4024         function returns an RAII object that must always be assigned to a local variable
4025         of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
4026         (otherwise this library will generate a run-time error, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>).
4027         Furthermore, C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> declarations
4028         cannot be used here and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
4029         type must be explicitly specified (otherwise this library will generate a
4030         compile-time error prior C++17 and a run-time error post C++17). The public
4031         function body is programmed right after the declaration of this RAII object.
4032       </para>
4033       <para>
4034         At construction, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
4035         RAII object for public functions does the following (enclosing public function
4036         entry):
4037       </para>
4038       <orderedlist inheritnum="ignore" continuation="restarts">
4039         <listitem>
4040           <simpara>
4041             Check static and non-static class invariants, by calling <literal moreinfo="none"><emphasis>type-of</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4042             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput>.
4043           </simpara>
4044         </listitem>
4045         <listitem>
4046           <simpara>
4047             Check preconditions, by calling the nullary functor <literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
4048           </simpara>
4049         </listitem>
4050       </orderedlist>
4051       <para>
4052         At destruction instead (enclosing public function exit):
4053       </para>
4054       <orderedlist inheritnum="ignore" continuation="restarts">
4055         <listitem>
4056           <simpara>
4057             Check static and non-static class invariants, by calling <literal moreinfo="none"><emphasis>type-of</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4058             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput>
4059             (even if the function body threw an exception).
4060           </simpara>
4061         </listitem>
4062         <listitem>
4063           <simpara>
4064             If the function body did not throw an exception:
4065             <orderedlist inheritnum="ignore" continuation="restarts">
4066               <listitem>
4067                 <simpara>
4068                   Check postconditions, by calling the nullary functor <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
4069                 </simpara>
4070               </listitem>
4071             </orderedlist>
4072           </simpara>
4073         </listitem>
4074         <listitem>
4075           <simpara>
4076             Else:
4077             <orderedlist inheritnum="ignore" continuation="restarts">
4078               <listitem>
4079                 <simpara>
4080                   Check exception guarantees, by calling the nullary functor <literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
4081                 </simpara>
4082               </listitem>
4083             </orderedlist>
4084           </simpara>
4085         </listitem>
4086       </orderedlist>
4087       <para>
4088         This ensures that public function contracts are correctly checked at run-time
4089         (see <link linkend="boost_contract.contract_programming_overview.public_function_calls">Public
4090         Function Calls</link>).
4091       </para>
4092       <note>
4093         <para>
4094           A public function can avoid calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4095           for efficiency but only when it has no preconditions, no postconditions,
4096           no exception guarantees, it is not virtual, it does not override any virtual
4097           function, and its class has no invariants.
4098         </para>
4099         <para>
4100           The default copy assignment operator automatically generated by C++ will
4101           not check contracts. Therefore, unless this operator is not public or it
4102           has no preconditions, no postconditions, no exception guarantees, and its
4103           class has no invariants, programmers should manually define it using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
4104           Similar considerations apply to all other operators automatically generated
4105           by C++ (e.g., the move operator).
4106         </para>
4107       </note>
4108     </section>
4109     <section id="boost_contract.tutorial.virtual_public_functions">
4110       <title><link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
4111       Public Functions</link></title>
4112       <para>
4113         Contracts for public functions are programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
4114         In this section, let's consider public functions that are virtual but that
4115         do not override any function from base classes. For example (see <ulink url="../../example/features/public.cpp"><literal moreinfo="none">public.cpp</literal></ulink>):
4116       </para>
4117       <para>
4118 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">unique_identifiers</phrase> <phrase role="special">:</phrase>
4119     <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">unique_identifiers</phrase><phrase role="special">&gt;</phrase>
4120 <phrase role="special">{</phrase>
4121 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4122     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
4123         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
4124     <phrase role="special">}</phrase>
4125 </programlisting>
4126       </para>
4127       <para>
4128 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4129     <phrase role="comment">// Contract for a public virtual function (but no override).</phrase>
4130     <phrase role="keyword">virtual</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">id</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Extra `v`.</phrase>
4131         <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
4132         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_find</phrase> <phrase role="special">=</phrase>
4133                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase> <phrase role="comment">// Pass `v`.</phrase>
4134         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
4135                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase> <phrase role="comment">// Pass `v`.</phrase>
4136         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase>
4137                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase> <phrase role="comment">// Pass `v` and `result`.</phrase>
4138             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
4139                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
4140                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase> <phrase role="comment">// ID cannot be already present.</phrase>
4141             <phrase role="special">})</phrase>
4142             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
4143                 <phrase role="keyword">if</phrase><phrase role="special">(!*</phrase><phrase role="identifier">old_find</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
4144                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase>
4145                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
4146                 <phrase role="special">}</phrase>
4147                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">id</phrase><phrase role="special">);</phrase>
4148             <phrase role="special">})</phrase>
4149         <phrase role="special">;</phrase>
4150
4151         <phrase role="comment">// Function body.</phrase>
4152         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">);</phrase>
4153         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase>
4154     <phrase role="special">}</phrase>
4155 </programlisting>
4156       </para>
4157       <para>
4158 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
4159 <phrase role="special">};</phrase>
4160 </programlisting>
4161       </para>
4162       <para>
4163         Virtual public functions must declare an extra trailing parameter of type
4164         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase></computeroutput> with default value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">0</phrase></computeroutput>
4165         (i.e., <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">nullptr</phrase></computeroutput>). <footnote id="boost_contract.tutorial.virtual_public_functions.f0">
4166         <para>
4167           The name of this extra parameter is arbitrary, but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput>
4168           is often used in this documentation.
4169         </para>
4170         </footnote> This extra parameter is the last parameter and it has a default
4171         value so it does not alter the calling interface of the virtual function
4172         (callers will rarely, if ever, have to explicitly deal with this extra parameter
4173         a part from when manipulating the virtual function type directly for function
4174         pointer type-casting, etc.). Programmers must pass the extra virtual parameter
4175         as the very first argument to all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
4176         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4177         calls in the virtual public function definition. <footnote id="boost_contract.tutorial.virtual_public_functions.f1">
4178         <para>
4179           <emphasis role="bold">Rationale:</emphasis> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase></computeroutput> parameter is used by this library to determine
4180           that a function is virtual (in C++ it is not possible to introspect if
4181           a function is declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">virtual</phrase></computeroutput>).
4182           Furthermore, this parameter is internally used by this library to implement
4183           subcontracting (specifically to pass result and old values that are evaluated
4184           by the overriding function to the contracts of overridden virtual functions
4185           in base classes, and also to check preconditions, postconditions, and exception
4186           guarantees of overridden virtual functions in <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
4187           and <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4188           with contracts of the overriding virtual function).
4189         </para>
4190         </footnote>
4191       </para>
4192       <para>
4193         When called from virtual public functions, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4194         function takes <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput> as a parameter
4195         (because public functions check class invariants, see <link linkend="boost_contract.tutorial.class_invariants">Class
4196         Invariants</link>). For virtual public functions returning <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>:
4197       </para>
4198 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
4199 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4200     <phrase role="comment">// A void virtual public function (that does not override).</phrase>
4201     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
4202         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase>
4203                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>                                    <phrase role="comment">// No result parameter...</phrase>
4204             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4205             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>                     <phrase role="comment">// ...so nullary functor.</phrase>
4206             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4207         <phrase role="special">;</phrase>
4208
4209         <phrase role="special">...</phrase>
4210     <phrase role="special">}</phrase>
4211
4212     <phrase role="special">...</phrase>
4213 <phrase role="special">}</phrase>
4214 </programlisting>
4215       <para>
4216         For virtual public functions not returning <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>,
4217         programmers must also pass a reference to the function return value as the
4218         second argument to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
4219         In this case, the library will pass this return value reference to the postcondition
4220         functor that must therefore take one single argument matching the return
4221         type, otherwise this library will generate a compile-time error (the functor
4222         parameter can be a constant reference <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput> to avoid extra copies of the return
4223         value): <footnote id="boost_contract.tutorial.virtual_public_functions.f2">
4224         <para>
4225           <emphasis role="bold">Rationale:</emphasis> The extra function result parameter
4226           taken by the functor passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase></computeroutput>
4227           is used by this library to pass the return value evaluated by the overriding
4228           function to all its overridden virtual functions to support subcontracting.
4229         </para>
4230         </footnote>
4231       </para>
4232 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
4233 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4234     <phrase role="comment">// A void virtual public function (that does not override).</phrase>
4235     <phrase role="keyword">virtual</phrase> <phrase role="identifier">t</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
4236         <phrase role="identifier">t</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
4237         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase>
4238                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>                            <phrase role="comment">// Result parameter...</phrase>
4239             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4240             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="identifier">t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>   <phrase role="comment">// ...so unary functor.</phrase>
4241             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4242         <phrase role="special">;</phrase>
4243
4244         <phrase role="special">...</phrase>                                                 <phrase role="comment">// Assign `result` at each return.</phrase>
4245     <phrase role="special">}</phrase>
4246
4247     <phrase role="special">...</phrase>
4248 <phrase role="special">}</phrase>
4249 </programlisting>
4250       <important>
4251         <para>
4252           It is the responsibility of the programmers to pass the extra virtual parameter
4253           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> to all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
4254           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4255           calls within virtual public functions, and also to pass the return value
4256           reference after <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4257           for non-void virtual public functions. This library cannot automatically
4258           generate compile-time errors if programmers fail to do so (but in general
4259           this will prevent the library from correctly checking contracts at run-time).
4260           <footnote id="boost_contract.tutorial.virtual_public_functions.f3">
4261           <para>
4262             <emphasis role="bold">Rationale:</emphasis> This library does not require
4263             programmers to specify the function type when using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4264             for non-overriding virtual public functions. Therefore, this library
4265             does not know if the enclosing function has a non-void return type so
4266             it cannot check if the return value reference is passed as required for
4267             non-overriding virtual public functions. Instead the function type is
4268             passed to this library for virtual public function overrides and that
4269             also allows this library to give a compile-time error if the return value
4270             reference is missing in those cases.
4271           </para>
4272           </footnote>
4273         </para>
4274         <para>
4275           <emphasis role="bold">Mnemonics:</emphasis>
4276         </para>
4277         <blockquote>
4278           <para>
4279             When <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> is present, always
4280             pass it as the first argument to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4281             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>.
4282           </para>
4283         </blockquote>
4284         <blockquote>
4285           <para>
4286             Always pass <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> to
4287             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4288             right after <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> for non-void
4289             functions.
4290           </para>
4291         </blockquote>
4292       </important>
4293       <para>
4294         For the rest, considerations made in <link linkend="boost_contract.tutorial.public_functions">Public
4295         Functions</link> apply to virtual public functions as well.
4296       </para>
4297       <note>
4298         <para>
4299           A virtual public function should always call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4300           (even if it has no preconditions, no postconditions, no exception guarantees,
4301           and its class has no invariants), otherwise this library will not be able
4302           to correctly use it for subcontracting.
4303         </para>
4304       </note>
4305     </section>
4306     <section id="boost_contract.tutorial.public_function_overrides__subcontracting_">
4307       <title><link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
4308       Function Overrides (Subcontracting)</link></title>
4309       <para>
4310         Contracts for public functions are programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
4311         In this section, let's consider public functions (virtual or not) that override
4312         virtual public functions from one or more of their public base classes. For
4313         example (see <ulink url="../../example/features/public.cpp"><literal moreinfo="none">public.cpp</literal></ulink>):
4314         <footnote id="boost_contract.tutorial.public_function_overrides__subcontracting_.f0">
4315         <para>
4316           In this documentation, function overrides are often marked with the code
4317           comment <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">/* override */</phrase></computeroutput>. On
4318           compilers that support C++11 virtual specifiers, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override</phrase></computeroutput>
4319           identifier can be used instead (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override</phrase></computeroutput>
4320           is not used in the documentation simply because virtual specifiers are
4321           not widely supported yet, even by compilers that support C++11 lambda functions).
4322         </para>
4323         </footnote>
4324       </para>
4325       <para>
4326 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">identifiers</phrase>
4327     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">unique_identifiers</phrase>
4328     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
4329 <phrase role="special">{</phrase>
4330 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4331     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// Bases typedef.</phrase>
4332     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
4333
4334     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check in AND with bases.</phrase>
4335         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
4336     <phrase role="special">}</phrase>
4337 </programlisting>
4338       </para>
4339       <para>
4340 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4341     <phrase role="comment">// Contract for a public function override.</phrase>
4342     <phrase role="keyword">int</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">id</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
4343         <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
4344         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_find</phrase> <phrase role="special">=</phrase>
4345                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase>
4346         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
4347                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
4348         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
4349             <phrase role="identifier">override_push_back</phrase> <phrase role="comment">// Pass override type plus below function pointer...</phrase>
4350         <phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">identifiers</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="comment">// ...and arguments.</phrase>
4351             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check in OR with bases.</phrase>
4352                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
4353                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase> <phrase role="comment">// ID can be already present.</phrase>
4354             <phrase role="special">})</phrase>
4355             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check in AND with bases.</phrase>
4356                 <phrase role="keyword">if</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_find</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase><phrase role="special">);</phrase>
4357             <phrase role="special">})</phrase>
4358         <phrase role="special">;</phrase>
4359
4360         <phrase role="comment">// Function body.</phrase>
4361         <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">))</phrase> <phrase role="identifier">unique_identifiers</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">);</phrase> <phrase role="comment">// Else, do nothing.</phrase>
4362         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase>
4363     <phrase role="special">}</phrase>
4364     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">push_back</phrase><phrase role="special">)</phrase> <phrase role="comment">// Define `override_push_back`.</phrase>
4365 </programlisting>
4366       </para>
4367       <para>
4368 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
4369 <phrase role="special">};</phrase>
4370 </programlisting>
4371       </para>
4372       <para>
4373         The extra <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase></computeroutput> declared using
4374         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
4375         is required by this library for derived classes and it is internally used
4376         to detect base classes for subcontracting (see <link linkend="boost_contract.tutorial.base_classes__subcontracting_">Base
4377         Classes</link>). This library will generate a compile-time error if there
4378         is no suitable virtual function to override in any of the public base classes
4379         for subcontracting. <footnote id="boost_contract.tutorial.public_function_overrides__subcontracting_.f1">
4380         <para>
4381           The compile-time error generated by the library in this case is similar
4382           in principle to the error generated by the C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override</phrase></computeroutput>
4383           specifier, but it is limited to functions with the extra <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase></computeroutput> parameter and searched recursively only
4384           in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> base classes passed
4385           to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
4386           because only those are considered for subcontracting.
4387         </para>
4388         </footnote>
4389       </para>
4390       <para>
4391         When called from public function overrides, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4392         function template takes an explicit template argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase></computeroutput><literal moreinfo="none"><emphasis>function-name</emphasis></literal>
4393         that must be defined using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>:
4394       </para>
4395 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>function-name</emphasis></literal><phrase role="special">)</phrase>
4396 </programlisting>
4397       <para>
4398         This can be declared at any point in the public section of the enclosing
4399         class (see <link linkend="boost_contract.advanced.access_specifiers">Access
4400         Specifiers</link> to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
4401         also in a non-public section of the class). <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
4402         is used only once in a class for a given function name and overloaded functions
4403         can reuse the same <literal moreinfo="none">override_<emphasis>function-name</emphasis></literal>
4404         definition (see <link linkend="boost_contract.advanced.function_overloads">Function
4405         Overloads</link>). <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
4406         can be used to generate a name different than <literal moreinfo="none">override_<emphasis>function-name</emphasis></literal>
4407         (e.g., to avoid generating C++ reserved names containing double underscores
4408         "<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__</phrase></computeroutput>" for function
4409         names that already start with an underscore "<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">_</phrase></computeroutput>",
4410         see <link linkend="boost_contract.advanced.named_overrides">Named Overrides</link>).
4411         For convenience <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDES">BOOST_CONTRACT_OVERRIDES</link></computeroutput>
4412         can be used with multiple function names instead of repeating <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput> for each
4413         function name (on compilers that support variadic macros). For example, for
4414         three functions named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase></computeroutput>,
4415         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">g</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">h</phrase></computeroutput>
4416         (but same for any other number of functions), the following:
4417       </para>
4418 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="identifier">g</phrase><phrase role="special">,</phrase> <phrase role="identifier">h</phrase><phrase role="special">)</phrase>
4419 </programlisting>
4420       <para>
4421         Is equivalent to: <footnote id="boost_contract.tutorial.public_function_overrides__subcontracting_.f2">
4422         <para>
4423           There is no equivalent of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
4424           that operates on multiple function names at once (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
4425           is not expected to be used often so it can simply be repeated multiple
4426           times when needed).
4427         </para>
4428         </footnote>
4429       </para>
4430 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
4431 <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">g</phrase><phrase role="special">)</phrase>
4432 <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">h</phrase><phrase role="special">)</phrase>
4433 </programlisting>
4434       <para>
4435         Public function overrides must always list the extra trailing parameter of
4436         type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase></computeroutput> with default value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">0</phrase></computeroutput>
4437         (i.e., <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">nullptr</phrase></computeroutput>), even when they
4438         are not declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">virtual</phrase></computeroutput>, if
4439         this parameter is present in the signature of the virtual function being
4440         overridden from base classes. Programmers must pass the extra virtual parameter
4441         as the very first argument to all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
4442         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4443         calls in the public function override definition (see <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
4444         Public Functions</link>).
4445       </para>
4446       <para>
4447         When called from public function overrides, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4448         function takes a pointer to the enclosing function, the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase><phrase role="keyword">this</phrase></computeroutput> (because
4449         public function overrides check class invariants, see <link linkend="boost_contract.tutorial.class_invariants">Class
4450         Invariants</link>), and references to each function argument in the order
4451         they appear in the function declaration. <footnote id="boost_contract.tutorial.public_function_overrides__subcontracting_.f3">
4452         <para>
4453           <emphasis role="bold">Rationale:</emphasis> The object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput>
4454           is passed after the function pointer to follow <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase></computeroutput>'s
4455           syntax. The function pointer and references to all function arguments are
4456           needed for public function overrides because this library has to internally
4457           call overridden virtual public functions to check their contracts for subcontracting
4458           (even if this library will not actually execute the bodies of the overridden
4459           functions).
4460         </para>
4461         </footnote> For public function overrides returning <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>:
4462       </para>
4463 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
4464 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4465     <phrase role="comment">// A void public function override.</phrase>
4466     <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
4467         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">override_f</phrase><phrase role="special">&gt;(</phrase>
4468                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">u</phrase><phrase role="special">::</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...,</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">)</phrase>              <phrase role="comment">// No result parameter...</phrase>
4469             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4470             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>                     <phrase role="comment">// ...so nullary functor.</phrase>
4471             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4472         <phrase role="special">;</phrase>
4473
4474         <phrase role="special">...</phrase>
4475     <phrase role="special">}</phrase>
4476     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
4477
4478     <phrase role="special">...</phrase>
4479 <phrase role="special">}</phrase>
4480 </programlisting>
4481       <para>
4482         For public function overrides not returning <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>,
4483         programmers must also pass a reference to the function return value as the
4484         second argument to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4485         (this library will generate a compile-time error otherwise). <footnote id="boost_contract.tutorial.public_function_overrides__subcontracting_.f4">
4486         <para>
4487           <emphasis role="bold">Rationale:</emphasis> As for non-overriding virtual
4488           public functions, also public function overrides use the extra return value
4489           parameter to pass it to the overridden functions when subcontracting. In
4490           the case of public function overrides, this library has the function pointer
4491           so it will generate a compile-time error if the function is non-void and
4492           programmers forget to specify the extra return value parameter (this extra
4493           error checking is not possible instead for non-overriding virtual public
4494           functions because their contracts do not take the function pointer as a
4495           parameter, see <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
4496           Public Functions</link>).
4497         </para>
4498         </footnote> In this case, the library will pass this return value reference
4499         to the postcondition functor that must therefore take one single argument
4500         matching the return type, otherwise this library will generate a compile-time
4501         error (the functor parameter can be a constant reference <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput> to avoid extra copies of the return
4502         value, similarly to non-overriding non-void <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
4503         Public Functions</link>):
4504       </para>
4505 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
4506 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4507     <phrase role="comment">// A non-void public function override.</phrase>
4508     <phrase role="identifier">t</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
4509         <phrase role="identifier">t</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
4510         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">override_f</phrase><phrase role="special">&gt;(</phrase>
4511                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">u</phrase><phrase role="special">::</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...,</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">)</phrase>      <phrase role="comment">// Result parameter...</phrase>
4512             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4513             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="identifier">t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>   <phrase role="comment">// ...so unary functor.</phrase>
4514             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4515         <phrase role="special">;</phrase>
4516
4517         <phrase role="special">...</phrase>                                                 <phrase role="comment">// Assign `result` at each return.</phrase>
4518     <phrase role="special">}</phrase>
4519     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
4520
4521     <phrase role="special">...</phrase>
4522 <phrase role="special">}</phrase>
4523 </programlisting>
4524       <para>
4525         This library will throw <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.bad_virtual_result_cast">boost::contract::bad_virtual_result_cast</link></computeroutput>
4526         if programmers specify return values for public function overrides in derived
4527         classes that are not consistent with the return types of the virtual public
4528         functions being overridden in the base classes. <footnote id="boost_contract.tutorial.public_function_overrides__subcontracting_.f5">
4529         <para>
4530           <emphasis role="bold">Rationale:</emphasis> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bad_any_cast</phrase></computeroutput>
4531           exception was not used here because it does not print the from- and to-
4532           type names (so it is not descriptive enough).
4533         </para>
4534         </footnote>
4535       </para>
4536       <important>
4537         <para>
4538           It is the responsibility of the programmers to pass the extra virtual parameter
4539           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> to all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
4540           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4541           calls within public function overrides, and also to pass the return value
4542           reference after <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4543           for non-void public function overrides. This library cannot always generate
4544           compile-time errors if programmers fail to do so (but in general this will
4545           prevent the library from correctly checking contracts at run-time).
4546         </para>
4547         <para>
4548           <emphasis role="bold">Mnemonics:</emphasis>
4549         </para>
4550         <blockquote>
4551           <para>
4552             When <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput>
4553             is present, always pass it as template parameter to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
4554           </para>
4555         </blockquote>
4556         <blockquote>
4557           <para>
4558             When <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> is present, always
4559             pass it as the first argument to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4560             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>.
4561           </para>
4562         </blockquote>
4563         <blockquote>
4564           <para>
4565             Always pass <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> to
4566             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4567             right after <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> for non-void
4568             functions.
4569           </para>
4570         </blockquote>
4571       </important>
4572       <para>
4573         At construction, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
4574         RAII object for public function overrides does the following (enclosing public
4575         function override entry):
4576       </para>
4577       <orderedlist inheritnum="ignore" continuation="restarts">
4578         <listitem>
4579           <simpara>
4580             Check static and non-static class invariants for all overridden bases
4581             and for the derived class in <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4582             with each other, by calling <literal moreinfo="none"><emphasis>type-of</emphasis>(<emphasis>overridden-base_1</emphasis>)</literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4583             <literal moreinfo="none"><emphasis>overridden-base_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>...
4584             <literal moreinfo="none"><emphasis>type-of</emphasis>(<emphasis>overridden-base_n</emphasis>)</literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4585             <literal moreinfo="none"><emphasis>overridden-base_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4586             <literal moreinfo="none"><emphasis>type-of</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput>
4587             <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4588             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput>.
4589           </simpara>
4590         </listitem>
4591         <listitem>
4592           <simpara>
4593             Check preconditions for all overridden base functions and for the overriding
4594             derived function in <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
4595             with each other, by calling the nullary functors <literal moreinfo="none"><emphasis>r_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>...
4596             <literal moreinfo="none"><emphasis>r_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>
4597             <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
4598             <literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>
4599             passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>r_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>, ... <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>r_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> for all of the overridden and overriding
4600             functions respectively.
4601           </simpara>
4602         </listitem>
4603       </orderedlist>
4604       <para>
4605         At destruction instead (enclosing public function override exit):
4606       </para>
4607       <orderedlist inheritnum="ignore" continuation="restarts">
4608         <listitem>
4609           <simpara>
4610             Check static and non-static class invariants for all overridden bases
4611             and for the derived class in <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4612             with each other, by calling <literal moreinfo="none"><emphasis>type-of</emphasis>(<emphasis>overridden-base_1</emphasis>)</literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4613             <literal moreinfo="none"><emphasis>overridden-base_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>...
4614             <literal moreinfo="none"><emphasis>type-of</emphasis>(<emphasis>overridden-base_n</emphasis>)</literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4615             <literal moreinfo="none"><emphasis>overridden-base_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4616             <literal moreinfo="none"><emphasis>type-of</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput>
4617             <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4618             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput>
4619             (even if the function body threw an exception).
4620           </simpara>
4621         </listitem>
4622         <listitem>
4623           <simpara>
4624             If the function body did not throw an exception:
4625             <orderedlist inheritnum="ignore" continuation="restarts">
4626               <listitem>
4627                 <simpara>
4628                   Check postconditions for all overridden base functions and for
4629                   the overriding derived function in <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4630                   with each other, by calling the nullary functors <literal moreinfo="none"><emphasis>s_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>...
4631                   <literal moreinfo="none"><emphasis>s_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>
4632                   <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4633                   <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>
4634                   passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>, ... <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> for all of the overridden and
4635                   overriding functions respectively (or the unary functors <literal moreinfo="none"><emphasis>s_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>result</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>...
4636                   <literal moreinfo="none"><emphasis>s_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>result</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4637                   <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>result</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> for non-void public function overrides).
4638                 </simpara>
4639               </listitem>
4640             </orderedlist>
4641           </simpara>
4642         </listitem>
4643         <listitem>
4644           <simpara>
4645             Else:
4646             <orderedlist inheritnum="ignore" continuation="restarts">
4647               <listitem>
4648                 <simpara>
4649                   Check exception guarantees for all overridden base functions and
4650                   for the overriding derived function in <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4651                   with each other, by calling the nullary functors <literal moreinfo="none"><emphasis>e_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>...
4652                   <literal moreinfo="none"><emphasis>e_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>
4653                   <link linkend="and_anchor"><literal moreinfo="none"><emphasis>AND</emphasis></literal></link>
4654                   <literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>
4655                   passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e_1</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>, ... <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e_n</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> for all of the overridden and
4656                   overriding functions respectively.
4657                 </simpara>
4658               </listitem>
4659             </orderedlist>
4660           </simpara>
4661         </listitem>
4662       </orderedlist>
4663       <para>
4664         This ensures that contracts and subcontracts of public function overrides
4665         are correctly checked at run-time in accordance with the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
4666         principle</ulink> (see <link linkend="boost_contract.contract_programming_overview.public_function_calls">Public
4667         Function Calls</link>).
4668       </para>
4669       <para>
4670         For the rest, considerations made in <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
4671         Public Functions</link> apply to public function overrides as well.
4672       </para>
4673       <note>
4674         <para>
4675           A public function override should always call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4676           (even if it has no preconditions, no postconditions, no exception guarantees,
4677           and its class has no invariants), otherwise this library will not be able
4678           to correctly use it for subcontracting.
4679         </para>
4680       </note>
4681     </section>
4682     <section id="boost_contract.tutorial.base_classes__subcontracting_">
4683       <title><link linkend="boost_contract.tutorial.base_classes__subcontracting_">Base
4684       Classes (Subcontracting)</link></title>
4685       <para>
4686         In order for this library to support subcontracting, programmers must specify
4687         the bases of a derived class declaring a public member type named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput> via a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase></computeroutput>
4688         using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>.
4689         For example (see <ulink url="../../example/features/base_types.cpp"><literal moreinfo="none">base_types.cpp</literal></ulink>):
4690       </para>
4691       <para>
4692 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">chars</phrase>
4693     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="comment">/* local macro (for convenience) */</phrase> <phrase role="special">\</phrase>
4694         <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">chars</phrase><phrase role="special">&gt;,</phrase> <phrase role="special">\</phrase>
4695         <phrase role="keyword">public</phrase> <phrase role="identifier">unique_chars</phrase><phrase role="special">,</phrase> <phrase role="special">\</phrase>
4696         <phrase role="keyword">public</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">pushable</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;,</phrase> <phrase role="special">\</phrase>
4697         <phrase role="keyword">virtual</phrase> <phrase role="keyword">protected</phrase> <phrase role="identifier">has_size</phrase><phrase role="special">,</phrase> <phrase role="special">\</phrase>
4698         <phrase role="keyword">private</phrase> <phrase role="identifier">has_empty</phrase>
4699     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase> <phrase role="comment">// Bases of this class.</phrase>
4700 <phrase role="special">{</phrase>
4701 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4702     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// Bases typedef.</phrase>
4703     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase> <phrase role="comment">// Undefine local macro.</phrase>
4704
4705     <phrase role="comment">/* ... */</phrase>
4706 </programlisting>
4707       </para>
4708       <para>
4709         For convenience, a <emphasis>local macro</emphasis> named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BASES</phrase></computeroutput>
4710         can be used to avoid repeating the base list twice (first in the derived
4711         class declaration <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> </computeroutput><literal moreinfo="none"><emphasis>class-name</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">
4712         <phrase role="special">:</phrase> </computeroutput><literal moreinfo="none"><emphasis>base-list</emphasis></literal>
4713         and then again when invoking <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>base-list</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>). Being a local macro, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BASES</phrase></computeroutput>
4714         must be undefined using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#undef</phrase>
4715         <phrase role="identifier">BASES</phrase></computeroutput> after it is used to declare
4716         the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase></computeroutput> (to avoid name clashes and macro redefinition
4717         errors). <footnote id="boost_contract.tutorial.base_classes__subcontracting_.f0">
4718         <para>
4719           The name of this local macro is arbitrary, but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BASES</phrase></computeroutput>
4720           is often used in this documentation.
4721         </para>
4722         </footnote>
4723       </para>
4724       <para>
4725         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
4726         is a variadic macro and accepts a list of bases separated by commas (see
4727         <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
4728         Macros</link> to program <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>
4729         without using macros). As already noted in <link linkend="boost_contract.tutorial.constructors">Constructors</link>,
4730         when the extra base <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
4731         is used to program constructor preconditions, its inheritance access level
4732         must always be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> and it
4733         must be specified as the very first base.
4734       </para>
4735       <important>
4736         <para>
4737           Each base passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
4738           must <emphasis>explicitly</emphasis> specify its inheritance access level
4739           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">protected</phrase></computeroutput>,
4740           or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> (but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">virtual</phrase></computeroutput> is optional and can be specified
4741           either before or after the access level as usual in C++). This library
4742           will generate a compile-time error if the first base is missing its inheritance
4743           access level, but this library will not be able to always generate an error
4744           if the access level is missing for bases after the first one. <footnote id="boost_contract.tutorial.base_classes__subcontracting_.f1">
4745           <para>
4746             <emphasis role="bold">Rationale:</emphasis> This library explicitly requires
4747             the inheritance access level because derived classes must subcontract
4748             only from public bases, but not from protected or private bases (see
4749             <link linkend="boost_contract.contract_programming_overview.public_function_calls">Public
4750             Function Calls</link>). <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
4751             inspects each inheritance access level using preprocessor meta-programming
4752             and removes non-public bases from the list of bases internally used for
4753             subcontracting. However, this library cannot always detect when programmers
4754             forget to specify the inheritance access level because, when commas are
4755             used to separate template parameters passed to base classes, the preprocessor
4756             will not be able to correctly use commas to identify the next base class
4757             token in the inheritance list (the preprocessor cannot distinguish between
4758             commas that are not protected by round parenthesis, like the ones used
4759             in templates). Therefore, this library uses the inheritance access level
4760             keyword <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">protected</phrase></computeroutput>, or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput>
4761             instead of commas <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">,</phrase></computeroutput> for
4762             the preprocessor to correctly find the next base class token in the inheritance
4763             list (thus inheritance access levels must always be explicit specified
4764             by programmers for each base).
4765           </para>
4766           </footnote> It is the responsibility of the programmers to make sure that
4767           all bases passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
4768           explicitly specify their inheritance access level (inheritance access levels
4769           are instead optional in C++ because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput>
4770           is implicitly assumed for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase></computeroutput>
4771           types and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase></computeroutput> types).
4772         </para>
4773         <para>
4774           <emphasis role="bold">Mnemonics:</emphasis>
4775         </para>
4776         <blockquote>
4777           <para>
4778             Always explicitly specify the inheritance access level <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">protected</phrase></computeroutput>,
4779             or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> for base classes
4780             passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>.
4781           </para>
4782         </blockquote>
4783       </important>
4784       <para>
4785         See <link linkend="boost_contract.advanced.access_specifiers">Access Specifiers</link>
4786         to avoid making the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>
4787         member type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>. <footnote id="boost_contract.tutorial.base_classes__subcontracting_.f2">
4788         <para>
4789           In this documentation the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_type</phrase></computeroutput>
4790           member type is often declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>
4791           for simplicity. However, in production code it might not be acceptable
4792           to augment the public members of a class adding the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>
4793           type (and that can be avoided using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
4794           as explained in <link linkend="boost_contract.advanced.access_specifiers">Access
4795           Specifiers</link>).
4796         </para>
4797         </footnote> See <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999732400">BOOST_CONTRACT_BASES_TYPEDEF</link></computeroutput>
4798         to use a name different from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>
4799         (e.g., because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>
4800         clashes with other names in user-defined classes).
4801       </para>
4802     </section>
4803     <section id="boost_contract.tutorial.static_public_functions">
4804       <title><link linkend="boost_contract.tutorial.static_public_functions">Static
4805       Public Functions</link></title>
4806       <para>
4807         Contracts for public functions are programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
4808         In this section, let's consider static public functions. For example (see
4809         <ulink url="../../example/features/static_public.cpp"><literal moreinfo="none">static_public.cpp</literal></ulink>):
4810       </para>
4811       <para>
4812 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">C</phrase><phrase role="special">&gt;</phrase>
4813 <phrase role="keyword">class</phrase> <phrase role="identifier">make</phrase> <phrase role="special">{</phrase>
4814 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4815     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Static class invariants.</phrase>
4816         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
4817     <phrase role="special">}</phrase>
4818
4819     <phrase role="comment">// Contract for a static public function.</phrase>
4820     <phrase role="keyword">static</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
4821         <phrase role="comment">// Explicit template parameter `make` (check static invariants).</phrase>
4822         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">make</phrase><phrase role="special">&gt;();</phrase>
4823
4824         <phrase role="keyword">return</phrase> <phrase role="identifier">instances_</phrase><phrase role="special">;</phrase> <phrase role="comment">// Function body.</phrase>
4825     <phrase role="special">}</phrase>
4826
4827     <phrase role="comment">/* ... */</phrase>
4828 </programlisting>
4829       </para>
4830       <para>
4831         It is possible to specify preconditions, postconditions, and exception guarantees
4832         for static public functions (see <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>,
4833         <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>,
4834         and <link linkend="boost_contract.tutorial.exception_guarantees">Exception
4835         Guarantees</link>). When called from static public functions, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4836         cannot take the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput>
4837         as a parameter (because there is no object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput>
4838         in static member functions) so the enclosing class type is specified via
4839         an explicit template parameter as in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput><literal moreinfo="none">&lt;<emphasis>class-type</emphasis>&gt;</literal>
4840         (the class type is required to check static class invariants, see <link linkend="boost_contract.tutorial.class_invariants">Class
4841         Invariants</link>):
4842       </para>
4843 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
4844 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4845     <phrase role="comment">// A static public function.</phrase>
4846     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
4847         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;()</phrase> <phrase role="comment">// Class type `u` as explicit template parameter.</phrase>
4848             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4849             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4850             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">})</phrase>
4851         <phrase role="special">;</phrase>
4852
4853         <phrase role="special">...</phrase>
4854     <phrase role="special">}</phrase>
4855
4856     <phrase role="special">...</phrase>
4857 <phrase role="special">};</phrase>
4858 </programlisting>
4859       <para>
4860         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4861         function returns an RAII object that must be assigned to a local variable
4862         of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
4863         (otherwise this library will generate a run-time error, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>).
4864         Furthermore, C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> declarations
4865         cannot be used here and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
4866         type must be explicitly specified (otherwise this library will generate a
4867         compile-time error prior C++17 and a run-time error post C++17). The static
4868         public functions body is programmed right after the declaration of this RAII
4869         object.
4870       </para>
4871       <para>
4872         At construction, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
4873         RAII object for static public functions does the following (enclosing static
4874         public function entry):
4875       </para>
4876       <orderedlist inheritnum="ignore" continuation="restarts">
4877         <listitem>
4878           <simpara>
4879             Check static class invariants, by calling <literal moreinfo="none"><emphasis>class-type</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> (but never non-static class invariants).
4880           </simpara>
4881         </listitem>
4882         <listitem>
4883           <simpara>
4884             Check preconditions, by calling the nullary functor <literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>r</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
4885           </simpara>
4886         </listitem>
4887       </orderedlist>
4888       <para>
4889         At destruction instead (enclosing static public function exit):
4890       </para>
4891       <orderedlist inheritnum="ignore" continuation="restarts">
4892         <listitem>
4893           <simpara>
4894             Check static class invariants, by calling <literal moreinfo="none"><emphasis>class-type</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> (even if the function body threw an
4895             exception, but never non-static class invariants).
4896           </simpara>
4897         </listitem>
4898         <listitem>
4899           <simpara>
4900             If the function body did not throw an exception:
4901             <orderedlist inheritnum="ignore" continuation="restarts">
4902               <listitem>
4903                 <simpara>
4904                   Check postconditions, by calling the nullary functor <literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>s</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
4905                 </simpara>
4906               </listitem>
4907             </orderedlist>
4908           </simpara>
4909         </listitem>
4910         <listitem>
4911           <simpara>
4912             Else:
4913             <orderedlist inheritnum="ignore" continuation="restarts">
4914               <listitem>
4915                 <simpara>
4916                   Check exception guarantees, by calling the nullary functor <literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>e</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>.
4917                 </simpara>
4918               </listitem>
4919             </orderedlist>
4920           </simpara>
4921         </listitem>
4922       </orderedlist>
4923       <para>
4924         This ensures that static public function contracts are correctly checked
4925         at run-time (static public functions do not subcontract because they have
4926         no object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput> and therefore
4927         there is no inheritance, see <link linkend="boost_contract.contract_programming_overview.public_function_calls">Public
4928         Function Calls</link>).
4929       </para>
4930       <note>
4931         <para>
4932           A static public function can avoid calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4933           for efficiency but only when it has no preconditions, no postconditions,
4934           no exception guarantees, and its class has no static invariants (the class
4935           can still have non-static invariants or base classes instead).
4936         </para>
4937       </note>
4938     </section>
4939   </section>
4940   <section id="boost_contract.advanced">
4941     <title><link linkend="boost_contract.advanced">Advanced</link></title>
4942     <para>
4943       This section is a guide to advanced usage of this library.
4944     </para>
4945     <section id="boost_contract.advanced.pure_virtual_public_functions">
4946       <title><link linkend="boost_contract.advanced.pure_virtual_public_functions">Pure
4947       Virtual Public Functions</link></title>
4948       <para>
4949         In C++, pure virtual functions are allowed to have a <ulink url="http://en.cppreference.com/w/cpp/language/abstract_class">default
4950         implementation</ulink> as long as such implementation is programmed out-of-line
4951         so defined outside the class declaring the pure virtual function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">virtual</phrase> <phrase role="special">...</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase></computeroutput>.
4952       </para>
4953       <para>
4954         Contracts for pure virtual public functions are programmed using the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
4955         function like for (non-pure) virtual public functions (all consideration
4956         made in <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
4957         Public Functions</link> apply). However, contracts have to be programmed
4958         out-of-line, in the default implementation of the pure virtual function.
4959         For example (see <ulink url="../../example/features/pure_virtual_public.cpp"><literal moreinfo="none">pure_virtual_public.cpp</literal></ulink>):
4960       </para>
4961       <para>
4962 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iterator</phrase><phrase role="special">&gt;</phrase>
4963 <phrase role="keyword">class</phrase> <phrase role="identifier">range</phrase> <phrase role="special">{</phrase>
4964 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
4965     <phrase role="comment">// Pure virtual function declaration (contract in definition below).</phrase>
4966     <phrase role="keyword">virtual</phrase> <phrase role="identifier">Iterator</phrase> <phrase role="identifier">begin</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
4967 </programlisting>
4968       </para>
4969       <para>
4970 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
4971 <phrase role="special">};</phrase>
4972 </programlisting>
4973       </para>
4974       <para>
4975 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Pure virtual function default implementation (out-of-line in C++).</phrase>
4976 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iterator</phrase><phrase role="special">&gt;</phrase>
4977 <phrase role="identifier">Iterator</phrase> <phrase role="identifier">range</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Iterator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">begin</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
4978     <phrase role="identifier">Iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase> <phrase role="comment">// As usual, virtual pass `result` right after `v`...</phrase>
4979     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
4980         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="identifier">Iterator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
4981             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">());</phrase>
4982         <phrase role="special">})</phrase>
4983     <phrase role="special">;</phrase>
4984
4985     <phrase role="comment">// Pure function body (never executed by this library).</phrase>
4986     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
4987     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
4988 <phrase role="special">}</phrase>
4989 </programlisting>
4990       </para>
4991       <para>
4992         This library will never actually execute the pure virtual function body while
4993         it is calling the pure virtual function default implementation to check contracts
4994         for subcontracting. Therefore, programmers can safely <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">)</phrase></computeroutput>
4995         at the beginning of the body if they intend for that body to never be executed
4996         (or they can program a working body in case they need to use pure virtual
4997         function default implementations as usual in C++).
4998       </para>
4999       <bridgehead renderas="sect4" id="boost_contract.advanced.pure_virtual_public_functions.h0">
5000         <phrase id="boost_contract.advanced.pure_virtual_public_functions.subcontracting_preconditions_always_true_or_false"/><link linkend="boost_contract.advanced.pure_virtual_public_functions.subcontracting_preconditions_always_true_or_false">Subcontracting
5001         Preconditions Always True or False</link>
5002       </bridgehead>
5003       <para>
5004         As seen in <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
5005         Function Overrides</link>, preconditions of overriding public functions are
5006         checked in <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
5007         with preconditions of overridden virtual public functions. Therefore, if
5008         a virtual public function in a base class specifies no precondition then
5009         preconditions specified by all its overriding functions in derived classes
5010         will have no effect (because when checked in <link linkend="or_anchor"><literal moreinfo="none"><emphasis>OR</emphasis></literal></link>
5011         with the overridden function from the base class that has no preconditions,
5012         they will always pass):
5013       </para>
5014 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Some base class.</phrase>
5015 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5016     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5017         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
5018             <phrase role="comment">// No preconditions, same as `ASSERT(true)`.</phrase>
5019             <phrase role="special">...</phrase>
5020         <phrase role="special">;</phrase>
5021
5022         <phrase role="special">...</phrase>
5023     <phrase role="special">}</phrase>
5024
5025     <phrase role="special">...</phrase>
5026 <phrase role="special">};</phrase>
5027 </programlisting>
5028       <para>
5029         This correctly reflects the fact that the overridden function in the base
5030         class can be called from any context (because it has no precondition) and
5031         so must all its overriding functions in all derived classes in accordance
5032         to the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
5033         principle</ulink>. <footnote id="boost_contract.advanced.pure_virtual_public_functions.f0">
5034         <para>
5035           This consequence of the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
5036           principle</ulink> <quote>that if any function in an inheritance hierarchy
5037           has no preconditions, then preconditions on functions overriding it have
5038           no useful effect</quote> is also explicitly mentioned in the contract documentation
5039           of the D Programming Language (see <link linkend="Bright04_anchor">[Bright04]</link>).
5040         </para>
5041         </footnote> In other words, the code above has the same effect as declaring
5042         the virtual public function in the base class with a single precondition
5043         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase><phrase role="special">)</phrase></computeroutput> that
5044         will always trivially pass:
5045       </para>
5046 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Some base class.</phrase>
5047 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5048     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5049         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
5050             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([]</phrase> <phrase role="special">{</phrase>
5051                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase><phrase role="special">);</phrase> <phrase role="comment">// Same as no preconditions.</phrase>
5052             <phrase role="special">})</phrase>
5053             <phrase role="special">...</phrase>
5054         <phrase role="special">;</phrase>
5055
5056         <phrase role="special">...</phrase>
5057     <phrase role="special">}</phrase>
5058
5059     <phrase role="special">...</phrase>
5060 <phrase role="special">};</phrase>
5061 </programlisting>
5062       <para>
5063         On the flip side, programmers might sometimes consider to declare a pure
5064         virtual public function in a base class with a single precondition <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">)</phrase></computeroutput> that
5065         will always fail. This indicates that the pure virtual public function can
5066         never be called unless it is redefined by a derived class (which is already
5067         the case with C++ pure virtual functions) and also that the base class designers
5068         have intentionally left it up to derived classes to specify preconditions
5069         for the pure virtual function in question. This technique might make sense
5070         only for preconditions of pure virtual public functions (otherwise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">)</phrase></computeroutput> will
5071         prevent calling virtual public functions in concrete bases). For example
5072         (see <ulink url="../../example/features/named_override.cpp"><literal moreinfo="none">named_override.cpp</literal></ulink>):
5073       </para>
5074       <para>
5075 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
5076 <phrase role="keyword">class</phrase> <phrase role="identifier">generic_unary_pack</phrase> <phrase role="special">{</phrase>
5077 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5078     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">_1</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5079     <phrase role="keyword">virtual</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">_1</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5080 <phrase role="special">};</phrase>
5081
5082 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
5083 <phrase role="keyword">void</phrase> <phrase role="identifier">generic_unary_pack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">_1</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5084     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
5085         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5086             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase> <phrase role="comment">// Defer preconditions to overrides.</phrase>
5087         <phrase role="special">})</phrase>
5088     <phrase role="special">;</phrase>
5089     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
5090 <phrase role="special">}</phrase>
5091
5092 <phrase role="comment">/* ... */</phrase>
5093 </programlisting>
5094       </para>
5095       <para>
5096         That said, the need to declare such a precondition <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">)</phrase></computeroutput>
5097         that will always fail might also be an indication that the base class interface
5098         is not correctly designed. In general, the base class interface should still
5099         contain all functions (eventually as pure virtual) that are necessary to
5100         program its contracts.
5101       </para>
5102     </section>
5103     <section id="boost_contract.advanced.optional_return_values">
5104       <title><link linkend="boost_contract.advanced.optional_return_values">Optional
5105       Return Values</link></title>
5106       <para>
5107         It is possible to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput>
5108         to handle return values when programmers cannot construct the result variable
5109         at its point of declaration before the contract (e.g., because an appropriate
5110         constructor for the return type is not available at that point, or just because
5111         it would be too expensive to execute an extra initialization of the return
5112         value at run-time). <footnote id="boost_contract.advanced.optional_return_values.f0">
5113         <para>
5114           <emphasis role="bold">Rationale:</emphasis> This library uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput> instead of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput>
5115           to support a larger number of compilers and their versions (because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput> was not available before C++17).
5116         </para>
5117         </footnote> For example (see <ulink url="../../example/features/optional_result.cpp"><literal moreinfo="none">optional_result.cpp</literal></ulink>):
5118       </para>
5119       <para>
5120 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">Index</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
5121 <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">get</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;&amp;</phrase> <phrase role="identifier">vect</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5122     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase> <phrase role="comment">// Result not initialized here...</phrase>
5123     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5124         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5125             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">Index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">vect</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
5126         <phrase role="special">})</phrase>
5127         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5128             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">vect</phrase><phrase role="special">[</phrase><phrase role="identifier">Index</phrase><phrase role="special">]);</phrase>
5129         <phrase role="special">})</phrase>
5130     <phrase role="special">;</phrase>
5131
5132     <phrase role="comment">// Function body (executed after preconditions checked).</phrase>
5133     <phrase role="keyword">return</phrase> <phrase role="special">*(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect</phrase><phrase role="special">[</phrase><phrase role="identifier">Index</phrase><phrase role="special">]);</phrase> <phrase role="comment">// ...result initialized here instead.</phrase>
5134 <phrase role="special">}</phrase>
5135 </programlisting>
5136       </para>
5137       <para>
5138         In this example the return type is a reference so it does not have default
5139         constructor that can be used to initialize <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput>
5140         when it is declared before the contract declaration. In addition, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Index</phrase></computeroutput> needs to be validated to be smaller
5141         than <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">size</phrase><phrase role="special">()</phrase></computeroutput>
5142         by the precondition before it can be used to retrieve the reference to assign
5143         to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> so <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">vect</phrase><phrase role="special">[</phrase><phrase role="identifier">Index</phrase><phrase role="special">]</phrase></computeroutput> cannot be used to initialize <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> when it is declared before the contract
5144         declaration. Therefore, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput>
5145         is used to defer <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> real
5146         initialization until the execution of the function body, after the contract
5147         declaration, where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Index</phrase></computeroutput>
5148         has been validated by the precondition and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">vect</phrase><phrase role="special">[</phrase><phrase role="identifier">Index</phrase><phrase role="special">]</phrase></computeroutput> can be safely evaluated to initialize <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput>.
5149       </para>
5150       <para>
5151         As seen in <link linkend="boost_contract.tutorial.return_values">Return Values</link>,
5152         it is the responsibility of the programmers to ensure that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> is always set to the return value
5153         (when the function exits without trowing an exception). This also ensures
5154         that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> is always set
5155         before the postconditions are checked so programmers can always dereference
5156         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> in postconditions
5157         to access the return value (using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">operator</phrase><phrase role="special">*</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">operator</phrase><phrase role="special">-&gt;</phrase></computeroutput> as usual with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput>,
5158         and without having to explicitly check if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput>
5159         is an empty <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput> object or not). This can be done
5160         ensuring that <emphasis>all</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">return</phrase></computeroutput>
5161         statements in the function are of the form:
5162       </para>
5163 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><literal moreinfo="none"><emphasis>return-type</emphasis></literal><phrase role="special">&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
5164 <phrase role="special">...</phrase>
5165 <phrase role="keyword">return</phrase> <phrase role="special">*(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <literal moreinfo="none"><emphasis>return-expression</emphasis></literal><phrase role="special">);</phrase> <phrase role="comment">// Assign `result` at each return.</phrase>
5166 </programlisting>
5167       <bridgehead renderas="sect4" id="boost_contract.advanced.optional_return_values.h0">
5168         <phrase id="boost_contract.advanced.optional_return_values.optional_results_in_virtual_public_functions"/><link linkend="boost_contract.advanced.optional_return_values.optional_results_in_virtual_public_functions">Optional
5169         Results in Virtual Public Functions</link>
5170       </bridgehead>
5171       <para>
5172         Similarly, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput> can be used to handle the return
5173         value passed to contracts of virtual public functions (pure or not) and of
5174         public function overrides. As seen in <link linkend="boost_contract.advanced.pure_virtual_public_functions">Pure
5175         Virtual Public Functions</link>, <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
5176         Public Functions</link>, and <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
5177         Function Overrides</link>, in these cases the return value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">result</phrase></computeroutput> must be passed as a parameter to
5178         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5179         right after the parameter <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput>
5180         of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase></computeroutput>. Then the functor passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase></computeroutput> takes one single parameter of type
5181         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase></computeroutput><literal moreinfo="none"><emphasis>return-type</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">
5182         <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase>
5183         <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput>.
5184         For example (see <ulink url="../../example/features/optional_result_virtual.cpp"><literal moreinfo="none">optional_result_virtual.cpp</literal></ulink>):
5185       </para>
5186       <para>
5187 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
5188 <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">accessible</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">index</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5189     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
5190     <phrase role="comment">// Pass `result` right after `v`...</phrase>
5191     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
5192         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5193             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
5194         <phrase role="special">})</phrase>
5195         <phrase role="comment">// ...plus postconditions take `result` as a parameter (not capture).</phrase>
5196         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5197             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="identifier">index</phrase><phrase role="special">));</phrase>
5198         <phrase role="special">})</phrase>
5199     <phrase role="special">;</phrase>
5200
5201     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
5202     <phrase role="keyword">return</phrase> <phrase role="special">*</phrase><phrase role="identifier">result</phrase><phrase role="special">;</phrase>
5203 <phrase role="special">}</phrase>
5204 </programlisting>
5205       </para>
5206       <para>
5207         The inner <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput>
5208         in the postcondition functor parameter type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;...</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="special">...</phrase></computeroutput>
5209         is mandatory (while the outer <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput> in the postcondition functor parameter
5210         type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;...&gt;</phrase>
5211         <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput>
5212         is not). <footnote id="boost_contract.advanced.optional_return_values.f1">
5213         <para>
5214           <emphasis role="bold">Rationale:</emphasis> This library requires the postcondition
5215           functor parameter to be of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;...</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase></computeroutput> so the return value does not have
5216           to be copied (because of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&amp;</phrase></computeroutput>)
5217           while postconditions are still not allowed to change its value (because
5218           of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>, see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
5219           In addition, programmers are encouraged to declare the postcondition functor
5220           to take its argument also as a constant reference <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;...</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput> to avoid possibly expensive copies
5221           of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase></computeroutput> type itself.
5222         </para>
5223         </footnote>
5224       </para>
5225     </section>
5226     <section id="boost_contract.advanced.private_and_protected_functions">
5227       <title><link linkend="boost_contract.advanced.private_and_protected_functions">Private
5228       and Protected Functions</link></title>
5229       <para>
5230         Private and protected functions do not check class invariants (because they
5231         are not part of the public class interface) and they do not subcontract (because
5232         they are not accessible at the calling site where the <ulink url="http://en.wikipedia.org/wiki/Liskov_substitution_principle">substitution
5233         principle</ulink> applies, see <link linkend="boost_contract.contract_programming_overview.function_calls">Function
5234         Calls</link>). However, programmers may still want to specify preconditions
5235         and postconditions for private and protected functions when they want to
5236         check correctness of their implementation and use (from within the class,
5237         base classes, friend classes or functions, etc.). When programmers decide
5238         to specify contracts for private and protected functions, they can use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5239         (because, like for non-member functions, this does not check class invariants
5240         and does not subcontract). For example (see <ulink url="../../example/features/private_protected.cpp"><literal moreinfo="none">private_protected.cpp</literal></ulink>):
5241       </para>
5242       <para>
5243 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">counter</phrase> <phrase role="special">{</phrase>
5244 <phrase role="keyword">protected</phrase><phrase role="special">:</phrase> <phrase role="comment">// Protected functions use `function()` (like non-members).</phrase>
5245     <phrase role="keyword">void</phrase> <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5246         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5247             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5248                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
5249             <phrase role="special">})</phrase>
5250             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5251                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
5252             <phrase role="special">})</phrase>
5253         <phrase role="special">;</phrase>
5254
5255         <phrase role="identifier">n_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
5256     <phrase role="special">}</phrase>
5257
5258 <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="comment">// Private functions use `function()` (like non-members).</phrase>
5259     <phrase role="keyword">void</phrase> <phrase role="identifier">dec</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
5260         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_get</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">());</phrase>
5261         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5262             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5263                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
5264                         <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">min</phrase><phrase role="special">());</phrase>
5265             <phrase role="special">})</phrase>
5266             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5267                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_get</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
5268             <phrase role="special">})</phrase>
5269         <phrase role="special">;</phrase>
5270
5271         <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
5272     <phrase role="special">}</phrase>
5273
5274     <phrase role="keyword">int</phrase> <phrase role="identifier">n_</phrase><phrase role="special">;</phrase>
5275
5276     <phrase role="comment">/* ... */</phrase>
5277 </programlisting>
5278       </para>
5279       <para>
5280         Considerations made in <link linkend="boost_contract.tutorial.non_member_functions">Non-Member
5281         Functions</link> apply to private and protected functions as well. See <link linkend="boost_contract.tutorial.constructors">Constructors</link> and <link linkend="boost_contract.tutorial.destructors">Destructors</link> on how to
5282         program contracts for private and protected constructors and destructors
5283         instead.
5284       </para>
5285       <bridgehead renderas="sect4" id="boost_contract.advanced.private_and_protected_functions.h0">
5286         <phrase id="boost_contract.advanced.private_and_protected_functions.virtual_private_and_protected_functions"/><link linkend="boost_contract.advanced.private_and_protected_functions.virtual_private_and_protected_functions">Virtual
5287         Private and Protected Functions</link>
5288       </bridgehead>
5289       <para>
5290         When private and protected functions are virtual they should still declare
5291         the extra virtual parameter of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase></computeroutput> with default value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">0</phrase></computeroutput>
5292         (see <link linkend="boost_contract.tutorial.virtual_public_functions">Virtual
5293         Public Functions</link>) even if that parameter does not have to be passed
5294         to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
5295         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5296         takes no such an argument (so the extra virtual parameter will remain unused
5297         and it does not need a name). <footnote id="boost_contract.advanced.private_and_protected_functions.f0">
5298         <para>
5299           Technically, the extra virtual parameter can still be passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput> but that is
5300           not necessary and it has no effect so it is not done in this documentation.
5301         </para>
5302         </footnote> That is necessary otherwise the private and protected virtual
5303         functions cannot be overridden by public functions in derived classes that
5304         specify contracts (because the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase></computeroutput>
5305         parameter has to be part of signatures for public function overrides). For
5306         example (see <ulink url="../../example/features/private_protected_virtual.cpp"><literal moreinfo="none">private_protected_virtual.cpp</literal></ulink>):
5307       </para>
5308       <para>
5309 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">counter</phrase> <phrase role="special">{</phrase>
5310     <phrase role="comment">// Virtual private and protected functions still declare extra</phrase>
5311     <phrase role="comment">// `virtual_* = 0` parameter (otherwise they cannot be overridden), but...</phrase>
5312 <phrase role="keyword">protected</phrase><phrase role="special">:</phrase>
5313     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5314         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase> <phrase role="comment">// ...no `v`.</phrase>
5315             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5316                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
5317             <phrase role="special">})</phrase>
5318             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5319                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
5320             <phrase role="special">})</phrase>
5321         <phrase role="special">;</phrase>
5322
5323         <phrase role="identifier">n_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
5324     <phrase role="special">}</phrase>
5325
5326 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
5327     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">dec</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5328         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_get</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">());</phrase> <phrase role="comment">// ...no `v`.</phrase>
5329         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase> <phrase role="comment">// ...no `v`.</phrase>
5330             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5331                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
5332                         <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">min</phrase><phrase role="special">());</phrase>
5333             <phrase role="special">})</phrase>
5334             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5335                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_get</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
5336             <phrase role="special">})</phrase>
5337         <phrase role="special">;</phrase>
5338
5339         <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
5340     <phrase role="special">}</phrase>
5341
5342     <phrase role="keyword">int</phrase> <phrase role="identifier">n_</phrase><phrase role="special">;</phrase>
5343
5344     <phrase role="comment">/* ... */</phrase>
5345 </programlisting>
5346       </para>
5347       <para>
5348         However, public functions in derived classes overriding private or protected
5349         virtual functions from base classes shall not specify the extra <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput>
5350         template parameter to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5351         because the overridden functions are private or protected and, not being
5352         public, they do not participate to subcontracting (this library will generate
5353         a compile-time error if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput> is specified because there will be no
5354         virtual <emphasis>public</emphasis> function to override from the base class).
5355         For example (see <ulink url="../../example/features/private_protected_virtual.cpp"><literal moreinfo="none">private_protected_virtual.cpp</literal></ulink>):
5356       </para>
5357       <para>
5358 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">counter10</phrase>
5359     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">counter</phrase>
5360     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
5361 <phrase role="special">{</phrase>
5362 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5363     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
5364     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
5365
5366     <phrase role="comment">// Overriding from non-public members so no subcontracting, no override_...</phrase>
5367
5368     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5369         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
5370             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5371                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">%</phrase> <phrase role="number">10</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
5372             <phrase role="special">})</phrase>
5373             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5374                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
5375             <phrase role="special">})</phrase>
5376         <phrase role="special">;</phrase>
5377
5378         <phrase role="identifier">counter</phrase><phrase role="special">::</phrase><phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">);</phrase>
5379     <phrase role="special">}</phrase>
5380
5381     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">dec</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5382         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_get</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">get</phrase><phrase role="special">());</phrase>
5383         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
5384             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5385                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
5386                         <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="number">10</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">min</phrase><phrase role="special">());</phrase>
5387             <phrase role="special">})</phrase>
5388             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5389                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_get</phrase> <phrase role="special">-</phrase> <phrase role="number">10</phrase><phrase role="special">);</phrase>
5390             <phrase role="special">})</phrase>
5391         <phrase role="special">;</phrase>
5392
5393         <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="number">10</phrase><phrase role="special">);</phrase>
5394     <phrase role="special">}</phrase>
5395
5396     <phrase role="comment">/* ... */</phrase>
5397 </programlisting>
5398       </para>
5399       <para>
5400         Furthermore, using multiple inheritance it is possible to override functions
5401         that are private or protected from one base but public from another base.
5402         In this case, public function overrides in derived classes will specify the
5403         extra <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput>
5404         template parameter to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5405         (because the overridden functions are private or protected in one base and
5406         those do not participate to subcontracting, but public in another base and
5407         these participate to subcontracting instead). For example (see <ulink url="../../example/features/private_protected_virtual_multi.cpp"><literal moreinfo="none">private_protected_virtual_multi.cpp</literal></ulink>):
5408       </para>
5409       <para>
5410 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">countable</phrase> <phrase role="special">{</phrase>
5411 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5412     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
5413         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
5414     <phrase role="special">}</phrase>
5415
5416     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">dec</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5417     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5418     <phrase role="keyword">virtual</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">get</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5419 <phrase role="special">};</phrase>
5420
5421 <phrase role="comment">/* ... */</phrase>
5422 </programlisting>
5423       </para>
5424       <para>
5425 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">counter10</phrase>
5426     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">countable</phrase><phrase role="special">,</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">counter</phrase> <phrase role="comment">// Multiple inheritance.</phrase>
5427     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
5428 <phrase role="special">{</phrase>
5429 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5430     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
5431     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
5432
5433     <phrase role="comment">// Overriding from public members from `countable` so use `override_...`.</phrase>
5434
5435     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5436         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
5437                 <phrase role="identifier">override_set</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">counter10</phrase><phrase role="special">::</phrase><phrase role="identifier">set</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
5438             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5439                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">%</phrase> <phrase role="number">10</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
5440             <phrase role="special">})</phrase>
5441             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5442                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
5443             <phrase role="special">})</phrase>
5444         <phrase role="special">;</phrase>
5445
5446         <phrase role="identifier">counter</phrase><phrase role="special">::</phrase><phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">);</phrase>
5447     <phrase role="special">}</phrase>
5448
5449     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">dec</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5450         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_get</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">get</phrase><phrase role="special">());</phrase>
5451         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
5452                 <phrase role="identifier">override_dec</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">counter10</phrase><phrase role="special">::</phrase><phrase role="identifier">dec</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
5453             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5454                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
5455                         <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="number">10</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">min</phrase><phrase role="special">());</phrase>
5456             <phrase role="special">})</phrase>
5457             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5458                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_get</phrase> <phrase role="special">-</phrase> <phrase role="number">10</phrase><phrase role="special">);</phrase>
5459             <phrase role="special">})</phrase>
5460         <phrase role="special">;</phrase>
5461
5462         <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="number">10</phrase><phrase role="special">);</phrase>
5463     <phrase role="special">}</phrase>
5464
5465     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">set</phrase><phrase role="special">,</phrase> <phrase role="identifier">dec</phrase><phrase role="special">)</phrase>
5466
5467     <phrase role="comment">/* ... */</phrase>
5468 </programlisting>
5469       </para>
5470       <warning>
5471         <para>
5472           Unfortunately, the code above does not compile on MSVC (at least up to
5473           Visual Studio 2015) because MSVC incorrectly gives a compile-time error
5474           when SFINAE fails due to private or protected access levels. Instead, GCC
5475           and Clang correctly implement SFINAE failures due to private and protected
5476           functions so the code above correctly complies on GCC and Clang. Therefore,
5477           currently it is not possible to override a function that is public in one
5478           base but private or protected in other base using this library on MSVC
5479           (at least up to Visual Studio 2015), but that can correctly be done on
5480           GCC or Clang instead.
5481         </para>
5482       </warning>
5483     </section>
5484     <section id="boost_contract.advanced.friend_functions">
5485       <title><link linkend="boost_contract.advanced.friend_functions">Friend Functions</link></title>
5486       <para>
5487         In general, friend functions are not member functions so <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5488         is used to program their contracts and all considerations made in <link linkend="boost_contract.tutorial.non_member_functions">Non-Member
5489         Functions</link> apply. For example (see <ulink url="../../example/features/friend.cpp"><literal moreinfo="none">friend.cpp</literal></ulink>):
5490       </para>
5491       <para>
5492 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">buffer</phrase><phrase role="special">;</phrase>
5493
5494 <phrase role="keyword">class</phrase> <phrase role="identifier">byte</phrase> <phrase role="special">{</phrase>
5495     <phrase role="keyword">friend</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase><phrase role="identifier">buffer</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">byte</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">);</phrase>
5496
5497 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
5498     <phrase role="keyword">char</phrase> <phrase role="identifier">value_</phrase><phrase role="special">;</phrase>
5499
5500     <phrase role="comment">/* ... */</phrase>
5501 </programlisting>
5502       </para>
5503       <para>
5504 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">buffer</phrase> <phrase role="special">{</phrase>
5505     <phrase role="comment">// Friend functions are not member functions...</phrase>
5506     <phrase role="keyword">friend</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase><phrase role="identifier">buffer</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">byte</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5507         <phrase role="comment">// ...so check contracts via `function` (which won't check invariants).</phrase>
5508         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5509             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5510                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
5511                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
5512             <phrase role="special">})</phrase>
5513         <phrase role="special">;</phrase>
5514
5515         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase> <phrase role="identifier">x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">values_</phrase><phrase role="special">.</phrase><phrase role="identifier">c_str</phrase><phrase role="special">();</phrase> <phrase role="special">*</phrase><phrase role="identifier">x</phrase> <phrase role="special">!=</phrase> <phrase role="char">'\0'</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5516             <phrase role="keyword">if</phrase><phrase role="special">(*</phrase><phrase role="identifier">x</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">value_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
5517         <phrase role="special">}</phrase>
5518         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
5519     <phrase role="special">}</phrase>
5520
5521 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
5522     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">values_</phrase><phrase role="special">;</phrase>
5523
5524     <phrase role="comment">/* ... */</phrase>
5525 </programlisting>
5526       </para>
5527       <para>
5528         However, in some cases a friend function might take an object as parameter
5529         and it can be logically considered an extension of that object's public interface
5530         (essentially at the same level as the object's public functions). In these
5531         cases, programmers might chose to program the friend function contracts using
5532         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5533         (instead of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>)
5534         so to also check the class invariants of the object passed as parameter (and
5535         not just pre- and postconditions). For example (see <ulink url="../../example/features/friend_invariant.cpp"><literal moreinfo="none">friend_invariant.cpp</literal></ulink>):
5536         <footnote id="boost_contract.advanced.friend_functions.f0">
5537         <para>
5538           <emphasis role="bold">Rationale:</emphasis> Contract programming proposals
5539           for C++ like <link linkend="N1962_anchor">[N1962]</link> do not provide
5540           a mechanism for friend functions to check class invariants of objects passed
5541           as parameters. In other words, these proposals do not enable contracts
5542           to recognize that in C++ some friend functions logically act as if they
5543           were part of the public interface of the objects they take as parameters.
5544           This is reasonable for proposals that add contracts to the core language
5545           because friend functions are not always meant to extend an object public
5546           interface and C++ does not provide a mechanism to programmatically specify
5547           when they do and when they do not. However, this library provides the flexibility
5548           to let programmers manually specify when friend functions should also check
5549           class invariants of the objects they take as parameters (using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>)
5550           and when they should not (using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5551           instead).
5552         </para>
5553         </footnote>
5554       </para>
5555       <para>
5556 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
5557 <phrase role="keyword">class</phrase> <phrase role="identifier">positive</phrase> <phrase role="special">{</phrase>
5558 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5559     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
5560         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
5561     <phrase role="special">}</phrase>
5562
5563     <phrase role="comment">// Can be considered an extension of enclosing class' public interface...</phrase>
5564     <phrase role="keyword">friend</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">positive</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">object</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5565         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_object_value</phrase> <phrase role="special">=</phrase>
5566                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">object</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">());</phrase>
5567         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
5568         <phrase role="comment">// ...so it can be made to check invariants via `public_function`.</phrase>
5569         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">object</phrase><phrase role="special">)</phrase>
5570             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5571                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
5572             <phrase role="special">})</phrase>
5573             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5574                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">object</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_value</phrase><phrase role="special">);</phrase>
5575                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_object_value</phrase><phrase role="special">);</phrase>
5576             <phrase role="special">})</phrase>
5577         <phrase role="special">;</phrase>
5578
5579         <phrase role="identifier">T</phrase> <phrase role="identifier">saved</phrase> <phrase role="special">=</phrase> <phrase role="identifier">object</phrase><phrase role="special">.</phrase><phrase role="identifier">value_</phrase><phrase role="special">;</phrase>
5580         <phrase role="identifier">object</phrase><phrase role="special">.</phrase><phrase role="identifier">value_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
5581         <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">saved</phrase><phrase role="special">;</phrase>
5582     <phrase role="special">}</phrase>
5583
5584 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
5585     <phrase role="identifier">T</phrase> <phrase role="identifier">value_</phrase><phrase role="special">;</phrase>
5586
5587     <phrase role="comment">/* ... */</phrase>
5588 </programlisting>
5589       </para>
5590       <para>
5591         This technique can also be extended to friend functions that take multiple
5592         objects as parameters and can be logically considered extensions to the public
5593         interfaces of each of these objects. For example:
5594       </para>
5595 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Can be considered an extension of multiple objects' public interfaces.</phrase>
5596 <phrase role="keyword">friend</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">class1</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">object1</phrase><phrase role="special">,</phrase> <phrase role="identifier">class2</phrase><phrase role="special">*</phrase> <phrase role="identifier">object2</phrase><phrase role="special">,</phrase> <phrase role="identifier">type3</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value3</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5597     <phrase role="comment">// Check preconditions.</phrase>
5598     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">pre</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5599         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5600             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">object2</phrase> <phrase role="special">!=</phrase> <phrase role="keyword">nullptr</phrase><phrase role="special">);</phrase>
5601             <phrase role="special">...</phrase>
5602         <phrase role="special">})</phrase>
5603     <phrase role="special">;</phrase>
5604     <phrase role="comment">// Check class invariants for each object (programmers chose the order).</phrase>
5605     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">inv1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">object1</phrase><phrase role="special">);</phrase>
5606     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">inv2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">object2</phrase><phrase role="special">);</phrase>
5607     <phrase role="comment">// Check postconditions and exception guarantees.</phrase>
5608     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">postex</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5609         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase>
5610         <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(...)</phrase>
5611     <phrase role="special">;</phrase>
5612
5613     <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
5614 <phrase role="special">}</phrase>
5615 </programlisting>
5616       <para>
5617         Changing the order of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
5618         declarations above, programmers can chose the order for checking class invariants
5619         among the different objects passed to the friend function and also whether
5620         to check these invariants before or after preconditions, postconditions,
5621         and exception guarantees of the friend function (see <link linkend="boost_contract.tutorial.non_member_functions">Non-Member
5622         Functions</link> and <link linkend="boost_contract.tutorial.public_functions">Public
5623         Functions</link> for information on how the RAII objects returned by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5624         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5625         check contract conditions). The example above is programmed to check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">class1</phrase></computeroutput> invariants before <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">class2</phrase></computeroutput> invariants (but that order could
5626         have been inverted if programmers so chose).
5627       </para>
5628       <note>
5629         <para>
5630           In the example above, preconditions are intentionally programmed to be
5631           checked before class invariants so the objects passed to the friend function
5632           can be validated by the preconditions before they are passed as pointers
5633           to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5634           (e.g., check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">object2</phrase></computeroutput> is
5635           not null). (Within member functions instead, the object pointer <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput> is always well-formed, its validation
5636           is never needed, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5637           checks class invariants before checking preconditions so programming preconditions
5638           can be simplified assuming the class invariants are satisfied already,
5639           see <link linkend="boost_contract.contract_programming_overview.public_function_calls">Public
5640           Function Calls</link>.)
5641         </para>
5642       </note>
5643     </section>
5644     <section id="boost_contract.advanced.function_overloads">
5645       <title><link linkend="boost_contract.advanced.function_overloads">Function
5646       Overloads</link></title>
5647       <para>
5648         No special attention is required when using this library with overloaded
5649         functions or constructors. The only exception is for the function pointer
5650         passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5651         from public function overrides (see <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
5652         Function Overrides</link>). When the name of public function override are
5653         also overloaded, the related function pointer cannot be automatically deduced
5654         by the compiler so programmers have to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static_cast</phrase></computeroutput>
5655         to resolve ambiguities (as usual with pointers to overloaded functions in
5656         C++). <footnote id="boost_contract.advanced.function_overloads.f0">
5657         <para>
5658           <emphasis role="bold">Rationale:</emphasis> In order to avoid copies, this
5659           library takes all function arguments and the return value passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5660           as references when used within public function overrides. Therefore, the
5661           library cannot differentiate when the actual function argument and return
5662           types are passed by reference and when they are not. As a result, the library
5663           cannot automatically reconstruct the type of the enclosing public function
5664           so this type must be deduced from the function pointer passed by programmers
5665           to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>.
5666           When this automatic deduction is not possible due to overloaded function
5667           names, programmers must explicitly use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static_cast</phrase></computeroutput>
5668           to resolve ambiguities as usual in C++ with pointers to overloaded functions.
5669         </para>
5670         </footnote> For example, note how <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static_cast</phrase></computeroutput>
5671         is used in the following calls to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5672         (see <ulink url="../../example/features/overload.cpp"><literal moreinfo="none">overload.cpp</literal></ulink>):
5673       </para>
5674       <para>
5675 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">string_lines</phrase>
5676     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">lines</phrase>
5677     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
5678 <phrase role="special">{</phrase>
5679 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
5680     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
5681     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
5682
5683     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">str</phrase><phrase role="special">)</phrase> <phrase role="comment">// Invoked only once for all `str` overloads.</phrase>
5684
5685     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">str</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5686         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
5687         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
5688                 <phrase role="identifier">override_str</phrase><phrase role="special">&gt;(</phrase>
5689             <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase>
5690             <phrase role="comment">// `static_cast` resolves overloaded function pointer ambiguities.</phrase>
5691             <phrase role="keyword">static_cast</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">(</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::*)(</phrase>
5692                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*)</phrase> <phrase role="keyword">const</phrase><phrase role="special">&gt;(&amp;</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::</phrase><phrase role="identifier">str</phrase><phrase role="special">),</phrase>
5693             <phrase role="keyword">this</phrase>
5694         <phrase role="special">);</phrase>
5695
5696         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">str_</phrase><phrase role="special">;</phrase>
5697     <phrase role="special">}</phrase>
5698
5699     <phrase role="comment">// Overload on (absence of) `const` qualifier.</phrase>
5700     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">str</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5701         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
5702                 <phrase role="identifier">override_str</phrase><phrase role="special">&gt;(</phrase>
5703             <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">str_</phrase><phrase role="special">,</phrase>
5704             <phrase role="comment">// `static_cast` resolves overloaded function pointer ambiguities.</phrase>
5705             <phrase role="keyword">static_cast</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">&amp;</phrase> <phrase role="special">(</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::*)(</phrase>
5706                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*)&gt;(&amp;</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::</phrase><phrase role="identifier">str</phrase><phrase role="special">),</phrase>
5707             <phrase role="keyword">this</phrase>
5708         <phrase role="special">);</phrase>
5709
5710         <phrase role="keyword">return</phrase> <phrase role="identifier">str_</phrase><phrase role="special">;</phrase>
5711     <phrase role="special">}</phrase>
5712
5713     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">put</phrase><phrase role="special">)</phrase> <phrase role="comment">// Invoked only once for all `put` overloads.</phrase>
5714
5715     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase>
5716             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5717         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_str</phrase> <phrase role="special">=</phrase>
5718                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">str</phrase><phrase role="special">());</phrase>
5719         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
5720                 <phrase role="identifier">override_put</phrase><phrase role="special">&gt;(</phrase>
5721             <phrase role="identifier">v</phrase><phrase role="special">,</phrase>
5722             <phrase role="comment">// `static_cast` resolves overloaded function pointer ambiguities.</phrase>
5723             <phrase role="keyword">static_cast</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::*)(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase>
5724                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*)&gt;(&amp;</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::</phrase><phrase role="identifier">put</phrase><phrase role="special">),</phrase>
5725             <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">x</phrase>
5726         <phrase role="special">)</phrase>
5727             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5728                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_str</phrase> <phrase role="special">+</phrase> <phrase role="identifier">x</phrase> <phrase role="special">+</phrase> <phrase role="char">'\n'</phrase><phrase role="special">);</phrase>
5729             <phrase role="special">})</phrase>
5730         <phrase role="special">;</phrase>
5731
5732         <phrase role="identifier">str_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">str_</phrase> <phrase role="special">+</phrase> <phrase role="identifier">x</phrase> <phrase role="special">+</phrase> <phrase role="char">'\n'</phrase><phrase role="special">;</phrase>
5733     <phrase role="special">}</phrase>
5734
5735     <phrase role="comment">// Overload on argument type.</phrase>
5736     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5737         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_str</phrase> <phrase role="special">=</phrase>
5738                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">str</phrase><phrase role="special">());</phrase>
5739         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
5740                 <phrase role="identifier">override_put</phrase><phrase role="special">&gt;(</phrase>
5741             <phrase role="identifier">v</phrase><phrase role="special">,</phrase>
5742             <phrase role="comment">// `static_cast` resolves overloaded function pointer ambiguities.</phrase>
5743             <phrase role="keyword">static_cast</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">,</phrase>
5744                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*)&gt;(&amp;</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::</phrase><phrase role="identifier">put</phrase><phrase role="special">),</phrase>
5745             <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">x</phrase>
5746         <phrase role="special">)</phrase>
5747             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5748                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_str</phrase> <phrase role="special">+</phrase> <phrase role="identifier">x</phrase> <phrase role="special">+</phrase> <phrase role="char">'\n'</phrase><phrase role="special">);</phrase>
5749             <phrase role="special">})</phrase>
5750         <phrase role="special">;</phrase>
5751
5752         <phrase role="identifier">str_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">str_</phrase> <phrase role="special">+</phrase> <phrase role="identifier">x</phrase> <phrase role="special">+</phrase> <phrase role="char">'\n'</phrase><phrase role="special">;</phrase>
5753     <phrase role="special">}</phrase>
5754
5755     <phrase role="comment">// Overload on argument type and arity (also with default parameter).</phrase>
5756     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">tab</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">,</phrase>
5757             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
5758         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_str</phrase> <phrase role="special">=</phrase>
5759                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">str</phrase><phrase role="special">());</phrase>
5760         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
5761                 <phrase role="identifier">override_put</phrase><phrase role="special">&gt;(</phrase>
5762             <phrase role="identifier">v</phrase><phrase role="special">,</phrase>
5763             <phrase role="comment">// `static_cast` resolves overloaded function pointer ambiguities.</phrase>
5764             <phrase role="keyword">static_cast</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase><phrase role="special">,</phrase>
5765                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*)&gt;(&amp;</phrase><phrase role="identifier">string_lines</phrase><phrase role="special">::</phrase><phrase role="identifier">put</phrase><phrase role="special">),</phrase>
5766             <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="identifier">tab</phrase>
5767         <phrase role="special">)</phrase>
5768             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5769                 <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostringstream</phrase> <phrase role="identifier">s</phrase><phrase role="special">;</phrase>
5770                 <phrase role="identifier">s</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase>
5771                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
5772                         <phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_str</phrase> <phrase role="special">+</phrase> <phrase role="special">(</phrase><phrase role="identifier">tab</phrase> <phrase role="special">?</phrase> <phrase role="string">"\t"</phrase> <phrase role="special">:</phrase> <phrase role="string">""</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="char">'\n'</phrase><phrase role="special">);</phrase>
5773             <phrase role="special">})</phrase>
5774         <phrase role="special">;</phrase>
5775
5776         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostringstream</phrase> <phrase role="identifier">s</phrase><phrase role="special">;</phrase>
5777         <phrase role="identifier">s</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">str_</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase><phrase role="identifier">tab</phrase> <phrase role="special">?</phrase> <phrase role="string">"\t"</phrase> <phrase role="special">:</phrase> <phrase role="string">""</phrase><phrase role="special">)</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">x</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="char">'\n'</phrase><phrase role="special">;</phrase>
5778         <phrase role="identifier">str_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">();</phrase>
5779     <phrase role="special">}</phrase>
5780
5781 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
5782     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">str_</phrase><phrase role="special">;</phrase>
5783 <phrase role="special">};</phrase>
5784 </programlisting>
5785       </para>
5786       <para>
5787         Overloaded functions have the same function name so the same <literal moreinfo="none">override_<emphasis>function-name</emphasis></literal>
5788         type can be reused as template parameter for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
5789         calls in a given class. Therefore, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
5790         only needs to be invoked once for a function name in a given class, even
5791         when that function name is overloaded.
5792       </para>
5793     </section>
5794     <section id="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">
5795       <title><link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">Lambdas,
5796       Loops, Code Blocks (and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput>)</link></title>
5797       <para>
5798         While contracts are usually most useful to program specifications of functions
5799         and class interfaces, this library also allows to check contract conditions
5800         for implementation code (lambda functions, loops, code blocks, etc.).
5801       </para>
5802       <para>
5803         Lambda functions are not member functions, they are not part of class public
5804         interfaces so they do not check class invariants and they do not subcontract.
5805         They can use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5806         to specify preconditions, postconditions, and exception guarantees (considerations
5807         made in <link linkend="boost_contract.tutorial.non_member_functions">Non-Member
5808         Functions</link> apply). For example (see <ulink url="../../example/features/lambda.cpp"><literal moreinfo="none">lambda.cpp</literal></ulink>):
5809       </para>
5810       <para>
5811 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="identifier">total</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5812 <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">for_each</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">cbegin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">(),</phrase>
5813     <phrase role="comment">// Contract for a lambda function.</phrase>
5814     <phrase role="special">[&amp;</phrase><phrase role="identifier">total</phrase><phrase role="special">]</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5815         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_total</phrase> <phrase role="special">=</phrase>
5816                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">total</phrase><phrase role="special">);</phrase>
5817         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5818             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5819                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
5820                         <phrase role="identifier">total</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
5821             <phrase role="special">})</phrase>
5822             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5823                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">total</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_total</phrase> <phrase role="special">+</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
5824             <phrase role="special">})</phrase>
5825         <phrase role="special">;</phrase>
5826
5827         <phrase role="identifier">total</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="comment">// Lambda function body.</phrase>
5828     <phrase role="special">}</phrase>
5829 <phrase role="special">);</phrase>
5830 </programlisting>
5831       </para>
5832       <para>
5833         Similarly, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5834         can be used to program preconditions, postconditions, and exception guarantees
5835         for loops. For example, for a for-loop but same for while- and all other
5836         loops (see <ulink url="../../example/features/loop.cpp"><literal moreinfo="none">loop.cpp</literal></ulink>):
5837       </para>
5838       <para>
5839 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="identifier">total</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5840 <phrase role="comment">// Contract for a for-loop (same for while- and all other loops).</phrase>
5841 <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase> <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
5842     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_total</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">total</phrase><phrase role="special">);</phrase>
5843     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5844         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5845             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
5846                     <phrase role="identifier">total</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="special">*</phrase><phrase role="identifier">i</phrase><phrase role="special">);</phrase>
5847         <phrase role="special">})</phrase>
5848         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5849             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">total</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_total</phrase> <phrase role="special">+</phrase> <phrase role="special">*</phrase><phrase role="identifier">i</phrase><phrase role="special">);</phrase>
5850         <phrase role="special">})</phrase>
5851     <phrase role="special">;</phrase>
5852
5853     <phrase role="identifier">total</phrase> <phrase role="special">+=</phrase> <phrase role="special">*</phrase><phrase role="identifier">i</phrase><phrase role="special">;</phrase> <phrase role="comment">// For-loop body.</phrase>
5854 <phrase role="special">}</phrase>
5855 </programlisting>
5856       </para>
5857       <para>
5858         More in general, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>
5859         can be used to program preconditions, postconditions, and exception guarantees
5860         of any block of code in a given function. For example (see <ulink url="../../example/features/code_block.cpp"><literal moreinfo="none">code_block.cpp</literal></ulink>):
5861       </para>
5862       <para>
5863 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">/* ... */</phrase>
5864
5865 <phrase role="comment">// Contract for a code block.</phrase>
5866 <phrase role="special">{</phrase> <phrase role="comment">// Code block entry (check preconditions).</phrase>
5867     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_total</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">total</phrase><phrase role="special">);</phrase>
5868     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
5869         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5870             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase>
5871         <phrase role="special">})</phrase>
5872         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
5873             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">total</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_total</phrase> <phrase role="special">+</phrase> <phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">0</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]);</phrase>
5874         <phrase role="special">})</phrase>
5875     <phrase role="special">;</phrase>
5876
5877     <phrase role="identifier">total</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">0</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">];</phrase> <phrase role="comment">// Code block body.</phrase>
5878 <phrase role="special">}</phrase> <phrase role="comment">// Code block exit (check postconditions and exceptions guarantees).</phrase>
5879
5880 <phrase role="comment">/* ... */</phrase>
5881 </programlisting>
5882       </para>
5883       <para>
5884         The library does not support contracts for functions and classes declared
5885         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput>. <footnote id="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__.f0">
5886         <para>
5887           <emphasis role="bold">Rationale:</emphasis> In general, it might be useful
5888           to specify contracts for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput>
5889           functions and literal classes. However, the current implementation of this
5890           library cannot support contracts for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput>
5891           functions and classes because C++ does not currently allow <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput> functions to do the following:
5892           Declare local variables of (literal) types with non-trivial <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput> destructors (this RAII technique
5893           is used by this library to check invariants, postconditions, and exceptions
5894           guarantees at exit); Call other <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput>
5895           functions using try-catch statements (used by this library to report contract
5896           assertion failures and catch any other exception that might be thrown when
5897           evaluating the asserted conditions); Use lambda functions (used by this
5898           library for convenience to program functors that that check preconditions,
5899           postconditions, and exception guarantees). Also note that even if supported,
5900           contracts for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput> functions
5901           probably would not use old values (because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput>
5902           prevents functions from having any side effect visible to the caller and
5903           variables recording such side-effects are usually the candidates for old
5904           value copies) and subcontracting (because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">constexpr</phrase></computeroutput>
5905           functions cannot be virtual).
5906         </para>
5907         </footnote>
5908       </para>
5909     </section>
5910     <section id="boost_contract.advanced.implementation_checks">
5911       <title><link linkend="boost_contract.advanced.implementation_checks">Implementation
5912       Checks</link></title>
5913       <para>
5914         This library provides also a mechanism to check assertions within implementation
5915         code (differently from preconditions, postconditions, exceptions guarantees,
5916         and class invariants that are instead checked before or after code that implements
5917         a function body). These <emphasis>implementation checks</emphasis> are programmed
5918         using a nullary functor that is directly assigned to a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
5919         object declaration right at the place within the code where the checks need
5920         to be performed (without calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>,
5921         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>,
5922         etc. in this case). For example (see <ulink url="../../example/features/check.cpp"><literal moreinfo="none">check.cpp</literal></ulink>):
5923       </para>
5924       <para>
5925 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
5926     <phrase role="comment">// Implementation checks (via nullary functor).</phrase>
5927     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="special">[]</phrase> <phrase role="special">{</phrase>
5928         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">gcd</phrase><phrase role="special">(</phrase><phrase role="number">12</phrase><phrase role="special">,</phrase> <phrase role="number">28</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">4</phrase><phrase role="special">);</phrase>
5929         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">gcd</phrase><phrase role="special">(</phrase><phrase role="number">4</phrase><phrase role="special">,</phrase> <phrase role="number">14</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">2</phrase><phrase role="special">);</phrase>
5930     <phrase role="special">};</phrase>
5931
5932     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5933 <phrase role="special">}</phrase>
5934 </programlisting>
5935       </para>
5936       <para>
5937         The implementation check functor should capture all the variables that it
5938         needs for its assertions. These variables can be captured by value when the
5939         overhead of copying such variables is acceptable. In any case, programmers
5940         should not write implementation checks that modify the value of the captured
5941         variables, even when those are captured by reference (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
5942       </para>
5943       <para>
5944         Any code can be programmed in the implementation check functor, but it is
5945         recommended to keep this code simple using mainly assertions and if-statements
5946         (to avoid programming complex checks that might be buggy and also slow to
5947         check at run-time). It is also recommended to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
5948         to program the assertions because that enables this library to print informative
5949         error messages when the asserted conditions are evaluated to be false (note
5950         that this is not a variadic macro, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
5951         Macros</link>):
5952       </para>
5953 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">)</phrase>
5954 <phrase role="comment">// Or, if `boolean-condition` contains commas `,` not already within parenthesis `()`...</phrase>
5955 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">))</phrase> <phrase role="comment">// ...use extra parenthesis (not a variadic macro).</phrase>
5956 </programlisting>
5957       <para>
5958         This library will automatically call the failure handler <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check_failure">boost::contract::check_failure</link></computeroutput>
5959         if any of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
5960         conditions are false or, more in general, if calling the implementation check
5961         functor throws any exception. By default, this failure handler prints an
5962         error message to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput> and terminates the program calling
5963         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput> (see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
5964         on Failures</link> to change the failure handler to throw exceptions, exit
5965         the program with an error code, etc.).
5966       </para>
5967       <para>
5968         Similarly to the C-style <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput>
5969         macro that is disabled when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">NDEBUG</phrase></computeroutput>
5970         is defined, implementation checks are disabled when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput>
5971         is defined (see <link linkend="boost_contract.extras.disable_contract_checking">Disable
5972         Contract Checking</link>). That will skip all implementation checks at run-time
5973         but it will not eliminate some of the overhead of executing and compiling
5974         the related <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
5975         declarations. Alternatively, this library provides the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput>
5976         macro that allows to completely remove run- and compile-time overheads of
5977         implementation checks when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput>
5978         is defined (note that this is not a variadic macro):
5979       </para>
5980 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">)</phrase>
5981 <phrase role="comment">// Or, if `boolean-condition` contains commas `,` not already within parenthesis `()`...</phrase>
5982 <phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">((</phrase><literal moreinfo="none"><emphasis>boolean-condition</emphasis></literal><phrase role="special">))</phrase> <phrase role="comment">// ...use extra parenthesis (not a variadic macro).</phrase>
5983 </programlisting>
5984       <para>
5985         For example (see <ulink url="../../example/features/check_macro.cpp"><literal moreinfo="none">check_macro.cpp</literal></ulink>):
5986       </para>
5987       <para>
5988 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
5989     <phrase role="comment">// Implementation checks (via macro, disable run-/compile-time overhead).</phrase>
5990     <phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(</phrase><phrase role="identifier">gcd</phrase><phrase role="special">(</phrase><phrase role="number">12</phrase><phrase role="special">,</phrase> <phrase role="number">28</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">4</phrase><phrase role="special">);</phrase>
5991     <phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(</phrase><phrase role="identifier">gcd</phrase><phrase role="special">(</phrase><phrase role="number">4</phrase><phrase role="special">,</phrase> <phrase role="number">14</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">2</phrase><phrase role="special">);</phrase>
5992
5993     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
5994 <phrase role="special">}</phrase>
5995 </programlisting>
5996       </para>
5997       <para>
5998         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput>
5999         macro is similar to the C-style assert macro as it accepts a boolean condition
6000         (instead of a nullary functor like <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
6001         does). <footnote id="boost_contract.advanced.implementation_checks.f0">
6002         <para>
6003           Of course, nothing prevents programmers from calling functors within <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput> to specify
6004           boolean conditions when if-guards and other statements are required to
6005           assert the implementation checks. For example, programmers can use C++11
6006           lambda functions to define and call such functors in place where the implementation
6007           checks are specified:
6008 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">-&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="special">{</phrase>
6009     <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">even_numbers</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">gcd</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="identifier">y</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">2</phrase><phrase role="special">;</phrase>
6010     <phrase role="keyword">else</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">gcd</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="identifier">y</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">;</phrase>
6011 <phrase role="special">}</phrase> <phrase role="special">());</phrase>
6012 </programlisting>
6013         </para>
6014         </footnote> Using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput>
6015         is essentially equivalent to using the C-style <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput>
6016         macro a part from the following:
6017       </para>
6018       <itemizedlist>
6019         <listitem>
6020           <simpara>
6021             Implementation checks are disabled defining <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput>
6022             (instead of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">NDEBUG</phrase></computeroutput> for
6023             disabling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput>).
6024           </simpara>
6025         </listitem>
6026         <listitem>
6027           <simpara>
6028             If the asserted boolean condition is either false or it throws an exception
6029             then this library will call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check_failure">boost::contract::check_failure</link></computeroutput>
6030             (instead <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> calls
6031             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">abort</phrase></computeroutput> if the asserted condition is
6032             false and it unwinds the stack if evaluating the condition throws an
6033             exception).
6034           </simpara>
6035         </listitem>
6036         <listitem>
6037           <simpara>
6038             Implementation checks are automatically disabled when other contract
6039             conditions specified using this library are already being checked (to
6040             avoid infinite recursion, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999679376">BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION</link></computeroutput>).
6041           </simpara>
6042         </listitem>
6043       </itemizedlist>
6044     </section>
6045     <section id="boost_contract.advanced.old_values_copied_at_body">
6046       <title><link linkend="boost_contract.advanced.old_values_copied_at_body">Old
6047       Values Copied at Body</link></title>
6048       <para>
6049         In the examples seen so far, old value variables of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
6050         are initialized to a copy of the expression passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
6051         as soon as they are declared. That correctly happens before the function
6052         body is executed but also before the contract is declared, therefore even
6053         before class invariants (for public functions) and preconditions are checked
6054         at function entry. This might work well in most practical cases however,
6055         technically speaking, old values should be copied before executing the function
6056         body but <emphasis>after</emphasis> checking class invariants and preconditions
6057         at function entry (see <link linkend="boost_contract.contract_programming_overview.assertions">Assertions</link>).
6058         Specifically, there could be cases in which it makes sense to evaluate the
6059         expressions passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
6060         only under the assumption that assertions programmed in class invariants
6061         and preconditions are true.
6062       </para>
6063       <para>
6064         This library allows to construct <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
6065         variables using their default constructor (equivalent to a null pointer)
6066         and then to later assign them to a copy of the expression specified by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput> in a nullary
6067         functor <literal moreinfo="none"><emphasis>d</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>
6068         passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>d</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput>. The functor <literal moreinfo="none"><emphasis>d</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput> is called by this library before the function
6069         body is executed but only after class invariants and preconditions are checked.
6070         Old value assignments via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput>
6071         must appear after preconditions but before postconditions and exception guarantees
6072         wen these are all present (see <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>,
6073         <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>,
6074         and <link linkend="boost_contract.tutorial.exception_guarantees">Exception
6075         Guarantees</link>). <footnote id="boost_contract.advanced.old_values_copied_at_body.f0">
6076         <para>
6077           <emphasis role="bold">Rationale:</emphasis> Functors for preconditions,
6078           old value assignments, postconditions, and exception guarantees are all
6079           optional but when specified, they must be specified in that order. Such
6080           order is enforced by the fact that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.specify__idm45394999179040">boost::contract::specify_precondition_old_postcondition_except</link></computeroutput>,
6081           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.specify__idm45394999245856">boost::contract::specify_old_postcondition_except</link></computeroutput>,
6082           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.specify__idm45394999207792">boost::contract::specify_postcondition_except</link></computeroutput>,
6083           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.specify_except">boost::contract::specify_except</link></computeroutput>,
6084           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.specify_nothing">boost::contract::specify_nothing</link></computeroutput>
6085           provide a progressively smaller subset of their <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>,
6086           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase></computeroutput>,
6087           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(...)</phrase></computeroutput> member functions. The enforced order
6088           for specifying preconditions, old value assignments, postconditions, and
6089           exception guarantees makes logical sense because it follows the order at
6090           which these are executed at run-time. Other contract programming frameworks
6091           allow to mix this order, that could have been implemented for this library
6092           as well but it would have complicated somewhat the library implementation
6093           while adding no real value (arguably creating confusion in user code by
6094           not enforcing a consistent order for specifying contract conditions).
6095         </para>
6096         </footnote>
6097       </para>
6098       <para>
6099         For example, the following old value expression <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">s</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">]</phrase></computeroutput> passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
6100         is valid only after the precondition has checked that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">index</phrase></computeroutput>
6101         is within the valid range <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">index</phrase>
6102         <phrase role="special">&lt;</phrase> <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase></computeroutput>.
6103         Therefore, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">old_char</phrase></computeroutput> is first
6104         declared using its default constructor (i.e., initialized to a null pointer)
6105         and later assigned to a copy of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">s</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">]</phrase></computeroutput> in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput>
6106         after the precondition has checked <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">index</phrase></computeroutput>
6107         (see <ulink url="../../example/features/old.cpp"><literal moreinfo="none">old.cpp</literal></ulink>):
6108       </para>
6109       <para>
6110 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase> <phrase role="identifier">replace</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">s</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">index</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6111     <phrase role="keyword">char</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
6112     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_char</phrase><phrase role="special">;</phrase> <phrase role="comment">// Null, old value copied later...</phrase>
6113     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
6114         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
6115             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
6116         <phrase role="special">})</phrase>
6117         <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// ...after preconditions (and invariants) checked.</phrase>
6118             <phrase role="identifier">old_char</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">]);</phrase>
6119         <phrase role="special">})</phrase>
6120         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
6121             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">]</phrase> <phrase role="special">==</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
6122             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_char</phrase><phrase role="special">);</phrase>
6123         <phrase role="special">})</phrase>
6124     <phrase role="special">;</phrase>
6125
6126     <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">s</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase>
6127     <phrase role="identifier">s</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase>
6128     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
6129 <phrase role="special">}</phrase>
6130 </programlisting>
6131       </para>
6132       <para>
6133         The functor passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput> should capture all the variables that
6134         it needs to evaluate the old value expressions passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>.
6135         In general, these variables should be captured by reference and not by value
6136         (because old values need to copy the values the captured variables will have
6137         just before executing the function body, and not the values these variables
6138         had when the functor passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput>
6139         was first declared). In any case, programmers should write the functor passed
6140         to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput> so that it modifies only old values
6141         and not the values of other captured variables, even when those are captured
6142         by reference (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
6143       </para>
6144       <para>
6145         This library will automatically call the failure handler <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></computeroutput>
6146         if calling the functor specified via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput>
6147         throws an exception (by default, this handler prints an error message to
6148         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput> and terminates the program calling
6149         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>, but see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
6150         on Failures</link> to throw exceptions, exit the program with an error code,
6151         etc.).
6152       </para>
6153       <note>
6154         <para>
6155           If old value pointers are initialized at the point of their construction
6156           instead of using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput> then an exception thrown by the old
6157           value expression passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>,
6158           or more in general any exception thrown by the old value pointer initialization,
6159           will result in that exception being thrown up the stack by the enclosing
6160           function. This is arguably less correct than calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></computeroutput>
6161           because an exception thrown by an old value copy causes the program to
6162           fail to check its postconditions and exception guarantees but should not
6163           automatically causes the enclosing function to thrown an exception (this
6164           might not be a significant difference in practice, but it could be an additional
6165           reason to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput> instead of assigning old values when
6166           they are declared before the contract). <footnote id="boost_contract.advanced.old_values_copied_at_body.f1">
6167           <para>
6168             <emphasis role="bold">Rationale:</emphasis> It would be possible for
6169             this library to internally wrap all old value operations (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput> copy
6170             constructor, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.make_old_idm45394998968720">boost::contract::make_old</link></computeroutput>,
6171             etc.) with try-catch statements so to call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></computeroutput>
6172             also when old values are copied when they are constructed outside <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput>. However, that will prevent this
6173             library from knowing the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.from">boost::contract::from</link></computeroutput>
6174             parameter and that would be problematic (specifically because destructors
6175             can have postconditions so that parameter is necessary to make sure user-defined
6176             failure handlers can be programmed to never throw from destructors as
6177             C++ usually requires).
6178           </para>
6179           </footnote>
6180         </para>
6181       </note>
6182     </section>
6183     <section id="boost_contract.advanced.named_overrides">
6184       <title><link linkend="boost_contract.advanced.named_overrides">Named Overrides</link></title>
6185       <para>
6186         As seen in <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
6187         Function Overrides</link>, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
6188         macro has to be used to declare the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput> that is passed as an explicit template
6189         parameter to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
6190         for public function overrides. The function names passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
6191         (and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDES">BOOST_CONTRACT_OVERRIDES</link></computeroutput>)
6192         should never start with an underscore to avoid generating names containing
6193         double underscores <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override__</phrase><phrase role="special">...</phrase></computeroutput> (because all symbols containing double
6194         underscores <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">__</phrase><phrase role="special">...</phrase></computeroutput> are reserved symbols in the C++ standard).
6195         There is a separate macro <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
6196         that can be used to explicitly specify the name of the type being declared:
6197         <footnote id="boost_contract.advanced.named_overrides.f0">
6198         <para>
6199           <emphasis role="bold">Rationale:</emphasis> A different macro <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
6200           is used instead of overloading <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
6201           using variadic macros because the override macro cannot be programmed manually
6202           by users so making it a variadic would prevent to use this library on compilers
6203           that do not support variadic macros (see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
6204           Macros</link>).
6205         </para>
6206         </footnote>
6207       </para>
6208 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>function-name</emphasis></literal><phrase role="special">)</phrase>                  <phrase role="comment">// Generate `override_...`.</phrase>
6209 <phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDE</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>type-name</emphasis></literal><phrase role="special">,</phrase> <literal moreinfo="none"><emphasis>function-name</emphasis></literal><phrase role="special">)</phrase> <phrase role="comment">// Generate `type-name`.</phrase>
6210 </programlisting>
6211       <para>
6212         For example, the following public function override is named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">_1</phrase></computeroutput> so <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">_1</phrase><phrase role="special">)</phrase></computeroutput>
6213         would declare a type named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override__1</phrase></computeroutput>
6214         (which is reserved symbol in C++ because it contains a double underscore
6215         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__</phrase></computeroutput>), thus <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">override1</phrase><phrase role="special">,</phrase> <phrase role="identifier">_1</phrase><phrase role="special">)</phrase></computeroutput>
6216         is used to name the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override1</phrase></computeroutput>
6217         instead (see <ulink url="../../example/features/named_override.cpp"><literal moreinfo="none">named_override.cpp</literal></ulink>):
6218       </para>
6219       <para>
6220 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
6221 <phrase role="keyword">class</phrase> <phrase role="identifier">positive_unary_pack</phrase>
6222     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">generic_unary_pack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
6223     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
6224 <phrase role="special">{</phrase>
6225 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
6226     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
6227     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
6228
6229     <phrase role="comment">// BOOST_CONTRACT_OVERRIDE(_1) would generate reserved name `override__1`.</phrase>
6230     <phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">override1</phrase><phrase role="special">,</phrase> <phrase role="identifier">_1</phrase><phrase role="special">)</phrase> <phrase role="comment">// Generate `override1`.</phrase>
6231
6232     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">_1</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
6233             <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
6234         <phrase role="comment">// Use `override1` generated by BOOST_CONTRACT_NAMED_OVERRIDE above.</phrase>
6235         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">override1</phrase><phrase role="special">&gt;(</phrase>
6236             <phrase role="identifier">v</phrase><phrase role="special">,</phrase>
6237             <phrase role="keyword">static_cast</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="identifier">positive_unary_pack</phrase><phrase role="special">::*)(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase>
6238                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*)&gt;(&amp;</phrase><phrase role="identifier">positive_unary_pack</phrase><phrase role="special">::</phrase><phrase role="identifier">_1</phrase><phrase role="special">),</phrase>
6239             <phrase role="keyword">this</phrase><phrase role="special">,</phrase>
6240             <phrase role="identifier">value</phrase>
6241         <phrase role="special">)</phrase>
6242             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
6243                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
6244             <phrase role="special">})</phrase>
6245         <phrase role="special">;</phrase>
6246         <phrase role="identifier">value1_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
6247     <phrase role="special">}</phrase>
6248
6249     <phrase role="comment">/* ... */</phrase>
6250 </programlisting>
6251       </para>
6252       <para>
6253         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
6254         macro can also be used when the name <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput> generated by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
6255         would clash with other names in user code, to generate names in CamelCase
6256         or in any other preferred style, and in any other case when programmers need
6257         or prefer to generate names different from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput>.
6258       </para>
6259       <para>
6260         Note that there is not a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDES</phrase></computeroutput>
6261         macro so <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
6262         needs to be invoked separately on each function name (there is instead a
6263         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDES">BOOST_CONTRACT_OVERRIDES</link></computeroutput>
6264         macro as seen in <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
6265         Function Overrides</link>). <footnote id="boost_contract.advanced.named_overrides.f1">
6266         <para>
6267           <emphasis role="bold">Rationale:</emphasis> The syntax for invoking a possible
6268           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDES</phrase></computeroutput>
6269           macro would need to be something like <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">type_name1</phrase><phrase role="special">,</phrase> <phrase role="identifier">func_name1</phrase><phrase role="special">,</phrase> <phrase role="identifier">type_name2</phrase><phrase role="special">,</phrase> <phrase role="identifier">func_name2</phrase><phrase role="special">,</phrase> <phrase role="special">...)</phrase></computeroutput>.
6270           The authors found such a syntax less readable than repeating single <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
6271           invocations as in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">type_name1</phrase><phrase role="special">,</phrase> <phrase role="identifier">func_name1</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">type_name2</phrase><phrase role="special">,</phrase> <phrase role="identifier">func_name2</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase></computeroutput> so
6272           decided not to provide the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NAMED_OVERRIDES</phrase></computeroutput>
6273           macro.
6274         </para>
6275         </footnote>
6276       </para>
6277     </section>
6278     <section id="boost_contract.advanced.access_specifiers">
6279       <title><link linkend="boost_contract.advanced.access_specifiers">Access Specifiers</link></title>
6280       <para>
6281         As seen thus far, this library requires programmers to decorate their classes
6282         declaring the following extra members:
6283       </para>
6284       <itemizedlist>
6285         <listitem>
6286           <simpara>
6287             The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput> member functions (used
6288             to check class invariants, see <link linkend="boost_contract.tutorial.class_invariants">Class
6289             Invariants</link>).
6290           </simpara>
6291         </listitem>
6292         <listitem>
6293           <simpara>
6294             The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput> member
6295             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase></computeroutput> declared via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
6296             (used to implement subcontracting, see <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
6297             Function Overrides</link>).
6298           </simpara>
6299         </listitem>
6300         <listitem>
6301           <simpara>
6302             The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput>
6303             member types declared via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>,
6304             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>,
6305             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDES">BOOST_CONTRACT_OVERRIDES</link></computeroutput>
6306             (used to implement subcontracting for overriding functions, see <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
6307             Function Overrides</link>). <footnote id="boost_contract.advanced.access_specifiers.f0">
6308             <para>
6309               <emphasis role="bold">Rationale:</emphasis> Note that the internals
6310               of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput>
6311               type generated by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
6312               use names reserved by this library so programmers should not actually
6313               use such a type even when it is declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>.
6314             </para>
6315             </footnote>
6316           </simpara>
6317         </listitem>
6318       </itemizedlist>
6319       <para>
6320         In general, these members must be declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>
6321         in the user class in order for this library to be able to access them. <footnote id="boost_contract.advanced.access_specifiers.f1">
6322         <para>
6323           There is some variability among compiler implementations: The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput> member type needs to be declared
6324           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> on MSVC, GCC, and Clang;
6325           The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase></computeroutput> member functions need
6326           to be declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> on MSVC,
6327           but not on GCC and Clang; The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override_</phrase><phrase role="special">...</phrase></computeroutput> member types do not have to be declared
6328           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> on any compiler. In
6329           any case, declaring these extra members all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>
6330           or all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> when the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput> class
6331           is also declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">friend</phrase></computeroutput> always
6332           works on all compilers.
6333         </para>
6334         </footnote> However, programmers might need to more precisely control the
6335         public members of their classes to prevent incorrect access of encapsulated
6336         members. All these members can be declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput>
6337         as long as the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
6338         class is declared as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">friend</phrase></computeroutput>
6339         of the user class. For example (see <ulink url="../../example/features/access.cpp"><literal moreinfo="none">access.cpp</literal></ulink>):
6340       </para>
6341       <para>
6342 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
6343 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase>
6344     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">pushable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
6345     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
6346 <phrase role="special">{</phrase> <phrase role="comment">// Private section of the class.</phrase>
6347     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase> <phrase role="comment">// Friend `access` class so...</phrase>
6348
6349     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// ...private bases.</phrase>
6350     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
6351
6352     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// ...private invariants.</phrase>
6353         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
6354     <phrase role="special">}</phrase>
6355
6356     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">push_back</phrase><phrase role="special">)</phrase> <phrase role="comment">// ...private overrides.</phrase>
6357
6358 <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="comment">// Public section of the class.</phrase>
6359     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
6360             <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
6361         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
6362                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
6363         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
6364                 <phrase role="identifier">override_push_back</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vector</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
6365             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
6366                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
6367             <phrase role="special">})</phrase>
6368             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
6369                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
6370             <phrase role="special">})</phrase>
6371         <phrase role="special">;</phrase>
6372
6373         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
6374     <phrase role="special">}</phrase>
6375
6376     <phrase role="comment">/* ... */</phrase>
6377 </programlisting>
6378       </para>
6379       <para>
6380         This technique is not used in most examples of this documentation only for
6381         brevity. Programmers are encouraged to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
6382         in real production code freely as they see fit.
6383       </para>
6384       <warning>
6385         <para>
6386           Not declaring <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
6387           friend of user classes might cause compiler errors on some compilers (e.g.,
6388           MSVC) because the private members needed to check the contracts will not
6389           be accessible. On other compilers (e.g., GCC and Clang), the private access
6390           level will instead fail SFINAE and no compiler error will be reported while
6391           invariants and subcontracting will be silently skipped at run-time. Therefore,
6392           programmers should always make sure to either declare invariant functions
6393           and base types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase></computeroutput> as
6394           public members or to declare <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
6395           as friend.
6396         </para>
6397       </warning>
6398     </section>
6399     <section id="boost_contract.advanced.throw_on_failures__and__noexcept__">
6400       <title><link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
6401       on Failures (and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput>)</link></title>
6402       <para>
6403         If a condition checked using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
6404         is evaluated to be false or, more in general, if any of the specified contract
6405         code throws an exception (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
6406         simply expands to code that throws a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.assertion_failure">boost::contract::assertion_failure</link></computeroutput>
6407         exception, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
6408         Macros</link>), this library will call an appropriate <emphasis>contract
6409         failure handler</emphasis> function as follow:
6410       </para>
6411       <itemizedlist>
6412         <listitem>
6413           <simpara>
6414             Preconditions: False <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
6415             assertions and exceptions thrown from within <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(...)</phrase></computeroutput>
6416             call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput>.
6417           </simpara>
6418         </listitem>
6419         <listitem>
6420           <simpara>
6421             Postconditions: False <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
6422             assertions and exceptions thrown from within <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(...)</phrase></computeroutput>
6423             call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.postcondition_failure">boost::contract::postcondition_failure</link></computeroutput>.
6424           </simpara>
6425         </listitem>
6426         <listitem>
6427           <simpara>
6428             Exceptions guarantees: False <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
6429             assertions and exceptions thrown from within <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(...)</phrase></computeroutput>
6430             call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput>.
6431           </simpara>
6432         </listitem>
6433         <listitem>
6434           <simpara>
6435             Class invariants: False <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
6436             assertions and exceptions thrown from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase><phrase role="special">()</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase></computeroutput> call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.entry_invariant_failure">boost::contract::entry_invariant_failure</link></computeroutput>
6437             when checked at function entry and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.exit_invariant_failure">boost::contract::exit_invariant_failure</link></computeroutput>
6438             when checked at function exit.
6439           </simpara>
6440         </listitem>
6441         <listitem>
6442           <simpara>
6443             Old values copied at body: Exceptions thrown from old values copied at
6444             body within <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(...)</phrase></computeroutput> call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></computeroutput>.
6445           </simpara>
6446         </listitem>
6447         <listitem>
6448           <simpara>
6449             Implementation checks: False <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
6450             assertions and exceptions thrown from implementation checks <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase>
6451             <phrase role="special">=</phrase> </computeroutput><literal moreinfo="none"><emphasis>nullary-functor</emphasis></literal>
6452             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(...)</phrase></computeroutput> call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check_failure">boost::contract::check_failure</link></computeroutput>.
6453           </simpara>
6454         </listitem>
6455       </itemizedlist>
6456       <para>
6457         By default, these contract failure handlers print a message to the standard
6458         error <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase></computeroutput> and then terminate the program calling
6459         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase></computeroutput>. <footnote id="boost_contract.advanced.throw_on_failures__and__noexcept__.f0">
6460         <para>
6461           <emphasis role="bold">Rationale:</emphasis> In general, when a contract
6462           fails the only safe thing to do is to terminate program execution (because
6463           the contract failure indicates a bug in the program, and in general a buggy
6464           program will be in a state for which no operation can be successfully and
6465           safely performed, so the program should be stopped as soon as possible).
6466           Therefore, this library terminates the program by default. However, for
6467           specific applications, programmers could implement some fail-safe mechanism
6468           for which some mission-critical operations could always be performed upon
6469           handling failures so this library allows programmers to override the default
6470           contract failure handlers to fully customize how to handle contract failures.
6471         </para>
6472         </footnote> However, programmers can override the default contract failure
6473         handlers to perform any custom action on contract failure using the following
6474         functions respectively:
6475       </para>
6476       <itemizedlist>
6477         <listitem>
6478           <simpara>
6479             Preconditions: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_precondition_failure">boost::contract::set_precondition_failure</link></computeroutput>.
6480           </simpara>
6481         </listitem>
6482         <listitem>
6483           <simpara>
6484             Postconditions: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_postcondition_failure">boost::contract::set_postcondition_failure</link></computeroutput>.
6485           </simpara>
6486         </listitem>
6487         <listitem>
6488           <simpara>
6489             Exception guarantees: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_except_failure">boost::contract::set_except_failure</link></computeroutput>.
6490           </simpara>
6491         </listitem>
6492         <listitem>
6493           <simpara>
6494             Class invariants: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_entr_idm45394999333872">boost::contract::set_entry_invariant_failure</link></computeroutput>
6495             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_exit_invariant_failure">boost::contract::set_exit_invariant_failure</link></computeroutput>,
6496             or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_invariant_failure">boost::contract::set_invariant_failure</link></computeroutput>
6497             (to set both entry and exit invariant failure handlers at once for convenience).
6498           </simpara>
6499         </listitem>
6500         <listitem>
6501           <simpara>
6502             Old values copied at body: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_old_failure">boost::contract::set_old_failure</link></computeroutput>.
6503           </simpara>
6504         </listitem>
6505         <listitem>
6506           <simpara>
6507             Implementation checks: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.set_check_failure">boost::contract::set_check_failure</link></computeroutput>.
6508           </simpara>
6509         </listitem>
6510       </itemizedlist>
6511       <para>
6512         These <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">set_</phrase><phrase role="special">...</phrase><phrase role="identifier">_failure</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>f</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> function calls return a reference to the
6513         contract failure handler functor <literal moreinfo="none"><emphasis>f</emphasis></literal>
6514         that they take as input parameter (so they can be concatenated). <footnote id="boost_contract.advanced.throw_on_failures__and__noexcept__.f1">
6515         <para>
6516           <emphasis role="bold">Rationale:</emphasis> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">set_</phrase><phrase role="special">...</phrase><phrase role="identifier">_failure</phrase></computeroutput>
6517           functions take a functor as parameter (to accept not just function pointers
6518           but also lambdas, binds, etc.) and they return this same functor as result
6519           so they can be concatenated (this interface is a bit different from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">set_terminate</phrase></computeroutput>). The related <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">get_</phrase><phrase role="special">...</phrase><phrase role="identifier">_failure</phrase></computeroutput> functions can be used to query
6520           the functors currently set as failure handlers (this interface is similar
6521           to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">get_terminate</phrase></computeroutput>).
6522         </para>
6523         </footnote> For example (see <ulink url="../../example/features/throw_on_failure.cpp"><literal moreinfo="none">throw_on_failure.cpp</literal></ulink>):
6524       </para>
6525       <para>
6526 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
6527     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">set_precondition_failure</phrase><phrase role="special">(</phrase>
6528     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">set_postcondition_failure</phrase><phrase role="special">(</phrase>
6529     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">set_invariant_failure</phrase><phrase role="special">(</phrase>
6530     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">set_old_failure</phrase><phrase role="special">(</phrase>
6531         <phrase role="special">[]</phrase> <phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">from</phrase> <phrase role="identifier">where</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6532             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase> <phrase role="special">==</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">from_destructor</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6533                 <phrase role="comment">// Shall not throw from C++ destructors.</phrase>
6534                 <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">clog</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">"ignored destructor contract failure"</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
6535             <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="keyword">throw</phrase><phrase role="special">;</phrase> <phrase role="comment">// Re-throw (assertion_failure, user-defined, etc.).</phrase>
6536         <phrase role="special">}</phrase>
6537     <phrase role="special">))));</phrase>
6538     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">set_except_failure</phrase><phrase role="special">(</phrase>
6539         <phrase role="special">[]</phrase> <phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6540             <phrase role="comment">// Already an active exception so shall not throw another...</phrase>
6541             <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">clog</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">"ignored exception guarantee failure"</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
6542         <phrase role="special">}</phrase>
6543     <phrase role="special">);</phrase>
6544     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">set_check_failure</phrase><phrase role="special">(</phrase>
6545         <phrase role="special">[]</phrase> <phrase role="special">{</phrase>
6546             <phrase role="comment">// But now CHECK shall not be used in destructor implementations.</phrase>
6547             <phrase role="keyword">throw</phrase><phrase role="special">;</phrase> <phrase role="comment">// Re-throw (assertion_failure, user-defined, etc.).</phrase>
6548         <phrase role="special">}</phrase>
6549     <phrase role="special">);</phrase>
6550
6551     <phrase role="comment">/* ... */</phrase>
6552 </programlisting>
6553       </para>
6554       <para>
6555         When programming custom failure handlers that trow exceptions instead of
6556         terminating the program, programmers should be wary of the following:
6557       </para>
6558       <itemizedlist>
6559         <listitem>
6560           <simpara>
6561             In order to comply with C++ and STL exception safety, destructors should
6562             never throw (in fact destructors are implicitly declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput> since C++11). This library passes
6563             a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.from">boost::contract::from</link></computeroutput>
6564             parameter to the contract failure handlers for preconditions, postconditions,
6565             class invariants, and old values copied at body (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput>,
6566             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.postcondition_failure">boost::contract::postcondition_failure</link></computeroutput>,
6567             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.entry_invariant_failure">boost::contract::entry_invariant_failure</link></computeroutput>,
6568             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.exit_invariant_failure">boost::contract::exit_invariant_failure</link></computeroutput>,
6569             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></computeroutput>
6570             respectively). This <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.from">boost::contract::from</link></computeroutput>
6571             parameter indicates if the contract failure occurred in a destructor,
6572             constructor, or function call so programmers can use it to code custom
6573             contract failure hander functions that never throw from destructors.
6574             (In the example above, contract failures from destructors are simply
6575             ignored even if that is probably never a safe thing to do in real production
6576             code.)
6577           </simpara>
6578         </listitem>
6579         <listitem>
6580           <simpara>
6581             C++ stack-unwinding will execute base class destructors even when the
6582             derived class destructor trows an exception. Therefore, the contracts
6583             of base class destructors will continue to be checked when contract failure
6584             handlers are programmed to throw exceptions on contract failures from
6585             destructors (yet another reason not to throw exceptions from destructors,
6586             not even because of contract failures).
6587           </simpara>
6588         </listitem>
6589         <listitem>
6590           <simpara>
6591             The contract failure handler for exception guarantees <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput>
6592             should never throw (regardless of the value of its <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.from">boost::contract::from</link></computeroutput>
6593             parameter) because when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput>
6594             is called there is already an active exception on the stack, the exception
6595             that triggered the exception guarantees to be checked in the first place
6596             (throwing an exception while there is already an active exception will
6597             force program termination or lead to undefined behaviour in C++).
6598           </simpara>
6599         </listitem>
6600         <listitem>
6601           <simpara>
6602             Implementation checks can appear in any code, including destructor implementation
6603             code, so <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check_failure">boost::contract::check_failure</link></computeroutput>
6604             should also never throw, or implementation checks should never be used
6605             in destructors otherwise these destructors will throw (note that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check_failure">boost::contract::check_failure</link></computeroutput>
6606             does not provide the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.from">boost::contract::from</link></computeroutput>
6607             parameter so it is not possible to differentiate from implementation
6608             checks failing from destructors instead than from other parts of the
6609             code).
6610           </simpara>
6611         </listitem>
6612       </itemizedlist>
6613       <note>
6614         <para>
6615           Programmers need to decide how to handle contract failures from destructors
6616           when they write custom contract failure handlers that throw exceptions
6617           instead of terminating the program (given that C++ and STL exception safety
6618           rules requires destructors to never throw). This is not a simple dilemma
6619           and it might be a good reason to terminate the program instead of throwing
6620           exceptions when assertions fail in C++ (as this library and also C-style
6621           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">assert</phrase></computeroutput> do by default).
6622         </para>
6623       </note>
6624       <bridgehead renderas="sect4" id="boost_contract.advanced.throw_on_failures__and__noexcept__.h0">
6625         <phrase id="boost_contract.advanced.throw_on_failures__and__noexcept__.throw_user_defined_exceptions"/><link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__.throw_user_defined_exceptions">Throw
6626         User-Defined Exceptions</link>
6627       </bridgehead>
6628       <para>
6629         Contract assertions can be programmed to throw <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.assertion_failure">boost::contract::assertion_failure</link></computeroutput>
6630         using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>condition</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> as we have seen so far (see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
6631         Macros</link>). Alternatively, contract assertions can be programmed to throw
6632         any other exception (including user-defined exceptions) using code similar
6633         to the following:
6634       </para>
6635 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase><phrase role="special">(!</phrase><literal moreinfo="none"><emphasis>condition</emphasis></literal><phrase role="special">)</phrase> <phrase role="keyword">throw</phrase> <literal moreinfo="none"><emphasis>exception-object</emphasis></literal><phrase role="special">;</phrase>
6636 </programlisting>
6637       <para>
6638         For example, the following precondition functor throws <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.assertion_failure">boost::contract::assertion_failure</link></computeroutput>
6639         (via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>)
6640         on its first assertion and the user-defined exception <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">too_large_error</phrase></computeroutput>
6641         on its second assertion (both exceptions will cause this library to call
6642         the customized <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput>
6643         listed above which will in turn re-throw the exceptions up the stack, see
6644         <ulink url="../../example/features/throw_on_failure.cpp"><literal moreinfo="none">throw_on_failure.cpp</literal></ulink>):
6645       </para>
6646       <para>
6647 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">too_large_error</phrase> <phrase role="special">{};</phrase>
6648
6649 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">MaxSize</phrase><phrase role="special">&gt;</phrase>
6650 <phrase role="keyword">class</phrase> <phrase role="identifier">cstring</phrase>
6651     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">cstring</phrase><phrase role="special">&lt;</phrase> <phrase role="special">\</phrase>
6652             <phrase role="identifier">MaxSize</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
6653     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
6654 <phrase role="special">{</phrase>
6655 </programlisting>
6656       </para>
6657       <para>
6658 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
6659     <phrase role="comment">/* implicit */</phrase> <phrase role="identifier">cstring</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase> <phrase role="identifier">chars</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
6660         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">cstring</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
6661             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">chars</phrase><phrase role="special">);</phrase> <phrase role="comment">// Throw `assertion_failure`.</phrase>
6662             <phrase role="comment">// Or, throw user-defined exception.</phrase>
6663             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">strlen</phrase><phrase role="special">(</phrase><phrase role="identifier">chars</phrase><phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">MaxSize</phrase><phrase role="special">)</phrase> <phrase role="keyword">throw</phrase> <phrase role="identifier">too_large_error</phrase><phrase role="special">();</phrase>
6664         <phrase role="special">})</phrase>
6665     <phrase role="special">{</phrase>
6666 </programlisting>
6667       </para>
6668       <para>
6669 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
6670 <phrase role="special">};</phrase>
6671 </programlisting>
6672       </para>
6673       <bridgehead renderas="sect4" id="boost_contract.advanced.throw_on_failures__and__noexcept__.h1">
6674         <phrase id="boost_contract.advanced.throw_on_failures__and__noexcept__.exception_specifiers___code__phrase_role__keyword__noexcept__phrase___code__and__code__phrase_role__keyword__throw__phrase___code___"/><link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__.exception_specifiers___code__phrase_role__keyword__noexcept__phrase___code__and__code__phrase_role__keyword__throw__phrase___code___">Exception
6675         Specifiers (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">throw</phrase></computeroutput>`)</link>
6676       </bridgehead>
6677       <para>
6678         Exception specifiers <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput>
6679         (since C++11) and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">throw</phrase></computeroutput> (deprecated
6680         in C++11) of the enclosing function, constructor, or destructor declaring
6681         the contract correctly apply to the contract code as well. Therefore, even
6682         if the contract failure handlers are reprogrammed to throw exceptions in
6683         case of contract failures, those exceptions will never be thrown outside
6684         the context of the enclosing operation if that is not in accordance with
6685         the exception specifiers of that operation (specifically, note that all destructors
6686         are implicitly declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput>
6687         in C++11).
6688       </para>
6689       <para>
6690         For example, the following code will correctly never throw from the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">noexcept</phrase></computeroutput> destructor, not even if the class
6691         invariants checked at destructor entry throw <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">too_large_error</phrase></computeroutput>
6692         and the contract failure handlers for invariants are programmed to throw
6693         from destructors (the program will always terminate in this case instead,
6694         see <ulink url="../../example/features/throw_on_failure.cpp"><literal moreinfo="none">throw_on_failure.cpp</literal></ulink>):
6695       </para>
6696       <para>
6697 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">too_large_error</phrase> <phrase role="special">{};</phrase>
6698
6699 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">MaxSize</phrase><phrase role="special">&gt;</phrase>
6700 <phrase role="keyword">class</phrase> <phrase role="identifier">cstring</phrase>
6701     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">cstring</phrase><phrase role="special">&lt;</phrase> <phrase role="special">\</phrase>
6702             <phrase role="identifier">MaxSize</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
6703     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
6704 <phrase role="special">{</phrase>
6705 </programlisting>
6706       </para>
6707       <para>
6708 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
6709     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
6710         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">MaxSize</phrase><phrase role="special">)</phrase> <phrase role="keyword">throw</phrase> <phrase role="identifier">too_large_error</phrase><phrase role="special">();</phrase> <phrase role="comment">// Throw user-defined ex.</phrase>
6711         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">chars_</phrase><phrase role="special">);</phrase> <phrase role="comment">// Or, throw `assertion_failure`.</phrase>
6712         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">chars_</phrase><phrase role="special">[</phrase><phrase role="identifier">size</phrase><phrase role="special">()]</phrase> <phrase role="special">==</phrase> <phrase role="char">'\0'</phrase><phrase role="special">);</phrase>
6713     <phrase role="special">}</phrase>
6714
6715     <phrase role="special">~</phrase><phrase role="identifier">cstring</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Exception specifiers apply to contract code.</phrase>
6716         <phrase role="comment">// Check invariants.</phrase>
6717         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
6718     <phrase role="special">}</phrase>
6719 </programlisting>
6720       </para>
6721       <para>
6722 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
6723 <phrase role="special">};</phrase>
6724 </programlisting>
6725       </para>
6726       <para>
6727 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">/* ... */</phrase>
6728
6729 <phrase role="comment">// Warning... might cause destructors to throw (unless declared noexcept).</phrase>
6730 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">set_invariant_failure</phrase><phrase role="special">(</phrase>
6731     <phrase role="special">[]</phrase> <phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6732         <phrase role="keyword">throw</phrase><phrase role="special">;</phrase> <phrase role="comment">// Throw no matter if from destructor, etc.</phrase>
6733     <phrase role="special">}</phrase>
6734 <phrase role="special">);</phrase>
6735
6736 <phrase role="comment">/* ... */</phrase>
6737 </programlisting>
6738       </para>
6739     </section>
6740   </section>
6741   <section id="boost_contract.extras">
6742     <title><link linkend="boost_contract.extras">Extras</link></title>
6743     <para>
6744       This section can be consulted selectively for specific topics of interest.
6745     </para>
6746     <section id="boost_contract.extras.old_value_requirements__templates_">
6747       <title><link linkend="boost_contract.extras.old_value_requirements__templates_">Old
6748       Value Requirements (Templates)</link></title>
6749       <para>
6750         Old values require to copy the expression passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
6751         thus the type of that expression needs to be copyable. More precisely, dereferencing
6752         an old value pointer of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>
6753         requires <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase></computeroutput> to be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>,
6754         otherwise this library will generate a compile-time error.
6755       </para>
6756       <para>
6757         In some cases it might be acceptable, or even desirable, to cause a compile-time
6758         error when a program uses old value types that are not copyable (because
6759         it is not possible to fully check the correctness of the program as stated
6760         by the contract assertions that use these old values). In these cases, programmers
6761         can declare old values using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
6762         as seen so far.
6763       </para>
6764       <para>
6765         However, in some other cases it might be desirable to simply skip assertions
6766         that use old values when the respective old value types are not copyable,
6767         without causing compile-time errors. Programmers can do this using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>
6768         instead of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
6769         and checking if the old value pointer is not null before dereferencing it
6770         in postconditions. For example, consider the following function template
6771         that could in general be instantiated for types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
6772         that are not copy constructible (that is for which <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase></computeroutput> is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">false</phrase></computeroutput>,
6773         see <ulink url="../../example/features/old_if_copyable.cpp"><literal moreinfo="none">old_if_copyable.cpp</literal></ulink>):
6774         <footnote id="boost_contract.extras.old_value_requirements__templates_.f0">
6775         <para>
6776           <emphasis role="bold">Rationale:</emphasis> <link linkend="N1962_anchor">[N1962]</link>
6777           and other proposals to add contracts to C++ do not provide a mechanism
6778           to selectively disable copies only for old value types that are not copy
6779           constructible. However, this library provides such a mechanism to allow
6780           to program contracts for template code without necessarily adding extra
6781           copy constructible type requirements that would not be present if it were
6782           not for copying old values (so compiling the code with and without contracts
6783           will not necessarily alter the type requirements of the program). Something
6784           similar could be achieved combing C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
6785           <phrase role="keyword">constexpr</phrase></computeroutput> with <link linkend="N1962_anchor">[N1962]</link>
6786           or <link linkend="P0380_anchor">[P0380]</link> so that old value expressions
6787           within template code can be guarded by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
6788           <phrase role="keyword">constexpr</phrase></computeroutput> statements checking if
6789           the old value types are copyable or not. For example, assuming old values
6790           are added to <link linkend="P0380_anchor">[P0380]</link> (using some kind
6791           of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">oldof</phrase><phrase role="special">(...)</phrase></computeroutput>
6792           syntax) and that C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput> can be used within <link linkend="P0380_anchor">[P0380]</link>
6793           contracts:
6794 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
6795 <phrase role="keyword">void</phrase> <phrase role="identifier">offset</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase>
6796     <phrase role="special">[[</phrase><phrase role="identifier">ensures</phrase><phrase role="special">:</phrase> <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">is_copy_constructible</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase><phrase role="special">]]</phrase>
6797 <phrase role="special">...</phrase>
6798 </programlisting>
6799         </para>
6800         </footnote>
6801       </para>
6802       <para>
6803 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="comment">// T might or might not be copyable.</phrase>
6804 <phrase role="keyword">void</phrase> <phrase role="identifier">offset</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6805     <phrase role="comment">// No compiler error if T has no copy constructor...</phrase>
6806     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
6807     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
6808         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
6809             <phrase role="comment">// ...but old value null if T has no copy constructor.</phrase>
6810             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_x</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
6811         <phrase role="special">})</phrase>
6812     <phrase role="special">;</phrase>
6813
6814     <phrase role="identifier">x</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
6815 <phrase role="special">}</phrase>
6816 </programlisting>
6817       </para>
6818       <para>
6819         The old value pointer <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">old_x</phrase></computeroutput>
6820         is programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>.
6821         When <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is copyable, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>
6822         behaves like <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>.
6823         When <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not copyable instead,
6824         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>
6825         will simply not copy <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">x</phrase></computeroutput> at
6826         run-time and leave <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">old_x</phrase></computeroutput>
6827         initialized to a null pointer. Therefore, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>
6828         objects like <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">old_x</phrase></computeroutput> must be
6829         checked to be not null as in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_x</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase></computeroutput> before
6830         they are dereferenced in postconditions and exception guarantees (to avoid
6831         run-time errors of dereferencing null pointers).
6832       </para>
6833       <para>
6834         If the above example used <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
6835         instead then this library would have generated a compile-time error when
6836         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">offset</phrase></computeroutput> is instantiated with
6837         types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> that are not copy
6838         constructible (but only if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">old_x</phrase></computeroutput>
6839         is actually dereferenced somewhere, for example in the contract assertions
6840         using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase><phrase role="identifier">old_x</phrase>
6841         <phrase role="special">...</phrase></computeroutput> or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">old_x</phrase><phrase role="special">-&gt;...</phrase></computeroutput>). <footnote id="boost_contract.extras.old_value_requirements__templates_.f1">
6842         <para>
6843           Technically, on C++17 it is possible to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
6844           together with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
6845           instead of using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>,
6846           for example:
6847 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
6848 <phrase role="keyword">void</phrase> <phrase role="identifier">offset</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6849     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_x</phrase><phrase role="special">;</phrase>
6850     <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">is_old_value_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
6851     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
6852         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
6853             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">is_old_value_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
6854         <phrase role="special">})</phrase>
6855     <phrase role="special">;</phrase>
6856
6857     <phrase role="identifier">x</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
6858 <phrase role="special">}</phrase>
6859 </programlisting>
6860           However, the authors find this code less readable and more verbose than
6861           its equivalent that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>.
6862           Guarding old value copies and related assertions with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
6863           <phrase role="keyword">constexpr</phrase></computeroutput> is useful instead when
6864           the guard condition checks type requirements more complex than just <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput>
6865           (as shown later in this documentation).
6866         </para>
6867         </footnote>
6868       </para>
6869       <para>
6870         When C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> declarations
6871         are used with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>,
6872         this library always defaults to using the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
6873         type (because its type requirements are more stringent than <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>).
6874         For example, the following statements are equivalent:
6875       </para>
6876 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase> <phrase role="comment">// C++11 auto declarations always use `old_ptr` (never `old_ptr_if_copyable`).</phrase>
6877 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">decltype</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">)&gt;</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
6878 </programlisting>
6879       <para>
6880         If programmers want to relax the copyable type requirement, they must do
6881         so explicitly by using the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>
6882         type instead of using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput> declarations.
6883       </para>
6884       <bridgehead renderas="sect4" id="boost_contract.extras.old_value_requirements__templates_.h0">
6885         <phrase id="boost_contract.extras.old_value_requirements__templates_.old_value_type_traits"/><link linkend="boost_contract.extras.old_value_requirements__templates_.old_value_type_traits">Old
6886         Value Type Traits</link>
6887       </bridgehead>
6888       <para>
6889         This library uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput>
6890         to determine if an old value type is copyable or not, and then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_value_copy">boost::contract::old_value_copy</link></computeroutput>
6891         to actually copy the old value.
6892       </para>
6893       <para>
6894         By default, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>
6895         is equivalent to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_copy_constructible</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput> and
6896         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_value_copy">boost::contract::old_value_copy</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>
6897         is implemented using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>'s
6898         copy constructor. However, these type traits can be specialized by programmers
6899         for example to avoid making old value copies of types even when they have
6900         a copy constructor (maybe because these copy constructors are too expensive),
6901         or to make old value copies for types that do not have a copy constructor,
6902         or for any other specific need programmers might have for the types in question.
6903       </para>
6904       <para>
6905         For example, the following specialization of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput>
6906         intentionally avoids making old value copies for all expressions of type
6907         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">w</phrase></computeroutput> even if that type has a
6908         copy constructor (see <ulink url="../../example/features/old_if_copyable.cpp"><literal moreinfo="none">old_if_copyable.cpp</literal></ulink>):
6909       </para>
6910       <para>
6911 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Copyable type but...</phrase>
6912 <phrase role="keyword">class</phrase> <phrase role="identifier">w</phrase> <phrase role="special">{</phrase>
6913 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
6914     <phrase role="identifier">w</phrase><phrase role="special">(</phrase><phrase role="identifier">w</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">{</phrase> <phrase role="comment">/* Some very expensive copy operation here... */</phrase> <phrase role="special">}</phrase>
6915
6916     <phrase role="comment">/* ... */</phrase>
6917 </programlisting>
6918       </para>
6919       <para>
6920 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// ...never copy old values for type `w` (because its copy is too expensive).</phrase>
6921 <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
6922     <phrase role="keyword">template</phrase><phrase role="special">&lt;&gt;</phrase>
6923     <phrase role="keyword">struct</phrase> <phrase role="identifier">is_old_value_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">w</phrase><phrase role="special">&gt;</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">false_type</phrase> <phrase role="special">{};</phrase>
6924 <phrase role="special">}</phrase> <phrase role="special">}</phrase>
6925 </programlisting>
6926       </para>
6927       <para>
6928         On the flip side, the following specializations of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput>
6929         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_value_copy">boost::contract::old_value_copy</link></computeroutput>
6930         make old value copies of expressions of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">p</phrase></computeroutput>
6931         even if that type does not actually have a copy constructor (see <ulink url="../../example/features/old_if_copyable.cpp"><literal moreinfo="none">old_if_copyable.cpp</literal></ulink>):
6932       </para>
6933       <para>
6934 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Non-copyable type but...</phrase>
6935 <phrase role="keyword">class</phrase> <phrase role="identifier">p</phrase> <phrase role="special">:</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">noncopyable</phrase> <phrase role="special">{</phrase>
6936     <phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="identifier">num_</phrase><phrase role="special">;</phrase>
6937
6938     <phrase role="keyword">friend</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_value_copy</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">p</phrase><phrase role="special">&gt;;</phrase>
6939
6940     <phrase role="comment">/* ... */</phrase>
6941 </programlisting>
6942       </para>
6943       <para>
6944 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// ...still copy old values for type `p` (using a deep copy).</phrase>
6945 <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
6946     <phrase role="keyword">template</phrase><phrase role="special">&lt;&gt;</phrase>
6947     <phrase role="keyword">struct</phrase> <phrase role="identifier">old_value_copy</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">p</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
6948         <phrase role="keyword">explicit</phrase> <phrase role="identifier">old_value_copy</phrase><phrase role="special">(</phrase><phrase role="identifier">p</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">old</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
6949             <phrase role="special">*</phrase><phrase role="identifier">old_</phrase><phrase role="special">.</phrase><phrase role="identifier">num_</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">old</phrase><phrase role="special">.</phrase><phrase role="identifier">num_</phrase><phrase role="special">;</phrase> <phrase role="comment">// Deep copy pointed value.</phrase>
6950         <phrase role="special">}</phrase>
6951
6952         <phrase role="identifier">p</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">old</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">old_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
6953
6954     <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
6955         <phrase role="identifier">p</phrase> <phrase role="identifier">old_</phrase><phrase role="special">;</phrase>
6956     <phrase role="special">};</phrase>
6957
6958     <phrase role="keyword">template</phrase><phrase role="special">&lt;&gt;</phrase>
6959     <phrase role="keyword">struct</phrase> <phrase role="identifier">is_old_value_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">p</phrase><phrase role="special">&gt;</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">true_type</phrase> <phrase role="special">{};</phrase>
6960 <phrase role="special">}</phrase> <phrase role="special">}</phrase>
6961 </programlisting>
6962       </para>
6963       <para>
6964         In general, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_copy_constructible</phrase></computeroutput> and therefore <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput>
6965         require C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">decltype</phrase></computeroutput> and SFINAE
6966         to automatically detect if a given type is copyable or not. On non-C++11
6967         compilers, it is possible to inherit the old value type from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">noncopyable</phrase></computeroutput>, or use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_MOVABLE_BUT_NOT_COPYABLE</phrase></computeroutput>,
6968         or specialize <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_copy_constructible</phrase></computeroutput> (see <ulink url="http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_copy_constructible</phrase></computeroutput></ulink> documentation
6969         for more information), or just specialize <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput>.
6970         For example, for a non-copyable type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">n</phrase></computeroutput>
6971         the following code will work also on non-C++11 compilers (see <ulink url="../../example/features/old_if_copyable.cpp"><literal moreinfo="none">old_if_copyable.cpp</literal></ulink>):
6972       </para>
6973       <para>
6974 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">n</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Do not want to use boost::noncopyable but...</phrase>
6975     <phrase role="keyword">int</phrase> <phrase role="identifier">num_</phrase><phrase role="special">;</phrase>
6976
6977 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
6978     <phrase role="identifier">n</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="comment">// ...unimplemented private copy constructor (so non-copyable).</phrase>
6979
6980     <phrase role="comment">/* ... */</phrase>
6981 </programlisting>
6982       </para>
6983       <para>
6984 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Specialize `boost::is_copy_constructible` (no need for this on C++11).</phrase>
6985 <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
6986     <phrase role="keyword">template</phrase><phrase role="special">&lt;&gt;</phrase>
6987     <phrase role="keyword">struct</phrase> <phrase role="identifier">is_old_value_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">n</phrase><phrase role="special">&gt;</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">false_type</phrase> <phrase role="special">{};</phrase>
6988 <phrase role="special">}</phrase> <phrase role="special">}</phrase>
6989 </programlisting>
6990       </para>
6991     </section>
6992     <section id="boost_contract.extras.assertion_requirements__templates_">
6993       <title><link linkend="boost_contract.extras.assertion_requirements__templates_">Assertion
6994       Requirements (Templates)</link></title>
6995       <para>
6996         In general, assertions can introduce a new set of requirements on the types
6997         used by the program. Some of these type requirements might be necessary only
6998         to check the assertions and they would not be required by the program otherwise.
6999       </para>
7000       <para>
7001         In some cases it might be acceptable, or even desirable, to cause a compile-time
7002         error when a program uses types that do not provide all the operations needed
7003         to check contract assertions (because it is not possible to fully check the
7004         correctness of the program as specified by its contracts). In these cases,
7005         programmers can specify contract assertions as we have seen so far, compilation
7006         will fail if user types do not provide all operations necessary to check
7007         the contracts.
7008       </para>
7009       <para>
7010         However, in some other cases it might be desirable to not augment the type
7011         requirements of a program just because of contract assertions and to simply
7012         skip assertions when user types do not provide all the operations necessary
7013         to check them, without causing compile-time errors. Programmers can do this
7014         using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
7015         on C++17 compilers, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7016         (or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if_c">boost::contract::condition_if_c</link></computeroutput>)
7017         on non-C++17 compilers.
7018       </para>
7019       <para>
7020         For example, let's consider the following <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>
7021         class template equivalent to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>.
7022         C++ <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput> does
7023         not require that its value type parameter <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
7024         has an equality operator <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">==</phrase></computeroutput>
7025         (it only requires <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> to be
7026         copy constructible, see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase></computeroutput>
7027         documentation). However, the contracts for the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase></computeroutput>
7028         public function include a postcondition <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">value</phrase></computeroutput>
7029         that introduces the new requirement that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
7030         must also have an equality operator <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">==</phrase></computeroutput>.
7031         Programmers can specify this postcondition as usual with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">back</phrase><phrase role="special">()</phrase>
7032         <phrase role="special">==</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase></computeroutput> an let the program fail to compile when
7033         users instantiate <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></computeroutput>
7034         with a type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> that does not
7035         provide an equality operator <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">==</phrase></computeroutput>.
7036         Otherwise, programmers can guard this postcondition using C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
7037         to evaluate the asserted condition only for types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
7038         that have an equality operator <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">==</phrase></computeroutput>
7039         and skip it otherwise. <footnote id="boost_contract.extras.assertion_requirements__templates_.f0">
7040         <para>
7041           <emphasis role="bold">Rationale:</emphasis> <link linkend="N1962_anchor">[N1962]</link>
7042           and other proposals to add contracts to C++ do not provide a mechanism
7043           to selectively disable assertions based on their type requirements. However,
7044           this library provides such a mechanism to allow to program contracts for
7045           template code without necessarily adding extra type requirements that would
7046           not be present if it was not for the contracts (so compiling the code with
7047           and without contracts will not alter the type requirements of the program).
7048           Something similar could be achieved combing C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
7049           <phrase role="keyword">constexpr</phrase></computeroutput> with <link linkend="N1962_anchor">[N1962]</link>
7050           or <link linkend="P0380_anchor">[P0380]</link> so that contract assertions
7051           within template code could be guarded by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
7052           <phrase role="keyword">constexpr</phrase></computeroutput> statements checking the
7053           related type requirements (<link linkend="N1962_anchor">[N1962]</link>
7054           already allows of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase></computeroutput> statements
7055           in contracts under the name of <emphasis>select assertions</emphasis>,
7056           <link linkend="P0380_anchor">[P0380]</link> does not so probably <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase></computeroutput> statements should be added to <link linkend="P0380_anchor">[P0380]</link>
7057           as well). For example, assuming C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
7058           <phrase role="keyword">constexpr</phrase></computeroutput> can be used within <link linkend="P0380_anchor">[P0380]</link> contracts:
7059 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
7060 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
7061 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7062     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
7063         <phrase role="special">[[</phrase><phrase role="identifier">ensures</phrase><phrase role="special">:</phrase> <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">value</phrase><phrase role="special">]]</phrase>
7064     <phrase role="special">...</phrase>
7065 <phrase role="special">};</phrase>
7066 </programlisting>
7067         </para>
7068         </footnote> For example:
7069       </para>
7070 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
7071 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
7072 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7073     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7074         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boot</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7075             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7076                 <phrase role="comment">// Guard with `if constexpr` for T without `==`.</phrase>
7077                 <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase>
7078                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
7079             <phrase role="special">})</phrase>
7080         <phrase role="special">;</phrase>
7081
7082         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
7083     <phrase role="special">}</phrase>
7084
7085     <phrase role="comment">/* ... */</phrase>
7086 </programlisting>
7087       <para>
7088         More in general, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
7089         can be used to guard a mix of both old value copies and contract assertions
7090         that introduce specific extra type requirements. For example, the following
7091         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">swap</phrase></computeroutput> function can be called
7092         on any type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> that is movable
7093         but its old value copies and postcondition assertions are evaluated only
7094         for types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> that are also
7095         copyable and have an equality operator <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">==</phrase></computeroutput>
7096         (see <ulink url="../../example/features/if_constexpr.cpp"><literal moreinfo="none">if_constexpr.cpp</literal></ulink>):
7097       </para>
7098       <para>
7099 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
7100 <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">y</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7101     <phrase role="keyword">constexpr</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">is_old_value_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase> <phrase role="special">&amp;&amp;</phrase>
7102             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">;</phrase>
7103     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_x</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_y</phrase><phrase role="special">;</phrase>
7104     <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">b</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Contract requires copyable T...</phrase>
7105         <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
7106         <phrase role="identifier">old_y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase><phrase role="special">);</phrase>
7107     <phrase role="special">}</phrase>
7108     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
7109         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7110             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">b</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// ... and T with `==`...</phrase>
7111                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_y</phrase><phrase role="special">);</phrase>
7112                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase><phrase role="special">);</phrase>
7113             <phrase role="special">}</phrase>
7114         <phrase role="special">})</phrase>
7115     <phrase role="special">;</phrase>
7116
7117     <phrase role="identifier">T</phrase> <phrase role="identifier">t</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase> <phrase role="comment">// ...but body only requires movable T.</phrase>
7118     <phrase role="identifier">x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase><phrase role="special">);</phrase>
7119     <phrase role="identifier">y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase><phrase role="identifier">t</phrase><phrase role="special">);</phrase>
7120 <phrase role="special">}</phrase>
7121 </programlisting>
7122       </para>
7123       <bridgehead renderas="sect4" id="boost_contract.extras.assertion_requirements__templates_.h0">
7124         <phrase id="boost_contract.extras.assertion_requirements__templates_.no__code__phrase_role__keyword__if__phrase___phrase_role__keyword__constexpr__phrase___code___no_c__17_"/><link linkend="boost_contract.extras.assertion_requirements__templates_.no__code__phrase_role__keyword__if__phrase___phrase_role__keyword__constexpr__phrase___code___no_c__17_">No
7125         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
7126         (no C++17)</link>
7127       </bridgehead>
7128       <para>
7129         On non-C++17 compilers where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput> is not available, it is possible
7130         to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7131         to skip assertions based on type requirements (even if this code is less
7132         readable and more verbose than using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
7133         <phrase role="keyword">constexpr</phrase></computeroutput>). For example (see <ulink url="../../example/features/condition_if.cpp"><literal moreinfo="none">condition_if.cpp</literal></ulink>):
7134       </para>
7135       <para>
7136 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
7137 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
7138 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7139     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7140         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7141             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7142                 <phrase role="comment">// Instead of `ASSERT(back() == value)` for T without `==`.</phrase>
7143                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
7144                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
7145                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;(),</phrase>
7146                             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">back</phrase><phrase role="special">()),</phrase>
7147                             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase>
7148                         <phrase role="special">)</phrase>
7149                     <phrase role="special">)</phrase>
7150                 <phrase role="special">);</phrase>
7151             <phrase role="special">})</phrase>
7152         <phrase role="special">;</phrase>
7153
7154         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
7155     <phrase role="special">}</phrase>
7156
7157     <phrase role="comment">/* ... */</phrase>
7158 </programlisting>
7159       </para>
7160       <para>
7161         More in general, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7162         is used as follow:
7163       </para>
7164 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Pred</phrase><phrase role="special">&gt;(</phrase>
7165     <phrase role="identifier">cond</phrase>
7166 <phrase role="special">)</phrase>
7167 </programlisting>
7168       <para>
7169         Where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred</phrase></computeroutput> is a nullary boolean
7170         meta-function and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">cond</phrase></computeroutput> is
7171         a nullary boolean functor. If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase></computeroutput>
7172         is statically evaluated to be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>
7173         at compile-time then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">cond</phrase><phrase role="special">()</phrase></computeroutput> is called at run-time and its boolean result
7174         is returned by the enclosing <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7175         call. Otherwise, if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase></computeroutput>
7176         is statically evaluated to be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">false</phrase></computeroutput>
7177         at compile-time then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7178         trivially returns <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>. Therefore,
7179         if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">cond</phrase></computeroutput> is a functor template
7180         instantiation (not just a functor) then its call that contains the assertion
7181         operations with the extra type requirements (e.g., the equality operator
7182         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">==</phrase></computeroutput>) will not be actually instantiated
7183         and compiled unless the compiler determines at compile-time that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase></computeroutput> is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>
7184         (when used this way, functor templates like <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase></computeroutput>
7185         and C++14 generic lambdas can be used to program <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">cond</phrase></computeroutput>,
7186         but C++11 lambdas cannot).
7187       </para>
7188       <para>
7189         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7190         function template is a special case of the more general <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput>,
7191         specifically <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">Pred</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase></computeroutput> is logically equivalent to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&lt;</phrase><phrase role="identifier">Pred</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">cond</phrase><phrase role="special">).</phrase><phrase role="identifier">else_</phrase><phrase role="special">([]</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase>
7192         <phrase role="keyword">true</phrase><phrase role="special">;</phrase> <phrase role="special">})</phrase></computeroutput>. <footnote id="boost_contract.extras.assertion_requirements__templates_.f1">
7193         <para>
7194           The internal implementation of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7195           is optimized and it does not actually use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput>.
7196         </para>
7197         </footnote> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput>
7198         function template also accepts a number of optional <emphasis>else-if</emphasis>
7199         statements and one optional <emphasis>else</emphasis> statement:
7200       </para>
7201 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">call_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Pred1</phrase><phrase role="special">&gt;(</phrase>
7202     <phrase role="identifier">t1</phrase>
7203 <phrase role="special">).</phrase><phrase role="keyword">template</phrase> <phrase role="identifier">else_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Pred2</phrase><phrase role="special">&gt;(</phrase>          <phrase role="comment">// Optional.</phrase>
7204     <phrase role="identifier">t2</phrase>
7205 <phrase role="special">)</phrase>
7206 <phrase role="special">...</phrase>                                 <phrase role="comment">// Optionally, other `else_if` statements.</phrase>
7207 <phrase role="special">.</phrase><phrase role="identifier">else_</phrase><phrase role="special">(</phrase>                             <phrase role="comment">// Optional for `void` functors, otherwise required.</phrase>
7208     <phrase role="identifier">e</phrase>
7209 <phrase role="special">)</phrase>
7210 </programlisting>
7211       <para>
7212         Where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred1</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred2</phrase></computeroutput>, ... are nullary boolean meta-functions
7213         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t1</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t2</phrase></computeroutput>,
7214         ..., <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">e</phrase></computeroutput> are nullary functors.
7215         The return types of the functor calls <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t1</phrase><phrase role="special">()</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t2</phrase><phrase role="special">()</phrase></computeroutput>, ..., <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">e</phrase><phrase role="special">()</phrase></computeroutput> must either be all the same (including
7216         possibly all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>) or be of
7217         types implicitly convertible into one another. At run-time <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput> will
7218         call the functor <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t1</phrase><phrase role="special">()</phrase></computeroutput>,
7219         or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t2</phrase><phrase role="special">()</phrase></computeroutput>,
7220         ..., or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">e</phrase><phrase role="special">()</phrase></computeroutput>
7221         depending on which meta-function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred1</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase></computeroutput>,
7222         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred2</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase></computeroutput>, ... is statically evaluated to be
7223         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput> or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">false</phrase></computeroutput>
7224         at compile-time, and it will return the value returned by the functor being
7225         called. If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t1</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t2</phrase></computeroutput>, ..., <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">e</phrase></computeroutput>
7226         are functor template instantiations (not just functors) then their code will
7227         only be compiled if the compiler determines they need to be actually called
7228         at run-time (so only if the related <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred1</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase></computeroutput>,
7229         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Pred2</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase></computeroutput>, ... are respectively evaluated to
7230         be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput> or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">false</phrase></computeroutput>
7231         at compile-time). All the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">else_if</phrase><phrase role="special">&lt;...&gt;(...)</phrase></computeroutput> statements are optional.
7232         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">else_</phrase><phrase role="special">(...)</phrase></computeroutput>
7233         statement is optional if the functor calls return <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>,
7234         otherwise it is required.
7235       </para>
7236       <para>
7237         In general, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput>
7238         can be used to program contract assertions that compile and check different
7239         functor templates depending on related predicates being statically evaluated
7240         to be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput> or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">false</phrase></computeroutput> at compile-time (but in most cases
7241         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7242         should be sufficient and less verbose to use). The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if_c">boost::contract::condition_if_c</link></computeroutput>,
7243         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if_c">boost::contract::call_if_c</link></computeroutput>,
7244         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">else_if_c</phrase></computeroutput>
7245         function templates work similarly to their counterparts without the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_c</phrase></computeroutput> postfix
7246         seen so far, but they take their predicate template parameters as static
7247         boolean values instead of nullary boolean meta-functions.
7248       </para>
7249       <para>
7250         On compilers that support C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
7251         <phrase role="keyword">constexpr</phrase></computeroutput> there should be no need
7252         to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
7253         or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput>
7254         because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
7255         can be used instead (making the code more readable and easier to program).
7256         <footnote id="boost_contract.extras.assertion_requirements__templates_.f2">
7257         <para>
7258           <para>
7259             A part from its use within contracts, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput>
7260             can be used together with C++14 generic lambdas to emulate C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
7261             (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">hana</phrase><phrase role="special">::</phrase><phrase role="identifier">if_</phrase></computeroutput> and probably other approaches can
7262             also be used together with generic lambdas to emulate C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase></computeroutput>
7263             on C++14 compilers). For example, the following implementation of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">myadvance</phrase></computeroutput> will compile since C++14
7264             and it is more concise, easier to read and maintain than the usual implementation
7265             of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">advance</phrase></computeroutput> that uses tag dispatching (see
7266             <ulink url="../../example/features/call_if_cxx14.cpp"><literal moreinfo="none">call_if_cxx14.cpp</literal></ulink>):
7267           </para>
7268           <para>
7269 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Dist</phrase><phrase role="special">&gt;</phrase>
7270 <phrase role="keyword">void</phrase> <phrase role="identifier">myadvance</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">Dist</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7271     <phrase role="identifier">Iter</phrase><phrase role="special">*</phrase> <phrase role="identifier">p</phrase> <phrase role="special">=</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">i</phrase><phrase role="special">;</phrase> <phrase role="comment">// So captures change actual pointed iterator value.</phrase>
7272     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">call_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">is_random_access_iterator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
7273         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">([]</phrase> <phrase role="special">(</phrase><phrase role="keyword">auto</phrase> <phrase role="identifier">p</phrase><phrase role="special">,</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// C++14 generic lambda.</phrase>
7274             <phrase role="special">*</phrase><phrase role="identifier">p</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
7275         <phrase role="special">},</phrase> <phrase role="identifier">p</phrase><phrase role="special">,</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
7276     <phrase role="special">).</phrase><phrase role="keyword">template</phrase> <phrase role="identifier">else_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">is_bidirectional_iterator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
7277         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">([]</phrase> <phrase role="special">(</phrase><phrase role="keyword">auto</phrase> <phrase role="identifier">p</phrase><phrase role="special">,</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7278             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">--)</phrase> <phrase role="special">++*</phrase><phrase role="identifier">p</phrase><phrase role="special">;</phrase>
7279             <phrase role="keyword">else</phrase> <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">++)</phrase> <phrase role="special">--*</phrase><phrase role="identifier">p</phrase><phrase role="special">;</phrase>
7280         <phrase role="special">},</phrase> <phrase role="identifier">p</phrase><phrase role="special">,</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
7281     <phrase role="special">).</phrase><phrase role="keyword">template</phrase> <phrase role="identifier">else_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">is_input_iterator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
7282         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">([]</phrase> <phrase role="special">(</phrase><phrase role="keyword">auto</phrase> <phrase role="identifier">p</phrase><phrase role="special">,</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7283             <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">--)</phrase> <phrase role="special">++*</phrase><phrase role="identifier">p</phrase><phrase role="special">;</phrase>
7284         <phrase role="special">},</phrase> <phrase role="identifier">p</phrase><phrase role="special">,</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
7285     <phrase role="special">).</phrase><phrase role="identifier">else_</phrase><phrase role="special">(</phrase>
7286         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">([]</phrase> <phrase role="special">(</phrase><phrase role="keyword">auto</phrase> <phrase role="identifier">false_</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7287             <phrase role="keyword">static_assert</phrase><phrase role="special">(</phrase><phrase role="identifier">false_</phrase><phrase role="special">,</phrase> <phrase role="string">"requires at least input iterator"</phrase><phrase role="special">);</phrase>
7288         <phrase role="special">},</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">false_type</phrase><phrase role="special">())</phrase> <phrase role="comment">// Use constexpr value.</phrase>
7289     <phrase role="special">);</phrase>
7290 <phrase role="special">}</phrase>
7291 </programlisting>
7292           </para>
7293           <para>
7294             Of course, since C++17 the implementation that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
7295             <phrase role="keyword">constexpr</phrase></computeroutput> is even more readable
7296             and concise:
7297 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Dist</phrase><phrase role="special">&gt;</phrase>
7298 <phrase role="keyword">void</phrase> <phrase role="identifier">myadvance</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">Dist</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7299     <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">is_random_access_iterator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7300         <phrase role="identifier">i</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
7301     <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">is_bidirectional_iterator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7302         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">--)</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">;</phrase>
7303         <phrase role="keyword">else</phrase> <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">++)</phrase> <phrase role="special">--</phrase><phrase role="identifier">i</phrase><phrase role="special">;</phrase>
7304     <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">is_input_iterator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Iter</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7305         <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">--)</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">;</phrase>
7306     <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase>
7307         <phrase role="keyword">static_assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">,</phrase> <phrase role="string">"requires at least input iterator"</phrase><phrase role="special">);</phrase>
7308     <phrase role="special">}</phrase>
7309 <phrase role="special">}</phrase>
7310 </programlisting>
7311           </para>
7312         </para>
7313         </footnote>
7314       </para>
7315     </section>
7316     <section id="boost_contract.extras.volatile_public_functions">
7317       <title><link linkend="boost_contract.extras.volatile_public_functions">Volatile
7318       Public Functions</link></title>
7319       <para>
7320         This library allows to specify a different set of class invariants to check
7321         for volatile public functions. These <emphasis>volatile class invariants</emphasis>
7322         are programmed in a public <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> function, named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>,
7323         taking no argument, and returning <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>
7324         (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999724496">BOOST_CONTRACT_INVARIANT_FUNC</link></computeroutput>
7325         to name the invariant function differently from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">invariant</phrase></computeroutput>
7326         and <link linkend="boost_contract.advanced.access_specifiers">Access Specifiers</link>
7327         to not have to declare it <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>).
7328         Classes that do no have invariants for their volatile public functions, simply
7329         do not declare the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> function.
7330       </para>
7331       <para>
7332         In general, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7333         invariants work the same as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7334         invariants (see <link linkend="boost_contract.tutorial.class_invariants">Class
7335         Invariants</link>) with the only difference that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>
7336         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7337         functions check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7338         invariants while non-<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> (i.e.,
7339         neither <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> nor <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>) and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7340         functions check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariants.
7341         A given class can specify any combination of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>,
7342         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>,
7343         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariant functions
7344         (see <link linkend="boost_contract.tutorial.class_invariants">Class Invariants</link>):
7345         <footnote id="boost_contract.extras.volatile_public_functions.f0">
7346         <para>
7347           <emphasis role="bold">Rationale:</emphasis> Constructors and destructors
7348           check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7349           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariants in that
7350           order because the qualifier that can be applied to more calls is checked
7351           first (note that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7352           calls can be made on any object while <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7353           calls cannot be made on <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>
7354           objects, in that sense the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7355           <phrase role="keyword">volatile</phrase></computeroutput> qualifier can be applied
7356           to more calls than <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> alone
7357           can). This is consistent with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
7358           class invariants that are checked even before <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7359           <phrase role="keyword">volatile</phrase></computeroutput> invariants (the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput> classifier can be applied to even
7360           more calls than <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>,
7361           in fact an object is not even needed to make static calls).
7362         </para>
7363         </footnote>
7364       </para>
7365       <itemizedlist>
7366         <listitem>
7367           <simpara>
7368             Constructors check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
7369             invariants at entry and exit (even if an exception is thrown), plus
7370             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7371             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariants in
7372             that order at exit but only if no exception is thrown.
7373           </simpara>
7374         </listitem>
7375         <listitem>
7376           <simpara>
7377             Destructors check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
7378             invariants at entry and exit (even if an exception is thrown), plus
7379             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7380             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariants in
7381             that order at entry (and at exit but only if an exception is thrown,
7382             even is destructors should in general never throw in C++).
7383           </simpara>
7384         </listitem>
7385         <listitem>
7386           <simpara>
7387             Both non-<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> public functions check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7388             invariants at entry and at exit (even if an exception is thrown).
7389           </simpara>
7390         </listitem>
7391         <listitem>
7392           <simpara>
7393             Both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7394             public functions check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
7395             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7396             invariants at entry and at exit (even if an exception is thrown).
7397           </simpara>
7398         </listitem>
7399       </itemizedlist>
7400       <para>
7401         These rules ensure that volatile class invariants are correctly checked (see
7402         <link linkend="boost_contract.contract_programming_overview.constructor_calls">Constructor
7403         Calls</link>, <link linkend="boost_contract.contract_programming_overview.destructor_calls">Destructor
7404         Calls</link>, and <link linkend="boost_contract.contract_programming_overview.public_function_calls">Public
7405         Function Calls</link>). For example (see <ulink url="../../example/features/volatile.cpp"><literal moreinfo="none">volatile.cpp</literal></ulink>):
7406       </para>
7407       <para>
7408 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
7409 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7410     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">();</phrase>     <phrase role="comment">// Static invariants.</phrase>
7411     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">;</phrase>    <phrase role="comment">// Volatile invariants.</phrase>
7412     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>             <phrase role="comment">// Const invariants.</phrase>
7413
7414     <phrase role="identifier">u</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check static, volatile, and const invariants.</phrase>
7415         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase><phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7416     <phrase role="special">}</phrase>
7417
7418     <phrase role="special">~</phrase><phrase role="identifier">u</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check static, volatile, and const invariants.</phrase>
7419         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7420     <phrase role="special">}</phrase>
7421
7422     <phrase role="keyword">void</phrase> <phrase role="identifier">nc</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check static and const invariants.</phrase>
7423         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7424     <phrase role="special">}</phrase>
7425
7426     <phrase role="keyword">void</phrase> <phrase role="identifier">c</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check static and const invariants.</phrase>
7427         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7428     <phrase role="special">}</phrase>
7429
7430     <phrase role="keyword">void</phrase> <phrase role="identifier">v</phrase><phrase role="special">()</phrase> <phrase role="keyword">volatile</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check static and volatile invariants.</phrase>
7431         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7432     <phrase role="special">}</phrase>
7433
7434     <phrase role="keyword">void</phrase> <phrase role="identifier">cv</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check static and volatile invariants.</phrase>
7435         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7436     <phrase role="special">}</phrase>
7437
7438     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">s</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Check static invariants only.</phrase>
7439         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;();</phrase>
7440     <phrase role="special">}</phrase>
7441 <phrase role="special">};</phrase>
7442 </programlisting>
7443       </para>
7444       <para>
7445         This library does not automatically check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7446         <phrase role="keyword">volatile</phrase></computeroutput> invariants for non-<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput> functions. However, if the contract
7447         specifications require it, programmers can explicitly call the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7448         invariant function from the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7449         invariant function (preferably in that order to be consistent with the order
7450         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7451         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariants are checked
7452         for constructors and destructors). That way all public functions, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput> or not, will check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7453         invariants (while only <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7454         and non-<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> public functions
7455         will check only <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariants,
7456         correctly so because the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>
7457         qualifier shall not be stripped away): <footnote id="boost_contract.extras.volatile_public_functions.f1">
7458         <para>
7459           <emphasis role="bold">Rationale:</emphasis> Note that while all public
7460           functions can be made to check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7461           <phrase role="keyword">volatile</phrase></computeroutput> invariants, it is never
7462           possible to make volatile public functions check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7463           non-volatile invariants. That is because both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7464           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput> can always be
7465           added but never stripped in C++ (a part from forcefully via <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const_cast</phrase></computeroutput>) but <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7466           is always automatically added by this library in order to enforce contract
7467           constant-correctness (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
7468           That said, it would be too stringent for this library to also automatically
7469           add <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput> and require all
7470           functions to check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> (not just <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>)
7471           invariants because only <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>
7472           members can be accessed from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7473           <phrase role="keyword">volatile</phrase></computeroutput> invariants so there could
7474           be many <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> (but not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>)
7475           members that are accessible from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7476           invariants but not from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> invariants. To avoid this confusion,
7477           this library has chosen to draw a clear dichotomy between <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7478           <phrase role="keyword">volatile</phrase></computeroutput> invariants so that only
7479           volatile public functions check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7480           <phrase role="keyword">volatile</phrase></computeroutput> invariants and only non-volatile
7481           public functions check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
7482           (but not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>)
7483           invariants. This is a clear distinction and it should serve most cases.
7484           If programmers need non-volatile public functions to also check <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
7485           invariants, they can explicitly do so by calling the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase>
7486           <phrase role="keyword">volatile</phrase></computeroutput> invariant function from
7487           the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> invariant function
7488           as shown in this documentation.
7489         </para>
7490         </footnote>
7491       </para>
7492 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
7493 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7494     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase>                 <phrase role="comment">// Volatile invariants.</phrase>
7495
7496     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
7497         <phrase role="keyword">auto</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="identifier">cv</phrase> <phrase role="special">=</phrase> <phrase role="keyword">this</phrase><phrase role="special">;</phrase> <phrase role="identifier">cv</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">invariant</phrase><phrase role="special">();</phrase>    <phrase role="comment">// Call `const volatile` invariant function above.</phrase>
7498         <phrase role="special">...</phrase>                                                 <phrase role="comment">// Other non-volatile invariants.</phrase>
7499     <phrase role="special">}</phrase>
7500
7501     <phrase role="special">...</phrase>
7502 <phrase role="special">};</phrase>
7503 </programlisting>
7504       <para>
7505         (As usual, private and protected functions do not check any invariant, not
7506         even when they are <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>
7507         or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>,
7508         see <link linkend="boost_contract.advanced.private_and_protected_functions">Private
7509         and Protected Functions</link>).
7510       </para>
7511     </section>
7512     <section id="boost_contract.extras.move_operations">
7513       <title><link linkend="boost_contract.extras.move_operations">Move Operations</link></title>
7514       <para>
7515         As with all public operations of a class, also public move operations should
7516         maintain class invariants (see <link linkend="Stroustrup13_anchor">[Stroustrup13]</link>,
7517         p. 520). Specifically, at a minimum C++ requires the following:
7518       </para>
7519       <itemizedlist>
7520         <listitem>
7521           <simpara>
7522             The moved-from object can be copy assigned.
7523           </simpara>
7524         </listitem>
7525         <listitem>
7526           <simpara>
7527             The moved-from object can be move assigned.
7528           </simpara>
7529         </listitem>
7530         <listitem>
7531           <simpara>
7532             The moved-from object can be destroyed (if not for any other reason,
7533             this requires that class invariants are maintained by move operations
7534             because the destructor of the moved-from object requires class invariants
7535             to be satisfied at its entry, as always with destructors see <link linkend="boost_contract.contract_programming_overview.destructor_calls">Destructor
7536             Calls</link>).
7537           </simpara>
7538         </listitem>
7539       </itemizedlist>
7540       <para>
7541         Therefore, both the move constructor and the move assignment operator need
7542         to maintain the class invariants of the moved-from object so their contracts
7543         can be programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>
7544         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
7545         as usual. For example (see <ulink url="../../example/features/move.cpp"><literal moreinfo="none">move.cpp</literal></ulink>):
7546       </para>
7547       <para>
7548 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">circular_buffer</phrase> <phrase role="special">:</phrase>
7549         <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">circular_buffer</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
7550 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7551     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
7552         <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">moved</phrase><phrase role="special">())</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Do not check (some) invariants for moved-from objects.</phrase>
7553             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
7554         <phrase role="special">}</phrase>
7555         <phrase role="comment">// More invariants here that hold also for moved-from objects (e.g.,</phrase>
7556         <phrase role="comment">// all assertions necessary to successfully destroy moved-from objects).</phrase>
7557     <phrase role="special">}</phrase>
7558
7559     <phrase role="comment">// Move constructor.</phrase>
7560     <phrase role="identifier">circular_buffer</phrase><phrase role="special">(</phrase><phrase role="identifier">circular_buffer</phrase><phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
7561         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">circular_buffer</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
7562             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">moved</phrase><phrase role="special">());</phrase>
7563         <phrase role="special">})</phrase>
7564     <phrase role="special">{</phrase>
7565         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7566             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7567                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">moved</phrase><phrase role="special">());</phrase>
7568                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">moved</phrase><phrase role="special">());</phrase>
7569             <phrase role="special">})</phrase>
7570         <phrase role="special">;</phrase>
7571
7572         <phrase role="identifier">move</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">circular_buffer</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">other</phrase><phrase role="special">));</phrase>
7573     <phrase role="special">}</phrase>
7574
7575     <phrase role="comment">// Move assignment.</phrase>
7576     <phrase role="identifier">circular_buffer</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase><phrase role="identifier">circular_buffer</phrase><phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7577         <phrase role="comment">// Moved-from can be (move) assigned (so no pre `!moved()` here).</phrase>
7578         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7579             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7580                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">moved</phrase><phrase role="special">());</phrase>
7581             <phrase role="special">})</phrase>
7582             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7583                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">moved</phrase><phrase role="special">());</phrase>
7584                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">moved</phrase><phrase role="special">());</phrase>
7585             <phrase role="special">})</phrase>
7586         <phrase role="special">;</phrase>
7587
7588         <phrase role="keyword">return</phrase> <phrase role="identifier">move</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">circular_buffer</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">other</phrase><phrase role="special">));</phrase>
7589     <phrase role="special">}</phrase>
7590
7591     <phrase role="special">~</phrase><phrase role="identifier">circular_buffer</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
7592         <phrase role="comment">// Moved-from can always be destroyed (in fact no preconditions).</phrase>
7593         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7594     <phrase role="special">}</phrase>
7595
7596     <phrase role="keyword">bool</phrase> <phrase role="identifier">moved</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
7597         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7598         <phrase role="keyword">return</phrase> <phrase role="identifier">moved_</phrase><phrase role="special">;</phrase>
7599     <phrase role="special">}</phrase>
7600
7601 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
7602     <phrase role="keyword">bool</phrase> <phrase role="identifier">moved_</phrase><phrase role="special">;</phrase>
7603
7604     <phrase role="comment">/* ... */</phrase>
7605 </programlisting>
7606       </para>
7607       <para>
7608         This example assumes that it is possible to call the public function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">moved</phrase><phrase role="special">()</phrase></computeroutput>
7609         on the moved-from object. <footnote id="boost_contract.extras.move_operations.f0">
7610         <para>
7611           In this example, the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">moved</phrase><phrase role="special">()</phrase></computeroutput> function is simple enough that programmers
7612           could decide to not even call <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
7613           from it for optimization reasons. However, calling <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
7614           from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">moved</phrase><phrase role="special">()</phrase></computeroutput>
7615           has no negative impact, a part from run-time overhead, because this library
7616           automatically disables contract checking while checking other contracts
7617           (so this call will not cause infinite recursion).
7618         </para>
7619         </footnote>
7620       </para>
7621       <note>
7622         <para>
7623           The default move constructor and move assignment operator generated by
7624           C++ will not automatically check contracts. Therefore, unless the move
7625           operations are not public or they have no preconditions, no postconditions,
7626           and their class has no invariants, programmers should manually define them
7627           using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>,
7628           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>,
7629           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>
7630           instead of relying on their default implementations generated by C++. (Same
7631           as for all other operations automatically implemented by C++.)
7632         </para>
7633       </note>
7634       <para>
7635         As always, programmers can decide to not program contracts for a given type.
7636         Specifically, they might decide to not program contracts for a class that
7637         needs to be moved in order to avoid the run-time overhead of checking contract
7638         assertions and to maximize performance (see <link linkend="boost_contract.contract_programming_overview.benefits_and_costs">Benefits
7639         and Costs</link>).
7640       </para>
7641     </section>
7642     <section id="boost_contract.extras.unions">
7643       <title><link linkend="boost_contract.extras.unions">Unions</link></title>
7644       <para>
7645         A C++ <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">union</phrase></computeroutput> cannot have virtual
7646         functions, base classes, and cannot be used as a base class thus subcontracting
7647         (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput>,
7648         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>,
7649         etc.) do not apply to unions. Also a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">union</phrase></computeroutput>
7650         cannot inherit from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
7651         (because it cannot have base classes), instead <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
7652         is used to declare a local object that checks constructor preconditions (at
7653         the very beginning of the constructor before old value copies and other contracts,
7654         see declaration of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pre</phrase></computeroutput> in
7655         the example below). A part from that, this library is used as usual to program
7656         contracts for unions. For example (see <ulink url="../../example/features/union.cpp"><literal moreinfo="none">union.cpp</literal></ulink>):
7657       </para>
7658       <para>
7659 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">union</phrase> <phrase role="identifier">positive</phrase> <phrase role="special">{</phrase>
7660 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7661     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Static class invariants (as usual).</phrase>
7662         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
7663     <phrase role="special">}</phrase>
7664
7665     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Class invariants (as usual).</phrase>
7666         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">i_</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
7667         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">d_</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
7668     <phrase role="special">}</phrase>
7669
7670     <phrase role="comment">// Contracts for constructor, as usual but...</phrase>
7671     <phrase role="keyword">explicit</phrase> <phrase role="identifier">positive</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">d_</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7672         <phrase role="comment">// ...unions cannot have bases so constructor preconditions here.</phrase>
7673         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">positive</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">pre</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7674             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
7675         <phrase role="special">});</phrase>
7676         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_instances</phrase> <phrase role="special">=</phrase>
7677                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">());</phrase>
7678         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7679             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7680                 <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">y</phrase><phrase role="special">;</phrase> <phrase role="identifier">get</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase><phrase role="special">);</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase> <phrase role="special">==</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase>
7681                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_instances</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
7682             <phrase role="special">})</phrase>
7683         <phrase role="special">;</phrase>
7684
7685         <phrase role="identifier">i_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase>
7686         <phrase role="special">++</phrase><phrase role="identifier">instances_</phrase><phrase role="special">;</phrase>
7687     <phrase role="special">}</phrase>
7688
7689     <phrase role="comment">// Contracts for destructor (as usual).</phrase>
7690     <phrase role="special">~</phrase><phrase role="identifier">positive</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
7691         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_instances</phrase> <phrase role="special">=</phrase>
7692                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">());</phrase>
7693         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7694             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7695                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_instances</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
7696             <phrase role="special">})</phrase>
7697         <phrase role="special">;</phrase>
7698
7699         <phrase role="special">--</phrase><phrase role="identifier">instances_</phrase><phrase role="special">;</phrase>
7700     <phrase role="special">}</phrase>
7701
7702     <phrase role="comment">// Contracts for public function (as usual, but no virtual or override).</phrase>
7703     <phrase role="keyword">void</phrase> <phrase role="identifier">get</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
7704         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7705             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7706                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
7707             <phrase role="special">})</phrase>
7708         <phrase role="special">;</phrase>
7709
7710         <phrase role="identifier">x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">i_</phrase><phrase role="special">;</phrase>
7711     <phrase role="special">}</phrase>
7712
7713     <phrase role="comment">// Contracts for static public function (as usual).</phrase>
7714     <phrase role="keyword">static</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
7715         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">positive</phrase><phrase role="special">&gt;();</phrase>
7716         <phrase role="keyword">return</phrase> <phrase role="identifier">instances_</phrase><phrase role="special">;</phrase>
7717     <phrase role="special">}</phrase>
7718
7719 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
7720     <phrase role="keyword">int</phrase> <phrase role="identifier">i_</phrase><phrase role="special">;</phrase>
7721     <phrase role="keyword">double</phrase> <phrase role="identifier">d_</phrase><phrase role="special">;</phrase>
7722
7723     <phrase role="comment">/* ... */</phrase>
7724 </programlisting>
7725       </para>
7726     </section>
7727     <section id="boost_contract.extras.assertion_levels">
7728       <title><link linkend="boost_contract.extras.assertion_levels">Assertion Levels</link></title>
7729       <para>
7730         This library provides three predefined <emphasis>assertion levels</emphasis>
7731         that can be used to selectively disable assertions depending on their computational
7732         complexity: <footnote id="boost_contract.extras.assertion_levels.f0">
7733         <para>
7734           The assertion levels predefined by this library are similar to the default,
7735           audit, and axiom levels from <link linkend="P0380_anchor">[P0380]</link>.
7736         </para>
7737         </footnote>
7738       </para>
7739       <itemizedlist>
7740         <listitem>
7741           <simpara>
7742             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
7743             is used to assert conditions that are not computationally expensive,
7744             at least compared to the cost of executing the function body. These assertions
7745             are the ones we have seen so far, they are always checked at run-time
7746             and they cannot be disabled.
7747           </simpara>
7748         </listitem>
7749         <listitem>
7750           <simpara>
7751             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput>
7752             is used to assert conditions that are computationally expensive compared
7753             to the cost of executing the function body. These assertions are not
7754             checked at run-time unless programmers explicitly define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_AUDITS">BOOST_CONTRACT_AUDITS</link></computeroutput>
7755             (undefined by default), but the asserted conditions are always compiled
7756             and therefore validated syntactically (even when they are not actually
7757             evaluated and checked at run-time).
7758           </simpara>
7759         </listitem>
7760         <listitem>
7761           <simpara>
7762             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link></computeroutput>
7763             is used to assert conditions that are computationally prohibitive, at
7764             least compared to the cost of executing the function body. These assertions
7765             are never evaluated or checked at run-time, but the asserted conditions
7766             are always compiled and therefore validated syntactically (so these assertions
7767             can serve as formal comments to the code).
7768           </simpara>
7769         </listitem>
7770       </itemizedlist>
7771       <para>
7772         In addition, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</link></computeroutput>
7773         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</link></computeroutput>
7774         are similar to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput>
7775         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link></computeroutput>
7776         but they are used to program audit and axiom levels for implementation checks
7777         instead of assertions (see <link linkend="boost_contract.advanced.implementation_checks">Implementation
7778         Checks</link>).
7779       </para>
7780       <para>
7781         For example, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput>
7782         can be used to program computationally expensive assertions (see <ulink url="../../example/features/assertion_level.cpp"><literal moreinfo="none">assertion_level.cpp</literal></ulink>):
7783       </para>
7784       <para>
7785 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">RandomIter</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
7786 <phrase role="identifier">RandomIter</phrase> <phrase role="identifier">random_binary_search</phrase><phrase role="special">(</phrase><phrase role="identifier">RandomIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">RandomIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase>
7787         <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7788     <phrase role="identifier">RandomIter</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
7789     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
7790         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7791             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase> <phrase role="comment">// Default, not expensive.</phrase>
7792             <phrase role="comment">// Expensive O(n) assertion (use AXIOM if prohibitive instead).</phrase>
7793             <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">is_sorted</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">));</phrase>
7794         <phrase role="special">})</phrase>
7795         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7796             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
7797         <phrase role="special">})</phrase>
7798     <phrase role="special">;</phrase>
7799
7800     <phrase role="comment">/* ... */</phrase>
7801 </programlisting>
7802       </para>
7803       <para>
7804         Similarly, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_AUDITS">BOOST_CONTRACT_AUDITS</link></computeroutput>
7805         can be used to disable expensive old value copies and related assertions
7806         that use them (see <ulink url="../../example/features/assertion_level.cpp"><literal moreinfo="none">assertion_level.cpp</literal></ulink>):
7807       </para>
7808       <para>
7809 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
7810 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
7811 </programlisting>
7812       </para>
7813       <para>
7814 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7815     <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">vector</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7816         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_me</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_other</phrase><phrase role="special">;</phrase>
7817         <phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDITS</phrase>
7818             <phrase role="identifier">old_me</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
7819             <phrase role="identifier">old_other</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">);</phrase>
7820         <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// Else, skip old value copies...</phrase>
7821         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7822             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7823                 <phrase role="comment">// ...and also skip related assertions.</phrase>
7824                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_other</phrase><phrase role="special">);</phrase>
7825                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_me</phrase><phrase role="special">);</phrase>
7826             <phrase role="special">})</phrase>
7827         <phrase role="special">;</phrase>
7828
7829         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase><phrase role="special">);</phrase>
7830     <phrase role="special">}</phrase>
7831 </programlisting>
7832       </para>
7833       <para>
7834 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
7835
7836 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
7837     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
7838 <phrase role="special">};</phrase>
7839 </programlisting>
7840       </para>
7841       <para>
7842         The condition passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link></computeroutput>
7843         is compiled but not actually evaluated at run-time so this macro can be used
7844         to program computationally prohibitive assertions but also assertions that
7845         cannot actually be programmed in C++ using functions that are declared but
7846         left undefined. For example, (see <ulink url="../../example/features/assertion_level.cpp"><literal moreinfo="none">assertion_level.cpp</literal></ulink>):
7847       </para>
7848       <para>
7849 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// If valid iterator range (cannot implement in C++ but OK to use in AXIOM).</phrase>
7850 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter</phrase><phrase role="special">&gt;</phrase>
7851 <phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase> <phrase role="comment">// Only declared, not actually defined.</phrase>
7852 </programlisting>
7853       </para>
7854       <para>
7855 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
7856 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
7857 </programlisting>
7858       </para>
7859       <para>
7860 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
7861     <phrase role="identifier">iterator</phrase> <phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7862         <phrase role="identifier">iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
7863         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_capacity</phrase> <phrase role="special">=</phrase>
7864                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
7865         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
7866             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
7867                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">);</phrase>
7868                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
7869                     <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
7870                 <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase>
7871                     <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
7872                 <phrase role="special">}</phrase>
7873             <phrase role="special">})</phrase>
7874         <phrase role="special">;</phrase>
7875
7876         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
7877     <phrase role="special">}</phrase>
7878 </programlisting>
7879       </para>
7880       <para>
7881 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude">    <phrase role="comment">/* ... */</phrase>
7882
7883 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
7884     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
7885 <phrase role="special">};</phrase>
7886 </programlisting>
7887       </para>
7888       <para>
7889         In addition to these assertion levels that are predefined by this library,
7890         programmers are free to define their own. For example, the following macro
7891         could be used to program and selectively disable assertions that have exponential
7892         computational complexity <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">O</phrase><phrase role="special">(</phrase><phrase role="identifier">e</phrase><phrase role="special">^</phrase><phrase role="identifier">n</phrase><phrase role="special">)</phrase></computeroutput>:
7893       </para>
7894 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">EXPONENTIALLY_COMPLEX_ASSERTIONS</phrase>
7895     <phrase role="comment">// Following will compile and also evaluate `cond`.</phrase>
7896     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">ASSERT_EXP</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase>
7897 <phrase role="preprocessor">#else</phrase>
7898     <phrase role="comment">// Following will compile but never actually evaluate `cond`.</phrase>
7899     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">ASSERT_EXP</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">))</phrase>
7900 <phrase role="preprocessor">#endif</phrase>
7901
7902 <phrase role="special">...</phrase>
7903
7904 <phrase role="identifier">ASSERT_EXP</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>some-exponentially-complex-boolean-condition</emphasis></literal><phrase role="special">);</phrase>
7905 </programlisting>
7906     </section>
7907     <section id="boost_contract.extras.disable_contract_checking">
7908       <title><link linkend="boost_contract.extras.disable_contract_checking">Disable
7909       Contract Checking</link></title>
7910       <para>
7911         Checking contracts adds run-time overhead and can slow down program execution
7912         (see <link linkend="boost_contract.contract_programming_overview.benefits_and_costs">Benefits
7913         and Costs</link>). Therefore, programmers can define any combination of the
7914         following macros (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">-</phrase><phrase role="identifier">D</phrase></computeroutput>
7915         option in Clang and GCC, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">/</phrase><phrase role="identifier">D</phrase></computeroutput>
7916         option in MSVC, etc.) to instruct this library to not check specific groups
7917         of contract conditions at run-time:
7918       </para>
7919       <itemizedlist>
7920         <listitem>
7921           <simpara>
7922             Define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput>
7923             to not check preconditions.
7924           </simpara>
7925         </listitem>
7926         <listitem>
7927           <simpara>
7928             Define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>
7929             to not check postconditions.
7930           </simpara>
7931         </listitem>
7932         <listitem>
7933           <simpara>
7934             Define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>
7935             to not check exception guarantees.
7936           </simpara>
7937         </listitem>
7938         <listitem>
7939           <simpara>
7940             Define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999637264">BOOST_CONTRACT_NO_ENTRY_INVARIANTS</link></computeroutput>
7941             to not check class invariants at call entry.
7942           </simpara>
7943         </listitem>
7944         <listitem>
7945           <simpara>
7946             Define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link></computeroutput>
7947             to not check class invariants at call exit.
7948           </simpara>
7949         </listitem>
7950         <listitem>
7951           <simpara>
7952             Or, define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput>
7953             to not check class invariants at both call entry and exit. (This is provided
7954             for convenience, it is equivalent to defining both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999637264">BOOST_CONTRACT_NO_ENTRY_INVARIANTS</link></computeroutput>
7955             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link></computeroutput>.)
7956           </simpara>
7957         </listitem>
7958         <listitem>
7959           <simpara>
7960             Define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput>
7961             to not evaluate implementation checks.
7962           </simpara>
7963         </listitem>
7964       </itemizedlist>
7965       <note>
7966         <para>
7967           Old values can be used by both postconditions and exception guarantees
7968           so it is necessary to define both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>
7969           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>
7970           to disable old value copies.
7971         </para>
7972       </note>
7973       <para>
7974         By default, none of these macros are defined so this library checks all contracts.
7975         When these macros are defined by the user, the implementation code of this
7976         library is internally optimized to minimize as much as possible any run-time
7977         and compile-time overhead associated with checking and compiling contracts
7978         (see <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">Disable
7979         Contract Compilation</link> for techniques to completely remove any run-time
7980         and compile-time overheads associated with contract code).
7981       </para>
7982       <para>
7983         For example, programmers could decide to check all contracts during early
7984         development builds, but later check only preconditions and maybe entry invariants
7985         for release builds by defining <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>,
7986         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>,
7987         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link></computeroutput>,
7988         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput>.
7989       </para>
7990     </section>
7991     <section id="boost_contract.extras.disable_contract_compilation__macro_interface_">
7992       <title><link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">Disable
7993       Contract Compilation (Macro Interface)</link></title>
7994       <para>
7995         This library provides macros that can be used to completely disable compile-time
7996         and run-time overhead introduced by contracts but at the cost of manually
7997         programming <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> statements around contract code:
7998       </para>
7999       <itemizedlist>
8000         <listitem>
8001           <simpara>
8002             This library defines <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999605408">BOOST_CONTRACT_NO_CONSTRUCTORS</link></computeroutput>
8003             when contract checking is disabled for constructors.
8004           </simpara>
8005         </listitem>
8006         <listitem>
8007           <simpara>
8008             This library defines <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999594544">BOOST_CONTRACT_NO_DESTRUCTORS</link></computeroutput>
8009             when contract checking is disabled for destructors.
8010           </simpara>
8011         </listitem>
8012         <listitem>
8013           <simpara>
8014             This library defines <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999586272">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</link></computeroutput>
8015             when contract checking is disabled for public functions.
8016           </simpara>
8017         </listitem>
8018         <listitem>
8019           <simpara>
8020             This library defines <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999577072">BOOST_CONTRACT_NO_FUNCTIONS</link></computeroutput>
8021             when contract checking is disabled for (non-public and non-member) functions.
8022           </simpara>
8023         </listitem>
8024         <listitem>
8025           <simpara>
8026             This library defines <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></computeroutput>
8027             when old value copies are disabled.
8028           </simpara>
8029         </listitem>
8030         <listitem>
8031           <simpara>
8032             This library defines <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_ALL">BOOST_CONTRACT_NO_ALL</link></computeroutput>
8033             when all contracts above and also implementation checks (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput>)
8034             are disabled.
8035           </simpara>
8036         </listitem>
8037       </itemizedlist>
8038       <para>
8039         These macros are not configuration macros and they should not be defined
8040         directly by programmers (otherwise this library will generate compile-time
8041         errors). Instead, these macros are automatically defined by this library
8042         when programmers define <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput>,
8043         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>,
8044         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>,
8045         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput>
8046         (or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999637264">BOOST_CONTRACT_NO_ENTRY_INVARIANTS</link></computeroutput>
8047         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link></computeroutput>),
8048         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput>
8049         (see <link linkend="boost_contract.extras.disable_contract_checking">Disable
8050         Contract Checking</link>).
8051       </para>
8052       <para>
8053         Alternatively, this library provides a macro-based interface defined in
8054         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link></computeroutput>
8055         that can also be used to completely disable compile-time and run-time overheads
8056         introduced by contracts but without the burden of manually writing the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> statements. For example, the following
8057         code shows how to use both the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link></computeroutput>
8058         macro interface and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase>
8059         <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput>
8060         statements to completely disable compile-time and run-time overheads for
8061         non-member function contracts (see <ulink url="../../example/features/ifdef_macro.cpp"><literal moreinfo="none">ifdef_macro.cpp</literal></ulink>
8062         and <ulink url="../../example/features/ifdef.cpp"><literal moreinfo="none">ifdef.cpp</literal></ulink>):
8063       </para>
8064       <informaltable frame="all">
8065         <tgroup cols="2">
8066           <thead>
8067             <row>
8068               <entry>
8069                 <para>
8070                   Macro Interface
8071                 </para>
8072               </entry>
8073               <entry>
8074                 <para>
8075                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> Statements
8076                 </para>
8077               </entry>
8078             </row>
8079           </thead>
8080           <tbody>
8081             <row>
8082               <entry>
8083                 <para>
8084 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Use macro interface to completely disable contract code compilation.</phrase>
8085 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract_macro</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
8086
8087 <phrase role="keyword">int</phrase> <phrase role="identifier">inc</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8088     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
8089     <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)(</phrase><phrase role="identifier">old_x</phrase><phrase role="special">,</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
8090     <phrase role="identifier">BOOST_CONTRACT_FUNCTION</phrase><phrase role="special">()</phrase>
8091         <phrase role="identifier">BOOST_CONTRACT_PRECONDITION</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8092             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">());</phrase>
8093         <phrase role="special">})</phrase>
8094         <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8095             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8096             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase><phrase role="special">);</phrase>
8097         <phrase role="special">})</phrase>
8098     <phrase role="special">;</phrase>
8099
8100     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">++;</phrase>
8101 <phrase role="special">}</phrase>
8102 </programlisting>
8103                 </para>
8104               </entry>
8105               <entry>
8106                 <para>
8107 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Use #ifdef to completely disable contract code compilation.</phrase>
8108 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">/</phrase><phrase role="identifier">core</phrase><phrase role="special">/</phrase><phrase role="identifier">config</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
8109 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_ALL</phrase>
8110     <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
8111 <phrase role="preprocessor">#endif</phrase>
8112
8113 <phrase role="keyword">int</phrase> <phrase role="identifier">inc</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8114     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
8115     <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
8116         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
8117     <phrase role="preprocessor">#endif</phrase>
8118     <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_FUNCTIONS</phrase>
8119         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
8120             <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PRECONDITIONS</phrase>
8121                 <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8122                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">());</phrase>
8123                 <phrase role="special">})</phrase>
8124             <phrase role="preprocessor">#endif</phrase>
8125             <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_POSTCONDITIONS</phrase>
8126                 <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8127                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8128                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase><phrase role="special">);</phrase>
8129                 <phrase role="special">})</phrase>
8130             <phrase role="preprocessor">#endif</phrase>
8131         <phrase role="special">;</phrase>
8132     <phrase role="preprocessor">#endif</phrase>
8133
8134     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">++;</phrase>
8135 <phrase role="special">}</phrase>
8136 </programlisting>
8137                 </para>
8138               </entry>
8139             </row>
8140           </tbody>
8141         </tgroup>
8142       </informaltable>
8143       <para>
8144         The same can be done to disable contract code complication for private and
8145         protected functions. The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998674080">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</link></computeroutput>
8146         macro is provided to handle non-copyable old value types (similar to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>).
8147       </para>
8148       <para>
8149         For constructors, destructors, and public functions the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link></computeroutput>
8150         macro interface and the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase>
8151         <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput>
8152         statements can be used as follow (see <ulink url="../../example/features/ifdef_macro.cpp"><literal moreinfo="none">ifdef_macro.cpp</literal></ulink>
8153         and <ulink url="../../example/features/ifdef.cpp"><literal moreinfo="none">ifdef.cpp</literal></ulink>):
8154       </para>
8155       <informaltable frame="all">
8156         <tgroup cols="2">
8157           <thead>
8158             <row>
8159               <entry>
8160                 <para>
8161                   Macro Interface
8162                 </para>
8163               </entry>
8164               <entry>
8165                 <para>
8166                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> Statements
8167                 </para>
8168               </entry>
8169             </row>
8170           </thead>
8171           <tbody>
8172             <row>
8173               <entry>
8174                 <para>
8175 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">integers</phrase>
8176     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">pushable</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase>
8177     <phrase role="special">:</phrase>
8178         <phrase role="comment">// Left in code (almost no overhead).</phrase>
8179         <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">integers</phrase><phrase role="special">&gt;,</phrase>
8180         <phrase role="identifier">BASES</phrase>
8181 <phrase role="special">{</phrase>
8182     <phrase role="comment">// Followings left in code (almost no overhead).</phrase>
8183     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
8184
8185     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
8186     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
8187
8188     <phrase role="identifier">BOOST_CONTRACT_INVARIANT</phrase><phrase role="special">({</phrase>
8189         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
8190     <phrase role="special">})</phrase>
8191
8192 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
8193     <phrase role="identifier">integers</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">from</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">to</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
8194         <phrase role="identifier">BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION</phrase><phrase role="special">(</phrase><phrase role="identifier">integers</phrase><phrase role="special">)([&amp;]</phrase> <phrase role="special">{</phrase>
8195             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">to</phrase><phrase role="special">);</phrase>
8196         <phrase role="special">}),</phrase>
8197         <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">to</phrase> <phrase role="special">-</phrase> <phrase role="identifier">from</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase>
8198     <phrase role="special">{</phrase>
8199         <phrase role="identifier">BOOST_CONTRACT_CONSTRUCTOR</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
8200             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8201                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">to</phrase> <phrase role="special">-</phrase> <phrase role="identifier">from</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">));</phrase>
8202             <phrase role="special">})</phrase>
8203         <phrase role="special">;</phrase>
8204
8205         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">from</phrase><phrase role="special">;</phrase> <phrase role="identifier">x</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">to</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">-</phrase> <phrase role="identifier">from</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase>
8206     <phrase role="special">}</phrase>
8207
8208     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">integers</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
8209         <phrase role="identifier">BOOST_CONTRACT_DESTRUCTOR</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase> <phrase role="comment">// Check invariants.</phrase>
8210     <phrase role="special">}</phrase>
8211
8212     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
8213         <phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase>
8214         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase> <phrase role="comment">// Left in code (almost no overhead).</phrase>
8215     <phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
8216         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">)(</phrase><phrase role="identifier">old_size</phrase><phrase role="special">);</phrase>
8217         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">override_push_back</phrase><phrase role="special">)(</phrase>
8218                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">integers</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase>
8219             <phrase role="identifier">BOOST_CONTRACT_PRECONDITION</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8220                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
8221             <phrase role="special">})</phrase>
8222             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8223                 <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
8224             <phrase role="special">})</phrase>
8225             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8226                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8227             <phrase role="special">})</phrase>
8228             <phrase role="identifier">BOOST_CONTRACT_EXCEPT</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8229                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase><phrase role="special">);</phrase>
8230             <phrase role="special">})</phrase>
8231         <phrase role="special">;</phrase>
8232
8233         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
8234     <phrase role="special">}</phrase>
8235
8236 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
8237     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">push_back</phrase><phrase role="special">)</phrase> <phrase role="comment">// Left in code (almost no overhead).</phrase>
8238
8239     <phrase role="comment">/* ... */</phrase>
8240 </programlisting>
8241                 </para>
8242               </entry>
8243               <entry>
8244                 <para>
8245 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">integers</phrase>
8246     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">pushable</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase>
8247     <phrase role="special">:</phrase>
8248         <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PRECONDITIONS</phrase>
8249             <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">integers</phrase><phrase role="special">&gt;,</phrase> <phrase role="identifier">BASES</phrase>
8250         <phrase role="preprocessor">#else</phrase>
8251             <phrase role="identifier">BASES</phrase>
8252         <phrase role="preprocessor">#endif</phrase>
8253 <phrase role="special">{</phrase>
8254     <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_ALL</phrase>
8255         <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
8256     <phrase role="preprocessor">#endif</phrase>
8257
8258     <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
8259         <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
8260     <phrase role="preprocessor">#endif</phrase>
8261     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
8262
8263     <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_INVARIANTS</phrase>
8264         <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8265             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
8266         <phrase role="special">}</phrase>
8267     <phrase role="preprocessor">#endif</phrase>
8268
8269 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
8270     <phrase role="identifier">integers</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">from</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">to</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
8271         <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PRECONDITIONS</phrase>
8272             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">integers</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
8273                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">to</phrase><phrase role="special">);</phrase>
8274             <phrase role="special">}),</phrase>
8275         <phrase role="preprocessor">#endif</phrase>
8276         <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">to</phrase> <phrase role="special">-</phrase> <phrase role="identifier">from</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase>
8277     <phrase role="special">{</phrase>
8278         <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_CONSTRUCTORS</phrase>
8279             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
8280                 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_POSTCONDITIONS</phrase>
8281                     <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8282                         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">to</phrase> <phrase role="special">-</phrase> <phrase role="identifier">from</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">));</phrase>
8283                     <phrase role="special">})</phrase>
8284                 <phrase role="preprocessor">#endif</phrase>
8285             <phrase role="special">;</phrase>
8286         <phrase role="preprocessor">#endif</phrase>
8287
8288         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">from</phrase><phrase role="special">;</phrase> <phrase role="identifier">x</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">to</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">-</phrase> <phrase role="identifier">from</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase>
8289     <phrase role="special">}</phrase>
8290
8291     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">integers</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
8292         <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_DESTRUCTORS</phrase>
8293             <phrase role="comment">// Check invariants.</phrase>
8294             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
8295         <phrase role="preprocessor">#endif</phrase>
8296     <phrase role="special">}</phrase>
8297
8298     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
8299         <phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase>
8300         <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
8301             <phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase>
8302         <phrase role="preprocessor">#endif</phrase>
8303     <phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
8304         <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
8305             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase><phrase role="special">;</phrase>
8306         <phrase role="preprocessor">#endif</phrase>
8307         <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
8308             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
8309                     <phrase role="identifier">override_push_back</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">integers</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase>
8310                 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PRECONDITIONS</phrase>
8311                     <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8312                         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
8313                     <phrase role="special">})</phrase>
8314                 <phrase role="preprocessor">#endif</phrase>
8315                 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
8316                     <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8317                         <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
8318                     <phrase role="special">})</phrase>
8319                 <phrase role="preprocessor">#endif</phrase>
8320                 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_POSTCONDITIONS</phrase>
8321                     <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8322                         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8323                     <phrase role="special">})</phrase>
8324                 <phrase role="preprocessor">#endif</phrase>
8325                 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_EXCEPTS</phrase>
8326                     <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8327                         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase><phrase role="special">);</phrase>
8328                     <phrase role="special">})</phrase>
8329                 <phrase role="preprocessor">#endif</phrase>
8330             <phrase role="special">;</phrase>
8331         <phrase role="preprocessor">#endif</phrase>
8332
8333         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
8334     <phrase role="special">}</phrase>
8335
8336 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
8337     <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
8338         <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">push_back</phrase><phrase role="special">)</phrase>
8339     <phrase role="preprocessor">#endif</phrase>
8340
8341     <phrase role="comment">/* ... */</phrase>
8342 </programlisting>
8343                 </para>
8344               </entry>
8345             </row>
8346           </tbody>
8347         </tgroup>
8348       </informaltable>
8349       <para>
8350         Static and volatile class invariants can be programmed using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998621472">BOOST_CONTRACT_STATIC_INVARIANT</link></computeroutput>
8351         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998635328">BOOST_CONTRACT_INVARIANT_VOLATILE</link></computeroutput>
8352         respectively (these macros expand code equivalent to the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase>
8353         <phrase role="keyword">void</phrase> <phrase role="identifier">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</phrase><phrase role="special">()</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase>
8354         <phrase role="identifier">BOOST_CONTRACT_INVARIANT_FUNC</phrase><phrase role="special">()</phrase>
8355         <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
8356         functions).
8357       </para>
8358       <para>
8359         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link></computeroutput>
8360         macro interface is usually preferred because more concise and easier to use
8361         than programming <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput>
8362         statements by hand. However, C++ macros expand on a single line of code and
8363         that can make compiler errors less useful when using this macro interface
8364         plus all contract assertions within a given set of preconditions, postconditions,
8365         exception guarantees, and class invariants will list the same line number
8366         in error messages when assertions fail at run-time (but error messages still
8367         list the assertion code and that should still allow programmers to identify
8368         the specific assertion that failed). Finally, the macro interface leaves
8369         a bit of contract decorations in the code but that should add no measurable
8370         compile-time or run-time overhead (specifically, extra <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">*</phrase></computeroutput> parameters, calls to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
8371         default constructor which does nothing, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
8372         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase></computeroutput>s, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.access">boost::contract::access</link></computeroutput>
8373         friendships are left in user code even when contracts are disabled unless
8374         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> statements are used).
8375       </para>
8376       <para>
8377         Disabling contract as shown in <link linkend="boost_contract.extras.disable_contract_checking">Disable
8378         Contract Checking</link> leaves the overhead of compiling contract code plus
8379         some small run-time overhead due to the initialization of old value pointers
8380         (even if those will be all null and no old value will be actually copied),
8381         the calls to the contract functions used to initialize <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.check">boost::contract::check</link></computeroutput>
8382         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput>
8383         (even if those calls will be internally optimized by this library to essentially
8384         do nothing), etc. For truly performance critical code for which even such
8385         small run-time overhead might not be acceptable, the macro interface (or
8386         the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> statements) can be used to completely
8387         disable compile-time and run-time overheads of contracts. However, for such
8388         performance critical code even the overhead of checking simple preconditions
8389         might be too much so it might be best to not program contracts at all.
8390       </para>
8391       <para>
8392         Usually, if the overhead of checking preconditions and other assertions is
8393         already considered acceptable for an application then the compile-time overhead
8394         of contracts should not represent an issue and it should be sufficient to
8395         disable contract checking at run-time as indicated in <link linkend="boost_contract.extras.disable_contract_checking">Disable
8396         Contract Checking</link> (without a real need to use the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link></computeroutput>
8397         macro interface or the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase>
8398         <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput>
8399         statements in most cases).
8400       </para>
8401     </section>
8402     <section id="boost_contract.extras.separate_body_implementation">
8403       <title><link linkend="boost_contract.extras.separate_body_implementation">Separate
8404       Body Implementation</link></title>
8405       <para>
8406         Contracts are part of the program specifications and not of its implementation
8407         (see <link linkend="boost_contract.contract_programming_overview.specifications_vs__implementation">Specifications
8408         vs. Implementation</link>). However, this library uses function definitions
8409         to program contracts so contract code appears together with the function
8410         implementation code. This is not ideal (even if contracts programmed using
8411         this library will always appear at the very beginning of the function definition
8412         so programmers will easily be able to distinguish contract code from the
8413         rest of the function implementation code so this might not be real limitation
8414         in practise).
8415       </para>
8416       <para>
8417         In some cases, it might be desirable to completely separate the contract
8418         code from the function implementation code. For example, this could be necessary
8419         for software that ships only header files and compiled object files to its
8420         users. If contracts are programmed in function definitions that are compiled
8421         in the object files, users will not be able to see the contract code to understand
8422         semantics and usage of the functions (again, this might not be a real problem
8423         in practice for example if contracts are already somehow extracted from the
8424         source code by some tool and presented as part of the documentation of the
8425         shipped software).
8426       </para>
8427       <para>
8428         In any case, when it is truly important to separate contracts from function
8429         implementation code, function implementations can be programmed in extra
8430         <emphasis>body functions</emphasis> (here named <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_body</phrase></computeroutput>, but any other naming scheme could
8431         be used) that are compiled in object files. Function definitions that remain
8432         in header files instead will contain just contract code followed by calls
8433         to the extra body functions. This technique allows to keep the contract code
8434         in header files while separating the implementation code to source and object
8435         files. However, this adds the overhead of manually programming an extra function
8436         declaration for each body function (plus the limitation that constructor
8437         member initialization lists must be programmed in header files because that
8438         is where constructors need to be defined to list constructor contract code).
8439         <footnote id="boost_contract.extras.separate_body_implementation.f0">
8440         <para>
8441           When used as default parameter values, lambda functions allow to program
8442           code statements within function declarations. However, these lambadas cannot
8443           be effectively used to program contracts in function declarations instead
8444           of definitions. That is because the C++11 standard does not allow lambdas
8445           in function declarations to capture any variable (for the good reason that
8446           it is not at all obvious how to correctly define the semantics of such
8447           captures). For example, the following code is not valid C++ and it does
8448           not compile:
8449 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Specifications (in declaration).</phrase>
8450 <phrase role="keyword">int</phrase> <phrase role="identifier">inc</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase>
8451     <phrase role="comment">// Error: Lambdas in default parameters cannot capture `this`, `x`, or any other variable.</phrase>
8452     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">()&gt;</phrase> <phrase role="identifier">pre</phrase> <phrase role="special">=</phrase> <phrase role="special">[&amp;]</phrase> <phrase role="special">{</phrase>
8453         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">max</phrase><phrase role="special">());</phrase>
8454     <phrase role="special">},</phrase>
8455     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)&gt;</phrase> <phrase role="identifier">post</phrase>
8456         <phrase role="special">=</phrase> <phrase role="special">[&amp;]</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">old_x</phrase><phrase role="special">)</phrase>
8457     <phrase role="special">{</phrase>
8458         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8459         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_x</phrase><phrase role="special">);</phrase>
8460     <phrase role="special">}</phrase>
8461 <phrase role="special">);</phrase>
8462
8463 <phrase role="comment">// Implementation (in definition).</phrase>
8464 <phrase role="keyword">int</phrase> <phrase role="identifier">inc</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase>
8465     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">()&gt;</phrase> <phrase role="identifier">pre</phrase><phrase role="special">,</phrase>
8466     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)&gt;</phrase> <phrase role="identifier">post</phrase>
8467 <phrase role="special">)</phrase> <phrase role="special">{</phrase>
8468     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
8469     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_x</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
8470     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
8471         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="identifier">pre</phrase><phrase role="special">)</phrase>
8472         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">post</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">old_x</phrase><phrase role="special">)))</phrase>
8473     <phrase role="special">;</phrase>
8474
8475     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">++;</phrase> <phrase role="comment">// Function body.</phrase>
8476 <phrase role="special">}</phrase>
8477 </programlisting>
8478           In any case, even if the above code compiled, it would require significant
8479           boiler-plate code to bind return and old values.
8480         </para>
8481         </footnote>
8482       </para>
8483       <para>
8484         For example, the following header file only contains function declarations,
8485         contract code, and constructor member initializations, but it does not contain
8486         the code implementing the function bodies (see <ulink url="../../example/features/separate_body.hpp"><literal moreinfo="none">separate_body.hpp</literal></ulink>):
8487       </para>
8488       <para>
8489 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">iarray</phrase> <phrase role="special">:</phrase>
8490         <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
8491 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
8492     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8493         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
8494     <phrase role="special">}</phrase>
8495
8496     <phrase role="keyword">explicit</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
8497         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
8498             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">max</phrase><phrase role="special">);</phrase>
8499         <phrase role="special">}),</phrase>
8500         <phrase role="comment">// Still, member initializations must be here.</phrase>
8501         <phrase role="identifier">values_</phrase><phrase role="special">(</phrase><phrase role="keyword">new</phrase> <phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="identifier">max</phrase><phrase role="special">]),</phrase>
8502         <phrase role="identifier">capacity_</phrase><phrase role="special">(</phrase><phrase role="identifier">max</phrase><phrase role="special">)</phrase>
8503     <phrase role="special">{</phrase>
8504         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
8505             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8506                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">max</phrase><phrase role="special">);</phrase>
8507                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
8508             <phrase role="special">})</phrase>
8509         <phrase role="special">;</phrase>
8510         <phrase role="identifier">constructor_body</phrase><phrase role="special">(</phrase><phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase> <phrase role="comment">// Separate constructor body impl.</phrase>
8511     <phrase role="special">}</phrase>
8512
8513     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">iarray</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
8514         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase> <phrase role="comment">// Inv.</phrase>
8515         <phrase role="identifier">destructor_body</phrase><phrase role="special">();</phrase> <phrase role="comment">// Separate destructor body implementation.</phrase>
8516     <phrase role="special">}</phrase>
8517
8518     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8519         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
8520                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
8521         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
8522             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8523                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
8524             <phrase role="special">})</phrase>
8525             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
8526                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8527             <phrase role="special">})</phrase>
8528         <phrase role="special">;</phrase>
8529         <phrase role="identifier">push_back_body</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase> <phrase role="comment">// Separate member function body implementation.</phrase>
8530     <phrase role="special">}</phrase>
8531
8532 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
8533     <phrase role="comment">// Contracts in class declaration (above), but body implementations are not.</phrase>
8534     <phrase role="keyword">void</phrase> <phrase role="identifier">constructor_body</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
8535     <phrase role="keyword">void</phrase> <phrase role="identifier">destructor_body</phrase><phrase role="special">();</phrase>
8536     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back_body</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
8537
8538     <phrase role="comment">/* ... */</phrase>
8539 </programlisting>
8540       </para>
8541       <para>
8542         Instead, the function bodies are implemented in a separate source file (see
8543         <ulink url="../../example/features/separate_body.cpp"><literal moreinfo="none">separate_body.cpp</literal></ulink>):
8544       </para>
8545       <para>
8546 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_body</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8547     <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">values_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="keyword">int</phrase><phrase role="special">();</phrase>
8548     <phrase role="identifier">size_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
8549 <phrase role="special">}</phrase>
8550
8551 <phrase role="keyword">void</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor_body</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">values_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
8552
8553 <phrase role="keyword">void</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back_body</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">values_</phrase><phrase role="special">[</phrase><phrase role="identifier">size_</phrase><phrase role="special">++]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
8554
8555 <phrase role="comment">/* ... */</phrase>
8556 </programlisting>
8557       </para>
8558       <para>
8559         The same technique can be used for non-member, private, and protected functions,
8560         etc.
8561       </para>
8562       <note>
8563         <para>
8564           When contracts are programmed only in <literal moreinfo="none">.cpp</literal> files and
8565           also all this library headers are <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase></computeroutput>d
8566           only from <literal moreinfo="none">.cpp</literal> files, then these <literal moreinfo="none">.cpp</literal>
8567           files can be compiled disabling specific contract checking (for example,
8568           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>,
8569           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>,
8570           and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link></computeroutput>,
8571           see <link linkend="boost_contract.extras.disable_contract_checking">Disable
8572           Contract Checking</link>). Then the code in these <literal moreinfo="none">.cpp</literal>
8573           files will always have such contract checking disabled even when linked
8574           to some other user code that might have been compiled with a different
8575           set of contracts disabled (i.e., a different set of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> macros defined). This technique might
8576           be useful to ship compiled object files (e.g., for a library) that will
8577           never check some contracts (e.g., postconditions, exception guarantees,
8578           and exit invariants) regardless of the definition of the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput>
8579           macros used to compile code that links against the shipped object files.
8580         </para>
8581         <para>
8582           On the flip side, if contracts are programmed only in header files (e.g.,
8583           using extra <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_body</phrase></computeroutput>
8584           functions as shown in this section) and this library headers are <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase></computeroutput>d only in these header files
8585           that are being shipped, then end users can enable or disables contract
8586           checking of the shipped code by defining the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput> macros when they compile the shipped
8587           header files as part of their code. This technique might be useful in other
8588           situations when programmers that ship code want to leave it up the their
8589           end users to decide which contracts of the shipped code should be checked
8590           at run-time.
8591         </para>
8592       </note>
8593     </section>
8594     <section id="boost_contract.extras.no_lambda_functions__no_c__11_">
8595       <title><link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
8596       Lambda Functions (No C++11)</link></title>
8597       <para>
8598         This section shows how to use this library without C++11 lambda functions.
8599         This has some advantages:
8600       </para>
8601       <itemizedlist>
8602         <listitem>
8603           <simpara>
8604             It allows to use this library on compilers that do not support C++11
8605             lambda functions (essentially most C++03 compilers with adequate support
8606             for SFINAE can be used in that case, see <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
8607             Macros</link> to also avoid using variadic macros). <footnote id="boost_contract.extras.no_lambda_functions__no_c__11_.f0">
8608             <para>
8609               Alternatively, on compilers that do not support C++11 lambda functions,
8610               <ulink url="http://www.boost.org/doc/libs/release/libs/local_function/doc/html/index.html">Boost.LocalFunction</ulink>
8611               could be used to program the contract functors still within the function
8612               definitions (for example, see <ulink url="../../example/features/no_lambdas_local_func.cpp"><literal moreinfo="none">no_lambda_local_func.cpp</literal></ulink>).
8613               In general, such a code is less verbose than the example shown in this
8614               section that uses contract functions programmed outside of the original
8615               function definitions (about 30% less lines of code) but the contract
8616               code is hard to read. Other libraries could also be used to program
8617               the contract functors without C++11 lambda functions (Boost.Lambda,
8618               Boost.Fusion, etc.) but again all these techniques will result in contract
8619               code either more verbose, or harder to read and maintain than the code
8620               that uses C++11 lambda functions.
8621             </para>
8622             </footnote>
8623           </simpara>
8624         </listitem>
8625         <listitem>
8626           <simpara>
8627             Contract functions (i.e., the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_precondition</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_old</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_postcondition</phrase></computeroutput> functions in the example
8628             below) can be programmed to fully enforce constant-correctness and other
8629             contract requirements at compile-time (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>).
8630             <footnote id="boost_contract.extras.no_lambda_functions__no_c__11_.f1">
8631             <para>
8632               If C++ allowed lambda functions to capture variables by constant reference
8633               (for example allowing a syntax like this <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[</phrase><phrase role="keyword">const</phrase><phrase role="special">&amp;]</phrase>
8634               <phrase role="special">{</phrase> <phrase role="special">...</phrase>
8635               <phrase role="special">}</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[</phrase><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase>
8636               </computeroutput><literal moreinfo="none"><emphasis>variable-name</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase></computeroutput>,
8637               see <ulink url="https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/0UKQw9eo3N0">https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/0UKQw9eo3N0</ulink>)
8638               also lambdas could be used to program contract functors that fully
8639               enforce <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>
8640               at compile-time. Note that C++11 lambdas allow to capture variables
8641               by value (using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[=]</phrase> <phrase role="special">{</phrase>
8642               <phrase role="special">...</phrase> <phrase role="special">}</phrase></computeroutput>
8643               and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">[</phrase></computeroutput><literal moreinfo="none"><emphasis>variable-name</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase></computeroutput>)
8644               and these value captures are <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
8645               (unless the lambda is explicitly declared <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">mutable</phrase></computeroutput>)
8646               but they are not suitable to program postconditions and exception guarantees
8647               using this library (because those require capturing by reference, see
8648               <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>
8649               and <link linkend="boost_contract.tutorial.exception_guarantees">Exception
8650               Guarantees</link>), plus they introduce a copy of the captured value
8651               that might be too expensive in general and therefore not suitable for
8652               preconditions either.
8653             </para>
8654             </footnote>
8655           </simpara>
8656         </listitem>
8657         <listitem>
8658           <simpara>
8659             Code of the contract functions is separated from function body implementations
8660             (see <link linkend="boost_contract.extras.separate_body_implementation">Separate
8661             Body Implementation</link>).
8662           </simpara>
8663         </listitem>
8664       </itemizedlist>
8665       <para>
8666         However, not using C++11 lambda functions comes at the significant cost of
8667         having to manually program the extra contract functions and related boiler-plate
8668         code. For example, the header file (see <ulink url="../../example/features/no_lambdas.hpp"><literal moreinfo="none">no_lambdas.hpp</literal></ulink>):
8669       </para>
8670       <para>
8671 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">iarray</phrase> <phrase role="special">:</phrase>
8672         <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
8673 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
8674     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
8675         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
8676     <phrase role="special">}</phrase>
8677
8678     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8679         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
8680     <phrase role="special">}</phrase>
8681
8682     <phrase role="keyword">explicit</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
8683         <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">constructor_precondition</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase>
8684                 <phrase role="keyword">unsigned</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8685             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">max</phrase><phrase role="special">);</phrase>
8686         <phrase role="special">}</phrase>
8687         <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">constructor_old</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;&amp;</phrase>
8688                 <phrase role="identifier">old_instances</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8689             <phrase role="identifier">old_instances</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">());</phrase>
8690         <phrase role="special">}</phrase>
8691         <phrase role="keyword">void</phrase> <phrase role="identifier">constructor_postcondition</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase>
8692                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">old_instances</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8693             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">max</phrase><phrase role="special">);</phrase>
8694             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
8695             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_instances</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8696         <phrase role="special">}</phrase>
8697
8698     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">iarray</phrase><phrase role="special">();</phrase>
8699         <phrase role="keyword">void</phrase> <phrase role="identifier">destructor_old</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;&amp;</phrase> <phrase role="identifier">old_instances</phrase><phrase role="special">)</phrase>
8700                 <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8701             <phrase role="identifier">old_instances</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">());</phrase>
8702         <phrase role="special">}</phrase>
8703         <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">destructor_postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase>
8704                 <phrase role="identifier">old_instances</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8705             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_instances</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8706         <phrase role="special">}</phrase>
8707
8708     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
8709         <phrase role="keyword">void</phrase> <phrase role="identifier">push_back_precondition</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8710             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
8711         <phrase role="special">}</phrase>
8712         <phrase role="keyword">void</phrase> <phrase role="identifier">push_back_old</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">,</phrase>
8713                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;&amp;</phrase> <phrase role="identifier">old_size</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8714             <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
8715         <phrase role="special">}</phrase>
8716         <phrase role="keyword">void</phrase> <phrase role="identifier">push_back_postcondition</phrase><phrase role="special">(</phrase>
8717                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">old_size</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8718             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
8719         <phrase role="special">}</phrase>
8720
8721     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
8722     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
8723
8724     <phrase role="keyword">static</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">instances</phrase><phrase role="special">();</phrase>
8725
8726 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
8727     <phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="identifier">values_</phrase><phrase role="special">;</phrase>
8728     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
8729     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase>
8730     <phrase role="keyword">static</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">instances_</phrase><phrase role="special">;</phrase>
8731 <phrase role="special">};</phrase>
8732 </programlisting>
8733       </para>
8734       <para>
8735         And, the source file (see <ulink url="../../example/features/no_lambdas.cpp"><literal moreinfo="none">no_lambdas.cpp</literal></ulink>):
8736       </para>
8737       <para>
8738 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">iarray</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
8739     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
8740             <phrase role="special">&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">,</phrase> <phrase role="identifier">max</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">)),</phrase>
8741     <phrase role="identifier">values_</phrase><phrase role="special">(</phrase><phrase role="keyword">new</phrase> <phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="identifier">max</phrase><phrase role="special">]),</phrase> <phrase role="comment">// Member initializations can be here.</phrase>
8742     <phrase role="identifier">capacity_</phrase><phrase role="special">(</phrase><phrase role="identifier">max</phrase><phrase role="special">)</phrase>
8743 <phrase role="special">{</phrase>
8744     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_instances</phrase><phrase role="special">;</phrase>
8745     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
8746         <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_old</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase><phrase role="identifier">old_instances</phrase><phrase role="special">)))</phrase>
8747         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
8748             <phrase role="special">&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_postcondition</phrase><phrase role="special">,</phrase>
8749             <phrase role="keyword">this</phrase><phrase role="special">,</phrase>
8750             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">max</phrase><phrase role="special">),</phrase>
8751             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">),</phrase>
8752             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">old_instances</phrase><phrase role="special">)</phrase>
8753         <phrase role="special">))</phrase>
8754     <phrase role="special">;</phrase>
8755
8756     <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">values_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="keyword">int</phrase><phrase role="special">();</phrase>
8757     <phrase role="identifier">size_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
8758     <phrase role="special">++</phrase><phrase role="identifier">instances_</phrase><phrase role="special">;</phrase>
8759 <phrase role="special">}</phrase>
8760
8761 <phrase role="identifier">iarray</phrase><phrase role="special">::~</phrase><phrase role="identifier">iarray</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
8762     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_instances</phrase><phrase role="special">;</phrase>
8763     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
8764         <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor_old</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase>
8765                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase><phrase role="identifier">old_instances</phrase><phrase role="special">)))</phrase>
8766         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor_postcondition</phrase><phrase role="special">,</phrase>
8767                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">old_instances</phrase><phrase role="special">)))</phrase>
8768     <phrase role="special">;</phrase>
8769
8770     <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">values_</phrase><phrase role="special">;</phrase>
8771     <phrase role="special">--</phrase><phrase role="identifier">instances_</phrase><phrase role="special">;</phrase>
8772 <phrase role="special">}</phrase>
8773
8774 <phrase role="keyword">void</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
8775     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase><phrase role="special">;</phrase>
8776     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
8777         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back_precondition</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">))</phrase>
8778         <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back_old</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">),</phrase>
8779                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase><phrase role="identifier">old_size</phrase><phrase role="special">)))</phrase>
8780         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">push_back_postcondition</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase>
8781                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">old_size</phrase><phrase role="special">)))</phrase>
8782     <phrase role="special">;</phrase>
8783
8784     <phrase role="identifier">values_</phrase><phrase role="special">[</phrase><phrase role="identifier">size_</phrase><phrase role="special">++]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
8785 <phrase role="special">}</phrase>
8786
8787 <phrase role="keyword">unsigned</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8788     <phrase role="comment">// Check invariants.</phrase>
8789     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
8790     <phrase role="keyword">return</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
8791 <phrase role="special">}</phrase>
8792
8793 <phrase role="keyword">unsigned</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
8794     <phrase role="comment">// Check invariants.</phrase>
8795     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
8796     <phrase role="keyword">return</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase>
8797 <phrase role="special">}</phrase>
8798
8799 <phrase role="keyword">int</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">instances</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
8800     <phrase role="comment">// Check static invariants.</phrase>
8801     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">iarray</phrase><phrase role="special">&gt;();</phrase>
8802     <phrase role="keyword">return</phrase> <phrase role="identifier">instances_</phrase><phrase role="special">;</phrase>
8803 <phrase role="special">}</phrase>
8804
8805 <phrase role="keyword">int</phrase> <phrase role="identifier">iarray</phrase><phrase role="special">::</phrase><phrase role="identifier">instances_</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
8806 </programlisting>
8807       </para>
8808       <para>
8809         If programmers also want to fully enforce all contract programming constant-correctness
8810         requirements at compile-time, they should follow these rules when programming
8811         the contract functions (see <link linkend="boost_contract.contract_programming_overview.constant_correctness">Constant-Correctness</link>):
8812       </para>
8813       <itemizedlist>
8814         <listitem>
8815           <simpara>
8816             Precondition functions (i.e., the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_precondition</phrase></computeroutput> functions in the example
8817             above) can take their arguments either by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
8818             value or by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput>,
8819             and when they are member functions they should be either <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput> or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput>
8820             functions.
8821           </simpara>
8822         </listitem>
8823         <listitem>
8824           <simpara>
8825             Postcondition functions (i.e., the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_postcondition</phrase></computeroutput> functions in the example
8826             above) should take their arguments by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput>, and when they are member functions
8827             they should be either <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
8828             or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> functions.
8829           </simpara>
8830         </listitem>
8831         <listitem>
8832           <simpara>
8833             Similarly, exception guarantee functions (not shown in the example above)
8834             should take their arguments by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput>, and when they are member functions
8835             they should be either <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
8836             or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> functions.
8837           </simpara>
8838         </listitem>
8839         <listitem>
8840           <simpara>
8841             Old value functions (i.e., the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">...</phrase><phrase role="identifier">_old</phrase></computeroutput> functions in the example above)
8842             should take their arguments by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput> a part from old value pointers that
8843             should be taken by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&amp;</phrase></computeroutput>
8844             (so only old value pointers can be modified), and when they are member
8845             functions they should be either <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
8846             or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase></computeroutput> functions.
8847           </simpara>
8848         </listitem>
8849         <listitem>
8850           <simpara>
8851             For constructors: Precondition, old value, and exception guarantee functions
8852             should be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput> (because
8853             there is no valid object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput>
8854             if the constructor body does not run successfully, see <link linkend="boost_contract.contract_programming_overview.constructor_calls">Constructor
8855             Calls</link>).
8856           </simpara>
8857         </listitem>
8858         <listitem>
8859           <simpara>
8860             For destructors: Postcondition functions should be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
8861             (because there is no valid object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput>
8862             after the destructor body runs successfully, but exception guarantee
8863             functions do not have to be <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static</phrase></computeroutput>
8864             since the object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput> is
8865             still valid because the destructor body did not run successfully, see
8866             <link linkend="boost_contract.contract_programming_overview.destructor_calls">Destructor
8867             Calls</link>).
8868           </simpara>
8869         </listitem>
8870       </itemizedlist>
8871       <para>
8872         Note that the extra contract functions also allow to keep the contract code
8873         in the header file while all function bodies are implemented in a separate
8874         source file (including the constructor member initialization list, that could
8875         not be done with the techniques shown in <link linkend="boost_contract.extras.separate_body_implementation">Separate
8876         Body Implementation</link>). <footnote id="boost_contract.extras.no_lambda_functions__no_c__11_.f2">
8877         <para>
8878           In this example, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">bind</phrase></computeroutput> was
8879           used to generate nullary functors from the contract functions. As always
8880           with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">bind</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">cref</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ref</phrase></computeroutput>
8881           must be used to bind arguments by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">&amp;</phrase></computeroutput>
8882           respectively, plus it might be necessary to explicitly <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static_cast</phrase></computeroutput>
8883           the function pointer passed to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">bind</phrase></computeroutput>
8884           for overloaded functions.
8885         </para>
8886         </footnote> Also note that the contract functions can always be declared
8887         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> if programmers need
8888         to exactly control the public members of the class (this was not done in
8889         this example only for brevity).
8890       </para>
8891       <para>
8892         The authors think this library is most useful when used together with C++11
8893         lambda functions (because of the large amount of boiler-plate code required
8894         when C++11 lambdas are not used as also shown by the example above).
8895       </para>
8896     </section>
8897     <section id="boost_contract.extras.no_macros__and_no_variadic_macros_">
8898       <title><link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_">No
8899       Macros (and No Variadic Macros)</link></title>
8900       <para>
8901         It is possible to specify contracts without using most of the macros provided
8902         by this library and programming the related code manually instead (the only
8903         macros that cannot be programmed manually are <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>,
8904         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDES">BOOST_CONTRACT_OVERRIDES</link></computeroutput>,
8905         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>).
8906       </para>
8907       <note>
8908         <para>
8909           Some of this library macros are variadic macros, others are not (see below).
8910           Variadic macros were officially added to the language in C++11 but most
8911           compilers have been supporting them as an extension for a long time, plus
8912           all compilers that support C++11 lambda functions should also support C++11
8913           variadic macros (and this library might rarely be used without the convenience
8914           of C++11 lambda functions, see <link linkend="boost_contract.extras.no_lambda_functions__no_c__11_">No
8915           Lambda Functions</link>). <footnote id="boost_contract.extras.no_macros__and_no_variadic_macros_.f0">
8916           <para>
8917             Compilation times of this library were measured to be comparable between
8918             compilers that support variadic macros and compilers that do not.
8919           </para>
8920           </footnote> Therefore, the rest of this section can be considered mainly
8921           a curiosity because programmers should seldom, if ever, need to use this
8922           library without using its macros.
8923         </para>
8924       </note>
8925       <bridgehead renderas="sect4" id="boost_contract.extras.no_macros__and_no_variadic_macros_.h0">
8926         <phrase id="boost_contract.extras.no_macros__and_no_variadic_macros_.overrides"/><link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_.overrides">Overrides</link>
8927       </bridgehead>
8928       <para>
8929         As shown in <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
8930         Function Overrides</link> and <link linkend="boost_contract.advanced.named_overrides">Named
8931         Overrides</link>, this library provides the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
8932         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></computeroutput>
8933         macros to program contracts for overriding public functions (see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_MAX_ARGS">BOOST_CONTRACT_MAX_ARGS</link></computeroutput> for compilers
8934         that do not support variadic templates). <footnote id="boost_contract.extras.no_macros__and_no_variadic_macros_.f1">
8935         <para>
8936           <emphasis role="bold">Rationale:</emphasis> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_MAX_ARGS">BOOST_CONTRACT_MAX_ARGS</link></computeroutput>
8937           macro is named after <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_FUNCTION_MAX_ARGS</phrase></computeroutput>.
8938         </para>
8939         </footnote> These macro cannot be programmed manually but they are not variadic
8940         macros (so programmers should be able to use them on any C++ compiler with
8941         a sound support for SFINAE). <footnote id="boost_contract.extras.no_macros__and_no_variadic_macros_.f2">
8942         <para>
8943           <emphasis role="bold">Rationale:</emphasis> These macros expand to SFINAE-based
8944           introspection template code that are too complex to be programmed manually
8945           by users (that remains the case even if C++14 generic lambdas were to be
8946           used here). On a related note, in theory using C++14 generic lambdas, the
8947           <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
8948           macro could be re-implemented in a way that can be expanded at function
8949           scope, instead of class scope (but there is not really a need to do that).
8950         </para>
8951         </footnote> The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDES">BOOST_CONTRACT_OVERRIDES</link></computeroutput>
8952         macro is a variadic macro instead but programmes can manually repeat the
8953         non-variadic macro <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput>
8954         for each overriding public function name on compilers that do not support
8955         variadic macros.
8956       </para>
8957       <bridgehead renderas="sect4" id="boost_contract.extras.no_macros__and_no_variadic_macros_.h1">
8958         <phrase id="boost_contract.extras.no_macros__and_no_variadic_macros_.assertions__not_variadic_"/><link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_.assertions__not_variadic_">Assertions
8959         (Not Variadic)</link>
8960       </bridgehead>
8961       <para>
8962         As shown in <link linkend="boost_contract.tutorial.preconditions">Preconditions</link>,
8963         <link linkend="boost_contract.tutorial.postconditions">Postconditions</link>,
8964         <link linkend="boost_contract.tutorial.exception_guarantees">Exception Guarantees</link>,
8965         <link linkend="boost_contract.tutorial.class_invariants">Class Invariants</link>,
8966         etc. this library provides the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
8967         macro to assert contract conditions. This is not a variadic macro and programmers
8968         should be able to use it on all C++ compilers. In any case, the invocation
8969         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase></computeroutput><literal moreinfo="none"><emphasis>cond</emphasis></literal><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">)</phrase></computeroutput> simply expands to code equivalent to the
8970         following: <footnote id="boost_contract.extras.no_macros__and_no_variadic_macros_.f3">
8971         <para>
8972           <emphasis role="bold">Rationale:</emphasis> There is no need for the code
8973           expanded by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
8974           to also use C++11 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__func__</phrase></computeroutput>.
8975           That is because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__func__</phrase></computeroutput>
8976           will always expand to the name <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">operator</phrase><phrase role="special">()</phrase></computeroutput> of the functor used to program the contract
8977           assertions (e.g., the internal name the compiler assigns to lambda functions)
8978           and it will not expand to the name of the actual function enclosing the
8979           contract declaration.
8980         </para>
8981         </footnote>
8982       </para>
8983 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase><phrase role="special">(!(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">))</phrase> <phrase role="special">{</phrase>
8984     <phrase role="keyword">throw</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">assertion_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">__FILE__</phrase><phrase role="special">,</phrase> <phrase role="identifier">__LINE__</phrase><phrase role="special">,</phrase>
8985             <phrase role="identifier">BOOST_PP_STRINGIZE</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">));</phrase>
8986 <phrase role="special">}</phrase>
8987 </programlisting>
8988       <para>
8989         In fact, this library considers any exception thrown from within preconditions,
8990         postconditions, exception guarantees, and class invariants as a contract
8991         failure and reports it calling the related contract failure handler (<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput>,
8992         etc.). If there is a need for it, programmers can always program contract
8993         assertions that throw specific user-defined exceptions as follow (see <link linkend="boost_contract.advanced.throw_on_failures__and__noexcept__">Throw
8994         on Failures</link>):
8995       </para>
8996 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase><phrase role="special">(!</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">)</phrase> <phrase role="keyword">throw</phrase> <literal moreinfo="none"><emphasis>exception-object</emphasis></literal><phrase role="special">;</phrase>
8997 </programlisting>
8998       <para>
8999         However, using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>
9000         is convenient because it always allows this library to show an informative
9001         message in case of assertion failure containing the assertion code, file
9002         name, line number, etc.
9003       </para>
9004       <para>
9005         As shown in <link linkend="boost_contract.extras.assertion_levels">Assertion
9006         Levels</link>, this library pre-defines <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput>
9007         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link></computeroutput>
9008         assertion levels. These macros are not variadic macros and programmers should
9009         be able to use them on all C++ compilers. In any case, their implementations
9010         are equivalent to the following:
9011       </para>
9012 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDITS</phrase>
9013     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">)</phrase> <phrase role="special">\</phrase>
9014         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">)</phrase>
9015 <phrase role="preprocessor">#else</phrase>
9016     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">)</phrase> <phrase role="special">\</phrase>
9017         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">))</phrase>
9018 <phrase role="preprocessor">#endif</phrase>
9019
9020 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">)</phrase> <phrase role="special">\</phrase>
9021     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase><literal moreinfo="none"><emphasis>cond</emphasis></literal><phrase role="special">))</phrase>
9022 </programlisting>
9023       <bridgehead renderas="sect4" id="boost_contract.extras.no_macros__and_no_variadic_macros_.h2">
9024         <phrase id="boost_contract.extras.no_macros__and_no_variadic_macros_.base_types__variadic_"/><link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_.base_types__variadic_">Base
9025         Types (Variadic)</link>
9026       </bridgehead>
9027       <para>
9028         As shown in <link linkend="boost_contract.tutorial.base_classes__subcontracting_">Base
9029         Classes</link>, this library provides the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
9030         variadic macro to declare the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>
9031         member type that will expand to the list of all public bases for a derived
9032         class. Programmers can also declare <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput>
9033         without using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
9034         at the cost of writing a bit more code and increase maintenance efforts.
9035         For example (see <ulink url="../../example/features/base_types_no_macro.cpp"><literal moreinfo="none">base_types_no_macro.cpp</literal></ulink>):
9036       </para>
9037       <para>
9038 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">mpl</phrase><phrase role="special">/</phrase><phrase role="identifier">vector</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9039
9040 <phrase role="keyword">class</phrase> <phrase role="identifier">chars</phrase> <phrase role="special">:</phrase>
9041     <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">chars</phrase><phrase role="special">&gt;,</phrase>
9042     <phrase role="keyword">public</phrase> <phrase role="identifier">unique_chars</phrase><phrase role="special">,</phrase>
9043     <phrase role="keyword">public</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">pushable</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;,</phrase>
9044     <phrase role="keyword">virtual</phrase> <phrase role="keyword">protected</phrase> <phrase role="identifier">has_size</phrase><phrase role="special">,</phrase>
9045     <phrase role="keyword">private</phrase> <phrase role="identifier">has_empty</phrase>
9046 <phrase role="special">{</phrase>
9047 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
9048     <phrase role="comment">// Program `base_types` without macros (list only public bases).</phrase>
9049     <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">unique_chars</phrase><phrase role="special">,</phrase> <phrase role="identifier">pushable</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
9050
9051     <phrase role="comment">/* ... */</phrase>
9052 </programlisting>
9053       </para>
9054       <para>
9055         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">base_types</phrase></computeroutput> member type
9056         must be a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase></computeroutput>
9057         which must list <emphasis>all and only</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>
9058         base classes (because only public bases subcontract, see <link linkend="boost_contract.contract_programming_overview.function_calls">Function
9059         Calls</link>), and in the same order these public base classes appear in
9060         the derived class inheritance list. If the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
9061         macro is not used, it is the responsibility of the programmers to maintain
9062         the correct list of bases in the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase></computeroutput> each time the derived class inheritance
9063         list changes (this might significantly complicate maintenance).
9064       </para>
9065       <para>
9066         In general, it is recommended to use the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>
9067         macro whenever possible.
9068       </para>
9069       <bridgehead renderas="sect4" id="boost_contract.extras.no_macros__and_no_variadic_macros_.h3">
9070         <phrase id="boost_contract.extras.no_macros__and_no_variadic_macros_.old_values__variadic_"/><link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_.old_values__variadic_">Old
9071         Values (Variadic)</link>
9072       </bridgehead>
9073       <para>
9074         As shown in <link linkend="boost_contract.tutorial.old_values">Old Values</link>,
9075         this library provides the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
9076         variadic macro to assign old value copies. Programmers can also assign old
9077         values without using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
9078         at the cost of writing a bit more code manually. For example (see <ulink url="../../example/features/old_no_macro.cpp"><literal moreinfo="none">old_no_macro.cpp</literal></ulink>):
9079       </para>
9080       <para>
9081 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
9082 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
9083 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
9084     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9085         <phrase role="comment">// Program old value instead of using `OLD(size())` macro.</phrase>
9086         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">unsigned</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9087             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">make_old</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_old</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">?</phrase>
9088                     <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">null_old</phrase><phrase role="special">())</phrase>
9089         <phrase role="special">;</phrase>
9090
9091         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9092             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9093                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
9094             <phrase role="special">})</phrase>
9095         <phrase role="special">;</phrase>
9096
9097         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
9098     <phrase role="special">}</phrase>
9099
9100     <phrase role="comment">/* ... */</phrase>
9101 </programlisting>
9102       </para>
9103       <para>
9104         The ternary operator <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_old</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">)</phrase>
9105         <phrase role="special">?</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">null_old</phrase><phrase role="special">()</phrase></computeroutput> must be used here to avoid evaluating and
9106         copying the old value expression <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">size</phrase><phrase role="special">()</phrase></computeroutput> when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.copy_old_idm45394998944672">boost::contract::copy_old</link></computeroutput>
9107         returns <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">false</phrase></computeroutput> (because old values
9108         are not being copied when postcondition and exception guarantee checking
9109         is disabled at run-time, an overridden virtual function call is not checking
9110         postconditions or exception guarantees yet, etc.). The enclosing <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.make_old_idm45394998968720">boost::contract::make_old</link></computeroutput>
9111         copies the old value expression and creates an old value pointer. Otherwise,
9112         <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.null_old">boost::contract::null_old</link></computeroutput>
9113         indicates that a null old value pointer should be created.
9114       </para>
9115       <para>
9116         The <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.make_old_idm45394998968720">boost::contract::make_old</link></computeroutput>
9117         and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.copy_old_idm45394998944672">boost::contract::copy_old</link></computeroutput>
9118         functions are used exactly as shown above but without the extra <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">v</phrase></computeroutput> parameter when they are called from within
9119         non-virtual functions (see <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">Public
9120         Function Overrides</link>). The old value pointer returned by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.make_old_idm45394998968720">boost::contract::make_old</link></computeroutput>
9121         can be assigned to either <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput>
9122         or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput>
9123         (see <link linkend="boost_contract.extras.old_value_requirements__templates_">Old
9124         Value Requirements</link>).
9125       </para>
9126       <para>
9127         In general, it is recommended to use the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>
9128         macro whenever possible.
9129       </para>
9130       <bridgehead renderas="sect4" id="boost_contract.extras.no_macros__and_no_variadic_macros_.h4">
9131         <phrase id="boost_contract.extras.no_macros__and_no_variadic_macros_.macro_interface__variadic_"/><link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_.macro_interface__variadic_">Macro
9132         Interface (Variadic)</link>
9133       </bridgehead>
9134       <para>
9135         Almost all macros defined in <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link></computeroutput>
9136         are variadic macros. On compilers that do not support variadic macros, programmers
9137         can manually disable contract code compilation using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase>
9138         <phrase role="identifier">BOOST_CONTRACT_NO_</phrase><phrase role="special">...</phrase></computeroutput>
9139         statements as shown in <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">Disable
9140         Contract Compilation</link>.
9141       </para>
9142     </section>
9143   </section>
9144   <section id="boost_contract.examples">
9145     <title><link linkend="boost_contract.examples">Examples</link></title>
9146     <para>
9147       This section lists some examples taken from different sources discussing contract
9148       programming and implemented here using this library.
9149     </para>
9150     <note>
9151       <para>
9152         Some of these examples might be from old code, containing obsolete coding
9153         practices, not optimized for execution speed, not complete, and they might
9154         be more relevant in the context of programming languages different from C++.
9155         Nevertheless, programmers are encouraged to review these examples to see
9156         a few diverse uses of this library that might be relevant to their needs.
9157       </para>
9158     </note>
9159     <para>
9160       The examples in this sections are taken from the following sources:
9161     </para>
9162     <itemizedlist>
9163       <listitem>
9164         <simpara>
9165           <link linkend="N1962_anchor">[N1962]</link>: Examples from a detailed and
9166           complete proposal to add contract programming to C++11 (unfortunately,
9167           this proposal was never accepted into the standard).
9168         </simpara>
9169       </listitem>
9170       <listitem>
9171         <simpara>
9172           <link linkend="Meyer97_anchor">[Meyer97]</link>: Examples from the Eiffel
9173           programming language (reprogrammed here in C++ using this library).
9174         </simpara>
9175       </listitem>
9176       <listitem>
9177         <simpara>
9178           <link linkend="Mitchell02_anchor">[Mitchell02]</link>: Additional examples
9179           from the Eiffel programming language (reprogrammed here in C++ using this
9180           library).
9181         </simpara>
9182       </listitem>
9183       <listitem>
9184         <simpara>
9185           <link linkend="Cline90_anchor">[Cline90]</link>: Examples from a very early
9186           proposal called Annotated C++ (A++) to add contract programming to C++
9187           (A++ was never implemented or proposed for addition to the standard).
9188         </simpara>
9189       </listitem>
9190     </itemizedlist>
9191     <para>
9192       The following are some examples of particular interest:
9193     </para>
9194     <itemizedlist>
9195       <listitem>
9196         <simpara>
9197           <link linkend="N1962_vector_anchor">[N1962] Vector</link>: Complete set
9198           of contracts for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase></computeroutput>, plus a comparison with <link linkend="N1962_anchor">[N1962]</link> syntax.
9199         </simpara>
9200       </listitem>
9201       <listitem>
9202         <simpara>
9203           <link linkend="N1962_square_root_anchor">[N1962] Square Root</link>: Comparison
9204           with D syntax.
9205         </simpara>
9206       </listitem>
9207       <listitem>
9208         <simpara>
9209           <link linkend="Mitchell02_counter_anchor">[Mitchell02] Counter</link>:
9210           Subcontracting.
9211         </simpara>
9212       </listitem>
9213       <listitem>
9214         <simpara>
9215           <link linkend="Meyer97_stack4_anchor">[Meyer97] Stack4</link>: Comparison
9216           with Eiffel syntax.
9217         </simpara>
9218       </listitem>
9219       <listitem>
9220         <simpara>
9221           <link linkend="Cline90_vector_anchor">[Cline90] Vector</link>: Comparison
9222           with A++ syntax.
9223         </simpara>
9224       </listitem>
9225     </itemizedlist>
9226     <para>
9227       Most of the examples listed here use old values and class invariants which
9228       are instead not supported by <link linkend="P0380_anchor">[P0380]</link>. Therefore,
9229       there is not meaningful example here that can be directly implemented and compared
9230       using <link linkend="P0380_anchor">[P0380]</link> syntax.
9231     </para>
9232     <section id="boost_contract.examples.__n1962___vector__contracts_for_stl_vector_and_comparison_with___n1962___proposed_syntax">
9233       <title><anchor id="N1962_vector_anchor"/>[N1962] Vector: Contracts for STL
9234       vector and comparison with <link linkend="N1962_anchor">[N1962]</link> proposed
9235       syntax</title>
9236       <para>
9237         On compilers that support C++17 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">if</phrase>
9238         <phrase role="keyword">constexpr</phrase></computeroutput>, the following example using
9239         this library can be simplified removing <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.contract.condition_if">boost::contract::condition_if</link></computeroutput>
9240         and related functor templates such as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">all_of_equal_to</phrase></computeroutput>,
9241         etc., making it more similar to the pseudo-code on the right-hand side (see
9242         <link linkend="boost_contract.extras.assertion_requirements__templates_">Assertion
9243         Requirements</link>).
9244       </para>
9245       <informaltable frame="all">
9246         <tgroup cols="2">
9247           <thead>
9248             <row>
9249               <entry>
9250                 <para>
9251                   This library
9252                 </para>
9253               </entry>
9254               <entry>
9255                 <para>
9256                   [N1962] proposal (not accepted in C++) plus C++17 <literal moreinfo="none">if constexpr</literal>
9257                 </para>
9258               </entry>
9259             </row>
9260           </thead>
9261           <tbody>
9262             <row>
9263               <entry>
9264                 <para>
9265 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9266 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">bind</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9267 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">optional</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9268 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">/</phrase><phrase role="identifier">cxx11</phrase><phrase role="special">/</phrase><phrase role="identifier">all_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9269 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9270 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">next_prior</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9271 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase>
9272 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">functional</phrase><phrase role="special">&gt;</phrase>
9273 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">iterator</phrase><phrase role="special">&gt;</phrase>
9274 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">memory</phrase><phrase role="special">&gt;</phrase>
9275 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
9276
9277 <phrase role="comment">// Could be programmed at call site with C++14 generic lambdas.</phrase>
9278 <phrase role="keyword">struct</phrase> <phrase role="identifier">all_of_equal_to</phrase> <phrase role="special">{</phrase>
9279     <phrase role="keyword">typedef</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">result_type</phrase><phrase role="special">;</phrase>
9280
9281     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
9282     <phrase role="identifier">result_type</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9283         <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
9284     <phrase role="special">}</phrase>
9285
9286     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
9287     <phrase role="identifier">result_type</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">where</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9288         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">j</phrase> <phrase role="special">=</phrase> <phrase role="identifier">where</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="special">++</phrase><phrase role="identifier">j</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9289             <phrase role="keyword">if</phrase><phrase role="special">(*</phrase><phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="special">*</phrase><phrase role="identifier">j</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
9290         <phrase role="special">}</phrase>
9291         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
9292     <phrase role="special">}</phrase>
9293 <phrase role="special">};</phrase>
9294
9295 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter</phrase><phrase role="special">&gt;</phrase>
9296 <phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase> <phrase role="comment">// Cannot implement in C++ (for axiom only).</phrase>
9297
9298 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter</phrase><phrase role="special">&gt;</phrase>
9299 <phrase role="keyword">bool</phrase> <phrase role="identifier">contained</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter</phrase> <phrase role="identifier">first1</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter</phrase> <phrase role="identifier">last1</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter</phrase> <phrase role="identifier">first2</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter</phrase> <phrase role="identifier">last2</phrase><phrase role="special">);</phrase> <phrase role="comment">// For axiom.</phrase>
9300
9301 <phrase role="comment">// STL vector requires T copyable but not equality comparable.</phrase>
9302 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
9303 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
9304     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
9305
9306     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9307         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
9308         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">())</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()));</phrase>
9309         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">rbegin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">rend</phrase><phrase role="special">())</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()));</phrase>
9310         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
9311         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
9312     <phrase role="special">}</phrase>
9313
9314 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
9315     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">allocator_type</phrase> <phrase role="identifier">allocator_type</phrase><phrase role="special">;</phrase>
9316     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">pointer</phrase> <phrase role="identifier">pointer</phrase><phrase role="special">;</phrase>
9317     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_pointer</phrase> <phrase role="identifier">const_pointer</phrase><phrase role="special">;</phrase>
9318     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">reference</phrase><phrase role="special">;</phrase>
9319     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_reference</phrase> <phrase role="identifier">const_reference</phrase><phrase role="special">;</phrase>
9320     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase>
9321     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">iterator</phrase><phrase role="special">;</phrase>
9322     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">const_iterator</phrase><phrase role="special">;</phrase>
9323     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">size_type</phrase><phrase role="special">;</phrase>
9324     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">difference_type</phrase> <phrase role="identifier">difference_type</phrase><phrase role="special">;</phrase>
9325     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">reverse_iterator</phrase>
9326             <phrase role="identifier">reverse_iterator</phrase><phrase role="special">;</phrase>
9327     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_reverse_iterator</phrase>
9328             <phrase role="identifier">const_reverse_iterator</phrase><phrase role="special">;</phrase>
9329
9330     <phrase role="identifier">vector</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9331         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9332             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9333                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9334             <phrase role="special">})</phrase>
9335         <phrase role="special">;</phrase>
9336     <phrase role="special">}</phrase>
9337
9338     <phrase role="keyword">explicit</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">alloc</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9339         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9340             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9341                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9342                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">);</phrase>
9343             <phrase role="special">})</phrase>
9344         <phrase role="special">;</phrase>
9345     <phrase role="special">}</phrase>
9346
9347     <phrase role="keyword">explicit</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9348         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9349             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9350                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
9351                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9352                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9353                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">all_of_equal_to</phrase><phrase role="special">(),</phrase> <phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">T</phrase><phrase role="special">())</phrase>
9354                     <phrase role="special">)</phrase>
9355                 <phrase role="special">);</phrase>
9356             <phrase role="special">})</phrase>
9357         <phrase role="special">;</phrase>
9358     <phrase role="special">}</phrase>
9359
9360     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9361         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9362             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9363                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
9364                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9365                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9366                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">all_of_equal_to</phrase><phrase role="special">(),</phrase> <phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase>
9367                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">))</phrase>
9368                     <phrase role="special">)</phrase>
9369                 <phrase role="special">);</phrase>
9370             <phrase role="special">})</phrase>
9371         <phrase role="special">;</phrase>
9372     <phrase role="special">}</phrase>
9373
9374     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
9375             <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9376         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9377             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9378                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
9379                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9380                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9381                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">all_of_equal_to</phrase><phrase role="special">(),</phrase> <phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase>
9382                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">))</phrase>
9383                     <phrase role="special">)</phrase>
9384                 <phrase role="special">);</phrase>
9385                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">);</phrase>
9386             <phrase role="special">})</phrase>
9387         <phrase role="special">;</phrase>
9388     <phrase role="special">}</phrase>
9389
9390     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
9391     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9392         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9393             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9394                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase>
9395                         <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()));</phrase>
9396             <phrase role="special">})</phrase>
9397         <phrase role="special">;</phrase>
9398     <phrase role="special">}</phrase>
9399
9400     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
9401     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
9402             <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9403         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9404             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9405                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase>
9406                         <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()));</phrase>
9407                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">);</phrase>
9408             <phrase role="special">})</phrase>
9409         <phrase role="special">;</phrase>
9410     <phrase role="special">}</phrase>
9411
9412     <phrase role="comment">/* implicit */</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9413         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9414             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9415                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9416                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9417                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(),</phrase>
9418                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">))</phrase>
9419                     <phrase role="special">)</phrase>
9420                 <phrase role="special">);</phrase>
9421             <phrase role="special">})</phrase>
9422         <phrase role="special">;</phrase>
9423     <phrase role="special">}</phrase>
9424
9425     <phrase role="identifier">vector</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase><phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9426         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9427         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9428             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9429                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9430                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9431                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(),</phrase>
9432                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">))</phrase>
9433                     <phrase role="special">)</phrase>
9434                 <phrase role="special">);</phrase>
9435                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9436                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9437                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(),</phrase>
9438                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase><phrase role="special">),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">))</phrase>
9439                     <phrase role="special">)</phrase>
9440                 <phrase role="special">);</phrase>
9441             <phrase role="special">})</phrase>
9442         <phrase role="special">;</phrase>
9443
9444         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase> <phrase role="special">!=</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="identifier">vect_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
9445         <phrase role="keyword">return</phrase> <phrase role="special">*(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9446     <phrase role="special">}</phrase>
9447
9448     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">vector</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9449         <phrase role="comment">// Check invariants.</phrase>
9450         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9451     <phrase role="special">}</phrase>
9452
9453     <phrase role="keyword">void</phrase> <phrase role="identifier">reserve</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9454         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9455             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9456                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
9457             <phrase role="special">})</phrase>
9458             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9459                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
9460             <phrase role="special">})</phrase>
9461         <phrase role="special">;</phrase>
9462
9463         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">);</phrase>
9464     <phrase role="special">}</phrase>
9465
9466     <phrase role="identifier">size_type</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9467         <phrase role="identifier">size_type</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9468         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9469             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9470                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9471             <phrase role="special">})</phrase>
9472         <phrase role="special">;</phrase>
9473
9474         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">();</phrase>
9475     <phrase role="special">}</phrase>
9476
9477     <phrase role="identifier">iterator</phrase> <phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9478         <phrase role="identifier">iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9479         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9480             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9481                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">());</phrase>
9482             <phrase role="special">})</phrase>
9483         <phrase role="special">;</phrase>
9484
9485         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
9486     <phrase role="special">}</phrase>
9487
9488     <phrase role="identifier">const_iterator</phrase> <phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9489         <phrase role="identifier">const_iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9490         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9491             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9492                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">());</phrase>
9493             <phrase role="special">})</phrase>
9494         <phrase role="special">;</phrase>
9495
9496         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
9497     <phrase role="special">}</phrase>
9498
9499     <phrase role="identifier">iterator</phrase> <phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9500         <phrase role="comment">// Check invariants.</phrase>
9501         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9502         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase>
9503     <phrase role="special">}</phrase>
9504
9505     <phrase role="identifier">const_iterator</phrase> <phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9506         <phrase role="comment">// Check invariants.</phrase>
9507         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9508         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase>
9509     <phrase role="special">}</phrase>
9510
9511     <phrase role="identifier">reverse_iterator</phrase> <phrase role="identifier">rbegin</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9512         <phrase role="identifier">iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9513         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9514             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9515                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">rend</phrase><phrase role="special">());</phrase>
9516             <phrase role="special">})</phrase>
9517         <phrase role="special">;</phrase>
9518
9519         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rbegin</phrase><phrase role="special">();</phrase>
9520     <phrase role="special">}</phrase>
9521
9522     <phrase role="identifier">const_reverse_iterator</phrase> <phrase role="identifier">rbegin</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9523         <phrase role="identifier">const_reverse_iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9524         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9525             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9526                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">rend</phrase><phrase role="special">());</phrase>
9527             <phrase role="special">})</phrase>
9528         <phrase role="special">;</phrase>
9529
9530         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rbegin</phrase><phrase role="special">();</phrase>
9531     <phrase role="special">}</phrase>
9532
9533     <phrase role="identifier">reverse_iterator</phrase> <phrase role="identifier">rend</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9534         <phrase role="comment">// Check invariants.</phrase>
9535         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9536         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rend</phrase><phrase role="special">();</phrase>
9537     <phrase role="special">}</phrase>
9538
9539     <phrase role="identifier">const_reverse_iterator</phrase> <phrase role="identifier">rend</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9540         <phrase role="comment">// Check invariants.</phrase>
9541         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9542         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rend</phrase><phrase role="special">();</phrase>
9543     <phrase role="special">}</phrase>
9544
9545     <phrase role="keyword">void</phrase> <phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">T</phrase><phrase role="special">())</phrase> <phrase role="special">{</phrase>
9546         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9547                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9548         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9549             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9550                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
9551                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9552                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9553                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9554                             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">all_of_equal_to</phrase><phrase role="special">(),</phrase> <phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase><phrase role="special">,</phrase>
9555                                     <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">))</phrase>
9556                         <phrase role="special">)</phrase>
9557                     <phrase role="special">);</phrase>
9558                 <phrase role="special">}</phrase>
9559             <phrase role="special">})</phrase>
9560         <phrase role="special">;</phrase>
9561
9562         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
9563     <phrase role="special">}</phrase>
9564
9565     <phrase role="identifier">size_type</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9566         <phrase role="identifier">size_type</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9567         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9568             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9569                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
9570             <phrase role="special">})</phrase>
9571         <phrase role="special">;</phrase>
9572
9573         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
9574     <phrase role="special">}</phrase>
9575
9576     <phrase role="identifier">size_type</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9577         <phrase role="identifier">size_type</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9578         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9579             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9580                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
9581             <phrase role="special">})</phrase>
9582         <phrase role="special">;</phrase>
9583
9584         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
9585     <phrase role="special">}</phrase>
9586
9587     <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9588         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9589         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9590             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9591                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
9592             <phrase role="special">})</phrase>
9593         <phrase role="special">;</phrase>
9594
9595         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
9596     <phrase role="special">}</phrase>
9597
9598     <phrase role="identifier">Allocator</phrase> <phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9599         <phrase role="comment">// Check invariants.</phrase>
9600         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9601         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">();</phrase>
9602     <phrase role="special">}</phrase>
9603
9604     <phrase role="identifier">reference</phrase> <phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9605         <phrase role="comment">// Check invariants, no pre (throw out_of_range for invalid index).</phrase>
9606         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9607         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase><phrase role="special">);</phrase>
9608     <phrase role="special">}</phrase>
9609
9610     <phrase role="identifier">const_reference</phrase> <phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9611         <phrase role="comment">// Check invariants, no pre (throw out_of_range for invalid index).</phrase>
9612         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9613         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase><phrase role="special">);</phrase>
9614     <phrase role="special">}</phrase>
9615
9616     <phrase role="identifier">reference</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9617         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9618             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9619                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9620             <phrase role="special">})</phrase>
9621         <phrase role="special">;</phrase>
9622
9623         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase>
9624     <phrase role="special">}</phrase>
9625
9626     <phrase role="identifier">const_reference</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9627         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9628             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9629                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9630             <phrase role="special">})</phrase>
9631         <phrase role="special">;</phrase>
9632
9633         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase>
9634     <phrase role="special">}</phrase>
9635
9636     <phrase role="identifier">reference</phrase> <phrase role="identifier">front</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9637         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9638             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9639                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9640             <phrase role="special">})</phrase>
9641         <phrase role="special">;</phrase>
9642
9643         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">front</phrase><phrase role="special">();</phrase>
9644     <phrase role="special">}</phrase>
9645
9646     <phrase role="identifier">const_reference</phrase> <phrase role="identifier">front</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9647         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9648             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9649                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9650             <phrase role="special">})</phrase>
9651         <phrase role="special">;</phrase>
9652
9653         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">front</phrase><phrase role="special">();</phrase>
9654     <phrase role="special">}</phrase>
9655
9656     <phrase role="identifier">reference</phrase> <phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9657         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9658             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9659                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9660             <phrase role="special">})</phrase>
9661         <phrase role="special">;</phrase>
9662
9663         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">back</phrase><phrase role="special">();</phrase>
9664     <phrase role="special">}</phrase>
9665
9666     <phrase role="identifier">const_reference</phrase> <phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
9667         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9668             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9669                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9670             <phrase role="special">})</phrase>
9671         <phrase role="special">;</phrase>
9672
9673         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">back</phrase><phrase role="special">();</phrase>
9674     <phrase role="special">}</phrase>
9675
9676     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9677         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9678                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9679         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_capacity</phrase> <phrase role="special">=</phrase>
9680                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
9681         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9682             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9683                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
9684             <phrase role="special">})</phrase>
9685             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9686                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
9687                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">);</phrase>
9688                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9689                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9690                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;(),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">back</phrase><phrase role="special">()),</phrase>
9691                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">))</phrase>
9692                     <phrase role="special">)</phrase>
9693                 <phrase role="special">);</phrase>
9694             <phrase role="special">})</phrase>
9695         <phrase role="special">;</phrase>
9696
9697         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
9698     <phrase role="special">}</phrase>
9699
9700     <phrase role="keyword">void</phrase> <phrase role="identifier">pop_back</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9701         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9702                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9703         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9704             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9705                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9706             <phrase role="special">})</phrase>
9707             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9708                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
9709             <phrase role="special">})</phrase>
9710         <phrase role="special">;</phrase>
9711
9712         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">pop_back</phrase><phrase role="special">();</phrase>
9713     <phrase role="special">}</phrase>
9714
9715     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
9716     <phrase role="keyword">void</phrase> <phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9717         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9718             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9719                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(</phrase>
9720                         <phrase role="special">!</phrase><phrase role="identifier">contained</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">));</phrase>
9721             <phrase role="special">})</phrase>
9722             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9723                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase>
9724                         <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()));</phrase>
9725             <phrase role="special">})</phrase>
9726         <phrase role="special">;</phrase>
9727
9728         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
9729     <phrase role="special">}</phrase>
9730
9731     <phrase role="keyword">void</phrase> <phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9732         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9733             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9734                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
9735             <phrase role="special">})</phrase>
9736             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9737                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9738                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9739                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">all_of_equal_to</phrase><phrase role="special">(),</phrase> <phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase>
9740                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">))</phrase>
9741                     <phrase role="special">)</phrase>
9742                 <phrase role="special">);</phrase>
9743             <phrase role="special">})</phrase>
9744         <phrase role="special">;</phrase>
9745
9746         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
9747     <phrase role="special">}</phrase>
9748
9749     <phrase role="identifier">iterator</phrase> <phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9750         <phrase role="identifier">iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9751         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9752                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9753         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_capacity</phrase> <phrase role="special">=</phrase>
9754                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
9755         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9756             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9757                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
9758             <phrase role="special">})</phrase>
9759             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9760                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
9761                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">);</phrase>
9762                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9763                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9764                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;(),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase><phrase role="special">),</phrase>
9765                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">))</phrase>
9766                     <phrase role="special">)</phrase>
9767                 <phrase role="special">);</phrase>
9768                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9769                     <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9770                 <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase>
9771                     <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9772                 <phrase role="special">}</phrase>
9773             <phrase role="special">})</phrase>
9774         <phrase role="special">;</phrase>
9775
9776         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
9777     <phrase role="special">}</phrase>
9778
9779     <phrase role="keyword">void</phrase> <phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9780         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9781                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9782         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_capacity</phrase> <phrase role="special">=</phrase>
9783                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
9784         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">iterator</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_where</phrase> <phrase role="special">=</phrase>
9785                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">);</phrase>
9786         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9787             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9788                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
9789             <phrase role="special">})</phrase>
9790             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9791                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
9792                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">);</phrase>
9793                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9794                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9795                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9796                             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">all_of_equal_to</phrase><phrase role="special">(),</phrase>
9797                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">prior</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_where</phrase><phrase role="special">),</phrase>
9798                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">prior</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_where</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase>
9799                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase>
9800                             <phrase role="special">)</phrase>
9801                         <phrase role="special">)</phrase>
9802                     <phrase role="special">);</phrase>
9803                     <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9804                 <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9805             <phrase role="special">})</phrase>
9806         <phrase role="special">;</phrase>
9807
9808         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
9809     <phrase role="special">}</phrase>
9810
9811     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
9812     <phrase role="keyword">void</phrase> <phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9813         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9814                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9815         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_capacity</phrase> <phrase role="special">=</phrase>
9816                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
9817         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">iterator</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_where</phrase> <phrase role="special">=</phrase>
9818                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">);</phrase>
9819         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9820             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9821                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">&lt;</phrase>
9822                         <phrase role="identifier">max_size</phrase><phrase role="special">());</phrase>
9823                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(</phrase>
9824                         <phrase role="special">!</phrase><phrase role="identifier">contained</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9825             <phrase role="special">})</phrase>
9826             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9827                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase>
9828                         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">));</phrase>
9829                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">);</phrase>
9830                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_capacity</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9831                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase>
9832                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9833                             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">all_of_equal_to</phrase><phrase role="special">(),</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase>
9834                                     <phrase role="special">*</phrase><phrase role="identifier">old_where</phrase><phrase role="special">)</phrase>
9835                         <phrase role="special">)</phrase>
9836                     <phrase role="special">);</phrase>
9837                     <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9838                 <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9839             <phrase role="special">})</phrase>
9840         <phrase role="special">;</phrase>
9841
9842         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
9843     <phrase role="special">}</phrase>
9844
9845     <phrase role="identifier">iterator</phrase> <phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9846         <phrase role="identifier">iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9847         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9848                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9849         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9850             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9851                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9852                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">end</phrase><phrase role="special">());</phrase>
9853             <phrase role="special">})</phrase>
9854             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9855                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
9856                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">());</phrase>
9857                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">end</phrase><phrase role="special">()));</phrase>
9858             <phrase role="special">})</phrase>
9859         <phrase role="special">;</phrase>
9860
9861         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">);</phrase>
9862     <phrase role="special">}</phrase>
9863
9864     <phrase role="identifier">iterator</phrase> <phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">iterator</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9865         <phrase role="identifier">iterator</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
9866         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">size_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_size</phrase> <phrase role="special">=</phrase>
9867                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
9868         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9869             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9870                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">));</phrase>
9871             <phrase role="special">})</phrase>
9872             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9873                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_size</phrase> <phrase role="special">-</phrase>
9874                         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">));</phrase>
9875                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">());</phrase>
9876                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(!</phrase><phrase role="identifier">valid</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">));</phrase>
9877             <phrase role="special">})</phrase>
9878         <phrase role="special">;</phrase>
9879
9880         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
9881     <phrase role="special">}</phrase>
9882
9883     <phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9884         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9885             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9886                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
9887             <phrase role="special">})</phrase>
9888         <phrase role="special">;</phrase>
9889
9890         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">clear</phrase><phrase role="special">();</phrase>
9891     <phrase role="special">}</phrase>
9892
9893     <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">vector</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9894         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_me</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_other</phrase><phrase role="special">;</phrase>
9895         <phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDITS</phrase>
9896             <phrase role="identifier">old_me</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
9897             <phrase role="identifier">old_other</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">);</phrase>
9898         <phrase role="preprocessor">#endif</phrase>
9899         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
9900             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9901                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">());</phrase>
9902             <phrase role="special">})</phrase>
9903             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
9904                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase>
9905                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase>
9906                             <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9907                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(),</phrase>
9908                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_other</phrase><phrase role="special">))</phrase>
9909                     <phrase role="special">)</phrase>
9910                 <phrase role="special">);</phrase>
9911                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase>
9912                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase>
9913                             <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase>
9914                         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;(),</phrase>
9915                                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">),</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_me</phrase><phrase role="special">))</phrase>
9916                     <phrase role="special">)</phrase>
9917                 <phrase role="special">);</phrase>
9918             <phrase role="special">})</phrase>
9919         <phrase role="special">;</phrase>
9920
9921         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">);</phrase>
9922     <phrase role="special">}</phrase>
9923
9924     <phrase role="keyword">friend</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase><phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
9925         <phrase role="comment">// Check class invariants for left and right objects.</phrase>
9926         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">left_inv</phrase> <phrase role="special">=</phrase>
9927                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">left</phrase><phrase role="special">);</phrase>
9928         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">right_inv</phrase> <phrase role="special">=</phrase>
9929                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">right</phrase><phrase role="special">);</phrase>
9930         <phrase role="keyword">return</phrase> <phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase> <phrase role="special">==</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
9931     <phrase role="special">}</phrase>
9932
9933 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
9934     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
9935 <phrase role="special">};</phrase>
9936
9937 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
9938     <phrase role="comment">// char type has operator==.</phrase>
9939
9940     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">v</phrase><phrase role="special">(</phrase><phrase role="number">3</phrase><phrase role="special">);</phrase>
9941     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase>
9942     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="char">'\0'</phrase><phrase role="special">));</phrase>
9943
9944     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">cv</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">;</phrase>
9945     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">cv</phrase> <phrase role="special">==</phrase> <phrase role="identifier">v</phrase><phrase role="special">);</phrase>
9946
9947     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">w</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">);</phrase>
9948     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">w</phrase> <phrase role="special">==</phrase> <phrase role="identifier">v</phrase><phrase role="special">);</phrase>
9949
9950     <phrase role="keyword">typename</phrase> <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
9951     <phrase role="identifier">assert</phrase><phrase role="special">(*</phrase><phrase role="identifier">i</phrase> <phrase role="special">==</phrase> <phrase role="char">'\0'</phrase><phrase role="special">);</phrase>
9952
9953     <phrase role="keyword">typename</phrase> <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">char</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">ci</phrase> <phrase role="special">=</phrase> <phrase role="identifier">cv</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
9954     <phrase role="identifier">assert</phrase><phrase role="special">(*</phrase><phrase role="identifier">ci</phrase> <phrase role="special">==</phrase> <phrase role="char">'\0'</phrase><phrase role="special">);</phrase>
9955
9956     <phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="number">2</phrase><phrase role="special">,</phrase> <phrase role="char">'a'</phrase><phrase role="special">);</phrase>
9957     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">0</phrase><phrase role="special">]</phrase> <phrase role="special">==</phrase> <phrase role="char">'a'</phrase><phrase role="special">);</phrase>
9958     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]</phrase> <phrase role="special">==</phrase> <phrase role="char">'a'</phrase><phrase role="special">);</phrase>
9959
9960     <phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="char">'b'</phrase><phrase role="special">);</phrase>
9961     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="char">'b'</phrase><phrase role="special">);</phrase>
9962
9963     <phrase role="keyword">struct</phrase> <phrase role="identifier">x</phrase> <phrase role="special">{};</phrase> <phrase role="comment">// x type doest not have operator==.</phrase>
9964
9965     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">x</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">y</phrase><phrase role="special">(</phrase><phrase role="number">3</phrase><phrase role="special">);</phrase>
9966     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase>
9967
9968     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">x</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">cy</phrase> <phrase role="special">=</phrase> <phrase role="identifier">y</phrase><phrase role="special">;</phrase>
9969     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">x</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">z</phrase><phrase role="special">(</phrase><phrase role="identifier">y</phrase><phrase role="special">);</phrase>
9970
9971     <phrase role="keyword">typename</phrase> <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">x</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">j</phrase> <phrase role="special">=</phrase> <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
9972     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">j</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">());</phrase>
9973     <phrase role="keyword">typename</phrase> <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">x</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">cj</phrase> <phrase role="special">=</phrase> <phrase role="identifier">cy</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
9974     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">cj</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">cy</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">());</phrase>
9975
9976     <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">j</phrase><phrase role="special">,</phrase> <phrase role="number">2</phrase><phrase role="special">,</phrase> <phrase role="identifier">x</phrase><phrase role="special">());</phrase>
9977     <phrase role="identifier">y</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">());</phrase>
9978
9979     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
9980 <phrase role="special">}</phrase>
9981 </programlisting>
9982                 </para>
9983               </entry>
9984               <entry>
9985                 <para>
9986 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Extra spaces, newlines, etc. for visual alignment with this library code.</phrase>
9987
9988 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">/</phrase><phrase role="identifier">cxx11</phrase><phrase role="special">/</phrase><phrase role="identifier">all_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9989 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9990 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">next_prior</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
9991 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase>
9992 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">iterator</phrase><phrase role="special">&gt;</phrase>
9993 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">memory</phrase><phrase role="special">&gt;</phrase>
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
10024 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
10025
10026
10027     <phrase role="identifier">invariant</phrase> <phrase role="special">{</phrase>
10028         <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
10029         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">())</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
10030         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">rbegin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">rend</phrase><phrase role="special">())</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
10031         <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">();</phrase>
10032         <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10033     <phrase role="special">}</phrase>
10034
10035 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
10036     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">allocator_type</phrase> <phrase role="identifier">allocator_type</phrase><phrase role="special">;</phrase>
10037     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">pointer</phrase> <phrase role="identifier">pointer</phrase><phrase role="special">;</phrase>
10038     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_pointer</phrase> <phrase role="identifier">const_pointer</phrase><phrase role="special">;</phrase>
10039     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">reference</phrase><phrase role="special">;</phrase>
10040     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_reference</phrase> <phrase role="identifier">const_reference</phrase><phrase role="special">;</phrase>
10041     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase>
10042     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">iterator</phrase><phrase role="special">;</phrase>
10043     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">const_iterator</phrase><phrase role="special">;</phrase>
10044     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">size_type</phrase><phrase role="special">;</phrase>
10045     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">difference_type</phrase> <phrase role="identifier">difference_type</phrase><phrase role="special">;</phrase>
10046     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">reverse_iterator</phrase>
10047             <phrase role="identifier">reverse_iterator</phrase><phrase role="special">;</phrase>
10048     <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">const_reverse_iterator</phrase>
10049             <phrase role="identifier">const_reverse_iterator</phrase><phrase role="special">;</phrase>
10050
10051     <phrase role="identifier">vector</phrase><phrase role="special">()</phrase>
10052         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10053             <phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10054         <phrase role="special">}</phrase>
10055         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">()</phrase>
10056     <phrase role="special">{}</phrase>
10057
10058
10059     <phrase role="keyword">explicit</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase>
10060         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10061             <phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10062             <phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">;</phrase>
10063         <phrase role="special">}</phrase>
10064         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">alloc</phrase><phrase role="special">)</phrase>
10065     <phrase role="special">{}</phrase>
10066
10067
10068     <phrase role="keyword">explicit</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase>
10069         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10070             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
10071             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10072                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">T</phrase><phrase role="special">());</phrase>
10073             <phrase role="special">}</phrase>
10074         <phrase role="special">}</phrase>
10075         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">)</phrase>
10076     <phrase role="special">{}</phrase>
10077
10078
10079
10080
10081     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
10082         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10083             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
10084             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10085                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10086             <phrase role="special">}</phrase>
10087         <phrase role="special">}</phrase>
10088         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
10089     <phrase role="special">{}</phrase>
10090
10091
10092
10093
10094
10095     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase>
10096         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10097             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
10098             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10099                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10100             <phrase role="special">}</phrase>
10101             <phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">;</phrase>
10102         <phrase role="special">}</phrase>
10103         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase>
10104     <phrase role="special">{}</phrase>
10105
10106
10107
10108
10109
10110
10111     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
10112     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
10113         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10114             <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
10115         <phrase role="special">}</phrase>
10116         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
10117     <phrase role="special">{}</phrase>
10118
10119
10120
10121     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
10122     <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase>
10123         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10124             <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
10125             <phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">;</phrase>
10126         <phrase role="special">}</phrase>
10127         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">)</phrase>
10128     <phrase role="special">{}</phrase>
10129
10130
10131
10132
10133     <phrase role="comment">/* implicit */</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase>
10134         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10135             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10136                 <phrase role="special">*</phrase><phrase role="keyword">this</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">;</phrase>
10137             <phrase role="special">}</phrase>
10138         <phrase role="special">}</phrase>
10139         <phrase role="special">:</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase><phrase role="special">)</phrase>
10140     <phrase role="special">{}</phrase>
10141
10142
10143
10144
10145
10146     <phrase role="identifier">vector</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase><phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase>
10147         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10148             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10149                 <phrase role="special">*</phrase><phrase role="keyword">this</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">;</phrase>
10150                 <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="keyword">this</phrase><phrase role="special">;</phrase>
10151             <phrase role="special">}</phrase>
10152         <phrase role="special">}</phrase>
10153     <phrase role="special">{</phrase>
10154         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase> <phrase role="special">!=</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="identifier">vect_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
10155         <phrase role="keyword">return</phrase> <phrase role="special">*</phrase><phrase role="keyword">this</phrase><phrase role="special">;</phrase>
10156     <phrase role="special">}</phrase>
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">vector</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase>
10170
10171
10172
10173
10174     <phrase role="keyword">void</phrase> <phrase role="identifier">reserve</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase>
10175         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10176             <phrase role="identifier">count</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10177         <phrase role="special">}</phrase>
10178         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10179             <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
10180         <phrase role="special">}</phrase>
10181     <phrase role="special">{</phrase>
10182         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">);</phrase>
10183     <phrase role="special">}</phrase>
10184
10185
10186
10187     <phrase role="identifier">size_type</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10188         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10189             <phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">size</phrase><phrase role="special">();</phrase>
10190         <phrase role="special">}</phrase>
10191     <phrase role="special">{</phrase>
10192         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">();</phrase>
10193     <phrase role="special">}</phrase>
10194
10195
10196
10197
10198     <phrase role="identifier">iterator</phrase> <phrase role="identifier">begin</phrase><phrase role="special">()</phrase>
10199         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10200             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">();</phrase>
10201         <phrase role="special">}</phrase>
10202     <phrase role="special">{</phrase>
10203         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
10204     <phrase role="special">}</phrase>
10205
10206
10207
10208
10209     <phrase role="identifier">const_iterator</phrase> <phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10210         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10211             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">();</phrase>
10212         <phrase role="special">}</phrase>
10213     <phrase role="special">{</phrase>
10214         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
10215     <phrase role="special">}</phrase>
10216
10217
10218
10219
10220     <phrase role="identifier">iterator</phrase> <phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
10221         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase>
10222     <phrase role="special">}</phrase>
10223
10224
10225
10226     <phrase role="identifier">const_iterator</phrase> <phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
10227         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase>
10228     <phrase role="special">}</phrase>
10229
10230
10231
10232     <phrase role="identifier">reverse_iterator</phrase> <phrase role="identifier">rbegin</phrase><phrase role="special">()</phrase>
10233         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10234             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">rend</phrase><phrase role="special">();</phrase>
10235         <phrase role="special">}</phrase>
10236     <phrase role="special">{</phrase>
10237         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rbegin</phrase><phrase role="special">();</phrase>
10238     <phrase role="special">}</phrase>
10239
10240
10241
10242
10243     <phrase role="identifier">const_reverse_iterator</phrase> <phrase role="identifier">rbegin</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10244         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10245             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">rend</phrase><phrase role="special">();</phrase>
10246         <phrase role="special">}</phrase>
10247     <phrase role="special">{</phrase>
10248         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rbegin</phrase><phrase role="special">();</phrase>
10249     <phrase role="special">}</phrase>
10250
10251
10252
10253
10254     <phrase role="identifier">reverse_iterator</phrase> <phrase role="identifier">rend</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
10255         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rend</phrase><phrase role="special">();</phrase>
10256     <phrase role="special">}</phrase>
10257
10258
10259
10260     <phrase role="identifier">const_reverse_iterator</phrase> <phrase role="identifier">rend</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
10261         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">rend</phrase><phrase role="special">();</phrase>
10262     <phrase role="special">}</phrase>
10263
10264
10265
10266     <phrase role="keyword">void</phrase> <phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">T</phrase><phrase role="special">())</phrase>
10267         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10268             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
10269             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10270                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()))</phrase> <phrase role="special">{</phrase>
10271                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()),</phrase>
10272                             <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10273                 <phrase role="special">}</phrase>
10274             <phrase role="special">}</phrase>
10275         <phrase role="special">}</phrase>
10276     <phrase role="special">{</phrase>
10277         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10278     <phrase role="special">}</phrase>
10279
10280
10281
10282
10283
10284
10285
10286     <phrase role="identifier">size_type</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10287         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10288             <phrase role="identifier">result</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">();</phrase>
10289         <phrase role="special">}</phrase>
10290     <phrase role="special">{</phrase>
10291         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
10292     <phrase role="special">}</phrase>
10293
10294
10295
10296
10297     <phrase role="identifier">size_type</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10298         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10299             <phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">();</phrase>
10300         <phrase role="special">}</phrase>
10301     <phrase role="special">{</phrase>
10302         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10303     <phrase role="special">}</phrase>
10304
10305
10306
10307
10308     <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10309         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10310             <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
10311         <phrase role="special">}</phrase>
10312     <phrase role="special">{</phrase>
10313         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10314     <phrase role="special">}</phrase>
10315
10316
10317
10318
10319     <phrase role="identifier">Alloctor</phrase> <phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
10320         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">();</phrase>
10321     <phrase role="special">}</phrase>
10322
10323
10324
10325     <phrase role="identifier">reference</phrase> <phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10326         <phrase role="comment">// No precondition (throw out_of_range for invalid index).</phrase>
10327         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase><phrase role="special">);</phrase>
10328     <phrase role="special">}</phrase>
10329
10330
10331     <phrase role="identifier">const_reference</phrase> <phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
10332         <phrase role="comment">// No precondition (throw out_of_range for invalid index).</phrase>
10333         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase><phrase role="special">);</phrase>
10334     <phrase role="special">}</phrase>
10335
10336
10337     <phrase role="identifier">reference</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase>
10338         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10339             <phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">();</phrase>
10340         <phrase role="special">}</phrase>
10341     <phrase role="special">{</phrase>
10342         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase>
10343     <phrase role="special">}</phrase>
10344
10345
10346
10347     <phrase role="identifier">const_reference</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase>
10348         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10349             <phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">();</phrase>
10350         <phrase role="special">}</phrase>
10351     <phrase role="special">{</phrase>
10352         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase>
10353     <phrase role="special">}</phrase>
10354
10355
10356
10357     <phrase role="identifier">reference</phrase> <phrase role="identifier">front</phrase><phrase role="special">()</phrase>
10358         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10359             <phrase role="special">!</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10360         <phrase role="special">}</phrase>
10361     <phrase role="special">{</phrase>
10362         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">front</phrase><phrase role="special">();</phrase>
10363     <phrase role="special">}</phrase>
10364
10365
10366
10367     <phrase role="identifier">const_reference</phrase> <phrase role="identifier">front</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10368         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10369             <phrase role="special">!</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10370         <phrase role="special">}</phrase>
10371     <phrase role="special">{</phrase>
10372         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">front</phrase><phrase role="special">();</phrase>
10373     <phrase role="special">}</phrase>
10374
10375
10376
10377     <phrase role="identifier">reference</phrase> <phrase role="identifier">back</phrase><phrase role="special">()</phrase>
10378         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10379             <phrase role="special">!</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10380         <phrase role="special">}</phrase>
10381     <phrase role="special">{</phrase>
10382         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">back</phrase><phrase role="special">();</phrase>
10383     <phrase role="special">}</phrase>
10384
10385
10386
10387     <phrase role="identifier">const_reference</phrase> <phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
10388         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10389             <phrase role="special">!</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10390         <phrase role="special">}</phrase>
10391     <phrase role="special">{</phrase>
10392         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">back</phrase><phrase role="special">();</phrase>
10393     <phrase role="special">}</phrase>
10394
10395
10396
10397     <phrase role="keyword">void</phrase> <phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
10398         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10399             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10400         <phrase role="special">}</phrase>
10401         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10402             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
10403             <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">())</phrase>
10404             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10405                 <phrase role="identifier">back</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
10406             <phrase role="special">}</phrase>
10407         <phrase role="special">}</phrase>
10408     <phrase role="special">{</phrase>
10409         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10410     <phrase role="special">}</phrase>
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421     <phrase role="keyword">void</phrase> <phrase role="identifier">pop_back</phrase><phrase role="special">()</phrase>
10422         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10423             <phrase role="special">!</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10424         <phrase role="special">}</phrase>
10425         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10426             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
10427         <phrase role="special">}</phrase>
10428     <phrase role="special">{</phrase>
10429         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">pop_back</phrase><phrase role="special">();</phrase>
10430     <phrase role="special">}</phrase>
10431
10432
10433
10434
10435
10436     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
10437     <phrase role="keyword">void</phrase> <phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">InputIter</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">InputIter</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
10438         <phrase role="comment">// Precondition: [begin(), end()) does not contain [first, last).</phrase>
10439         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10440             <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">());</phrase>
10441         <phrase role="special">}</phrase>
10442     <phrase role="special">{</phrase>
10443         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
10444     <phrase role="special">}</phrase>
10445
10446
10447
10448
10449
10450
10451
10452     <phrase role="keyword">void</phrase> <phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">vallue</phrase><phrase role="special">)</phrase>
10453         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10454             <phrase role="identifier">count</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10455         <phrase role="special">}</phrase>
10456         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10457             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10458                 <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10459             <phrase role="special">}</phrase>
10460         <phrase role="special">}</phrase>
10461     <phrase role="special">{</phrase>
10462         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10463     <phrase role="special">}</phrase>
10464
10465
10466
10467
10468
10469
10470     <phrase role="identifier">iterator</phrase> <phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
10471         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10472             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10473         <phrase role="special">}</phrase>
10474         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10475             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
10476             <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
10477             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10478                 <phrase role="special">*</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
10479             <phrase role="special">}</phrase>
10480             <phrase role="comment">//  if(capacity() &gt; oldof(capacity()))</phrase>
10481             <phrase role="comment">//      [begin(), end()) is invalid</phrase>
10482             <phrase role="comment">//  else</phrase>
10483             <phrase role="comment">//      [where, end()) is invalid</phrase>
10484         <phrase role="special">}</phrase>
10485     <phrase role="special">{</phrase>
10486         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10487     <phrase role="special">}</phrase>
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500     <phrase role="keyword">void</phrase> <phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">size_type</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
10501         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10502             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10503         <phrase role="special">}</phrase>
10504         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10505             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
10506             <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
10507             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()))</phrase> <phrase role="special">{</phrase>
10508                 <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10509                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">prior</phrase><phrase role="special">(</phrase><phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">)),</phrase>
10510                             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">prior</phrase><phrase role="special">(</phrase><phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">))</phrase> <phrase role="special">+</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10511                 <phrase role="special">}</phrase>
10512                 <phrase role="comment">// [where, end()) is invalid</phrase>
10513             <phrase role="special">}</phrase>
10514             <phrase role="comment">// else [begin(), end()) is invalid</phrase>
10515         <phrase role="special">}</phrase>
10516     <phrase role="special">{</phrase>
10517         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10518     <phrase role="special">}</phrase>
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">InputIter</phrase><phrase role="special">&gt;</phrase>
10533     <phrase role="keyword">void</phrase> <phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iterator</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iterator</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
10534         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10535             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">();</phrase>
10536             <phrase role="comment">// [first, last) is not contained in [begin(), end())</phrase>
10537         <phrase role="special">}</phrase>
10538         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10539             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">+</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
10540             <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
10541             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()))</phrase> <phrase role="special">{</phrase>
10542                 <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10543                     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">all_of_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">));</phrase>
10544                 <phrase role="special">}</phrase>
10545                 <phrase role="comment">// [where, end()) is invalid</phrase>
10546             <phrase role="special">}</phrase>
10547             <phrase role="comment">// else [begin(), end()) is invalid</phrase>
10548         <phrase role="special">}</phrase>
10549     <phrase role="special">{</phrase>
10550         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">,</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
10551     <phrase role="special">}</phrase>
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566     <phrase role="identifier">iterator</phrase> <phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">where</phrase><phrase role="special">)</phrase>
10567         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10568             <phrase role="special">!</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10569             <phrase role="identifier">where</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">end</phrase><phrase role="special">();</phrase>
10570         <phrase role="special">}</phrase>
10571         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10572             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldod</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
10573             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">();</phrase>
10574             <phrase role="comment">// [where, end()) is invalid</phrase>
10575         <phrase role="special">}</phrase>
10576     <phrase role="special">{</phrase>
10577         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">where</phrase><phrase role="special">);</phrase>
10578     <phrase role="special">}</phrase>
10579
10580
10581
10582
10583
10584
10585     <phrase role="identifier">iterator</phrase> <phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">iterator</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
10586         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10587             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">lasst</phrase><phrase role="special">);</phrase>
10588         <phrase role="special">}</phrase>
10589         <phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10590             <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">())</phrase> <phrase role="special">-</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">distance</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
10591             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">end</phrase><phrase role="special">();</phrase>
10592             <phrase role="comment">// [first, last) is invalid</phrase>
10593         <phrase role="special">}</phrase>
10594     <phrase role="special">{</phrase>
10595         <phrase role="keyword">return</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">);</phrase>
10596     <phrase role="special">}</phrase>
10597
10598
10599
10600
10601
10602
10603
10604     <phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">()</phrase>
10605         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10606             <phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
10607         <phrase role="special">}</phrase>
10608     <phrase role="special">{</phrase>
10609         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">clear</phrase><phrase role="special">();</phrase>
10610     <phrase role="special">}</phrase>
10611
10612
10613
10614     <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">vector</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase>
10615         <phrase role="identifier">precondition</phrase> <phrase role="special">{</phrase>
10616             <phrase role="identifier">get_allocator</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">get_allocator</phrase><phrase role="special">();</phrase>
10617         <phrase role="special">}</phrase>
10618         <phrase role="identifier">postcondition</phrase> <phrase role="special">{</phrase>
10619             <phrase role="keyword">if</phrase> <phrase role="keyword">constexpr</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_equal_to</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10620                 <phrase role="special">*</phrase><phrase role="keyword">this</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">);</phrase>
10621                 <phrase role="identifier">other</phrase> <phrase role="special">==</phrase> <phrase role="identifier">oldof</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
10622             <phrase role="special">}</phrase>
10623         <phrase role="special">}</phrase>
10624     <phrase role="special">{</phrase>
10625         <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">swap</phrase><phrase role="special">(</phrase><phrase role="identifier">other</phrase><phrase role="special">);</phrase>
10626     <phrase role="special">}</phrase>
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645     <phrase role="keyword">friend</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase><phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">vector</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10646         <phrase role="comment">// Cannot check class invariants for left and right objects.</phrase>
10647         <phrase role="keyword">return</phrase> <phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase> <phrase role="special">==</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
10648     <phrase role="special">}</phrase>
10649
10650
10651
10652
10653
10654 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
10655     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
10656 <phrase role="special">};</phrase>
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701 <phrase role="comment">// End.</phrase>
10702 </programlisting>
10703                 </para>
10704               </entry>
10705             </row>
10706           </tbody>
10707         </tgroup>
10708       </informaltable>
10709     </section>
10710     <section id="boost_contract.examples.__n1962___circle__subcontracting">
10711       <title><link linkend="boost_contract.examples.__n1962___circle__subcontracting">[N1962]
10712       Circle: Subcontracting</link></title>
10713       <para>
10714 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
10715 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
10716
10717 <phrase role="keyword">class</phrase> <phrase role="identifier">shape</phrase> <phrase role="special">{</phrase>
10718 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
10719     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">shape</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase>
10720
10721     <phrase role="keyword">virtual</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">compute_area</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
10722 <phrase role="special">};</phrase>
10723
10724 <phrase role="keyword">unsigned</phrase> <phrase role="identifier">shape</phrase><phrase role="special">::</phrase><phrase role="identifier">compute_area</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
10725     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10726     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
10727         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10728             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
10729         <phrase role="special">})</phrase>
10730     <phrase role="special">;</phrase>
10731     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
10732     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10733 <phrase role="special">}</phrase>
10734
10735 <phrase role="keyword">class</phrase> <phrase role="identifier">circle</phrase>
10736     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">shape</phrase>
10737     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
10738 <phrase role="special">{</phrase>
10739     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
10740
10741     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
10742     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
10743
10744     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">compute_area</phrase><phrase role="special">);</phrase>
10745
10746 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
10747     <phrase role="keyword">static</phrase> <phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">pi</phrase> <phrase role="special">=</phrase> <phrase role="number">3</phrase><phrase role="special">;</phrase> <phrase role="comment">// Truncated to int from 3.14...</phrase>
10748
10749     <phrase role="keyword">explicit</phrase> <phrase role="identifier">circle</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">a_radius</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">radius_</phrase><phrase role="special">(</phrase><phrase role="identifier">a_radius</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10750         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
10751             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10752                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">radius</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">a_radius</phrase><phrase role="special">);</phrase>
10753             <phrase role="special">})</phrase>
10754         <phrase role="special">;</phrase>
10755     <phrase role="special">}</phrase>
10756
10757     <phrase role="keyword">virtual</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">compute_area</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase>
10758             <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
10759         <phrase role="keyword">unsigned</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10760         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
10761                 <phrase role="identifier">override_compute_area</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">circle</phrase><phrase role="special">::</phrase><phrase role="identifier">compute_area</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
10762             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10763                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">pi</phrase> <phrase role="special">*</phrase> <phrase role="identifier">radius</phrase><phrase role="special">()</phrase> <phrase role="special">*</phrase> <phrase role="identifier">radius</phrase><phrase role="special">());</phrase>
10764             <phrase role="special">})</phrase>
10765         <phrase role="special">;</phrase>
10766
10767         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">pi</phrase> <phrase role="special">*</phrase> <phrase role="identifier">radius</phrase><phrase role="special">()</phrase> <phrase role="special">*</phrase> <phrase role="identifier">radius</phrase><phrase role="special">();</phrase>
10768     <phrase role="special">}</phrase>
10769
10770     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">radius</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
10771         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
10772         <phrase role="keyword">return</phrase> <phrase role="identifier">radius_</phrase><phrase role="special">;</phrase>
10773     <phrase role="special">}</phrase>
10774
10775 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
10776     <phrase role="keyword">unsigned</phrase> <phrase role="identifier">radius_</phrase><phrase role="special">;</phrase>
10777 <phrase role="special">};</phrase>
10778
10779 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
10780     <phrase role="identifier">circle</phrase> <phrase role="identifier">c</phrase><phrase role="special">(</phrase><phrase role="number">2</phrase><phrase role="special">);</phrase>
10781     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">c</phrase><phrase role="special">.</phrase><phrase role="identifier">radius</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">2</phrase><phrase role="special">);</phrase>
10782     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">c</phrase><phrase role="special">.</phrase><phrase role="identifier">compute_area</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">12</phrase><phrase role="special">);</phrase>
10783     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
10784 <phrase role="special">}</phrase>
10785 </programlisting>
10786       </para>
10787     </section>
10788     <section id="boost_contract.examples.__n1962___factorial__recursion">
10789       <title><anchor id="N1962_factorial_anchor"/><link linkend="boost_contract.examples.__n1962___factorial__recursion">[N1962]
10790       Factorial: Recursion</link></title>
10791       <para>
10792 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
10793 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
10794
10795 <phrase role="keyword">int</phrase> <phrase role="identifier">factorial</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10796     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10797     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
10798         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10799             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Non-negative natural number.</phrase>
10800             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">12</phrase><phrase role="special">);</phrase> <phrase role="comment">// Max function input.</phrase>
10801         <phrase role="special">})</phrase>
10802         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10803             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
10804             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Select assertion.</phrase>
10805                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
10806             <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase>
10807                 <phrase role="comment">// Assertions automatically disabled in other assertions.</phrase>
10808                 <phrase role="comment">// Therefore, this postcondition can recursively call the</phrase>
10809                 <phrase role="comment">// function without causing infinite recursion.</phrase>
10810                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">*</phrase> <phrase role="identifier">factorial</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">));</phrase>
10811             <phrase role="special">}</phrase>
10812         <phrase role="special">})</phrase>
10813     <phrase role="special">;</phrase>
10814
10815     <phrase role="keyword">return</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">2</phrase> <phrase role="special">?</phrase> <phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">n</phrase> <phrase role="special">*</phrase> <phrase role="identifier">factorial</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">));</phrase>
10816 <phrase role="special">}</phrase>
10817
10818 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
10819     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">factorial</phrase><phrase role="special">(</phrase><phrase role="number">4</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">24</phrase><phrase role="special">);</phrase>
10820     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
10821 <phrase role="special">}</phrase>
10822 </programlisting>
10823       </para>
10824     </section>
10825     <section id="boost_contract.examples.__n1962___equal__operators">
10826       <title><link linkend="boost_contract.examples.__n1962___equal__operators">[N1962]
10827       Equal: Operators</link></title>
10828       <para>
10829 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
10830 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
10831
10832 <phrase role="comment">// Forward declaration because == and != contracts use one another's function.</phrase>
10833 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
10834 <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">);</phrase>
10835
10836 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
10837 <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">!=(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10838     <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10839     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
10840         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10841             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">!(</phrase><phrase role="identifier">left</phrase> <phrase role="special">==</phrase> <phrase role="identifier">right</phrase><phrase role="special">));</phrase>
10842         <phrase role="special">})</phrase>
10843     <phrase role="special">;</phrase>
10844
10845     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10846 <phrase role="special">}</phrase>
10847
10848 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
10849 <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10850     <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10851     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
10852         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10853             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">!(</phrase><phrase role="identifier">left</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">right</phrase><phrase role="special">));</phrase>
10854         <phrase role="special">})</phrase>
10855     <phrase role="special">;</phrase>
10856
10857     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase> <phrase role="special">==</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
10858 <phrase role="special">}</phrase>
10859
10860 <phrase role="keyword">struct</phrase> <phrase role="identifier">number</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase>
10861
10862 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
10863     <phrase role="identifier">number</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
10864     <phrase role="identifier">n</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="number">123</phrase><phrase role="special">;</phrase>
10865
10866     <phrase role="identifier">assert</phrase><phrase role="special">((</phrase><phrase role="identifier">n</phrase> <phrase role="special">==</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="keyword">true</phrase><phrase role="special">);</phrase>   <phrase role="comment">// Explicitly call operator==.</phrase>
10867     <phrase role="identifier">assert</phrase><phrase role="special">((</phrase><phrase role="identifier">n</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="keyword">false</phrase><phrase role="special">);</phrase>  <phrase role="comment">// Explicitly call operator!=.</phrase>
10868
10869     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
10870 <phrase role="special">}</phrase>
10871 </programlisting>
10872       </para>
10873     </section>
10874     <section id="boost_contract.examples.__n1962___sum__array_parameter">
10875       <title><link linkend="boost_contract.examples.__n1962___sum__array_parameter">[N1962]
10876       Sum: Array parameter</link></title>
10877       <para>
10878 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
10879 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
10880
10881 <phrase role="keyword">int</phrase> <phrase role="identifier">sum</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="identifier">array</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10882     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10883     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
10884         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10885             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">%</phrase> <phrase role="number">4</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
10886         <phrase role="special">})</phrase>
10887     <phrase role="special">;</phrase>
10888
10889     <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
10890     <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">result</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">array</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">];</phrase>
10891     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10892 <phrase role="special">}</phrase>
10893
10894 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
10895     <phrase role="keyword">int</phrase> <phrase role="identifier">a</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="special">{</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">2</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">,</phrase> <phrase role="number">4</phrase><phrase role="special">};</phrase>
10896     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">sum</phrase><phrase role="special">(</phrase><phrase role="number">4</phrase><phrase role="special">,</phrase> <phrase role="identifier">a</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">10</phrase><phrase role="special">);</phrase>
10897     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
10898 <phrase role="special">}</phrase>
10899 </programlisting>
10900       </para>
10901     </section>
10902     <section id="boost_contract.examples.__n1962___square_root__default_parameters_and_comparison_with_d_syntax">
10903       <title><anchor id="N1962_square_root_anchor"/><link linkend="boost_contract.examples.__n1962___square_root__default_parameters_and_comparison_with_d_syntax">[N1962]
10904       Square Root: Default parameters and comparison with D syntax</link></title>
10905       <informaltable frame="all">
10906         <tgroup cols="2">
10907           <thead>
10908             <row>
10909               <entry>
10910                 <para>
10911                   This Library
10912                 </para>
10913               </entry>
10914               <entry>
10915                 <para>
10916                   The D Programming Language
10917                 </para>
10918               </entry>
10919             </row>
10920           </thead>
10921           <tbody>
10922             <row>
10923               <entry>
10924                 <para>
10925 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
10926 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cmath</phrase><phrase role="special">&gt;</phrase>
10927 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
10928
10929 <phrase role="keyword">long</phrase> <phrase role="identifier">lsqrt</phrase><phrase role="special">(</phrase><phrase role="keyword">long</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10930     <phrase role="keyword">long</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
10931     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
10932         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10933             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
10934         <phrase role="special">})</phrase>
10935         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
10936             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">*</phrase> <phrase role="identifier">result</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
10937             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">result</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">*</phrase> <phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
10938         <phrase role="special">})</phrase>
10939     <phrase role="special">;</phrase>
10940
10941     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="keyword">long</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">sqrt</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">)));</phrase>
10942 <phrase role="special">}</phrase>
10943
10944 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
10945     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">lsqrt</phrase><phrase role="special">(</phrase><phrase role="number">4</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">2</phrase><phrase role="special">);</phrase>
10946     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
10947 <phrase role="special">}</phrase>
10948 </programlisting>
10949                 </para>
10950               </entry>
10951               <entry>
10952                 <para>
10953 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Extra spaces, newlines, etc. for visual alignment with this library code.</phrase>
10954
10955
10956
10957 <phrase role="keyword">long</phrase> <phrase role="identifier">lsqrt</phrase><phrase role="special">(</phrase><phrase role="keyword">long</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase>
10958 <phrase role="identifier">in</phrase> <phrase role="special">{</phrase>
10959     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
10960 <phrase role="special">}</phrase>
10961 <phrase role="identifier">out</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
10962     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">*</phrase> <phrase role="identifier">result</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
10963     <phrase role="identifier">assert</phrase><phrase role="special">((</phrase><phrase role="identifier">result</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">*</phrase> <phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase>
10964 <phrase role="special">}</phrase>
10965 <phrase role="keyword">do</phrase> <phrase role="special">{</phrase>
10966     <phrase role="keyword">return</phrase> <phrase role="identifier">cast</phrase><phrase role="special">(</phrase><phrase role="keyword">long</phrase><phrase role="special">)</phrase><phrase role="identifier">std</phrase><phrase role="special">.</phrase><phrase role="identifier">math</phrase><phrase role="special">.</phrase><phrase role="identifier">sqrt</phrase><phrase role="special">(</phrase><phrase role="identifier">cast</phrase><phrase role="special">(</phrase><phrase role="identifier">real</phrase><phrase role="special">)</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
10967 <phrase role="special">}</phrase>
10968
10969
10970
10971
10972
10973
10974
10975
10976 <phrase role="comment">// End.</phrase>
10977 </programlisting>
10978                 </para>
10979               </entry>
10980             </row>
10981           </tbody>
10982         </tgroup>
10983       </informaltable>
10984     </section>
10985     <section id="boost_contract.examples.__meyer97___stack4__comparison_with_eiffel_syntax">
10986       <title><anchor id="Meyer97_stack4_anchor"/><link linkend="boost_contract.examples.__meyer97___stack4__comparison_with_eiffel_syntax">[Meyer97]
10987       Stack4: Comparison with Eiffel syntax</link></title>
10988       <informaltable frame="all">
10989         <tgroup cols="2">
10990           <thead>
10991             <row>
10992               <entry>
10993                 <para>
10994                   This Library
10995                 </para>
10996               </entry>
10997               <entry>
10998                 <para>
10999                   The Eiffel Programming Language
11000                 </para>
11001               </entry>
11002             </row>
11003           </thead>
11004           <tbody>
11005             <row>
11006               <entry>
11007                 <para>
11008 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// File: stack4.hpp</phrase>
11009 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">STACK4_HPP_</phrase>
11010 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">STACK4_HPP_</phrase>
11011
11012 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
11013
11014 <phrase role="comment">// Dispenser with LIFO access policy and fixed max capacity.</phrase>
11015 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
11016 <phrase role="keyword">class</phrase> <phrase role="identifier">stack4</phrase>
11017     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">stack4</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
11018     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
11019 <phrase role="special">{</phrase>
11020     <phrase role="keyword">friend</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
11021     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
11022     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
11023
11024     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11025         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count non-negative.</phrase>
11026         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase> <phrase role="comment">// Count bounded.</phrase>
11027         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase> <phrase role="comment">// Empty if no elem.</phrase>
11028     <phrase role="special">}</phrase>
11029
11030 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
11031     <phrase role="comment">/* Initialization */</phrase>
11032
11033     <phrase role="comment">// Allocate static from a maximum of n elements.</phrase>
11034     <phrase role="keyword">explicit</phrase> <phrase role="identifier">stack4</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
11035         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">stack4</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
11036             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Non-negative capacity.</phrase>
11037         <phrase role="special">})</phrase>
11038     <phrase role="special">{</phrase>
11039         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11040             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11041                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase> <phrase role="comment">// Capacity set.</phrase>
11042             <phrase role="special">})</phrase>
11043         <phrase role="special">;</phrase>
11044
11045         <phrase role="identifier">capacity_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
11046         <phrase role="identifier">count_</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
11047         <phrase role="identifier">array_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">n</phrase><phrase role="special">];</phrase>
11048     <phrase role="special">}</phrase>
11049
11050     <phrase role="comment">// Deep copy via constructor.</phrase>
11051     <phrase role="comment">/* implicit */</phrase> <phrase role="identifier">stack4</phrase><phrase role="special">(</phrase><phrase role="identifier">stack4</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11052         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11053             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11054                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
11055                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11056                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">);</phrase>
11057             <phrase role="special">})</phrase>
11058         <phrase role="special">;</phrase>
11059
11060         <phrase role="identifier">capacity_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
11061         <phrase role="identifier">count_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">count_</phrase><phrase role="special">;</phrase>
11062         <phrase role="identifier">array_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity_</phrase><phrase role="special">];</phrase>
11063         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">count_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">];</phrase>
11064     <phrase role="special">}</phrase>
11065
11066     <phrase role="comment">// Deep copy via assignment.</phrase>
11067     <phrase role="identifier">stack4</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase><phrase role="identifier">stack4</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11068         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11069             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11070                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
11071                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11072                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(*</phrase><phrase role="keyword">this</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">);</phrase>
11073             <phrase role="special">})</phrase>
11074         <phrase role="special">;</phrase>
11075
11076         <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">array_</phrase><phrase role="special">;</phrase>
11077         <phrase role="identifier">capacity_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
11078         <phrase role="identifier">count_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">count_</phrase><phrase role="special">;</phrase>
11079         <phrase role="identifier">array_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity_</phrase><phrase role="special">];</phrase>
11080         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">count_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">];</phrase>
11081         <phrase role="keyword">return</phrase> <phrase role="special">*</phrase><phrase role="keyword">this</phrase><phrase role="special">;</phrase>
11082     <phrase role="special">}</phrase>
11083
11084     <phrase role="comment">// Destroy this stack.</phrase>
11085     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">stack4</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11086         <phrase role="comment">// Check invariants.</phrase>
11087         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11088         <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">array_</phrase><phrase role="special">;</phrase>
11089     <phrase role="special">}</phrase>
11090
11091     <phrase role="comment">/* Access */</phrase>
11092
11093     <phrase role="comment">// Max number of stack elements.</phrase>
11094     <phrase role="keyword">int</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11095         <phrase role="comment">// Check invariants.</phrase>
11096         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11097         <phrase role="keyword">return</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
11098     <phrase role="special">}</phrase>
11099
11100     <phrase role="comment">// Number of stack elements.</phrase>
11101     <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11102         <phrase role="comment">// Check invariants.</phrase>
11103         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11104         <phrase role="keyword">return</phrase> <phrase role="identifier">count_</phrase><phrase role="special">;</phrase>
11105     <phrase role="special">}</phrase>
11106
11107     <phrase role="comment">// Top element.</phrase>
11108     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11109         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11110             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11111                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase> <phrase role="comment">// Not empty (i.e., count &gt; 0).</phrase>
11112             <phrase role="special">})</phrase>
11113         <phrase role="special">;</phrase>
11114
11115         <phrase role="keyword">return</phrase> <phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">count_</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">];</phrase>
11116     <phrase role="special">}</phrase>
11117
11118     <phrase role="comment">/* Status Report */</phrase>
11119
11120     <phrase role="comment">// Is stack empty?</phrase>
11121     <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11122         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
11123         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11124             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11125                 <phrase role="comment">// Empty definition.</phrase>
11126                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
11127             <phrase role="special">})</phrase>
11128         <phrase role="special">;</phrase>
11129
11130         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">count_</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
11131     <phrase role="special">}</phrase>
11132
11133     <phrase role="comment">// Is stack full?</phrase>
11134     <phrase role="keyword">bool</phrase> <phrase role="identifier">full</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11135         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
11136         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11137             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11138                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="comment">// Full definition.</phrase>
11139                         <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()));</phrase>
11140             <phrase role="special">})</phrase>
11141         <phrase role="special">;</phrase>
11142
11143         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">count_</phrase> <phrase role="special">==</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">);</phrase>
11144     <phrase role="special">}</phrase>
11145
11146     <phrase role="comment">/* Element Change */</phrase>
11147
11148     <phrase role="comment">// Add x on top.</phrase>
11149     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11150         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11151         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11152             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11153                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase> <phrase role="comment">// Not full.</phrase>
11154             <phrase role="special">})</phrase>
11155             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11156                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase> <phrase role="comment">// Not empty.</phrase>
11157                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase> <phrase role="comment">// Added to top.</phrase>
11158                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// One more.</phrase>
11159             <phrase role="special">})</phrase>
11160         <phrase role="special">;</phrase>
11161
11162         <phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">count_</phrase><phrase role="special">++]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase>
11163     <phrase role="special">}</phrase>
11164
11165     <phrase role="comment">// Remove top element.</phrase>
11166     <phrase role="keyword">void</phrase> <phrase role="identifier">remove</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11167         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11168         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11169             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11170                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase> <phrase role="comment">// Not empty (i.e., count &gt; 0).</phrase>
11171             <phrase role="special">})</phrase>
11172             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11173                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase> <phrase role="comment">// Not full.</phrase>
11174                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// One less.</phrase>
11175             <phrase role="special">})</phrase>
11176         <phrase role="special">;</phrase>
11177
11178         <phrase role="special">--</phrase><phrase role="identifier">count_</phrase><phrase role="special">;</phrase>
11179     <phrase role="special">}</phrase>
11180
11181     <phrase role="comment">/* Friend Helpers */</phrase>
11182
11183     <phrase role="keyword">friend</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase><phrase role="identifier">stack4</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase> <phrase role="identifier">stack4</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11184         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">inv1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">left</phrase><phrase role="special">);</phrase>
11185         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">inv2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">right</phrase><phrase role="special">);</phrase>
11186         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">count_</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">count_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
11187         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">count_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11188             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">array_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">])</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
11189         <phrase role="special">}</phrase>
11190         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
11191     <phrase role="special">}</phrase>
11192
11193 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
11194     <phrase role="keyword">int</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
11195     <phrase role="keyword">int</phrase> <phrase role="identifier">count_</phrase><phrase role="special">;</phrase>
11196     <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">array_</phrase><phrase role="special">;</phrase> <phrase role="comment">// Internally use C-style array.</phrase>
11197 <phrase role="special">};</phrase>
11198
11199 <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// #include guard</phrase>
11200 </programlisting>
11201                 </para>
11202               </entry>
11203               <entry>
11204                 <para>
11205 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">--</phrase> <phrase role="identifier">Extra</phrase> <phrase role="identifier">spaces</phrase><phrase role="special">,</phrase> <phrase role="identifier">newlines</phrase><phrase role="special">,</phrase> <phrase role="identifier">etc</phrase><phrase role="special">.</phrase> <phrase role="keyword">for</phrase> <phrase role="identifier">visual</phrase> <phrase role="identifier">alignment</phrase> <phrase role="identifier">with</phrase> <phrase role="keyword">this</phrase> <phrase role="identifier">library</phrase> <phrase role="identifier">code</phrase><phrase role="special">.</phrase>
11206
11207
11208
11209
11210
11211 <phrase role="identifier">indexing</phrase>
11212     <phrase role="identifier">destription</phrase><phrase role="special">:</phrase> <phrase role="string">"Dispenser with LIFO access policy and a fixed max capacity."</phrase>
11213 <phrase role="keyword">class</phrase> <phrase role="identifier">interface</phrase> <phrase role="identifier">STACK4</phrase><phrase role="special">[</phrase><phrase role="identifier">G</phrase><phrase role="special">]</phrase> <phrase role="identifier">creation</phrase> <phrase role="identifier">make</phrase> <phrase role="special">--</phrase> <phrase role="identifier">Interface</phrase> <phrase role="identifier">only</phrase> <phrase role="special">(</phrase><phrase role="identifier">no</phrase> <phrase role="identifier">implementation</phrase><phrase role="special">).</phrase>
11214
11215
11216
11217
11218
11219
11220
11221 <phrase role="identifier">invariant</phrase>
11222     <phrase role="identifier">count_non_negative</phrase><phrase role="special">:</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase>
11223     <phrase role="identifier">count_bounded</phrase><phrase role="special">:</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase>
11224     <phrase role="identifier">empty_if_no_elements</phrase><phrase role="special">:</phrase> <phrase role="identifier">empty</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
11225
11226
11227
11228 <phrase role="identifier">feature</phrase> <phrase role="special">--</phrase> <phrase role="identifier">Initialization</phrase>
11229
11230     <phrase role="special">--</phrase> <phrase role="identifier">Allocate</phrase> <phrase role="identifier">stack</phrase> <phrase role="keyword">for</phrase> <phrase role="identifier">a</phrase> <phrase role="identifier">maximum</phrase> <phrase role="identifier">of</phrase> <phrase role="identifier">n</phrase> <phrase role="identifier">elements</phrase><phrase role="special">.</phrase>
11231     <phrase role="identifier">make</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase><phrase role="special">:</phrase> <phrase role="identifier">INTEGER</phrase><phrase role="special">)</phrase> <phrase role="identifier">is</phrase>
11232         <phrase role="identifier">require</phrase>
11233             <phrase role="identifier">non_negative_capacity</phrase><phrase role="special">:</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase>
11234         <phrase role="identifier">ensure</phrase>
11235             <phrase role="identifier">capacity_set</phrase><phrase role="special">:</phrase> <phrase role="identifier">capacity</phrase> <phrase role="special">=</phrase> <phrase role="identifier">n</phrase>
11236         <phrase role="identifier">end</phrase>
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288 <phrase role="identifier">feature</phrase> <phrase role="special">--</phrase> <phrase role="identifier">Access</phrase>
11289
11290     <phrase role="special">--</phrase> <phrase role="identifier">Max</phrase> <phrase role="identifier">number</phrase> <phrase role="identifier">of</phrase> <phrase role="identifier">stack</phrase> <phrase role="identifier">elements</phrase><phrase role="special">.</phrase>
11291     <phrase role="identifier">capacity</phrase><phrase role="special">:</phrase> <phrase role="identifier">INTEGER</phrase>
11292
11293
11294
11295
11296
11297     <phrase role="special">--</phrase> <phrase role="identifier">Number</phrase> <phrase role="identifier">of</phrase> <phrase role="identifier">stack</phrase> <phrase role="identifier">elements</phrase><phrase role="special">.</phrase>
11298     <phrase role="identifier">count</phrase><phrase role="special">:</phrase> <phrase role="identifier">INTEGER</phrase>
11299
11300
11301
11302
11303
11304     <phrase role="special">--</phrase> <phrase role="identifier">Top</phrase> <phrase role="identifier">element</phrase><phrase role="special">.</phrase>
11305     <phrase role="identifier">item</phrase><phrase role="special">:</phrase> <phrase role="identifier">G</phrase> <phrase role="identifier">is</phrase>
11306         <phrase role="identifier">require</phrase>
11307             <phrase role="identifier">not_empty</phrase><phrase role="special">:</phrase> <phrase role="keyword">not</phrase> <phrase role="identifier">empty</phrase> <phrase role="special">--</phrase> <phrase role="identifier">i</phrase><phrase role="special">.</phrase><phrase role="identifier">e</phrase><phrase role="special">.,</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase>
11308         <phrase role="identifier">end</phrase>
11309
11310
11311
11312
11313
11314
11315 <phrase role="identifier">feature</phrase> <phrase role="special">--</phrase> <phrase role="identifier">Status</phrase> <phrase role="identifier">report</phrase>
11316
11317     <phrase role="special">--</phrase> <phrase role="identifier">Is</phrase> <phrase role="identifier">stack</phrase> <phrase role="identifier">empty</phrase><phrase role="special">?</phrase>
11318     <phrase role="identifier">empty</phrase><phrase role="special">:</phrase> <phrase role="identifier">BOOLEAN</phrase> <phrase role="identifier">is</phrase>
11319         <phrase role="identifier">ensure</phrase>
11320             <phrase role="identifier">empty_definition</phrase><phrase role="special">:</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
11321         <phrase role="identifier">end</phrase>
11322
11323
11324
11325
11326
11327
11328
11329
11330     <phrase role="special">--</phrase> <phrase role="identifier">Is</phrase> <phrase role="identifier">stack</phrase> <phrase role="identifier">full</phrase><phrase role="special">?</phrase>
11331     <phrase role="identifier">full</phrase><phrase role="special">:</phrase> <phrase role="identifier">BOOLEAN</phrase> <phrase role="identifier">is</phrase>
11332         <phrase role="identifier">ensure</phrase>
11333             <phrase role="identifier">full_definition</phrase><phrase role="special">:</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">)</phrase>
11334         <phrase role="identifier">end</phrase>
11335
11336
11337
11338
11339
11340
11341
11342
11343 <phrase role="identifier">feature</phrase> <phrase role="special">--</phrase> <phrase role="identifier">Element</phrase> <phrase role="identifier">change</phrase>
11344
11345     <phrase role="special">--</phrase> <phrase role="identifier">Add</phrase> <phrase role="identifier">x</phrase> <phrase role="identifier">on</phrase> <phrase role="identifier">top</phrase><phrase role="special">.</phrase>
11346     <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">:</phrase> <phrase role="identifier">G</phrase><phrase role="special">)</phrase> <phrase role="identifier">is</phrase>
11347         <phrase role="identifier">require</phrase>
11348             <phrase role="identifier">not_full</phrase><phrase role="special">:</phrase> <phrase role="keyword">not</phrase> <phrase role="identifier">full</phrase>
11349         <phrase role="identifier">ensure</phrase>
11350             <phrase role="identifier">not_empty</phrase><phrase role="special">:</phrase> <phrase role="keyword">not</phrase> <phrase role="identifier">empty</phrase>
11351             <phrase role="identifier">added_to_top</phrase><phrase role="special">:</phrase> <phrase role="identifier">item</phrase> <phrase role="special">=</phrase> <phrase role="identifier">x</phrase>
11352             <phrase role="identifier">one_more_item</phrase><phrase role="special">:</phrase> <phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">old</phrase> <phrase role="identifier">count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase>
11353         <phrase role="identifier">end</phrase>
11354
11355
11356
11357
11358
11359
11360
11361
11362     <phrase role="special">--</phrase> <phrase role="identifier">Remove</phrase> <phrase role="identifier">top</phrase> <phrase role="identifier">element</phrase><phrase role="special">.</phrase>
11363     <phrase role="identifier">remove</phrase> <phrase role="identifier">is</phrase>
11364         <phrase role="identifier">require</phrase>
11365             <phrase role="identifier">not_empty</phrase><phrase role="special">:</phrase> <phrase role="keyword">not</phrase> <phrase role="identifier">empty</phrase> <phrase role="special">--</phrase> <phrase role="identifier">i</phrase><phrase role="special">.</phrase><phrase role="identifier">e</phrase><phrase role="special">.,</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase>
11366         <phrase role="identifier">ensure</phrase>
11367             <phrase role="identifier">not_full</phrase><phrase role="special">:</phrase> <phrase role="keyword">not</phrase> <phrase role="identifier">full</phrase>
11368             <phrase role="identifier">one_fewer_item</phrase><phrase role="special">:</phrase> <phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">old</phrase> <phrase role="identifier">count</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase>
11369
11370         <phrase role="identifier">end</phrase>
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394 <phrase role="identifier">end</phrase> <phrase role="special">--</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">interface</phrase> <phrase role="identifier">STACK4</phrase>
11395
11396 <phrase role="special">--</phrase> <phrase role="identifier">End</phrase><phrase role="special">.</phrase>
11397 </programlisting>
11398                 </para>
11399               </entry>
11400             </row>
11401             <row>
11402               <entry>
11403                 <para>
11404 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="string">"stack4.hpp"</phrase>
11405 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
11406
11407 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11408     <phrase role="identifier">stack4</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">s</phrase><phrase role="special">(</phrase><phrase role="number">3</phrase><phrase role="special">);</phrase>
11409     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase>
11410     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
11411     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
11412     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
11413
11414     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="number">123</phrase><phrase role="special">);</phrase>
11415     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
11416     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
11417     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
11418
11419     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">remove</phrase><phrase role="special">();</phrase>
11420     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
11421     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
11422
11423     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
11424 <phrase role="special">}</phrase>
11425 </programlisting>
11426                 </para>
11427               </entry>
11428               <entry>
11429               </entry>
11430             </row>
11431           </tbody>
11432         </tgroup>
11433       </informaltable>
11434     </section>
11435     <section id="boost_contract.examples.__meyer97___stack3__error_codes_instead_of_preconditions">
11436       <title><link linkend="boost_contract.examples.__meyer97___stack3__error_codes_instead_of_preconditions">[Meyer97]
11437       Stack3: Error codes instead of preconditions</link></title>
11438       <para>
11439 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// File: stack3.cpp</phrase>
11440 <phrase role="preprocessor">#include</phrase> <phrase role="string">"stack4.hpp"</phrase>
11441 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
11442 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">optional</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
11443 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
11444
11445 <phrase role="comment">// Dispenser LIFO with max capacity using error codes.</phrase>
11446 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
11447 <phrase role="keyword">class</phrase> <phrase role="identifier">stack3</phrase> <phrase role="special">{</phrase>
11448     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
11449
11450     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11451         <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">error</phrase><phrase role="special">())</phrase> <phrase role="special">{</phrase>
11452             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count non-negative.</phrase>
11453             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase> <phrase role="comment">// Count bounded.</phrase>
11454             <phrase role="comment">// Empty if no element.</phrase>
11455             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
11456         <phrase role="special">}</phrase>
11457     <phrase role="special">}</phrase>
11458
11459 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
11460     <phrase role="keyword">enum</phrase> <phrase role="identifier">error_code</phrase> <phrase role="special">{</phrase>
11461         <phrase role="identifier">no_error</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">,</phrase>
11462         <phrase role="identifier">overflow_error</phrase><phrase role="special">,</phrase>
11463         <phrase role="identifier">underflow_error</phrase><phrase role="special">,</phrase>
11464         <phrase role="identifier">size_error</phrase>
11465     <phrase role="special">};</phrase>
11466
11467     <phrase role="comment">/* Initialization */</phrase>
11468
11469     <phrase role="comment">// Create stack for max of n elems, if n &lt; 0 set error (no preconditions).</phrase>
11470     <phrase role="keyword">explicit</phrase> <phrase role="identifier">stack3</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">default_value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">T</phrase><phrase role="special">())</phrase> <phrase role="special">:</phrase>
11471             <phrase role="identifier">stack_</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">),</phrase> <phrase role="identifier">error_</phrase><phrase role="special">(</phrase><phrase role="identifier">no_error</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11472         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11473             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11474                 <phrase role="comment">// Error if impossible.</phrase>
11475                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">n</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">error</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">size_error</phrase><phrase role="special">));</phrase>
11476                 <phrase role="comment">// No error if possible.</phrase>
11477                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">n</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="special">!</phrase><phrase role="identifier">error</phrase><phrase role="special">());</phrase>
11478                 <phrase role="comment">// Created if no error.</phrase>
11479                 <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">error</phrase><phrase role="special">())</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
11480             <phrase role="special">})</phrase>
11481         <phrase role="special">;</phrase>
11482
11483         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">n</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="identifier">stack_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">stack4</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">n</phrase><phrase role="special">);</phrase>
11484         <phrase role="keyword">else</phrase> <phrase role="identifier">error_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">size_error</phrase><phrase role="special">;</phrase>
11485     <phrase role="special">}</phrase>
11486
11487     <phrase role="comment">/* Access */</phrase>
11488
11489     <phrase role="comment">// Max number of stack elements.</phrase>
11490     <phrase role="keyword">int</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11491         <phrase role="comment">// Check invariants.</phrase>
11492         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11493         <phrase role="keyword">return</phrase> <phrase role="identifier">stack_</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">();</phrase>
11494     <phrase role="special">}</phrase>
11495
11496     <phrase role="comment">// Number of stack elements.</phrase>
11497     <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11498         <phrase role="comment">// Check invariants.</phrase>
11499         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11500         <phrase role="keyword">return</phrase> <phrase role="identifier">stack_</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">();</phrase>
11501     <phrase role="special">}</phrase>
11502
11503     <phrase role="comment">// Top element if present, otherwise none and set error (no preconditions).</phrase>
11504     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11505         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11506             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11507                 <phrase role="comment">// Error if impossible.</phrase>
11508                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">error</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">underflow_error</phrase><phrase role="special">));</phrase>
11509                 <phrase role="comment">// No error if possible.</phrase>
11510                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">!</phrase><phrase role="identifier">error</phrase><phrase role="special">());</phrase>
11511             <phrase role="special">})</phrase>
11512         <phrase role="special">;</phrase>
11513
11514         <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="special">{</phrase>
11515             <phrase role="identifier">error_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">no_error</phrase><phrase role="special">;</phrase>
11516             <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;(</phrase><phrase role="identifier">stack_</phrase><phrase role="special">.</phrase><phrase role="identifier">item</phrase><phrase role="special">());</phrase>
11517         <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase>
11518             <phrase role="identifier">error_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">underflow_error</phrase><phrase role="special">;</phrase>
11519             <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;();</phrase>
11520         <phrase role="special">}</phrase>
11521     <phrase role="special">}</phrase>
11522
11523     <phrase role="comment">/* Status Report */</phrase>
11524
11525     <phrase role="comment">// Error indicator set by various operations.</phrase>
11526     <phrase role="identifier">error_code</phrase> <phrase role="identifier">error</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11527         <phrase role="comment">// Check invariants.</phrase>
11528         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11529         <phrase role="keyword">return</phrase> <phrase role="identifier">error_</phrase><phrase role="special">;</phrase>
11530     <phrase role="special">}</phrase>
11531
11532     <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11533         <phrase role="comment">// Check invariants.</phrase>
11534         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11535         <phrase role="keyword">return</phrase> <phrase role="identifier">stack_</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
11536     <phrase role="special">}</phrase>
11537
11538     <phrase role="keyword">bool</phrase> <phrase role="identifier">full</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11539         <phrase role="comment">// Check invariants.</phrase>
11540         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11541         <phrase role="keyword">return</phrase> <phrase role="identifier">stack_</phrase><phrase role="special">.</phrase><phrase role="identifier">full</phrase><phrase role="special">();</phrase>
11542     <phrase role="special">}</phrase>
11543
11544     <phrase role="comment">/* Element Change */</phrase>
11545
11546     <phrase role="comment">// Add x to top if capacity allows, otherwise set error (no preconditions).</phrase>
11547     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11548         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_full</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
11549         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11550         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11551             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11552                 <phrase role="comment">// Error if impossible.</phrase>
11553                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_full</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">error</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">overflow_error</phrase><phrase role="special">));</phrase>
11554                 <phrase role="comment">// No error if possible.</phrase>
11555                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!*</phrase><phrase role="identifier">old_full</phrase> <phrase role="special">==</phrase> <phrase role="special">!</phrase><phrase role="identifier">error</phrase><phrase role="special">());</phrase>
11556                 <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">error</phrase><phrase role="special">())</phrase> <phrase role="special">{</phrase> <phrase role="comment">// If no error...</phrase>
11557                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase> <phrase role="comment">// ...not empty.</phrase>
11558                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase> <phrase role="comment">// ...added to top.</phrase>
11559                     <phrase role="comment">// ...one more.</phrase>
11560                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
11561                 <phrase role="special">}</phrase>
11562             <phrase role="special">})</phrase>
11563         <phrase role="special">;</phrase>
11564
11565         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">full</phrase><phrase role="special">())</phrase> <phrase role="identifier">error_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">overflow_error</phrase><phrase role="special">;</phrase>
11566         <phrase role="keyword">else</phrase> <phrase role="special">{</phrase>
11567             <phrase role="identifier">stack_</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">);</phrase>
11568             <phrase role="identifier">error_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">no_error</phrase><phrase role="special">;</phrase>
11569         <phrase role="special">}</phrase>
11570     <phrase role="special">}</phrase>
11571
11572     <phrase role="comment">// Remove top element if possible, otherwise set error (no preconditions).</phrase>
11573     <phrase role="keyword">void</phrase> <phrase role="identifier">remove</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11574         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_empty</phrase> <phrase role="special">=</phrase>
11575                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
11576         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11577         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11578             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11579                 <phrase role="comment">// Error if impossible.</phrase>
11580                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_empty</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">error</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase>
11581                         <phrase role="identifier">underflow_error</phrase><phrase role="special">));</phrase>
11582                 <phrase role="comment">// No error if possible.</phrase>
11583                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!*</phrase><phrase role="identifier">old_empty</phrase> <phrase role="special">==</phrase> <phrase role="special">!</phrase><phrase role="identifier">error</phrase><phrase role="special">());</phrase>
11584                 <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">error</phrase><phrase role="special">())</phrase> <phrase role="special">{</phrase> <phrase role="comment">// If no error...</phrase>
11585                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase> <phrase role="comment">// ...not full.</phrase>
11586                     <phrase role="comment">// ...one less.</phrase>
11587                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
11588                 <phrase role="special">}</phrase>
11589             <phrase role="special">})</phrase>
11590         <phrase role="special">;</phrase>
11591
11592         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">())</phrase> <phrase role="identifier">error_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">underflow_error</phrase><phrase role="special">;</phrase>
11593         <phrase role="keyword">else</phrase> <phrase role="special">{</phrase>
11594             <phrase role="identifier">stack_</phrase><phrase role="special">.</phrase><phrase role="identifier">remove</phrase><phrase role="special">();</phrase>
11595             <phrase role="identifier">error_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">no_error</phrase><phrase role="special">;</phrase>
11596         <phrase role="special">}</phrase>
11597     <phrase role="special">}</phrase>
11598
11599 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
11600     <phrase role="identifier">stack4</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">stack_</phrase><phrase role="special">;</phrase>
11601     <phrase role="keyword">mutable</phrase> <phrase role="identifier">error_code</phrase> <phrase role="identifier">error_</phrase><phrase role="special">;</phrase>
11602 <phrase role="special">};</phrase>
11603
11604 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11605     <phrase role="identifier">stack3</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">s</phrase><phrase role="special">(</phrase><phrase role="number">3</phrase><phrase role="special">);</phrase>
11606     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase>
11607     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
11608     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
11609     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
11610
11611     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="number">123</phrase><phrase role="special">);</phrase>
11612     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
11613     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
11614     <phrase role="identifier">assert</phrase><phrase role="special">(*</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
11615
11616     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">remove</phrase><phrase role="special">();</phrase>
11617     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
11618     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
11619
11620     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
11621 <phrase role="special">}</phrase>
11622 </programlisting>
11623       </para>
11624     </section>
11625     <section id="boost_contract.examples.__mitchell02___name_list__relaxed_subcontracts">
11626       <title><link linkend="boost_contract.examples.__mitchell02___name_list__relaxed_subcontracts">[Mitchell02]
11627       Name List: Relaxed subcontracts</link></title>
11628       <para>
11629 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
11630 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">string</phrase><phrase role="special">&gt;</phrase>
11631 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase>
11632 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">&gt;</phrase>
11633 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
11634
11635 <phrase role="comment">// List of names.</phrase>
11636 <phrase role="keyword">class</phrase> <phrase role="identifier">name_list</phrase> <phrase role="special">{</phrase>
11637     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
11638
11639     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11640         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Non-negative count.</phrase>
11641     <phrase role="special">}</phrase>
11642
11643 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
11644     <phrase role="comment">/* Creation */</phrase>
11645
11646     <phrase role="comment">// Create an empty list.</phrase>
11647     <phrase role="identifier">name_list</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11648         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11649             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11650                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Empty list.</phrase>
11651             <phrase role="special">})</phrase>
11652         <phrase role="special">;</phrase>
11653     <phrase role="special">}</phrase>
11654
11655     <phrase role="comment">// Destroy list.</phrase>
11656     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">name_list</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11657         <phrase role="comment">// Check invariants.</phrase>
11658         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11659     <phrase role="special">}</phrase>
11660
11661     <phrase role="comment">/* Basic Queries */</phrase>
11662
11663     <phrase role="comment">// Number of names in list.</phrase>
11664     <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11665         <phrase role="comment">// Check invariants.</phrase>
11666         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11667         <phrase role="keyword">return</phrase> <phrase role="identifier">names_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
11668     <phrase role="special">}</phrase>
11669
11670     <phrase role="comment">// Is name in list?</phrase>
11671     <phrase role="keyword">bool</phrase> <phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">name</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11672         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
11673         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11674             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11675                 <phrase role="comment">// If empty, has not.</phrase>
11676                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">result</phrase><phrase role="special">);</phrase>
11677             <phrase role="special">})</phrase>
11678         <phrase role="special">;</phrase>
11679
11680         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">names_</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">()</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">names_</phrase><phrase role="special">.</phrase><phrase role="identifier">cbegin</phrase><phrase role="special">(),</phrase>
11681                 <phrase role="identifier">names_</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">(),</phrase> <phrase role="identifier">name</phrase><phrase role="special">);</phrase>
11682     <phrase role="special">}</phrase>
11683
11684     <phrase role="comment">/* Commands */</phrase>
11685
11686     <phrase role="comment">// Add name to list, if name not already in list.</phrase>
11687     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">name</phrase><phrase role="special">,</phrase>
11688             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11689         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_has_name</phrase> <phrase role="special">=</phrase>
11690                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">));</phrase>
11691         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase>
11692                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11693         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11694             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11695                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">));</phrase> <phrase role="comment">// Not already in list.</phrase>
11696             <phrase role="special">})</phrase>
11697             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11698                 <phrase role="keyword">if</phrase><phrase role="special">(!*</phrase><phrase role="identifier">old_has_name</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// If-guard allows to relax subcontracts.</phrase>
11699                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">));</phrase> <phrase role="comment">// Name in list.</phrase>
11700                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Inc.</phrase>
11701                 <phrase role="special">}</phrase>
11702             <phrase role="special">})</phrase>
11703         <phrase role="special">;</phrase>
11704
11705         <phrase role="identifier">names_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">);</phrase>
11706     <phrase role="special">}</phrase>
11707
11708 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
11709     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">names_</phrase><phrase role="special">;</phrase>
11710 <phrase role="special">};</phrase>
11711
11712 <phrase role="keyword">class</phrase> <phrase role="identifier">relaxed_name_list</phrase>
11713     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">name_list</phrase>
11714     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
11715 <phrase role="special">{</phrase>
11716     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
11717
11718     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// Subcontracting.</phrase>
11719     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
11720
11721     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">put</phrase><phrase role="special">);</phrase>
11722
11723 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
11724     <phrase role="comment">/*  Commands */</phrase>
11725
11726     <phrase role="comment">// Add name to list, or do nothing if name already in list (relaxed).</phrase>
11727     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">name</phrase><phrase role="special">,</phrase>
11728             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
11729         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_has_name</phrase> <phrase role="special">=</phrase>
11730                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">));</phrase>
11731         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase>
11732                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11733         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
11734                 <phrase role="identifier">override_put</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">relaxed_name_list</phrase><phrase role="special">::</phrase><phrase role="identifier">put</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">name</phrase><phrase role="special">)</phrase>
11735             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Relax inherited preconditions.</phrase>
11736                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">));</phrase> <phrase role="comment">// Already in list.</phrase>
11737             <phrase role="special">})</phrase>
11738             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Inherited post. not checked given if-guard.</phrase>
11739                 <phrase role="keyword">if</phrase><phrase role="special">(*</phrase><phrase role="identifier">old_has_name</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11740                     <phrase role="comment">// Count unchanged if name already in list.</phrase>
11741                     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase><phrase role="special">);</phrase>
11742                 <phrase role="special">}</phrase>
11743             <phrase role="special">})</phrase>
11744         <phrase role="special">;</phrase>
11745
11746         <phrase role="keyword">if</phrase><phrase role="special">(!</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">))</phrase> <phrase role="identifier">name_list</phrase><phrase role="special">::</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">name</phrase><phrase role="special">);</phrase> <phrase role="comment">// Else, do nothing.</phrase>
11747     <phrase role="special">}</phrase>
11748 <phrase role="special">};</phrase>
11749
11750 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11751     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">js</phrase> <phrase role="special">=</phrase> <phrase role="string">"John Smith"</phrase><phrase role="special">;</phrase>
11752
11753     <phrase role="identifier">relaxed_name_list</phrase> <phrase role="identifier">rl</phrase><phrase role="special">;</phrase>
11754     <phrase role="identifier">rl</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">);</phrase>
11755     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">rl</phrase><phrase role="special">.</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">));</phrase>
11756     <phrase role="identifier">rl</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">);</phrase> <phrase role="comment">// OK, relaxed contracts allow calling this again (do nothing).</phrase>
11757
11758     <phrase role="identifier">name_list</phrase> <phrase role="identifier">nl</phrase><phrase role="special">;</phrase>
11759     <phrase role="identifier">nl</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">);</phrase>
11760     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">nl</phrase><phrase role="special">.</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">));</phrase>
11761     <phrase role="comment">// nl.put(js); // Error, contracts do not allow calling this again.</phrase>
11762
11763     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
11764 <phrase role="special">}</phrase>
11765 </programlisting>
11766       </para>
11767     </section>
11768     <section id="boost_contract.examples.__mitchell02___dictionary__key_value_map">
11769       <title><link linkend="boost_contract.examples.__mitchell02___dictionary__key_value_map">[Mitchell02]
11770       Dictionary: Key-value map</link></title>
11771       <para>
11772 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
11773 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">utility</phrase><phrase role="special">&gt;</phrase>
11774 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">map</phrase><phrase role="special">&gt;</phrase>
11775 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
11776
11777 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">K</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
11778 <phrase role="keyword">class</phrase> <phrase role="identifier">dictionary</phrase> <phrase role="special">{</phrase>
11779     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
11780
11781     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11782         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Non-negative count.</phrase>
11783     <phrase role="special">}</phrase>
11784
11785 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
11786     <phrase role="comment">/* Creation */</phrase>
11787
11788     <phrase role="comment">// Create empty dictionary.</phrase>
11789     <phrase role="identifier">dictionary</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11790         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11791             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11792                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Empty.</phrase>
11793             <phrase role="special">})</phrase>
11794         <phrase role="special">;</phrase>
11795     <phrase role="special">}</phrase>
11796
11797     <phrase role="comment">// Destroy dictionary.</phrase>
11798     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">dictionary</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11799         <phrase role="comment">// Check invariants.</phrase>
11800         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11801     <phrase role="special">}</phrase>
11802
11803     <phrase role="comment">/* Basic Queries */</phrase>
11804
11805     <phrase role="comment">// Number of key entries.</phrase>
11806     <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11807         <phrase role="comment">// Check invariants.</phrase>
11808         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11809         <phrase role="keyword">return</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
11810     <phrase role="special">}</phrase>
11811
11812     <phrase role="comment">// Has entry for key?</phrase>
11813     <phrase role="keyword">bool</phrase> <phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">K</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">key</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11814         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
11815         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11816             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11817                 <phrase role="comment">// Empty has no key.</phrase>
11818                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">result</phrase><phrase role="special">);</phrase>
11819             <phrase role="special">})</phrase>
11820         <phrase role="special">;</phrase>
11821
11822         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">)</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">());</phrase>
11823     <phrase role="special">}</phrase>
11824
11825     <phrase role="comment">// Value for a given key.</phrase>
11826     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value_for</phrase><phrase role="special">(</phrase><phrase role="identifier">K</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">key</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11827         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11828             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11829                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">));</phrase> <phrase role="comment">// Has key.</phrase>
11830             <phrase role="special">})</phrase>
11831         <phrase role="special">;</phrase>
11832
11833         <phrase role="comment">// Find != end because of precondition (no defensive programming).</phrase>
11834         <phrase role="keyword">return</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">)-&gt;</phrase><phrase role="identifier">second</phrase><phrase role="special">;</phrase>
11835     <phrase role="special">}</phrase>
11836
11837     <phrase role="comment">/* Commands */</phrase>
11838
11839     <phrase role="comment">// Add value of a given key.</phrase>
11840     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">K</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">key</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11841         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11842         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11843             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11844                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">));</phrase> <phrase role="comment">// Has not key already.</phrase>
11845             <phrase role="special">})</phrase>
11846             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11847                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count inc.</phrase>
11848                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">));</phrase> <phrase role="comment">// Has key.</phrase>
11849                 <phrase role="comment">// Value set for key.</phrase>
11850                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">value_for</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
11851             <phrase role="special">})</phrase>
11852         <phrase role="special">;</phrase>
11853
11854         <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_pair</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">));</phrase>
11855     <phrase role="special">}</phrase>
11856
11857     <phrase role="comment">// Remove value for given key.</phrase>
11858     <phrase role="keyword">void</phrase> <phrase role="identifier">remove</phrase><phrase role="special">(</phrase><phrase role="identifier">K</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">key</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
11859         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
11860         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11861             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11862                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">));</phrase> <phrase role="comment">// Has key.</phrase>
11863             <phrase role="special">})</phrase>
11864             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11865                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count dec.</phrase>
11866                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">));</phrase> <phrase role="comment">// Has not key.</phrase>
11867             <phrase role="special">})</phrase>
11868         <phrase role="special">;</phrase>
11869
11870         <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">key</phrase><phrase role="special">);</phrase>
11871     <phrase role="special">}</phrase>
11872
11873 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
11874     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">map</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">K</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">items_</phrase><phrase role="special">;</phrase>
11875 <phrase role="special">};</phrase>
11876
11877 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11878     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">js</phrase> <phrase role="special">=</phrase> <phrase role="string">"John Smith"</phrase><phrase role="special">;</phrase>
11879
11880     <phrase role="identifier">dictionary</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">ages</phrase><phrase role="special">;</phrase>
11881     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">ages</phrase><phrase role="special">.</phrase><phrase role="identifier">has</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">));</phrase>
11882
11883     <phrase role="identifier">ages</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">,</phrase> <phrase role="number">23</phrase><phrase role="special">);</phrase>
11884     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">ages</phrase><phrase role="special">.</phrase><phrase role="identifier">value_for</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">23</phrase><phrase role="special">);</phrase>
11885
11886     <phrase role="identifier">ages</phrase><phrase role="special">.</phrase><phrase role="identifier">remove</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">);</phrase>
11887     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">ages</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
11888
11889     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
11890 <phrase role="special">}</phrase>
11891 </programlisting>
11892       </para>
11893     </section>
11894     <section id="boost_contract.examples.__mitchell02___courier__subcontracting_and_static_class_invariants">
11895       <title><link linkend="boost_contract.examples.__mitchell02___courier__subcontracting_and_static_class_invariants">[Mitchell02]
11896       Courier: Subcontracting and static class invariants</link></title>
11897       <para>
11898 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
11899 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">string</phrase><phrase role="special">&gt;</phrase>
11900 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
11901
11902 <phrase role="keyword">struct</phrase> <phrase role="identifier">package</phrase> <phrase role="special">{</phrase>
11903     <phrase role="keyword">double</phrase> <phrase role="identifier">weight_kg</phrase><phrase role="special">;</phrase>
11904     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">location</phrase><phrase role="special">;</phrase>
11905     <phrase role="keyword">double</phrase> <phrase role="identifier">accepted_hour</phrase><phrase role="special">;</phrase>
11906     <phrase role="keyword">double</phrase> <phrase role="identifier">delivered_hour</phrase><phrase role="special">;</phrase>
11907
11908     <phrase role="keyword">explicit</phrase> <phrase role="identifier">package</phrase><phrase role="special">(</phrase>
11909         <phrase role="keyword">double</phrase> <phrase role="identifier">_weight_kg</phrase><phrase role="special">,</phrase>
11910         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">_location</phrase> <phrase role="special">=</phrase> <phrase role="string">""</phrase><phrase role="special">,</phrase>
11911         <phrase role="keyword">double</phrase> <phrase role="identifier">_accepted_hour</phrase> <phrase role="special">=</phrase> <phrase role="number">0.0</phrase><phrase role="special">,</phrase>
11912         <phrase role="keyword">double</phrase> <phrase role="identifier">_delivered_hour</phrase> <phrase role="special">=</phrase> <phrase role="number">0.0</phrase>
11913     <phrase role="special">)</phrase> <phrase role="special">:</phrase>
11914         <phrase role="identifier">weight_kg</phrase><phrase role="special">(</phrase><phrase role="identifier">_weight_kg</phrase><phrase role="special">),</phrase>
11915         <phrase role="identifier">location</phrase><phrase role="special">(</phrase><phrase role="identifier">_location</phrase><phrase role="special">),</phrase>
11916         <phrase role="identifier">accepted_hour</phrase><phrase role="special">(</phrase><phrase role="identifier">_accepted_hour</phrase><phrase role="special">),</phrase>
11917         <phrase role="identifier">delivered_hour</phrase><phrase role="special">(</phrase><phrase role="identifier">_delivered_hour</phrase><phrase role="special">)</phrase>
11918     <phrase role="special">{}</phrase>
11919 <phrase role="special">};</phrase>
11920
11921 <phrase role="comment">// Courier for package delivery.</phrase>
11922 <phrase role="keyword">class</phrase> <phrase role="identifier">courier</phrase>
11923     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">courier</phrase><phrase role="special">&gt;</phrase>
11924     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
11925 <phrase role="special">{</phrase>
11926     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
11927
11928     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
11929     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
11930
11931     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11932         <phrase role="comment">// Positive min. insurance.</phrase>
11933         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">min_insurance_usd</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0.0</phrase><phrase role="special">);</phrase>
11934     <phrase role="special">}</phrase>
11935
11936     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11937         <phrase role="comment">// Above min. insurance.</phrase>
11938         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">insurance_cover_usd</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">min_insurance_usd</phrase><phrase role="special">);</phrase>
11939     <phrase role="special">}</phrase>
11940
11941 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
11942     <phrase role="keyword">static</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">min_insurance_usd</phrase><phrase role="special">;</phrase>
11943
11944     <phrase role="comment">/* Creation */</phrase>
11945
11946     <phrase role="comment">// Create courier with specified insurance value.</phrase>
11947     <phrase role="keyword">explicit</phrase> <phrase role="identifier">courier</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase> <phrase role="identifier">_insurance_cover_usd</phrase> <phrase role="special">=</phrase> <phrase role="identifier">min_insurance_usd</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
11948         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">courier</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
11949             <phrase role="comment">// Positive insurance.</phrase>
11950             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">_insurance_cover_usd</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0.0</phrase><phrase role="special">);</phrase>
11951         <phrase role="special">}),</phrase>
11952         <phrase role="identifier">insurance_cover_usd_</phrase><phrase role="special">(</phrase><phrase role="identifier">_insurance_cover_usd</phrase><phrase role="special">)</phrase>
11953     <phrase role="special">{</phrase>
11954         <phrase role="comment">// Check invariants.</phrase>
11955         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11956     <phrase role="special">}</phrase>
11957
11958     <phrase role="comment">// Destroy courier.</phrase>
11959     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">courier</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
11960         <phrase role="comment">// Check invariants.</phrase>
11961         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11962     <phrase role="special">}</phrase>
11963
11964     <phrase role="comment">/* Queries */</phrase>
11965
11966     <phrase role="comment">// Return insurance cover.</phrase>
11967     <phrase role="keyword">double</phrase> <phrase role="identifier">insurance_cover_usd</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
11968         <phrase role="comment">// Check invariants.</phrase>
11969         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
11970         <phrase role="keyword">return</phrase> <phrase role="identifier">insurance_cover_usd_</phrase><phrase role="special">;</phrase>
11971     <phrase role="special">}</phrase>
11972
11973     <phrase role="comment">/* Commands */</phrase>
11974
11975     <phrase role="comment">// Deliver package to destination.</phrase>
11976     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">deliver</phrase><phrase role="special">(</phrase>
11977         <phrase role="identifier">package</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">package_delivery</phrase><phrase role="special">,</phrase>
11978         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">destination</phrase><phrase role="special">,</phrase>
11979         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase>
11980     <phrase role="special">)</phrase> <phrase role="special">{</phrase>
11981         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
11982             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11983                 <phrase role="comment">// Within max weight of this delivery.</phrase>
11984                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">weight_kg</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">5.0</phrase><phrase role="special">);</phrase>
11985             <phrase role="special">})</phrase>
11986             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
11987                 <phrase role="comment">// Within max delivery type.</phrase>
11988                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">(</phrase><phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">delivered_hour</phrase> <phrase role="special">-</phrase>
11989                         <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">accepted_hour</phrase><phrase role="special">)</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">3.0</phrase><phrase role="special">);</phrase>
11990                 <phrase role="comment">// Delivered at destination.</phrase>
11991                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">location</phrase> <phrase role="special">==</phrase> <phrase role="identifier">destination</phrase><phrase role="special">);</phrase>
11992             <phrase role="special">})</phrase>
11993         <phrase role="special">;</phrase>
11994
11995         <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">location</phrase> <phrase role="special">=</phrase> <phrase role="identifier">destination</phrase><phrase role="special">;</phrase>
11996         <phrase role="comment">// Delivery takes 2.5 hours.</phrase>
11997         <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">delivered_hour</phrase> <phrase role="special">=</phrase> <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">accepted_hour</phrase> <phrase role="special">+</phrase> <phrase role="number">2.5</phrase><phrase role="special">;</phrase>
11998     <phrase role="special">}</phrase>
11999
12000 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12001     <phrase role="keyword">double</phrase> <phrase role="identifier">insurance_cover_usd_</phrase><phrase role="special">;</phrase>
12002 <phrase role="special">};</phrase>
12003
12004 <phrase role="keyword">double</phrase> <phrase role="identifier">courier</phrase><phrase role="special">::</phrase><phrase role="identifier">min_insurance_usd</phrase> <phrase role="special">=</phrase> <phrase role="number">10.0e+6</phrase><phrase role="special">;</phrase>
12005
12006 <phrase role="comment">// Different courier for package delivery.</phrase>
12007 <phrase role="keyword">class</phrase> <phrase role="identifier">different_courier</phrase>
12008     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase> <phrase role="special">\</phrase>
12009             <phrase role="identifier">different_courier</phrase><phrase role="special">&gt;,</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">courier</phrase>
12010     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
12011 <phrase role="special">{</phrase>
12012     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
12013
12014     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// Subcontracting.</phrase>
12015     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
12016
12017     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12018         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="comment">// Better insurance amount.</phrase>
12019                 <phrase role="identifier">different_insurance_usd</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">courier</phrase><phrase role="special">::</phrase><phrase role="identifier">min_insurance_usd</phrase><phrase role="special">);</phrase>
12020     <phrase role="special">}</phrase>
12021
12022     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12023         <phrase role="comment">// Above different insurance value.</phrase>
12024         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">insurance_cover_usd</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">different_insurance_usd</phrase><phrase role="special">);</phrase>
12025     <phrase role="special">}</phrase>
12026
12027     <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">deliver</phrase><phrase role="special">)</phrase>
12028
12029 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12030     <phrase role="keyword">static</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">different_insurance_usd</phrase><phrase role="special">;</phrase>
12031
12032     <phrase role="comment">/* Creation */</phrase>
12033
12034     <phrase role="comment">// Create courier with specified insurance value.</phrase>
12035     <phrase role="keyword">explicit</phrase> <phrase role="identifier">different_courier</phrase><phrase role="special">(</phrase>
12036             <phrase role="keyword">double</phrase> <phrase role="identifier">insurance_cover_usd</phrase> <phrase role="special">=</phrase> <phrase role="identifier">different_insurance_usd</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
12037         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">different_courier</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
12038             <phrase role="comment">// Positive insurance value.</phrase>
12039             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">insurance_cover_usd</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0.0</phrase><phrase role="special">);</phrase>
12040         <phrase role="special">}),</phrase>
12041         <phrase role="identifier">courier</phrase><phrase role="special">(</phrase><phrase role="identifier">insurance_cover_usd</phrase><phrase role="special">)</phrase>
12042     <phrase role="special">{</phrase>
12043         <phrase role="comment">// Check invariants.</phrase>
12044         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12045     <phrase role="special">}</phrase>
12046
12047     <phrase role="comment">// Destroy courier.</phrase>
12048     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">different_courier</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12049         <phrase role="comment">// Check invariants.</phrase>
12050         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12051     <phrase role="special">}</phrase>
12052
12053     <phrase role="comment">/* Commands */</phrase>
12054
12055     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">deliver</phrase><phrase role="special">(</phrase>
12056         <phrase role="identifier">package</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">package_delivery</phrase><phrase role="special">,</phrase>
12057         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">destination</phrase><phrase role="special">,</phrase>
12058         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase>
12059     <phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
12060         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
12061             <phrase role="identifier">override_deliver</phrase>
12062         <phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">different_courier</phrase><phrase role="special">::</phrase><phrase role="identifier">deliver</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">package_delivery</phrase><phrase role="special">,</phrase> <phrase role="identifier">destination</phrase><phrase role="special">)</phrase>
12063             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12064                 <phrase role="comment">// Package can weight more (weaker precondition).</phrase>
12065                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">weight_kg</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">8.0</phrase><phrase role="special">);</phrase>
12066             <phrase role="special">})</phrase>
12067             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12068                 <phrase role="comment">// Faster delivery (stronger postcondition).</phrase>
12069                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">(</phrase><phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">delivered_hour</phrase> <phrase role="special">-</phrase>
12070                         <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">accepted_hour</phrase><phrase role="special">)</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">2.0</phrase><phrase role="special">);</phrase>
12071                 <phrase role="comment">// Inherited "delivery at destination" postcondition.</phrase>
12072             <phrase role="special">})</phrase>
12073         <phrase role="special">;</phrase>
12074
12075         <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">location</phrase> <phrase role="special">=</phrase> <phrase role="identifier">destination</phrase><phrase role="special">;</phrase>
12076         <phrase role="comment">// Delivery takes 0.5 hours.</phrase>
12077         <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">delivered_hour</phrase> <phrase role="special">=</phrase> <phrase role="identifier">package_delivery</phrase><phrase role="special">.</phrase><phrase role="identifier">accepted_hour</phrase> <phrase role="special">+</phrase> <phrase role="number">0.5</phrase><phrase role="special">;</phrase>
12078     <phrase role="special">}</phrase>
12079 <phrase role="special">};</phrase>
12080
12081 <phrase role="keyword">double</phrase> <phrase role="identifier">different_courier</phrase><phrase role="special">::</phrase><phrase role="identifier">different_insurance_usd</phrase> <phrase role="special">=</phrase> <phrase role="number">20.0e+6</phrase><phrase role="special">;</phrase>
12082
12083 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12084     <phrase role="identifier">package</phrase> <phrase role="identifier">cups</phrase><phrase role="special">(</phrase><phrase role="number">3.6</phrase><phrase role="special">,</phrase> <phrase role="string">"store"</phrase><phrase role="special">);</phrase>
12085     <phrase role="identifier">courier</phrase> <phrase role="identifier">c</phrase><phrase role="special">;</phrase>
12086     <phrase role="identifier">c</phrase><phrase role="special">.</phrase><phrase role="identifier">deliver</phrase><phrase role="special">(</phrase><phrase role="identifier">cups</phrase><phrase role="special">,</phrase> <phrase role="string">"home"</phrase><phrase role="special">);</phrase>
12087     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">cups</phrase><phrase role="special">.</phrase><phrase role="identifier">location</phrase> <phrase role="special">==</phrase> <phrase role="string">"home"</phrase><phrase role="special">);</phrase>
12088
12089     <phrase role="identifier">package</phrase> <phrase role="identifier">desk</phrase><phrase role="special">(</phrase><phrase role="number">7.2</phrase><phrase role="special">,</phrase> <phrase role="string">"store"</phrase><phrase role="special">);</phrase>
12090     <phrase role="identifier">different_courier</phrase> <phrase role="identifier">dc</phrase><phrase role="special">;</phrase>
12091     <phrase role="identifier">dc</phrase><phrase role="special">.</phrase><phrase role="identifier">deliver</phrase><phrase role="special">(</phrase><phrase role="identifier">desk</phrase><phrase role="special">,</phrase> <phrase role="string">"office"</phrase><phrase role="special">);</phrase>
12092     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">desk</phrase><phrase role="special">.</phrase><phrase role="identifier">location</phrase> <phrase role="special">==</phrase> <phrase role="string">"office"</phrase><phrase role="special">);</phrase>
12093
12094     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12095 <phrase role="special">}</phrase>
12096 </programlisting>
12097       </para>
12098     </section>
12099     <section id="boost_contract.examples.__mitchell02___stack__stack_like_container">
12100       <title><link linkend="boost_contract.examples.__mitchell02___stack__stack_like_container">[Mitchell02]
12101       Stack: Stack-like container</link></title>
12102       <para>
12103 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12104 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">optional</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12105 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase>
12106 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
12107
12108 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
12109 <phrase role="keyword">class</phrase> <phrase role="identifier">stack</phrase> <phrase role="special">{</phrase>
12110     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
12111
12112     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12113         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Non-negative count.</phrase>
12114     <phrase role="special">}</phrase>
12115
12116 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12117     <phrase role="comment">/* Creation */</phrase>
12118
12119     <phrase role="comment">// Create empty stack.</phrase>
12120     <phrase role="identifier">stack</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12121         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12122             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12123                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Empty.</phrase>
12124             <phrase role="special">})</phrase>
12125         <phrase role="special">;</phrase>
12126     <phrase role="special">}</phrase>
12127
12128     <phrase role="comment">// Destroy stack.</phrase>
12129     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">stack</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12130         <phrase role="comment">// Check invariants.</phrase>
12131         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12132     <phrase role="special">}</phrase>
12133
12134     <phrase role="comment">/* Basic Queries */</phrase>
12135
12136     <phrase role="comment">// Number of items.</phrase>
12137     <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12138         <phrase role="comment">// Check invariants.</phrase>
12139         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12140         <phrase role="keyword">return</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
12141     <phrase role="special">}</phrase>
12142
12143     <phrase role="comment">// Item at index in [1, count()] (as in Eiffel).</phrase>
12144     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">item_at</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12145         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12146             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12147                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Positive index.</phrase>
12148                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">count</phrase><phrase role="special">());</phrase> <phrase role="comment">// Index within count.</phrase>
12149             <phrase role="special">})</phrase>
12150         <phrase role="special">;</phrase>
12151
12152         <phrase role="keyword">return</phrase> <phrase role="identifier">items_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">];</phrase>
12153     <phrase role="special">}</phrase>
12154
12155     <phrase role="comment">/* Derived Queries */</phrase>
12156
12157     <phrase role="comment">// If no items.</phrase>
12158     <phrase role="keyword">bool</phrase> <phrase role="identifier">is_empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12159         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
12160         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12161             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12162                 <phrase role="comment">// Consistent with count.</phrase>
12163                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
12164             <phrase role="special">})</phrase>
12165         <phrase role="special">;</phrase>
12166
12167         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
12168     <phrase role="special">}</phrase>
12169
12170     <phrase role="comment">// Top item.</phrase>
12171     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12172         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase> <phrase role="comment">// Avoid extra construction of T.</phrase>
12173         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12174             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12175                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Not empty.</phrase>
12176             <phrase role="special">})</phrase>
12177             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12178                 <phrase role="comment">// Item on top.</phrase>
12179                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">item_at</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()));</phrase>
12180             <phrase role="special">})</phrase>
12181         <phrase role="special">;</phrase>
12182
12183         <phrase role="keyword">return</phrase> <phrase role="special">*(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">item_at</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()));</phrase>
12184     <phrase role="special">}</phrase>
12185
12186     <phrase role="comment">/* Commands */</phrase>
12187
12188     <phrase role="comment">// Push item to the top.</phrase>
12189     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">new_item</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12190         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
12191         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12192             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12193                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count inc.</phrase>
12194                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">new_item</phrase><phrase role="special">);</phrase> <phrase role="comment">// Item set.</phrase>
12195             <phrase role="special">})</phrase>
12196         <phrase role="special">;</phrase>
12197
12198         <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">new_item</phrase><phrase role="special">);</phrase>
12199     <phrase role="special">}</phrase>
12200
12201     <phrase role="comment">// Pop top item.</phrase>
12202     <phrase role="keyword">void</phrase> <phrase role="identifier">remove</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12203         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
12204         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12205             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12206                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Not empty.</phrase>
12207             <phrase role="special">})</phrase>
12208             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12209                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count dec.</phrase>
12210             <phrase role="special">})</phrase>
12211         <phrase role="special">;</phrase>
12212
12213         <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">pop_back</phrase><phrase role="special">();</phrase>
12214     <phrase role="special">}</phrase>
12215
12216 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12217     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">items_</phrase><phrase role="special">;</phrase>
12218 <phrase role="special">};</phrase>
12219
12220 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12221     <phrase role="identifier">stack</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">s</phrase><phrase role="special">;</phrase>
12222     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
12223
12224     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="number">123</phrase><phrase role="special">);</phrase>
12225     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">item</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
12226
12227     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">remove</phrase><phrase role="special">();</phrase>
12228     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">());</phrase>
12229
12230     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12231 <phrase role="special">}</phrase>
12232 </programlisting>
12233       </para>
12234     </section>
12235     <section id="boost_contract.examples.__mitchell02___simple_queue__queue_like_container_and_disable_old_value_copies_for_audit_assertions">
12236       <title><link linkend="boost_contract.examples.__mitchell02___simple_queue__queue_like_container_and_disable_old_value_copies_for_audit_assertions">[Mitchell02]
12237       Simple Queue: Queue-like container and disable old value copies for audit assertions</link></title>
12238       <para>
12239 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12240 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">optional</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12241 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase>
12242 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
12243
12244 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
12245 <phrase role="keyword">class</phrase> <phrase role="identifier">simple_queue</phrase>
12246     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase> <phrase role="special">\</phrase>
12247             <phrase role="identifier">simple_queue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
12248     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
12249 <phrase role="special">{</phrase>
12250     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
12251
12252     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
12253     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
12254
12255     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12256         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Non-negative count.</phrase>
12257     <phrase role="special">}</phrase>
12258
12259 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12260     <phrase role="comment">/* Creation */</phrase>
12261
12262     <phrase role="comment">// Create empty queue.</phrase>
12263     <phrase role="keyword">explicit</phrase> <phrase role="identifier">simple_queue</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">a_capacity</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
12264         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">simple_queue</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
12265             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">a_capacity</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Positive capacity.</phrase>
12266         <phrase role="special">})</phrase>
12267     <phrase role="special">{</phrase>
12268         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12269             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12270                 <phrase role="comment">// Capacity set.</phrase>
12271                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">a_capacity</phrase><phrase role="special">);</phrase>
12272                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">());</phrase> <phrase role="comment">// Empty.</phrase>
12273             <phrase role="special">})</phrase>
12274         <phrase role="special">;</phrase>
12275
12276         <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase><phrase role="identifier">a_capacity</phrase><phrase role="special">);</phrase>
12277     <phrase role="special">}</phrase>
12278
12279     <phrase role="comment">// Destroy queue.</phrase>
12280     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">simple_queue</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12281         <phrase role="comment">// Check invariants.</phrase>
12282         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12283     <phrase role="special">}</phrase>
12284
12285     <phrase role="comment">/* Basic Queries */</phrase>
12286
12287     <phrase role="comment">// Items in queue (in their order).</phrase>
12288     <phrase role="comment">// (Somewhat exposes implementation but allows to check more contracts.)</phrase>
12289     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">items</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12290         <phrase role="comment">// Check invariants.</phrase>
12291         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12292         <phrase role="keyword">return</phrase> <phrase role="identifier">items_</phrase><phrase role="special">;</phrase>
12293     <phrase role="special">}</phrase>
12294
12295     <phrase role="comment">// Max number of items queue can hold.</phrase>
12296     <phrase role="keyword">int</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12297         <phrase role="comment">// Check invariants.</phrase>
12298         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12299         <phrase role="keyword">return</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">();</phrase>
12300     <phrase role="special">}</phrase>
12301
12302     <phrase role="comment">/* Derived Queries */</phrase>
12303
12304     <phrase role="comment">// Number of items.</phrase>
12305     <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12306         <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
12307         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12308             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12309                 <phrase role="comment">// Return items count.</phrase>
12310                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">().</phrase><phrase role="identifier">size</phrase><phrase role="special">()));</phrase>
12311             <phrase role="special">})</phrase>
12312         <phrase role="special">;</phrase>
12313
12314         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
12315     <phrase role="special">}</phrase>
12316
12317     <phrase role="comment">// Item at head.</phrase>
12318     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">head</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12319         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
12320         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12321             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12322                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">());</phrase> <phrase role="comment">// Not empty.</phrase>
12323             <phrase role="special">})</phrase>
12324             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12325                 <phrase role="comment">// Return item on top.</phrase>
12326                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="identifier">items</phrase><phrase role="special">().</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">));</phrase>
12327             <phrase role="special">})</phrase>
12328         <phrase role="special">;</phrase>
12329
12330         <phrase role="keyword">return</phrase> <phrase role="special">*(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">));</phrase>
12331     <phrase role="special">}</phrase>
12332
12333     <phrase role="comment">// If queue contains no item.</phrase>
12334     <phrase role="keyword">bool</phrase> <phrase role="identifier">is_empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12335         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
12336         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12337             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12338                 <phrase role="comment">// Consistent with count.</phrase>
12339                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
12340             <phrase role="special">})</phrase>
12341         <phrase role="special">;</phrase>
12342
12343         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
12344     <phrase role="special">}</phrase>
12345
12346     <phrase role="comment">// If queue has no room for another item.</phrase>
12347     <phrase role="keyword">bool</phrase> <phrase role="identifier">is_full</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12348         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
12349         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12350             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12351                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="comment">// Consistent with size and capacity.</phrase>
12352                         <phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">().</phrase><phrase role="identifier">size</phrase><phrase role="special">())));</phrase>
12353             <phrase role="special">})</phrase>
12354         <phrase role="special">;</phrase>
12355
12356         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
12357     <phrase role="special">}</phrase>
12358
12359     <phrase role="comment">/* Commands */</phrase>
12360
12361     <phrase role="comment">// Remove head itme and shift all other items.</phrase>
12362     <phrase role="keyword">void</phrase> <phrase role="identifier">remove</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12363         <phrase role="comment">// Expensive all_equal postcond. and old_items copy might be skipped.</phrase>
12364         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">old_items</phrase><phrase role="special">;</phrase>
12365             <phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDIITS</phrase>
12366                 <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">())</phrase>
12367             <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// Else, leave old pointer null...</phrase>
12368         <phrase role="special">;</phrase>
12369         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
12370         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12371             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12372                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">());</phrase> <phrase role="comment">// Not empty.</phrase>
12373             <phrase role="special">})</phrase>
12374             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12375                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count dec.</phrase>
12376                 <phrase role="comment">// ...following skipped #ifndef AUDITS.</phrase>
12377                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_items</phrase><phrase role="special">)</phrase> <phrase role="identifier">all_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">(),</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_items</phrase><phrase role="special">,</phrase> <phrase role="comment">/* shifted = */</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
12378             <phrase role="special">})</phrase>
12379         <phrase role="special">;</phrase>
12380
12381         <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">erase</phrase><phrase role="special">(</phrase><phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">());</phrase>
12382     <phrase role="special">}</phrase>
12383
12384     <phrase role="comment">// Add item to tail.</phrase>
12385     <phrase role="keyword">void</phrase> <phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">item</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12386         <phrase role="comment">// Expensive all_equal postcond. and old_items copy might be skipped.</phrase>
12387         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">old_items</phrase><phrase role="special">;</phrase>
12388             <phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDITS</phrase>
12389                 <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">())</phrase>
12390             <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// Else, leave old pointer null...</phrase>
12391         <phrase role="special">;</phrase>
12392         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
12393         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12394             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12395                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase> <phrase role="comment">// Room for add.</phrase>
12396             <phrase role="special">})</phrase>
12397             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12398                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count inc.</phrase>
12399                 <phrase role="comment">// Second to last item.</phrase>
12400                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">().</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="identifier">item</phrase><phrase role="special">);</phrase>
12401                 <phrase role="comment">// ...following skipped #ifndef AUDITS.</phrase>
12402                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_items</phrase><phrase role="special">)</phrase> <phrase role="identifier">all_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">(),</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_items</phrase><phrase role="special">);</phrase>
12403             <phrase role="special">})</phrase>
12404         <phrase role="special">;</phrase>
12405
12406         <phrase role="identifier">items_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">item</phrase><phrase role="special">);</phrase>
12407     <phrase role="special">}</phrase>
12408
12409 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12410     <phrase role="comment">// Contract helper.</phrase>
12411     <phrase role="keyword">static</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">all_equal</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">left</phrase><phrase role="special">,</phrase>
12412             <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">right</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">offset</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12413         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
12414             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12415                 <phrase role="comment">// Correct offset.</phrase>
12416                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">offset</phrase><phrase role="special">);</phrase>
12417             <phrase role="special">})</phrase>
12418         <phrase role="special">;</phrase>
12419
12420         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">offset</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12421             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">left</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">i</phrase> <phrase role="special">-</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">right</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">i</phrase><phrase role="special">))</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
12422         <phrase role="special">}</phrase>
12423         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
12424     <phrase role="special">}</phrase>
12425
12426     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">items_</phrase><phrase role="special">;</phrase>
12427 <phrase role="special">};</phrase>
12428
12429 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12430     <phrase role="identifier">simple_queue</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">q</phrase><phrase role="special">(</phrase><phrase role="number">10</phrase><phrase role="special">);</phrase>
12431     <phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="number">123</phrase><phrase role="special">);</phrase>
12432     <phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">put</phrase><phrase role="special">(</phrase><phrase role="number">456</phrase><phrase role="special">);</phrase>
12433
12434     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">10</phrase><phrase role="special">);</phrase>
12435     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">head</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
12436
12437     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">());</phrase>
12438     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">is_full</phrase><phrase role="special">());</phrase>
12439
12440     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">items</phrase> <phrase role="special">=</phrase> <phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">items</phrase><phrase role="special">();</phrase>
12441     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
12442     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">items</phrase><phrase role="special">.</phrase><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">456</phrase><phrase role="special">);</phrase>
12443
12444     <phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">remove</phrase><phrase role="special">();</phrase>
12445     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">q</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
12446
12447     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12448 <phrase role="special">}</phrase>
12449 </programlisting>
12450       </para>
12451     </section>
12452     <section id="boost_contract.examples.__mitchell02___customer_manager__contracts_instead_of_defensive_programming">
12453       <title><link linkend="boost_contract.examples.__mitchell02___customer_manager__contracts_instead_of_defensive_programming">[Mitchell02]
12454       Customer Manager: Contracts instead of defensive programming</link></title>
12455       <para>
12456 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12457 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">string</phrase><phrase role="special">&gt;</phrase>
12458 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">map</phrase><phrase role="special">&gt;</phrase>
12459 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">utility</phrase><phrase role="special">&gt;</phrase>
12460 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
12461
12462 <phrase role="comment">// Basic customer information.</phrase>
12463 <phrase role="keyword">struct</phrase> <phrase role="identifier">customer_info</phrase> <phrase role="special">{</phrase>
12464     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">customer_manager</phrase><phrase role="special">;</phrase>
12465
12466     <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">identifier</phrase><phrase role="special">;</phrase>
12467
12468     <phrase role="identifier">identifier</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase>
12469
12470     <phrase role="keyword">explicit</phrase> <phrase role="identifier">customer_info</phrase><phrase role="special">(</phrase><phrase role="identifier">identifier</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">_id</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
12471             <phrase role="identifier">id</phrase><phrase role="special">(</phrase><phrase role="identifier">_id</phrase><phrase role="special">),</phrase> <phrase role="identifier">name_</phrase><phrase role="special">(),</phrase> <phrase role="identifier">address_</phrase><phrase role="special">(),</phrase> <phrase role="identifier">birthday_</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase>
12472
12473 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12474     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">name_</phrase><phrase role="special">;</phrase>
12475     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">address_</phrase><phrase role="special">;</phrase>
12476     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">birthday_</phrase><phrase role="special">;</phrase>
12477 <phrase role="special">};</phrase>
12478
12479 <phrase role="comment">// Manage customers.</phrase>
12480 <phrase role="keyword">class</phrase> <phrase role="identifier">customer_manager</phrase> <phrase role="special">{</phrase>
12481     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
12482
12483     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12484         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="comment">// Non-negative count.</phrase>
12485     <phrase role="special">}</phrase>
12486
12487 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12488     <phrase role="comment">/* Creation */</phrase>
12489
12490     <phrase role="identifier">customer_manager</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12491         <phrase role="comment">// Check invariants.</phrase>
12492         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12493     <phrase role="special">}</phrase>
12494
12495     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">customer_manager</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12496         <phrase role="comment">// Check invariants.</phrase>
12497         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12498     <phrase role="special">}</phrase>
12499
12500     <phrase role="comment">/* Basic Queries */</phrase>
12501
12502     <phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12503         <phrase role="comment">// Check invariants.</phrase>
12504         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12505         <phrase role="keyword">return</phrase> <phrase role="identifier">customers_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
12506     <phrase role="special">}</phrase>
12507
12508     <phrase role="keyword">bool</phrase> <phrase role="identifier">id_active</phrase><phrase role="special">(</phrase><phrase role="identifier">customer_info</phrase><phrase role="special">::</phrase><phrase role="identifier">identifier</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12509         <phrase role="comment">// Check invariants.</phrase>
12510         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12511         <phrase role="keyword">return</phrase> <phrase role="identifier">customers_</phrase><phrase role="special">.</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">customers_</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">();</phrase>
12512     <phrase role="special">}</phrase>
12513
12514     <phrase role="comment">/* Derived Queries */</phrase>
12515
12516     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">name_for</phrase><phrase role="special">(</phrase><phrase role="identifier">customer_info</phrase><phrase role="special">::</phrase><phrase role="identifier">identifier</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12517         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12518             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12519                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">id_active</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase> <phrase role="comment">// Active.</phrase>
12520             <phrase role="special">})</phrase>
12521         <phrase role="special">;</phrase>
12522
12523         <phrase role="comment">// Find != end because of preconditions (no defensive programming).</phrase>
12524         <phrase role="keyword">return</phrase> <phrase role="identifier">customers_</phrase><phrase role="special">.</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">)-&gt;</phrase><phrase role="identifier">second</phrase><phrase role="special">.</phrase><phrase role="identifier">name_</phrase><phrase role="special">;</phrase>
12525     <phrase role="special">}</phrase>
12526
12527     <phrase role="comment">/* Commands */</phrase>
12528
12529     <phrase role="keyword">void</phrase> <phrase role="identifier">add</phrase><phrase role="special">(</phrase><phrase role="identifier">customer_info</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">info</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12530         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">());</phrase>
12531         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12532             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12533                 <phrase role="comment">// Not already active.</phrase>
12534                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">id_active</phrase><phrase role="special">(</phrase><phrase role="identifier">info</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase>
12535             <phrase role="special">})</phrase>
12536             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12537                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Count inc.</phrase>
12538                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">id_active</phrase><phrase role="special">(</phrase><phrase role="identifier">info</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase> <phrase role="comment">// Activated.</phrase>
12539             <phrase role="special">})</phrase>
12540         <phrase role="special">;</phrase>
12541
12542         <phrase role="identifier">customers_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_pair</phrase><phrase role="special">(</phrase><phrase role="identifier">info</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">,</phrase> <phrase role="identifier">customer</phrase><phrase role="special">(</phrase><phrase role="identifier">info</phrase><phrase role="special">)));</phrase>
12543     <phrase role="special">}</phrase>
12544
12545     <phrase role="keyword">void</phrase> <phrase role="identifier">set_name</phrase><phrase role="special">(</phrase><phrase role="identifier">customer_info</phrase><phrase role="special">::</phrase><phrase role="identifier">identifier</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">id</phrase><phrase role="special">,</phrase>
12546             <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">name</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12547         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12548             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12549                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">id_active</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase> <phrase role="comment">// Already active.</phrase>
12550             <phrase role="special">})</phrase>
12551             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12552                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">name_for</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="identifier">name</phrase><phrase role="special">);</phrase> <phrase role="comment">// Name set.</phrase>
12553             <phrase role="special">})</phrase>
12554         <phrase role="special">;</phrase>
12555
12556         <phrase role="comment">// Find != end because of precondition (no defensive programming).</phrase>
12557         <phrase role="identifier">customers_</phrase><phrase role="special">.</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">id</phrase><phrase role="special">)-&gt;</phrase><phrase role="identifier">second</phrase><phrase role="special">.</phrase><phrase role="identifier">name_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">name</phrase><phrase role="special">;</phrase>
12558     <phrase role="special">}</phrase>
12559
12560 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12561     <phrase role="keyword">class</phrase> <phrase role="identifier">agent</phrase> <phrase role="special">{};</phrase> <phrase role="comment">// Customer agent.</phrase>
12562
12563     <phrase role="keyword">struct</phrase> <phrase role="identifier">customer</phrase> <phrase role="special">:</phrase> <phrase role="identifier">customer_info</phrase> <phrase role="special">{</phrase>
12564         <phrase role="identifier">agent</phrase> <phrase role="identifier">managing_agent</phrase><phrase role="special">;</phrase>
12565         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">last_contact</phrase><phrase role="special">;</phrase>
12566
12567         <phrase role="keyword">explicit</phrase> <phrase role="identifier">customer</phrase><phrase role="special">(</phrase><phrase role="identifier">customer_info</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">info</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">customer_info</phrase><phrase role="special">(</phrase><phrase role="identifier">info</phrase><phrase role="special">),</phrase>
12568                 <phrase role="identifier">managing_agent</phrase><phrase role="special">(),</phrase> <phrase role="identifier">last_contact</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase>
12569     <phrase role="special">};</phrase>
12570
12571     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">map</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">customer_info</phrase><phrase role="special">::</phrase><phrase role="identifier">identifier</phrase><phrase role="special">,</phrase> <phrase role="identifier">customer</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">customers_</phrase><phrase role="special">;</phrase>
12572 <phrase role="special">};</phrase>
12573
12574 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12575     <phrase role="identifier">customer_manager</phrase> <phrase role="identifier">m</phrase><phrase role="special">;</phrase>
12576     <phrase role="identifier">customer_info</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">js</phrase><phrase role="special">(</phrase><phrase role="string">"john_smith_123"</phrase><phrase role="special">);</phrase>
12577     <phrase role="identifier">m</phrase><phrase role="special">.</phrase><phrase role="identifier">add</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">);</phrase>
12578     <phrase role="identifier">m</phrase><phrase role="special">.</phrase><phrase role="identifier">set_name</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">,</phrase> <phrase role="string">"John Smith"</phrase><phrase role="special">);</phrase>
12579     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">m</phrase><phrase role="special">.</phrase><phrase role="identifier">name_for</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="string">"John Smith"</phrase><phrase role="special">);</phrase>
12580     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">m</phrase><phrase role="special">.</phrase><phrase role="identifier">count</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
12581     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">m</phrase><phrase role="special">.</phrase><phrase role="identifier">id_active</phrase><phrase role="special">(</phrase><phrase role="identifier">js</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">));</phrase>
12582     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12583 <phrase role="special">}</phrase>
12584 </programlisting>
12585       </para>
12586     </section>
12587     <section id="boost_contract.examples.__mitchell02___observer__pure_virtual_functions">
12588       <title><link linkend="boost_contract.examples.__mitchell02___observer__pure_virtual_functions">[Mitchell02]
12589       Observer: Pure virtual functions</link></title>
12590       <para>
12591 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">OBSERVER_HPP_</phrase>
12592 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">OBSERVER_HPP_</phrase>
12593
12594 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12595 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
12596
12597 <phrase role="comment">// Observer.</phrase>
12598 <phrase role="keyword">class</phrase> <phrase role="identifier">observer</phrase> <phrase role="special">{</phrase>
12599     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">subject</phrase><phrase role="special">;</phrase>
12600 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12601     <phrase role="comment">// No inv and no bases so contracts optional if no pre, post, and override.</phrase>
12602
12603     <phrase role="comment">/* Creation */</phrase>
12604
12605     <phrase role="identifier">observer</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12606         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12607         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12608     <phrase role="special">}</phrase>
12609
12610     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">observer</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12611         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12612         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12613     <phrase role="special">}</phrase>
12614
12615     <phrase role="comment">/* Commands */</phrase>
12616
12617     <phrase role="comment">// If up-to-date with related subject.</phrase>
12618     <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
12619             <phrase role="keyword">const</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12620
12621     <phrase role="comment">// Update this observer.</phrase>
12622     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">update</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12623 <phrase role="special">};</phrase>
12624
12625 <phrase role="keyword">bool</phrase> <phrase role="identifier">observer</phrase><phrase role="special">::</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12626     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12627     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
12628     <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
12629 <phrase role="special">}</phrase>
12630
12631 <phrase role="keyword">void</phrase> <phrase role="identifier">observer</phrase><phrase role="special">::</phrase><phrase role="identifier">update</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12632     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12633         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12634             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">());</phrase> <phrase role="comment">// Up-to-date.</phrase>
12635         <phrase role="special">})</phrase>
12636     <phrase role="special">;</phrase>
12637     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
12638 <phrase role="special">}</phrase>
12639
12640 <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// #include guard</phrase>
12641 </programlisting>
12642       </para>
12643       <para>
12644 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">SUBJECT_HPP_</phrase>
12645 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">SUBJECT_HPP_</phrase>
12646
12647 <phrase role="preprocessor">#include</phrase> <phrase role="string">"observer.hpp"</phrase>
12648 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12649 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;</phrase>
12650 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">&gt;</phrase>
12651 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
12652
12653 <phrase role="comment">// Subject for observer design pattern.</phrase>
12654 <phrase role="keyword">class</phrase> <phrase role="identifier">subject</phrase> <phrase role="special">{</phrase>
12655     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
12656
12657     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12658         <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">all_observers_valid</phrase><phrase role="special">(</phrase><phrase role="identifier">observers</phrase><phrase role="special">()));</phrase> <phrase role="comment">// Valid.</phrase>
12659     <phrase role="special">}</phrase>
12660
12661 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12662     <phrase role="comment">/* Creation */</phrase>
12663
12664     <phrase role="comment">// Construct subject with no observer.</phrase>
12665     <phrase role="identifier">subject</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12666         <phrase role="comment">// Check invariant.</phrase>
12667         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12668     <phrase role="special">}</phrase>
12669
12670     <phrase role="comment">// Destroy subject.</phrase>
12671     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">subject</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12672         <phrase role="comment">// Check invariant.</phrase>
12673         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12674     <phrase role="special">}</phrase>
12675
12676     <phrase role="comment">/* Queries */</phrase>
12677
12678     <phrase role="comment">// If given object is attached.</phrase>
12679     <phrase role="keyword">bool</phrase> <phrase role="identifier">attached</phrase><phrase role="special">(</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase> <phrase role="identifier">ob</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12680         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12681             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12682                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">ob</phrase><phrase role="special">);</phrase> <phrase role="comment">// Not null.</phrase>
12683             <phrase role="special">})</phrase>
12684         <phrase role="special">;</phrase>
12685
12686         <phrase role="keyword">return</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">find</phrase><phrase role="special">(</phrase><phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">cbegin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">(),</phrase> <phrase role="identifier">ob</phrase><phrase role="special">)</phrase> <phrase role="special">!=</phrase>
12687                 <phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">();</phrase>
12688     <phrase role="special">}</phrase>
12689
12690     <phrase role="comment">/* Commands */</phrase>
12691
12692     <phrase role="comment">// Attach given object as an observer.</phrase>
12693     <phrase role="keyword">void</phrase> <phrase role="identifier">attach</phrase><phrase role="special">(</phrase><phrase role="identifier">observer</phrase><phrase role="special">*</phrase> <phrase role="identifier">ob</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12694         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">old_observers</phrase><phrase role="special">;</phrase>
12695         <phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDITS</phrase>
12696             <phrase role="identifier">old_observers</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">observers</phrase><phrase role="special">());</phrase>
12697         <phrase role="preprocessor">#endif</phrase>
12698         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12699             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12700                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">ob</phrase><phrase role="special">);</phrase> <phrase role="comment">// Not null.</phrase>
12701                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">attached</phrase><phrase role="special">(</phrase><phrase role="identifier">ob</phrase><phrase role="special">));</phrase> <phrase role="comment">// Not already attached.</phrase>
12702             <phrase role="special">})</phrase>
12703             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12704                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">attached</phrase><phrase role="special">(</phrase><phrase role="identifier">ob</phrase><phrase role="special">));</phrase> <phrase role="comment">// Attached.</phrase>
12705                 <phrase role="comment">// Others not changed (frame rule).</phrase>
12706                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">other_observers_unchanged</phrase><phrase role="special">(</phrase>
12707                         <phrase role="special">*</phrase><phrase role="identifier">old_observers</phrase><phrase role="special">,</phrase> <phrase role="identifier">observers</phrase><phrase role="special">(),</phrase> <phrase role="identifier">ob</phrase><phrase role="special">));</phrase>
12708             <phrase role="special">})</phrase>
12709         <phrase role="special">;</phrase>
12710
12711         <phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase><phrase role="identifier">ob</phrase><phrase role="special">);</phrase>
12712     <phrase role="special">}</phrase>
12713
12714 <phrase role="keyword">protected</phrase><phrase role="special">:</phrase>
12715     <phrase role="comment">// Contracts could have been omitted for protected/private with no pre/post.</phrase>
12716
12717     <phrase role="comment">/* Queries */</phrase>
12718
12719     <phrase role="comment">// All observers attached to this subject.</phrase>
12720     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="identifier">observers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12721         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="identifier">obs</phrase><phrase role="special">;</phrase>
12722         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase><phrase role="special">*&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">cbegin</phrase><phrase role="special">();</phrase>
12723                 <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">();</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12724             <phrase role="identifier">obs</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(*</phrase><phrase role="identifier">i</phrase><phrase role="special">);</phrase>
12725         <phrase role="special">}</phrase>
12726         <phrase role="keyword">return</phrase> <phrase role="identifier">obs</phrase><phrase role="special">;</phrase>
12727     <phrase role="special">}</phrase>
12728
12729     <phrase role="comment">/* Commands */</phrase>
12730
12731     <phrase role="comment">// Update all attached observers.</phrase>
12732     <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12733         <phrase role="comment">// Protected members use `function` (no inv and no subcontracting).</phrase>
12734         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
12735             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12736                 <phrase role="comment">// All updated.</phrase>
12737                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">all_observers_updated</phrase><phrase role="special">(</phrase><phrase role="identifier">observers</phrase><phrase role="special">()));</phrase>
12738             <phrase role="special">})</phrase>
12739         <phrase role="special">;</phrase>
12740
12741         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase><phrase role="special">*&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
12742                 <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">observers_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12743             <phrase role="comment">// Class invariants ensure no null pointers in observers but class</phrase>
12744             <phrase role="comment">// invariants not checked for non-public functions so assert here.</phrase>
12745             <phrase role="identifier">assert</phrase><phrase role="special">(*</phrase><phrase role="identifier">i</phrase><phrase role="special">);</phrase> <phrase role="comment">// Pointer not null (defensive programming).</phrase>
12746             <phrase role="special">(*</phrase><phrase role="identifier">i</phrase><phrase role="special">)-&gt;</phrase><phrase role="identifier">update</phrase><phrase role="special">();</phrase>
12747         <phrase role="special">}</phrase>
12748     <phrase role="special">}</phrase>
12749
12750 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12751     <phrase role="comment">/* Contract Helpers */</phrase>
12752
12753     <phrase role="keyword">static</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">all_observers_valid</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">obs</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12754         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">obs</phrase><phrase role="special">.</phrase><phrase role="identifier">cbegin</phrase><phrase role="special">();</phrase>
12755                 <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">obs</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">();</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12756             <phrase role="keyword">if</phrase><phrase role="special">(!*</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
12757         <phrase role="special">}</phrase>
12758         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
12759     <phrase role="special">}</phrase>
12760
12761     <phrase role="keyword">static</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">other_observers_unchanged</phrase><phrase role="special">(</phrase>
12762         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">old_obs</phrase><phrase role="special">,</phrase>
12763         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">new_obs</phrase><phrase role="special">,</phrase>
12764         <phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase> <phrase role="identifier">ob</phrase>
12765     <phrase role="special">)</phrase> <phrase role="special">{</phrase>
12766         <phrase role="comment">// Private members use `function` (no inv and no subcontracting).</phrase>
12767         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
12768             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12769                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">ob</phrase><phrase role="special">);</phrase> <phrase role="comment">// Not null.</phrase>
12770             <phrase role="special">})</phrase>
12771         <phrase role="special">;</phrase>
12772
12773         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="identifier">remaining</phrase> <phrase role="special">=</phrase> <phrase role="identifier">new_obs</phrase><phrase role="special">;</phrase>
12774         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">remove</phrase><phrase role="special">(</phrase><phrase role="identifier">remaining</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">remaining</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="identifier">ob</phrase><phrase role="special">);</phrase>
12775
12776         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">remaining_it</phrase> <phrase role="special">=</phrase>
12777                 <phrase role="identifier">remaining</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
12778         <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">old_it</phrase> <phrase role="special">=</phrase> <phrase role="identifier">old_obs</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase>
12779         <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">remaining</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">()</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">remaining_it</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">old_obs</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">()</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">old_it</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12780             <phrase role="keyword">if</phrase><phrase role="special">(*</phrase><phrase role="identifier">remaining_it</phrase> <phrase role="special">!=</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_it</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
12781             <phrase role="special">++</phrase><phrase role="identifier">remaining_it</phrase><phrase role="special">;</phrase>
12782             <phrase role="special">++</phrase><phrase role="identifier">old_it</phrase><phrase role="special">;</phrase>
12783         <phrase role="special">}</phrase>
12784         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
12785     <phrase role="special">}</phrase>
12786
12787     <phrase role="keyword">static</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">all_observers_updated</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">obs</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12788         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&gt;::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="identifier">obs</phrase><phrase role="special">.</phrase><phrase role="identifier">cbegin</phrase><phrase role="special">();</phrase>
12789                 <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">obs</phrase><phrase role="special">.</phrase><phrase role="identifier">cend</phrase><phrase role="special">();</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12790             <phrase role="keyword">if</phrase><phrase role="special">(!*</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
12791             <phrase role="keyword">if</phrase><phrase role="special">(!(*</phrase><phrase role="identifier">i</phrase><phrase role="special">)-&gt;</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">())</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
12792         <phrase role="special">}</phrase>
12793         <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
12794     <phrase role="special">}</phrase>
12795
12796     <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">observer</phrase><phrase role="special">*&gt;</phrase> <phrase role="identifier">observers_</phrase><phrase role="special">;</phrase>
12797 <phrase role="special">};</phrase>
12798
12799 <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// #include guard</phrase>
12800 </programlisting>
12801       </para>
12802       <para>
12803 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="string">"observer/observer.hpp"</phrase>
12804 <phrase role="preprocessor">#include</phrase> <phrase role="string">"observer/subject.hpp"</phrase>
12805 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12806 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
12807
12808 <phrase role="keyword">int</phrase> <phrase role="identifier">test_state</phrase><phrase role="special">;</phrase> <phrase role="comment">// For testing only.</phrase>
12809
12810 <phrase role="comment">// Implement an actual subject.</phrase>
12811 <phrase role="keyword">class</phrase> <phrase role="identifier">concrete_subject</phrase>
12812     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">subject</phrase>
12813     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
12814 <phrase role="special">{</phrase>
12815     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
12816
12817     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// Subcontracting.</phrase>
12818     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
12819
12820 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12821     <phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">state</phrase><phrase role="special">;</phrase> <phrase role="comment">// Some state being observed.</phrase>
12822
12823     <phrase role="identifier">concrete_subject</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">state_</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12824         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12825         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12826     <phrase role="special">}</phrase>
12827
12828     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">concrete_subject</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12829         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12830         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12831     <phrase role="special">}</phrase>
12832
12833     <phrase role="keyword">void</phrase> <phrase role="identifier">set_state</phrase><phrase role="special">(</phrase><phrase role="identifier">state</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">new_state</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12834         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12835         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12836
12837         <phrase role="identifier">state_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">new_state</phrase><phrase role="special">;</phrase>
12838         <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">state_</phrase> <phrase role="special">==</phrase> <phrase role="identifier">test_state</phrase><phrase role="special">);</phrase>
12839         <phrase role="identifier">notify</phrase><phrase role="special">();</phrase> <phrase role="comment">// Notify all observers.</phrase>
12840     <phrase role="special">}</phrase>
12841
12842     <phrase role="identifier">state</phrase> <phrase role="identifier">get_state</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12843         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12844         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12845         <phrase role="keyword">return</phrase> <phrase role="identifier">state_</phrase><phrase role="special">;</phrase>
12846     <phrase role="special">}</phrase>
12847
12848 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12849     <phrase role="identifier">state</phrase> <phrase role="identifier">state_</phrase><phrase role="special">;</phrase>
12850 <phrase role="special">};</phrase>
12851
12852 <phrase role="comment">// Implement an actual observer.</phrase>
12853 <phrase role="keyword">class</phrase> <phrase role="identifier">concrete_observer</phrase>
12854     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">observer</phrase>
12855     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
12856 <phrase role="special">{</phrase>
12857     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
12858
12859     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// Subcontracting.</phrase>
12860     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
12861
12862     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">,</phrase> <phrase role="identifier">update</phrase><phrase role="special">)</phrase>
12863
12864 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12865     <phrase role="comment">// Create concrete observer.</phrase>
12866     <phrase role="keyword">explicit</phrase> <phrase role="identifier">concrete_observer</phrase><phrase role="special">(</phrase><phrase role="identifier">concrete_subject</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">subj</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
12867             <phrase role="identifier">subject_</phrase><phrase role="special">(</phrase><phrase role="identifier">subj</phrase><phrase role="special">),</phrase> <phrase role="identifier">observed_state_</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12868         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12869         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12870     <phrase role="special">}</phrase>
12871
12872     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">concrete_observer</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12873         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12874         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12875     <phrase role="special">}</phrase>
12876
12877     <phrase role="comment">// Implement base virtual functions.</phrase>
12878
12879     <phrase role="keyword">bool</phrase> <phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
12880             <phrase role="keyword">const</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
12881         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
12882         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
12883             <phrase role="identifier">override_up_to_date_with_subject</phrase>
12884         <phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">concrete_observer</phrase><phrase role="special">::</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12885
12886         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> <phrase role="comment">// For simplicity, assume always up-to-date.</phrase>
12887     <phrase role="special">}</phrase>
12888
12889     <phrase role="keyword">void</phrase> <phrase role="identifier">update</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
12890         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
12891                 <phrase role="identifier">override_update</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">concrete_observer</phrase><phrase role="special">::</phrase><phrase role="identifier">update</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12892
12893         <phrase role="identifier">observed_state_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">subject_</phrase><phrase role="special">.</phrase><phrase role="identifier">get_state</phrase><phrase role="special">();</phrase>
12894         <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">observed_state_</phrase> <phrase role="special">==</phrase> <phrase role="identifier">test_state</phrase><phrase role="special">);</phrase>
12895     <phrase role="special">}</phrase>
12896
12897 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12898     <phrase role="identifier">concrete_subject</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">subject_</phrase><phrase role="special">;</phrase>
12899     <phrase role="identifier">concrete_subject</phrase><phrase role="special">::</phrase><phrase role="identifier">state</phrase> <phrase role="identifier">observed_state_</phrase><phrase role="special">;</phrase>
12900 <phrase role="special">};</phrase>
12901
12902 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12903     <phrase role="identifier">concrete_subject</phrase> <phrase role="identifier">subj</phrase><phrase role="special">;</phrase>
12904     <phrase role="identifier">concrete_observer</phrase> <phrase role="identifier">ob</phrase><phrase role="special">(</phrase><phrase role="identifier">subj</phrase><phrase role="special">);</phrase>
12905     <phrase role="identifier">subj</phrase><phrase role="special">.</phrase><phrase role="identifier">attach</phrase><phrase role="special">(&amp;</phrase><phrase role="identifier">ob</phrase><phrase role="special">);</phrase>
12906
12907     <phrase role="identifier">subj</phrase><phrase role="special">.</phrase><phrase role="identifier">set_state</phrase><phrase role="special">(</phrase><phrase role="identifier">test_state</phrase> <phrase role="special">=</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
12908     <phrase role="identifier">subj</phrase><phrase role="special">.</phrase><phrase role="identifier">set_state</phrase><phrase role="special">(</phrase><phrase role="identifier">test_state</phrase> <phrase role="special">=</phrase> <phrase role="number">456</phrase><phrase role="special">);</phrase>
12909
12910     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12911 <phrase role="special">}</phrase>
12912 </programlisting>
12913       </para>
12914     </section>
12915     <section id="boost_contract.examples.__mitchell02___counter__subcontracting">
12916       <title><anchor id="Mitchell02_counter_anchor"/><link linkend="boost_contract.examples.__mitchell02___counter__subcontracting">[Mitchell02]
12917       Counter: Subcontracting</link></title>
12918       <para>
12919 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">PUSH_BUTTON_HPP_</phrase>
12920 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">PUSH_BUTTON_HPP_</phrase>
12921
12922 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
12923 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
12924
12925 <phrase role="keyword">class</phrase> <phrase role="identifier">push_button</phrase> <phrase role="special">{</phrase>
12926 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
12927     <phrase role="comment">// No inv and no bases so contracts optional if no pre, post, and override.</phrase>
12928
12929     <phrase role="comment">/* Creation */</phrase>
12930
12931     <phrase role="comment">// Create an enabled button.</phrase>
12932     <phrase role="identifier">push_button</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">enabled_</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12933         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12934             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12935                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">enabled</phrase><phrase role="special">());</phrase> <phrase role="comment">// Enabled.</phrase>
12936             <phrase role="special">})</phrase>
12937         <phrase role="special">;</phrase>
12938     <phrase role="special">}</phrase>
12939
12940     <phrase role="comment">// Destroy button.</phrase>
12941     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">push_button</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12942         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12943         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12944     <phrase role="special">}</phrase>
12945
12946     <phrase role="comment">/* Queries */</phrase>
12947
12948     <phrase role="comment">// If button is enabled.</phrase>
12949     <phrase role="keyword">bool</phrase> <phrase role="identifier">enabled</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
12950         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
12951         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
12952         <phrase role="keyword">return</phrase> <phrase role="identifier">enabled_</phrase><phrase role="special">;</phrase>
12953     <phrase role="special">}</phrase>
12954
12955     <phrase role="comment">/* Commands */</phrase>
12956
12957     <phrase role="comment">// Enable button.</phrase>
12958     <phrase role="keyword">void</phrase> <phrase role="identifier">enable</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12959         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12960             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12961                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">enabled</phrase><phrase role="special">());</phrase> <phrase role="comment">// Enabled.</phrase>
12962             <phrase role="special">})</phrase>
12963         <phrase role="special">;</phrase>
12964
12965         <phrase role="identifier">enabled_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase>
12966     <phrase role="special">}</phrase>
12967
12968     <phrase role="comment">// Disable button.</phrase>
12969     <phrase role="keyword">void</phrase> <phrase role="identifier">disable</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
12970         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12971             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12972                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">enabled</phrase><phrase role="special">());</phrase> <phrase role="comment">// Disabled.</phrase>
12973             <phrase role="special">})</phrase>
12974         <phrase role="special">;</phrase>
12975
12976         <phrase role="identifier">enabled_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase>
12977     <phrase role="special">}</phrase>
12978
12979     <phrase role="comment">// Invoke externally when button clicked.</phrase>
12980     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">on_bn_clicked</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
12981
12982 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
12983     <phrase role="keyword">bool</phrase> <phrase role="identifier">enabled_</phrase><phrase role="special">;</phrase>
12984 <phrase role="special">};</phrase>
12985
12986 <phrase role="keyword">void</phrase> <phrase role="identifier">push_button</phrase><phrase role="special">::</phrase><phrase role="identifier">on_bn_clicked</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
12987     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
12988         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
12989             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">enabled</phrase><phrase role="special">());</phrase> <phrase role="comment">// Enabled.</phrase>
12990         <phrase role="special">})</phrase>
12991     <phrase role="special">;</phrase>
12992     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
12993 <phrase role="special">}</phrase>
12994
12995 <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// #include guard</phrase>
12996 </programlisting>
12997       </para>
12998       <para>
12999 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">DECREMENT_BUTTON_HPP_</phrase>
13000 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">DECREMENT_BUTTON_HPP_</phrase>
13001
13002 <phrase role="preprocessor">#include</phrase> <phrase role="string">"push_button.hpp"</phrase>
13003 <phrase role="preprocessor">#include</phrase> <phrase role="string">"counter.hpp"</phrase>
13004 <phrase role="preprocessor">#include</phrase> <phrase role="string">"../observer/observer.hpp"</phrase>
13005 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13006 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">noncopyable</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13007
13008 <phrase role="keyword">class</phrase> <phrase role="identifier">decrement_button</phrase>
13009     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">push_button</phrase><phrase role="special">,</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">observer</phrase><phrase role="special">,</phrase> <phrase role="special">\</phrase>
13010             <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">noncopyable</phrase>
13011     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
13012 <phrase role="special">{</phrase>
13013     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13014
13015     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
13016     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
13017
13018     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">on_bn_clicked</phrase><phrase role="special">,</phrase> <phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">,</phrase> <phrase role="identifier">update</phrase><phrase role="special">);</phrase>
13019
13020 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13021     <phrase role="comment">/* Creation */</phrase>
13022
13023     <phrase role="keyword">explicit</phrase> <phrase role="identifier">decrement_button</phrase><phrase role="special">(</phrase><phrase role="identifier">counter</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">a_counter</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">counter_</phrase><phrase role="special">(</phrase><phrase role="identifier">a_counter</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13024         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13025             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13026                 <phrase role="comment">// Enable iff positive value.</phrase>
13027                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">enabled</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">a_counter</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
13028             <phrase role="special">})</phrase>
13029         <phrase role="special">;</phrase>
13030         <phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">attach</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13031     <phrase role="special">}</phrase>
13032
13033     <phrase role="comment">// Destroy button.</phrase>
13034     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">decrement_button</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13035         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
13036         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13037     <phrase role="special">}</phrase>
13038
13039     <phrase role="comment">/* Commands */</phrase>
13040
13041     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">on_bn_clicked</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
13042             <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13043         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_value</phrase> <phrase role="special">=</phrase>
13044                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">());</phrase>
13045         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13046             <phrase role="identifier">override_on_bn_clicked</phrase>
13047         <phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">decrement_button</phrase><phrase role="special">::</phrase><phrase role="identifier">on_bn_clicked</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13048             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13049                 <phrase role="comment">// Counter decremented.</phrase>
13050                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_value</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13051             <phrase role="special">})</phrase>
13052         <phrase role="special">;</phrase>
13053         <phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">decrement</phrase><phrase role="special">();</phrase>
13054     <phrase role="special">}</phrase>
13055
13056     <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
13057             <phrase role="keyword">const</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13058         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13059         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13060             <phrase role="identifier">override_up_to_date_with_subject</phrase>
13061         <phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">decrement_button</phrase><phrase role="special">::</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13062
13063         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> <phrase role="comment">// For simplicity, assume always up-to-date.</phrase>
13064     <phrase role="special">}</phrase>
13065
13066     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">update</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13067         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13068                 <phrase role="identifier">override_update</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">decrement_button</phrase><phrase role="special">::</phrase><phrase role="identifier">update</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13069             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13070                 <phrase role="comment">// Enabled iff positive value.</phrase>
13071                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">enabled</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
13072             <phrase role="special">})</phrase>
13073         <phrase role="special">;</phrase>
13074
13075         <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="identifier">disable</phrase><phrase role="special">();</phrase>
13076         <phrase role="keyword">else</phrase> <phrase role="identifier">enable</phrase><phrase role="special">();</phrase>
13077     <phrase role="special">}</phrase>
13078
13079 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13080     <phrase role="identifier">counter</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">counter_</phrase><phrase role="special">;</phrase>
13081 <phrase role="special">};</phrase>
13082
13083 <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// #include guard</phrase>
13084 </programlisting>
13085       </para>
13086       <para>
13087 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">COUNTER_HPP_</phrase>
13088 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">COUNTER_HPP_</phrase>
13089
13090 <phrase role="preprocessor">#include</phrase> <phrase role="string">"../observer/subject.hpp"</phrase>
13091 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13092
13093 <phrase role="keyword">class</phrase> <phrase role="identifier">counter</phrase>
13094     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">subject</phrase>
13095     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
13096 <phrase role="special">{</phrase>
13097     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13098
13099     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
13100     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
13101
13102 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13103     <phrase role="comment">/* Creation */</phrase>
13104
13105     <phrase role="comment">// Construct counter with specified value.</phrase>
13106     <phrase role="keyword">explicit</phrase> <phrase role="identifier">counter</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">a_value</phrase> <phrase role="special">=</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">value_</phrase><phrase role="special">(</phrase><phrase role="identifier">a_value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13107         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13108             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13109                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">a_value</phrase><phrase role="special">);</phrase> <phrase role="comment">// Value set.</phrase>
13110             <phrase role="special">})</phrase>
13111         <phrase role="special">;</phrase>
13112     <phrase role="special">}</phrase>
13113
13114     <phrase role="comment">// Destroy counter.</phrase>
13115     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">counter</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13116         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
13117         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13118     <phrase role="special">}</phrase>
13119
13120     <phrase role="comment">/* Queries */</phrase>
13121
13122     <phrase role="comment">// Current counter value.</phrase>
13123     <phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13124         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
13125         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13126         <phrase role="keyword">return</phrase> <phrase role="identifier">value_</phrase><phrase role="special">;</phrase>
13127     <phrase role="special">}</phrase>
13128
13129     <phrase role="comment">/* Commands */</phrase>
13130
13131     <phrase role="comment">// Decrement counter value.</phrase>
13132     <phrase role="keyword">void</phrase> <phrase role="identifier">decrement</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13133         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">());</phrase>
13134         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13135             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13136                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_value</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="comment">// Decrement.</phrase>
13137             <phrase role="special">})</phrase>
13138         <phrase role="special">;</phrase>
13139
13140         <phrase role="special">--</phrase><phrase role="identifier">value_</phrase><phrase role="special">;</phrase>
13141         <phrase role="identifier">notify</phrase><phrase role="special">();</phrase> <phrase role="comment">// Notify all attached observers.</phrase>
13142     <phrase role="special">}</phrase>
13143
13144 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13145     <phrase role="keyword">int</phrase> <phrase role="identifier">value_</phrase><phrase role="special">;</phrase>
13146 <phrase role="special">};</phrase>
13147
13148 <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// #include guard</phrase>
13149 </programlisting>
13150       </para>
13151       <para>
13152 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="string">"counter/counter.hpp"</phrase>
13153 <phrase role="preprocessor">#include</phrase> <phrase role="string">"counter/decrement_button.hpp"</phrase>
13154 <phrase role="preprocessor">#include</phrase> <phrase role="string">"observer/observer.hpp"</phrase>
13155 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
13156
13157 <phrase role="keyword">int</phrase> <phrase role="identifier">test_counter</phrase><phrase role="special">;</phrase>
13158
13159 <phrase role="keyword">class</phrase> <phrase role="identifier">view_of_counter</phrase>
13160     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">observer</phrase>
13161     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
13162 <phrase role="special">{</phrase>
13163     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13164
13165     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
13166     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
13167
13168     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">,</phrase> <phrase role="identifier">update</phrase><phrase role="special">)</phrase>
13169
13170 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13171     <phrase role="comment">/* Creation */</phrase>
13172
13173     <phrase role="comment">// Create view associated with given counter.</phrase>
13174     <phrase role="keyword">explicit</phrase> <phrase role="identifier">view_of_counter</phrase><phrase role="special">(</phrase><phrase role="identifier">counter</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">a_counter</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">counter_</phrase><phrase role="special">(</phrase><phrase role="identifier">a_counter</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13175         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
13176         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13177
13178         <phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">attach</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13179         <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">test_counter</phrase><phrase role="special">);</phrase>
13180     <phrase role="special">}</phrase>
13181
13182     <phrase role="comment">// Destroy view.</phrase>
13183     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">view_of_counter</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13184         <phrase role="comment">// Could have omitted contracts here (nothing to check).</phrase>
13185         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13186     <phrase role="special">}</phrase>
13187
13188     <phrase role="comment">/* Commands */</phrase>
13189
13190     <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
13191             <phrase role="keyword">const</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13192         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13193         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13194             <phrase role="identifier">override_up_to_date_with_subject</phrase>
13195         <phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">view_of_counter</phrase><phrase role="special">::</phrase><phrase role="identifier">up_to_date_with_subject</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13196
13197         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> <phrase role="comment">// For simplicity, assume always up-to-date.</phrase>
13198     <phrase role="special">}</phrase>
13199
13200     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">update</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13201         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13202                 <phrase role="identifier">override_update</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">view_of_counter</phrase><phrase role="special">::</phrase><phrase role="identifier">update</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13203
13204         <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">counter_</phrase><phrase role="special">.</phrase><phrase role="identifier">value</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">test_counter</phrase><phrase role="special">);</phrase>
13205     <phrase role="special">}</phrase>
13206
13207 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13208     <phrase role="identifier">counter</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">counter_</phrase><phrase role="special">;</phrase>
13209 <phrase role="special">};</phrase>
13210
13211 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13212     <phrase role="identifier">counter</phrase> <phrase role="identifier">cnt</phrase><phrase role="special">(</phrase><phrase role="identifier">test_counter</phrase> <phrase role="special">=</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13213     <phrase role="identifier">view_of_counter</phrase> <phrase role="identifier">view</phrase><phrase role="special">(</phrase><phrase role="identifier">cnt</phrase><phrase role="special">);</phrase>
13214
13215     <phrase role="identifier">decrement_button</phrase> <phrase role="identifier">dec</phrase><phrase role="special">(</phrase><phrase role="identifier">cnt</phrase><phrase role="special">);</phrase>
13216     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">dec</phrase><phrase role="special">.</phrase><phrase role="identifier">enabled</phrase><phrase role="special">());</phrase>
13217
13218     <phrase role="identifier">test_counter</phrase><phrase role="special">--;</phrase>
13219     <phrase role="identifier">dec</phrase><phrase role="special">.</phrase><phrase role="identifier">on_bn_clicked</phrase><phrase role="special">();</phrase>
13220     <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">dec</phrase><phrase role="special">.</phrase><phrase role="identifier">enabled</phrase><phrase role="special">());</phrase>
13221
13222     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13223 <phrase role="special">}</phrase>
13224 </programlisting>
13225       </para>
13226     </section>
13227     <section id="boost_contract.examples.__cline90___vector__comparison_with_a___proposal_syntax">
13228       <title><anchor id="Cline90_vector_anchor"/><link linkend="boost_contract.examples.__cline90___vector__comparison_with_a___proposal_syntax">[Cline90]
13229       Vector: Comparison with A++ proposal syntax</link></title>
13230       <informaltable frame="all">
13231         <tgroup cols="2">
13232           <thead>
13233             <row>
13234               <entry>
13235                 <para>
13236                   This Library
13237                 </para>
13238               </entry>
13239               <entry>
13240                 <para>
13241                   A++ Proposal (never actually implemented)
13242                 </para>
13243               </entry>
13244             </row>
13245           </thead>
13246           <tbody>
13247             <row>
13248               <entry>
13249                 <para>
13250 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">VECTOR_HPP_</phrase>
13251 <phrase role="preprocessor">#define</phrase> <phrase role="identifier">VECTOR_HPP_</phrase>
13252
13253 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13254
13255 <phrase role="comment">// NOTE: Incomplete contract assertions, addressing only `size`.</phrase>
13256 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13257 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase>
13258     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
13259     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
13260 <phrase role="special">{</phrase>
13261     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13262
13263     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
13264     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
13265
13266     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13267         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13268     <phrase role="special">}</phrase>
13269
13270 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13271     <phrase role="keyword">explicit</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
13272         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vector</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
13273             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13274         <phrase role="special">}),</phrase>
13275         <phrase role="identifier">data_</phrase><phrase role="special">(</phrase><phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">count</phrase><phrase role="special">]),</phrase>
13276         <phrase role="identifier">size_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">)</phrase>
13277     <phrase role="special">{</phrase>
13278         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13279             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13280                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
13281             <phrase role="special">})</phrase>
13282         <phrase role="special">;</phrase>
13283
13284         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">T</phrase><phrase role="special">();</phrase>
13285     <phrase role="special">}</phrase>
13286
13287     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">vector</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13288         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13289         <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase>
13290     <phrase role="special">}</phrase>
13291
13292     <phrase role="keyword">int</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13293         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13294         <phrase role="keyword">return</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase> <phrase role="comment">// Non-negative result already checked by invariant.</phrase>
13295     <phrase role="special">}</phrase>
13296
13297     <phrase role="keyword">void</phrase> <phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13298         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13299             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13300                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13301             <phrase role="special">})</phrase>
13302             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13303                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
13304             <phrase role="special">})</phrase>
13305         <phrase role="special">;</phrase>
13306
13307         <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">slice</phrase> <phrase role="special">=</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">count</phrase><phrase role="special">];</phrase>
13308         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">slice</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">];</phrase>
13309         <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase>
13310         <phrase role="identifier">data_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">slice</phrase><phrase role="special">;</phrase>
13311         <phrase role="identifier">size_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
13312     <phrase role="special">}</phrase>
13313
13314     <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13315         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13316             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13317                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13318                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
13319             <phrase role="special">})</phrase>
13320         <phrase role="special">;</phrase>
13321
13322         <phrase role="keyword">return</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase>
13323     <phrase role="special">}</phrase>
13324
13325     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13326         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13327             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13328                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13329                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">());</phrase>
13330             <phrase role="special">})</phrase>
13331         <phrase role="special">;</phrase>
13332
13333         <phrase role="keyword">return</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase>
13334     <phrase role="special">}</phrase>
13335
13336 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13337     <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase>
13338     <phrase role="keyword">int</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase>
13339 <phrase role="special">};</phrase>
13340
13341 <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// #include guard</phrase>
13342 </programlisting>
13343                 </para>
13344               </entry>
13345               <entry>
13346                 <para>
13347 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// Extra spaces, newlines, etc. for visual alignment with this library code.</phrase>
13348
13349
13350
13351
13352
13353 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13354 <phrase role="keyword">class</phrase> <phrase role="identifier">vector</phrase> <phrase role="special">{</phrase>
13355
13356
13357
13358
13359
13360
13361
13362
13363 <phrase role="identifier">legal</phrase><phrase role="special">:</phrase> <phrase role="comment">// Class invariants (legal).</phrase>
13364     <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13365
13366
13367 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13368     <phrase role="keyword">explicit</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
13369         <phrase role="identifier">data_</phrase><phrase role="special">(</phrase><phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">count</phrase><phrase role="special">]),</phrase>
13370         <phrase role="identifier">size_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">)</phrase>
13371     <phrase role="special">{</phrase>
13372         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">T</phrase><phrase role="special">();</phrase>
13373     <phrase role="special">}</phrase>
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">vector</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
13385
13386
13387
13388
13389     <phrase role="keyword">int</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
13390
13391
13392
13393
13394     <phrase role="keyword">void</phrase> <phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13395         <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">slice</phrase> <phrase role="special">=</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">count</phrase><phrase role="special">];</phrase>
13396         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">slice</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">];</phrase>
13397         <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase>
13398         <phrase role="identifier">data_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">slice</phrase><phrase role="special">;</phrase>
13399         <phrase role="identifier">size_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase>
13400     <phrase role="special">}</phrase>
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411     <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase> <phrase role="special">}</phrase>
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422     <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">index</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">index</phrase><phrase role="special">];</phrase> <phrase role="special">}</phrase>
13423
13424
13425
13426
13427 <phrase role="identifier">axioms</phrase><phrase role="special">:</phrase> <phrase role="comment">// Preconditions (require) and postconditions (promise) for each func.</phrase>
13428     <phrase role="special">[</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase> <phrase role="identifier">require</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">promise</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">]</phrase> <phrase role="identifier">vector</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">);</phrase>
13429     <phrase role="special">[</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase> <phrase role="identifier">require</phrase> <phrase role="identifier">count</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">promise</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">]</phrase> <phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">);</phrase>
13430     <phrase role="special">[</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">index</phrase><phrase role="special">;</phrase> <phrase role="identifier">require</phrase> <phrase role="identifier">index</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">()]</phrase> <phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)[</phrase><phrase role="identifier">x</phrase><phrase role="special">];</phrase>       <phrase role="comment">// Op[].</phrase>
13431     <phrase role="special">[</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">index</phrase><phrase role="special">;</phrase> <phrase role="identifier">require</phrase> <phrase role="identifier">index</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">index</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">()]</phrase> <phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)[</phrase><phrase role="identifier">x</phrase><phrase role="special">]</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> <phrase role="comment">// Op[].</phrase>
13432
13433 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13434     <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase>
13435     <phrase role="keyword">int</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase>
13436 <phrase role="special">};</phrase>
13437
13438 <phrase role="comment">// End.</phrase>
13439 </programlisting>
13440                 </para>
13441               </entry>
13442             </row>
13443             <row>
13444               <entry>
13445                 <para>
13446 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="string">"vector.hpp"</phrase>
13447 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
13448
13449 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13450     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">v</phrase> <phrase role="special">(</phrase><phrase role="number">3</phrase><phrase role="special">);</phrase>
13451     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase>
13452
13453     <phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">0</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="number">123</phrase><phrase role="special">;</phrase>
13454     <phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">resize</phrase><phrase role="special">(</phrase><phrase role="number">2</phrase><phrase role="special">);</phrase>
13455     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">[</phrase><phrase role="number">0</phrase><phrase role="special">]</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
13456     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">2</phrase><phrase role="special">);</phrase>
13457
13458     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13459 <phrase role="special">}</phrase>
13460 </programlisting>
13461                 </para>
13462               </entry>
13463               <entry>
13464               </entry>
13465             </row>
13466           </tbody>
13467         </tgroup>
13468       </informaltable>
13469     </section>
13470     <section id="boost_contract.examples.__cline90___stack__stack_like_container">
13471       <title><link linkend="boost_contract.examples.__cline90___stack__stack_like_container">[Cline90]
13472       Stack: Stack-like container</link></title>
13473       <para>
13474 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13475 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
13476
13477 <phrase role="comment">// NOTE: Incomplete contract assertions, addressing only `empty` and `full`.</phrase>
13478 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13479 <phrase role="keyword">class</phrase> <phrase role="identifier">stack</phrase>
13480     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase>
13481     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
13482 <phrase role="special">{</phrase>
13483     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13484
13485     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
13486     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
13487
13488 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13489     <phrase role="keyword">explicit</phrase> <phrase role="identifier">stack</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
13490         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">stack</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
13491             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13492         <phrase role="special">}),</phrase>
13493         <phrase role="identifier">data_</phrase><phrase role="special">(</phrase><phrase role="keyword">new</phrase> <phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">capacity</phrase><phrase role="special">]),</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">),</phrase> <phrase role="identifier">size_</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">)</phrase>
13494     <phrase role="special">{</phrase>
13495         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13496             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13497                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13498                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">full</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">capacity</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
13499             <phrase role="special">})</phrase>
13500         <phrase role="special">;</phrase>
13501
13502         <phrase role="keyword">for</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">T</phrase><phrase role="special">();</phrase>
13503     <phrase role="special">}</phrase>
13504
13505     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">stack</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13506         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13507         <phrase role="keyword">delete</phrase><phrase role="special">[]</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase>
13508     <phrase role="special">}</phrase>
13509
13510     <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13511         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13512         <phrase role="keyword">return</phrase> <phrase role="identifier">size_</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13513     <phrase role="special">}</phrase>
13514
13515     <phrase role="keyword">bool</phrase> <phrase role="identifier">full</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13516         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13517         <phrase role="keyword">return</phrase> <phrase role="identifier">size_</phrase> <phrase role="special">==</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
13518     <phrase role="special">}</phrase>
13519
13520     <phrase role="keyword">void</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13521         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13522             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13523                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
13524             <phrase role="special">})</phrase>
13525             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13526                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13527             <phrase role="special">})</phrase>
13528         <phrase role="special">;</phrase>
13529
13530         <phrase role="identifier">data_</phrase><phrase role="special">[</phrase><phrase role="identifier">size_</phrase><phrase role="special">++]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
13531     <phrase role="special">}</phrase>
13532
13533     <phrase role="identifier">T</phrase> <phrase role="identifier">pop</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13534         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13535             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13536                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13537             <phrase role="special">})</phrase>
13538             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13539                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
13540             <phrase role="special">})</phrase>
13541         <phrase role="special">;</phrase>
13542
13543         <phrase role="keyword">return</phrase> <phrase role="identifier">data_</phrase><phrase role="special">[--</phrase><phrase role="identifier">size_</phrase><phrase role="special">];</phrase>
13544     <phrase role="special">}</phrase>
13545
13546 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13547     <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">data_</phrase><phrase role="special">;</phrase>
13548     <phrase role="keyword">int</phrase> <phrase role="identifier">capacity_</phrase><phrase role="special">;</phrase>
13549     <phrase role="keyword">int</phrase> <phrase role="identifier">size_</phrase><phrase role="special">;</phrase>
13550 <phrase role="special">};</phrase>
13551
13552 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13553     <phrase role="identifier">stack</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">s</phrase><phrase role="special">(</phrase><phrase role="number">3</phrase><phrase role="special">);</phrase>
13554     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase><phrase role="number">123</phrase><phrase role="special">);</phrase>
13555     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">pop</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
13556     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13557 <phrase role="special">}</phrase>
13558 </programlisting>
13559       </para>
13560     </section>
13561     <section id="boost_contract.examples.__cline90___vector_stack__subcontracting">
13562       <title><link linkend="boost_contract.examples.__cline90___vector_stack__subcontracting">[Cline90]
13563       Vector-Stack: Subcontracting</link></title>
13564       <para>
13565 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="string">"vector.hpp"</phrase>
13566 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13567 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">optional</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13568 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
13569
13570 <phrase role="comment">// NOTE: Incomplete contract assertions, addressing only `empty` and `full`.</phrase>
13571 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13572 <phrase role="keyword">class</phrase> <phrase role="identifier">abstract_stack</phrase> <phrase role="special">{</phrase>
13573 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13574     <phrase role="identifier">abstract_stack</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13575         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13576             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13577                 <phrase role="comment">// AXIOM as empty() cannot actually be checked here to avoid</phrase>
13578                 <phrase role="comment">// calling pure virtual function length() during construction).</phrase>
13579                 <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13580             <phrase role="special">})</phrase>
13581         <phrase role="special">;</phrase>
13582     <phrase role="special">}</phrase>
13583
13584     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">abstract_stack</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13585         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13586     <phrase role="special">}</phrase>
13587
13588     <phrase role="keyword">bool</phrase> <phrase role="identifier">full</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13589         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13590         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13591             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13592                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">()));</phrase>
13593             <phrase role="special">})</phrase>
13594         <phrase role="special">;</phrase>
13595
13596         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
13597     <phrase role="special">}</phrase>
13598
13599     <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13600         <phrase role="keyword">bool</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13601         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13602             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13603                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">));</phrase>
13604             <phrase role="special">})</phrase>
13605         <phrase role="special">;</phrase>
13606
13607         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13608     <phrase role="special">}</phrase>
13609
13610     <phrase role="keyword">virtual</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">length</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13611     <phrase role="keyword">virtual</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13612
13613     <phrase role="keyword">virtual</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">item</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13614
13615     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13616     <phrase role="keyword">virtual</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13617
13618     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13619 <phrase role="special">};</phrase>
13620
13621 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13622 <phrase role="keyword">int</phrase> <phrase role="identifier">abstract_stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">length</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13623     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13624     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13625         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13626             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13627         <phrase role="special">})</phrase>
13628     <phrase role="special">;</phrase>
13629     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
13630     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13631 <phrase role="special">}</phrase>
13632
13633 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13634 <phrase role="keyword">int</phrase> <phrase role="identifier">abstract_stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">capacity</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13635     <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13636     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13637         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13638             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13639         <phrase role="special">})</phrase>
13640     <phrase role="special">;</phrase>
13641     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
13642     <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13643 <phrase role="special">}</phrase>
13644
13645 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13646 <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abstract_stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">item</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13647     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13648     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13649         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13650             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13651         <phrase role="special">})</phrase>
13652     <phrase role="special">;</phrase>
13653     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
13654     <phrase role="keyword">return</phrase> <phrase role="special">*</phrase><phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13655 <phrase role="special">}</phrase>
13656
13657 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13658 <phrase role="keyword">void</phrase> <phrase role="identifier">abstract_stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13659     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13660         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13661             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
13662         <phrase role="special">})</phrase>
13663         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13664             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13665         <phrase role="special">})</phrase>
13666     <phrase role="special">;</phrase>
13667     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
13668 <phrase role="special">}</phrase>
13669
13670 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13671 <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abstract_stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13672     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13673     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_item</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">item</phrase><phrase role="special">());</phrase>
13674     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13675         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13676             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13677         <phrase role="special">})</phrase>
13678         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13679             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(!</phrase><phrase role="identifier">full</phrase><phrase role="special">());</phrase>
13680             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(*</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="special">*</phrase><phrase role="identifier">old_item</phrase><phrase role="special">);</phrase>
13681         <phrase role="special">})</phrase>
13682     <phrase role="special">;</phrase>
13683     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
13684     <phrase role="keyword">return</phrase> <phrase role="special">*</phrase><phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13685 <phrase role="special">}</phrase>
13686
13687 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13688 <phrase role="keyword">void</phrase> <phrase role="identifier">abstract_stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">clear</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13689     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13690         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13691             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">empty</phrase><phrase role="special">());</phrase>
13692         <phrase role="special">})</phrase>
13693     <phrase role="special">;</phrase>
13694     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="keyword">false</phrase><phrase role="special">);</phrase>
13695 <phrase role="special">}</phrase>
13696
13697 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13698 <phrase role="keyword">class</phrase> <phrase role="identifier">vstack</phrase>
13699     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase> <phrase role="special">\</phrase>
13700             <phrase role="identifier">vstack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="special">&gt;,</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">abstract_stack</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
13701     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
13702 <phrase role="special">{</phrase>
13703     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13704
13705     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
13706     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
13707
13708     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13709         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13710         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">());</phrase>
13711     <phrase role="special">}</phrase>
13712
13713     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">,</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">,</phrase> <phrase role="identifier">item</phrase><phrase role="special">,</phrase> <phrase role="identifier">push</phrase><phrase role="special">,</phrase> <phrase role="identifier">pop</phrase><phrase role="special">,</phrase> <phrase role="identifier">clear</phrase><phrase role="special">)</phrase>
13714
13715 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13716     <phrase role="keyword">explicit</phrase> <phrase role="identifier">vstack</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">count</phrase> <phrase role="special">=</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
13717         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">vstack</phrase><phrase role="special">&gt;([&amp;]</phrase> <phrase role="special">{</phrase>
13718             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13719         <phrase role="special">}),</phrase>
13720         <phrase role="identifier">vect_</phrase><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">),</phrase> <phrase role="comment">// OK, executed after precondition so count &gt;= 0.</phrase>
13721         <phrase role="identifier">len_</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">)</phrase>
13722     <phrase role="special">{</phrase>
13723         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13724             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13725                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
13726                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase>
13727             <phrase role="special">})</phrase>
13728         <phrase role="special">;</phrase>
13729     <phrase role="special">}</phrase>
13730
13731     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">vstack</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13732         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13733     <phrase role="special">}</phrase>
13734
13735     <phrase role="comment">// Inherited from abstract_stack.</phrase>
13736
13737     <phrase role="keyword">virtual</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">length</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13738         <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13739         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13740                 <phrase role="identifier">override_length</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vstack</phrase><phrase role="special">::</phrase><phrase role="identifier">length</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13741         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">len_</phrase><phrase role="special">;</phrase>
13742     <phrase role="special">}</phrase>
13743
13744     <phrase role="keyword">virtual</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
13745             <phrase role="keyword">const</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13746         <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13747         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13748                 <phrase role="identifier">override_capacity</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vstack</phrase><phrase role="special">::</phrase><phrase role="identifier">capacity</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13749         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
13750     <phrase role="special">}</phrase>
13751
13752     <phrase role="keyword">virtual</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">item</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
13753             <phrase role="keyword">const</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13754         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13755         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13756                 <phrase role="identifier">override_item</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vstack</phrase><phrase role="special">::</phrase><phrase role="identifier">item</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13757         <phrase role="keyword">return</phrase> <phrase role="special">*(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">[</phrase><phrase role="identifier">len_</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">]);</phrase>
13758     <phrase role="special">}</phrase>
13759
13760     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
13761             <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13762         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13763                 <phrase role="identifier">override_push</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vstack</phrase><phrase role="special">::</phrase><phrase role="identifier">push</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
13764         <phrase role="identifier">vect_</phrase><phrase role="special">[</phrase><phrase role="identifier">len_</phrase><phrase role="special">++]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
13765     <phrase role="special">}</phrase>
13766
13767     <phrase role="keyword">virtual</phrase> <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13768         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">optional</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;&gt;</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13769         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13770                 <phrase role="identifier">override_pop</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vstack</phrase><phrase role="special">::</phrase><phrase role="identifier">pop</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13771         <phrase role="keyword">return</phrase> <phrase role="special">*(</phrase><phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">[--</phrase><phrase role="identifier">len_</phrase><phrase role="special">]);</phrase>
13772     <phrase role="special">}</phrase>
13773
13774     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="comment">/* override */</phrase> <phrase role="special">{</phrase>
13775         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
13776                 <phrase role="identifier">override_clear</phrase><phrase role="special">&gt;(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">vstack</phrase><phrase role="special">::</phrase><phrase role="identifier">clear</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13777         <phrase role="identifier">len_</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13778     <phrase role="special">}</phrase>
13779
13780 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13781     <phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">vect_</phrase><phrase role="special">;</phrase>
13782     <phrase role="keyword">int</phrase> <phrase role="identifier">len_</phrase><phrase role="special">;</phrase>
13783 <phrase role="special">};</phrase>
13784
13785 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13786     <phrase role="identifier">vstack</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">s</phrase><phrase role="special">(</phrase><phrase role="number">3</phrase><phrase role="special">);</phrase>
13787     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">capacity</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase>
13788
13789     <phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase><phrase role="number">123</phrase><phrase role="special">);</phrase>
13790     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13791     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">.</phrase><phrase role="identifier">pop</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">123</phrase><phrase role="special">);</phrase>
13792
13793     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13794 <phrase role="special">}</phrase>
13795 </programlisting>
13796       </para>
13797     </section>
13798     <section id="boost_contract.examples.__cline90___calendar__a_very_simple_calendar">
13799       <title><link linkend="boost_contract.examples.__cline90___calendar__a_very_simple_calendar">[Cline90]
13800       Calendar: A very simple calendar</link></title>
13801       <para>
13802 <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
13803 <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">cassert</phrase><phrase role="special">&gt;</phrase>
13804
13805 <phrase role="keyword">class</phrase> <phrase role="identifier">calendar</phrase> <phrase role="special">{</phrase>
13806     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13807
13808     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13809         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">month</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13810         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">month</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">12</phrase><phrase role="special">);</phrase>
13811         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">date</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13812         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">date</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">days_in</phrase><phrase role="special">(</phrase><phrase role="identifier">month</phrase><phrase role="special">()));</phrase>
13813     <phrase role="special">}</phrase>
13814
13815 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
13816     <phrase role="identifier">calendar</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">month_</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">date_</phrase><phrase role="special">(</phrase><phrase role="number">31</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13817         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13818             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13819                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">month</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13820                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">date</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">31</phrase><phrase role="special">);</phrase>
13821             <phrase role="special">})</phrase>
13822         <phrase role="special">;</phrase>
13823     <phrase role="special">}</phrase>
13824
13825     <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">calendar</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13826         <phrase role="comment">// Check invariants.</phrase>
13827         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13828     <phrase role="special">}</phrase>
13829
13830     <phrase role="keyword">int</phrase> <phrase role="identifier">month</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13831         <phrase role="comment">// Check invariants.</phrase>
13832         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13833         <phrase role="keyword">return</phrase> <phrase role="identifier">month_</phrase><phrase role="special">;</phrase>
13834     <phrase role="special">}</phrase>
13835
13836     <phrase role="keyword">int</phrase> <phrase role="identifier">date</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
13837         <phrase role="comment">// Check invariants.</phrase>
13838         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">);</phrase>
13839         <phrase role="keyword">return</phrase> <phrase role="identifier">date_</phrase><phrase role="special">;</phrase>
13840     <phrase role="special">}</phrase>
13841
13842     <phrase role="keyword">void</phrase> <phrase role="identifier">reset</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">new_month</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13843         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
13844             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13845                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">new_month</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13846                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">new_month</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">12</phrase><phrase role="special">);</phrase>
13847             <phrase role="special">})</phrase>
13848             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13849                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">month</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">new_month</phrase><phrase role="special">);</phrase>
13850             <phrase role="special">})</phrase>
13851         <phrase role="special">;</phrase>
13852
13853         <phrase role="identifier">month_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">new_month</phrase><phrase role="special">;</phrase>
13854     <phrase role="special">}</phrase>
13855
13856 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
13857     <phrase role="keyword">static</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">days_in</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">month</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
13858         <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
13859         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">()</phrase>
13860             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13861                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">month</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13862                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">month</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">12</phrase><phrase role="special">);</phrase>
13863             <phrase role="special">})</phrase>
13864             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">([&amp;]</phrase> <phrase role="special">{</phrase>
13865                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&gt;=</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13866                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">31</phrase><phrase role="special">);</phrase>
13867             <phrase role="special">})</phrase>
13868         <phrase role="special">;</phrase>
13869
13870         <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="number">31</phrase><phrase role="special">;</phrase> <phrase role="comment">// For simplicity, assume all months have 31 days.</phrase>
13871     <phrase role="special">}</phrase>
13872
13873     <phrase role="keyword">int</phrase> <phrase role="identifier">month_</phrase><phrase role="special">,</phrase> <phrase role="identifier">date_</phrase><phrase role="special">;</phrase>
13874 <phrase role="special">};</phrase>
13875
13876 <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
13877     <phrase role="identifier">calendar</phrase> <phrase role="identifier">cal</phrase><phrase role="special">;</phrase>
13878     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">cal</phrase><phrase role="special">.</phrase><phrase role="identifier">date</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">31</phrase><phrase role="special">);</phrase>
13879     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">cal</phrase><phrase role="special">.</phrase><phrase role="identifier">month</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
13880
13881     <phrase role="identifier">cal</phrase><phrase role="special">.</phrase><phrase role="identifier">reset</phrase><phrase role="special">(</phrase><phrase role="number">8</phrase><phrase role="special">);</phrase> <phrase role="comment">// Set month </phrase>
13882     <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">cal</phrase><phrase role="special">.</phrase><phrase role="identifier">month</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="number">8</phrase><phrase role="special">);</phrase>
13883
13884     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
13885 <phrase role="special">}</phrase>
13886 </programlisting>
13887       </para>
13888     </section>
13889   </section>
13890   <section id="reference"><title>Reference</title><section id="header.boost.contract_hpp"><title>Header &lt;<ulink url="../../../../boost/contract.hpp">boost/contract.hpp</ulink>&gt;</title><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>
13891 </para>
13892 </para>
13893 </section>
13894 <section id="header.boost.contract.assert_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/assert.hpp">boost/contract/assert.hpp</ulink>&gt;</title><para>Assert contract conditions. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
13895
13896 <link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link>(cond)
13897 <link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link>(cond)
13898 <link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link>(cond)</synopsis>
13899 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_ASSERT"><refmeta><refentrytitle>Macro BOOST_CONTRACT_ASSERT</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_ASSERT</refname><refpurpose>Preferred way to assert contract conditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.assert_hpp">boost/contract/assert.hpp</link>&gt;
13900
13901 </phrase>BOOST_CONTRACT_ASSERT(cond)</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput>, etc.). However, it is preferred to use this macro because it expands to code that throws <computeroutput><link linkend="boost.contract.assertion_failure">boost::contract::assertion_failure</link></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><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>, <computeroutput><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link></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>
13902 </para>
13903
13904 </para><variablelist spacing="compact"><?dbhtml 
13905               list-presentation="table"
13906             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
13907                       list-presentation="table"
13908                     ?><varlistentry><term><computeroutput>cond</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
13909 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45395000817520"><refmeta><refentrytitle>Macro BOOST_CONTRACT_ASSERT_AUDIT</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_ASSERT_AUDIT</refname><refpurpose>Preferred way to assert contract conditions that are computationally expensive, at least compared to the computational cost of executing the function body. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.assert_hpp">boost/contract/assert.hpp</link>&gt;
13910
13911 </phrase>BOOST_CONTRACT_ASSERT_AUDIT(cond)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>The asserted condition will always be compiled and validated syntactically, but it will not be checked at run-time unless  <computeroutput><link linkend="BOOST_CONTRACT_AUDITS">BOOST_CONTRACT_AUDITS</link></computeroutput> is defined (undefined by default). This macro is defined by code equivalent to:</para><para><programlisting><phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDITS</phrase>
13912     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> \
13913         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase>
13914 <phrase role="preprocessor">#else</phrase>
13915     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> \
13916         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase> <phrase role="special">||</phrase> <phrase role="identifier">cond</phrase><phrase role="special">)</phrase>
13917 <phrase role="preprocessor">#endif</phrase>
13918 </programlisting></para><para> <computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>, <computeroutput><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link></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>
13919 </para>
13920
13921 </para><variablelist spacing="compact"><?dbhtml 
13922               list-presentation="table"
13923             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
13924                       list-presentation="table"
13925                     ?><varlistentry><term><computeroutput>cond</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
13926 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45395027441616"><refmeta><refentrytitle>Macro BOOST_CONTRACT_ASSERT_AXIOM</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_ASSERT_AXIOM</refname><refpurpose>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. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.assert_hpp">boost/contract/assert.hpp</link>&gt;
13927
13928 </phrase>BOOST_CONTRACT_ASSERT_AXIOM(cond)</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_ASSERT_AXIOM</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> \
13929     <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase> <phrase role="special">||</phrase> <phrase role="identifier">cond</phrase><phrase role="special">)</phrase>
13930 </programlisting></para><para> <computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>, <computeroutput><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CO_idm45395027441616">BOOST_CONTRACT_ASSERT_AXIOM</link></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>
13931 </para>
13932
13933 </para><variablelist spacing="compact"><?dbhtml 
13934               list-presentation="table"
13935             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
13936                       list-presentation="table"
13937                     ?><varlistentry><term><computeroutput>cond</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
13938 </section>
13939 <section id="header.boost.contract.base_types_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/base_types.hpp">boost/contract/base_types.hpp</ulink>&gt;</title><para>Specify inheritance form base classes (for subcontracting). </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
13940
13941 <link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link>(...)</synopsis>
13942 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_BASE_TYPES"><refmeta><refentrytitle>Macro BOOST_CONTRACT_BASE_TYPES</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_BASE_TYPES</refname><refpurpose>Used to program the <computeroutput>typedef</computeroutput> that lists the bases of a derived class. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.base_types_hpp">boost/contract/base_types.hpp</link>&gt;
13943
13944 </phrase>BOOST_CONTRACT_BASE_TYPES(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999732400">BOOST_CONTRACT_BASES_TYPEDEF</link></computeroutput>) using this macro:</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
13945     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">protected</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">w1</phrase><phrase role="special">,</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">w2</phrase>
13946     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
13947 <phrase role="special">{</phrase>
13948     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">:</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
13949
13950     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
13951     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
13952
13953     <phrase role="special">...</phrase>
13954 <phrase role="special">}</phrase><phrase role="special">;</phrase>
13955 </programlisting></para><para>This <computeroutput>typedef</computeroutput> must be <computeroutput>public</computeroutput> unless <computeroutput><link linkend="boost.contract.access">boost::contract::access</link></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>
13956 </para>
13957
13958 </para><variablelist spacing="compact"><?dbhtml 
13959               list-presentation="table"
13960             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
13961                       list-presentation="table"
13962                     ?><varlistentry><term><computeroutput>...</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
13963 </section>
13964 <section id="header.boost.contract.call_if_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/call_if.hpp">boost/contract/call_if.hpp</ulink>&gt;</title><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>
13965 </note>
13966 </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
13967   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
13968     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ThenResult <phrase role="special">=</phrase> <phrase role="identifier">internal_type</phrase><phrase role="special">&gt;</phrase> 
13969       <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">;</phrase>
13970
13971     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
13972       <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000098448">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">false</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">internal_type</phrase><phrase role="special">&gt;</phrase><phrase role="special">;</phrase>
13973     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000058976">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">internal_type</phrase><phrase role="special">&gt;</phrase><phrase role="special">;</phrase>
13974     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ThenResult<phrase role="special">&gt;</phrase> 
13975       <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000042848">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">ThenResult</phrase><phrase role="special">&gt;</phrase><phrase role="special">;</phrase>
13976     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000002720">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase><phrase role="special">;</phrase>
13977     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
13978       <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase> <phrase role="special">&gt;</phrase> <link linkend="boost.contract.call_if_c"><phrase role="identifier">call_if_c</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
13979     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
13980       <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase> <phrase role="special">&gt;</phrase> <link linkend="boost.contract.call_if"><phrase role="identifier">call_if</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
13981     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <link linkend="boost.contract.condition_if_c"><phrase role="identifier">condition_if_c</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
13982     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
13983       <phrase role="keyword">bool</phrase> <link linkend="boost.contract.condition_if"><phrase role="identifier">condition_if</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
13984   <phrase role="special">}</phrase>
13985 <phrase role="special">}</phrase></synopsis>
13986 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.call_if_statement"><refmeta><refentrytitle>Struct template call_if_statement</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::call_if_statement</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
13987
13988 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ThenResult <phrase role="special">=</phrase> <phrase role="identifier">internal_type</phrase><phrase role="special">&gt;</phrase> 
13989 <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if_statement">call_if_statement</link> <phrase role="special">{</phrase>
13990 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput> and <computeroutput><link linkend="boost.contract.call_if_c">boost::contract::call_if_c</link></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
13991         Assertion Requirements</link></para>
13992 </para>
13993
13994 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">bool</phrase> Pred</literallayout></para><para><para>Static boolean predicate that selects which functor template call to compile and execute. </para></para></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> Then</literallayout></para><para><para>Type of the functor template to call if the static predicate <computeroutput>Pred</computeroutput> is <computeroutput>true</computeroutput>. </para></para></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> ThenResult <phrase role="special">=</phrase> <phrase role="identifier">internal_type</phrase></literallayout></para><para><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></para></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.call_if__idm45395000098448"><refmeta><refentrytitle>Struct template call_if_statement&lt;false, Then, internal_type&gt;</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::call_if_statement&lt;false, Then, internal_type&gt;</refname><refpurpose>Template specialization to handle static predicates that are <computeroutput>false</computeroutput> (not needed on C++17 compilers, use <computeroutput>if constexpr</computeroutput> instead). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
13995
13996 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
13997 <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000098448">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">false</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">internal_type</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
13998   <phrase role="comment">// <link linkend="boost.contract.call_if__idm45395000098448construct-copy-destruct">construct/copy/destruct</link></phrase>
13999   <phrase role="keyword">explicit</phrase> <link linkend="idm45395000063008-bb"><phrase role="identifier">call_if_statement</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14000
14001   <phrase role="comment">// <link linkend="idm45395000089616-bb">public member functions</link></phrase>
14002   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Else<phrase role="special">&gt;</phrase> <phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Else</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">&gt;</phrase><phrase role="special">::</phrase><phrase role="identifier">type</phrase> <link linkend="idm45395000089056-bb"><phrase role="identifier">else_</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Else</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14003   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14004     <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">ElseIfPred</phrase><phrase role="special">,</phrase> <phrase role="identifier">ElseIfThen</phrase> <phrase role="special">&gt;</phrase> <link linkend="idm45395000080400-bb"><phrase role="identifier">else_if_c</phrase></link><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14005   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14006     <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">ElseIfPred</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">ElseIfThen</phrase> <phrase role="special">&gt;</phrase> 
14007     <link linkend="idm45395000071648-bb"><phrase role="identifier">else_if</phrase></link><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14008 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput> and <computeroutput><link linkend="boost.contract.call_if_c">boost::contract::call_if_c</link></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
14009         Assertion Requirements</link></para>
14010 </para>
14011
14012 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> Then</literallayout></para><para><para>Type of functor template to call when the static predicate is <computeroutput>true</computeroutput> (never the case for this template specialization). </para></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.call_if__idm45395000098448construct-copy-destruct"/><computeroutput>call_if_statement</computeroutput> 
14013         public
14014        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45395000063008-bb"/><phrase role="identifier">call_if_statement</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object with the then-branch functor template. <para>
14015 </para><variablelist spacing="compact"><?dbhtml 
14016           list-presentation="table"
14017         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14018                   list-presentation="table"
14019                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45395000089616-bb"/><computeroutput>call_if_statement</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Else<phrase role="special">&gt;</phrase> <phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Else</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">&gt;</phrase><phrase role="special">::</phrase><phrase role="identifier">type</phrase> <anchor id="idm45395000089056-bb"/><phrase role="identifier">else_</phrase><phrase role="special">(</phrase><phrase role="identifier">Else</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify the else-branch functor template. <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>
14020 </note>
14021
14022
14023 </para><variablelist spacing="compact"><?dbhtml 
14024           list-presentation="table"
14025         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14026                   list-presentation="table"
14027                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>A copy of the value returned by the call to the else-branch functor template <computeroutput>f()</computeroutput>. </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14028   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">ElseIfPred</phrase><phrase role="special">,</phrase> <phrase role="identifier">ElseIfThen</phrase> <phrase role="special">&gt;</phrase> <anchor id="idm45395000080400-bb"/><phrase role="identifier">else_if_c</phrase><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify an else-if-branch functor template (using a static boolean predicate). <para>
14029
14030
14031 </para><variablelist spacing="compact"><?dbhtml 
14032           list-presentation="table"
14033         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14034                   list-presentation="table"
14035                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14036                   list-presentation="table"
14037                 ?><varlistentry><term><computeroutput>ElseIfPred</computeroutput></term><listitem><para>Static boolean predicate selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14038   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">ElseIfPred</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">ElseIfThen</phrase> <phrase role="special">&gt;</phrase> 
14039   <anchor id="idm45395000071648-bb"/><phrase role="identifier">else_if</phrase><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify an else-if-branch functor template (using a nullary boolen meta-function). <para>
14040
14041
14042 </para><variablelist spacing="compact"><?dbhtml 
14043           list-presentation="table"
14044         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14045                   list-presentation="table"
14046                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14047                   list-presentation="table"
14048                 ?><varlistentry><term><computeroutput>ElseIfPred</computeroutput></term><listitem><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.call_if__idm45395000058976"><refmeta><refentrytitle>Struct template call_if_statement&lt;true, Then, internal_type&gt;</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::call_if_statement&lt;true, Then, internal_type&gt;</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
14049
14050 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
14051 <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000058976">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">internal_type</phrase><phrase role="special">&gt;</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> boost::contract::call_if_statement&lt; true, Then, result_of&lt; Then()&gt;::type &gt;
14052 <phrase role="special">{</phrase>
14053   <phrase role="comment">// <link linkend="boost.contract.call_if__idm45395000058976construct-copy-destruct">construct/copy/destruct</link></phrase>
14054   <phrase role="keyword">explicit</phrase> <link linkend="idm45395000046864-bb"><phrase role="identifier">call_if_statement</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14055 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput> and <computeroutput><link linkend="boost.contract.call_if_c">boost::contract::call_if_c</link></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>
14056 </note>
14057 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
14058         Assertion Requirements</link></para>
14059 </para>
14060
14061 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> Then</literallayout></para><para><para>Type of functor template to call when the static predicate is <computeroutput>true</computeroutput> (as it is for this template specialization). </para></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.call_if__idm45395000058976construct-copy-destruct"/><computeroutput>call_if_statement</computeroutput> 
14062         public
14063        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45395000046864-bb"/><phrase role="identifier">call_if_statement</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object with the then-branch functor template. <para>
14064 </para><variablelist spacing="compact"><?dbhtml 
14065           list-presentation="table"
14066         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14067                   list-presentation="table"
14068                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.call_if__idm45395000042848"><refmeta><refentrytitle>Struct template call_if_statement&lt;true, Then, ThenResult&gt;</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::call_if_statement&lt;true, Then, ThenResult&gt;</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
14069
14070 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ThenResult<phrase role="special">&gt;</phrase> 
14071 <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000042848">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">ThenResult</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
14072   <phrase role="comment">// <link linkend="boost.contract.call_if__idm45395000042848construct-copy-destruct">construct/copy/destruct</link></phrase>
14073   <phrase role="keyword">explicit</phrase> <link linkend="idm45395000007120-bb"><phrase role="identifier">call_if_statement</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14074
14075   <phrase role="comment">// <link linkend="idm45395000033040-bb">public member functions</link></phrase>
14076   <link linkend="idm45395000032480-bb"><phrase role="keyword">operator</phrase> <phrase role="identifier">ThenResult</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14077   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Else<phrase role="special">&gt;</phrase> <phrase role="identifier">ThenResult</phrase> <link linkend="idm45395000030976-bb"><phrase role="identifier">else_</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Else</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14078   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14079     <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">ThenResult</phrase> <phrase role="special">&gt;</phrase> 
14080     <link linkend="idm45395000024480-bb"><phrase role="identifier">else_if_c</phrase></link><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14081   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14082     <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">ThenResult</phrase> <phrase role="special">&gt;</phrase> 
14083     <link linkend="idm45395000015744-bb"><phrase role="identifier">else_if</phrase></link><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14084 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Usually this class template is instantiated only via the return value of  <computeroutput><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput> and <computeroutput><link linkend="boost.contract.call_if_c">boost::contract::call_if_c</link></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
14085         Assertion Requirements</link></para>
14086 </para>
14087
14088 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> Then</literallayout></para><para><para>Type of functor template to call when the static predicate is <computeroutput>true</computeroutput> (as it is for this template specialization). </para></para></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> ThenResult</literallayout></para><para><para>Non-void return type of the then-branch functor template call. </para></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.call_if__idm45395000042848construct-copy-destruct"/><computeroutput>call_if_statement</computeroutput> 
14089         public
14090        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45395000007120-bb"/><phrase role="identifier">call_if_statement</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object with the then-branch functor template. <para>
14091 </para><variablelist spacing="compact"><?dbhtml 
14092           list-presentation="table"
14093         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14094                   list-presentation="table"
14095                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45395000033040-bb"/><computeroutput>call_if_statement</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45395000032480-bb"/><phrase role="keyword">operator</phrase> <phrase role="identifier">ThenResult</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>This implicit type conversion returns a copy of the value returned by the call to the then-branch functor template. </listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Else<phrase role="special">&gt;</phrase> <phrase role="identifier">ThenResult</phrase> <anchor id="idm45395000030976-bb"/><phrase role="identifier">else_</phrase><phrase role="special">(</phrase><phrase role="identifier">Else</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify the else-branch functor template. <para>
14096
14097 </para><variablelist spacing="compact"><?dbhtml 
14098           list-presentation="table"
14099         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14100                   list-presentation="table"
14101                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14102   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">ThenResult</phrase> <phrase role="special">&gt;</phrase> 
14103   <anchor id="idm45395000024480-bb"/><phrase role="identifier">else_if_c</phrase><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify an else-if-branch functor template (using a static boolean predicate). <para>
14104
14105
14106 </para><variablelist spacing="compact"><?dbhtml 
14107           list-presentation="table"
14108         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14109                   list-presentation="table"
14110                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14111                   list-presentation="table"
14112                 ?><varlistentry><term><computeroutput>ElseIfPred</computeroutput></term><listitem><para>Static boolean predicate selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14113   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="identifier">ThenResult</phrase> <phrase role="special">&gt;</phrase> 
14114   <anchor id="idm45395000015744-bb"/><phrase role="identifier">else_if</phrase><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify an else-if-branch functor template (using a nullary boolean meta-function). <para>
14115
14116
14117 </para><variablelist spacing="compact"><?dbhtml 
14118           list-presentation="table"
14119         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14120                   list-presentation="table"
14121                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14122                   list-presentation="table"
14123                 ?><varlistentry><term><computeroutput>ElseIfPred</computeroutput></term><listitem><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.call_if__idm45395000002720"><refmeta><refentrytitle>Struct template call_if_statement&lt;true, Then, void&gt;</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::call_if_statement&lt;true, Then, void&gt;</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
14124
14125 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
14126 <phrase role="keyword">struct</phrase> <link linkend="boost.contract.call_if__idm45395000002720">call_if_statement</link><phrase role="special">&lt;</phrase><phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
14127   <phrase role="comment">// <link linkend="boost.contract.call_if__idm45395000002720construct-copy-destruct">construct/copy/destruct</link></phrase>
14128   <phrase role="keyword">explicit</phrase> <link linkend="idm45394999971152-bb"><phrase role="identifier">call_if_statement</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Then</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14129
14130   <phrase role="comment">// <link linkend="idm45394999993936-bb">public member functions</link></phrase>
14131   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Else<phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <link linkend="idm45394999993376-bb"><phrase role="identifier">else_</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Else</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14132   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14133     <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <link linkend="idm45394999987552-bb"><phrase role="identifier">else_if_c</phrase></link><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14134   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14135     <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <link linkend="idm45394999979296-bb"><phrase role="identifier">else_if</phrase></link><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14136 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Usually this class template is instantiated only via the return value of  <computeroutput><link linkend="boost.contract.call_if">boost::contract::call_if</link></computeroutput> and <computeroutput><link linkend="boost.contract.call_if_c">boost::contract::call_if_c</link></computeroutput>.</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.assertion_requirements__templates_">
14137         Assertion Requirements</link></para>
14138 </para>
14139
14140 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> Then</literallayout></para><para><para>Type of functor template to call when the static predicate if <computeroutput>true</computeroutput> (as it is for this template specialization). </para></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.call_if__idm45395000002720construct-copy-destruct"/><computeroutput>call_if_statement</computeroutput> 
14141         public
14142        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45394999971152-bb"/><phrase role="identifier">call_if_statement</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object with the then-branch functor template. <para>
14143 </para><variablelist spacing="compact"><?dbhtml 
14144           list-presentation="table"
14145         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14146                   list-presentation="table"
14147                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999993936-bb"/><computeroutput>call_if_statement</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Else<phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <anchor id="idm45394999993376-bb"/><phrase role="identifier">else_</phrase><phrase role="special">(</phrase><phrase role="identifier">Else</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify the else-branch functor template. <para>
14148 </para><variablelist spacing="compact"><?dbhtml 
14149           list-presentation="table"
14150         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14151                   list-presentation="table"
14152                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14153   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <anchor id="idm45394999987552-bb"/><phrase role="identifier">else_if_c</phrase><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify an else-if-branch functor template (using a static boolean predicate). <para>
14154
14155
14156 </para><variablelist spacing="compact"><?dbhtml 
14157           list-presentation="table"
14158         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14159                   list-presentation="table"
14160                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14161                   list-presentation="table"
14162                 ?><varlistentry><term><computeroutput>ElseIfPred</computeroutput></term><listitem><para>Static boolean predicate selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> ElseIfPred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> ElseIfThen<phrase role="special">&gt;</phrase> 
14163   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="keyword">true</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <anchor id="idm45394999979296-bb"/><phrase role="identifier">else_if</phrase><phrase role="special">(</phrase><phrase role="identifier">ElseIfThen</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Specify an else-if-branch functor template (using a nullary boolean meta-function). <para>
14164
14165
14166 </para><variablelist spacing="compact"><?dbhtml 
14167           list-presentation="table"
14168         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14169                   list-presentation="table"
14170                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14171                   list-presentation="table"
14172                 ?><varlistentry><term><computeroutput>ElseIfPred</computeroutput></term><listitem><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.call_if_c"><refmeta><refentrytitle>Function template call_if_c</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::call_if_c</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
14173
14174 </phrase>
14175 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
14176   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">call_if_c</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Create a call-if object with the specified then-branch functor template:</para><para><programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">call_if_c</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Pred1</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase>
14177     <phrase role="identifier">then_functor_template1</phrase>
14178 <phrase role="special">)</phrase><phrase role="special">.</phrase><phrase role="keyword">template</phrase> <phrase role="identifier">else_if_c</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Pred2</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase>            <phrase role="comment">// Optional.</phrase>
14179     <phrase role="identifier">then_functor_template2</phrase>
14180 <phrase role="special">)</phrase>                                       <phrase role="comment">// Optionally, other `else_if_c` or</phrase>
14181 <phrase role="special">...</phrase>                                     <phrase role="comment">// `else_if`.</phrase>
14182 <phrase role="special">.</phrase><phrase role="identifier">else_</phrase><phrase role="special">(</phrase>                                 <phrase role="comment">// Optional for `void` functors,</phrase>
14183     <phrase role="identifier">else_functor_template</phrase>               <phrase role="comment">// but required for non `void`.</phrase>
14184 <phrase role="special">)</phrase>
14185 </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_">
14186         Assertion Requirements</link></para>
14187 </para>
14188
14189
14190
14191 </para><variablelist spacing="compact"><?dbhtml 
14192           list-presentation="table"
14193         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14194                   list-presentation="table"
14195                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14196                   list-presentation="table"
14197                 ?><varlistentry><term><computeroutput>Pred</computeroutput></term><listitem><para>Static boolean predicate selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.call_if"><refmeta><refentrytitle>Function template call_if</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::call_if</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
14198
14199 </phrase>
14200 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
14201   <link linkend="boost.contract.call_if_statement">call_if_statement</link><phrase role="special">&lt;</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">::</phrase><phrase role="identifier">value</phrase><phrase role="special">,</phrase> <phrase role="identifier">Then</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">call_if</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">call_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Pred1</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase>
14202     <phrase role="identifier">then_functor_template1</phrase>
14203 <phrase role="special">)</phrase><phrase role="special">.</phrase><phrase role="keyword">template</phrase> <phrase role="identifier">else_if</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Pred2</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase>              <phrase role="comment">// Optional.</phrase>
14204     <phrase role="identifier">then_functor_template2</phrase>
14205 <phrase role="special">)</phrase>                                       <phrase role="comment">// Optionally, other `else_if` or</phrase>
14206 <phrase role="special">...</phrase>                                     <phrase role="comment">// `else_if_c`.</phrase>
14207 <phrase role="special">.</phrase><phrase role="identifier">else_</phrase><phrase role="special">(</phrase>                                 <phrase role="comment">// Optional for `void` functors,</phrase>
14208     <phrase role="identifier">else_functor_template</phrase>               <phrase role="comment">// but required for non `void`.</phrase>
14209 <phrase role="special">)</phrase>
14210 </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_">
14211         Assertion Requirements</link></para>
14212 </para>
14213
14214
14215
14216 </para><variablelist spacing="compact"><?dbhtml 
14217           list-presentation="table"
14218         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14219                   list-presentation="table"
14220                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14221                   list-presentation="table"
14222                 ?><varlistentry><term><computeroutput>Pred</computeroutput></term><listitem><para>Nullary boolean meta-function selecting which functor template call to compile and execute.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.condition_if_c"><refmeta><refentrytitle>Function template condition_if_c</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::condition_if_c</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
14223
14224 </phrase>
14225 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">bool</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
14226   <phrase role="keyword">bool</phrase> <phrase role="identifier">condition_if_c</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> f<phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> else_ <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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_">
14227         Assertion Requirements</link></para>
14228 </para>
14229
14230
14231
14232
14233 </para><variablelist spacing="compact"><?dbhtml 
14234           list-presentation="table"
14235         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14236                   list-presentation="table"
14237                 ?><varlistentry><term><computeroutput>else_</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14238                   list-presentation="table"
14239                 ?><varlistentry><term><computeroutput>Pred</computeroutput></term><listitem><para>Static boolean predicate selecting when the functor template call <computeroutput>f()</computeroutput> should be compiled and executed. </para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.condition_if"><refmeta><refentrytitle>Function template condition_if</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::condition_if</refname><refpurpose>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). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.call_if_hpp">boost/contract/call_if.hpp</link>&gt;
14240
14241 </phrase>
14242 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Pred<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Then<phrase role="special">&gt;</phrase> 
14243   <phrase role="keyword">bool</phrase> <phrase role="identifier">condition_if</phrase><phrase role="special">(</phrase><phrase role="identifier">Then</phrase> f<phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> else_ <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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_">
14244         Assertion Requirements</link></para>
14245 </para>
14246
14247
14248
14249 </para><variablelist spacing="compact"><?dbhtml 
14250           list-presentation="table"
14251         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14252                   list-presentation="table"
14253                 ?><varlistentry><term><computeroutput>else_</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14254                   list-presentation="table"
14255                 ?><varlistentry><term><computeroutput>Pred</computeroutput></term><listitem><para>Nullary boolean meta-function selecting when the functor template call <computeroutput>f()</computeroutput> should be compiled and executed.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></refsect1></refentry>
14256 </section>
14257 <section id="header.boost.contract.check_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/check.hpp">boost/contract/check.hpp</ulink>&gt;</title><para>RAII object that checks contracts. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
14258   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
14259     <phrase role="keyword">class</phrase> <link linkend="boost.contract.check">check</link><phrase role="special">;</phrase>
14260   <phrase role="special">}</phrase>
14261 <phrase role="special">}</phrase></synopsis>
14262 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.check"><refmeta><refentrytitle>Class check</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::check</refname><refpurpose>RAII object that checks the contracts. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.check_hpp">boost/contract/check.hpp</link>&gt;
14263
14264 </phrase>
14265 <phrase role="keyword">class</phrase> <link linkend="boost.contract.check">check</link> <phrase role="special">{</phrase>
14266 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14267   <phrase role="comment">// <link linkend="boost.contract.checkconstruct-copy-destruct">construct/copy/destruct</link></phrase>
14268   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="idm45394999887520-bb"><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14269   <link linkend="idm45394999880144-bb"><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.check">check</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14270   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">&gt;</phrase> 
14271     <link linkend="idm45394999877248-bb"><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14272   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">&gt;</phrase> 
14273     <link linkend="idm45394999867968-bb"><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14274   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">&gt;</phrase> 
14275     <link linkend="idm45394999856928-bb"><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14276   <link linkend="idm45394999845840-bb"><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.specify_except">specify_except</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14277   <link linkend="idm45394999836656-bb"><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.specify_nothing">specify_nothing</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14278   <link linkend="idm45394999827456-bb"><phrase role="special">~</phrase><phrase role="identifier">check</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14279 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14280 <listitem><para>Postconditions are checked only if the body does not throw an exception. </para>
14281 </listitem>
14282 <listitem><para>Exceptions guarantees are checked only if the body throws an exception. </para>
14283 </listitem>
14284 <listitem><para>Constructor entry never checks class invariants. </para>
14285 </listitem>
14286 <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>
14287 </listitem>
14288 <listitem><para>Static invariants are always checked at entry and exit (and regardless of the body throwing exceptions or not).</para>
14289 </listitem>
14290 </itemizedlist>
14291 When used this way, this object is constructed and initialized to the return value of one of the contract functions <computeroutput><link linkend="boost.contract.function">boost::contract::function</link></computeroutput>,  <computeroutput><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput>, <computeroutput><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput>, or <computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></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>
14292 </para>
14293 </para><refsect2><title><anchor id="boost.contract.checkconstruct-copy-destruct"/><computeroutput>check</computeroutput> 
14294         public
14295        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <anchor id="idm45394999887520-bb"/><phrase role="identifier">check</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object for implementation checks. <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__">
14296             Throw on Failure</link>).</para><para>
14297 </para><variablelist spacing="compact"><?dbhtml 
14298           list-presentation="table"
14299         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14300                   list-presentation="table"
14301                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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">
14302             Implementation Checks</link>). </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="idm45394999880144-bb"/><phrase role="identifier">check</phrase><phrase role="special">(</phrase><link linkend="boost.contract.check">check</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> other<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object copying it from the specified one. <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>
14303 </para><variablelist spacing="compact"><?dbhtml 
14304           list-presentation="table"
14305         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14306                   list-presentation="table"
14307                 ?><varlistentry><term><computeroutput>other</computeroutput></term><listitem><para>Copied-from object. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">&gt;</phrase> 
14308   <anchor id="idm45394999877248-bb"/><phrase role="identifier">check</phrase><phrase role="special">(</phrase><link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> contract<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object to check the specified contract. <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__">
14309             Throw on Failure</link>).</para><para>
14310
14311 </para><variablelist spacing="compact"><?dbhtml 
14312           list-presentation="table"
14313         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14314                   list-presentation="table"
14315                 ?><varlistentry><term><computeroutput>contract</computeroutput></term><listitem><para>Contract to be checked (usually the return value of  <computeroutput><computeroutput><link linkend="boost.contract.function">boost::contract::function</link></computeroutput></computeroutput> or  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></computeroutput>).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14316                   list-presentation="table"
14317                 ?><varlistentry><term><computeroutput>VirtualResult</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">&gt;</phrase> 
14318   <anchor id="idm45394999867968-bb"/><phrase role="identifier">check</phrase><phrase role="special">(</phrase><link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> contract<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object to check the specified contract. <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__">
14319             Throw on Failure</link>).</para><para>
14320
14321 </para><variablelist spacing="compact"><?dbhtml 
14322           list-presentation="table"
14323         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14324                   list-presentation="table"
14325                 ?><varlistentry><term><computeroutput>contract</computeroutput></term><listitem><para>Contract to be checked (usually the return value of  <computeroutput><computeroutput><link linkend="boost.contract.function">boost::contract::function</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput></computeroutput>, or  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></computeroutput>).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14326                   list-presentation="table"
14327                 ?><varlistentry><term><computeroutput>VirtualResult</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">&gt;</phrase> 
14328   <anchor id="idm45394999856928-bb"/><phrase role="identifier">check</phrase><phrase role="special">(</phrase><link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> contract<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object to check the specified contract. <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__">
14329             Throw on Failure</link>).</para><para>
14330
14331 </para><variablelist spacing="compact"><?dbhtml 
14332           list-presentation="table"
14333         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14334                   list-presentation="table"
14335                 ?><varlistentry><term><computeroutput>contract</computeroutput></term><listitem><para>Contract to be checked (usually the return value of  <computeroutput><computeroutput><link linkend="boost.contract.function">boost::contract::function</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput></computeroutput>, or  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></computeroutput>).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14336                   list-presentation="table"
14337                 ?><varlistentry><term><computeroutput>VirtualResult</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="idm45394999845840-bb"/><phrase role="identifier">check</phrase><phrase role="special">(</phrase><link linkend="boost.contract.specify_except">specify_except</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> contract<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object to check the specified contract. <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__">
14338             Throw on Failure</link>).</para><para>
14339
14340 </para><variablelist spacing="compact"><?dbhtml 
14341           list-presentation="table"
14342         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14343                   list-presentation="table"
14344                 ?><varlistentry><term><computeroutput>contract</computeroutput></term><listitem><para>Contract to be checked (usually the return value of  <computeroutput><computeroutput><link linkend="boost.contract.function">boost::contract::function</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput></computeroutput>, or  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></computeroutput>).</para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="idm45394999836656-bb"/><phrase role="identifier">check</phrase><phrase role="special">(</phrase><link linkend="boost.contract.specify_nothing">specify_nothing</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> contract<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object to check the specified contract. <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__">
14345             Throw on Failure</link>).</para><para>
14346
14347 </para><variablelist spacing="compact"><?dbhtml 
14348           list-presentation="table"
14349         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14350                   list-presentation="table"
14351                 ?><varlistentry><term><computeroutput>contract</computeroutput></term><listitem><para>Contract to be checked (usually the return value of  <computeroutput><computeroutput><link linkend="boost.contract.function">boost::contract::function</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.constructor">boost::contract::constructor</link></computeroutput></computeroutput>,  <computeroutput><computeroutput><link linkend="boost.contract.destructor">boost::contract::destructor</link></computeroutput></computeroutput>, or  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></computeroutput>).</para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="idm45394999827456-bb"/><phrase role="special">~</phrase><phrase role="identifier">check</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <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__">
14352             Throw on Failure</link>). (This is declared <computeroutput>noexcept(false)</computeroutput> since C++11.) </para></listitem></orderedlist></refsect2></refsect1></refentry>
14353 </section>
14354 <section id="header.boost.contract.constructor_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/constructor.hpp">boost/contract/constructor.hpp</ulink>&gt;</title><para>Program contracts for constructors. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
14355   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
14356     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
14357       <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link> <link linkend="boost.contract.constructor"><phrase role="identifier">constructor</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Class</phrase> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14358   <phrase role="special">}</phrase>
14359 <phrase role="special">}</phrase></synopsis>
14360 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.constructor"><refmeta><refentrytitle>Function template constructor</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::constructor</refname><refpurpose>Program contracts for constructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.constructor_hpp">boost/contract/constructor.hpp</link>&gt;
14361
14362 </phrase>
14363 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
14364   <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link> <phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="identifier">Class</phrase> <phrase role="special">*</phrase> obj<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used to specify postconditions, exception guarantees, old value copies at body, and check class invariants for constructors (see  <computeroutput><computeroutput><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput></computeroutput> to specify preconditions for constructors):</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
14365     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">:</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
14366
14367     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
14368         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14369         <phrase role="special">...</phrase>
14370     <phrase role="special">}</phrase>
14371
14372 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14373     <phrase role="identifier">u</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
14374         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
14375         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
14376             <phrase role="comment">// No `.precondition` (use `constructor_precondition` instead).</phrase>
14377             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
14378                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14379                 <phrase role="special">...</phrase>
14380             <phrase role="special">}</phrase><phrase role="special">)</phrase>
14381             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
14382                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14383                 <phrase role="special">...</phrase>
14384             <phrase role="special">}</phrase><phrase role="special">)</phrase>
14385             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
14386                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14387                 <phrase role="special">...</phrase>
14388             <phrase role="special">}</phrase><phrase role="special">)</phrase>
14389         <phrase role="special">;</phrase>
14390
14391         <phrase role="special">...</phrase> <phrase role="comment">// Constructor body.</phrase>
14392     <phrase role="special">}</phrase>
14393
14394     <phrase role="special">...</phrase>
14395 <phrase role="special">}</phrase><phrase role="special">;</phrase>
14396 </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>
14397 </para>
14398
14399
14400
14401 </para><variablelist spacing="compact"><?dbhtml 
14402           list-presentation="table"
14403         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14404                   list-presentation="table"
14405                 ?><varlistentry><term><computeroutput>obj</computeroutput></term><listitem><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">
14406             Class Invariants</link> and  <link linkend="boost_contract.extras.volatile_public_functions">
14407             Volatile Public Functions</link>).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14408                   list-presentation="table"
14409                 ?><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry>
14410 </section>
14411 <section id="header.boost.contract.core.access_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/core/access.hpp">boost/contract/core/access.hpp</ulink>&gt;</title><para>Allow to declare invariants, base types, etc all as private members. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
14412   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
14413     <phrase role="keyword">class</phrase> <link linkend="boost.contract.access">access</link><phrase role="special">;</phrase>
14414   <phrase role="special">}</phrase>
14415 <phrase role="special">}</phrase></synopsis>
14416 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.access"><refmeta><refentrytitle>Class access</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::access</refname><refpurpose>Declare this class as friend to program invariants and base types as private members. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.access_hpp">boost/contract/core/access.hpp</link>&gt;
14417
14418 </phrase>
14419 <phrase role="keyword">class</phrase> <link linkend="boost.contract.access">access</link> <phrase role="special">{</phrase>
14420 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
14421     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">w</phrase>
14422     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
14423 <phrase role="special">{</phrase>
14424     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
14425
14426     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase> <phrase role="comment">// Private.</phrase>
14427     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
14428
14429     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase> <phrase role="comment">// Private (same for static and volatile).</phrase>
14430
14431 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14432     <phrase role="special">...</phrase>
14433 <phrase role="special">}</phrase><phrase role="special">;</phrase>
14434 </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>
14435 </warning>
14436 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.access_specifiers"> Access Specifiers</link> </para>
14437 </para>
14438 </para></refsect1></refentry>
14439 </section>
14440 <section id="header.boost.contract.core.check_macro_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/core/check_macro.hpp">boost/contract/core/check_macro.hpp</ulink>&gt;</title><para>Macros for implementation checks. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
14441
14442 <link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link>(cond)
14443 <link linkend="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</link>(cond)
14444 <link linkend="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</link>(cond)</synopsis>
14445 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_CHECK"><refmeta><refentrytitle>Macro BOOST_CONTRACT_CHECK</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_CHECK</refname><refpurpose>Preferred way to assert implementation check conditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.check_macro_hpp">boost/contract/core/check_macro.hpp</link>&gt;
14446
14447 </phrase>BOOST_CONTRACT_CHECK(cond)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>It is preferred to use this macro instead of programming implementation checks in a nullary functor passed to <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></computeroutput> constructor because this macro will completely remove implementation checks from the code when <computeroutput><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></computeroutput> is defined:</para><para><programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
14448     <phrase role="special">...</phrase>
14449     <phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14450     <phrase role="special">...</phrase>
14451 <phrase role="special">}</phrase>
14452 </programlisting></para><para> <computeroutput><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</link></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>
14453 </para>
14454
14455 </para><variablelist spacing="compact"><?dbhtml 
14456               list-presentation="table"
14457             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14458                       list-presentation="table"
14459                     ?><varlistentry><term><computeroutput>cond</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
14460 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_CHECK_AUDIT"><refmeta><refentrytitle>Macro BOOST_CONTRACT_CHECK_AUDIT</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_CHECK_AUDIT</refname><refpurpose>Preferred way to assert implementation check conditions that are computationally expensive, at least compared to the computational cost of executing the function body. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.check_macro_hpp">boost/contract/core/check_macro.hpp</link>&gt;
14461
14462 </phrase>BOOST_CONTRACT_CHECK_AUDIT(cond)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>The specified condition will always be compiled and validated syntactically, but it will not be checked at run-time unless  <computeroutput><link linkend="BOOST_CONTRACT_AUDITS">BOOST_CONTRACT_AUDITS</link></computeroutput> is defined (undefined by default). This macro is defined by code equivalent to:</para><para><programlisting><phrase role="preprocessor">#ifdef</phrase> <phrase role="identifier">BOOST_CONTRACT_AUDITS</phrase>
14463     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_CHECK_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> \
14464         <phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase>
14465 <phrase role="preprocessor">#else</phrase>
14466     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_CHECK_AUDIT</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> \
14467         <phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase> <phrase role="special">||</phrase> <phrase role="identifier">cond</phrase><phrase role="special">)</phrase>
14468 <phrase role="preprocessor">#endif</phrase>
14469 </programlisting></para><para> <computeroutput><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</link></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>
14470 </para>
14471
14472 </para><variablelist spacing="compact"><?dbhtml 
14473               list-presentation="table"
14474             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14475                       list-presentation="table"
14476                     ?><varlistentry><term><computeroutput>cond</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
14477 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_CHECK_AXIOM"><refmeta><refentrytitle>Macro BOOST_CONTRACT_CHECK_AXIOM</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_CHECK_AXIOM</refname><refpurpose>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. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.check_macro_hpp">boost/contract/core/check_macro.hpp</link>&gt;
14478
14479 </phrase>BOOST_CONTRACT_CHECK_AXIOM(cond)</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="preprocessor">#define</phrase> <phrase role="identifier">BOOST_CONTRACT_CHECK_AXIOM</phrase><phrase role="special">(</phrase><phrase role="identifier">cond</phrase><phrase role="special">)</phrase> \
14480     <phrase role="identifier">BOOST_CONTRACT_CHECK</phrase><phrase role="special">(</phrase><phrase role="keyword">true</phrase> <phrase role="special">||</phrase> <phrase role="identifier">cond</phrase><phrase role="special">)</phrase>
14481 </programlisting></para><para> <computeroutput><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_CHECK_AXIOM">BOOST_CONTRACT_CHECK_AXIOM</link></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>
14482 </para>
14483
14484 </para><variablelist spacing="compact"><?dbhtml 
14485               list-presentation="table"
14486             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14487                       list-presentation="table"
14488                     ?><varlistentry><term><computeroutput>cond</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
14489 </section>
14490 <section id="header.boost.contract.core.config_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/core/config.hpp">boost/contract/core/config.hpp</ulink>&gt;</title><para>Configure this library compile-time and run-time behaviours. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
14491
14492 <link linkend="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</link>
14493 <link linkend="BOOST_CONTRACT_STATIC_LINK">BOOST_CONTRACT_STATIC_LINK</link>
14494 <link linkend="BOOST_CONTRACT_HEADER_ONLY">BOOST_CONTRACT_HEADER_ONLY</link>
14495 <link linkend="BOOST_CO_idm45394999743888">BOOST_CONTRACT_DISABLE_THREADS</link>
14496 <link linkend="BOOST_CONTRACT_MAX_ARGS">BOOST_CONTRACT_MAX_ARGS</link>
14497 <link linkend="BOOST_CO_idm45394999732400">BOOST_CONTRACT_BASES_TYPEDEF</link>
14498 <link linkend="BOOST_CO_idm45394999724496">BOOST_CONTRACT_INVARIANT_FUNC</link>
14499 <link linkend="BOOST_CO_idm45394999714768">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</link>
14500 <link linkend="BOOST_CONTRACT_PERMISSIVE">BOOST_CONTRACT_PERMISSIVE</link>
14501 <link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link>
14502 <link linkend="BOOST_CO_idm45394999685184">BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</link>
14503 <link linkend="BOOST_CO_idm45394999679376">BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION</link>
14504 <link linkend="BOOST_CONTRACT_AUDITS">BOOST_CONTRACT_AUDITS</link>
14505 <link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link>
14506 <link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link>
14507 <link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link>
14508 <link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link>
14509 <link linkend="BOOST_CO_idm45394999637264">BOOST_CONTRACT_NO_ENTRY_INVARIANTS</link>
14510 <link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link>
14511 <link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link>
14512 <link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link>
14513 <link linkend="BOOST_CO_idm45394999605408">BOOST_CONTRACT_NO_CONSTRUCTORS</link>
14514 <link linkend="BOOST_CO_idm45394999594544">BOOST_CONTRACT_NO_DESTRUCTORS</link>
14515 <link linkend="BOOST_CO_idm45394999586272">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</link>
14516 <link linkend="BOOST_CO_idm45394999577072">BOOST_CONTRACT_NO_FUNCTIONS</link>
14517 <link linkend="BOOST_CO_idm45394999566736">BOOST_CONTRACT_NO_CONDITIONS</link>
14518 <link linkend="BOOST_CONTRACT_NO_ALL">BOOST_CONTRACT_NO_ALL</link></synopsis>
14519 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_DYN_LINK"><refmeta><refentrytitle>Macro BOOST_CONTRACT_DYN_LINK</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_DYN_LINK</refname><refpurpose>Define this macro to compile this library as a shared library (recommended). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14520
14521 </phrase>BOOST_CONTRACT_DYN_LINK</synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14522 </warning>
14523 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.getting_started"> Getting Started</link> </para>
14524 </para>
14525 </para></refsect1></refentry>
14526 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_STATIC_LINK"><refmeta><refentrytitle>Macro BOOST_CONTRACT_STATIC_LINK</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_STATIC_LINK</refname><refpurpose>Define this macro to compile this library as a static library (not recommended). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14527
14528 </phrase>BOOST_CONTRACT_STATIC_LINK</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</link></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>
14529 </warning>
14530 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.getting_started"> Getting Started</link> </para>
14531 </para>
14532 </para></refsect1></refentry>
14533 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_HEADER_ONLY"><refmeta><refentrytitle>Macro BOOST_CONTRACT_HEADER_ONLY</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_HEADER_ONLY</refname><refpurpose>Automatically defined by this library when it is being used as a header-only library (not recommended). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14534
14535 </phrase>BOOST_CONTRACT_HEADER_ONLY</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</link></computeroutput> (or <computeroutput>BOOST_ALL_DYN_LINK</computeroutput>) and  <computeroutput><link linkend="BOOST_CONTRACT_STATIC_LINK">BOOST_CONTRACT_STATIC_LINK</link></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><link linkend="BOOST_CONTRACT_DYN_LINK">BOOST_CONTRACT_DYN_LINK</link></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>
14536 </warning>
14537 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.getting_started"> Getting Started</link> </para>
14538 </para>
14539 </para></refsect1></refentry>
14540 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999743888"><refmeta><refentrytitle>Macro BOOST_CONTRACT_DISABLE_THREADS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_DISABLE_THREADS</refname><refpurpose>Define this macro to not lock internal library data for thread safety (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14541
14542 </phrase>BOOST_CONTRACT_DISABLE_THREADS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14543 </note>
14544 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.contract_programming_overview.assertions"> Assertions</link> </para>
14545 </para>
14546 </para></refsect1></refentry>
14547 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_MAX_ARGS"><refmeta><refentrytitle>Macro BOOST_CONTRACT_MAX_ARGS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_MAX_ARGS</refname><refpurpose>Maximum number of arguments for public function overrides on compilers that do not support variadic templates (default to <computeroutput>10</computeroutput>). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14548
14549 </phrase>BOOST_CONTRACT_MAX_ARGS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></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>
14550 </note>
14551 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.no_macros__and_no_variadic_macros_"> No Macros</link> </para>
14552 </para>
14553 </para></refsect1></refentry>
14554 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999732400"><refmeta><refentrytitle>Macro BOOST_CONTRACT_BASES_TYPEDEF</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_BASES_TYPEDEF</refname><refpurpose>Define the name of the base type <computeroutput>typedef</computeroutput> (<computeroutput>base_types</computeroutput> by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14555
14556 </phrase>BOOST_CONTRACT_BASES_TYPEDEF</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This macro expands to the name of the <computeroutput>typedef</computeroutput> that lists the base classes for subcontracting via <computeroutput><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput>:</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
14557     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">w</phrase>
14558     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
14559 <phrase role="special">{</phrase>
14560     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">:</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
14561
14562     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">BOOST_CONTRACT_TYPEDEF</phrase><phrase role="special">;</phrase>
14563     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
14564
14565     <phrase role="special">...</phrase>
14566 <phrase role="special">}</phrase><phrase role="special">;</phrase>
14567 </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>
14568 </para>
14569 </para></refsect1></refentry>
14570 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999724496"><refmeta><refentrytitle>Macro BOOST_CONTRACT_INVARIANT_FUNC</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_INVARIANT_FUNC</refname><refpurpose>Define the name of the class invariant member function (<computeroutput>invariant</computeroutput> by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14571
14572 </phrase>BOOST_CONTRACT_INVARIANT_FUNC</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
14573     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
14574
14575     <phrase role="keyword">void</phrase> <phrase role="identifier">BOOST_CONTRACT_INVARIANT_FUNC</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
14576         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14577         <phrase role="special">...</phrase>
14578     <phrase role="special">}</phrase>
14579     
14580     <phrase role="keyword">void</phrase> <phrase role="identifier">BOOST_CONTRACT_INVARIANT_FUNC</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> <phrase role="special">{</phrase>
14581         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14582         <phrase role="special">...</phrase>
14583     <phrase role="special">}</phrase>
14584
14585     <phrase role="special">...</phrase>
14586 <phrase role="special">}</phrase><phrase role="special">;</phrase>
14587 </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><link linkend="BOOST_CO_idm45394999714768">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</link></computeroutput>.</para>
14588 </note>
14589 <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">
14590         Volatile Public Functions</link> </para>
14591 </para>
14592 </para></refsect1></refentry>
14593 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999714768"><refmeta><refentrytitle>Macro BOOST_CONTRACT_STATIC_INVARIANT_FUNC</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_STATIC_INVARIANT_FUNC</refname><refpurpose>Define the name of the static invariant member function (<computeroutput>static_invariant</computeroutput> by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14594
14595 </phrase>BOOST_CONTRACT_STATIC_INVARIANT_FUNC</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This macro expands to the name of the <computeroutput>static</computeroutput> member function that checks static class invariants:</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
14596     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
14597
14598     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
14599         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14600         <phrase role="special">...</phrase>
14601     <phrase role="special">}</phrase>
14602
14603     <phrase role="special">...</phrase>
14604 <phrase role="special">}</phrase><phrase role="special">;</phrase>
14605 </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><link linkend="BOOST_CO_idm45394999724496">BOOST_CONTRACT_INVARIANT_FUNC</link></computeroutput>.</para>
14606 </note>
14607 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link> </para>
14608 </para>
14609 </para></refsect1></refentry>
14610 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_PERMISSIVE"><refmeta><refentrytitle>Macro BOOST_CONTRACT_PERMISSIVE</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_PERMISSIVE</refname><refpurpose>Disable some compile-time errors generated by this library (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14611
14612 </phrase>BOOST_CONTRACT_PERMISSIVE</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Defining this macro disables a number of static checks and related compile-time errors generated by this library, for example:</para><para><itemizedlist>
14613 <listitem><para>The static invariant member function named as <computeroutput>BOOST_CONTRACT_STATIC_INVARIANT_FUNC</computeroutput> must be declared <computeroutput>static</computeroutput>. </para>
14614 </listitem>
14615 <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>
14616 </listitem>
14617 <listitem><para>Derived classes that program contracts for one or more public function overrides via <computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput> must also define the <computeroutput><link linkend="BOOST_CONTRACT_BASE_TYPES">BOOST_CONTRACT_BASE_TYPES</link></computeroutput> <computeroutput>typedef</computeroutput>.</para>
14618 </listitem>
14619 </itemizedlist>
14620 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>
14621 </para>
14622 </para></refsect1></refentry>
14623 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999694064"><refmeta><refentrytitle>Macro BOOST_CONTRACT_ON_MISSING_CHECK_DECL</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_ON_MISSING_CHECK_DECL</refname><refpurpose>Code block to execute if contracts are not assigned to a  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></computeroutput> variable (undefined and executes <computeroutput>BOOST_ASSERT(false)</computeroutput> by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14624
14625 </phrase>BOOST_CONTRACT_ON_MISSING_CHECK_DECL</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>In general, there is a logic error in the program when contracts are not explicitly assigned to a local variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><phrase role="identifier">gcc</phrase> <phrase role="special">-</phrase><phrase role="identifier">DBOOST_CONTRACT_ON_MISSING_CHECK_DECL</phrase><phrase role="special">=</phrase><phrase role="char">'{ throw std::logic_error("missing contract check declaration"); }'</phrase> <phrase role="special">...</phrase>
14626 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial"> Tutorial</link> </para>
14627 </para>
14628 </para></refsect1></refentry>
14629 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999685184"><refmeta><refentrytitle>Macro BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</refname><refpurpose>Define this macro to not disable other assertions while checking preconditions (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14630
14631 </phrase>BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</synopsis></refsynopsisdiv><refsect1><title>Description</title><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">
14632         Feature Summary</link> </para>
14633 </para>
14634 </para></refsect1></refentry>
14635 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999679376"><refmeta><refentrytitle>Macro BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION</refname><refpurpose>Define this macro to not disable any assertion while checking other assertions (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14636
14637 </phrase>BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999685184">BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION</link></computeroutput> was also defined.)</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.contract_programming_overview.feature_summary">
14638         Feature Summary</link> </para>
14639 </para>
14640 </para></refsect1></refentry>
14641 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_AUDITS"><refmeta><refentrytitle>Macro BOOST_CONTRACT_AUDITS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_AUDITS</refname><refpurpose>Define this macro to evaluate and check audit assertions at run-time (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14642
14643 </phrase>BOOST_CONTRACT_AUDITS</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Audit assertions and implementation checks programmed via  <computeroutput><link linkend="BOOST_CO_idm45395000817520">BOOST_CONTRACT_ASSERT_AUDIT</link></computeroutput> and  <computeroutput><link linkend="BOOST_CONTRACT_CHECK_AUDIT">BOOST_CONTRACT_CHECK_AUDIT</link></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>
14644 </para>
14645 </para></refsect1></refentry>
14646 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_NO_CHECKS"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_CHECKS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_CHECKS</refname><refpurpose>If defined, this library disables implementation checks (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14647
14648 </phrase>BOOST_CONTRACT_NO_CHECKS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CONTRACT_CHECK">BOOST_CONTRACT_CHECK</link></computeroutput> (recommended).</para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.advanced.implementation_checks">
14649         Implementation Checks</link>,  <link linkend="boost_contract.extras.disable_contract_checking">
14650         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14651         Disable Contract Compilation</link> </para>
14652 </para>
14653 </para></refsect1></refentry>
14654 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999662416"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_PRECONDITIONS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_PRECONDITIONS</refname><refpurpose>If defined, this library does not check preconditions (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14655
14656 </phrase>BOOST_CONTRACT_NO_PRECONDITIONS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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">
14657         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14658         Disable Contract Compilation</link> </para>
14659 </para>
14660 </para></refsect1></refentry>
14661 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999656032"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_POSTCONDITIONS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_POSTCONDITIONS</refname><refpurpose>If defined, this library does not check postconditions (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14662
14663 </phrase>BOOST_CONTRACT_NO_POSTCONDITIONS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput> and  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput> in order to disable old value copies (see <computeroutput><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></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">
14664         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14665         Disable Contract Compilation</link> </para>
14666 </para>
14667 </para></refsect1></refentry>
14668 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_NO_EXCEPTS"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_EXCEPTS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_EXCEPTS</refname><refpurpose>If defined, this library does not check exception guarantees (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14669
14670 </phrase>BOOST_CONTRACT_NO_EXCEPTS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput> and  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput> in order to disable old value copies (see <computeroutput><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></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">
14671         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14672         Disable Contract Compilation</link> </para>
14673 </para>
14674 </para></refsect1></refentry>
14675 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999637264"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_ENTRY_INVARIANTS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_ENTRY_INVARIANTS</refname><refpurpose>If defined, this library does not check class invariants at entry (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14676
14677 </phrase>BOOST_CONTRACT_NO_ENTRY_INVARIANTS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></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">
14678         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14679         Disable Contract Compilation</link> </para>
14680 </para>
14681 </para></refsect1></refentry>
14682 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999629648"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_EXIT_INVARIANTS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_EXIT_INVARIANTS</refname><refpurpose>If defined, this library does not check class invariants at exit (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14683
14684 </phrase>BOOST_CONTRACT_NO_EXIT_INVARIANTS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></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">
14685         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14686         Disable Contract Compilation</link> </para>
14687 </para>
14688 </para></refsect1></refentry>
14689 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999622032"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_INVARIANTS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_INVARIANTS</refname><refpurpose>If defined, this library does not check class invariants (undefined by default). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14690
14691 </phrase>BOOST_CONTRACT_NO_INVARIANTS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999637264">BOOST_CONTRACT_NO_ENTRY_INVARIANTS</link></computeroutput> and  <computeroutput><link linkend="BOOST_CO_idm45394999629648">BOOST_CONTRACT_NO_EXIT_INVARIANTS</link></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">
14692         Disable Contract Checking</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14693         Disable Contract Compilation</link> </para>
14694 </para>
14695 </para></refsect1></refentry>
14696 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_NO_OLDS"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_OLDS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_OLDS</refname><refpurpose>Automatically defined by this library when old value copies are not to be performed. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14697
14698 </phrase>BOOST_CONTRACT_NO_OLDS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput> and  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></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">
14699         Old Values Copied at Body</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14700         Disable Contract Compilation</link> </para>
14701 </para>
14702 </para></refsect1></refentry>
14703 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999605408"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_CONSTRUCTORS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_CONSTRUCTORS</refname><refpurpose>Automatically defined by this library when contracts are not checked for constructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14704
14705 </phrase>BOOST_CONTRACT_NO_CONSTRUCTORS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></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><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput> so they are disabled by <computeroutput><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput> instead.</para>
14706 </note>
14707 <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_">
14708         Disable Contract Compilation</link> </para>
14709 </para>
14710 </para></refsect1></refentry>
14711 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999594544"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_DESTRUCTORS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_DESTRUCTORS</refname><refpurpose>Automatically defined by this library when contracts are not checked for destructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14712
14713 </phrase>BOOST_CONTRACT_NO_DESTRUCTORS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></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_">
14714         Disable Contract Compilation</link> </para>
14715 </para>
14716 </para></refsect1></refentry>
14717 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999586272"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</refname><refpurpose>Automatically defined by this library when contracts are not checked for public functions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14718
14719 </phrase>BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></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_">
14720         Disable Contract Compilation</link> </para>
14721 </para>
14722 </para></refsect1></refentry>
14723 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999577072"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_FUNCTIONS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_FUNCTIONS</refname><refpurpose>Automatically defined by this library when contracts are not checked for non-member, private, or protected functions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14724
14725 </phrase>BOOST_CONTRACT_NO_FUNCTIONS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></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">
14726         Private and Protected Functions</link>,  <link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">
14727         Lambdas, Loops, Code Blocks</link>,  <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
14728         Disable Contract Compilation</link> </para>
14729 </para>
14730 </para></refsect1></refentry>
14731 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394999566736"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_CONDITIONS</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_CONDITIONS</refname><refpurpose>Automatically defined by this library when contracts are not checked for preconditions, postconditions, exceptions guarantees, and class invariants (excluding implementation checks). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14732
14733 </phrase>BOOST_CONTRACT_NO_CONDITIONS</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></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_">
14734         Disable Contract Compilation</link> </para>
14735 </para>
14736 </para></refsect1></refentry>
14737 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_NO_ALL"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NO_ALL</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NO_ALL</refname><refpurpose>Automatically defined by this library when contracts are not checked at all (neither for specifications nor for implementations). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.config_hpp">boost/contract/core/config.hpp</link>&gt;
14738
14739 </phrase>BOOST_CONTRACT_NO_ALL</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput>,  <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CONTRACT_NO_CHECKS">BOOST_CONTRACT_NO_CHECKS</link></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><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">/</phrase><phrase role="identifier">core</phrase><phrase role="special">/</phrase><phrase role="identifier">config</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
14740 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_ALL</phrase>
14741     <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">contract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
14742 <phrase role="preprocessor">#endif</phrase>
14743 </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_">
14744         Disable Contract Compilation</link> </para>
14745 </para>
14746 </para></refsect1></refentry>
14747 </section>
14748 <section id="header.boost.contract.core.constructor_precondition_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/core/constructor_precondition.hpp">boost/contract/core/constructor_precondition.hpp</ulink>&gt;</title><para>Program preconditions for constructors. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
14749   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
14750     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <link linkend="boost.contract.constructor_precondition">constructor_precondition</link><phrase role="special">;</phrase>
14751   <phrase role="special">}</phrase>
14752 <phrase role="special">}</phrase></synopsis>
14753 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.constructor_precondition"><refmeta><refentrytitle>Class template constructor_precondition</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::constructor_precondition</refname><refpurpose>Program preconditions for constructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.constructor_precondition_hpp">boost/contract/core/constructor_precondition.hpp</link>&gt;
14754
14755 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
14756 <phrase role="keyword">class</phrase> <link linkend="boost.contract.constructor_precondition">constructor_precondition</link> <phrase role="special">{</phrase>
14757 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14758   <phrase role="comment">// <link linkend="boost.contract.constructor_preconditionconstruct-copy-destruct">construct/copy/destruct</link></phrase>
14759   <link linkend="idm45394999534384-bb"><phrase role="identifier">constructor_precondition</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14760   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <phrase role="keyword">explicit</phrase> <link linkend="idm45394999532192-bb"><phrase role="identifier">constructor_precondition</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14761 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
14762     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase><phrase role="special">,</phrase> \
14763             <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase>
14764     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
14765 <phrase role="special">{</phrase>
14766     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
14767
14768     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
14769     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
14770
14771 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14772     <phrase role="keyword">explicit</phrase> <phrase role="identifier">u</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
14773         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase>
14774             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">!=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14775             <phrase role="special">...</phrase>
14776         <phrase role="special">}</phrase><phrase role="special">)</phrase><phrase role="special">,</phrase>
14777         <phrase role="identifier">b</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">.</phrase><phrase role="number">0</phrase> <phrase role="special">/</phrase> <phrase role="keyword">float</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">)</phrase><phrase role="special">)</phrase>
14778     <phrase role="special">{</phrase>
14779         <phrase role="special">...</phrase>
14780     <phrase role="special">}</phrase>
14781
14782     <phrase role="special">...</phrase>
14783 <phrase role="special">}</phrase><phrase role="special">;</phrase>
14784 </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><link linkend="boost.contract.constructor">boost::contract::constructor</link></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>
14785 </para>
14786
14787 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> Class</literallayout></para><para><para>The class type of the constructor for which preconditions are being programmed. </para></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.constructor_preconditionconstruct-copy-destruct"/><computeroutput>constructor_precondition</computeroutput> 
14788         public
14789        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999534384-bb"/><phrase role="identifier">constructor_precondition</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object without specifying constructor preconditions. <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>
14790 </note>
14791 </para></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <phrase role="keyword">explicit</phrase> <anchor id="idm45394999532192-bb"/><phrase role="identifier">constructor_precondition</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object specifying constructor preconditions. <para>
14792 </para><variablelist spacing="compact"><?dbhtml 
14793           list-presentation="table"
14794         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14795                   list-presentation="table"
14796                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>Nullary functor called by this library to check constructor preconditions <computeroutput>f()</computeroutput>. Assertions within this functor call are usually programmed using <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput></computeroutput>). This functor should capture variables by (constant) value, or better by (constant) reference to avoid extra copies. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry>
14797 </section>
14798 <section id="header.boost.contract.core.exception_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/core/exception.hpp">boost/contract/core/exception.hpp</ulink>&gt;</title><para>Handle contract assertion failures. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
14799   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
14800     <phrase role="keyword">class</phrase> <link linkend="boost.contract.assertion_failure">assertion_failure</link><phrase role="special">;</phrase>
14801     <phrase role="keyword">class</phrase> <link linkend="boost.contract.bad_virtual_result_cast">bad_virtual_result_cast</link><phrase role="special">;</phrase>
14802     <phrase role="keyword">class</phrase> <link linkend="boost.contract.exception">exception</link><phrase role="special">;</phrase>
14803
14804     <phrase role="keyword">enum</phrase> <link linkend="boost.contract.from">from</link><phrase role="special">;</phrase>
14805     <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">&gt;</phrase> <link linkend="boost.contract.from_failure_handler"><phrase role="identifier">from_failure_handler</phrase></link><phrase role="special">;</phrase>
14806     <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">&gt;</phrase> <link linkend="boost.contract.failure_handler"><phrase role="identifier">failure_handler</phrase></link><phrase role="special">;</phrase>
14807     <phrase role="identifier">failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <link linkend="boost.contract.set_check_failure"><phrase role="identifier">set_check_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14808     <phrase role="identifier">failure_handler</phrase> <link linkend="boost.contract.get_check_failure"><phrase role="identifier">get_check_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14809     <phrase role="keyword">void</phrase> <link linkend="boost.contract.check_failure"><phrase role="identifier">check_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14810     <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14811     <link linkend="boost.contract.set_precondition_failure"><phrase role="identifier">set_precondition_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14812     <phrase role="identifier">from_failure_handler</phrase> <link linkend="boost.contract.get_precondition_failure"><phrase role="identifier">get_precondition_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14813     <phrase role="keyword">void</phrase> <link linkend="boost.contract.precondition_failure"><phrase role="identifier">precondition_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14814     <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14815     <link linkend="boost.contract.set_postcondition_failure"><phrase role="identifier">set_postcondition_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14816     <phrase role="identifier">from_failure_handler</phrase> <link linkend="boost.contract.get_postcondition_failure"><phrase role="identifier">get_postcondition_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14817     <phrase role="keyword">void</phrase> <link linkend="boost.contract.postcondition_failure"><phrase role="identifier">postcondition_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14818     <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14819     <link linkend="boost.contract.set_except_failure"><phrase role="identifier">set_except_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14820     <phrase role="identifier">from_failure_handler</phrase> <link linkend="boost.contract.get_except_failure"><phrase role="identifier">get_except_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14821     <phrase role="keyword">void</phrase> <link linkend="boost.contract.except_failure"><phrase role="identifier">except_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14822     <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14823     <link linkend="boost.contract.set_old_failure"><phrase role="identifier">set_old_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14824     <phrase role="identifier">from_failure_handler</phrase> <link linkend="boost.contract.get_old_failure"><phrase role="identifier">get_old_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14825     <phrase role="keyword">void</phrase> <link linkend="boost.contract.old_failure"><phrase role="identifier">old_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14826     <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14827     <link linkend="boost.contract.set_entr_idm45394999333872"><phrase role="identifier">set_entry_invariant_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14828     <phrase role="identifier">from_failure_handler</phrase> <link linkend="boost.contract.get_entr_idm45394999324384"><phrase role="identifier">get_entry_invariant_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14829     <phrase role="keyword">void</phrase> <link linkend="boost.contract.entry_invariant_failure"><phrase role="identifier">entry_invariant_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14830     <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14831     <link linkend="boost.contract.set_exit_invariant_failure"><phrase role="identifier">set_exit_invariant_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14832     <phrase role="identifier">from_failure_handler</phrase> <link linkend="boost.contract.get_exit_invariant_failure"><phrase role="identifier">get_exit_invariant_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14833     <phrase role="keyword">void</phrase> <link linkend="boost.contract.exit_invariant_failure"><phrase role="identifier">exit_invariant_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14834     <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14835     <link linkend="boost.contract.set_invariant_failure"><phrase role="identifier">set_invariant_failure</phrase></link><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14836   <phrase role="special">}</phrase>
14837 <phrase role="special">}</phrase></synopsis>
14838 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.assertion_failure"><refmeta><refentrytitle>Class assertion_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::assertion_failure</refname><refpurpose>Exception typically used to report a contract assertion failure. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14839
14840 </phrase>
14841 <phrase role="keyword">class</phrase> <link linkend="boost.contract.assertion_failure">assertion_failure</link> <phrase role="special">:</phrase>
14842   <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase>, <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase>
14843 <phrase role="special">{</phrase>
14844 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14845   <phrase role="comment">// <link linkend="boost.contract.assertion_failureconstruct-copy-destruct">construct/copy/destruct</link></phrase>
14846   <phrase role="keyword">explicit</phrase> <link linkend="idm45394999500624-bb"><phrase role="identifier">assertion_failure</phrase></link><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="string">""</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">,</phrase> 
14847                              <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="string">""</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14848   <phrase role="keyword">explicit</phrase> <link linkend="idm45394999493584-bb"><phrase role="identifier">assertion_failure</phrase></link><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14849   <link linkend="idm45394999491104-bb"><phrase role="special">~</phrase><phrase role="identifier">assertion_failure</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14850
14851   <phrase role="comment">// <link linkend="idm45394999515280-bb">public member functions</link></phrase>
14852   <phrase role="keyword">virtual</phrase> <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <link linkend="idm45394999514720-bb"><phrase role="identifier">what</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14853   <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <link linkend="idm45394999509616-bb"><phrase role="identifier">file</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14854   <phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> <link linkend="idm45394999506688-bb"><phrase role="identifier">line</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14855   <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <link linkend="idm45394999503760-bb"><phrase role="identifier">code</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14856 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This exception is thrown by code expanded by <computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></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><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></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>
14857 </para>
14858 </para><refsect2><title><anchor id="boost.contract.assertion_failureconstruct-copy-destruct"/><computeroutput>assertion_failure</computeroutput> 
14859         public
14860        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45394999500624-bb"/><phrase role="identifier">assertion_failure</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase> file <phrase role="special">=</phrase> <phrase role="string">""</phrase><phrase role="special">,</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> line <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">,</phrase> 
14861                            <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase> code <phrase role="special">=</phrase> <phrase role="string">""</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object with file name, line number, and source code text of an assertion condition (all optional). <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>
14862 </para><variablelist spacing="compact"><?dbhtml 
14863           list-presentation="table"
14864         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14865                   list-presentation="table"
14866                 ?><varlistentry><term><computeroutput>code</computeroutput></term><listitem><para>Text listing the source code of the assertion condition. </para></listitem></varlistentry><varlistentry><term><computeroutput>file</computeroutput></term><listitem><para>Name of the file containing the assertion (usually set using <computeroutput>__FILE__</computeroutput>). </para></listitem></varlistentry><varlistentry><term><computeroutput>line</computeroutput></term><listitem><para>Number of the line containing the assertion (usually set using <computeroutput>__LINE__</computeroutput>). </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45394999493584-bb"/><phrase role="identifier">assertion_failure</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase> code<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object only with the source code text of the assertion condition. <para>
14867 </para><variablelist spacing="compact"><?dbhtml 
14868           list-presentation="table"
14869         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14870                   list-presentation="table"
14871                 ?><varlistentry><term><computeroutput>code</computeroutput></term><listitem><para>Text listing the source code of the assertion condition. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="idm45394999491104-bb"/><phrase role="special">~</phrase><phrase role="identifier">assertion_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999515280-bb"/><computeroutput>assertion_failure</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">virtual</phrase> <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <anchor id="idm45394999514720-bb"/><phrase role="identifier">what</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>String describing the failed assertion. <para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11).</para><para>
14872 </para><variablelist spacing="compact"><?dbhtml 
14873           list-presentation="table"
14874         ?><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <anchor id="idm45394999509616-bb"/><phrase role="identifier">file</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Name of the file containing the assertion. <para>
14875 </para><variablelist spacing="compact"><?dbhtml 
14876           list-presentation="table"
14877         ?><varlistentry><term>Returns:</term><listitem><para>File name as specified at construction (or <computeroutput>""</computeroutput> if no file was specified). </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> <anchor id="idm45394999506688-bb"/><phrase role="identifier">line</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Number of the line containing the assertion. <para>
14878 </para><variablelist spacing="compact"><?dbhtml 
14879           list-presentation="table"
14880         ?><varlistentry><term>Returns:</term><listitem><para>Line number as specified at construction (or <computeroutput>0</computeroutput> if no line number was specified). </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <anchor id="idm45394999503760-bb"/><phrase role="identifier">code</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Text listing the source code of the assertion condition. <para>
14881 </para><variablelist spacing="compact"><?dbhtml 
14882           list-presentation="table"
14883         ?><varlistentry><term>Returns:</term><listitem><para>Assertion condition source code as specified at construction (or <computeroutput>""</computeroutput> if no source code text was specified). </para></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.bad_virtual_result_cast"><refmeta><refentrytitle>Class bad_virtual_result_cast</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::bad_virtual_result_cast</refname><refpurpose>Exception thrown when inconsistent return values are passed to overridden virtual public functions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14884
14885 </phrase>
14886 <phrase role="keyword">class</phrase> <link linkend="boost.contract.bad_virtual_result_cast">bad_virtual_result_cast</link> <phrase role="special">:</phrase>
14887   <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bad_cast</phrase>, <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase>
14888 <phrase role="special">{</phrase>
14889 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14890   <phrase role="comment">// <link linkend="boost.contract.bad_virtual_result_castconstruct-copy-destruct">construct/copy/destruct</link></phrase>
14891   <phrase role="keyword">explicit</phrase> <link linkend="idm45394999479088-bb"><phrase role="identifier">bad_virtual_result_cast</phrase></link><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14892   <link linkend="idm45394999475504-bb"><phrase role="special">~</phrase><phrase role="identifier">bad_virtual_result_cast</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14893
14894   <phrase role="comment">// <link linkend="idm45394999483408-bb">public member functions</link></phrase>
14895   <phrase role="keyword">virtual</phrase> <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <link linkend="idm45394999482848-bb"><phrase role="identifier">what</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
14896 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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_">
14897         Public Function Overrides</link> </para>
14898 </para>
14899 </para><refsect2><title><anchor id="boost.contract.bad_virtual_result_castconstruct-copy-destruct"/><computeroutput>bad_virtual_result_cast</computeroutput> 
14900         public
14901        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45394999479088-bb"/><phrase role="identifier">bad_virtual_result_cast</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase> from_type_name<phrase role="special">,</phrase> 
14902                                  <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="special">*</phrase> to_type_name<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object with the name of the from- and to- result types. <para>
14903 </para><variablelist spacing="compact"><?dbhtml 
14904           list-presentation="table"
14905         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14906                   list-presentation="table"
14907                 ?><varlistentry><term><computeroutput>from_type_name</computeroutput></term><listitem><para>Name of the from-type (source of the cast). </para></listitem></varlistentry><varlistentry><term><computeroutput>to_type_name</computeroutput></term><listitem><para>Name of the to-type (destination of the cast). </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="idm45394999475504-bb"/><phrase role="special">~</phrase><phrase role="identifier">bad_virtual_result_cast</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999483408-bb"/><computeroutput>bad_virtual_result_cast</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">virtual</phrase> <phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <anchor id="idm45394999482848-bb"/><phrase role="identifier">what</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Description for this error (containing both from- and to- type names). <para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.exception"><refmeta><refentrytitle>Class exception</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::exception</refname><refpurpose>Public base class for all exceptions directly thrown by this library. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14908
14909 </phrase>
14910 <phrase role="keyword">class</phrase> <link linkend="boost.contract.exception">exception</link> <phrase role="special">{</phrase>
14911 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
14912   <phrase role="comment">// <link linkend="boost.contract.exceptionconstruct-copy-destruct">construct/copy/destruct</link></phrase>
14913   <link linkend="idm45394999466544-bb"><phrase role="special">~</phrase><phrase role="identifier">exception</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
14914 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.assertion_failure">boost::contract::assertion_failure</link></computeroutput>,  <computeroutput><link linkend="boost.contract.bad_virtual_result_cast">boost::contract::bad_virtual_result_cast</link></computeroutput>, etc. </para>
14915 </para>
14916 </para><refsect2><title><anchor id="boost.contract.exceptionconstruct-copy-destruct"/><computeroutput>exception</computeroutput> 
14917         public
14918        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999466544-bb"/><phrase role="special">~</phrase><phrase role="identifier">exception</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <para><emphasis role="bold">Throws:</emphasis> This is declared <computeroutput>noexcept</computeroutput> (or <computeroutput>throw()</computeroutput> before C++11). </para></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.from"><refmeta><refentrytitle>Type from</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::from</refname><refpurpose>Indicate the kind of operation where the contract assertion failed. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14919
14920 </phrase>
14921
14922 <phrase role="keyword">enum</phrase> <phrase role="identifier">from</phrase> <phrase role="special">{</phrase> <link linkend="boost.contract.from.from_constructor">from_constructor</link>, <link linkend="boost.contract.from.from_destructor">from_destructor</link>, <link linkend="boost.contract.from.from_function">from_function</link> <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14923 </para>
14924 </para><variablelist spacing="compact"><varlistentry><term><computeroutput>from_constructor</computeroutput><anchor id="boost.contract.from.from_constructor"/></term><listitem>Assertion failed when checking contracts for constructors. </listitem></varlistentry><varlistentry><term><computeroutput>from_destructor</computeroutput><anchor id="boost.contract.from.from_destructor"/></term><listitem>Assertion failed when checking contracts for destructors . </listitem></varlistentry><varlistentry><term><computeroutput>from_function</computeroutput><anchor id="boost.contract.from.from_function"/></term><listitem>Assertion failed when checking contracts for functions (members or not, public or not). </listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.from_failure_handler"><refmeta><refentrytitle>Type definition from_failure_handler</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>from_failure_handler</refname><refpurpose>Type of assertion failure handler functions (with <computeroutput>from</computeroutput> parameter). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14925
14926 </phrase>
14927 <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase><phrase role="special">)</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">from_failure_handler</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Assertion failure handler functions specified by this type must be functors returning <computeroutput>void</computeroutput> and taking a single parameter of type  <computeroutput><link linkend="boost.contract.from">boost::contract::from</link></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>
14928 </para>
14929 </para></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.failure_handler"><refmeta><refentrytitle>Type definition failure_handler</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>failure_handler</refname><refpurpose>Type of assertion failure handler functions (without <computeroutput>from</computeroutput> parameter). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14930
14931 </phrase>
14932 <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">failure_handler</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14933 </para>
14934 </para></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_check_failure"><refmeta><refentrytitle>Function set_check_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_check_failure</refname><refpurpose>Set failure handler for implementation checks. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14935
14936 </phrase>
14937 <phrase role="identifier">failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <phrase role="identifier">set_check_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14938
14939 <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>
14940 </para>
14941 </para><variablelist spacing="compact"><?dbhtml 
14942           list-presentation="table"
14943         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14944                   list-presentation="table"
14945                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.get_check_failure"><refmeta><refentrytitle>Function get_check_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::get_check_failure</refname><refpurpose>Return failure handler currently set for implementation checks. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14946
14947 </phrase>
14948 <phrase role="identifier">failure_handler</phrase> <phrase role="identifier">get_check_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14949 <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>
14950 </para>
14951 </para><variablelist spacing="compact"><?dbhtml 
14952           list-presentation="table"
14953         ?><varlistentry><term>Returns:</term><listitem><para>A copy of the failure handler currently set.</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.check_failure"><refmeta><refentrytitle>Function check_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::check_failure</refname><refpurpose>Call failure handler for implementation checks. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14954
14955 </phrase>
14956 <phrase role="keyword">void</phrase> <phrase role="identifier">check_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14957 </para>
14958 </para></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_precondition_failure"><refmeta><refentrytitle>Function set_precondition_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_precondition_failure</refname><refpurpose>Set failure handler for preconditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14959
14960 </phrase>
14961 <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14962 <phrase role="identifier">set_precondition_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14963
14964 <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>
14965 </para>
14966 </para><variablelist spacing="compact"><?dbhtml 
14967           list-presentation="table"
14968         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14969                   list-presentation="table"
14970                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.get_precondition_failure"><refmeta><refentrytitle>Function get_precondition_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::get_precondition_failure</refname><refpurpose>Return failure handler currently set for preconditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14971
14972 </phrase>
14973 <phrase role="identifier">from_failure_handler</phrase> <phrase role="identifier">get_precondition_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14974 <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>
14975 </para>
14976 </para><variablelist spacing="compact"><?dbhtml 
14977           list-presentation="table"
14978         ?><varlistentry><term>Returns:</term><listitem><para>A copy of the failure handler currently set.</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.precondition_failure"><refmeta><refentrytitle>Function precondition_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::precondition_failure</refname><refpurpose>Call failure handler for preconditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14979
14980 </phrase>
14981 <phrase role="keyword">void</phrase> <phrase role="identifier">precondition_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> where<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14982 <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>
14983 </para>
14984 </para><variablelist spacing="compact"><?dbhtml 
14985           list-presentation="table"
14986         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14987                   list-presentation="table"
14988                 ?><varlistentry><term><computeroutput>where</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_postcondition_failure"><refmeta><refentrytitle>Function set_postcondition_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_postcondition_failure</refname><refpurpose>Set failure handler for postconditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
14989
14990 </phrase>
14991 <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
14992 <phrase role="identifier">set_postcondition_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
14993
14994 <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>
14995 </para>
14996 </para><variablelist spacing="compact"><?dbhtml 
14997           list-presentation="table"
14998         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
14999                   list-presentation="table"
15000                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.get_postcondition_failure"><refmeta><refentrytitle>Function get_postcondition_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::get_postcondition_failure</refname><refpurpose>Return failure handler currently set for postconditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15001
15002 </phrase>
15003 <phrase role="identifier">from_failure_handler</phrase> <phrase role="identifier">get_postcondition_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15004 <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>
15005 </para>
15006 </para><variablelist spacing="compact"><?dbhtml 
15007           list-presentation="table"
15008         ?><varlistentry><term>Returns:</term><listitem><para>A copy of the failure handler currently set.</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.postcondition_failure"><refmeta><refentrytitle>Function postcondition_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::postcondition_failure</refname><refpurpose>Call failure handler for postconditions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15009
15010 </phrase>
15011 <phrase role="keyword">void</phrase> <phrase role="identifier">postcondition_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> where<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15012 <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>
15013 </para>
15014 </para><variablelist spacing="compact"><?dbhtml 
15015           list-presentation="table"
15016         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15017                   list-presentation="table"
15018                 ?><varlistentry><term><computeroutput>where</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_except_failure"><refmeta><refentrytitle>Function set_except_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_except_failure</refname><refpurpose>Set failure handler for exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15019
15020 </phrase>
15021 <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
15022 <phrase role="identifier">set_except_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15023
15024 <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>
15025 </para>
15026 </para><variablelist spacing="compact"><?dbhtml 
15027           list-presentation="table"
15028         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15029                   list-presentation="table"
15030                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.get_except_failure"><refmeta><refentrytitle>Function get_except_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::get_except_failure</refname><refpurpose>Return failure handler currently set for exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15031
15032 </phrase>
15033 <phrase role="identifier">from_failure_handler</phrase> <phrase role="identifier">get_except_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15034 <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>
15035 </para>
15036 </para><variablelist spacing="compact"><?dbhtml 
15037           list-presentation="table"
15038         ?><varlistentry><term>Returns:</term><listitem><para>A copy of the failure handler currently set.</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.except_failure"><refmeta><refentrytitle>Function except_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::except_failure</refname><refpurpose>Call failure handler for exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15039
15040 </phrase>
15041 <phrase role="keyword">void</phrase> <phrase role="identifier">except_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> where<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15042 </warning>
15043
15044 <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>
15045 </para>
15046 </para><variablelist spacing="compact"><?dbhtml 
15047           list-presentation="table"
15048         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15049                   list-presentation="table"
15050                 ?><varlistentry><term><computeroutput>where</computeroutput></term><listitem><para>Operation that failed the contract assertion.</para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_old_failure"><refmeta><refentrytitle>Function set_old_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_old_failure</refname><refpurpose>Set failure handler for old values copied at body. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15051
15052 </phrase>
15053 <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <phrase role="identifier">set_old_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15054
15055 <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>
15056 </para>
15057 </para><variablelist spacing="compact"><?dbhtml 
15058           list-presentation="table"
15059         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15060                   list-presentation="table"
15061                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.get_old_failure"><refmeta><refentrytitle>Function get_old_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::get_old_failure</refname><refpurpose>Return failure handler currently set for old values copied at body. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15062
15063 </phrase>
15064 <phrase role="identifier">from_failure_handler</phrase> <phrase role="identifier">get_old_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15065 <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>
15066 </para>
15067 </para><variablelist spacing="compact"><?dbhtml 
15068           list-presentation="table"
15069         ?><varlistentry><term>Returns:</term><listitem><para>A copy of the failure handler currently set.</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.old_failure"><refmeta><refentrytitle>Function old_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::old_failure</refname><refpurpose>Call failure handler for old values copied at body. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15070
15071 </phrase>
15072 <phrase role="keyword">void</phrase> <phrase role="identifier">old_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> where<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15073 <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>
15074 </para>
15075 </para><variablelist spacing="compact"><?dbhtml 
15076           list-presentation="table"
15077         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15078                   list-presentation="table"
15079                 ?><varlistentry><term><computeroutput>where</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_entr_idm45394999333872"><refmeta><refentrytitle>Function set_entry_invariant_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_entry_invariant_failure</refname><refpurpose>Set failure handler for class invariants at entry. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15080
15081 </phrase>
15082 <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
15083 <phrase role="identifier">set_entry_invariant_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15084
15085 <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">
15086         Volatile Public Functions</link> </para>
15087 </para>
15088 </para><variablelist spacing="compact"><?dbhtml 
15089           list-presentation="table"
15090         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15091                   list-presentation="table"
15092                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.get_entr_idm45394999324384"><refmeta><refentrytitle>Function get_entry_invariant_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::get_entry_invariant_failure</refname><refpurpose>Return failure handler currently set for class invariants at entry. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15093
15094 </phrase>
15095 <phrase role="identifier">from_failure_handler</phrase> <phrase role="identifier">get_entry_invariant_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15096 <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">
15097         Volatile Public Functions</link> </para>
15098 </para>
15099 </para><variablelist spacing="compact"><?dbhtml 
15100           list-presentation="table"
15101         ?><varlistentry><term>Returns:</term><listitem><para>A copy of the failure handler currently set.</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.entry_invariant_failure"><refmeta><refentrytitle>Function entry_invariant_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::entry_invariant_failure</refname><refpurpose>Call failure handler for class invariants at entry. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15102
15103 </phrase>
15104 <phrase role="keyword">void</phrase> <phrase role="identifier">entry_invariant_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> where<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15105 <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">
15106         Volatile Public Functions</link> </para>
15107 </para>
15108 </para><variablelist spacing="compact"><?dbhtml 
15109           list-presentation="table"
15110         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15111                   list-presentation="table"
15112                 ?><varlistentry><term><computeroutput>where</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_exit_invariant_failure"><refmeta><refentrytitle>Function set_exit_invariant_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_exit_invariant_failure</refname><refpurpose>Set failure handler for class invariants at exit. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15113
15114 </phrase>
15115 <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
15116 <phrase role="identifier">set_exit_invariant_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15117
15118 <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">
15119         Volatile Public Functions</link> </para>
15120 </para>
15121 </para><variablelist spacing="compact"><?dbhtml 
15122           list-presentation="table"
15123         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15124                   list-presentation="table"
15125                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.get_exit_invariant_failure"><refmeta><refentrytitle>Function get_exit_invariant_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::get_exit_invariant_failure</refname><refpurpose>Return failure handler currently set for class invariants at exit. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15126
15127 </phrase>
15128 <phrase role="identifier">from_failure_handler</phrase> <phrase role="identifier">get_exit_invariant_failure</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15129 <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">
15130         Volatile Public Functions</link> </para>
15131 </para>
15132 </para><variablelist spacing="compact"><?dbhtml 
15133           list-presentation="table"
15134         ?><varlistentry><term>Returns:</term><listitem><para>A copy of the failure handler currently set.</para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.exit_invariant_failure"><refmeta><refentrytitle>Function exit_invariant_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::exit_invariant_failure</refname><refpurpose>Call failure handler for class invariants at exit. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15135
15136 </phrase>
15137 <phrase role="keyword">void</phrase> <phrase role="identifier">exit_invariant_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from</phrase> where<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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>
15138 <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">
15139         Volatile Public Functions</link> </para>
15140 </para>
15141 </para><variablelist spacing="compact"><?dbhtml 
15142           list-presentation="table"
15143         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15144                   list-presentation="table"
15145                 ?><varlistentry><term><computeroutput>where</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.set_invariant_failure"><refmeta><refentrytitle>Function set_invariant_failure</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::set_invariant_failure</refname><refpurpose>Set failure handler for class invariants (at both entry and exit). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.exception_hpp">boost/contract/core/exception.hpp</link>&gt;
15146
15147 </phrase>
15148 <phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> 
15149 <phrase role="identifier">set_invariant_failure</phrase><phrase role="special">(</phrase><phrase role="identifier">from_failure_handler</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is provided for convenience and it is equivalent to call both  <computeroutput><computeroutput><link linkend="boost.contract.set_entr_idm45394999333872">boost::contract::set_entry_invariant_failure</link></computeroutput></computeroutput> and  <computeroutput><computeroutput><link linkend="boost.contract.set_exit_invariant_failure">boost::contract::set_exit_invariant_failure</link></computeroutput></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>
15150
15151 <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">
15152         Volatile Public Functions</link> </para>
15153 </para>
15154 </para><variablelist spacing="compact"><?dbhtml 
15155           list-presentation="table"
15156         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15157                   list-presentation="table"
15158                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>New failure handler functor to set for both entry and exit invariants.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Same failure handler functor <computeroutput>f</computeroutput> passed as parameter (e.g., for concatenating function calls).</para></listitem></varlistentry></variablelist></refsect1></refentry>
15159 </section>
15160 <section id="header.boost.contract.core.specify_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/core/specify.hpp">boost/contract/core/specify.hpp</ulink>&gt;</title><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><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
15161   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
15162     <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify_except">specify_except</link><phrase role="special">;</phrase>
15163     <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link><phrase role="special">;</phrase>
15164     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase> 
15165       <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link><phrase role="special">;</phrase>
15166     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link><phrase role="special">;</phrase>
15167     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase> 
15168       <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link><phrase role="special">;</phrase>
15169   <phrase role="special">}</phrase>
15170 <phrase role="special">}</phrase></synopsis>
15171 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.specify_except"><refmeta><refentrytitle>Class specify_except</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::specify_except</refname><refpurpose>Allow to specify exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.specify_hpp">boost/contract/core/specify.hpp</link>&gt;
15172
15173 </phrase>
15174 <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify_except">specify_except</link> <phrase role="special">{</phrase>
15175 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15176   <phrase role="comment">// <link linkend="boost.contract.specify_exceptconstruct-copy-destruct">construct/copy/destruct</link></phrase>
15177   <link linkend="idm45394999256816-bb"><phrase role="special">~</phrase><phrase role="identifier">specify_except</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15178
15179   <phrase role="comment">// <link linkend="idm45394999264384-bb">public member functions</link></phrase>
15180   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <link linkend="idm45394999263824-bb"><phrase role="identifier">except</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15181 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.function">boost::contract::function</link></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>
15182 </para>
15183 </para><refsect2><title><anchor id="boost.contract.specify_exceptconstruct-copy-destruct"/><computeroutput>specify_except</computeroutput> 
15184         public
15185        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999256816-bb"/><phrase role="special">~</phrase><phrase role="identifier">specify_except</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <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__">
15186             Throw on Failure</link>). </para></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999264384-bb"/><computeroutput>specify_except</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <anchor id="idm45394999263824-bb"/><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify exception guarantees. <para>
15187
15188 </para><variablelist spacing="compact"><?dbhtml 
15189           list-presentation="table"
15190         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15191                   list-presentation="table"
15192                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.specify_nothing"><refmeta><refentrytitle>Class specify_nothing</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::specify_nothing</refname><refpurpose>Used to prevent setting other contract conditions after exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.specify_hpp">boost/contract/core/specify.hpp</link>&gt;
15193
15194 </phrase>
15195 <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <phrase role="special">{</phrase>
15196 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15197   <phrase role="comment">// <link linkend="boost.contract.specify_nothingconstruct-copy-destruct">construct/copy/destruct</link></phrase>
15198   <link linkend="idm45394999248752-bb"><phrase role="special">~</phrase><phrase role="identifier">specify_nothing</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15199 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.function">boost::contract::function</link></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>
15200 </para>
15201 </para><refsect2><title><anchor id="boost.contract.specify_nothingconstruct-copy-destruct"/><computeroutput>specify_nothing</computeroutput> 
15202         public
15203        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999248752-bb"/><phrase role="special">~</phrase><phrase role="identifier">specify_nothing</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <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__">
15204             Throw on Failure</link>). </para></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.specify__idm45394999245856"><refmeta><refentrytitle>Class template specify_old_postcondition_except</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::specify_old_postcondition_except</refname><refpurpose>Allow to specify old values copied at body, postconditions, and exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.specify_hpp">boost/contract/core/specify.hpp</link>&gt;
15205
15206 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase> 
15207 <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link> <phrase role="special">{</phrase>
15208 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15209   <phrase role="comment">// <link linkend="boost.contract.specify__idm45394999245856construct-copy-destruct">construct/copy/destruct</link></phrase>
15210   <link linkend="idm45394999210688-bb"><phrase role="special">~</phrase><phrase role="identifier">specify_old_postcondition_except</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15211
15212   <phrase role="comment">// <link linkend="idm45394999237760-bb">public member functions</link></phrase>
15213   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> 
15214     <link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <link linkend="idm45394999237200-bb"><phrase role="identifier">old</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15215   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_except">specify_except</link> <link linkend="idm45394999228704-bb"><phrase role="identifier">postcondition</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15216   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <link linkend="idm45394999217696-bb"><phrase role="identifier">except</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15217 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.function">boost::contract::function</link></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>
15218 </para>
15219
15220 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase></literallayout></para><para><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></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.specify__idm45394999245856construct-copy-destruct"/><computeroutput>specify_old_postcondition_except</computeroutput> 
15221         public
15222        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999210688-bb"/><phrase role="special">~</phrase><phrase role="identifier">specify_old_postcondition_except</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <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__">
15223             Throw on Failure</link>). </para></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999237760-bb"/><computeroutput>specify_old_postcondition_except</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> 
15224   <link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <anchor id="idm45394999237200-bb"/><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify old values copied at body. <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>
15225
15226 </para><variablelist spacing="compact"><?dbhtml 
15227           list-presentation="table"
15228         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15229                   list-presentation="table"
15230                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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><computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput></computeroutput>. Any exception thrown by a call to this functor will result in this library calling <computeroutput><computeroutput><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></computeroutput></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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_except">specify_except</link> <anchor id="idm45394999228704-bb"/><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify postconditions. <para>
15231
15232 </para><variablelist spacing="compact"><?dbhtml 
15233           list-presentation="table"
15234         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15235                   list-presentation="table"
15236                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.postcondition_failure">boost::contract::postcondition_failure</link></computeroutput></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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <anchor id="idm45394999217696-bb"/><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify exception guarantees. <para>
15237
15238 </para><variablelist spacing="compact"><?dbhtml 
15239           list-presentation="table"
15240         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15241                   list-presentation="table"
15242                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.specify__idm45394999207792"><refmeta><refentrytitle>Class template specify_postcondition_except</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::specify_postcondition_except</refname><refpurpose>Allow to specify postconditions or exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.specify_hpp">boost/contract/core/specify.hpp</link>&gt;
15243
15244 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase> 
15245 <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link> <phrase role="special">{</phrase>
15246 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15247   <phrase role="comment">// <link linkend="boost.contract.specify__idm45394999207792construct-copy-destruct">construct/copy/destruct</link></phrase>
15248   <link linkend="idm45394999181936-bb"><phrase role="special">~</phrase><phrase role="identifier">specify_postcondition_except</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15249
15250   <phrase role="comment">// <link linkend="idm45394999200512-bb">public member functions</link></phrase>
15251   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_except">specify_except</link> <link linkend="idm45394999199952-bb"><phrase role="identifier">postcondition</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15252   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <link linkend="idm45394999188944-bb"><phrase role="identifier">except</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15253 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.function">boost::contract::function</link></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>
15254 </para>
15255
15256 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase></literallayout></para><para><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></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.specify__idm45394999207792construct-copy-destruct"/><computeroutput>specify_postcondition_except</computeroutput> 
15257         public
15258        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999181936-bb"/><phrase role="special">~</phrase><phrase role="identifier">specify_postcondition_except</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <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__">
15259             Throw on Failure</link>). </para></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999200512-bb"/><computeroutput>specify_postcondition_except</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_except">specify_except</link> <anchor id="idm45394999199952-bb"/><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify postconditions. <para>
15260
15261 </para><variablelist spacing="compact"><?dbhtml 
15262           list-presentation="table"
15263         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15264                   list-presentation="table"
15265                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.postcondition_failure">boost::contract::postcondition_failure</link></computeroutput></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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <anchor id="idm45394999188944-bb"/><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify exception guarantees. <para>
15266
15267 </para><variablelist spacing="compact"><?dbhtml 
15268           list-presentation="table"
15269         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15270                   list-presentation="table"
15271                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.specify__idm45394999179040"><refmeta><refentrytitle>Class template specify_precondition_old_postcondition_except</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::specify_precondition_old_postcondition_except</refname><refpurpose>Allow to specify preconditions, old values copied at body, postconditions, and exception guarantees. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.specify_hpp">boost/contract/core/specify.hpp</link>&gt;
15272
15273 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase> 
15274 <phrase role="keyword">class</phrase> <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> <phrase role="special">{</phrase>
15275 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15276   <phrase role="comment">// <link linkend="boost.contract.specify__idm45394999179040construct-copy-destruct">construct/copy/destruct</link></phrase>
15277   <link linkend="idm45394999136032-bb"><phrase role="special">~</phrase><phrase role="identifier">specify_precondition_old_postcondition_except</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15278
15279   <phrase role="comment">// <link linkend="idm45394999170160-bb">public member functions</link></phrase>
15280   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> 
15281     <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <link linkend="idm45394999169600-bb"><phrase role="identifier">precondition</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15282   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> 
15283     <link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <link linkend="idm45394999162544-bb"><phrase role="identifier">old</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15284   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_except">specify_except</link> <link linkend="idm45394999154048-bb"><phrase role="identifier">postcondition</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15285   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <link linkend="idm45394999143040-bb"><phrase role="identifier">except</phrase></link><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15286 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.function">boost::contract::function</link></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>
15287 </para>
15288
15289 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> VirtualResult <phrase role="special">=</phrase> <phrase role="keyword">void</phrase></literallayout></para><para><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></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.specify__idm45394999179040construct-copy-destruct"/><computeroutput>specify_precondition_old_postcondition_except</computeroutput> 
15290         public
15291        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999136032-bb"/><phrase role="special">~</phrase><phrase role="identifier">specify_precondition_old_postcondition_except</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Destruct this object. <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__">
15292             Throw on Failure</link>). </para></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999170160-bb"/><computeroutput>specify_precondition_old_postcondition_except</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> 
15293   <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <anchor id="idm45394999169600-bb"/><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify preconditions. <para>
15294
15295 </para><variablelist spacing="compact"><?dbhtml 
15296           list-presentation="table"
15297         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15298                   list-presentation="table"
15299                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>Nullary functor called by this library to check preconditions <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></computeroutput></computeroutput>). This functor should capture variables by (constant) value, or better by (constant) reference (to avoid extra copies).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> 
15300   <link linkend="boost.contract.specify__idm45394999207792">specify_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> <anchor id="idm45394999162544-bb"/><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify old values copied at body. <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>
15301
15302 </para><variablelist spacing="compact"><?dbhtml 
15303           list-presentation="table"
15304         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15305                   list-presentation="table"
15306                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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><computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput></computeroutput>. Any exception thrown by a call to this functor will result in this library calling <computeroutput><computeroutput><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></computeroutput></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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><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></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_except">specify_except</link> <anchor id="idm45394999154048-bb"/><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify postconditions. <para>
15307
15308 </para><variablelist spacing="compact"><?dbhtml 
15309           list-presentation="table"
15310         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15311                   list-presentation="table"
15312                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><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><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.postcondition_failure">boost::contract::postcondition_failure</link></computeroutput></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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> F<phrase role="special">&gt;</phrase> <link linkend="boost.contract.specify_nothing">specify_nothing</link> <anchor id="idm45394999143040-bb"/><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="identifier">F</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> f<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Allow to specify exception guarantees. <para>
15313
15314 </para><variablelist spacing="compact"><?dbhtml 
15315           list-presentation="table"
15316         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15317                   list-presentation="table"
15318                 ?><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>Nullary functor called by this library to check exception guarantees <computeroutput>f()</computeroutput>. Assertions within this functor are usually programmed using  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><computeroutput><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></computeroutput></computeroutput>). This functor should capture variables by (constant) references (to access the values they will have at function exit).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. </para></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry>
15319 </section>
15320 <section id="header.boost.contract.core.virtual_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/core/virtual.hpp">boost/contract/core/virtual.hpp</ulink>&gt;</title><para>Handle virtual public functions with contracts (for subcontracting). </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
15321   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
15322     <phrase role="keyword">class</phrase> <link linkend="boost.contract.virtual_">virtual_</link><phrase role="special">;</phrase>
15323   <phrase role="special">}</phrase>
15324 <phrase role="special">}</phrase></synopsis>
15325 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.virtual_"><refmeta><refentrytitle>Class virtual_</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::virtual_</refname><refpurpose>Type of extra function parameter to handle contracts for virtual public functions (for subcontracting). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.core.virtual_hpp">boost/contract/core/virtual.hpp</link>&gt;
15326
15327 </phrase>
15328 <phrase role="keyword">class</phrase> <link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">{</phrase>
15329 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15330 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15331     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">x</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Declare `v`.</phrase>
15332         <phrase role="special">...</phrase> <phrase role="comment">// Contract declaration (which will use `v`) and function body.</phrase>
15333     <phrase role="special">}</phrase>
15334
15335     <phrase role="special">...</phrase>
15336 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15337 </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><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>, and all other operations of this library that accept a pointer to  <computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></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_">
15338         Public Function Overrides</link> </para>
15339 </para>
15340 </para></refsect1></refentry>
15341 </section>
15342 <section id="header.boost.contract.destructor_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/destructor.hpp">boost/contract/destructor.hpp</ulink>&gt;</title><para>Program contracts for destructors. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
15343   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
15344     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15345       <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link> <link linkend="boost.contract.destructor"><phrase role="identifier">destructor</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Class</phrase> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15346   <phrase role="special">}</phrase>
15347 <phrase role="special">}</phrase></synopsis>
15348 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.destructor"><refmeta><refentrytitle>Function template destructor</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::destructor</refname><refpurpose>Program contracts for destructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.destructor_hpp">boost/contract/destructor.hpp</link>&gt;
15349
15350 </phrase>
15351 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15352   <link linkend="boost.contract.specify__idm45394999245856">specify_old_postcondition_except</link> <phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="identifier">Class</phrase> <phrase role="special">*</phrase> obj<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15353     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
15354
15355     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
15356         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15357         <phrase role="special">...</phrase>
15358     <phrase role="special">}</phrase>
15359
15360 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15361     <phrase role="special">~</phrase><phrase role="identifier">u</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15362         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
15363         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
15364             <phrase role="comment">// No `.precondition` (destructors have no preconditions).</phrase>
15365             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15366                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15367                 <phrase role="special">...</phrase>
15368             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15369             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15370                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15371                 <phrase role="special">...</phrase>
15372             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15373             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15374                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15375                 <phrase role="special">...</phrase>
15376             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15377         <phrase role="special">;</phrase>
15378
15379         <phrase role="special">...</phrase> <phrase role="comment">// Destructor body.</phrase>
15380     <phrase role="special">}</phrase>
15381     
15382     <phrase role="special">...</phrase>
15383 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15384 </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>
15385 </para>
15386
15387
15388
15389 </para><variablelist spacing="compact"><?dbhtml 
15390           list-presentation="table"
15391         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15392                   list-presentation="table"
15393                 ?><varlistentry><term><computeroutput>obj</computeroutput></term><listitem><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">
15394             Class Invariants</link> and  <link linkend="boost_contract.extras.volatile_public_functions">
15395             Volatile Public Functions</link>).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15396                   list-presentation="table"
15397                 ?><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry>
15398 </section>
15399 <section id="header.boost.contract.function_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/function.hpp">boost/contract/function.hpp</ulink>&gt;</title><para>Program contracts for (non-public) functions. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
15400   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
15401     <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> <link linkend="boost.contract.function"><phrase role="identifier">function</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15402   <phrase role="special">}</phrase>
15403 <phrase role="special">}</phrase></synopsis>
15404 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.function"><refmeta><refentrytitle>Function function</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::function</refname><refpurpose>Program contracts for non-member, private and protected functions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.function_hpp">boost/contract/function.hpp</link>&gt;
15405
15406 </phrase>
15407 <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> <phrase role="identifier">function</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15408     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
15409     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase>
15410         <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15411             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15412             <phrase role="special">...</phrase>
15413         <phrase role="special">}</phrase><phrase role="special">)</phrase>
15414         <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15415             <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>  
15416             <phrase role="special">...</phrase>
15417         <phrase role="special">}</phrase><phrase role="special">)</phrase>
15418         <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15419             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15420             <phrase role="special">...</phrase>
15421         <phrase role="special">}</phrase><phrase role="special">)</phrase>
15422         <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15423             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15424             <phrase role="special">...</phrase>
15425         <phrase role="special">}</phrase><phrase role="special">)</phrase>
15426     <phrase role="special">;</phrase>
15427
15428     <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
15429 <phrase role="special">}</phrase>
15430 </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">
15431         Private and Protected Functions</link>,  <link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">
15432         Lambdas, Loops, Code Blocks</link></para>
15433 </para>
15434
15435 </para><variablelist spacing="compact"><?dbhtml 
15436           list-presentation="table"
15437         ?><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry>
15438 </section>
15439 <section id="header.boost.contract.old_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/old.hpp">boost/contract/old.hpp</ulink>&gt;</title><para>Handle old values. </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
15440
15441 <link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link>(...)</synopsis><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
15442   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
15443     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <phrase role="keyword">struct</phrase> <link linkend="boost.contract.is_old_value_copyable">is_old_value_copyable</link><phrase role="special">;</phrase>
15444
15445     <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_pointer">old_pointer</link><phrase role="special">;</phrase>
15446     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_ptr">old_ptr</link><phrase role="special">;</phrase>
15447     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_ptr_if_copyable">old_ptr_if_copyable</link><phrase role="special">;</phrase>
15448     <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_value">old_value</link><phrase role="special">;</phrase>
15449
15450     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <phrase role="keyword">struct</phrase> <link linkend="boost.contract.old_value_copy">old_value_copy</link><phrase role="special">;</phrase>
15451     <link linkend="boost.contract.old_value">old_value</link> <link linkend="boost.contract.null_old"><phrase role="identifier">null_old</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15452     <link linkend="boost.contract.old_pointer">old_pointer</link> <link linkend="boost.contract.make_old_idm45394998968720"><phrase role="identifier">make_old</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.old_value">old_value</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15453     <link linkend="boost.contract.old_pointer">old_pointer</link> <link linkend="boost.contract.make_old_idm45394998958240"><phrase role="identifier">make_old</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase><phrase role="special">,</phrase> <link linkend="boost.contract.old_value">old_value</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15454     <phrase role="keyword">bool</phrase> <link linkend="boost.contract.copy_old_idm45394998944672"><phrase role="identifier">copy_old</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15455     <phrase role="keyword">bool</phrase> <link linkend="boost.contract.copy_old_idm45394998938528"><phrase role="identifier">copy_old</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15456   <phrase role="special">}</phrase>
15457 <phrase role="special">}</phrase></synopsis>
15458 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.is_old_value_copyable"><refmeta><refentrytitle>Struct template is_old_value_copyable</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::is_old_value_copyable</refname><refpurpose>Trait to check if an old value type can be copied or not. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15459
15460 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15461 <phrase role="keyword">struct</phrase> <link linkend="boost.contract.is_old_value_copyable">is_old_value_copyable</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_copy_constructible</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">{</phrase>
15462 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase><phrase role="special">;</phrase> <phrase role="comment">// Some user-defined type for which old values shall not be copied.</phrase>
15463
15464 <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
15465     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="special">&gt;</phrase> <phrase role="comment">// Specialization to not copy old values of type `u`.</phrase>
15466     <phrase role="keyword">struct</phrase> <phrase role="identifier">is_old_value_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">false_type</phrase> <phrase role="special">{</phrase><phrase role="special">}</phrase><phrase role="special">;</phrase>
15467 <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="comment">// namespace</phrase>
15468 </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_">
15469         Old Value Requirements</link> </para>
15470 </para>
15471 </para></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.old_pointer"><refmeta><refentrytitle>Class old_pointer</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::old_pointer</refname><refpurpose>Convert old value copies into old value pointers. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15472
15473 </phrase>
15474 <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_pointer">old_pointer</link> <phrase role="special">{</phrase>
15475 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15476
15477   <phrase role="comment">// <link linkend="idm45394999074832-bb">public member functions</link></phrase>
15478   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <link linkend="idm45394999074272-bb"><phrase role="keyword">operator</phrase> <phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15479   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <link linkend="idm45394999068640-bb"><phrase role="keyword">operator</phrase> <phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15480 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><refsect2><title><anchor id="idm45394999074832-bb"/><computeroutput>old_pointer</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <anchor id="idm45394999074272-bb"/><phrase role="keyword">operator</phrase> <phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Convert this object to an actual old value pointer for which the old value type <computeroutput>T</computeroutput> might or not be copyable. <para>For example, this is implicitly called when assigning or initializing old value pointers of type <computeroutput><computeroutput><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput></computeroutput>.</para><para>
15481 </para><variablelist spacing="compact"><?dbhtml 
15482           list-presentation="table"
15483         ?><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15484                   list-presentation="table"
15485                 ?><varlistentry><term><computeroutput>T</computeroutput></term><listitem><para>Type of the pointed old value. The old value pointer will always be null if this type is not copyable (see <computeroutput><computeroutput><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput></computeroutput>), but this library will not generate a compile-time error. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> <anchor id="idm45394999068640-bb"/><phrase role="keyword">operator</phrase> <phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Convert this object to an actual old value pointer for which the old value type <computeroutput>T</computeroutput> must be copyable. <para>For example, this is implicitly called when assigning or initializing old value pointers of type <computeroutput><computeroutput><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput></computeroutput>.</para><para>
15486 </para><variablelist spacing="compact"><?dbhtml 
15487           list-presentation="table"
15488         ?><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15489                   list-presentation="table"
15490                 ?><varlistentry><term><computeroutput>T</computeroutput></term><listitem><para>Type of the pointed old value. This type must be copyable (see <computeroutput><computeroutput><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></computeroutput></computeroutput>), otherwise this library will generate a compile-time error when the old value pointer is dereferenced. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.old_ptr"><refmeta><refentrytitle>Class template old_ptr</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::old_ptr</refname><refpurpose>Old value pointer that requires the pointed old value type to be copyable. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15491
15492 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15493 <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_ptr">old_ptr</link> <phrase role="special">{</phrase>
15494 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15495   <phrase role="comment">// types</phrase>
15496   <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <anchor id="boost.contract.old_ptr.element_type"/><phrase role="identifier">element_type</phrase><phrase role="special">;</phrase>  <phrase role="comment">// Pointed old value type. </phrase>
15497
15498   <phrase role="comment">// <link linkend="boost.contract.old_ptrconstruct-copy-destruct">construct/copy/destruct</link></phrase>
15499   <link linkend="idm45394999038400-bb"><phrase role="identifier">old_ptr</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15500
15501   <phrase role="comment">// <link linkend="idm45394999053440-bb">public member functions</link></phrase>
15502   <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <link linkend="idm45394999052880-bb"><phrase role="keyword">operator</phrase> <phrase role="special">*</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
15503   <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <link linkend="idm45394999047296-bb"><phrase role="keyword">operator</phrase><phrase role="special">-&gt;</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
15504   <phrase role="keyword">explicit</phrase> <link linkend="idm45394999041712-bb"><phrase role="keyword">operator</phrase> <phrase role="keyword">bool</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
15505 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This pointer can be set to point an actual old value copy using either  <computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput> or <computeroutput><link linkend="boost.contract.make_old_idm45394998968720">boost::contract::make_old</link></computeroutput> (that is why this class does not have public non-default constructors):</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15506 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15507     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15508         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="comment">// For copyable `old_type`.</phrase>
15509                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15510         <phrase role="special">...</phrase>
15511     <phrase role="special">}</phrase>
15512
15513     <phrase role="special">...</phrase>
15514 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15515 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.tutorial.old_values"> Old Values</link></para>
15516 </para>
15517
15518 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> T</literallayout></para><para><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></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.old_ptrconstruct-copy-destruct"/><computeroutput>old_ptr</computeroutput> 
15519         public
15520        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999038400-bb"/><phrase role="identifier">old_ptr</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this old value pointer as null. </listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999053440-bb"/><computeroutput>old_ptr</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <anchor id="idm45394999052880-bb"/><phrase role="keyword">operator</phrase> <phrase role="special">*</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Dereference this old value pointer. <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>
15521 </para><variablelist spacing="compact"><?dbhtml 
15522           list-presentation="table"
15523         ?><varlistentry><term>Returns:</term><listitem><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">
15524         Constant Correctness</link>). </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <anchor id="idm45394999047296-bb"/><phrase role="keyword">operator</phrase><phrase role="special">-&gt;</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Structure-dereference this old value pointer. <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>
15525 </para><variablelist spacing="compact"><?dbhtml 
15526           list-presentation="table"
15527         ?><varlistentry><term>Returns:</term><listitem><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">
15528         Constant Correctness</link>). </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45394999041712-bb"/><phrase role="keyword">operator</phrase> <phrase role="keyword">bool</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Query if this old value pointer is null or not (safe-bool operator). <para>(This is implemented using safe-bool emulation on compilers that do not support C++11 explicit type conversion operators.)</para><para>
15529 </para><variablelist spacing="compact"><?dbhtml 
15530           list-presentation="table"
15531         ?><varlistentry><term>Returns:</term><listitem><para>True if this pointer is not null, false otherwise. </para></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.old_ptr_if_copyable"><refmeta><refentrytitle>Class template old_ptr_if_copyable</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::old_ptr_if_copyable</refname><refpurpose>Old value pointer that does not require the pointed old value type to be copyable. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15532
15533 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15534 <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_ptr_if_copyable">old_ptr_if_copyable</link> <phrase role="special">{</phrase>
15535 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15536   <phrase role="comment">// types</phrase>
15537   <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <anchor id="boost.contract.old_ptr_if_copyable.element_type"/><phrase role="identifier">element_type</phrase><phrase role="special">;</phrase>  <phrase role="comment">// Pointed old value type. </phrase>
15538
15539   <phrase role="comment">// <link linkend="boost.contract.old_ptr_if_copyableconstruct-copy-destruct">construct/copy/destruct</link></phrase>
15540   <link linkend="idm45394999013184-bb"><phrase role="identifier">old_ptr_if_copyable</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15541   <link linkend="idm45394999012576-bb"><phrase role="identifier">old_ptr_if_copyable</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.old_ptr">old_ptr</link><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15542
15543   <phrase role="comment">// <link linkend="idm45394999028256-bb">public member functions</link></phrase>
15544   <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <link linkend="idm45394999027696-bb"><phrase role="keyword">operator</phrase> <phrase role="special">*</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
15545   <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <link linkend="idm45394999022096-bb"><phrase role="keyword">operator</phrase><phrase role="special">-&gt;</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
15546   <phrase role="keyword">explicit</phrase> <link linkend="idm45394999016496-bb"><phrase role="keyword">operator</phrase> <phrase role="keyword">bool</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
15547 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This pointer can be set to point to an actual old value copy using either  <computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput> or <computeroutput><link linkend="boost.contract.make_old_idm45394998968720">boost::contract::make_old</link></computeroutput>:</para><para><programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="comment">// Type `T` might or not be copyable.</phrase>
15548 <phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15549 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15550     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15551         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase>
15552                 <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15553         <phrase role="special">...</phrase>
15554             <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="comment">// Always null for non-copyable types.</phrase>
15555         <phrase role="special">...</phrase>
15556     <phrase role="special">}</phrase>
15557
15558     <phrase role="special">...</phrase>
15559 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15560 </programlisting></para><para><para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.old_value_requirements__templates_">
15561         Old Value Requirements</link></para>
15562 </para>
15563
15564 </para><refsect2><title>Template Parameters</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">typename</phrase> T</literallayout></para><para><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></para></listitem></orderedlist></refsect2><refsect2><title><anchor id="boost.contract.old_ptr_if_copyableconstruct-copy-destruct"/><computeroutput>old_ptr_if_copyable</computeroutput> 
15565         public
15566        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="idm45394999013184-bb"/><phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this old value pointer as null. </listitem><listitem><para><literallayout class="monospaced"><anchor id="idm45394999012576-bb"/><phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">(</phrase><link linkend="boost.contract.old_ptr">old_ptr</link><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> other<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this old value pointer from an old value pointer that requires the old value type to be copyable. <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><computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput></computeroutput> (this constructor is usually not explicitly called by user code).</para><para>
15567 </para><variablelist spacing="compact"><?dbhtml 
15568           list-presentation="table"
15569         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15570                   list-presentation="table"
15571                 ?><varlistentry><term><computeroutput>other</computeroutput></term><listitem><para>Old value pointer that requires the old value type to be copyable. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394999028256-bb"/><computeroutput>old_ptr_if_copyable</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <anchor id="idm45394999027696-bb"/><phrase role="keyword">operator</phrase> <phrase role="special">*</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Dereference this old value pointer. <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>
15572 </para><variablelist spacing="compact"><?dbhtml 
15573           list-presentation="table"
15574         ?><varlistentry><term>Returns:</term><listitem><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">
15575         Constant Correctness</link>). </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">*</phrase> <anchor id="idm45394999022096-bb"/><phrase role="keyword">operator</phrase><phrase role="special">-&gt;</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Structure-dereference this old value pointer. <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>
15576 </para><variablelist spacing="compact"><?dbhtml 
15577           list-presentation="table"
15578         ?><varlistentry><term>Returns:</term><listitem><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">
15579         Constant Correctness</link>). </para></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45394999016496-bb"/><phrase role="keyword">operator</phrase> <phrase role="keyword">bool</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Query if this old value pointer is null or not (safe-bool operator). <para>(This is implemented using safe-bool emulation on compilers that do not support C++11 explicit type conversion operators.)</para><para>
15580 </para><variablelist spacing="compact"><?dbhtml 
15581           list-presentation="table"
15582         ?><varlistentry><term>Returns:</term><listitem><para>True if this pointer is not null, false otherwise. </para></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.old_value"><refmeta><refentrytitle>Class old_value</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::old_value</refname><refpurpose>Convert user-specified expressions to old values. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15583
15584 </phrase>
15585 <phrase role="keyword">class</phrase> <link linkend="boost.contract.old_value">old_value</link> <phrase role="special">{</phrase>
15586 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15587   <phrase role="comment">// <link linkend="boost.contract.old_valueconstruct-copy-destruct">construct/copy/destruct</link></phrase>
15588   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15589     <link linkend="idm45394999003184-bb"><phrase role="identifier">old_value</phrase></link><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">,</phrase> 
15590               <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">enable_if</phrase><phrase role="special">&lt;</phrase> <link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase><phrase role="special">::</phrase><phrase role="identifier">type</phrase> <phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15591   <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15592     <link linkend="idm45394998995648-bb"><phrase role="identifier">old_value</phrase></link><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">,</phrase> 
15593               <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">disable_if</phrase><phrase role="special">&lt;</phrase> <link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase><phrase role="special">::</phrase><phrase role="identifier">type</phrase> <phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15594 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link></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_">
15595         Old Value Requirements</link> </para>
15596 </para>
15597 </para><refsect2><title><anchor id="boost.contract.old_valueconstruct-copy-destruct"/><computeroutput>old_value</computeroutput> 
15598         public
15599        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15600   <anchor id="idm45394999003184-bb"/><phrase role="identifier">old_value</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> old<phrase role="special">,</phrase> 
15601             <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">enable_if</phrase><phrase role="special">&lt;</phrase> <link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase><phrase role="special">::</phrase><phrase role="identifier">type</phrase> <phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object from the specified old value when the old value type is copy constructible. <para>The specified old value <computeroutput>old</computeroutput> is copied (one time only) using <computeroutput><computeroutput><link linkend="boost.contract.old_value_copy">boost::contract::old_value_copy</link></computeroutput></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><computeroutput><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></computeroutput></computeroutput>).</para><para>
15602
15603 </para><variablelist spacing="compact"><?dbhtml 
15604           list-presentation="table"
15605         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15606                   list-presentation="table"
15607                 ?><varlistentry><term><computeroutput>old</computeroutput></term><listitem><para>Old value to be copied.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15608                   list-presentation="table"
15609                 ?><varlistentry><term><computeroutput>T</computeroutput></term><listitem><para>Old value type. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15610   <anchor id="idm45394998995648-bb"/><phrase role="identifier">old_value</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> old<phrase role="special">,</phrase> 
15611             <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">disable_if</phrase><phrase role="special">&lt;</phrase> <link linkend="boost.contract.is_old_value_copyable">boost::contract::is_old_value_copyable</link><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase><phrase role="special">::</phrase><phrase role="identifier">type</phrase> <phrase role="special">*</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object from the specified old value when the old value type is not copyable. <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>
15612
15613 </para><variablelist spacing="compact"><?dbhtml 
15614           list-presentation="table"
15615         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15616                   list-presentation="table"
15617                 ?><varlistentry><term><computeroutput>old</computeroutput></term><listitem><para>Old value (that will not be copied in this case).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15618                   list-presentation="table"
15619                 ?><varlistentry><term><computeroutput>T</computeroutput></term><listitem><para>Old value type. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.old_value_copy"><refmeta><refentrytitle>Struct template old_value_copy</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::old_value_copy</refname><refpurpose>Trait to copy an old value. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15620
15621 </phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">&gt;</phrase> 
15622 <phrase role="keyword">struct</phrase> <link linkend="boost.contract.old_value_copy">old_value_copy</link> <phrase role="special">{</phrase>
15623   <phrase role="comment">// <link linkend="boost.contract.old_value_copyconstruct-copy-destruct">construct/copy/destruct</link></phrase>
15624   <phrase role="keyword">explicit</phrase> <link linkend="idm45394998977872-bb"><phrase role="identifier">old_value_copy</phrase></link><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15625
15626   <phrase role="comment">// <link linkend="idm45394998981760-bb">public member functions</link></phrase>
15627   <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <link linkend="idm45394998981200-bb"><phrase role="identifier">old</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
15628 <phrase role="special">}</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase>
15629 <phrase role="keyword">class</phrase> <phrase role="identifier">old_value_copy</phrase> <phrase role="special">{</phrase>
15630 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15631     <phrase role="keyword">explicit</phrase> <phrase role="identifier">old_value_copy</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">old</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
15632         <phrase role="identifier">old_</phrase><phrase role="special">(</phrase><phrase role="identifier">old</phrase><phrase role="special">)</phrase> <phrase role="comment">// One single copy of value using T's copy constructor.</phrase>
15633     <phrase role="special">{</phrase><phrase role="special">}</phrase>
15634
15635     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">old_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
15636
15637 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
15638     <phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">old_</phrase><phrase role="special">;</phrase> <phrase role="comment">// The old value copy.</phrase>
15639 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15640 </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_">
15641         Old Value Requirements</link> </para>
15642 </para>
15643 </para><refsect2><title><anchor id="boost.contract.old_value_copyconstruct-copy-destruct"/><computeroutput>old_value_copy</computeroutput> 
15644         public
15645        construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">explicit</phrase> <anchor id="idm45394998977872-bb"/><phrase role="identifier">old_value_copy</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> old<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para>Construct this object by making one single copy of the specified old value. <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><computeroutput><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></computeroutput></computeroutput>).</para><para>
15646 </para><variablelist spacing="compact"><?dbhtml 
15647           list-presentation="table"
15648         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15649                   list-presentation="table"
15650                 ?><varlistentry><term><computeroutput>old</computeroutput></term><listitem><para>The old value to copy. </para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="idm45394998981760-bb"/><computeroutput>old_value_copy</computeroutput> public member functions</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase>  <phrase role="special">&amp;</phrase> <anchor id="idm45394998981200-bb"/><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para>Return a (constant) reference to the old value that was copied. <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">
15651 Constant Correctness</link>). </para></listitem></orderedlist></refsect2></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.null_old"><refmeta><refentrytitle>Function null_old</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::null_old</refname><refpurpose>Return a "null" old value. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15652
15653 </phrase>
15654 <link linkend="boost.contract.old_value">old_value</link> <phrase role="identifier">null_old</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>The related old value pointer will also be null. This function is usually only called by the code expanded by  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput></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>
15655 </para>
15656
15657 </para><variablelist spacing="compact"><?dbhtml 
15658           list-presentation="table"
15659         ?><varlistentry><term>Returns:</term><listitem><para>Null old value. </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.make_old_idm45394998968720"><refmeta><refentrytitle>Function make_old</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::make_old</refname><refpurpose>Make an old value pointer (but not for virtual public functions and public functions overrides). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15660
15661 </phrase>
15662 <link linkend="boost.contract.old_pointer">old_pointer</link> <phrase role="identifier">make_old</phrase><phrase role="special">(</phrase><link linkend="boost.contract.old_value">old_value</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> old<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">make_old</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_old</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">?</phrase> <phrase role="identifier">old_expr</phrase> <phrase role="special">:</phrase>
15663         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">null_old</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">)</phrase>
15664 </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>
15665 </para>
15666
15667
15668 </para><variablelist spacing="compact"><?dbhtml 
15669           list-presentation="table"
15670         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15671                   list-presentation="table"
15672                 ?><varlistentry><term><computeroutput>old</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Old value pointer (usually implicitly converted to either  <computeroutput><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput> or  <computeroutput><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput> in user code). </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.make_old_idm45394998958240"><refmeta><refentrytitle>Function make_old</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::make_old</refname><refpurpose>Make an old value pointer (for virtual public functions and public functions overrides). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15673
15674 </phrase>
15675 <link linkend="boost.contract.old_pointer">old_pointer</link> <phrase role="identifier">make_old</phrase><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase> v<phrase role="special">,</phrase> <link linkend="boost.contract.old_value">old_value</link> <phrase role="keyword">const</phrase> <phrase role="special">&amp;</phrase> old<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">make_old</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_old</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">)</phrase> <phrase role="special">?</phrase> <phrase role="identifier">old_expr</phrase> <phrase role="special">:</phrase>
15676         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">null_old</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">)</phrase>
15677 </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>
15678 </para>
15679
15680
15681 </para><variablelist spacing="compact"><?dbhtml 
15682           list-presentation="table"
15683         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15684                   list-presentation="table"
15685                 ?><varlistentry><term><computeroutput>old</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>v</computeroutput></term><listitem><para>The trailing parameter of type  <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual or overriding public function declaring the contract. </para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>Old value pointer (usually implicitly converted to either  <computeroutput><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput> or  <computeroutput><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></computeroutput> in user code). </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.copy_old_idm45394998944672"><refmeta><refentrytitle>Function copy_old</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::copy_old</refname><refpurpose>Query if old values need to be copied (but not for virtual public functions and public function overrides). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15686
15687 </phrase>
15688 <phrase role="keyword">bool</phrase> <phrase role="identifier">copy_old</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>For example, this function always returns false when both postconditions and exception guarantees are not being checked (see  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></computeroutput></computeroutput>). This function is usually only called by the code expanded by  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput></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>
15689 </para>
15690
15691 </para><variablelist spacing="compact"><?dbhtml 
15692           list-presentation="table"
15693         ?><varlistentry><term>Returns:</term><listitem><para>True if old values need to be copied, false otherwise. </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.copy_old_idm45394998938528"><refmeta><refentrytitle>Function copy_old</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::copy_old</refname><refpurpose>Query if old values need to be copied (for virtual public functions and public function overrides). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15694
15695 </phrase>
15696 <phrase role="keyword">bool</phrase> <phrase role="identifier">copy_old</phrase><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase> v<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>For example, this function always returns false when both postconditions and exception guarantees are not being checked (see  <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></computeroutput></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><computeroutput><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput></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>
15697 </para>
15698
15699
15700 </para><variablelist spacing="compact"><?dbhtml 
15701           list-presentation="table"
15702         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15703                   list-presentation="table"
15704                 ?><varlistentry><term><computeroutput>v</computeroutput></term><listitem><para>The trailing parameter of type  <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual or overriding public function declaring the contract.</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>True if old values need to be copied, false otherwise. </para></listitem></varlistentry></variablelist></refsect1></refentry>
15705 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_OLDOF"><refmeta><refentrytitle>Macro BOOST_CONTRACT_OLDOF</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_OLDOF</refname><refpurpose>Macro typically used to copy an old value expression and assign it to an old value pointer. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.old_hpp">boost/contract/old.hpp</link>&gt;
15706
15707 </phrase>BOOST_CONTRACT_OLDOF(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>The expression expanded by this macro should be assigned to an old value pointer of type <computeroutput><link linkend="boost.contract.old_ptr">boost::contract::old_ptr</link></computeroutput> or  <computeroutput><link linkend="boost.contract.old_ptr_if_copyable">boost::contract::old_ptr_if_copyable</link></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><phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase>
15708 </programlisting></para><para>2. From all other operations:</para><para><programlisting><phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase>
15709 </programlisting></para><para>Where:</para><para><itemizedlist>
15710 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra parameter of type  <computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function or public function overrides declaring the contract. </para>
15711 </listitem>
15712 <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>
15713 </listitem>
15714 </itemizedlist>
15715 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>
15716 </para>
15717 </para></refsect1></refentry>
15718 </section>
15719 <section id="header.boost.contract.override_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/override.hpp">boost/contract/override.hpp</ulink>&gt;</title><para>Handle public function overrides (for subcontracting). </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
15720
15721 <link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link>(type_name, func_name)
15722 <link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link>(func_name)
15723 <link linkend="BOOST_CONTRACT_OVERRIDES">BOOST_CONTRACT_OVERRIDES</link>(...)</synopsis>
15724 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998912688"><refmeta><refentrytitle>Macro BOOST_CONTRACT_NAMED_OVERRIDE</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_NAMED_OVERRIDE</refname><refpurpose>Declare an override type trait with an arbitrary name. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.override_hpp">boost/contract/override.hpp</link>&gt;
15725
15726 </phrase>BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Declare the override type trait named <computeroutput>type_name</computeroutput> to pass as an explicit template parameter to <computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></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>
15727 </para>
15728
15729 </para><variablelist spacing="compact"><?dbhtml 
15730               list-presentation="table"
15731             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15732                       list-presentation="table"
15733                     ?><varlistentry><term><computeroutput>func_name</computeroutput></term><listitem><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">
15734                     Function Overloads</link>). (This is not a variadic macro parameter but it should never contain commas because it is an identifier.) </para></listitem></varlistentry><varlistentry><term><computeroutput>type_name</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
15735 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_OVERRIDE"><refmeta><refentrytitle>Macro BOOST_CONTRACT_OVERRIDE</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_OVERRIDE</refname><refpurpose>Declare an override type trait named <computeroutput>override_<emphasis>func_name</emphasis></computeroutput>. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.override_hpp">boost/contract/override.hpp</link>&gt;
15736
15737 </phrase>BOOST_CONTRACT_OVERRIDE(func_name)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Declare the override type trait named <computeroutput>override_<emphasis>func_name</emphasis></computeroutput> to pass as an explicit template parameter to <computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput> for public function overrides. Use <computeroutput><link linkend="BOOST_CO_idm45394998912688">BOOST_CONTRACT_NAMED_OVERRIDE</link></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_">
15738         Public Function Overrides</link></para>
15739 </para>
15740
15741 </para><variablelist spacing="compact"><?dbhtml 
15742               list-presentation="table"
15743             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15744                       list-presentation="table"
15745                     ?><varlistentry><term><computeroutput>func_name</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
15746 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_OVERRIDES"><refmeta><refentrytitle>Macro BOOST_CONTRACT_OVERRIDES</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_OVERRIDES</refname><refpurpose>Declare multiple override type traits at once naming them <computeroutput>override_...</computeroutput> (for convenience). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.override_hpp">boost/contract/override.hpp</link>&gt;
15747
15748 </phrase>BOOST_CONTRACT_OVERRIDES(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">f_1</phrase><phrase role="special">)</phrase>
15749 <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">f_2</phrase><phrase role="special">)</phrase>
15750 <phrase role="special">...</phrase>
15751 <phrase role="identifier">BOOST_CONTRACT_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">f_n</phrase><phrase role="special">)</phrase>
15752 </programlisting></para><para>On compilers that do not support variadic macros, the override type traits can be equivalently programmed one-by-one calling  <computeroutput><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></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_">
15753         Public Function Overrides</link></para>
15754 </para>
15755
15756 </para><variablelist spacing="compact"><?dbhtml 
15757               list-presentation="table"
15758             ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15759                       list-presentation="table"
15760                     ?><varlistentry><term><computeroutput>...</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist></refsect1></refentry>
15761 </section>
15762 <section id="header.boost.contract.public_function_hpp"><title>Header &lt;<ulink url="../../../../boost/contract/public_function.hpp">boost/contract/public_function.hpp</ulink>&gt;</title><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><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
15763   <phrase role="keyword">namespace</phrase> <phrase role="identifier">contract</phrase> <phrase role="special">{</phrase>
15764     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15765       <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> <link linkend="boost.contract.public_f_idm45394998885120"><phrase role="identifier">public_function</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15766     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15767       <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> <link linkend="boost.contract.public_f_idm45394998874224"><phrase role="identifier">public_function</phrase></link><phrase role="special">(</phrase><phrase role="identifier">Class</phrase> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15768     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15769       <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> 
15770       <link linkend="boost.contract.public_f_idm45394998859936"><phrase role="identifier">public_function</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase><phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15771     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15772       <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> 
15773       <link linkend="boost.contract.public_f_idm45394998841296"><phrase role="identifier">public_function</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase><phrase role="special">,</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15774     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Override<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> F<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Class<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase><phrase role="special">...</phrase> Args<phrase role="special">&gt;</phrase> 
15775       <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> 
15776       <link linkend="boost.contract.public_f_idm45394998817488"><phrase role="identifier">public_function</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase><phrase role="special">,</phrase> <phrase role="identifier">F</phrase><phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15777     <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Override<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> F<phrase role="special">,</phrase> 
15778              <phrase role="keyword">typename</phrase> Class<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase><phrase role="special">...</phrase> Args<phrase role="special">&gt;</phrase> 
15779       <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> 
15780       <link linkend="boost.contract.public_f_idm45394998787360"><phrase role="identifier">public_function</phrase></link><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase><phrase role="special">,</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="identifier">F</phrase><phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15781   <phrase role="special">}</phrase>
15782 <phrase role="special">}</phrase></synopsis>
15783 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.public_f_idm45394998885120"><refmeta><refentrytitle>Function template public_function</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::public_function</refname><refpurpose>Program contracts for static public functions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.public_function_hpp">boost/contract/public_function.hpp</link>&gt;
15784
15785 </phrase>
15786 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15787   <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> <phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15788     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
15789
15790     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">static_invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for non-static).</phrase>
15791         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15792         <phrase role="special">...</phrase>
15793     <phrase role="special">}</phrase>
15794
15795 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15796     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15797         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
15798         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase>
15799             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15800                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15801                 <phrase role="special">...</phrase>
15802             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15803             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15804                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15805                 <phrase role="special">...</phrase>
15806             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15807             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15808                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15809                 <phrase role="special">...</phrase>
15810             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15811             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15812                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15813                 <phrase role="special">...</phrase>
15814             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15815         <phrase role="special">;</phrase>
15816
15817         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
15818     <phrase role="special">}</phrase>
15819     
15820     <phrase role="special">...</phrase>
15821 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15822 </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>
15823 </para>
15824
15825
15826 </para><variablelist spacing="compact"><?dbhtml 
15827           list-presentation="table"
15828         ?><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15829                   list-presentation="table"
15830                 ?><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.public_f_idm45394998874224"><refmeta><refentrytitle>Function template public_function</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::public_function</refname><refpurpose>Program contracts for public functions that are not static, not virtual, and do not not override. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.public_function_hpp">boost/contract/public_function.hpp</link>&gt;
15831
15832 </phrase>
15833 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15834   <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> <phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">Class</phrase> <phrase role="special">*</phrase> obj<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15835     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
15836
15837     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
15838         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15839         <phrase role="special">...</phrase>
15840     <phrase role="special">}</phrase>
15841
15842 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15843     <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15844         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
15845         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
15846             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15847                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15848                 <phrase role="special">...</phrase>
15849             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15850             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15851                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15852                 <phrase role="special">...</phrase>
15853             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15854             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15855                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15856                 <phrase role="special">...</phrase>
15857             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15858             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15859                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15860                 <phrase role="special">...</phrase>
15861             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15862         <phrase role="special">;</phrase>
15863
15864         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
15865     <phrase role="special">}</phrase>
15866     
15867     <phrase role="special">...</phrase>
15868 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15869 </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>
15870 </para>
15871
15872
15873
15874 </para><variablelist spacing="compact"><?dbhtml 
15875           list-presentation="table"
15876         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15877                   list-presentation="table"
15878                 ?><varlistentry><term><computeroutput>obj</computeroutput></term><listitem><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">
15879             Volatile Public Functions</link>).</para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15880                   list-presentation="table"
15881                 ?><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.public_f_idm45394998859936"><refmeta><refentrytitle>Function template public_function</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::public_function</refname><refpurpose>Program contracts for void virtual public functions that do not override. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.public_function_hpp">boost/contract/public_function.hpp</link>&gt;
15882
15883 </phrase>
15884 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15885   <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> 
15886   <phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase> v<phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase> obj<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15887     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
15888
15889     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
15890         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15891         <phrase role="special">...</phrase>
15892     <phrase role="special">}</phrase>
15893
15894 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15895     <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15896         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
15897         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
15898             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15899                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15900                 <phrase role="special">...</phrase>
15901             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15902             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15903                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15904                 <phrase role="special">...</phrase>
15905             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15906             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15907                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15908                 <phrase role="special">...</phrase>
15909             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15910             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15911                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15912                 <phrase role="special">...</phrase>
15913             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15914         <phrase role="special">;</phrase>
15915
15916         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
15917     <phrase role="special">}</phrase>
15918     
15919     <phrase role="special">...</phrase>
15920 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15921 </programlisting></para><para>A virtual public function should always call  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></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>
15922 </para>
15923
15924
15925
15926 </para><variablelist spacing="compact"><?dbhtml 
15927           list-presentation="table"
15928         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15929                   list-presentation="table"
15930                 ?><varlistentry><term><computeroutput>obj</computeroutput></term><listitem><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">
15931             Volatile Public Functions</link>).</para></listitem></varlistentry><varlistentry><term><computeroutput>v</computeroutput></term><listitem><para>The trailing parameter of type  <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function. </para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15932                   list-presentation="table"
15933                 ?><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.public_f_idm45394998841296"><refmeta><refentrytitle>Function template public_function</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::public_function</refname><refpurpose>Program contracts for non-void virtual public functions that do not override. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.public_function_hpp">boost/contract/public_function.hpp</link>&gt;
15934
15935 </phrase>
15936 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Class<phrase role="special">&gt;</phrase> 
15937   <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> 
15938   <phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase> v<phrase role="special">,</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&amp;</phrase> r<phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase> obj<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
15939     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
15940
15941     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
15942         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15943         <phrase role="special">...</phrase>
15944     <phrase role="special">}</phrase>
15945
15946 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
15947     <phrase role="identifier">t</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
15948         <phrase role="identifier">t</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
15949         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
15950         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase>
15951                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
15952             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15953                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15954                 <phrase role="special">...</phrase>
15955             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15956             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15957                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15958                 <phrase role="special">...</phrase>
15959             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15960             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">(</phrase><phrase role="identifier">t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15961                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15962                 <phrase role="special">...</phrase>
15963             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15964             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
15965                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
15966                 <phrase role="special">...</phrase>
15967             <phrase role="special">}</phrase><phrase role="special">)</phrase>
15968         <phrase role="special">;</phrase>
15969
15970         <phrase role="special">...</phrase> <phrase role="comment">// Function body (use `return result = return_expr`).</phrase>
15971     <phrase role="special">}</phrase>
15972     
15973     <phrase role="special">...</phrase>
15974 <phrase role="special">}</phrase><phrase role="special">;</phrase>
15975 </programlisting></para><para>A virtual public function should always call  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></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>
15976 </para>
15977
15978
15979
15980 </para><variablelist spacing="compact"><?dbhtml 
15981           list-presentation="table"
15982         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15983                   list-presentation="table"
15984                 ?><varlistentry><term><computeroutput>obj</computeroutput></term><listitem><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">
15985             Volatile Public Functions</link>).</para></listitem></varlistentry><varlistentry><term><computeroutput>r</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>v</computeroutput></term><listitem><para>The trailing parameter of type  <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function. </para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
15986                   list-presentation="table"
15987                 ?><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>VirtualResult</computeroutput></term><listitem><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">
15988                         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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.public_f_idm45394998817488"><refmeta><refentrytitle>Function template public_function</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::public_function</refname><refpurpose>Program contracts for void public functions overrides (virtual or not). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.public_function_hpp">boost/contract/public_function.hpp</link>&gt;
15989
15990 </phrase>
15991 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Override<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> F<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> Class<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase><phrase role="special">...</phrase> Args<phrase role="special">&gt;</phrase> 
15992   <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link> 
15993   <phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase> v<phrase role="special">,</phrase> <phrase role="identifier">F</phrase> f<phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase> obj<phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;</phrase><phrase role="special">...</phrase> args<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
15994     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase><phrase role="special">,</phrase> \
15995             <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">w</phrase>
15996     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
15997 <phrase role="special">{</phrase>
15998     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
15999
16000     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
16001     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
16002
16003     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
16004         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16005         <phrase role="special">...</phrase>
16006     <phrase role="special">}</phrase>
16007
16008     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
16009
16010 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16011     <phrase role="comment">// Override from `b::f`.</phrase>
16012     <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16013         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
16014         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
16015                 <phrase role="identifier">override_f</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">u</phrase><phrase role="special">::</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">)</phrase>
16016             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16017                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16018                 <phrase role="special">...</phrase>
16019             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16020             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16021                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16022                 <phrase role="special">...</phrase>
16023             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16024             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16025                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16026                 <phrase role="special">...</phrase>
16027             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16028             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16029                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16030                 <phrase role="special">...</phrase>
16031             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16032         <phrase role="special">;</phrase>
16033
16034         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16035     <phrase role="special">}</phrase>
16036     
16037     <phrase role="special">...</phrase>
16038 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16039 </programlisting></para><para>A public function override should always call  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></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_">
16040         Public Function Overrides</link></para>
16041 </para>
16042
16043
16044
16045 </para><variablelist spacing="compact"><?dbhtml 
16046           list-presentation="table"
16047         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
16048                   list-presentation="table"
16049                 ?><varlistentry><term><computeroutput>args</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>A pointer to the enclosing public function override declaring the contract (but see <link linkend="boost_contract.advanced.function_overloads">
16050             Function Overloads</link>). </para></listitem></varlistentry><varlistentry><term><computeroutput>obj</computeroutput></term><listitem><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">
16051             Volatile Public Functions</link>). </para></listitem></varlistentry><varlistentry><term><computeroutput>v</computeroutput></term><listitem><para>The trailing parameter of type  <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing public function override. </para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
16052                   list-presentation="table"
16053                 ?><varlistentry><term><computeroutput>Args</computeroutput></term><listitem><para>The types of all parameters passed to the enclosing public function override declaring the contract, but excluding the trailing parameter type <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput>*</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><computeroutput><link linkend="BOOST_CONTRACT_MAX_ARGS">BOOST_CONTRACT_MAX_ARGS</link></computeroutput></computeroutput>). (Usually these template parameters are automatically deduced by C++ and they do not need to be explicitly specified by programmers.)</para></listitem></varlistentry><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>F</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>Override</computeroutput></term><listitem><para>The type trait <computeroutput>override_<emphasis>function-name</emphasis></computeroutput> declared using the <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput></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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry><refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.contract.public_f_idm45394998787360"><refmeta><refentrytitle>Function template public_function</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::contract::public_function</refname><refpurpose>Program contracts for non-void public functions overrides (virtual or not). </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract.public_function_hpp">boost/contract/public_function.hpp</link>&gt;
16054
16055 </phrase>
16056 <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> Override<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> VirtualResult<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> F<phrase role="special">,</phrase> 
16057          <phrase role="keyword">typename</phrase> Class<phrase role="special">,</phrase> <phrase role="keyword">typename</phrase><phrase role="special">...</phrase> Args<phrase role="special">&gt;</phrase> 
16058   <link linkend="boost.contract.specify__idm45394999179040">specify_precondition_old_postcondition_except</link><phrase role="special">&lt;</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&gt;</phrase> 
16059   <phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><link linkend="boost.contract.virtual_">virtual_</link> <phrase role="special">*</phrase> v<phrase role="special">,</phrase> <phrase role="identifier">VirtualResult</phrase> <phrase role="special">&amp;</phrase> r<phrase role="special">,</phrase> <phrase role="identifier">F</phrase> f<phrase role="special">,</phrase> <phrase role="identifier">Class</phrase> <phrase role="special">*</phrase> obj<phrase role="special">,</phrase> 
16060                   <phrase role="identifier">Args</phrase> <phrase role="special">&amp;</phrase><phrase role="special">...</phrase> args<phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
16061     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase><phrase role="special">,</phrase> \
16062             <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">w</phrase>
16063     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
16064 <phrase role="special">{</phrase>
16065     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
16066
16067     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
16068     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
16069
16070     <phrase role="keyword">void</phrase> <phrase role="identifier">invariant</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
16071         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16072         <phrase role="special">...</phrase>
16073     <phrase role="special">}</phrase>
16074
16075     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
16076
16077 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16078     <phrase role="comment">// Override from `b::f`.</phrase>
16079     <phrase role="identifier">t</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16080         <phrase role="identifier">t</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
16081         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase><phrase role="special">;</phrase>
16082         <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">c</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase>
16083                 <phrase role="identifier">override_f</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">u</phrase><phrase role="special">::</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">)</phrase>
16084             <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16085                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16086                 <phrase role="special">...</phrase>
16087             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16088             <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16089                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16090                 <phrase role="special">...</phrase>
16091             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16092             <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">(</phrase><phrase role="identifier">t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16093                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16094                 <phrase role="special">...</phrase>
16095             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16096             <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16097                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16098                 <phrase role="special">...</phrase>
16099             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16100         <phrase role="special">;</phrase>
16101
16102         <phrase role="special">...</phrase> <phrase role="comment">// Function body (use `return result = return_expr`).</phrase>
16103     <phrase role="special">}</phrase>
16104     
16105     <phrase role="special">...</phrase>
16106 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16107 </programlisting></para><para>A public function override should always call  <computeroutput><computeroutput><link linkend="boost.contract.public_f_idm45394998885120">boost::contract::public_function</link></computeroutput></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_">
16108         Public Function Overrides</link></para>
16109 </para>
16110
16111
16112
16113 </para><variablelist spacing="compact"><?dbhtml 
16114           list-presentation="table"
16115         ?><varlistentry><term>Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
16116                   list-presentation="table"
16117                 ?><varlistentry><term><computeroutput>args</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>f</computeroutput></term><listitem><para>A pointer to the enclosing public function override declaring the contract (but see <link linkend="boost_contract.advanced.function_overloads">
16118             Function Overloads</link>). </para></listitem></varlistentry><varlistentry><term><computeroutput>obj</computeroutput></term><listitem><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">
16119             Volatile Public Functions</link>). </para></listitem></varlistentry><varlistentry><term><computeroutput>r</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>v</computeroutput></term><listitem><para>The trailing parameter of type  <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing public function override. </para></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Template Parameters:</term><listitem><variablelist spacing="compact"><?dbhtml 
16120                   list-presentation="table"
16121                 ?><varlistentry><term><computeroutput>Args</computeroutput></term><listitem><para>The types of all parameters passed to the enclosing public function override declaring the contract, but excluding the trailing parameter type <computeroutput><computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput>*</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><computeroutput><link linkend="BOOST_CONTRACT_MAX_ARGS">BOOST_CONTRACT_MAX_ARGS</link></computeroutput></computeroutput>). (Usually these template parameters are automatically deduced by C++ and they do not need to be explicitly specified by programmers.)</para></listitem></varlistentry><varlistentry><term><computeroutput>Class</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>F</computeroutput></term><listitem><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></listitem></varlistentry><varlistentry><term><computeroutput>Override</computeroutput></term><listitem><para>The type trait <computeroutput>override_<emphasis>function-name</emphasis></computeroutput> declared using the <computeroutput><computeroutput><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput></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></listitem></varlistentry><varlistentry><term><computeroutput>VirtualResult</computeroutput></term><listitem><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">
16122                         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></listitem></varlistentry></variablelist></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><para>The result of this function must be assigned to a variable of type  <computeroutput><link linkend="boost.contract.check">boost::contract::check</link></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><link linkend="BOOST_CO_idm45394999694064">BOOST_CONTRACT_ON_MISSING_CHECK_DECL</link></computeroutput>). </para></listitem></varlistentry></variablelist></refsect1></refentry>
16123 </section>
16124 <section id="header.boost.contract_macro_hpp"><title>Header &lt;<ulink url="../../../../boost/contract_macro.hpp">boost/contract_macro.hpp</ulink>&gt;</title><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_">
16125 Disable Contract Compilation</link>). </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
16126
16127 <link linkend="BOOST_CO_idm45394998748208">BOOST_CONTRACT_PRECONDITION</link>(...)
16128 <link linkend="BOOST_CO_idm45394998736528">BOOST_CONTRACT_POSTCONDITION</link>(...)
16129 <link linkend="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</link>(...)
16130 <link linkend="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</link>(...)
16131 <link linkend="BOOST_CONTRACT_OLD_PTR">BOOST_CONTRACT_OLD_PTR</link>(...)
16132 <link linkend="BOOST_CO_idm45394998674080">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</link>(...)
16133 <link linkend="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</link>(...)
16134 <link linkend="BOOST_CO_idm45394998635328">BOOST_CONTRACT_INVARIANT_VOLATILE</link>(...)
16135 <link linkend="BOOST_CO_idm45394998621472">BOOST_CONTRACT_STATIC_INVARIANT</link>(...)
16136 <link linkend="BOOST_CONTRACT_CONSTRUCTOR">BOOST_CONTRACT_CONSTRUCTOR</link>(...)
16137 <link linkend="BOOST_CO_idm45394998587680">BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION</link>(...)
16138 <link linkend="BOOST_CONTRACT_DESTRUCTOR">BOOST_CONTRACT_DESTRUCTOR</link>(...)
16139 <link linkend="BOOST_CONTRACT_FUNCTION">BOOST_CONTRACT_FUNCTION</link>()
16140 <link linkend="BOOST_CO_idm45394998534992">BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION</link>(...)
16141 <link linkend="BOOST_CO_idm45394998517984">BOOST_CONTRACT_PUBLIC_FUNCTION</link>(...)
16142 <link linkend="BOOST_CO_idm45394998486064">BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</link>(...)</synopsis>
16143 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998748208"><refmeta><refentrytitle>Macro BOOST_CONTRACT_PRECONDITION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_PRECONDITION</refname><refpurpose>Program preconditions that can be completely disabled at compile-time. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16144
16145 </phrase>BOOST_CONTRACT_PRECONDITION(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para><computeroutput>BOOST_CONTRACT_PRECONDITION(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when  <computeroutput><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PRECONDITIONS</phrase>
16146     <phrase role="special">.</phrase><phrase role="identifier">precondition</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
16147 <phrase role="preprocessor">#endif</phrase>
16148 </programlisting></para><para>Where:</para><para><itemizedlist>
16149 <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><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></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>
16150 </listitem>
16151 </itemizedlist>
16152 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16153         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.preconditions"> Preconditions</link> </para>
16154 </para>
16155 </para></refsect1></refentry>
16156 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998736528"><refmeta><refentrytitle>Macro BOOST_CONTRACT_POSTCONDITION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_POSTCONDITION</refname><refpurpose>Program postconditions that can be completely disabled at compile-time. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16157
16158 </phrase>BOOST_CONTRACT_POSTCONDITION(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para><computeroutput>BOOST_CONTRACT_POSTCONDITION(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when  <computeroutput><link linkend="BOOST_CO_idm45394999656032">BOOST_CONTRACT_NO_POSTCONDITIONS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_POSTCONDITIONS</phrase>
16159     <phrase role="special">.</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
16160 <phrase role="preprocessor">#endif</phrase>
16161 </programlisting></para><para>Where:</para><para><itemizedlist>
16162 <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><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><link linkend="boost.contract.postcondition_failure">boost::contract::postcondition_failure</link></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>
16163 </listitem>
16164 </itemizedlist>
16165 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16166         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.postconditions"> Postconditions</link> </para>
16167 </para>
16168 </para></refsect1></refentry>
16169 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_EXCEPT"><refmeta><refentrytitle>Macro BOOST_CONTRACT_EXCEPT</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_EXCEPT</refname><refpurpose>Program exception guarantees that can be completely disabled at compile-time. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16170
16171 </phrase>BOOST_CONTRACT_EXCEPT(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para><computeroutput>BOOST_CONTRACT_EXCEPT(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when <computeroutput><link linkend="BOOST_CONTRACT_NO_EXCEPTS">BOOST_CONTRACT_NO_EXCEPTS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_EXCEPTS</phrase>
16172     <phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
16173 <phrase role="preprocessor">#endif</phrase>
16174 </programlisting></para><para>Where:</para><para><itemizedlist>
16175 <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><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling  <computeroutput><link linkend="boost.contract.except_failure">boost::contract::except_failure</link></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>
16176 </listitem>
16177 </itemizedlist>
16178 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16179         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.exception_guarantees"> Exception Guarantees</link> </para>
16180 </para>
16181 </para></refsect1></refentry>
16182 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_OLD"><refmeta><refentrytitle>Macro BOOST_CONTRACT_OLD</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_OLD</refname><refpurpose>Program old value copies at body that can be completely disabled at compile-time. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16183
16184 </phrase>BOOST_CONTRACT_OLD(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para><computeroutput>BOOST_CONTRACT_OLD(f)</computeroutput> expands to code equivalent to the following (note that no code is generated when <computeroutput><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
16185     <phrase role="special">.</phrase><phrase role="identifier">old</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
16186 <phrase role="preprocessor">#endif</phrase>
16187 </programlisting></para><para>Where:</para><para><itemizedlist>
16188 <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><link linkend="BOOST_CONTRACT_OLDOF">BOOST_CONTRACT_OLDOF</link></computeroutput>. Any exception thrown by a call to this functor will result in this library calling <computeroutput><link linkend="boost.contract.old_failure">boost::contract::old_failure</link></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>
16189 </listitem>
16190 </itemizedlist>
16191 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16192         Disable Contract Compilation</link>,  <link linkend="boost_contract.advanced.old_values_copied_at_body">
16193         Old Values Copied at Body</link> </para>
16194 </para>
16195 </para></refsect1></refentry>
16196 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_OLD_PTR"><refmeta><refentrytitle>Macro BOOST_CONTRACT_OLD_PTR</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_OLD_PTR</refname><refpurpose>Program old values that can be completely disabled at compile-time for old value types that are required to be copyable. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16197
16198 </phrase>BOOST_CONTRACT_OLD_PTR(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used to program old value copies for copyable types:</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
16199 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16200     <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16201         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_a</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase> <phrase role="comment">// Null...</phrase>
16202         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_b</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr_b</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase> <phrase role="comment">// Set.</phrase>
16203         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16204             <phrase role="special">...</phrase>
16205             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase>
16206                 <phrase role="identifier">old_var_a</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase> <phrase role="comment">// ...set.</phrase>
16207                 <phrase role="special">...</phrase>
16208             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16209             <phrase role="special">...</phrase>
16210         <phrase role="special">;</phrase>
16211
16212         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16213     <phrase role="special">}</phrase>
16214
16215     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">g</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16216         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_a</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase> <phrase role="comment">// No `v`</phrase>
16217         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_b</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_var_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr_b</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase> <phrase role="comment">// `v`</phrase>
16218         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16219             <phrase role="special">...</phrase>
16220             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase>
16221                 <phrase role="identifier">old_var_a</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase> <phrase role="comment">// `v`</phrase>
16222                 <phrase role="special">...</phrase>
16223             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16224             <phrase role="special">...</phrase>
16225         <phrase role="special">;</phrase>
16226
16227         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16228     <phrase role="special">}</phrase>
16229
16230     <phrase role="special">...</phrase>
16231 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16232 </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><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
16233     <phrase role="comment">// This declaration does not need to use `v`.</phrase>
16234     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase>
16235 <phrase role="preprocessor">#endif</phrase>
16236 </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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
16237     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase>
16238             <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase>
16239 <phrase role="preprocessor">#endif</phrase>
16240 </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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
16241     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase>
16242             <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase>
16243 <phrase role="preprocessor">#endif</phrase>
16244 </programlisting></para><para>Where:</para><para><itemizedlist>
16245 <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><link linkend="BOOST_CO_idm45394998674080">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</link></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>
16246 </listitem>
16247 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra training parameter of type  <computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></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>
16248 </listitem>
16249 <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>
16250 </listitem>
16251 <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>
16252 </listitem>
16253 </itemizedlist>
16254 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16255         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.old_values"> Old Values</link> </para>
16256 </para>
16257 </para></refsect1></refentry>
16258 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998674080"><refmeta><refentrytitle>Macro BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</refname><refpurpose>Program old values that can be completely disabled at compile-time for old value types that are not required to be copyable. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16259
16260 </phrase>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used to program old value copies for types that might or might not be copyable:</para><para><programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase> <phrase role="comment">// Type `T` might or not be copyable.</phrase>
16261 <phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
16262 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16263     <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16264         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_a</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16265         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_b</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_b</phrase><phrase role="special">,</phrase>
16266                 <phrase role="identifier">old_expr_b</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16267         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16268             <phrase role="special">...</phrase>
16269             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase>
16270                 <phrase role="identifier">old_var_a</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16271                 <phrase role="special">...</phrase>
16272             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16273             <phrase role="special">...</phrase> <phrase role="comment">// In postconditions or exception guarantees:</phrase>
16274                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_a</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="comment">// Always null for non-copyable types.</phrase>
16275                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_b</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="comment">// Always null for non-copyable types.</phrase>
16276             <phrase role="special">...</phrase>
16277         <phrase role="special">;</phrase>
16278
16279         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16280     <phrase role="special">}</phrase>
16281
16282     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">g</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16283         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_a</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16284         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR_IF_COPYABLE</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type_b</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_var_b</phrase><phrase role="special">,</phrase>
16285                 <phrase role="identifier">old_expr_b</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16286         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16287             <phrase role="special">...</phrase>
16288             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase>
16289                 <phrase role="identifier">old_var_a</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr_a</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16290                 <phrase role="special">...</phrase>
16291             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16292             <phrase role="special">...</phrase> <phrase role="comment">// In postconditions or exception guarantees:</phrase>
16293                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_a</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="comment">// Always null for non-copyable types.</phrase>
16294                 <phrase role="keyword">if</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var_b</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="comment">// Always null for non-copyable types.</phrase>
16295             <phrase role="special">...</phrase>
16296         <phrase role="special">;</phrase>
16297
16298         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16299     <phrase role="special">}</phrase>
16300
16301     <phrase role="special">...</phrase>
16302 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16303 </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><link linkend="BOOST_CONTRACT_NO_OLDS">BOOST_CONTRACT_NO_OLDS</link></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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
16304     <phrase role="comment">// This declaration does not need to use `v`.</phrase>
16305     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase>
16306 <phrase role="preprocessor">#endif</phrase>
16307 </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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
16308     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase>
16309             <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase>
16310 <phrase role="preprocessor">#endif</phrase>
16311 </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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_OLDS</phrase>
16312     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">old_ptr_if_copyable</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">old_type</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase>
16313             <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase>
16314 <phrase role="preprocessor">#endif</phrase>
16315 </programlisting></para><para>Where:</para><para><itemizedlist>
16316 <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><link linkend="BOOST_CONTRACT_OLD_PTR">BOOST_CONTRACT_OLD_PTR</link></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.) </para>
16317 </listitem>
16318 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra trailing parameter of type  <computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></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>
16319 </listitem>
16320 <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>
16321 </listitem>
16322 <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>
16323 </listitem>
16324 </itemizedlist>
16325 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16326         Disable Contract Compilation</link>,  <link linkend="boost_contract.extras.old_value_requirements__templates_">
16327         Old Value Requirements</link> </para>
16328 </para>
16329 </para></refsect1></refentry>
16330 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_INVARIANT"><refmeta><refentrytitle>Macro BOOST_CONTRACT_INVARIANT</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_INVARIANT</refname><refpurpose>Program (constant) class invariants that can be completely disabled at compile-time. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16331
16332 </phrase>BOOST_CONTRACT_INVARIANT(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para><computeroutput>BOOST_CONTRACT_INVARIANT</computeroutput>({ ... }) expands to code equivalent to the following (note that no code is generated when  <computeroutput><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_INVARIANTS</phrase>
16333     <phrase role="keyword">void</phrase> <phrase role="identifier">BOOST_CONTRACT_INVARIANT_FUNC</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase>
16334         <phrase role="special">...</phrase>
16335     <phrase role="special">}</phrase>
16336 <phrase role="preprocessor">#endif</phrase>
16337 </programlisting></para><para>Where:</para><para><itemizedlist>
16338 <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><link linkend="BOOST_CO_idm45394998621472">BOOST_CONTRACT_STATIC_INVARIANT</link></computeroutput> and  <computeroutput><link linkend="BOOST_CO_idm45394998635328">BOOST_CONTRACT_INVARIANT_VOLATILE</link></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><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></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><link linkend="boost.contract.entry_invariant_failure">boost::contract::entry_invariant_failure</link></computeroutput> or  <computeroutput><link linkend="boost.contract.exit_invariant_failure">boost::contract::exit_invariant_failure</link></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)</para>
16339 </listitem>
16340 </itemizedlist>
16341 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16342         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link> </para>
16343 </para>
16344 </para></refsect1></refentry>
16345 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998635328"><refmeta><refentrytitle>Macro BOOST_CONTRACT_INVARIANT_VOLATILE</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_INVARIANT_VOLATILE</refname><refpurpose>Program volatile class invariants that can be completely disabled at compile-time. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16346
16347 </phrase>BOOST_CONTRACT_INVARIANT_VOLATILE(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para><computeroutput>BOOST_CONTRACT_INVARIANT_VOLATILE</computeroutput>({ ... }) expands to code equivalent to the following (note that no code is generated when  <computeroutput><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_INVARIANTS</phrase>
16348     <phrase role="keyword">void</phrase> <phrase role="identifier">BOOST_CONTRACT_INVARIANT_FUNC</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> <phrase role="special">{</phrase>
16349         <phrase role="special">...</phrase>
16350     <phrase role="special">}</phrase>
16351 <phrase role="preprocessor">#endif</phrase>
16352 </programlisting></para><para>Where:</para><para><itemizedlist>
16353 <listitem><para><emphasis role="bold">{ ... }</emphasis> is the definition of the function that checks class invariants for volatile public functions (see <computeroutput><link linkend="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</link></computeroutput> and  <computeroutput><link linkend="BOOST_CO_idm45394998621472">BOOST_CONTRACT_STATIC_INVARIANT</link></computeroutput>). The curly parenthesis are mandatory. Assertions within this function are usually programmed using  <computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></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><link linkend="boost.contract.entry_invariant_failure">boost::contract::entry_invariant_failure</link></computeroutput> or  <computeroutput><link linkend="boost.contract.exit_invariant_failure">boost::contract::exit_invariant_failure</link></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)</para>
16354 </listitem>
16355 </itemizedlist>
16356 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16357         Disable Contract Compilation</link>,  <link linkend="boost_contract.extras.volatile_public_functions">
16358         Volatile Public Functions</link> </para>
16359 </para>
16360 </para></refsect1></refentry>
16361 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998621472"><refmeta><refentrytitle>Macro BOOST_CONTRACT_STATIC_INVARIANT</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_STATIC_INVARIANT</refname><refpurpose>Program static class invariants that can be completely disabled at compile-time. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16362
16363 </phrase>BOOST_CONTRACT_STATIC_INVARIANT(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para><computeroutput>BOOST_CONTRACT_STATIC_INVARIANT</computeroutput>({ ... }) expands to code equivalent to the following (note that no code is generated when  <computeroutput><link linkend="BOOST_CO_idm45394999622032">BOOST_CONTRACT_NO_INVARIANTS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_INVARIANTS</phrase>
16364     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">BOOST_CONTRACT_STATIC_INVARIANT_FUNC</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16365         <phrase role="special">...</phrase>
16366     <phrase role="special">}</phrase>
16367 <phrase role="preprocessor">#endif</phrase>
16368 </programlisting></para><para>Where:</para><para><itemizedlist>
16369 <listitem><para><emphasis role="bold">{ ... }</emphasis> is the definition of the function that checks class invariants for static public functions (see <computeroutput><link linkend="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</link></computeroutput> and  <computeroutput><link linkend="BOOST_CO_idm45394998635328">BOOST_CONTRACT_INVARIANT_VOLATILE</link></computeroutput>). The curly parenthesis are mandatory. Assertions within this function are usually programmed using  <computeroutput><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></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><link linkend="boost.contract.entry_invariant_failure">boost::contract::entry_invariant_failure</link></computeroutput> or  <computeroutput><link linkend="boost.contract.exit_invariant_failure">boost::contract::exit_invariant_failure</link></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)</para>
16370 </listitem>
16371 </itemizedlist>
16372 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16373         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.class_invariants"> Class Invariants</link> </para>
16374 </para>
16375 </para></refsect1></refentry>
16376 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_CONSTRUCTOR"><refmeta><refentrytitle>Macro BOOST_CONTRACT_CONSTRUCTOR</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_CONSTRUCTOR</refname><refpurpose>Program contracts that can be completely disabled at compile-time for constructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16377
16378 </phrase>BOOST_CONTRACT_CONSTRUCTOR(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used together with <computeroutput><link linkend="BOOST_CO_idm45394998736528">BOOST_CONTRACT_POSTCONDITION</link></computeroutput>,  <computeroutput><link linkend="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</link></computeroutput> to specify postconditions, exception guarantees, and old value copies at body that can be completely disabled at compile-time for constructors (see  <computeroutput><link linkend="BOOST_CO_idm45394998587680">BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION</link></computeroutput> to specify preconditions for constructors):</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
16379     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
16380
16381     <phrase role="identifier">BOOST_CONTRACT_INVARIANT</phrase><phrase role="special">(</phrase><phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
16382         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16383         <phrase role="special">...</phrase>
16384     <phrase role="special">}</phrase><phrase role="special">)</phrase>
16385
16386 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16387     <phrase role="identifier">u</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16388         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16389         <phrase role="identifier">BOOST_CONTRACT_CONSTRUCTOR</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16390             <phrase role="comment">// No `PRECONDITION` (use `CONSTRUCTOR_PRECONDITION` if needed).</phrase>
16391             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16392                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_epxr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16393                 <phrase role="special">...</phrase>
16394             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16395             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16396                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16397                 <phrase role="special">...</phrase>
16398             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16399             <phrase role="identifier">BOOST_CONTRACT_EXCEPT</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16400                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16401                 <phrase role="special">...</phrase>
16402             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16403         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16404
16405         <phrase role="special">...</phrase> <phrase role="comment">// Constructor body.</phrase>
16406     <phrase role="special">}</phrase>
16407
16408     <phrase role="special">...</phrase>
16409 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16410 </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><link linkend="BOOST_CO_idm45394999605408">BOOST_CONTRACT_NO_CONSTRUCTORS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_CONSTRUCTORS</phrase>
16411     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase>
16412             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor</phrase><phrase role="special">(</phrase><phrase role="identifier">obj</phrase><phrase role="special">)</phrase>
16413 <phrase role="preprocessor">#endif</phrase>
16414 </programlisting></para><para>Where:</para><para><itemizedlist>
16415 <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><link linkend="BOOST_CONTRACT_INVARIANT">BOOST_CONTRACT_INVARIANT</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394998621472">BOOST_CONTRACT_STATIC_INVARIANT</link></computeroutput>, and  <computeroutput><link linkend="BOOST_CO_idm45394998635328">BOOST_CONTRACT_INVARIANT_VOLATILE</link></computeroutput>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.) </para>
16416 </listitem>
16417 <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>
16418 </listitem>
16419 </itemizedlist>
16420 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16421         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.constructors"> Constructors</link> </para>
16422 </para>
16423 </para></refsect1></refentry>
16424 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998587680"><refmeta><refentrytitle>Macro BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION</refname><refpurpose>Program preconditions that can be disabled at compile-time for constructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16425
16426 </phrase>BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used together with <computeroutput><link linkend="BOOST_CONTRACT_CONSTRUCTOR">BOOST_CONTRACT_CONSTRUCTOR</link></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><link linkend="boost.contract.constructor_precondition">boost::contract::constructor_precondition</link></computeroutput> must be the first and private base of the class declaring the constructor for which preconditions are programmed:</para><para><programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
16427     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase><phrase role="special">,</phrase> \
16428             <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase>
16429     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
16430 <phrase role="special">{</phrase>
16431     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
16432
16433     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
16434     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
16435
16436     <phrase role="special">...</phrase>
16437
16438 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16439     <phrase role="keyword">explicit</phrase> <phrase role="identifier">u</phrase><phrase role="special">(</phrase><phrase role="keyword">unsigned</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase>
16440         <phrase role="identifier">BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION</phrase><phrase role="special">(</phrase><phrase role="identifier">u</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase>
16441             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="identifier">x</phrase> <phrase role="special">!=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16442         <phrase role="special">}</phrase><phrase role="special">)</phrase><phrase role="special">,</phrase>
16443         <phrase role="identifier">b</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase> <phrase role="special">/</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase>
16444     <phrase role="special">{</phrase>
16445         <phrase role="special">...</phrase>
16446     <phrase role="special">}</phrase>
16447
16448     <phrase role="special">...</phrase>
16449 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16450 </programlisting></para><para><computeroutput>BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(class_type)(f)</computeroutput> expands to code equivalent to the following (note that when  <computeroutput><link linkend="BOOST_CO_idm45394999662416">BOOST_CONTRACT_NO_PRECONDITIONS</link></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><phrase role="comment">// Guarded only by NO_PRECONDITIONS (and not also by NO_CONSTRUCTORS)</phrase>
16451 <phrase role="comment">// because for constructor's preconditions (not for postconditions, etc.).</phrase>
16452 <phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PRECONDITIONS</phrase>
16453     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">class_type</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase>
16454 <phrase role="preprocessor">#else</phrase> <phrase role="comment">// No-op call (likely optimized away, minimal to no overhead).</phrase>
16455     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">class_type</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase>
16456 <phrase role="preprocessor">#endif</phrase>
16457 </programlisting></para><para>Where:</para><para><itemizedlist>
16458 <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>
16459 </listitem>
16460 <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><link linkend="BOOST_CONTRACT_ASSERT">BOOST_CONTRACT_ASSERT</link></computeroutput>, but any exception thrown by a call to this functor indicates a contract failure (and will result in this library calling  <computeroutput><link linkend="boost.contract.precondition_failure">boost::contract::precondition_failure</link></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>
16461 </listitem>
16462 </itemizedlist>
16463 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16464         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.constructors"> Constructors</link> </para>
16465 </para>
16466 </para></refsect1></refentry>
16467 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_DESTRUCTOR"><refmeta><refentrytitle>Macro BOOST_CONTRACT_DESTRUCTOR</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_DESTRUCTOR</refname><refpurpose>Program contracts that can be completely disabled at compile-time for destructors. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16468
16469 </phrase>BOOST_CONTRACT_DESTRUCTOR(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used together with <computeroutput><link linkend="BOOST_CO_idm45394998736528">BOOST_CONTRACT_POSTCONDITION</link></computeroutput>,  <computeroutput><link linkend="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</link></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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
16470     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
16471
16472     <phrase role="identifier">BOOST_CONTRACT_INVARIANT</phrase><phrase role="special">(</phrase><phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
16473         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16474         <phrase role="special">...</phrase>
16475     <phrase role="special">}</phrase><phrase role="special">)</phrase>
16476
16477 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16478     <phrase role="special">~</phrase><phrase role="identifier">u</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16479         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16480         <phrase role="identifier">BOOST_CONTRACT_DESTRUCTOR</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16481             <phrase role="comment">// No `PRECONDITION` (destructors have no preconditions).</phrase>
16482             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16483                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16484                 <phrase role="special">...</phrase>
16485             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16486             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16487                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16488                 <phrase role="special">...</phrase>
16489             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16490             <phrase role="identifier">BOOST_CONTRACT_EXCEPT</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16491                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16492                 <phrase role="special">...</phrase>
16493             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16494         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16495
16496         <phrase role="special">...</phrase> <phrase role="comment">// Destructor body.</phrase>
16497     <phrase role="special">}</phrase>
16498     
16499     <phrase role="special">...</phrase>
16500 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16501 </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><link linkend="BOOST_CO_idm45394999594544">BOOST_CONTRACT_NO_DESTRUCTORS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_DESTRUCTORS</phrase>
16502     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase>
16503             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">destructor</phrase><phrase role="special">(</phrase><phrase role="identifier">obj</phrase><phrase role="special">)</phrase>
16504 <phrase role="preprocessor">#endif</phrase>
16505 </programlisting></para><para>Where:</para><para><itemizedlist>
16506 <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">
16507         Class Invariants</link> and  <link linkend="boost_contract.extras.volatile_public_functions">
16508         Volatile Public Functions</link>). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.) </para>
16509 </listitem>
16510 <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>
16511 </listitem>
16512 </itemizedlist>
16513 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16514         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.destructors"> Destructors</link> </para>
16515 </para>
16516 </para></refsect1></refentry>
16517 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CONTRACT_FUNCTION"><refmeta><refentrytitle>Macro BOOST_CONTRACT_FUNCTION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_FUNCTION</refname><refpurpose>Program contracts that can be completely disabled at compile-time for (non-public) functions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16518
16519 </phrase>BOOST_CONTRACT_FUNCTION()</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used together with <computeroutput><link linkend="BOOST_CO_idm45394998748208">BOOST_CONTRACT_PRECONDITION</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394998736528">BOOST_CONTRACT_POSTCONDITION</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</link></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><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16520     <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16521     <phrase role="identifier">BOOST_CONTRACT_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase>
16522         <phrase role="identifier">BOOST_CONTRACT_PRECONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16523             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16524             <phrase role="special">...</phrase>
16525         <phrase role="special">}</phrase><phrase role="special">)</phrase>
16526         <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16527             <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>  
16528             <phrase role="special">...</phrase>
16529         <phrase role="special">}</phrase><phrase role="special">)</phrase>
16530         <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16531             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16532             <phrase role="special">...</phrase>
16533         <phrase role="special">}</phrase><phrase role="special">)</phrase>
16534         <phrase role="identifier">BOOST_CONTRACT_EXCEPT</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16535             <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16536             <phrase role="special">...</phrase>
16537         <phrase role="special">}</phrase><phrase role="special">)</phrase>
16538     <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16539
16540     <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16541 <phrase role="special">}</phrase>
16542 </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><link linkend="BOOST_CO_idm45394999577072">BOOST_CONTRACT_NO_FUNCTIONS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_FUNCTIONS</phrase>
16543     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase>
16544             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase>
16545 <phrase role="preprocessor">#endif</phrase>
16546 </programlisting></para><para>Where:</para><para><itemizedlist>
16547 <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>
16548 </listitem>
16549 </itemizedlist>
16550 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16551         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">
16552         Private and Protected Functions</link>,  <link linkend="boost_contract.advanced.lambdas__loops__code_blocks__and__constexpr__">
16553         Lambdas, Loops, Code Blocks</link> </para>
16554 </para>
16555 </para></refsect1></refentry>
16556 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998534992"><refmeta><refentrytitle>Macro BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION</refname><refpurpose>Program contracts that can be completely disabled at compile-time for static public functions. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16557
16558 </phrase>BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used together with <computeroutput><link linkend="BOOST_CO_idm45394998748208">BOOST_CONTRACT_PRECONDITION</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394998736528">BOOST_CONTRACT_POSTCONDITION</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</link></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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
16559     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
16560
16561     <phrase role="identifier">BOOST_CONTRACT_STATIC_INVARIANT</phrase><phrase role="special">(</phrase><phrase role="special">{</phrase> <phrase role="comment">// Optional (as for non-static).</phrase>
16562         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16563         <phrase role="special">...</phrase>
16564     <phrase role="special">}</phrase><phrase role="special">)</phrase>
16565
16566 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16567     <phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16568         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16569         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="identifier">u</phrase><phrase role="special">)</phrase>
16570             <phrase role="identifier">BOOST_CONTRACT_PRECONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16571                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16572                 <phrase role="special">...</phrase>
16573             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16574             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16575                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16576                 <phrase role="special">...</phrase>
16577             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16578             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16579                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16580                 <phrase role="special">...</phrase>
16581             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16582             <phrase role="identifier">BOOST_CONTRACT_EXCEPT</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16583                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16584                 <phrase role="special">...</phrase>
16585             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16586         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16587
16588         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16589     <phrase role="special">}</phrase>
16590     
16591     <phrase role="special">...</phrase>
16592 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16593 </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><link linkend="BOOST_CO_idm45394999586272">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</link></computeroutput> is defined):</para><para><programlisting><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
16594     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase>
16595             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">class_type</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase>
16596 <phrase role="preprocessor">#endif</phrase>
16597 </programlisting></para><para>Where:</para><para><itemizedlist>
16598 <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>
16599 </listitem>
16600 <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>
16601 </listitem>
16602 </itemizedlist>
16603 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16604         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.static_public_functions"> Static Public Functions</link> </para>
16605 </para>
16606 </para></refsect1></refentry>
16607 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998517984"><refmeta><refentrytitle>Macro BOOST_CONTRACT_PUBLIC_FUNCTION</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_PUBLIC_FUNCTION</refname><refpurpose>Program contracts that can be completely disabled at compile-time for non-static public functions that do not override. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16608
16609 </phrase>BOOST_CONTRACT_PUBLIC_FUNCTION(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used together with <computeroutput><link linkend="BOOST_CO_idm45394998748208">BOOST_CONTRACT_PRECONDITION</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394998736528">BOOST_CONTRACT_POSTCONDITION</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</link></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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase> <phrase role="special">{</phrase>
16610     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
16611
16612     <phrase role="identifier">BOOST_CONTRACT_INVARIANT</phrase><phrase role="special">(</phrase><phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
16613         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16614         <phrase role="special">...</phrase>
16615     <phrase role="special">}</phrase><phrase role="special">)</phrase>
16616
16617 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16618     <phrase role="comment">// Non-virtual (same if void).</phrase>
16619     <phrase role="identifier">t</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16620         <phrase role="identifier">t</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
16621         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16622         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16623             <phrase role="identifier">BOOST_CONTRACT_PRECONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16624                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16625                 <phrase role="special">...</phrase>
16626             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16627             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16628                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16629                 <phrase role="special">...</phrase>
16630             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16631             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16632                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16633                 <phrase role="special">...</phrase>
16634             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16635             <phrase role="identifier">BOOST_CONTRACT_EXCEPT</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16636                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16637                 <phrase role="special">...</phrase>
16638             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16639         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16640
16641         <phrase role="special">...</phrase> <phrase role="comment">// Function body (use `return result = return_expr`).</phrase>
16642     <phrase role="special">}</phrase>
16643     
16644     <phrase role="comment">// Virtual and void.</phrase>
16645     <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">g</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16646         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16647         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16648             <phrase role="special">...</phrase>
16649             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16650                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16651                 <phrase role="special">...</phrase>
16652             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16653             <phrase role="special">...</phrase>
16654         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16655         
16656         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16657     <phrase role="special">}</phrase>
16658     
16659     <phrase role="comment">// Virtual and non-void.</phrase>
16660     <phrase role="keyword">virtual</phrase> <phrase role="identifier">t</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16661         <phrase role="identifier">t</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
16662         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16663         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase>
16664             <phrase role="special">...</phrase>
16665             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16666                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16667                 <phrase role="special">...</phrase>
16668             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16669             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">(</phrase><phrase role="identifier">t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional</phrase>
16670                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16671                 <phrase role="special">...</phrase>
16672             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16673             <phrase role="special">...</phrase>
16674         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16675         
16676         <phrase role="special">...</phrase> <phrase role="comment">// Function body (use `return result = return_expr`).</phrase>
16677     <phrase role="special">}</phrase>
16678     
16679     <phrase role="special">...</phrase>
16680 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16681 </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><link linkend="BOOST_CO_idm45394998517984">BOOST_CONTRACT_PUBLIC_FUNCTION</link></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><link linkend="BOOST_CO_idm45394999586272">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</link></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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
16682     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase>
16683             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">obj</phrase><phrase role="special">)</phrase>
16684 <phrase role="preprocessor">#endif</phrase>
16685 </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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
16686     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase>
16687             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">obj</phrase><phrase role="special">)</phrase>
16688 <phrase role="preprocessor">#endif</phrase>
16689 </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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
16690     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase>
16691             <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">public_function</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">r</phrase><phrase role="special">,</phrase> <phrase role="identifier">obj</phrase><phrase role="special">)</phrase>
16692 <phrase role="preprocessor">#endif</phrase>
16693 </programlisting></para><para>Where (these are all variadic macro parameters so they can contain commas not protected by round parenthesis):</para><para><itemizedlist>
16694 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra parameter of type  <computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function declaring the contract. </para>
16695 </listitem>
16696 <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>
16697 </listitem>
16698 <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">
16699         Volatile Public Functions</link>). </para>
16700 </listitem>
16701 <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>
16702 </listitem>
16703 </itemizedlist>
16704 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16705         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.public_functions"> Public Functions</link>,  <link linkend="boost_contract.tutorial.virtual_public_functions">
16706         Virtual Public Functions</link> </para>
16707 </para>
16708 </para></refsect1></refentry>
16709 <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="BOOST_CO_idm45394998486064"><refmeta><refentrytitle>Macro BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</refname><refpurpose>Program contracts that can be completely disabled at compile-time for public function overrides. </refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.boost.contract_macro_hpp">boost/contract_macro.hpp</link>&gt;
16710
16711 </phrase>BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(...)</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>This is used together with <computeroutput><link linkend="BOOST_CO_idm45394998748208">BOOST_CONTRACT_PRECONDITION</link></computeroutput>,  <computeroutput><link linkend="BOOST_CO_idm45394998736528">BOOST_CONTRACT_POSTCONDITION</link></computeroutput>, <computeroutput><link linkend="BOOST_CONTRACT_EXCEPT">BOOST_CONTRACT_EXCEPT</link></computeroutput>, and <computeroutput><link linkend="BOOST_CONTRACT_OLD">BOOST_CONTRACT_OLD</link></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><phrase role="keyword">class</phrase> <phrase role="identifier">u</phrase>
16712     <phrase role="preprocessor">#define</phrase> <phrase role="identifier">BASES</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">constructor_precondition</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">u</phrase><phrase role="special">&gt;</phrase><phrase role="special">,</phrase> \
16713             <phrase role="keyword">public</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">w</phrase>
16714     <phrase role="special">:</phrase> <phrase role="identifier">BASES</phrase>
16715 <phrase role="special">{</phrase>
16716     <phrase role="keyword">friend</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">access</phrase><phrase role="special">;</phrase>
16717
16718     <phrase role="keyword">typedef</phrase> <phrase role="identifier">BOOST_CONTRACT_BASE_TYPES</phrase><phrase role="special">(</phrase><phrase role="identifier">BASES</phrase><phrase role="special">)</phrase> <phrase role="identifier">base_types</phrase><phrase role="special">;</phrase>
16719     <phrase role="preprocessor">#undef</phrase> <phrase role="identifier">BASES</phrase>
16720
16721     <phrase role="identifier">BOOST_CONTRACT_INVARIANT</phrase><phrase role="special">(</phrase><phrase role="special">{</phrase> <phrase role="comment">// Optional (as for static and volatile).</phrase>
16722         <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16723         <phrase role="special">...</phrase>
16724     <phrase role="special">}</phrase><phrase role="special">)</phrase>
16725
16726     <phrase role="identifier">BOOST_CONTRACT_OVERRIDES</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="identifier">g</phrase><phrase role="special">)</phrase>
16727
16728 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
16729     <phrase role="comment">// Override from `b::f`, and void.</phrase>
16730     <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16731         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16732         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">override_f</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase>
16733                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">u</phrase><phrase role="special">::</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">)</phrase>
16734             <phrase role="identifier">BOOST_CONTRACT_PRECONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16735                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16736                 <phrase role="special">...</phrase>
16737             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16738             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16739                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16740                 <phrase role="special">...</phrase>
16741             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16742             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16743                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16744                 <phrase role="special">...</phrase>
16745             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16746             <phrase role="identifier">BOOST_CONTRACT_EXCEPT</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16747                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16748                 <phrase role="special">...</phrase>
16749             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16750         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16751
16752         <phrase role="special">...</phrase> <phrase role="comment">// Function body.</phrase>
16753     <phrase role="special">}</phrase>
16754     
16755     <phrase role="comment">// Override from `b::g`, and void.</phrase>
16756     <phrase role="identifier">t</phrase> <phrase role="identifier">g</phrase><phrase role="special">(</phrase><phrase role="identifier">t_1</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">t_n</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">virtual_</phrase><phrase role="special">*</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase>
16757         <phrase role="identifier">t</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
16758         <phrase role="identifier">BOOST_CONTRACT_OLD_PTR</phrase><phrase role="special">(</phrase><phrase role="identifier">old_type</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase><phrase role="identifier">old_var</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16759         <phrase role="identifier">BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</phrase><phrase role="special">(</phrase><phrase role="identifier">override_g</phrase><phrase role="special">)</phrase><phrase role="special">(</phrase>
16760                 <phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">result</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">u</phrase><phrase role="special">::</phrase><phrase role="identifier">g</phrase><phrase role="special">,</phrase> <phrase role="keyword">this</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_1</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">,</phrase> <phrase role="identifier">a_n</phrase><phrase role="special">)</phrase>
16761             <phrase role="special">...</phrase>
16762             <phrase role="identifier">BOOST_CONTRACT_OLD</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional.</phrase>
16763                 <phrase role="identifier">old_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">BOOST_CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">old_expr</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16764                 <phrase role="special">...</phrase>
16765             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16766             <phrase role="identifier">BOOST_CONTRACT_POSTCONDITION</phrase><phrase role="special">(</phrase><phrase role="special">[</phrase><phrase role="special">&amp;</phrase><phrase role="special">]</phrase> <phrase role="special">(</phrase><phrase role="identifier">t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Optional</phrase>
16767                 <phrase role="identifier">BOOST_CONTRACT_ASSERT</phrase><phrase role="special">(</phrase><phrase role="special">...</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
16768                 <phrase role="special">...</phrase>
16769             <phrase role="special">}</phrase><phrase role="special">)</phrase>
16770             <phrase role="special">...</phrase>
16771         <phrase role="special">;</phrase> <phrase role="comment">// Trailing `;` is required.</phrase>
16772
16773         <phrase role="special">...</phrase> <phrase role="comment">// Function body (use `return result = return_expr`).</phrase>
16774     <phrase role="special">}</phrase>
16775     
16776     <phrase role="special">...</phrase>
16777 <phrase role="special">}</phrase><phrase role="special">;</phrase>
16778 </programlisting></para><para>Public function overrides should always use  <computeroutput><link linkend="BOOST_CO_idm45394998486064">BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE</link></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><link linkend="BOOST_CO_idm45394999586272">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</link></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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
16779     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase>
16780             <phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">override_type</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="identifier">obj</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">)</phrase>
16781 <phrase role="preprocessor">#endif</phrase>
16782 </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><phrase role="preprocessor">#ifndef</phrase> <phrase role="identifier">BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS</phrase>
16783     <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase><phrase role="identifier">check</phrase> <phrase role="identifier">internal_var</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">contract</phrase><phrase role="special">::</phrase>
16784             <phrase role="identifier">public_function</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">override_type</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="identifier">v</phrase><phrase role="special">,</phrase> <phrase role="identifier">r</phrase><phrase role="special">,</phrase> <phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="identifier">obj</phrase><phrase role="special">,</phrase> <phrase role="special">...</phrase><phrase role="special">)</phrase>
16785 <phrase role="preprocessor">#endif</phrase>
16786 </programlisting></para><para>Where (these are all variadic macro parameters so they can contain commas not protected by round parenthesis):</para><para><itemizedlist>
16787 <listitem><para><computeroutput><emphasis role="bold">override_type</emphasis></computeroutput> is the type <computeroutput>override_<emphasis>function-name</emphasis></computeroutput> declared using the  <computeroutput><link linkend="BOOST_CONTRACT_OVERRIDE">BOOST_CONTRACT_OVERRIDE</link></computeroutput> or related macros. </para>
16788 </listitem>
16789 <listitem><para><computeroutput><emphasis role="bold">v</emphasis></computeroutput> is the extra parameter of type  <computeroutput><link linkend="boost.contract.virtual_">boost::contract::virtual_</link></computeroutput><computeroutput>*</computeroutput> and default value <computeroutput>0</computeroutput> from the enclosing virtual public function declaring the contract. </para>
16790 </listitem>
16791 <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>
16792 </listitem>
16793 <listitem><para><computeroutput><emphasis role="bold">f</emphasis></computeroutput> is a pointer to the enclosing public function override declaring the contract. </para>
16794 </listitem>
16795 <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">
16796         Volatile Public Functions</link>). </para>
16797 </listitem>
16798 <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>
16799 </listitem>
16800 <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>
16801 </listitem>
16802 </itemizedlist>
16803 <para><emphasis role="bold">See Also:</emphasis><para> <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">
16804         Disable Contract Compilation</link>,  <link linkend="boost_contract.tutorial.public_function_overrides__subcontracting_">
16805         Public Function Overrides</link> </para>
16806 </para>
16807 </para></refsect1></refentry>
16808 </section>
16809 </section>
16810   <section id="boost_contract.release_notes">
16811     <title><link linkend="boost_contract.release_notes">Release Notes</link></title>
16812     <para>
16813       This section contains notes on all releases of this library (from the latest
16814       to the oldest).
16815     </para>
16816     <section id="boost_contract.release_notes.release_1_0_1">
16817       <title><link linkend="boost_contract.release_notes.release_1_0_1">Release 1.0.1</link></title>
16818       <para>
16819         September 12, 2019
16820       </para>
16821       <para>
16822         Cleanups and small fixes:
16823       </para>
16824       <orderedlist inheritnum="ignore" continuation="restarts">
16825         <listitem>
16826           <simpara>
16827             Using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uncaught_exceptions</phrase></computeroutput> on C++17 compilers
16828             onward (instead of the now obsolete <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uncaught_exception</phrase></computeroutput>).
16829           </simpara>
16830         </listitem>
16831         <listitem>
16832           <simpara>
16833             Fixed a few warnings.
16834           </simpara>
16835         </listitem>
16836         <listitem>
16837           <simpara>
16838             Removed linking to Boost.System (Boost.System is now a header-only library).
16839           </simpara>
16840         </listitem>
16841         <listitem>
16842           <simpara>
16843             Added this library to Boost's Continuous Integration (CI).
16844           </simpara>
16845         </listitem>
16846         <listitem>
16847           <simpara>
16848             Fixed documentation typos.
16849           </simpara>
16850         </listitem>
16851       </orderedlist>
16852       <para>
16853         Released files are part of <ulink url="https://www.boost.org/users/history/">Boost
16854         1.72.0</ulink>.
16855       </para>
16856     </section>
16857     <section id="boost_contract.release_notes.release_1_0_0">
16858       <title><link linkend="boost_contract.release_notes.release_1_0_0">Release 1.0.0</link></title>
16859       <para>
16860         January 6, 2018 (Il Giorno della Befana)
16861       </para>
16862       <para>
16863         First Boost release:
16864       </para>
16865       <orderedlist inheritnum="ignore" continuation="restarts">
16866         <listitem>
16867           <simpara>
16868             Fixed all tests to pass as Boost regression tests (and marked those that
16869             are expected to fail on some specific compiler/platform versions).
16870           </simpara>
16871         </listitem>
16872         <listitem>
16873           <simpara>
16874             Adjusted build scripts to work within Boost libraries.
16875           </simpara>
16876         </listitem>
16877         <listitem>
16878           <simpara>
16879             Updated documentation to fit as a Boost library.
16880           </simpara>
16881         </listitem>
16882       </orderedlist>
16883       <para>
16884         Released files are part of <ulink url="https://www.boost.org/users/history/">Boost
16885         1.67.0</ulink>.
16886       </para>
16887     </section>
16888     <section id="boost_contract.release_notes.release_0_5_0">
16889       <title><link linkend="boost_contract.release_notes.release_0_5_0">Release 0.5.0</link></title>
16890       <para>
16891         September 2, 2017
16892       </para>
16893       <para>
16894         Contracts without the macros:
16895       </para>
16896       <orderedlist inheritnum="ignore" continuation="restarts">
16897         <listitem>
16898           <simpara>
16899             Using plain C++ code instead of macros to program contracts.
16900             <orderedlist inheritnum="ignore" continuation="restarts">
16901               <listitem>
16902                 <simpara>
16903                   The removed macros very hard to use because they required programmers
16904                   to learn a domain-specific embedded language that replaced the
16905                   usual C++ syntax for declaring functions and classes.
16906                 </simpara>
16907               </listitem>
16908               <listitem>
16909                 <simpara>
16910                   The removed macros also made the code less readable, increased
16911                   compilation time (because of extensive preprocessor meta-programming),
16912                   and gave cryptic compiler errors.
16913                 </simpara>
16914               </listitem>
16915               <listitem>
16916                 <simpara>
16917                   However, the removed macros more correctly specified contracts
16918                   in code declarations instead of definitions, and they completely
16919                   removed extra code when contracts were disabled (both of those
16920                   can be done by the current version of this library but at the cost
16921                   of manually writing some boiler-plate code which was previous automatically
16922                   handled by the macros instead, see <link linkend="boost_contract.extras.separate_body_implementation">Separate
16923                   Body Implementation</link> and <link linkend="boost_contract.extras.disable_contract_compilation__macro_interface_">Disable
16924                   Contract Compilation</link>).
16925                 </simpara>
16926               </listitem>
16927             </orderedlist>
16928           </simpara>
16929         </listitem>
16930         <listitem>
16931           <simpara>
16932             Simplified the library by removing some extra features that were not
16933             directly related to contract programming, specifically:
16934             <orderedlist inheritnum="ignore" continuation="restarts">
16935               <listitem>
16936                 <simpara>
16937                   Removed loop variants (because these are rarely if ever used).
16938                 </simpara>
16939               </listitem>
16940               <listitem>
16941                 <simpara>
16942                   Removed named and deduced parameters (because these can be programmed
16943                   directly using <ulink url="http://www.boost.org/doc/libs/release/libs/parameter/doc/html/index.html">Boost.Parameter</ulink>).
16944                 </simpara>
16945               </listitem>
16946               <listitem>
16947                 <simpara>
16948                   Removed concepts (because these can be programmed directly using
16949                   <ulink url="http://www.boost.org/doc/libs/1_65_0/libs/concept_check/concept_check.htm">Boost.ConceptCheck</ulink>).
16950                 </simpara>
16951               </listitem>
16952               <listitem>
16953                 <simpara>
16954                   Removed emulation of virtual specifiers <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override</phrase></computeroutput>,
16955                   <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">final</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">new</phrase></computeroutput> (because <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">override</phrase></computeroutput>
16956                   can be programmed directly using C++11, while <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">final</phrase></computeroutput>
16957                   and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">new</phrase></computeroutput> are rarely
16958                   if ever used).
16959                 </simpara>
16960               </listitem>
16961               <listitem>
16962                 <simpara>
16963                   Removed <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">static_assert</phrase></computeroutput>
16964                   emulation (because this can be programmed directly using C++11,
16965                   or using <ulink url="http://www.boost.org/doc/libs/1_65_0/doc/html/boost_staticassert.html">Boost.StaticAssert</ulink>).
16966                 </simpara>
16967               </listitem>
16968             </orderedlist>
16969           </simpara>
16970         </listitem>
16971         <listitem>
16972           <simpara>
16973             Ensuring that old values and return values are copied only once even
16974             when subcontracting is used with multiple inheritance.
16975           </simpara>
16976         </listitem>
16977         <listitem>
16978           <simpara>
16979             Improved template meta-programming algorithm that searches the inheritance
16980             tree for subcontracting when multiple inheritance is used.
16981           </simpara>
16982         </listitem>
16983         <listitem>
16984           <simpara>
16985             Exception specifications and function-try blocks apply also to exceptions
16986             thrown by the contracts, and not just to exceptions thrown by the body.
16987           </simpara>
16988         </listitem>
16989         <listitem>
16990           <simpara>
16991             Added contracts for exception guarantees (using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase><phrase role="identifier">except</phrase><phrase role="special">(...)</phrase></computeroutput>,
16992             etc.).
16993           </simpara>
16994         </listitem>
16995         <listitem>
16996           <simpara>
16997             Added predefined assertion levels for "audit" and "axiom".
16998           </simpara>
16999         </listitem>
17000         <listitem>
17001           <simpara>
17002             Added <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">call_if</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">condition_if</phrase></computeroutput> (assertions requirements
17003             were supported also by previous revisions of this library but they were
17004             handled by internal code generated by the contract macros).
17005           </simpara>
17006         </listitem>
17007       </orderedlist>
17008       <para>
17009         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.5.0">files</ulink>.
17010       </para>
17011     </section>
17012     <section id="boost_contract.release_notes.release_0_4_1">
17013       <title><link linkend="boost_contract.release_notes.release_0_4_1">Release 0.4.1</link></title>
17014       <note>
17015         <para>
17016           This revision of the library passed Boost formal review and it was accepted
17017           into the Boost libraries (see <ulink url="https://groups.google.com/forum/?fromgroups=#!topic/boost-list/jQ7OjAmos_Y">https://groups.google.com/forum/?fromgroups=#!topic/boost-list/jQ7OjAmos_Y</ulink>).
17018         </para>
17019       </note>
17020       <para>
17021         August 20, 2012
17022       </para>
17023       <para>
17024         Accepted into Boost:
17025       </para>
17026       <orderedlist inheritnum="ignore" continuation="restarts">
17027         <listitem>
17028           <simpara>
17029             Using non-fix-spaced font in Full Table of Contents section.
17030           </simpara>
17031         </listitem>
17032         <listitem>
17033           <simpara>
17034             Added a couple of notes to the documentation.
17035           </simpara>
17036         </listitem>
17037         <listitem>
17038           <simpara>
17039             Changed <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">CONTRACT_MEMBER_BODY</phrase><phrase role="special">(</phrase><phrase role="identifier">class_type</phrase><phrase role="special">,</phrase> <phrase role="identifier">function_name</phrase><phrase role="special">)</phrase></computeroutput> to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">class_type</phrase><phrase role="special">::</phrase><phrase role="identifier">CONTRACT_MEMBER_BODY</phrase><phrase role="special">(</phrase><phrase role="identifier">function_name</phrase><phrase role="special">)</phrase></computeroutput> so the macro can also be used to declare
17040             derived classes avoiding using the library syntax even when the base
17041             class has contracts.
17042           </simpara>
17043         </listitem>
17044       </orderedlist>
17045       <para>
17046         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.4.1">files</ulink>.
17047       </para>
17048     </section>
17049     <section id="boost_contract.release_notes.release_0_4_0">
17050       <title><link linkend="boost_contract.release_notes.release_0_4_0">Release 0.4.0</link></title>
17051       <para>
17052         June 4, 2012
17053       </para>
17054       <para>
17055         Simplified syntax, added named parameters and concepts:
17056       </para>
17057       <orderedlist inheritnum="ignore" continuation="restarts">
17058         <listitem>
17059           <simpara>
17060             Simplified syntax by reducing extra parenthesis to the bare necessary
17061             minimum (using some of the preprocessor parsing techniques originally
17062             introduced by Boost.LocalFunction).
17063           </simpara>
17064         </listitem>
17065         <listitem>
17066           <simpara>
17067             Postcondition old values only copy the old-of expression (e.g., copy
17068             just vector size instead of entire vector). This improves performance
17069             and introduces the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ConstantCopyConstructible</phrase></computeroutput>
17070             requirement just for the old value expression type (e.g., a vector might
17071             not be copyable while its size always is because it is an integral type).
17072             Removed the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">copyable</phrase></computeroutput>
17073             tag.
17074           </simpara>
17075         </listitem>
17076         <listitem>
17077           <simpara>
17078             Body defined outside the macros (so compiler-errors for definitions retain
17079             their usual meaning).
17080           </simpara>
17081         </listitem>
17082         <listitem>
17083           <simpara>
17084             Added <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">CONTRACT_CLASS</phrase></computeroutput>
17085             macro and removed the need to duplicate declaration elements (do not
17086             repeat function declaration, do not repeat class name in function declaration,
17087             etc).
17088           </simpara>
17089         </listitem>
17090         <listitem>
17091           <simpara>
17092             Using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">_TPL</phrase></computeroutput> macros so
17093             to reduce compile-time (instead of internally making all templates contract
17094             functions so to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typename</phrase></computeroutput>
17095             freely).
17096           </simpara>
17097         </listitem>
17098         <listitem>
17099           <simpara>
17100             Overloading no longer requires unique parameter names.
17101           </simpara>
17102         </listitem>
17103         <listitem>
17104           <simpara>
17105             Added C++11-like virtual specifiers.
17106           </simpara>
17107         </listitem>
17108         <listitem>
17109           <simpara>
17110             Added constant assertions plus constant-expressions for select assertion
17111             if-conditions and for loop variants.
17112           </simpara>
17113         </listitem>
17114         <listitem>
17115           <simpara>
17116             Added named and deduced parameters.
17117           </simpara>
17118         </listitem>
17119         <listitem>
17120           <simpara>
17121             Added concept checking.
17122           </simpara>
17123         </listitem>
17124         <listitem>
17125           <simpara>
17126             Removed the interface to use the library without the macro (programmers
17127             were required to write too much boiler-plate code for the non-macro interface
17128             to be actually usable, plus supporting both the macro and non-macro interfaces
17129             limited what the macros could do).
17130           </simpara>
17131         </listitem>
17132       </orderedlist>
17133       <para>
17134         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.4.0">files</ulink>.
17135       </para>
17136     </section>
17137     <section id="boost_contract.release_notes.release_0_3_490">
17138       <title><link linkend="boost_contract.release_notes.release_0_3_490">Release
17139       0.3.490</link></title>
17140       <para>
17141         March 7, 2010
17142       </para>
17143       <para>
17144         Support for most/all C++ constructs:
17145       </para>
17146       <orderedlist inheritnum="ignore" continuation="restarts">
17147         <listitem>
17148           <simpara>
17149             Added support and examples for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">volatile</phrase></computeroutput>,
17150             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">auto</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">explicit</phrase></computeroutput>,
17151             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">export</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">extern</phrase></computeroutput>,
17152             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">friend</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">inline</phrase></computeroutput>,
17153             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">throw</phrase></computeroutput> (for exception specifications).
17154           </simpara>
17155         </listitem>
17156         <listitem>
17157           <simpara>
17158             Documented that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">union</phrase></computeroutput> cannot
17159             be contracted.
17160           </simpara>
17161         </listitem>
17162       </orderedlist>
17163       <para>
17164         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.3.490">files</ulink>.
17165       </para>
17166     </section>
17167     <section id="boost_contract.release_notes.release_0_3_469">
17168       <title><link linkend="boost_contract.release_notes.release_0_3_469">Release
17169       0.3.469</link></title>
17170       <para>
17171         February 21, 2010
17172       </para>
17173       <para>
17174         Support for most/all contract programming features:
17175       </para>
17176       <orderedlist inheritnum="ignore" continuation="restarts">
17177         <listitem>
17178           <simpara>
17179             Removed use of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">self</phrase></computeroutput>,
17180             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">variable</phrase><phrase role="special">.</phrase><phrase role="identifier">now</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">variable</phrase><phrase role="special">.</phrase><phrase role="identifier">old</phrase></computeroutput>
17181             in writing contracts. Object <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">this</phrase></computeroutput>
17182             and variables are now accessed as usual in member functions. <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">CONTRACT_OLDOF</phrase><phrase role="special">(</phrase><phrase role="identifier">variable</phrase><phrase role="special">)</phrase></computeroutput>
17183             is used to access old values in postconditions.
17184           </simpara>
17185         </listitem>
17186         <listitem>
17187           <simpara>
17188             Added <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">precondition</phrase><phrase role="special">)</phrase></computeroutput>, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">)</phrase></computeroutput>,
17189             and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">body</phrase><phrase role="special">)</phrase></computeroutput> to specify contracts within the function
17190             signature sequence. If no preconditions then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">precondition</phrase><phrase role="special">)</phrase>
17191             <phrase role="special">({...})</phrase></computeroutput> is simply omitted from
17192             the sequence (same for postconditions, body is mandatory instead). For
17193             non-void functions, users can name the result argument with <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">)</phrase> <phrase role="special">(</phrase><phrase role="identifier">result</phrase><phrase role="special">-</phrase><phrase role="identifier">name</phrase><phrase role="special">)</phrase> <phrase role="special">({...})</phrase></computeroutput>.
17194           </simpara>
17195         </listitem>
17196         <listitem>
17197           <simpara>
17198             Changed contract class template to use same syntax as Boost.Function
17199             (i.e., <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput> function type).
17200           </simpara>
17201         </listitem>
17202         <listitem>
17203           <simpara>
17204             Added support for free functions and static member functions.
17205           </simpara>
17206         </listitem>
17207         <listitem>
17208           <simpara>
17209             Added support for subcontracting with multiple inheritance.
17210           </simpara>
17211         </listitem>
17212         <listitem>
17213           <simpara>
17214             Added static class invariants which are always checked (also at constructors
17215             entry, destructor exit, and by static member functions).
17216           </simpara>
17217         </listitem>
17218         <listitem>
17219           <simpara>
17220             Added block invariants and Eiffel-like loop variants.
17221           </simpara>
17222         </listitem>
17223         <listitem>
17224           <simpara>
17225             Added handlers to customize action on contract failure (default to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase><phrase role="special">()</phrase></computeroutput>).
17226           </simpara>
17227         </listitem>
17228         <listitem>
17229           <simpara>
17230             Removed feature for automatic contract documentation using Doxygen (this
17231             is not compatible with added <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">precondition</phrase><phrase role="special">)</phrase></computeroutput>,
17232             <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">postcondition</phrase><phrase role="special">)</phrase></computeroutput>, and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">(</phrase><phrase role="identifier">body</phrase><phrase role="special">)</phrase></computeroutput>
17233             because Doxygen preprocessor is not capable to handle Boost.Preprocessor
17234             sequences).
17235           </simpara>
17236         </listitem>
17237         <listitem>
17238           <simpara>
17239             Rewritten entire documentation (now using Boost.QuickBook instead of
17240             Doxygen).
17241           </simpara>
17242         </listitem>
17243       </orderedlist>
17244       <para>
17245         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.3.469">files</ulink>.
17246       </para>
17247     </section>
17248     <section id="boost_contract.release_notes.release_0_2_190">
17249       <title><link linkend="boost_contract.release_notes.release_0_2_190">Release
17250       0.2.190</link></title>
17251       <para>
17252         November 21, 2009
17253       </para>
17254       <para>
17255         Compiled on both GCC and MSVC:
17256       </para>
17257       <orderedlist inheritnum="ignore" continuation="restarts">
17258         <listitem>
17259           <simpara>
17260             Compiled using both GCC (Linux and Cygwin) and MSVC (Windows XP).
17261           </simpara>
17262         </listitem>
17263         <listitem>
17264           <simpara>
17265             Required to use void to specify empty function argument list. This is
17266             to comply with C++03 standard that does not allow to pass empty macro
17267             parameters so it does not support empty preprocessor sequences <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">()</phrase></computeroutput>.
17268           </simpara>
17269         </listitem>
17270       </orderedlist>
17271       <para>
17272         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.2.190">files</ulink>.
17273       </para>
17274     </section>
17275     <section id="boost_contract.release_notes.release_0_1_126">
17276       <title><link linkend="boost_contract.release_notes.release_0_1_126">Release
17277       0.1.126</link></title>
17278       <para>
17279         June 17, 2009
17280       </para>
17281       <para>
17282         Added documentation:
17283       </para>
17284       <orderedlist inheritnum="ignore" continuation="restarts">
17285         <listitem>
17286           <simpara>
17287             Completed first documentation draft.
17288           </simpara>
17289         </listitem>
17290       </orderedlist>
17291       <para>
17292         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.1.126">files</ulink>.
17293       </para>
17294     </section>
17295     <section id="boost_contract.release_notes.release_0_1_55">
17296       <title><link linkend="boost_contract.release_notes.release_0_1_55">Release
17297       0.1.55</link></title>
17298       <para>
17299         April 19, 2009
17300       </para>
17301       <para>
17302         Cleaned-up first release:
17303       </para>
17304       <orderedlist inheritnum="ignore" continuation="restarts">
17305         <listitem>
17306           <simpara>
17307             Reorganized files to cleanup root directory.
17308           </simpara>
17309         </listitem>
17310         <listitem>
17311           <simpara>
17312             Added installation program.
17313           </simpara>
17314         </listitem>
17315       </orderedlist>
17316       <para>
17317         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.1.55">files</ulink>.
17318       </para>
17319     </section>
17320     <section id="boost_contract.release_notes.release_0_1_50">
17321       <title><link linkend="boost_contract.release_notes.release_0_1_50">Release
17322       0.1.50</link></title>
17323       <para>
17324         April 19, 2009
17325       </para>
17326       <para>
17327         First release:
17328       </para>
17329       <orderedlist inheritnum="ignore" continuation="restarts">
17330         <listitem>
17331           <simpara>
17332             First public release.
17333           </simpara>
17334         </listitem>
17335       </orderedlist>
17336       <para>
17337         Released <ulink url="https://github.com/boostorg/contract/releases/tag/v0.1.50">files</ulink>.
17338       </para>
17339     </section>
17340   </section>
17341   <section id="boost_contract.bibliography">
17342     <title><link linkend="boost_contract.bibliography">Bibliography</link></title>
17343     <para>
17344       This section lists all references consulted while designing and developing
17345       this library.
17346     </para>
17347     <para>
17348       <anchor id="Andrzej13_anchor"/>[Andrzej13] A. Krzemienski. <ulink url="https://akrzemi1.wordpress.com/2013/01/04/preconditions-part-i/"><emphasis>Andrzej's
17349       C++ blog: Preconditions</emphasis></ulink>. 2013.
17350     </para>
17351     <para>
17352       <anchor id="Bright04_anchor"/>[Bright04] W. Bright. <ulink url="https://dlang.org/spec/contracts.html"><emphasis>Contract
17353       Programming for the D Programming Language</emphasis></ulink>. 2004.
17354     </para>
17355     <para>
17356       <anchor id="Bright04b_anchor"/>[Bright04b] W. Bright. <ulink url="http://www.digitalmars.com/ctg/contract.html"><emphasis>Contract
17357       Programming for the Digital Mars C++ Compiler</emphasis></ulink>. 2004.
17358     </para>
17359     <para>
17360       <anchor id="C2_anchor"/>[C2] Aechmea. <ulink url="http://www.programmersheaven.com/app/news/DisplayNews.aspx?NewsID=3843"><emphasis>C^2
17361       Contract Programming add-on for C++</emphasis></ulink>. 2005.
17362     </para>
17363     <para>
17364       <anchor id="Chrome_anchor"/>[Chrome] RemObjects. <ulink url="http://blogs.remobjects.com/blogs/mh/2008/05/01/p216"><emphasis>Chrome:
17365       Contract Programming for Object Pascal in .NET</emphasis></ulink>. 2002.
17366     </para>
17367     <para>
17368       <anchor id="Clarke06_anchor"/>[Clarke06] L. A. Clarke and D. S. Rosenblum.
17369       <ulink url="http://discovery.ucl.ac.uk/4991/1/4991.pdf"><emphasis>A Historical
17370       Perspective on Runtime Assertion Checking in Software Development</emphasis></ulink>.
17371       Newsletter ACM SIGSOFT Software Engineering Notes, 2006.
17372     </para>
17373     <para>
17374       <anchor id="Cline90_anchor"/>[Cline90] M. Cline and D. Lea. <emphasis>The Behaviour
17375       of C++ Classes</emphasis> and <ulink url="http://surface.syr.edu/cgi/viewcontent.cgi?article=1116&amp;context=eecs"><emphasis>Using
17376       Annotated C++</emphasis></ulink>. Proc. of the Symposium on Object Oriented
17377       Programming Emphasizing Practical Applications, Maris College, 1990.
17378     </para>
17379     <para>
17380       <anchor id="Ellis90_anchor"/>[Ellis90] M. A. Ellis and B. Stroustrup. <emphasis>The
17381       Annotated C++ Reference Manual</emphasis>. ANSI Base Document, Addison Wesley,
17382       1990.
17383     </para>
17384     <para>
17385       <anchor id="Gautron92_anchor"/>[Gautron92] P. Gautron. <emphasis>An Assertion
17386       Mechanism Based on Exceptions</emphasis>. Fourth C++ Technical Conference,
17387       1992.
17388     </para>
17389     <para>
17390       <anchor id="Hoare73_anchor"/>[Hoare73] C. A. R. Hoare. <emphasis>Hints on Programming
17391       Language Design</emphasis>. Stanford University Artificial Intelligence memo
17392       AIM-224/STAN-CS-73-403, pages 193-216, 1973.
17393     </para>
17394     <para>
17395       <anchor id="CodeContracts_anchor"/>[CodeContracts] Microsoft Research. <ulink url="http://research.microsoft.com/en-us/projects/contracts/"><emphasis>Code
17396       Contracts: Design-By-Contract Programming for All .NET Programming Languages</emphasis></ulink>.
17397       2012.
17398     </para>
17399     <para>
17400       <anchor id="iContract_anchor"/>[iContract] O. Enseling. <ulink url="http://www.javaworld.com/javaworld/jw-02-2001/jw-0216-cooltools.html"><emphasis>iContract:
17401       Contract Programming for Java</emphasis></ulink>. 2001.
17402     </para>
17403     <para>
17404       <anchor id="Jcontract_anchor"/>[Jcontract] Parasoft. <ulink url="http://www.parasoft.com/jsp/products/article.jsp?label=product_info_Jcontract"><emphasis>Jcontract:
17405       Contract Programming for Java</emphasis></ulink>.
17406     </para>
17407     <para>
17408       <anchor id="Lindrud04_anchor"/>[Lindrud04] J. Lindrud. <ulink url="http://www.codeproject.com/Articles/8293/Design-by-Contract-in-C"><emphasis>Design
17409       by Contract in C++</emphasis></ulink>. 2004.
17410     </para>
17411     <para>
17412       <anchor id="Maley99_anchor"/>[Maley99] D. Maley and I. Spence. <ulink url="http://www.computer.org/portal/web/csdl/doi/10.1109/TOOLS.1999.779000"><emphasis>Emulating
17413       Design by Contract in C++</emphasis></ulink>. Proceedings of TOOLS, IEEE Computer
17414       Society, 1999.
17415     </para>
17416     <para>
17417       <anchor id="Meyer97_anchor"/>[Meyer97] B. Meyer. <emphasis>Object Oriented
17418       Software Construction</emphasis>. Prentice-Hall, 2nd edition, 1997.
17419     </para>
17420     <para>
17421       <anchor id="Mitchell02_anchor"/>[Mitchell02] R. Mitchell and J. McKim. <emphasis>Design
17422       by Contract, by Example</emphasis>. Addison-Wesley, 2002.
17423     </para>
17424     <para>
17425       <anchor id="N1613_anchor"/>[N1613] T. Ottosen. <ulink url="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1613.pdf"><emphasis>Proposal
17426       to add Design by Contract to C++</emphasis></ulink>. The C++ Standards Committee,
17427       N1613, 2004.
17428     </para>
17429     <para>
17430       <anchor id="N1653_anchor"/>[N1653] C. Nelson. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm"><emphasis>Working
17431       draft changes for C99 preprocessor synchronization</emphasis></ulink>. C++
17432       Standards Committee, N1653, 2004.
17433     </para>
17434     <para>
17435       <anchor id="N1669_anchor"/>[N1669] T. Ottosen. <ulink url="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1669.html"><emphasis>Proposal
17436       to add Contract Programming to C++ (revision 1)</emphasis></ulink>. The C++
17437       Standards Committee, N1669, 2004.
17438     </para>
17439     <para>
17440       <anchor id="N1773_anchor"/>[N1773] D. Abrahams, L. Crowl, T. Ottosen, and J.
17441       Widman. <ulink url="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1773.html"><emphasis>Proposal
17442       to add Contract Programming to C++ (revision 2)</emphasis></ulink>. The C++
17443       Standards Committee, N1773, 2005.
17444     </para>
17445     <para>
17446       <anchor id="N1866_anchor"/>[N1866] L. Crowl and T. Ottosen. <ulink url="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1866.html"><emphasis>Proposal
17447       to add Contract Programming to C++ (revision 3)</emphasis></ulink>. The C++
17448       Standards Committee, N1866, 2005.
17449     </para>
17450     <para>
17451       <anchor id="N1895_anchor"/>[N1895] H. Sutter and F. Glassborow. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1895.pdf"><emphasis>Delegating
17452       Constructors (revision 2)</emphasis></ulink>. C++ Standards Committee, N1895,
17453       2005.
17454     </para>
17455     <para>
17456       <anchor id="N1962_anchor"/>[N1962] L. Crowl and T. Ottosen. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1962.html"><emphasis>Proposal
17457       to add Contract Programming to C++ (revision 4)</emphasis></ulink>. The C++
17458       Standards Committee, N1962, 2006.
17459     </para>
17460     <para>
17461       <anchor id="N2081_anchor"/>[N2081] D. Gregor and B. Stroustrup. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2081.pdf"><emphasis>Concepts
17462       (revision 1)</emphasis></ulink>. The C++ Standards Committee, N2081, 2006.
17463     </para>
17464     <para>
17465       <anchor id="N2887_anchor"/>[N2887] G. Dos Reis, B. Stroustrup, and A. Meredith.
17466       <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2887.pdf"><emphasis>Axioms:
17467       Semantics Aspects of C++ Concepts</emphasis></ulink>. The C++ Standards Committee,
17468       N2887, 2009.
17469     </para>
17470     <para>
17471       <anchor id="N2914_anchor"/>[N2914] P. Becker. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2914.pdf"><emphasis>Working
17472       Draft, Standard for Programming Language C++</emphasis></ulink>. The C++ Standards
17473       Committee, N2914, 2009.
17474     </para>
17475     <para>
17476       <anchor id="N2906_anchor"/>[N2906] B. Stroustrup. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2906.pdf"><emphasis>Simplifying
17477       the sue of concepts</emphasis></ulink>. The C++ Standards Committee, N2906,
17478       2009.
17479     </para>
17480     <para>
17481       <anchor id="N3248_anchor"/>[N3248] J. Lakos. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3248.pdf"><emphasis><literal moreinfo="none">noexcept</literal>
17482       Prevents Library Validation</emphasis></ulink>. The C++ Standards Committee,
17483       N3248, 2011.
17484     </para>
17485     <para>
17486       <anchor id="N4154_anchor"/>[N4154] D. Krauss. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4154.pdf"><emphasis>Operator
17487       <literal moreinfo="none">assert</literal></emphasis></ulink>. The C++ Standards Committee,
17488       N4154, 2014.
17489     </para>
17490     <para>
17491       <anchor id="N4160_anchor"/>[N4160] A. Krzemienski. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4160.html"><emphasis>Value
17492       constraints</emphasis></ulink>. The C++ Standards Committee, N4160, 2014.
17493     </para>
17494     <para>
17495       <anchor id="N4248_anchor"/>[N4248] A. Meredith. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4248.html"><emphasis>Library
17496       Preconditions are a Language Feature</emphasis></ulink>. The C++ Standards
17497       Committee, N4248, 2014.
17498     </para>
17499     <para>
17500       <anchor id="N4293_anchor"/>[N4293] J. D. Garcia. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4293.pdf"><emphasis>C++
17501       language support for contract programming</emphasis></ulink>. The C++ Standards
17502       Committee, N4293, 2014.
17503     </para>
17504     <para>
17505       <anchor id="N4378_anchor"/>[N4378] J. Lakos, N. Myers, A. Zakharov, and A.
17506       Beels. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4378.pdf"><emphasis>Language
17507       Support for Contract Assertions (Revision 10)</emphasis></ulink>. The C++ Standards
17508       Committee, N4378, 2015.
17509     </para>
17510     <para>
17511       <anchor id="Nana_anchor"/>[Nana] P. J. Maker. <ulink url="https://github.com/pjmaker/nana"><emphasis>GNU
17512       Nana</emphasis></ulink>. 2014.
17513     </para>
17514     <para>
17515       <anchor id="N4379_anchor"/>[N4378] J. Lakos and N. Myers. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4379.pdf"><emphasis>FAQ
17516       about Contract Assertions</emphasis></ulink>. The C++ Standards Committee,
17517       N4379, 2015.
17518     </para>
17519     <para>
17520       <anchor id="N4435_anchor"/>[N4435] W. E. Brown. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4435.pdf"><emphasis>Proposing
17521       Contract Attributes</emphasis></ulink>. The C++ Standards Committee, N4435,
17522       2015.
17523     </para>
17524     <para>
17525       <anchor id="P0147_anchor"/>[P0147] L. Crowl. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0147r0.html"><emphasis>The
17526       Use and Implementation of Contracts</emphasis></ulink>. The C++ Standards Committee,
17527       P0147R0, 2015.
17528     </para>
17529     <para>
17530       <anchor id="P0166_anchor"/>[P0166] J. D. Garcia. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0166r0.pdf"><emphasis>Three
17531       interesting questions about contracts</emphasis></ulink>. The C++ Standards
17532       Committee, P0166R0, 2015.
17533     </para>
17534     <para>
17535       <anchor id="P0246_anchor"/>[P0246] N. Myers. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0246r0.pdf"><emphasis>Criteria
17536       for Contract Support Merged Proposal</emphasis></ulink>. The C++ Standards
17537       Committee, P0246R0, 2016.
17538     </para>
17539     <para>
17540       <anchor id="P0287_anchor"/>[P0287] G. Dos Reis, J.D. Garcia, F. Logozzo, M.
17541       Fahndrich, S. Lahiri. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0287r0.pdf"><emphasis>Simple
17542       Contracts for C++ (R1)</emphasis></ulink>. The C++ Standards Committee, P0287R0,
17543       2016.
17544     </para>
17545     <para>
17546       <anchor id="P0380_anchor"/>[P0380] G. Dos Reis, J.D. Garcia, J. Lakos, A. Meredith,
17547       N. Myers, and B. Stroustrup. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0380r1.pdf"><emphasis>A
17548       Contract Design</emphasis></ulink>. The C++ Standards Committee, P0380R1, 2016.
17549     </para>
17550     <para>
17551       <anchor id="P0542_anchor"/>[P0542] G. Dos Reis, J.D. Garcia, J. Lakos, A. Meredith,
17552       N. Myers, and B. Stroustrup. <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0542r0.html"><emphasis>Support
17553       for contract based programming in C++</emphasis></ulink>. The C++ Standards
17554       Committee, P0542R0, 2017.
17555     </para>
17556     <para>
17557       <anchor id="Rosenblum95_anchor"/>[Rosenblum95] D. S. Rosenblum. <ulink url="http://www.cs.toronto.edu/~chechik/courses06/csc410/rosenblum_assert95.pdf"><emphasis>A
17558       practical Approach to Programming With Assertions</emphasis></ulink>. IEEE
17559       Transactions on Software Engineering, 1995.
17560     </para>
17561     <para>
17562       <anchor id="SPARKAda_anchor"/>[SPARKAda] Praxis. <ulink url="http://www.praxis-his.com/sparkada/language.asp"><emphasis>SPARKAda
17563       (Ada-like Language with Contract Programming)</emphasis></ulink>.
17564     </para>
17565     <para>
17566       <anchor id="SpecSharp_anchor"/>[SpecSharp] Microsoft. <ulink url="http://research.microsoft.com/en-us/projects/specsharp/"><emphasis>Spec#
17567       (C# Extension)</emphasis></ulink>.
17568     </para>
17569     <para>
17570       <anchor id="Stroustrup94_anchor"/>[Stroustrup94] B. Stroustrup. <emphasis>The
17571       Design and Evolution of C++</emphasis>. Addison Wesley, 1994.
17572     </para>
17573     <para>
17574       <anchor id="Stroustrup13_anchor"/>[Stroustrup13] B. Stroustrup. <emphasis>The
17575       C++ Programming Language</emphasis>. Addison Wesley, 4th Edition, 2013.
17576     </para>
17577     <para>
17578       <anchor id="Tandin04_anchor"/>[Tandin04] A. Tandin. <ulink url="http://www.codeproject.com/KB/macros/DbC_and_Doxygen.aspx"><emphasis>Design
17579       by Contract macros for C++ and link to Doxygen</emphasis></ulink>. 2004.
17580     </para>
17581     <para>
17582       <anchor id="Wilson06_anchor"/>[Wilson06] M. Wilson. <ulink url="http://www.artima.com/cppsource/deepspace.html"><emphasis>Contract
17583       Programming 101 - The Nuclear Reactor and the Deep Space Probe</emphasis></ulink>.
17584       The C++ Source, 2006.
17585     </para>
17586   </section>
17587   <section id="boost_contract.acknowledgments">
17588     <title><link linkend="boost_contract.acknowledgments">Acknowledgments</link></title>
17589     <para>
17590       This section tries to recognize the contributions of all the different people
17591       that participated directly or indirectly to the design and development of this
17592       library.
17593     </para>
17594     <para>
17595       Sincere thanks to my parents for their support with my education and my studies
17596       in computer science.
17597     </para>
17598     <para>
17599       Many thanks to Andrzej Krzemienski for reviewing early versions of this library
17600       providing valuable insights and exchanging early ideas on assertion requirements.
17601     </para>
17602     <para>
17603       Many thanks to Vicente J. Botet Escriba for reviewing earlier versions of this
17604       library providing valuable insights and for suggesting to use a dedicated trait
17605       to copy old values.
17606     </para>
17607     <para>
17608       Thanks to Steven Watanabe for providing valuable insights on C++, SFINAE, and
17609       introspection.
17610     </para>
17611     <para>
17612       Thanks to Dave Abrahams for moderating the Boost review of this library.
17613     </para>
17614     <para>
17615       Thanks to Daniel James for his help with incorporating this library files into
17616       the Boost Git repository.
17617     </para>
17618     <para>
17619       Thanks to James E. King III for integrating this library with Boost's Continuous
17620       Integration (CI).
17621     </para>
17622     <para>
17623       Thanks to David Maley for sharing source code form his inspiring work on emulating
17624       contract programming and subcontracting in C++ in <link linkend="Maley99_anchor">[Maley99]</link>.
17625     </para>
17626     <para>
17627       Many thanks to Thorsten Ottosen for his work on the <link linkend="N1962_anchor">[N1962]</link>
17628       proposal (and its previous revisions) and for clarifying the proposal requirements
17629       directly with the library authors when needed.
17630     </para>
17631     <para>
17632       Many thanks to Bertrand Meyer for his pioneering and thorough work on contract
17633       programming in <link linkend="Meyer97_anchor">[Meyer97]</link>.
17634     </para>
17635     <para>
17636       Finally, many thanks to the entire Boost community and <ulink url="http://lists.boost.org">mailing
17637       list</ulink> for providing valuable comments on this library and great insights
17638       on the C++ programming language.
17639     </para>
17640   </section>
17641 </chapter>