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>Class template any</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="../../boost_typeerasure/reference.html#header.boost.type_erasure.any_hpp" title="Header <boost/type_erasure/any.hpp>"> 10<link rel="prev" href="../../boost_typeerasure/reference.html" title="Reference"> 11<link rel="next" href="any_Conc_1_3_41_13_1_1_1_2.html" title="Class template any<Concept, const T &>"> 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="../../boost_typeerasure/reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_typeerasure/reference.html#header.boost.type_erasure.any_hpp"><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="any_Conc_1_3_41_13_1_1_1_2.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="boost.type_erasure.any"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Class template any</span></h2> 30<p>boost::type_erasure::any</p> 31</div> 32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../boost_typeerasure/reference.html#header.boost.type_erasure.any_hpp" title="Header <boost/type_erasure/any.hpp>">boost/type_erasure/any.hpp</a>> 34 35</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept<span class="special">,</span> <span class="keyword">typename</span> T <span class="special">=</span> <a class="link" href="_self.html" title="Struct _self">_self</a><span class="special">></span> 36<span class="keyword">class</span> <a class="link" href="any.html" title="Class template any">any</a> <span class="special">{</span> 37<span class="keyword">public</span><span class="special">:</span> 38 <span class="comment">// <a class="link" href="any.html#boost.type_erasure.anyconstruct-copy-destruct">construct/copy/destruct</a></span> 39 <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_4-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 40 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_5-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span><span class="special">)</span><span class="special">;</span> 41 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">,</span> <span class="keyword">typename</span> Map<span class="special">></span> <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_6-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="static_binding.html" title="Struct template static_binding">static_binding</a><span class="special"><</span> <span class="identifier">Map</span> <span class="special">></span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 42 <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_7-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 43 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept2<span class="special">,</span> <span class="keyword">typename</span> Tag2<span class="special">></span> 44 <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_8-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a><span class="special"><</span> <span class="identifier">Concept2</span><span class="special">,</span> <span class="identifier">Tag2</span> <span class="special">></span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 45 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept2<span class="special">,</span> <span class="keyword">typename</span> Tag2<span class="special">,</span> <span class="keyword">typename</span> Map<span class="special">></span> 46 <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_9-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a><span class="special"><</span> <span class="identifier">Concept2</span><span class="special">,</span> <span class="identifier">Tag2</span> <span class="special">></span> <span class="special">&</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="static_binding.html" title="Struct template static_binding">static_binding</a><span class="special"><</span> <span class="identifier">Map</span> <span class="special">></span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 47 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept2<span class="special">,</span> <span class="keyword">typename</span> Tag2<span class="special">></span> 48 <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_10-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a><span class="special"><</span> <span class="identifier">Concept2</span><span class="special">,</span> <span class="identifier">Tag2</span> <span class="special">></span> <span class="special">&</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="binding.html" title="Class template binding">binding</a><span class="special"><</span> <span class="identifier">Concept</span> <span class="special">></span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 49 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> U<span class="special">></span> <span class="keyword">explicit</span> <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_11-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span><span class="special">...</span><span class="special">)</span><span class="special">;</span> 50 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> U<span class="special">></span> <span class="keyword">explicit</span> <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_12-bb"><span class="identifier">any</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="binding.html" title="Class template binding">binding</a><span class="special"><</span> <span class="identifier">Concept</span> <span class="special">></span> <span class="special">&</span><span class="special">,</span> <span class="identifier">U</span> <span class="special">&&</span><span class="special">...</span><span class="special">)</span><span class="special">;</span> 51 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a class="link" href="../any.html" title="Class any">any</a> <span class="special">&</span> <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_13-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span><span class="special">)</span><span class="special">;</span> 52 <a class="link" href="any.html#id-1_3_41_13_1_1_1_1_14-bb"><span class="special">~</span><span class="identifier">any</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 53<span class="special">}</span><span class="special">;</span></pre></div> 54<div class="refsect1"> 55<a name="id-1.3.41.13.2.3.4"></a><h2>Description</h2> 56<p>The class template <a class="link" href="any.html" title="Class template any">any</a> can store any object that models a specific <a class="link" href="../../boost_typeerasure/conceptdef.html" title="Concept Definitions">Concept</a>. It dispatches all the functions defined by the <a class="link" href="../../boost_typeerasure/conceptdef.html" title="Concept Definitions">Concept</a> to the contained type at runtime.</p> 57<p> 58</p> 59<p><span class="bold"><strong>See Also:</strong></span></p> 60<p><a class="link" href="concept_of.html" title="Struct template concept_of">concept_of</a>, <a class="link" href="placeholder_of.html" title="Struct template placeholder_of">placeholder_of</a>, <a class="link" href="any_cast.html" title="Function any_cast">any_cast</a>, <a class="link" href="is_empty.html" title="Function template is_empty">is_empty</a>, <a class="link" href="binding_of.html" title="Function template binding_of">binding_of</a>, <a class="link" href="typeid_of.html" title="Function typeid_of">typeid_of</a> </p> 61<p> 62</p> 63<p> 64</p> 65<div class="refsect2"> 66<a name="id-1.3.41.13.2.3.4.4"></a><h3>Template Parameters</h3> 67<div class="orderedlist"><ol class="orderedlist" type="1"> 68<li class="listitem"> 69<pre class="literallayout"><span class="keyword">typename</span> Concept</pre> 70<p>The <a class="link" href="../../boost_typeerasure/conceptdef.html" title="Concept Definitions">Concept</a> that the stored type should model. </p> 71</li> 72<li class="listitem"> 73<pre class="literallayout"><span class="keyword">typename</span> T <span class="special">=</span> <a class="link" href="_self.html" title="Struct _self">_self</a></pre> 74<p>A <code class="computeroutput"><a class="link" href="placeholder.html" title="Struct placeholder">placeholder</a></code> specifying which type this is.</p> 75</li> 76</ol></div> 77</div> 78<div class="refsect2"> 79<a name="id-1.3.41.13.2.3.4.5"></a><h3> 80<a name="boost.type_erasure.anyconstruct-copy-destruct"></a><code class="computeroutput">any</code> 81 public 82 construct/copy/destruct</h3> 83<div class="orderedlist"><ol class="orderedlist" type="1"> 84<li class="listitem"> 85<pre class="literallayout"><a name="id-1_3_41_13_1_1_1_1_4-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre> 86<p>Constructs an empty <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>.</p> 87<p>Except as otherwise noted, all operations on an empty <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> result in a <code class="computeroutput"><a class="link" href="bad_function_call.html" title="Class bad_function_call">bad_function_call</a></code> exception. The copy-constructor of an empty <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> creates another null <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>. The destructor of an empty <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> is a no-op. Comparison operators treat all empty <code class="computeroutput"><a class="link" href="any.html" title="Class template any">anys</a></code> as equal. <code class="computeroutput"><a class="link" href="typeid_of.html" title="Function typeid_of">typeid_of</a></code> applied to an empty <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> returns <code class="computeroutput">typeid(void)</code>.</p> 88<p>An <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> which does not include <code class="computeroutput"><a class="link" href="relaxed.html" title="Struct relaxed">relaxed</a></code> in its <a class="link" href="../../boost_typeerasure/conceptdef.html" title="Concept Definitions">Concept</a> can never be null.</p> 89<p> 90 91</p> 92<p><span class="bold"><strong>See Also:</strong></span></p> 93<p> <code class="computeroutput"><a class="link" href="is_empty.html" title="Function template is_empty">is_empty</a></code> </p> 94<p> 95</p> 96<p> 97</p> 98<div class="variablelist"><table border="0" class="variablelist compact"> 99<colgroup> 100<col align="left" valign="top"> 101<col> 102</colgroup> 103<tbody> 104<tr> 105<td><p><span class="term">Requires:</span></p></td> 106<td><p><a class="link" href="relaxed.html" title="Struct relaxed">relaxed</a> must be in <code class="computeroutput">Concept</code>.</p></td> 107</tr> 108<tr> 109<td><p><span class="term">Throws:</span></p></td> 110<td>Nothing. </td> 111</tr> 112</tbody> 113</table></div> 114</li> 115<li class="listitem"> 116<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a name="id-1_3_41_13_1_1_1_1_5-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span> data<span class="special">)</span><span class="special">;</span></pre> 117<p>Constructs an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> to hold a copy of <code class="computeroutput">data</code>. The <code class="computeroutput">Concept</code> will be instantiated with the placeholder <code class="computeroutput">T</code> bound to U.</p> 118<p> 119 120 121 122 123</p> 124<div class="note"><table border="0" summary="Note"> 125<tr> 126<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td> 127<th align="left">Note</th> 128</tr> 129<tr><td align="left" valign="top"><p>This constructor never matches if the argument is an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>, <code class="computeroutput"><a class="link" href="binding.html" title="Class template binding">binding</a></code>, or <code class="computeroutput"><a class="link" href="static_binding.html" title="Struct template static_binding">static_binding</a></code>. </p></td></tr> 130</table></div> 131<p> 132</p> 133<div class="variablelist"><table border="0" class="variablelist compact"> 134<colgroup> 135<col align="left" valign="top"> 136<col> 137</colgroup> 138<tbody> 139<tr> 140<td><p><span class="term">Parameters:</span></p></td> 141<td><div class="variablelist"><table border="0" class="variablelist compact"> 142<colgroup> 143<col align="left" valign="top"> 144<col> 145</colgroup> 146<tbody><tr> 147<td><p><span class="term"><code class="computeroutput">data</code></span></p></td> 148<td><p>The object to store in the <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>.</p></td> 149</tr></tbody> 150</table></div></td> 151</tr> 152<tr> 153<td><p><span class="term">Requires:</span></p></td> 154<td><p><code class="computeroutput">U</code> is a model of <code class="computeroutput">Concept</code>. </p></td> 155</tr> 156<tr> 157<td><p><span class="term">Requires:</span></p></td> 158<td><p><code class="computeroutput">U</code> must be <a href="../../../../doc/html/CopyConstructible.html" target="_top">CopyConstructible</a>. </p></td> 159</tr> 160<tr> 161<td><p><span class="term">Requires:</span></p></td> 162<td><p><code class="computeroutput">Concept</code> must not refer to any non-deduced placeholder besides <code class="computeroutput">T</code>.</p></td> 163</tr> 164<tr> 165<td><p><span class="term">Throws:</span></p></td> 166<td>std::bad_alloc or whatever that the copy constructor of <code class="computeroutput">U</code> throws.</td> 167</tr> 168</tbody> 169</table></div> 170</li> 171<li class="listitem"> 172<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">,</span> <span class="keyword">typename</span> Map<span class="special">></span> 173 <a name="id-1_3_41_13_1_1_1_1_6-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span> data<span class="special">,</span> <span class="keyword">const</span> <a class="link" href="static_binding.html" title="Struct template static_binding">static_binding</a><span class="special"><</span> <span class="identifier">Map</span> <span class="special">></span> <span class="special">&</span> binding<span class="special">)</span><span class="special">;</span></pre> 174<p>Constructs an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> to hold a copy of <code class="computeroutput">data</code> with explicitly specified placeholder bindings.</p> 175<p> 176 177 178 179 180 181</p> 182<div class="note"><table border="0" summary="Note"> 183<tr> 184<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td> 185<th align="left">Note</th> 186</tr> 187<tr><td align="left" valign="top"><p>This constructor never matches if the argument is an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>. </p></td></tr> 188</table></div> 189<p> 190</p> 191<div class="variablelist"><table border="0" class="variablelist compact"> 192<colgroup> 193<col align="left" valign="top"> 194<col> 195</colgroup> 196<tbody> 197<tr> 198<td><p><span class="term">Parameters:</span></p></td> 199<td><div class="variablelist"><table border="0" class="variablelist compact"> 200<colgroup> 201<col align="left" valign="top"> 202<col> 203</colgroup> 204<tbody> 205<tr> 206<td><p><span class="term"><code class="computeroutput">binding</code></span></p></td> 207<td><p>Specifies the types that all the placeholders should bind to.</p></td> 208</tr> 209<tr> 210<td><p><span class="term"><code class="computeroutput">data</code></span></p></td> 211<td><p>The object to store in the <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>. </p></td> 212</tr> 213</tbody> 214</table></div></td> 215</tr> 216<tr> 217<td><p><span class="term">Requires:</span></p></td> 218<td><p><code class="computeroutput">U</code> is a model of <code class="computeroutput">Concept</code>. </p></td> 219</tr> 220<tr> 221<td><p><span class="term">Requires:</span></p></td> 222<td><p><code class="computeroutput">U</code> must be <a href="../../../../doc/html/CopyConstructible.html" target="_top">CopyConstructible</a>. </p></td> 223</tr> 224<tr> 225<td><p><span class="term">Requires:</span></p></td> 226<td><p><code class="computeroutput">Map</code> is an MPL map with an entry for every non-deduced placeholder referred to by <code class="computeroutput">Concept</code>. </p></td> 227</tr> 228<tr> 229<td><p><span class="term">Requires:</span></p></td> 230<td><p><code class="computeroutput"><code class="computeroutput">T</code> must</code> map to <code class="computeroutput">U</code> in <code class="computeroutput">Map</code>.</p></td> 231</tr> 232<tr> 233<td><p><span class="term">Throws:</span></p></td> 234<td>std::bad_alloc or whatever that the copy constructor of <code class="computeroutput">U</code> throws.</td> 235</tr> 236</tbody> 237</table></div> 238</li> 239<li class="listitem"> 240<pre class="literallayout"><a name="id-1_3_41_13_1_1_1_1_7-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a> <span class="special">&</span> other<span class="special">)</span><span class="special">;</span></pre> 241<p>Copies an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>.</p> 242<p> 243 244 245</p> 246<div class="variablelist"><table border="0" class="variablelist compact"> 247<colgroup> 248<col align="left" valign="top"> 249<col> 250</colgroup> 251<tbody> 252<tr> 253<td><p><span class="term">Parameters:</span></p></td> 254<td><div class="variablelist"><table border="0" class="variablelist compact"> 255<colgroup> 256<col align="left" valign="top"> 257<col> 258</colgroup> 259<tbody><tr> 260<td><p><span class="term"><code class="computeroutput">other</code></span></p></td> 261<td><p>The object to make a copy of.</p></td> 262</tr></tbody> 263</table></div></td> 264</tr> 265<tr> 266<td><p><span class="term">Requires:</span></p></td> 267<td><p><code class="computeroutput">Concept</code> must contain <a class="link" href="constructible.html" title="Struct template constructible">constructible<T(const T&)></a>. (This is included in <a class="link" href="copy_constructible.html" title="Struct template copy_constructible">copy_constructible<T></a>)</p></td> 268</tr> 269<tr> 270<td><p><span class="term">Throws:</span></p></td> 271<td>std::bad_alloc or whatever that the copy constructor of the contained type throws. </td> 272</tr> 273</tbody> 274</table></div> 275</li> 276<li class="listitem"> 277<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept2<span class="special">,</span> <span class="keyword">typename</span> Tag2<span class="special">></span> 278 <a name="id-1_3_41_13_1_1_1_1_8-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a><span class="special"><</span> <span class="identifier">Concept2</span><span class="special">,</span> <span class="identifier">Tag2</span> <span class="special">></span> <span class="special">&</span> other<span class="special">)</span><span class="special">;</span></pre> 279<p>Upcasts from an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> with stricter requirements to an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> with weaker requirements.</p> 280<p> 281 282 283 284 285</p> 286<div class="variablelist"><table border="0" class="variablelist compact"> 287<colgroup> 288<col align="left" valign="top"> 289<col> 290</colgroup> 291<tbody> 292<tr> 293<td><p><span class="term">Parameters:</span></p></td> 294<td><div class="variablelist"><table border="0" class="variablelist compact"> 295<colgroup> 296<col align="left" valign="top"> 297<col> 298</colgroup> 299<tbody><tr> 300<td><p><span class="term"><code class="computeroutput">other</code></span></p></td> 301<td><p>The object to make a copy of.</p></td> 302</tr></tbody> 303</table></div></td> 304</tr> 305<tr> 306<td><p><span class="term">Requires:</span></p></td> 307<td><p><code class="computeroutput">Concept</code> must contain <a class="link" href="constructible.html" title="Struct template constructible">constructible<T(const T&)></a>. </p></td> 308</tr> 309<tr> 310<td><p><span class="term">Requires:</span></p></td> 311<td><p><code class="computeroutput">Concept</code> must not refer to any non-deduced placeholder besides <code class="computeroutput">T</code>. </p></td> 312</tr> 313<tr> 314<td><p><span class="term">Requires:</span></p></td> 315<td><p>After substituting <code class="computeroutput">T</code> for <code class="computeroutput">Tag2</code>, the requirements of <code class="computeroutput">Concept2</code> must be a superset of the requirements of <code class="computeroutput">Concept</code>.</p></td> 316</tr> 317<tr> 318<td><p><span class="term">Throws:</span></p></td> 319<td>std::bad_alloc or whatever that the copy constructor of the contained type throws. </td> 320</tr> 321</tbody> 322</table></div> 323</li> 324<li class="listitem"> 325<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept2<span class="special">,</span> <span class="keyword">typename</span> Tag2<span class="special">,</span> <span class="keyword">typename</span> Map<span class="special">></span> 326 <a name="id-1_3_41_13_1_1_1_1_9-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a><span class="special"><</span> <span class="identifier">Concept2</span><span class="special">,</span> <span class="identifier">Tag2</span> <span class="special">></span> <span class="special">&</span> other<span class="special">,</span> 327 <span class="keyword">const</span> <a class="link" href="static_binding.html" title="Struct template static_binding">static_binding</a><span class="special"><</span> <span class="identifier">Map</span> <span class="special">></span> <span class="special">&</span> binding<span class="special">)</span><span class="special">;</span></pre> 328<p>Constructs an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> from another <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>.</p> 329<p> 330 331 332 333 334</p> 335<div class="variablelist"><table border="0" class="variablelist compact"> 336<colgroup> 337<col align="left" valign="top"> 338<col> 339</colgroup> 340<tbody> 341<tr> 342<td><p><span class="term">Parameters:</span></p></td> 343<td><div class="variablelist"><table border="0" class="variablelist compact"> 344<colgroup> 345<col align="left" valign="top"> 346<col> 347</colgroup> 348<tbody> 349<tr> 350<td><p><span class="term"><code class="computeroutput">binding</code></span></p></td> 351<td><p>Specifies the mapping between the placeholders used by the two concepts.</p></td> 352</tr> 353<tr> 354<td><p><span class="term"><code class="computeroutput">other</code></span></p></td> 355<td><p>The object to make a copy of. </p></td> 356</tr> 357</tbody> 358</table></div></td> 359</tr> 360<tr> 361<td><p><span class="term">Requires:</span></p></td> 362<td><p><code class="computeroutput">Concept</code> must contain <a class="link" href="constructible.html" title="Struct template constructible">constructible<T(const T&)></a>. </p></td> 363</tr> 364<tr> 365<td><p><span class="term">Requires:</span></p></td> 366<td><p><code class="computeroutput">Map</code> must be an MPL map with keys for all the non-deduced placeholders used by <code class="computeroutput">Concept</code> and values for the corresponding placeholders in <code class="computeroutput">Concept2</code>. </p></td> 367</tr> 368<tr> 369<td><p><span class="term">Requires:</span></p></td> 370<td><p>After substituting placeholders according to <code class="computeroutput">Map</code>, the requirements of <code class="computeroutput">Concept2</code> must be a superset of the requirements of <code class="computeroutput">Concept</code>.</p></td> 371</tr> 372<tr> 373<td><p><span class="term">Throws:</span></p></td> 374<td>std::bad_alloc or whatever that the copy constructor of the contained type throws. </td> 375</tr> 376</tbody> 377</table></div> 378</li> 379<li class="listitem"> 380<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept2<span class="special">,</span> <span class="keyword">typename</span> Tag2<span class="special">></span> 381 <a name="id-1_3_41_13_1_1_1_1_10-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../any.html" title="Class any">any</a><span class="special"><</span> <span class="identifier">Concept2</span><span class="special">,</span> <span class="identifier">Tag2</span> <span class="special">></span> <span class="special">&</span> other<span class="special">,</span> <span class="keyword">const</span> <a class="link" href="binding.html" title="Class template binding">binding</a><span class="special"><</span> <span class="identifier">Concept</span> <span class="special">></span> <span class="special">&</span> binding<span class="special">)</span><span class="special">;</span></pre> 382<p>Constructs an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> from another <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>.</p> 383<p> 384 385 386 387 388</p> 389<div class="warning"><table border="0" summary="Warning"> 390<tr> 391<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../doc/src/images/warning.png"></td> 392<th align="left">Warning</th> 393</tr> 394<tr><td align="left" valign="top"><p>This constructor is potentially dangerous, as it cannot check at compile time whether the arguments match. </p></td></tr> 395</table></div> 396<p> 397</p> 398<div class="variablelist"><table border="0" class="variablelist compact"> 399<colgroup> 400<col align="left" valign="top"> 401<col> 402</colgroup> 403<tbody> 404<tr> 405<td><p><span class="term">Parameters:</span></p></td> 406<td><div class="variablelist"><table border="0" class="variablelist compact"> 407<colgroup> 408<col align="left" valign="top"> 409<col> 410</colgroup> 411<tbody> 412<tr> 413<td><p><span class="term"><code class="computeroutput">binding</code></span></p></td> 414<td><p>Specifies the bindings of placeholders to actual types.</p></td> 415</tr> 416<tr> 417<td><p><span class="term"><code class="computeroutput">other</code></span></p></td> 418<td><p>The object to make a copy of. </p></td> 419</tr> 420</tbody> 421</table></div></td> 422</tr> 423<tr> 424<td><p><span class="term">Requires:</span></p></td> 425<td><p><code class="computeroutput">Concept</code> must contain <a class="link" href="constructible.html" title="Struct template constructible">constructible<T(const T&)></a>. </p></td> 426</tr> 427<tr> 428<td><p><span class="term">Requires:</span></p></td> 429<td><p>The type stored in <code class="computeroutput">other</code> must match the type expected by <code class="computeroutput">binding</code>.</p></td> 430</tr> 431<tr> 432<td><p><span class="term">Postconditions:</span></p></td> 433<td><p>binding_of(*this) == <code class="computeroutput">binding</code> </p></td> 434</tr> 435<tr> 436<td><p><span class="term">Throws:</span></p></td> 437<td>std::bad_alloc or whatever that the copy constructor of the contained type throws.</td> 438</tr> 439</tbody> 440</table></div> 441</li> 442<li class="listitem"> 443<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> U<span class="special">></span> <span class="keyword">explicit</span> <a name="id-1_3_41_13_1_1_1_1_11-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span><span class="special">...</span> arg<span class="special">)</span><span class="special">;</span></pre> 444<p>Calls a constructor of the contained type. The bindings will be deduced from the arguments.</p> 445<p> 446 447 448 449 450</p> 451<div class="note"><table border="0" summary="Note"> 452<tr> 453<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td> 454<th align="left">Note</th> 455</tr> 456<tr><td align="left" valign="top"><p>This constructor is never chosen if any other constructor can be called instead. </p></td></tr> 457</table></div> 458<p> 459</p> 460<div class="variablelist"><table border="0" class="variablelist compact"> 461<colgroup> 462<col align="left" valign="top"> 463<col> 464</colgroup> 465<tbody> 466<tr> 467<td><p><span class="term">Parameters:</span></p></td> 468<td><div class="variablelist"><table border="0" class="variablelist compact"> 469<colgroup> 470<col align="left" valign="top"> 471<col> 472</colgroup> 473<tbody><tr> 474<td><p><span class="term"><code class="computeroutput">arg</code></span></p></td> 475<td><p>The arguments to be passed to the underlying constructor.</p></td> 476</tr></tbody> 477</table></div></td> 478</tr> 479<tr> 480<td><p><span class="term">Requires:</span></p></td> 481<td><p><code class="computeroutput">Concept</code> must contain an instance of <a class="link" href="constructible.html" title="Struct template constructible">constructible</a> which can be called with these arguments. </p></td> 482</tr> 483<tr> 484<td><p><span class="term">Requires:</span></p></td> 485<td><p>At least one of the arguments must by an <a class="link" href="any.html" title="Class template any">any</a> with the same <code class="computeroutput">Concept</code> as this. </p></td> 486</tr> 487<tr> 488<td><p><span class="term">Requires:</span></p></td> 489<td><p>The bindings of all the arguments that are <a class="link" href="any.html" title="Class template any">any</a>'s, must be the same.</p></td> 490</tr> 491<tr> 492<td><p><span class="term">Throws:</span></p></td> 493<td>std::bad_alloc or whatever that the constructor of the contained type throws.</td> 494</tr> 495</tbody> 496</table></div> 497</li> 498<li class="listitem"> 499<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> U<span class="special">></span> 500 <span class="keyword">explicit</span> <a name="id-1_3_41_13_1_1_1_1_12-bb"></a><span class="identifier">any</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="binding.html" title="Class template binding">binding</a><span class="special"><</span> <span class="identifier">Concept</span> <span class="special">></span> <span class="special">&</span> binding<span class="special">,</span> <span class="identifier">U</span> <span class="special">&&</span><span class="special">...</span> arg<span class="special">)</span><span class="special">;</span></pre> 501<p>Calls a constructor of the contained type.</p> 502<p> 503 504 505 506 507</p> 508<div class="variablelist"><table border="0" class="variablelist compact"> 509<colgroup> 510<col align="left" valign="top"> 511<col> 512</colgroup> 513<tbody> 514<tr> 515<td><p><span class="term">Parameters:</span></p></td> 516<td><div class="variablelist"><table border="0" class="variablelist compact"> 517<colgroup> 518<col align="left" valign="top"> 519<col> 520</colgroup> 521<tbody> 522<tr> 523<td><p><span class="term"><code class="computeroutput">arg</code></span></p></td> 524<td><p>The arguments to be passed to the underlying constructor.</p></td> 525</tr> 526<tr> 527<td><p><span class="term"><code class="computeroutput">binding</code></span></p></td> 528<td><p>Specifies the bindings of placeholders to actual types. </p></td> 529</tr> 530</tbody> 531</table></div></td> 532</tr> 533<tr> 534<td><p><span class="term">Requires:</span></p></td> 535<td><p><code class="computeroutput">Concept</code> must contain a matching instance of <a class="link" href="constructible.html" title="Struct template constructible">constructible</a>. </p></td> 536</tr> 537<tr> 538<td><p><span class="term">Requires:</span></p></td> 539<td><p>The contained type of every argument that is an <a class="link" href="any.html" title="Class template any">any</a>, must be the same as that specified by <code class="computeroutput">binding</code>.</p></td> 540</tr> 541<tr> 542<td><p><span class="term">Postconditions:</span></p></td> 543<td><p>binding_of(*this) == <code class="computeroutput">binding</code> </p></td> 544</tr> 545<tr> 546<td><p><span class="term">Throws:</span></p></td> 547<td>std::bad_alloc or whatever that the constructor of the contained type throws. </td> 548</tr> 549</tbody> 550</table></div> 551</li> 552<li class="listitem"> 553<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a class="link" href="../any.html" title="Class any">any</a> <span class="special">&</span> <a name="id-1_3_41_13_1_1_1_1_13-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="identifier">U</span> <span class="special">&&</span> other<span class="special">)</span><span class="special">;</span></pre> 554<p>Assigns to an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>.</p> 555<p>If an appropriate overload of <code class="computeroutput"><a class="link" href="assignable.html" title="Struct template assignable">assignable</a></code> is not available and <code class="computeroutput"><a class="link" href="relaxed.html" title="Struct relaxed">relaxed</a></code> is in <code class="computeroutput">Concept</code>, falls back on constructing from <code class="computeroutput">other</code>.</p> 556<div class="note"><table border="0" summary="Note"> 557<tr> 558<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td> 559<th align="left">Note</th> 560</tr> 561<tr><td align="left" valign="top"><p>If <code class="computeroutput">U</code> is an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>, then this can decide dynamically whether to use construction based on the type stored in other.</p></td></tr> 562</table></div> 563<p> 564 565</p> 566<div class="variablelist"><table border="0" class="variablelist compact"> 567<colgroup> 568<col align="left" valign="top"> 569<col> 570</colgroup> 571<tbody><tr> 572<td><p><span class="term">Throws:</span></p></td> 573<td>Whatever the assignment operator of the contained type throws. When falling back on construction, throws <code class="computeroutput">std::bad_alloc</code> or whatever the move (or copy) constructor of the contained type throws. In this case move assignment provides the strong exception guarantee. When calling a (move) assignment operator of the contained type, the exception guarantee is whatever the contained type provides. </td> 574</tr></tbody> 575</table></div> 576</li> 577<li class="listitem"> 578<pre class="literallayout"><a name="id-1_3_41_13_1_1_1_1_14-bb"></a><span class="special">~</span><span class="identifier">any</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre> 579<p> 580</p> 581<div class="variablelist"><table border="0" class="variablelist compact"> 582<colgroup> 583<col align="left" valign="top"> 584<col> 585</colgroup> 586<tbody><tr> 587<td><p><span class="term">Requires:</span></p></td> 588<td><p><code class="computeroutput">Concept</code> includes <a class="link" href="destructible.html" title="Struct template destructible">destructible<T></a>. </p></td> 589</tr></tbody> 590</table></div> 591</li> 592</ol></div> 593</div> 594<div class="refsect2"> 595<a name="id-1.3.41.13.2.3.4.6"></a><h3>Specializations</h3> 596<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 597<li class="listitem"><p><a class="link" href="any_Conc_1_3_41_13_1_1_1_2.html" title="Class template any<Concept, const T &>">Class template any<Concept, const T &></a></p></li> 598<li class="listitem"><p><a class="link" href="any_Conc_1_3_41_13_1_1_1_3.html" title="Class template any<Concept, T &>">Class template any<Concept, T &></a></p></li> 599<li class="listitem"><p><a class="link" href="any_Conc_1_3_41_13_1_1_1_4.html" title="Class template any<Concept, T &&>">Class template any<Concept, T &&></a></p></li> 600</ul></div> 601</div> 602</div> 603</div> 604<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 605<td align="left"></td> 606<td align="right"><div class="copyright-footer">Copyright © 2011-2013 Steven Watanabe<p> 607 Distributed under the Boost Software License, Version 1.0. (See accompanying 608 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 609 </p> 610</div></td> 611</tr></table> 612<hr> 613<div class="spirit-nav"> 614<a accesskey="p" href="../../boost_typeerasure/reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_typeerasure/reference.html#header.boost.type_erasure.any_hpp"><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="any_Conc_1_3_41_13_1_1_1_2.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 615</div> 616</body> 617</html> 618