Imported Upstream version 1.57.0
[platform/upstream/boost.git] / doc / html / variant / misc.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Miscellaneous Notes</title>
5 <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8 <link rel="up" href="../variant.html" title="Chapter&#160;38.&#160;Boost.Variant">
9 <link rel="prev" href="design.html" title="Design Overview">
10 <link rel="next" href="refs.html" title="References">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
15 <td align="center"><a href="../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="design.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../variant.html"><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="refs.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="variant.misc"></a>Miscellaneous Notes</h2></div></div></div>
28 <div class="toc"><dl class="toc">
29 <dt><span class="section"><a href="misc.html#variant.versus-any">Boost.Variant vs. Boost.Any</a></span></dt>
30 <dt><span class="section"><a href="misc.html#idp525417744">Portability</a></span></dt>
31 <dt><span class="section"><a href="misc.html#variant.troubleshooting">Troubleshooting</a></span></dt>
32 <dt><span class="section"><a href="misc.html#variant.ack">Acknowledgments</a></span></dt>
33 </dl></div>
34 <div class="section">
35 <div class="titlepage"><div><div><h3 class="title">
36 <a name="variant.versus-any"></a>Boost.Variant vs. Boost.Any</h3></div></div></div>
37 <p>As a discriminated union container, the Variant library shares many
38     of the same features of the <a class="link" href="../any.html" title="Chapter&#160;3.&#160;Boost.Any">Any</a> library.
39     However, since neither library wholly encapsulates the features of the
40     other, one library cannot be generally recommended for use over the
41     other.</p>
42 <p>That said, Boost.Variant has several advantages over Boost.Any,
43     such as:
44
45     </p>
46 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
47 <li class="listitem">Boost.Variant guarantees the type of its content is one of a
48         finite, user-specified set of types.</li>
49 <li class="listitem">Boost.Variant provides <span class="emphasis"><em>compile-time</em></span>
50         checked visitation of its content. (By contrast, the current version
51         of Boost.Any provides no visitation mechanism at all; but even if it
52         did, it would need to be checked at run-time.)</li>
53 <li class="listitem">Boost.Variant enables generic visitation of its content.
54         (Even if Boost.Any did provide a visitation mechanism, it would enable
55         visitation only of explicitly-specified types.)</li>
56 <li class="listitem">Boost.Variant offers an efficient, stack-based storage scheme
57         (avoiding the overhead of dynamic allocation).</li>
58 </ul></div>
59 <p>
60
61   </p>
62 <p>Of course, Boost.Any has several advantages over Boost.Variant,
63     such as:
64
65     </p>
66 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
67 <li class="listitem">Boost.Any, as its name implies, allows virtually any type for
68         its content, providing great flexibility.</li>
69 <li class="listitem">Boost.Any provides the no-throw guarantee of exception safety
70         for its swap operation.</li>
71 <li class="listitem">Boost.Any makes little use of template metaprogramming
72         techniques (avoiding potentially hard-to-read error messages and
73         significant compile-time processor and memory demands).</li>
74 </ul></div>
75 <p>
76
77   </p>
78 </div>
79 <div class="section">
80 <div class="titlepage"><div><div><h3 class="title">
81 <a name="idp525417744"></a>Portability</h3></div></div></div>
82 <p>The library aims for 100% ANSI/ISO C++ conformance. However, this is
83     strictly impossible due to the inherently non-portable nature of the
84     Type Traits library's
85     <code class="computeroutput">type_with_alignment</code> facility. In
86     practice though, no compilers or platforms have been discovered where this
87     reliance on undefined behavior has been an issue.</p>
88 <p>Additionally, significant effort has been expended to ensure proper
89     functioning despite various compiler bugs and other conformance problems.
90     To date the library testsuite has
91     been compiled and tested successfully on at least the following compilers
92     for basic and advanced functionality:
93
94     </p>
95 <div class="informaltable"><table class="table">
96 <colgroup>
97 <col>
98 <col>
99 <col>
100 <col>
101 <col>
102 </colgroup>
103 <thead><tr>
104 <th>&#160;</th>
105 <th>Basic</th>
106 <th>
107               <code class="computeroutput">variant&lt;T&amp;&gt;</code>
108             </th>
109 <th>
110               <a class="link" href="tutorial.html#variant.tutorial.over-sequence" title="Using a type sequence to specify bounded types">
111                 <code class="computeroutput">make_variant_over</code>
112               </a>
113             </th>
114 <th>
115               <a class="link" href="tutorial.html#variant.tutorial.recursive.recursive-variant" title="Recursive types with make_recursive_variant">
116                 <code class="computeroutput">make_recursive_variant</code>
117               </a>
118             </th>
119 </tr></thead>
120 <tbody>
121 <tr>
122 <td>Borland C++ 5.5.1 and 5.6.4</td>
123 <td>X</td>
124 <td>X</td>
125 <td>&#160;</td>
126 <td>&#160;</td>
127 </tr>
128 <tr>
129 <td>Comeau C++ 4.3.0</td>
130 <td>X</td>
131 <td>X</td>
132 <td>X</td>
133 <td>X</td>
134 </tr>
135 <tr>
136 <td>GNU GCC 3.3.1</td>
137 <td>X</td>
138 <td>X</td>
139 <td>X</td>
140 <td>X</td>
141 </tr>
142 <tr>
143 <td>GNU GCC 2.95.3</td>
144 <td>X</td>
145 <td>X</td>
146 <td>&#160;</td>
147 <td>X</td>
148 </tr>
149 <tr>
150 <td>Intel C++ 7.0</td>
151 <td>X</td>
152 <td>&#160;</td>
153 <td>X</td>
154 <td>X</td>
155 </tr>
156 <tr>
157 <td>Metrowerks CodeWarrior 8.3</td>
158 <td>X</td>
159 <td>&#160;</td>
160 <td>X</td>
161 <td>X</td>
162 </tr>
163 <tr>
164 <td>Microsoft Visual C++ 7.1</td>
165 <td>X</td>
166 <td>X</td>
167 <td>X</td>
168 <td>X</td>
169 </tr>
170 <tr>
171 <td>Microsoft Visual C++ 6 SP5 and 7</td>
172 <td>X</td>
173 <td>&#160;</td>
174 <td>&#160;</td>
175 <td>&#160;</td>
176 </tr>
177 </tbody>
178 </table></div>
179 <p>
180
181   </p>
182 <p>Finally, the current state of the testsuite in CVS may be found on the
183     <a href="http://boost.sourceforge.net/regression-logs" target="_top">Test Summary</a>
184     page. Please note, however, that this page reports on day-to-day changes
185     to inter-release code found in the Boost CVS and thus likely does not
186     match the state of code found in Boost releases.</p>
187 </div>
188 <div class="section">
189 <div class="titlepage"><div><div><h3 class="title">
190 <a name="variant.troubleshooting"></a>Troubleshooting</h3></div></div></div>
191 <div class="toc"><dl class="toc">
192 <dt><span class="section"><a href="misc.html#variant.troubleshooting.template-depth">"Template instantiation depth exceeds maximum"</a></span></dt>
193 <dt><span class="section"><a href="misc.html#variant.troubleshooting.compiler-memory">"Internal heap limit reached"</a></span></dt>
194 </dl></div>
195 <p>Due to the heavy use of templates in the implementation of
196   <code class="computeroutput">variant</code>, it is not uncommon when compiling to encounter
197   problems related to template instantiaton depth, compiler memory, etc. This
198   section attempts to provide advice to common problems experienced on several
199   popular compilers.</p>
200 <p>(This section is still in progress, with additional advice/feedback
201   welcome. Please post to the Boost-Users list with any useful experiences you
202   may have.)</p>
203 <div class="section">
204 <div class="titlepage"><div><div><h4 class="title">
205 <a name="variant.troubleshooting.template-depth"></a>"Template instantiation depth exceeds maximum"</h4></div></div></div>
206 <div class="toc"><dl class="toc"><dt><span class="section"><a href="misc.html#variant.troubleshooting.template-depth.gcc">GNU GCC</a></span></dt></dl></div>
207 <div class="section">
208 <div class="titlepage"><div><div><h5 class="title">
209 <a name="variant.troubleshooting.template-depth.gcc"></a>GNU GCC</h5></div></div></div>
210 <p>The compiler option
211         <code class="computeroutput">-ftemplate-depth-<span class="emphasis"><em>NN</em></span></code> can increase the
212         maximum allowed instantiation depth. (Try
213         <code class="computeroutput">-ftemplate-depth-50</code>.)</p>
214 </div>
215 </div>
216 <div class="section">
217 <div class="titlepage"><div><div><h4 class="title">
218 <a name="variant.troubleshooting.compiler-memory"></a>"Internal heap limit reached"</h4></div></div></div>
219 <div class="toc"><dl class="toc"><dt><span class="section"><a href="misc.html#variant.troubleshooting.compiler-memory.msvc">Microsoft Visual C++</a></span></dt></dl></div>
220 <div class="section">
221 <div class="titlepage"><div><div><h5 class="title">
222 <a name="variant.troubleshooting.compiler-memory.msvc"></a>Microsoft Visual C++</h5></div></div></div>
223 <p>The compiler option <code class="computeroutput">/Zm<span class="emphasis"><em>NNN</em></span></code> can
224         increase the memory allocation limit. The <code class="computeroutput">NNN</code> is a
225         scaling percentage (i.e., <code class="computeroutput">100</code> denotes the default limit).
226         (Try <code class="computeroutput">/Zm200</code>.)</p>
227 </div>
228 </div>
229 </div>
230 <div class="section">
231 <div class="titlepage"><div><div><h3 class="title">
232 <a name="variant.ack"></a>Acknowledgments</h3></div></div></div>
233 <p>Eric Friedman and Itay Maman designed the initial submission; Eric was
234   the primary implementer.</p>
235 <p>Eric is also the library maintainer and has expanded upon the initial
236   submission -- adding
237   <code class="computeroutput"><a class="link" href="../boost/make_recursive_variant.html" title="Class template make_recursive_variant">make_recursive_variant</a></code>,
238   <code class="computeroutput"><a class="link" href="../boost/make_variant_over.html" title="Class template make_variant_over">make_variant_over</a></code>, support for
239   reference content, etc.</p>
240 <p>Andrei Alexandrescu's work in
241     [<a class="link" href="refs.html#variant.refs.ale01a">Ale01a</a>]
242 and
243     [<a class="link" href="refs.html#variant.refs.ale02">Ale02</a>]
244 inspired the library's design.</p>
245 <p>Jeff Garland was the formal review manager.</p>
246 <p>Douglas Gregor,
247 Dave Abrahams,
248 Anthony Williams,
249 Fernando Cacciola,
250 Joel de Guzman,
251 Dirk Schreib,
252 Brad King,
253 Giovanni Bajo,
254 Eugene Gladyshev,
255 and others provided helpful feedback and suggestions to refine the semantics,
256 interface, and implementation of the library.</p>
257 </div>
258 </div>
259 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
260 <td align="left"></td>
261 <td align="right"><div class="copyright-footer">Copyright &#169; 2002, 2003 Eric Friedman, Itay Maman<p>Distributed under the Boost Software License, Version 1.0.
262     (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at 
263     <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
264     </p>
265 </div></td>
266 </tr></table>
267 <hr>
268 <div class="spirit-nav">
269 <a accesskey="p" href="design.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../variant.html"><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="refs.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
270 </div>
271 </body>
272 </html>