• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5<title>BoostBook element function</title>
6<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9<link rel="up" href="../../reference.html" title="Reference">
10<link rel="prev" href="source.html" title="BoostBook element source">
11<link rel="next" href="macroname.html" title="BoostBook element macroname">
12</head>
13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14<table cellpadding="2" width="100%"><tr>
15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
16<td align="center"><a href="../../../../index.html">Home</a></td>
17<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20<td align="center"><a href="../../../../more/index.htm">More</a></td>
21</tr></table>
22<hr>
23<div class="spirit-nav">
24<a accesskey="p" href="source.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="macroname.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
25</div>
26<div class="refentry">
27<a name="boostbook.dtd.function"></a><div class="titlepage"></div>
28<div class="refnamediv">
29<h2><span class="refentrytitle">
30          BoostBook element <code class="sgmltag-element">function</code></span></h2>
31<p>function — Declares a function</p>
32</div>
33<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
34<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv">function ::=
35  (<a class="link" href="template.html" title="BoostBook element template">template</a>?, <a class="link" href="type.html" title="BoostBook element type">type</a>, <a class="link" href="parameter.html" title="BoostBook element parameter">parameter</a>*, <a class="link" href="purpose.html" title="BoostBook element purpose">purpose</a>?, <a class="link" href="description.html" title="BoostBook element description">description</a>?, <a class="link" href="requires.html" title="BoostBook element requires">requires</a>?, <a class="link" href="effects.html" title="BoostBook element effects">effects</a>?, <a class="link" href="postconditions.html" title="BoostBook element postconditions">postconditions</a>?, <a class="link" href="returns.html" title="BoostBook element returns">returns</a>?, <a class="link" href="throws.html" title="BoostBook element throws">throws</a>?, <a class="link" href="complexity.html" title="BoostBook element complexity">complexity</a>?, <a class="link" href="notes.html" title="BoostBook element notes">notes</a>?, <a class="link" href="rationale.html" title="BoostBook element rationale">rationale</a>?)
36</div>
37<div class="refsection">
38<a name="id-1.4.3.7.19.4"></a><h2>Description</h2>
39<p>BoostBook functions are documented by specifying the
40  function's interface (e.g., its C++ signature) and its
41  behavior. Constructors, destructors, member functions, and free
42  functions all use the same documentation method, although the
43  top-level tags differ.</p>
44<p>The behavior of functions in BoostBook is documenting using a
45  style similar to that of the C++ standard, with clauses describing
46  the requirements, effects, postconditions, exception behavior, and
47  return values of functions.</p>
48<p>The following example illustrates some constructors and a
49  destructor for <code class="computeroutput"><a class="link" href="../../boost/any.html" title="Class any">boost::any</a></code>. Note that one of
50  the constructors takes a single parameter whose name is "other" and
51  whose type, <code class="computeroutput">const any&amp;</code> is contained in the
52  &lt;paramtype&gt; element; any number of parameters may be specified
53  in this way.</p>
54<pre class="programlisting">&lt;class name="any"&gt;
55  &lt;constructor&gt;
56    &lt;postconditions&gt;&lt;para&gt;&lt;this-&gt;empty()&gt;&lt;/para&gt;&lt;/postconditions&gt;
57  &lt;/constructor&gt;
58
59  &lt;constructor&gt;
60    &lt;parameter name="other"&gt;
61      &lt;paramtype&gt;const &lt;classname&gt;any&lt;/classname&gt;&amp;amp;&lt;/paramtype&gt;
62    &lt;/parameter&gt;
63
64    &lt;effects&gt;
65      &lt;simpara&gt; Copy constructor that copies
66        content of &lt;code&gt;other&lt;/code&gt; into the new instance,
67        so that any content is equivalent in both type and value to the
68        content of &lt;code&gt;other&lt;/code&gt;, or empty if
69        &lt;code&gt;other&lt;/code&gt; is
70        empty.
71      &lt;/simpara&gt;
72    &lt;/effects&gt;
73
74    &lt;throws&gt;
75      &lt;simpara&gt;May fail with a
76        &lt;classname&gt;std::bad_alloc&lt;/classname&gt; exception or any
77        exceptions arising from the copy constructor of the
78        contained type.
79      &lt;/simpara&gt;
80    &lt;/throws&gt;
81  &lt;/constructor&gt;
82
83  &lt;destructor&gt;
84     &lt;effects&gt;&lt;simpara&gt;Releases any and all resources used in
85     management of instance.&lt;/simpara&gt;&lt;/effects&gt;
86
87     &lt;throws&gt;&lt;simpara&gt;Nothing.&lt;/simpara&gt;&lt;/throws&gt;
88  &lt;/destructor&gt;
89&lt;/class&gt;</pre>
90</div>
91<div class="refsection">
92<a name="id-1.4.3.7.19.5"></a><h2>Attributes</h2>
93<div class="informaltable"><table class="table">
94<colgroup>
95<col>
96<col>
97<col>
98<col>
99</colgroup>
100<thead><tr>
101<th>Name</th>
102<th>Type</th>
103<th>Value</th>
104<th>Purpose</th>
105</tr></thead>
106<tbody>
107<tr>
108<td>last-revision</td>
109<td>#IMPLIED</td>
110<td>CDATA</td>
111<td>Set to $Date$ to keep "last revised" information in sync with CVS changes</td>
112</tr>
113<tr>
114<td>specifiers</td>
115<td>#IMPLIED</td>
116<td>CDATA</td>
117<td>The specifiers for this function, e.g., inline, static, etc.</td>
118</tr>
119<tr>
120<td>name</td>
121<td>#REQUIRED</td>
122<td>CDATA</td>
123<td>The name of the element being declared to referenced</td>
124</tr>
125<tr>
126<td>id</td>
127<td>#IMPLIED</td>
128<td>CDATA</td>
129<td>A global identifier for this element</td>
130</tr>
131<tr>
132<td>xml:base</td>
133<td>#IMPLIED</td>
134<td>CDATA</td>
135<td>Implementation detail used by XIncludes</td>
136</tr>
137</tbody>
138</table></div>
139</div>
140</div>
141<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
142<td align="left"></td>
143<td align="right"><div class="copyright-footer">Copyright © 2003-2005 Douglas Gregor<p>Distributed under the Boost Software License, Version 1.0.
144      (See accompanying file LICENSE_1_0.txt or copy at
145      <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
146      </p>
147</div></td>
148</tr></table>
149<hr>
150<div class="spirit-nav">
151<a accesskey="p" href="source.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="macroname.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
152</div>
153</body>
154</html>
155