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 38. Boost.Variant">
9 <link rel="prev" href="design.html" title="Design Overview">
10 <link rel="next" href="refs.html" title="References">
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>
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>
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>
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 3. 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
42 <p>That said, Boost.Variant has several advantages over Boost.Any,
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>
62 <p>Of course, Boost.Any has several advantages over Boost.Variant,
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>
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
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:
95 <div class="informaltable"><table class="table">
107 <code class="computeroutput">variant<T&></code>
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>
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>
122 <td>Borland C++ 5.5.1 and 5.6.4</td>
129 <td>Comeau C++ 4.3.0</td>
136 <td>GNU GCC 3.3.1</td>
143 <td>GNU GCC 2.95.3</td>
150 <td>Intel C++ 7.0</td>
157 <td>Metrowerks CodeWarrior 8.3</td>
164 <td>Microsoft Visual C++ 7.1</td>
171 <td>Microsoft Visual C++ 6 SP5 and 7</td>
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>
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>
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
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>
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>
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
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>]
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>
255 and others provided helpful feedback and suggestions to refine the semantics,
256 interface, and implementation of the library.</p>
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 © 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>)
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>