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