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.69.1"> |
---|
7 | <link rel="start" href="../index.html" title="The Boost C++ Libraries"> |
---|
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.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="../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#id2335348-bb">any</a>(); |
---|
39 | <a href="any.html#id2335362-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#id2335410-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#id2335472-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#id2336475-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> ValueType &); |
---|
43 | <a href="any.html#id2335457-bb">~any</a>(); |
---|
44 | |
---|
45 | <span class="emphasis"><em>// <a href="any.html#id2336530-bb">modifiers</a></em></span> |
---|
46 | <span class="type"><a href="any.html" title="Class any">any</a> &</span> <a href="any.html#id2336535-bb">swap</a>(<a href="any.html" title="Class any">any</a> &); |
---|
47 | |
---|
48 | <span class="emphasis"><em>// <a href="any.html#id2336585-bb">queries</a></em></span> |
---|
49 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="any.html#id2336590-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#id2336618-bb">type</a>() <span class="bold"><strong>const</strong></span>; |
---|
51 | };</pre></div> |
---|
52 | <div class="refsect1" lang="en"> |
---|
53 | <a name="id2571408"></a><h2>Description</h2> |
---|
54 | <div class="refsect2" lang="en"> |
---|
55 | <a name="id2571411"></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="id2335348-bb"></a>any();</pre> |
---|
60 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Postconditions</span></b>: |
---|
61 | |
---|
62 | <code class="computeroutput">this-><a href="any.html#id2336590-bb">empty</a>()</code></p> |
---|
63 | </li> |
---|
64 | <li> |
---|
65 | <pre class="literallayout"><a name="id2335362-bb"></a>any(<span class="bold"><strong>const</strong></span> <a href="any.html" title="Class any">any</a> & other);</pre> |
---|
66 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
67 | |
---|
68 | Copy constructor that copies content of |
---|
69 | <code class="computeroutput">other</code> into new instance, so that any content |
---|
70 | is equivalent in both type and value to the content of |
---|
71 | <code class="computeroutput">other</code>, or empty if <code class="computeroutput">other</code> is |
---|
72 | empty. <br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
73 | |
---|
74 | May fail with a |
---|
75 | <code class="computeroutput">std::bad_alloc</code> |
---|
76 | exception or any exceptions arising from the copy |
---|
77 | constructor of the contained type.</p> |
---|
78 | </li> |
---|
79 | <li> |
---|
80 | <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> ValueType> <a name="id2335410-bb"></a>any(<span class="bold"><strong>const</strong></span> ValueType & value);</pre> |
---|
81 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
82 | |
---|
83 | Makes a copy of <code class="computeroutput">value</code>, so |
---|
84 | that the initial content of the new instance is equivalent |
---|
85 | in both type and value to |
---|
86 | <code class="computeroutput">value</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
87 | |
---|
88 | <code class="computeroutput">std::bad_alloc</code> |
---|
89 | or any exceptions arising from the copy constructor of the |
---|
90 | contained type.</p> |
---|
91 | </li> |
---|
92 | <li> |
---|
93 | <pre class="literallayout"><span class="type"><a href="any.html" title="Class any">any</a> &</span> <a name="id2335472-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> |
---|
94 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
95 | |
---|
96 | Copies content of <code class="computeroutput">rhs</code> into |
---|
97 | current instance, discarding previous content, so that the |
---|
98 | new content is equivalent in both type and value to the |
---|
99 | content of <code class="computeroutput">rhs</code>, or empty if |
---|
100 | <code class="computeroutput">rhs.<a href="any.html#id2336590-bb">empty</a>()</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
101 | |
---|
102 | <code class="computeroutput">std::bad_alloc</code> |
---|
103 | or any exceptions arising from the copy constructor of the |
---|
104 | contained type. Assignment satisfies the strong guarantee |
---|
105 | of exception safety.</p> |
---|
106 | </li> |
---|
107 | <li> |
---|
108 | <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="id2336475-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> ValueType & rhs);</pre> |
---|
109 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
110 | |
---|
111 | Makes a copy of <code class="computeroutput">rhs</code>, |
---|
112 | discarding previous content, so that the new content of is |
---|
113 | equivalent in both type and value to |
---|
114 | <code class="computeroutput">rhs</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
115 | |
---|
116 | <code class="computeroutput">std::bad_alloc</code> |
---|
117 | or any exceptions arising from the copy constructor of the |
---|
118 | contained type. Assignment satisfies the strong guarantee |
---|
119 | of exception safety.</p> |
---|
120 | </li> |
---|
121 | <li> |
---|
122 | <pre class="literallayout"><a name="id2335457-bb"></a>~any();</pre> |
---|
123 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
124 | |
---|
125 | Releases any and all resources used in |
---|
126 | management of instance.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
127 | |
---|
128 | Nothing.</p> |
---|
129 | </li> |
---|
130 | </ol></div> |
---|
131 | </div> |
---|
132 | <div class="refsect2" lang="en"> |
---|
133 | <a name="id2571814"></a><h3> |
---|
134 | <a name="id2336530-bb"></a><code class="computeroutput">any</code> modifiers</h3> |
---|
135 | <div class="orderedlist"><ol type="1"><li> |
---|
136 | <pre class="literallayout"><span class="type"><a href="any.html" title="Class any">any</a> &</span> <a name="id2336535-bb"></a>swap(<a href="any.html" title="Class any">any</a> & rhs);</pre> |
---|
137 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
138 | |
---|
139 | Exchange of the contents of |
---|
140 | <code class="computeroutput">*this</code> and |
---|
141 | <code class="computeroutput">rhs</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Returns</span></b>: |
---|
142 | |
---|
143 | <code class="computeroutput">*this</code><br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
144 | |
---|
145 | Nothing.</p> |
---|
146 | </li></ol></div> |
---|
147 | </div> |
---|
148 | <div class="refsect2" lang="en"> |
---|
149 | <a name="id2571901"></a><h3> |
---|
150 | <a name="id2336585-bb"></a><code class="computeroutput">any</code> queries</h3> |
---|
151 | <div class="orderedlist"><ol type="1"> |
---|
152 | <li> |
---|
153 | <pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2336590-bb"></a>empty() <span class="bold"><strong>const</strong></span>;</pre> |
---|
154 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Returns</span></b>: |
---|
155 | |
---|
156 | <code class="computeroutput">true</code> if instance is |
---|
157 | empty, otherwise <code class="computeroutput">false</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
158 | |
---|
159 | Will not throw.</p> |
---|
160 | </li> |
---|
161 | <li> |
---|
162 | <pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> std::type_info &</span> <a name="id2336618-bb"></a>type() <span class="bold"><strong>const</strong></span>;</pre> |
---|
163 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Returns</span></b>: |
---|
164 | |
---|
165 | the <code class="computeroutput">typeid</code> of the |
---|
166 | contained value if instance is non-empty, otherwise |
---|
167 | <code class="computeroutput">typeid(void)</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Notes</span></b>: |
---|
168 | |
---|
169 | Useful for querying against types known |
---|
170 | either at compile time or only at |
---|
171 | runtime.</p> |
---|
172 | </li> |
---|
173 | </ol></div> |
---|
174 | </div> |
---|
175 | </div> |
---|
176 | </div> |
---|
177 | <table width="100%"><tr> |
---|
178 | <td align="left"></td> |
---|
179 | <td align="right"><small>Copyright © 2001 Kevlin Henney</small></td> |
---|
180 | </tr></table> |
---|
181 | <hr> |
---|
182 | <div class="spirit-nav"> |
---|
183 | <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> |
---|
184 | </div> |
---|
185 | </body> |
---|
186 | </html> |
---|