| [12] | 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
|---|
| 4 | <title>Miscellaneous Notes</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="../variant.html" title="Chapter 15. 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%"> |
|---|
| 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="design.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../variant.html"><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="refs.html"><img src="../images/next.png" alt="Next"></a> |
|---|
| 24 | </div> |
|---|
| 25 | <div class="section" lang="en"> |
|---|
| 26 | <div class="titlepage"><div><div><h3 class="title"> |
|---|
| 27 | <a name="variant.misc"></a>Miscellaneous Notes</h3></div></div></div> |
|---|
| 28 | <div class="toc"><dl> |
|---|
| 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#id2841449">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" lang="en"> |
|---|
| 35 | <div class="titlepage"><div><div><h4 class="title"> |
|---|
| 36 | <a name="variant.versus-any"></a>Boost.Variant vs. Boost.Any</h4></div></div></div> |
|---|
| 37 | <p>As a discriminated union container, the Variant library shares many |
|---|
| 38 | of the same features of the <a href="../any.html" title="Chapter 1. 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 type="disc"> |
|---|
| 47 | <li>Boost.Variant guarantees the type of its content is one of a |
|---|
| 48 | finite, user-specified set of types.</li> |
|---|
| 49 | <li>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>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>Boost.Variant offers an efficient, stack-based storage scheme |
|---|
| 57 | (avoiding the overhead of dynamic allocation).</li> |
|---|
| 58 | </ul></div> |
|---|
| 59 | <p>Of course, Boost.Any has several advantages over Boost.Variant, |
|---|
| 60 | such as: |
|---|
| 61 | |
|---|
| 62 | </p> |
|---|
| 63 | <div class="itemizedlist"><ul type="disc"> |
|---|
| 64 | <li>Boost.Any, as its name implies, allows virtually any type for |
|---|
| 65 | its content, providing great flexibility.</li> |
|---|
| 66 | <li>Boost.Any provides the no-throw guarantee of exception safety |
|---|
| 67 | for its swap operation.</li> |
|---|
| 68 | <li>Boost.Any makes little use of template metaprogramming |
|---|
| 69 | techniques (avoiding potentially hard-to-read error messages and |
|---|
| 70 | significant compile-time processor and memory demands).</li> |
|---|
| 71 | </ul></div> |
|---|
| 72 | </div> |
|---|
| 73 | <div class="section" lang="en"> |
|---|
| 74 | <div class="titlepage"><div><div><h4 class="title"> |
|---|
| 75 | <a name="id2841449"></a>Portability</h4></div></div></div> |
|---|
| 76 | <p>The library aims for 100% ANSI/ISO C++ conformance. However, this is |
|---|
| 77 | strictly impossible due to the inherently non-portable nature of the |
|---|
| 78 | Type Traits library's |
|---|
| 79 | <code class="computeroutput">type_with_alignment</code> facility. In |
|---|
| 80 | practice though, no compilers or platforms have been discovered where this |
|---|
| 81 | reliance on undefined behavior has been an issue.</p> |
|---|
| 82 | <p>Additionally, significant effort has been expended to ensure proper |
|---|
| 83 | functioning despite various compiler bugs and other conformance problems. |
|---|
| 84 | To date the library testsuite has |
|---|
| 85 | been compiled and tested successfully on at least the following compilers |
|---|
| 86 | for basic and advanced functionality: |
|---|
| 87 | |
|---|
| 88 | </p> |
|---|
| 89 | <div class="informaltable"><table class="table"> |
|---|
| 90 | <colgroup> |
|---|
| 91 | <col> |
|---|
| 92 | <col> |
|---|
| 93 | <col> |
|---|
| 94 | <col> |
|---|
| 95 | <col> |
|---|
| 96 | </colgroup> |
|---|
| 97 | <thead><tr> |
|---|
| 98 | <th> </th> |
|---|
| 99 | <th>Basic</th> |
|---|
| 100 | <th><code class="computeroutput">variant<T&></code></th> |
|---|
| 101 | <th><a href="tutorial.html#variant.tutorial.over-sequence" title="Using a type sequence to specify bounded types"><code class="computeroutput">make_variant_over</code></a></th> |
|---|
| 102 | <th><a href="tutorial.html#variant.tutorial.recursive.recursive-variant" title="Recursive types with make_recursive_variant"><code class="computeroutput">make_recursive_variant</code></a></th> |
|---|
| 103 | </tr></thead> |
|---|
| 104 | <tbody> |
|---|
| 105 | <tr> |
|---|
| 106 | <td>Borland C++ 5.5.1 and 5.6.4</td> |
|---|
| 107 | <td>X</td> |
|---|
| 108 | <td>X</td> |
|---|
| 109 | <td> </td> |
|---|
| 110 | <td> </td> |
|---|
| 111 | </tr> |
|---|
| 112 | <tr> |
|---|
| 113 | <td>Comeau C++ 4.3.0</td> |
|---|
| 114 | <td>X</td> |
|---|
| 115 | <td>X</td> |
|---|
| 116 | <td>X</td> |
|---|
| 117 | <td>X</td> |
|---|
| 118 | </tr> |
|---|
| 119 | <tr> |
|---|
| 120 | <td>GNU GCC 3.3.1</td> |
|---|
| 121 | <td>X</td> |
|---|
| 122 | <td>X</td> |
|---|
| 123 | <td>X</td> |
|---|
| 124 | <td>X</td> |
|---|
| 125 | </tr> |
|---|
| 126 | <tr> |
|---|
| 127 | <td>GNU GCC 2.95.3</td> |
|---|
| 128 | <td>X</td> |
|---|
| 129 | <td>X</td> |
|---|
| 130 | <td> </td> |
|---|
| 131 | <td>X</td> |
|---|
| 132 | </tr> |
|---|
| 133 | <tr> |
|---|
| 134 | <td>Intel C++ 7.0</td> |
|---|
| 135 | <td>X</td> |
|---|
| 136 | <td> </td> |
|---|
| 137 | <td>X</td> |
|---|
| 138 | <td>X</td> |
|---|
| 139 | </tr> |
|---|
| 140 | <tr> |
|---|
| 141 | <td>Metrowerks CodeWarrior 8.3</td> |
|---|
| 142 | <td>X</td> |
|---|
| 143 | <td> </td> |
|---|
| 144 | <td>X</td> |
|---|
| 145 | <td>X</td> |
|---|
| 146 | </tr> |
|---|
| 147 | <tr> |
|---|
| 148 | <td>Microsoft Visual C++ 7.1</td> |
|---|
| 149 | <td>X</td> |
|---|
| 150 | <td>X</td> |
|---|
| 151 | <td>X</td> |
|---|
| 152 | <td>X</td> |
|---|
| 153 | </tr> |
|---|
| 154 | <tr> |
|---|
| 155 | <td>Microsoft Visual C++ 6 SP5 and 7</td> |
|---|
| 156 | <td>X</td> |
|---|
| 157 | <td> </td> |
|---|
| 158 | <td> </td> |
|---|
| 159 | <td> </td> |
|---|
| 160 | </tr> |
|---|
| 161 | </tbody> |
|---|
| 162 | </table></div> |
|---|
| 163 | <p>Finally, the current state of the testsuite in CVS may be found on the |
|---|
| 164 | <a href="http://boost.sourceforge.net/regression-logs" target="_top">Test Summary</a> |
|---|
| 165 | page. Please note, however, that this page reports on day-to-day changes |
|---|
| 166 | to inter-release code found in the Boost CVS and thus likely does not |
|---|
| 167 | match the state of code found in Boost releases.</p> |
|---|
| 168 | </div> |
|---|
| 169 | <div class="section" lang="en"> |
|---|
| 170 | <div class="titlepage"><div><div><h4 class="title"> |
|---|
| 171 | <a name="variant.troubleshooting"></a>Troubleshooting</h4></div></div></div> |
|---|
| 172 | <div class="toc"><dl> |
|---|
| 173 | <dt><span class="section"><a href="misc.html#variant.troubleshooting.template-depth">"Template instantiation depth exceeds maximum"</a></span></dt> |
|---|
| 174 | <dt><span class="section"><a href="misc.html#variant.troubleshooting.compiler-memory">"Internal heap limit reached"</a></span></dt> |
|---|
| 175 | </dl></div> |
|---|
| 176 | <p>Due to the heavy use of templates in the implementation of |
|---|
| 177 | <code class="computeroutput">variant</code>, it is not uncommon when compiling to encounter |
|---|
| 178 | problems related to template instantiaton depth, compiler memory, etc. This |
|---|
| 179 | section attempts to provide advice to common problems experienced on several |
|---|
| 180 | popular compilers.</p> |
|---|
| 181 | <p>(This section is still in progress, with additional advice/feedback |
|---|
| 182 | welcome. Please post to the Boost-Users list with any useful experiences you |
|---|
| 183 | may have.)</p> |
|---|
| 184 | <div class="section" lang="en"> |
|---|
| 185 | <div class="titlepage"><div><div><h5 class="title"> |
|---|
| 186 | <a name="variant.troubleshooting.template-depth"></a>"Template instantiation depth exceeds maximum"</h5></div></div></div> |
|---|
| 187 | <div class="toc"><dl><dt><span class="section"><a href="misc.html#variant.troubleshooting.template-depth.gcc">GNU GCC</a></span></dt></dl></div> |
|---|
| 188 | <div class="section" lang="en"> |
|---|
| 189 | <div class="titlepage"><div><div><h6 class="title"> |
|---|
| 190 | <a name="variant.troubleshooting.template-depth.gcc"></a>GNU GCC</h6></div></div></div> |
|---|
| 191 | <p>The compiler option |
|---|
| 192 | <code class="computeroutput">-ftemplate-depth-<span class="emphasis"><em>NN</em></span></code> can increase the |
|---|
| 193 | maximum allowed instantiation depth. (Try |
|---|
| 194 | <code class="computeroutput">-ftemplate-depth-50</code>.)</p> |
|---|
| 195 | </div> |
|---|
| 196 | </div> |
|---|
| 197 | <div class="section" lang="en"> |
|---|
| 198 | <div class="titlepage"><div><div><h5 class="title"> |
|---|
| 199 | <a name="variant.troubleshooting.compiler-memory"></a>"Internal heap limit reached"</h5></div></div></div> |
|---|
| 200 | <div class="toc"><dl><dt><span class="section"><a href="misc.html#variant.troubleshooting.compiler-memory.msvc">Microsoft Visual C++</a></span></dt></dl></div> |
|---|
| 201 | <div class="section" lang="en"> |
|---|
| 202 | <div class="titlepage"><div><div><h6 class="title"> |
|---|
| 203 | <a name="variant.troubleshooting.compiler-memory.msvc"></a>Microsoft Visual C++</h6></div></div></div> |
|---|
| 204 | <p>The compiler option <code class="computeroutput">/Zm<span class="emphasis"><em>NNN</em></span></code> can |
|---|
| 205 | increase the memory allocation limit. The <code class="computeroutput">NNN</code> is a |
|---|
| 206 | scaling percentage (i.e., <code class="computeroutput">100</code> denotes the default limit). |
|---|
| 207 | (Try <code class="computeroutput">/Zm200</code>.)</p> |
|---|
| 208 | </div> |
|---|
| 209 | </div> |
|---|
| 210 | </div> |
|---|
| 211 | <div class="section" lang="en"> |
|---|
| 212 | <div class="titlepage"><div><div><h4 class="title"> |
|---|
| 213 | <a name="variant.ack"></a>Acknowledgments</h4></div></div></div> |
|---|
| 214 | <p>Eric Friedman and Itay Maman designed the initial submission; Eric was |
|---|
| 215 | the primary implementer.</p> |
|---|
| 216 | <p>Eric is also the library maintainer and has expanded upon the initial |
|---|
| 217 | submission -- adding |
|---|
| 218 | <code class="computeroutput"><a href="../make_recursive_variant.html" title="Class template make_recursive_variant">make_recursive_variant</a></code>, |
|---|
| 219 | <code class="computeroutput"><a href="../make_variant_over.html" title="Class template make_variant_over">make_variant_over</a></code>, support for |
|---|
| 220 | reference content, etc.</p> |
|---|
| 221 | <p>Andrei Alexandrescu's work in |
|---|
| 222 | [<a href="refs.html#variant.refs.ale01a">Ale01a</a>] |
|---|
| 223 | and |
|---|
| 224 | [<a href="refs.html#variant.refs.ale02">Ale02</a>] |
|---|
| 225 | inspired the library's design.</p> |
|---|
| 226 | <p>Jeff Garland was the formal review manager.</p> |
|---|
| 227 | <p>Douglas Gregor, |
|---|
| 228 | Dave Abrahams, |
|---|
| 229 | Anthony Williams, |
|---|
| 230 | Fernando Cacciola, |
|---|
| 231 | Joel de Guzman, |
|---|
| 232 | Dirk Schreib, |
|---|
| 233 | Brad King, |
|---|
| 234 | Giovanni Bajo, |
|---|
| 235 | Eugene Gladyshev, |
|---|
| 236 | and others provided helpful feedback and suggestions to refine the semantics, |
|---|
| 237 | interface, and implementation of the library.</p> |
|---|
| 238 | </div> |
|---|
| 239 | </div> |
|---|
| 240 | <table width="100%"><tr> |
|---|
| 241 | <td align="left"></td> |
|---|
| 242 | <td align="right"><small>Copyright © 2002, 2003 Eric Friedman, Itay Maman</small></td> |
|---|
| 243 | </tr></table> |
|---|
| 244 | <hr> |
|---|
| 245 | <div class="spirit-nav"> |
|---|
| 246 | <a accesskey="p" href="design.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../variant.html"><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="refs.html"><img src="../images/next.png" alt="Next"></a> |
|---|
| 247 | </div> |
|---|
| 248 | </body> |
|---|
| 249 | </html> |
|---|