mirror of
https://github.com/boostorg/contract.git
synced 2026-01-30 07:42:46 +00:00
71 lines
6.3 KiB
HTML
Executable File
71 lines
6.3 KiB
HTML
Executable File
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>Macro CONTRACT_OLDOF</title>
|
|
<link rel="stylesheet" href="doc/html/boostbook.css" type="text/css">
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
|
|
<link rel="start" href="index.html" title="Contract++ 0.3.469">
|
|
<link rel="up" href="reference.html#header..home.lcaminiti.sandbox.dbcpp_sourceforge.boost-quickbook.doc.qbk.src.contract.old_hpp" title="Header <contract/old.hpp>">
|
|
<link rel="prev" href="contract/copy.html" title="Class template copy">
|
|
<link rel="next" href="contract/state.html" title="Class state">
|
|
</head>
|
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="contract/copy.html"><img src="./doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header..home.lcaminiti.sandbox.dbcpp_sourceforge.boost-quickbook.doc.qbk.src.contract.old_hpp"><img src="./doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="./doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="contract/state.html"><img src="./doc/html/images/next.png" alt="Next"></a>
|
|
</div>
|
|
<hr>
|
|
<div class="refentry" lang="en">
|
|
<a name="CONTRACT_OLDOF"></a><div class="titlepage"></div>
|
|
<div class="refnamediv">
|
|
<h2><span class="refentrytitle">Macro CONTRACT_OLDOF</span></h2>
|
|
<p>CONTRACT_OLDOF</p>
|
|
</div>
|
|
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
|
|
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="emphasis"><em>// In header: <<a class="link" href="reference.html#header..home.lcaminiti.sandbox.dbcpp_sourceforge.boost-quickbook.doc.qbk.src.contract.old_hpp" title="Header <contract/old.hpp>">contract/old.hpp</a>>
|
|
|
|
</em></span>CONTRACT_OLDOF(variable_name)</pre></div>
|
|
<div class="refsect1" lang="en">
|
|
<a name="id2660464"></a><h2>Description</h2>
|
|
<p>Macro used to access old value for the variable with the specified name in postconditions.</p>
|
|
<p>The library automatically declares variables to hold old values of types tagged <code class="computeroutput">contract::copyable</code> and makes then accessible in the postconditions code block (and from the postconditions code block only). This macro simply expands the specified name to the name of the old variable automatically declared by the library.</p>
|
|
<p>For example, in postconditions of a member function <code class="computeroutput">void myvector<T>::push_back(const T& element)</code>, if both the class type <code class="computeroutput">myvector</code> and the <code class="computeroutput">element</code> argument type <code class="computeroutput">const T&</code> have been tagged copyable (see the <code class="computeroutput">sequence</code> parameter of <code class="computeroutput">CONTRACT_FUNCTION()</code> and <code class="computeroutput">contract::copy</code>) then the following old values are available: </p>
|
|
<pre class="programlisting"> CONTRACT_OLDOF(this)->... // Object old value.
|
|
CONTRACT_OLDOF(element)... // Old value of function argument `element`.
|
|
</pre>
|
|
<p><span class="bold"><strong>Parameters:</strong></span> </p>
|
|
<div class="informaltable"><table class="table">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<tbody><tr>
|
|
<td><span class="bold"><strong><code class="computeroutput">variable_name</code></strong></span></td>
|
|
<td>Use <code class="computeroutput">this</code> to access a pointer to the old object value. Use one of the function argument names to access the old value of that argument. The type of the variable with the specified name must be tagged <code class="computeroutput">contract::copyable</code> in the signature sequence its old value to be available (otherwise the use of this macro will generate a compile-time error with <code class="computeroutput">noold</code> in the error message). </td>
|
|
</tr></tbody>
|
|
</table></div>
|
|
<p>
|
|
</p>
|
|
<p><span class="bold"><strong>Returns:</strong></span> This macro expands to code equivalent to the following: </p>
|
|
<pre class="programlisting"> contract_old_ ## variable_name ## _
|
|
</pre>
|
|
<p> (The preprocessor operator <code class="computeroutput">##</code> concatenates the specified tokens.)</p>
|
|
<p><span class="bold"><strong>Note:</strong></span> Shallow copies are performed for old values of pointer types (unless the pointed type defines a different copy constructor or <code class="computeroutput">contract::copy</code> has been specialized for the pointed type to perform a different copy operation). Therefore, if a pointer type is tagged <code class="computeroutput">contract::copyable</code>, the old pointer value will be available in the postconditions and not the old pointed value -- this might not be what you intended. The notable exception is the object which is passed by pointer (like <code class="computeroutput">this</code>) but its old value is automatically deep copied by the library.</p>
|
|
<p><span class="bold"><strong>Note:</strong></span> The library supports old values for the object and all the function argument types. This is a subset of the old values supported by Eiffel which are old values for any expression that can be evaluated in postconditions. However, the old values supported by the library are usually enough to program the postconditions.</p>
|
|
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput">contract::copy</code>, <code class="computeroutput">contract::copyable</code> </p>
|
|
</div>
|
|
</div>
|
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
<td align="left"></td>
|
|
<td align="right"><div class="copyright-footer">Copyright © 2009 -2010 Lorenzo Caminiti<p>
|
|
Distributed under the Contract++ Software License, Version 1.0 (see accompanying
|
|
file LICENSE_1_0.txt)
|
|
</p>
|
|
</div></td>
|
|
</tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="contract/copy.html"><img src="./doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header..home.lcaminiti.sandbox.dbcpp_sourceforge.boost-quickbook.doc.qbk.src.contract.old_hpp"><img src="./doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="./doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="contract/state.html"><img src="./doc/html/images/next.png" alt="Next"></a>
|
|
</div>
|
|
</body>
|
|
</html>
|