1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Class any</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="../any/reference.html#header.boost.any.hpp" title="Header <boost/any.hpp>"> |
---|
9 | <link rel="prev" href="bad_any_cast.html" title="Class bad_any_cast"> |
---|
10 | <link rel="next" href="any_cast.html" title="Function any_cast"> |
---|
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="bad_any_cast.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../any/reference.html#header.boost.any.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="any_cast.html"><img src="../images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="refentry" lang="en"> |
---|
26 | <a name="boost.any"></a><div class="titlepage"></div> |
---|
27 | <div class="refnamediv"> |
---|
28 | <h2><span class="refentrytitle">Class any</span></h2> |
---|
29 | <p>boost::any — A class whose instances can hold instances of any |
---|
30 | type that satisfies <a href="../any/reference.html#any.ValueType" title="ValueType requirements">ValueType</a> |
---|
31 | requirements.</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"><pre class="synopsis"> |
---|
35 | <span class="bold"><strong>class</strong></span> any { |
---|
36 | <span class="bold"><strong>public</strong></span>: |
---|
37 | <span class="emphasis"><em>// <a href="any.html#boost.anyconstruct-copy-destruct">construct/copy/destruct</a></em></span> |
---|
38 | <a href="any.html#id717178-bb">any</a>(); |
---|
39 | <a href="any.html#id717190-bb">any</a>(<span class="bold"><strong>const</strong></span> <a href="any.html" title="Class any">any</a> &); |
---|
40 | <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> ValueType> <a href="any.html#id717232-bb">any</a>(<span class="bold"><strong>const</strong></span> ValueType &); |
---|
41 | <span class="type"><a href="any.html" title="Class any">any</a> &</span> <a href="any.html#id717286-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> <a href="any.html" title="Class any">any</a> &); |
---|
42 | <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> ValueType> <span class="type"><a href="any.html" title="Class any">any</a> &</span> <a href="any.html#id717336-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> ValueType &); |
---|
43 | <a href="any.html#id717273-bb">~any</a>(); |
---|
44 | |
---|
45 | <span class="emphasis"><em>// <a href="any.html#id717384-bb">modifiers</a></em></span> |
---|
46 | <span class="type"><a href="any.html" title="Class any">any</a> &</span> <a href="any.html#id717388-bb">swap</a>(<a href="any.html" title="Class any">any</a> &); |
---|
47 | |
---|
48 | <span class="emphasis"><em>// <a href="any.html#id717430-bb">queries</a></em></span> |
---|
49 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="any.html#id717434-bb">empty</a>() <span class="bold"><strong>const</strong></span>; |
---|
50 | <span class="type"><span class="bold"><strong>const</strong></span> std::type_info &</span> <a href="any.html#id717459-bb">type</a>() <span class="bold"><strong>const</strong></span>; |
---|
51 | };</pre></div> |
---|
52 | <div class="refsect1" lang="en"> |
---|
53 | <a name="id937772"></a><h2>Description</h2> |
---|
54 | <div class="refsect2" lang="en"> |
---|
55 | <a name="id937775"></a><h3> |
---|
56 | <a name="boost.anyconstruct-copy-destruct"></a><code class="computeroutput">any</code> construct/copy/destruct</h3> |
---|
57 | <div class="orderedlist"><ol type="1"> |
---|
58 | <li> |
---|
59 | <pre class="literallayout"><a name="id717178-bb"></a>any();</pre> |
---|
60 | <div class="variablelist"><table border="0"> |
---|
61 | <col align="left" valign="top"> |
---|
62 | <tbody><tr> |
---|
63 | <td> |
---|
64 | <span class="term">Postconditions:</span></td> |
---|
65 | <td><code class="computeroutput">this-><a href="any.html#id717434-bb">empty</a>()</code></td> |
---|
66 | </tr></tbody> |
---|
67 | </table></div> |
---|
68 | </li> |
---|
69 | <li> |
---|
70 | <pre class="literallayout"><a name="id717190-bb"></a>any(<span class="bold"><strong>const</strong></span> <a href="any.html" title="Class any">any</a> & other);</pre> |
---|
71 | <div class="variablelist"><table border="0"> |
---|
72 | <col align="left" valign="top"> |
---|
73 | <tbody> |
---|
74 | <tr> |
---|
75 | <td> |
---|
76 | <span class="term">Effects:</span></td> |
---|
77 | <td> Copy constructor that copies content of |
---|
78 | <code class="computeroutput">other</code> into new instance, so that any content |
---|
79 | is equivalent in both type and value to the content of |
---|
80 | <code class="computeroutput">other</code>, or empty if <code class="computeroutput">other</code> is |
---|
81 | empty. </td> |
---|
82 | </tr> |
---|
83 | <tr> |
---|
84 | <td> |
---|
85 | <span class="term">Throws:</span></td> |
---|
86 | <td>May fail with a |
---|
87 | <code class="computeroutput">std::bad_alloc</code> |
---|
88 | exception or any exceptions arising from the copy |
---|
89 | constructor of the contained type.</td> |
---|
90 | </tr> |
---|
91 | </tbody> |
---|
92 | </table></div> |
---|
93 | </li> |
---|
94 | <li> |
---|
95 | <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> ValueType> <a name="id717232-bb"></a>any(<span class="bold"><strong>const</strong></span> ValueType & value);</pre> |
---|
96 | <div class="variablelist"><table border="0"> |
---|
97 | <col align="left" valign="top"> |
---|
98 | <tbody> |
---|
99 | <tr> |
---|
100 | <td> |
---|
101 | <span class="term">Effects:</span></td> |
---|
102 | <td>Makes a copy of <code class="computeroutput">value</code>, so |
---|
103 | that the initial content of the new instance is equivalent |
---|
104 | in both type and value to |
---|
105 | <code class="computeroutput">value</code>.</td> |
---|
106 | </tr> |
---|
107 | <tr> |
---|
108 | <td> |
---|
109 | <span class="term">Throws:</span></td> |
---|
110 | <td> |
---|
111 | <code class="computeroutput">std::bad_alloc</code> |
---|
112 | or any exceptions arising from the copy constructor of the |
---|
113 | contained type.</td> |
---|
114 | </tr> |
---|
115 | </tbody> |
---|
116 | </table></div> |
---|
117 | </li> |
---|
118 | <li> |
---|
119 | <pre class="literallayout"><span class="type"><a href="any.html" title="Class any">any</a> &</span> <a name="id717286-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> <a href="any.html" title="Class any">any</a> & rhs);</pre> |
---|
120 | <div class="variablelist"><table border="0"> |
---|
121 | <col align="left" valign="top"> |
---|
122 | <tbody> |
---|
123 | <tr> |
---|
124 | <td> |
---|
125 | <span class="term">Effects:</span></td> |
---|
126 | <td>Copies content of <code class="computeroutput">rhs</code> into |
---|
127 | current instance, discarding previous content, so that the |
---|
128 | new content is equivalent in both type and value to the |
---|
129 | content of <code class="computeroutput">rhs</code>, or empty if |
---|
130 | <code class="computeroutput">rhs.<a href="any.html#id717434-bb">empty</a>()</code>.</td> |
---|
131 | </tr> |
---|
132 | <tr> |
---|
133 | <td> |
---|
134 | <span class="term">Throws:</span></td> |
---|
135 | <td> |
---|
136 | <code class="computeroutput">std::bad_alloc</code> |
---|
137 | or any exceptions arising from the copy constructor of the |
---|
138 | contained type. Assignment satisfies the strong guarantee |
---|
139 | of exception safety.</td> |
---|
140 | </tr> |
---|
141 | </tbody> |
---|
142 | </table></div> |
---|
143 | </li> |
---|
144 | <li> |
---|
145 | <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> ValueType> <span class="type"><a href="any.html" title="Class any">any</a> &</span> <a name="id717336-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> ValueType & rhs);</pre> |
---|
146 | <div class="variablelist"><table border="0"> |
---|
147 | <col align="left" valign="top"> |
---|
148 | <tbody> |
---|
149 | <tr> |
---|
150 | <td> |
---|
151 | <span class="term">Effects:</span></td> |
---|
152 | <td>Makes a copy of <code class="computeroutput">rhs</code>, |
---|
153 | discarding previous content, so that the new content of is |
---|
154 | equivalent in both type and value to |
---|
155 | <code class="computeroutput">rhs</code>.</td> |
---|
156 | </tr> |
---|
157 | <tr> |
---|
158 | <td> |
---|
159 | <span class="term">Throws:</span></td> |
---|
160 | <td> |
---|
161 | <code class="computeroutput">std::bad_alloc</code> |
---|
162 | or any exceptions arising from the copy constructor of the |
---|
163 | contained type. Assignment satisfies the strong guarantee |
---|
164 | of exception safety.</td> |
---|
165 | </tr> |
---|
166 | </tbody> |
---|
167 | </table></div> |
---|
168 | </li> |
---|
169 | <li> |
---|
170 | <pre class="literallayout"><a name="id717273-bb"></a>~any();</pre> |
---|
171 | <div class="variablelist"><table border="0"> |
---|
172 | <col align="left" valign="top"> |
---|
173 | <tbody> |
---|
174 | <tr> |
---|
175 | <td> |
---|
176 | <span class="term">Effects:</span></td> |
---|
177 | <td>Releases any and all resources used in |
---|
178 | management of instance.</td> |
---|
179 | </tr> |
---|
180 | <tr> |
---|
181 | <td> |
---|
182 | <span class="term">Throws:</span></td> |
---|
183 | <td>Nothing.</td> |
---|
184 | </tr> |
---|
185 | </tbody> |
---|
186 | </table></div> |
---|
187 | </li> |
---|
188 | </ol></div> |
---|
189 | </div> |
---|
190 | <div class="refsect2" lang="en"> |
---|
191 | <a name="id938180"></a><h3> |
---|
192 | <a name="id717384-bb"></a><code class="computeroutput">any</code> modifiers</h3> |
---|
193 | <div class="orderedlist"><ol type="1"><li> |
---|
194 | <pre class="literallayout"><span class="type"><a href="any.html" title="Class any">any</a> &</span> <a name="id717388-bb"></a>swap(<a href="any.html" title="Class any">any</a> & rhs);</pre> |
---|
195 | <div class="variablelist"><table border="0"> |
---|
196 | <col align="left" valign="top"> |
---|
197 | <tbody> |
---|
198 | <tr> |
---|
199 | <td> |
---|
200 | <span class="term">Effects:</span></td> |
---|
201 | <td>Exchange of the contents of |
---|
202 | <code class="computeroutput">*this</code> and |
---|
203 | <code class="computeroutput">rhs</code>.</td> |
---|
204 | </tr> |
---|
205 | <tr> |
---|
206 | <td> |
---|
207 | <span class="term">Returns:</span></td> |
---|
208 | <td><code class="computeroutput">*this</code></td> |
---|
209 | </tr> |
---|
210 | <tr> |
---|
211 | <td> |
---|
212 | <span class="term">Throws:</span></td> |
---|
213 | <td>Nothing.</td> |
---|
214 | </tr> |
---|
215 | </tbody> |
---|
216 | </table></div> |
---|
217 | </li></ol></div> |
---|
218 | </div> |
---|
219 | <div class="refsect2" lang="en"> |
---|
220 | <a name="id938267"></a><h3> |
---|
221 | <a name="id717430-bb"></a><code class="computeroutput">any</code> queries</h3> |
---|
222 | <div class="orderedlist"><ol type="1"> |
---|
223 | <li> |
---|
224 | <pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id717434-bb"></a>empty() <span class="bold"><strong>const</strong></span>;</pre> |
---|
225 | <div class="variablelist"><table border="0"> |
---|
226 | <col align="left" valign="top"> |
---|
227 | <tbody> |
---|
228 | <tr> |
---|
229 | <td> |
---|
230 | <span class="term">Returns:</span></td> |
---|
231 | <td> |
---|
232 | <code class="computeroutput">true</code> if instance is |
---|
233 | empty, otherwise <code class="computeroutput">false</code>.</td> |
---|
234 | </tr> |
---|
235 | <tr> |
---|
236 | <td> |
---|
237 | <span class="term">Throws:</span></td> |
---|
238 | <td>Will not throw.</td> |
---|
239 | </tr> |
---|
240 | </tbody> |
---|
241 | </table></div> |
---|
242 | </li> |
---|
243 | <li> |
---|
244 | <pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> std::type_info &</span> <a name="id717459-bb"></a>type() <span class="bold"><strong>const</strong></span>;</pre> |
---|
245 | <div class="variablelist"><table border="0"> |
---|
246 | <col align="left" valign="top"> |
---|
247 | <tbody> |
---|
248 | <tr> |
---|
249 | <td> |
---|
250 | <span class="term">Returns:</span></td> |
---|
251 | <td>the <code class="computeroutput">typeid</code> of the |
---|
252 | contained value if instance is non-empty, otherwise |
---|
253 | <code class="computeroutput">typeid(void)</code>.</td> |
---|
254 | </tr> |
---|
255 | <tr> |
---|
256 | <td> |
---|
257 | <span class="term">Notes:</span></td> |
---|
258 | <td>Useful for querying against types known |
---|
259 | either at compile time or only at |
---|
260 | runtime.</td> |
---|
261 | </tr> |
---|
262 | </tbody> |
---|
263 | </table></div> |
---|
264 | </li> |
---|
265 | </ol></div> |
---|
266 | </div> |
---|
267 | </div> |
---|
268 | </div> |
---|
269 | <table width="100%"><tr> |
---|
270 | <td align="left"></td> |
---|
271 | <td align="right"><small>Copyright © 2001 Kevlin Henney</small></td> |
---|
272 | </tr></table> |
---|
273 | <hr> |
---|
274 | <div class="spirit-nav"> |
---|
275 | <a accesskey="p" href="bad_any_cast.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../any/reference.html#header.boost.any.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="any_cast.html"><img src="../images/next.png" alt="Next"></a> |
---|
276 | </div> |
---|
277 | </body> |
---|
278 | </html> |
---|