Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/doc/html/boost/recursive_wrapper.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 13.2 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Class template recursive_wrapper</title>
5<link rel="stylesheet" href="../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
7<link rel="start" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8<link rel="up" href="../variant/reference.html#header.boost.variant.recursive_wrapper.hpp" title="Header &lt;boost/variant/recursive_wrapper.hpp&gt;">
9<link rel="prev" href="make_recursive_variant_over.html" title="Class template make_recursive_variant_over">
10<link rel="next" href="is_recursive_wrapper.html" title="Class template is_recursive_wrapper">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%">
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
15<td align="center"><a href="../../../index.htm">Home</a></td>
16<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="../../../people/people.htm">People</a></td>
18<td align="center"><a href="../../../more/faq.htm">FAQ</a></td>
19<td align="center"><a href="../../../more/index.htm">More</a></td>
20</table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="make_recursive_variant_over.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../variant/reference.html#header.boost.variant.recursive_wrapper.hpp"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_recursive_wrapper.html"><img src="../images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="boost.recursive_wrapper"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class template recursive_wrapper</span></h2>
29<p>boost::recursive_wrapper &#8212; Solves circular dependencies, enabling recursive types.</p>
30</div>
31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="bold"><strong>template</strong></span>&lt;<span class="bold"><strong>typename</strong></span> T&gt; 
33<span class="bold"><strong>class</strong></span> recursive_wrapper {
34<span class="bold"><strong>public</strong></span>:
35  <span class="emphasis"><em>// types</em></span>
36  <span class="bold"><strong>typedef</strong></span> T type;
37
38  <span class="emphasis"><em>// <a href="recursive_wrapper.html#boost.recursive_wrapperconstruct-copy-destruct">construct/copy/destruct</a></em></span>
39  <a href="recursive_wrapper.html#id721031-bb">recursive_wrapper</a>();
40  <a href="recursive_wrapper.html#id1672537-bb">recursive_wrapper</a>(<span class="bold"><strong>const</strong></span> recursive_wrapper &amp;);
41  <a href="recursive_wrapper.html#id1672580-bb">recursive_wrapper</a>(<span class="bold"><strong>const</strong></span> T &amp;);
42  <a href="recursive_wrapper.html#id1570808-bb">~recursive_wrapper</a>();
43
44  <span class="emphasis"><em>// <a href="recursive_wrapper.html#id1672623-bb">modifiers</a></em></span>
45  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="recursive_wrapper.html#id1672627-bb">swap</a>(recursive_wrapper &amp;);
46  <span class="type">recursive_wrapper &amp;</span> <a href="recursive_wrapper.html#id1672659-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> recursive_wrapper &amp;);
47  <span class="type">recursive_wrapper &amp;</span> <a href="recursive_wrapper.html#id1637652-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> T &amp;);
48
49  <span class="emphasis"><em>// <a href="recursive_wrapper.html#id1637710-bb">queries</a></em></span>
50  <span class="type">T &amp;</span> <a href="recursive_wrapper.html#id1637718-bb">get</a>();
51  <span class="type"><span class="bold"><strong>const</strong></span> T &amp;</span> <a href="recursive_wrapper.html#id1637725-bb">get</a>() <span class="bold"><strong>const</strong></span>;
52  <span class="type">T *</span> <a href="recursive_wrapper.html#id1591460-bb">get_pointer</a>();
53  <span class="type"><span class="bold"><strong>const</strong></span> T *</span> <a href="recursive_wrapper.html#id1591467-bb">get_pointer</a>() <span class="bold"><strong>const</strong></span>;
54};</pre></div>
55<div class="refsect1" lang="en">
56<a name="id1948029"></a><h2>Description</h2>
57<p>The <code class="computeroutput">recursive_wrapper</code> class template has an
58          interface similar to a simple value container, but its content is
59          allocated dynamically. This allows <code class="computeroutput">recursive_wrapper</code> to
60          hold types <code class="computeroutput">T</code> whose member data leads to a circular
61          dependency (e.g., a data member of <code class="computeroutput">T</code> has a data member
62          of type <code class="computeroutput">T</code>).</p>
63<p>The application of <code class="computeroutput">recursive_wrapper</code> is easiest
64          understood in context. See
65          <a href="../variant/tutorial.html#variant.tutorial.recursive.recursive-wrapper" title="Recursive types with recursive_wrapper">the section called &#8220;Recursive types with <code class="computeroutput">recursive_wrapper</code>&#8221;</a> for a
66          demonstration of a common use of the class template.</p>
67<p><span class="bold"><strong>Notes</strong></span>:</p>
68<div class="itemizedlist"><ul type="disc"><li>Any type specified as the template argument to
69            <code class="computeroutput">recursive_wrapper</code> must be capable of construction via
70            <code class="computeroutput">operator new</code>. Thus, for instance, references are not
71            supported.</li></ul></div>
72<div class="refsect2" lang="en">
73<a name="id1948117"></a><h3>
74<a name="boost.recursive_wrapperconstruct-copy-destruct"></a><code class="computeroutput">recursive_wrapper</code> construct/copy/destruct</h3>
75<div class="orderedlist"><ol type="1">
76<li>
77<pre class="literallayout"><a name="id721031-bb"></a>recursive_wrapper();</pre>
78<p>Initializes <code class="computeroutput">*this</code> by default construction of
79            <code class="computeroutput">T</code>.</p>
80<div class="variablelist"><table border="0">
81<col align="left" valign="top">
82<tbody>
83<tr>
84<td>
85<span class="term">Requires:</span></td>
86<td>
87<code class="computeroutput">T</code> must fulfill the requirements of the
88            <span class="emphasis"><em>DefaultConstructible</em></span> [20.1.4]
89            concept.</td>
90</tr>
91<tr>
92<td>
93<span class="term">Throws:</span></td>
94<td>May fail with any exceptions arising from the default
95            constructor of <code class="computeroutput">T</code> or, in the event of
96            insufficient memory, with <code class="computeroutput">std::bad_alloc</code>.</td>
97</tr>
98</tbody>
99</table></div>
100</li>
101<li>
102<pre class="literallayout"><a name="id1672537-bb"></a>recursive_wrapper(<span class="bold"><strong>const</strong></span> recursive_wrapper &amp; other);</pre>
103<p>Copies the content of <code class="computeroutput">other</code> into
104            <code class="computeroutput">*this</code>.</p>
105<div class="variablelist"><table border="0">
106<col align="left" valign="top">
107<tbody><tr>
108<td>
109<span class="term">Throws:</span></td>
110<td>May fail with any exceptions arising from the
111            copy constructor of <code class="computeroutput">T</code> or, in the event of
112            insufficient memory, with <code class="computeroutput">std::bad_alloc</code>.</td>
113</tr></tbody>
114</table></div>
115</li>
116<li>
117<pre class="literallayout"><a name="id1672580-bb"></a>recursive_wrapper(<span class="bold"><strong>const</strong></span> T &amp; operand);</pre>
118<p>Copies <code class="computeroutput">operand</code> into
119            <code class="computeroutput">*this</code>.</p>
120<div class="variablelist"><table border="0">
121<col align="left" valign="top">
122<tbody><tr>
123<td>
124<span class="term">Throws:</span></td>
125<td>May fail with any exceptions arising from the
126            copy constructor of <code class="computeroutput">T</code> or, in the event of
127            insufficient memory, with <code class="computeroutput">std::bad_alloc</code>.</td>
128</tr></tbody>
129</table></div>
130</li>
131<li>
132<pre class="literallayout"><a name="id1570808-bb"></a>~recursive_wrapper();</pre>
133<p>Deletes the content of <code class="computeroutput">*this</code>.</p>
134<div class="variablelist"><table border="0">
135<col align="left" valign="top">
136<tbody><tr>
137<td>
138<span class="term">Throws:</span></td>
139<td>Will not throw.</td>
140</tr></tbody>
141</table></div>
142</li>
143</ol></div>
144</div>
145<div class="refsect2" lang="en">
146<a name="id1948359"></a><h3>
147<a name="id1672623-bb"></a><code class="computeroutput">recursive_wrapper</code> modifiers</h3>
148<div class="orderedlist"><ol type="1">
149<li>
150<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1672627-bb"></a>swap(recursive_wrapper &amp; other);</pre>
151<p>Exchanges contents of <code class="computeroutput">*this</code> and
152              <code class="computeroutput">other</code>.</p>
153<div class="variablelist"><table border="0">
154<col align="left" valign="top">
155<tbody><tr>
156<td>
157<span class="term">Throws:</span></td>
158<td>Will not throw.</td>
159</tr></tbody>
160</table></div>
161</li>
162<li>
163<pre class="literallayout"><span class="type">recursive_wrapper &amp;</span> <a name="id1672659-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> recursive_wrapper &amp; rhs);</pre>
164<p>Assigns the content of <code class="computeroutput">rhs</code> to the content of
165              <code class="computeroutput">*this</code>.</p>
166<div class="variablelist"><table border="0">
167<col align="left" valign="top">
168<tbody>
169<tr>
170<td>
171<span class="term">Requires:</span></td>
172<td>
173<code class="computeroutput">T</code> must fulfill the requirements of
174            the <a href="../Assignable.html" title="Concept Assignable">Assignable</a>
175            concept.</td>
176</tr>
177<tr>
178<td>
179<span class="term">Throws:</span></td>
180<td>May fail with any exceptions arising from the assignment
181              operator of <code class="computeroutput">T</code>.</td>
182</tr>
183</tbody>
184</table></div>
185</li>
186<li>
187<pre class="literallayout"><span class="type">recursive_wrapper &amp;</span> <a name="id1637652-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> T &amp; rhs);</pre>
188<p>Assigns <code class="computeroutput">rhs</code> into the content of
189              <code class="computeroutput">*this</code>.</p>
190<div class="variablelist"><table border="0">
191<col align="left" valign="top">
192<tbody>
193<tr>
194<td>
195<span class="term">Requires:</span></td>
196<td>
197<code class="computeroutput">T</code> must fulfill the requirements of the
198              <a href="../Assignable.html" title="Concept Assignable">Assignable</a>
199              concept.</td>
200</tr>
201<tr>
202<td>
203<span class="term">Throws:</span></td>
204<td>May fail with any exceptions arising from the assignment
205              operator of <code class="computeroutput">T</code>.</td>
206</tr>
207</tbody>
208</table></div>
209</li>
210</ol></div>
211</div>
212<div class="refsect2" lang="en">
213<a name="id1948581"></a><h3>
214<a name="id1637710-bb"></a><code class="computeroutput">recursive_wrapper</code> queries</h3>
215<div class="orderedlist"><ol type="1">
216<li>
217<p><a name="id1637714-bb"></a></p>
218<pre class="literallayout"><span class="type">T &amp;</span> <a name="id1637718-bb"></a>get();
219<span class="type"><span class="bold"><strong>const</strong></span> T &amp;</span> <a name="id1637725-bb"></a>get() <span class="bold"><strong>const</strong></span>;</pre>
220<p>Returns a reference to the content of
221              <code class="computeroutput">*this</code>.</p>
222<div class="variablelist"><table border="0">
223<col align="left" valign="top">
224<tbody><tr>
225<td>
226<span class="term">Throws:</span></td>
227<td>Will not throw.</td>
228</tr></tbody>
229</table></div>
230</li>
231<li>
232<p><a name="id1591456-bb"></a></p>
233<pre class="literallayout"><span class="type">T *</span> <a name="id1591460-bb"></a>get_pointer();
234<span class="type"><span class="bold"><strong>const</strong></span> T *</span> <a name="id1591467-bb"></a>get_pointer() <span class="bold"><strong>const</strong></span>;</pre>
235<p>Returns a pointer to the content of
236              <code class="computeroutput">*this</code>.</p>
237<div class="variablelist"><table border="0">
238<col align="left" valign="top">
239<tbody><tr>
240<td>
241<span class="term">Throws:</span></td>
242<td>Will not throw.</td>
243</tr></tbody>
244</table></div>
245</li>
246</ol></div>
247</div>
248</div>
249</div>
250<table width="100%"><tr>
251<td align="left"></td>
252<td align="right"><small>Copyright © 2002, 2003 Eric Friedman, Itay Maman</small></td>
253</tr></table>
254<hr>
255<div class="spirit-nav">
256<a accesskey="p" href="make_recursive_variant_over.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../variant/reference.html#header.boost.variant.recursive_wrapper.hpp"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_recursive_wrapper.html"><img src="../images/next.png" alt="Next"></a>
257</div>
258</body>
259</html>
Note: See TracBrowser for help on using the repository browser.