Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/recursive_wrapper.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 12.7 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.69.1">
7<link rel="start" href="index.html" title="The Boost C++ Libraries">
8<link rel="up" href="variant/reference.html#id2644455" title="Header &lt;boost/variant/recursive_wrapper.hpp&gt;">
9<link rel="prev" href="id2655704.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.png (6897 bytes)" 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="id2655704.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="variant/reference.html#id2644455"><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="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#recursive_wrapperconstruct-copy-destruct">construct/copy/destruct</a></em></span>
39  <a href="recursive_wrapper.html#id2671693-bb">recursive_wrapper</a>();
40  <a href="recursive_wrapper.html#id2637040-bb">recursive_wrapper</a>(<span class="bold"><strong>const</strong></span> recursive_wrapper &amp;);
41  <a href="recursive_wrapper.html#id2344755-bb">recursive_wrapper</a>(<span class="bold"><strong>const</strong></span> T &amp;);
42  <a href="recursive_wrapper.html#id2674999-bb">~recursive_wrapper</a>();
43
44  <span class="emphasis"><em>// <a href="recursive_wrapper.html#id2644448-bb">modifiers</a></em></span>
45  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="recursive_wrapper.html#id2668585-bb">swap</a>(recursive_wrapper &amp;);
46  <span class="type">recursive_wrapper &amp;</span> <a href="recursive_wrapper.html#id2367524-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#id2666359-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#id2655610-bb">queries</a></em></span>
50  <span class="type">T &amp;</span> <a href="recursive_wrapper.html#id2645317-bb">get</a>();
51  <span class="type"><span class="bold"><strong>const</strong></span> T &amp;</span> <a href="recursive_wrapper.html#id2535155-bb">get</a>() <span class="bold"><strong>const</strong></span>;
52  <span class="type">T *</span> <a href="recursive_wrapper.html#id2653701-bb">get_pointer</a>();
53  <span class="type"><span class="bold"><strong>const</strong></span> T *</span> <a href="recursive_wrapper.html#id2667787-bb">get_pointer</a>() <span class="bold"><strong>const</strong></span>;
54};</pre></div>
55<div class="refsect1" lang="en">
56<a name="id2836870"></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="id2836951"></a><h3>
74<a name="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="id2671693-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<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>:
81
82    <code class="computeroutput">T</code> must fulfill the requirements of the
83            <span class="emphasis"><em>DefaultConstructible</em></span> [20.1.4]
84            concept.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
85
86    May fail with any exceptions arising from the default
87            constructor of <code class="computeroutput">T</code> or, in the event of
88            insufficient memory, with <code class="computeroutput">std::bad_alloc</code>.</p>
89</li>
90<li>
91<pre class="literallayout"><a name="id2637040-bb"></a>recursive_wrapper(<span class="bold"><strong>const</strong></span> recursive_wrapper &amp; other);</pre>
92<p>Copies the content of <code class="computeroutput">other</code> into
93            <code class="computeroutput">*this</code>.</p>
94<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
95
96    May fail with any exceptions arising from the
97            copy constructor of <code class="computeroutput">T</code> or, in the event of
98            insufficient memory, with <code class="computeroutput">std::bad_alloc</code>.</p>
99</li>
100<li>
101<pre class="literallayout"><a name="id2344755-bb"></a>recursive_wrapper(<span class="bold"><strong>const</strong></span> T &amp; operand);</pre>
102<p>Copies <code class="computeroutput">operand</code> into
103            <code class="computeroutput">*this</code>.</p>
104<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
105
106    May fail with any exceptions arising from the
107            copy constructor of <code class="computeroutput">T</code> or, in the event of
108            insufficient memory, with <code class="computeroutput">std::bad_alloc</code>.</p>
109</li>
110<li>
111<pre class="literallayout"><a name="id2674999-bb"></a>~recursive_wrapper();</pre>
112<p>Deletes the content of <code class="computeroutput">*this</code>.</p>
113<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
114
115    Will not throw.</p>
116</li>
117</ol></div>
118</div>
119<div class="refsect2" lang="en">
120<a name="id2837191"></a><h3>
121<a name="id2644448-bb"></a><code class="computeroutput">recursive_wrapper</code> modifiers</h3>
122<div class="orderedlist"><ol type="1">
123<li>
124<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2668585-bb"></a>swap(recursive_wrapper &amp; other);</pre>
125<p>Exchanges contents of <code class="computeroutput">*this</code> and
126              <code class="computeroutput">other</code>.</p>
127<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
128
129    Will not throw.</p>
130</li>
131<li>
132<pre class="literallayout"><span class="type">recursive_wrapper &amp;</span> <a name="id2367524-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> recursive_wrapper &amp; rhs);</pre>
133<p>Assigns the content of <code class="computeroutput">rhs</code> to the content of
134              <code class="computeroutput">*this</code>.</p>
135<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>:
136
137    <code class="computeroutput">T</code> must fulfill the requirements of
138            the <a href="Assignable.html" title="Concept Assignable">Assignable</a>
139            concept.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
140
141    May fail with any exceptions arising from the assignment
142              operator of <code class="computeroutput">T</code>.</p>
143</li>
144<li>
145<pre class="literallayout"><span class="type">recursive_wrapper &amp;</span> <a name="id2666359-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> T &amp; rhs);</pre>
146<p>Assigns <code class="computeroutput">rhs</code> into the content of
147              <code class="computeroutput">*this</code>.</p>
148<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>:
149
150    <code class="computeroutput">T</code> must fulfill the requirements of the
151              <a href="Assignable.html" title="Concept Assignable">Assignable</a>
152              concept.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
153
154    May fail with any exceptions arising from the assignment
155              operator of <code class="computeroutput">T</code>.</p>
156</li>
157</ol></div>
158</div>
159<div class="refsect2" lang="en">
160<a name="id2837414"></a><h3>
161<a name="id2655610-bb"></a><code class="computeroutput">recursive_wrapper</code> queries</h3>
162<div class="orderedlist"><ol type="1">
163<li>
164<p><a name="id2636766-bb"></a></p>
165<pre class="literallayout"><span class="type">T &amp;</span> <a name="id2645317-bb"></a>get();
166<span class="type"><span class="bold"><strong>const</strong></span> T &amp;</span> <a name="id2535155-bb"></a>get() <span class="bold"><strong>const</strong></span>;</pre>
167<p>Returns a reference to the content of
168              <code class="computeroutput">*this</code>.</p>
169<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
170
171    Will not throw.</p>
172</li>
173<li>
174<p><a name="id2671337-bb"></a></p>
175<pre class="literallayout"><span class="type">T *</span> <a name="id2653701-bb"></a>get_pointer();
176<span class="type"><span class="bold"><strong>const</strong></span> T *</span> <a name="id2667787-bb"></a>get_pointer() <span class="bold"><strong>const</strong></span>;</pre>
177<p>Returns a pointer to the content of
178              <code class="computeroutput">*this</code>.</p>
179<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
180
181    Will not throw.</p>
182</li>
183</ol></div>
184</div>
185</div>
186</div>
187<table width="100%"><tr>
188<td align="left"></td>
189<td align="right"><small>Copyright © 2002, 2003 Eric Friedman, Itay Maman</small></td>
190</tr></table>
191<hr>
192<div class="spirit-nav">
193<a accesskey="p" href="id2655704.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="variant/reference.html#id2644455"><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>
194</div>
195</body>
196</html>
Note: See TracBrowser for help on using the repository browser.